@sgrs/client-ts — TypeScript client for the SGRS governance platform
Unified HTTP + optional NATS real-time event transport.
HTTP-only usage (no nats package required):
import { createClient } from '@sgrs/client-ts';const client = createClient({ baseUrl: 'http://localhost:3003' });const result = await client.scopes.list(); Copy
import { createClient } from '@sgrs/client-ts';const client = createClient({ baseUrl: 'http://localhost:3003' });const result = await client.scopes.list();
With real-time NATS events (requires: npm install nats):
import { createClient } from '@sgrs/client-ts';const client = createClient({ baseUrl: 'http://localhost:3003', nats: { servers: 'nats://localhost:4222' },});await client.connect();// CRITICAL PATH — veto propagation to all swarm agentsclient.events.onVetoActivated('acme', (event) => { console.log('Veto raised by', event.activatedBy);});// Finality convergenceclient.events.onFinalityFinal('acme', 'scope-1', (event) => { console.log('Converged at round', event.round);});await client.close(); // drain + disconnect Copy
import { createClient } from '@sgrs/client-ts';const client = createClient({ baseUrl: 'http://localhost:3003', nats: { servers: 'nats://localhost:4222' },});await client.connect();// CRITICAL PATH — veto propagation to all swarm agentsclient.events.onVetoActivated('acme', (event) => { console.log('Veto raised by', event.activatedBy);});// Finality convergenceclient.events.onFinalityFinal('acme', 'scope-1', (event) => { console.log('Converged at round', event.round);});await client.close(); // drain + disconnect
Create a new SGRS API client with the given configuration.
@sgrs/client-ts — TypeScript client for the SGRS governance platform
Unified HTTP + optional NATS real-time event transport.
HTTP-only usage (no nats package required):
With real-time NATS events (requires: npm install nats):