SDK — Agent Operations

View as Markdown

Source: packages/sdk/src/agents.ts.

SDK methodEndpoint
registerAgent(params)POST /api/v1/agents
getAgent(did)GET /api/v1/agents/{did}
updateAgent(did, updates)PUT /api/v1/agents/{did}
decommissionAgent(did)DELETE /api/v1/agents/{did}
getAgentCard(did)GET /.well-known/agent.json?did=…
issueAgentDelegation(params)POST /api/v1/agents/{delegatorDid}/delegate
verifyDelegationChain(chain)POST /api/v1/delegations/verify-chain
discoverAgents(query)GET /api/v1/agents/discover?…
getAuditLog(did, limit?, offset?)GET /api/v1/agents/{did}/audit-log?…

RegisterAgentParams (mapping note)

autonomyLevel accepts a string (Intern, Junior, Senior, Principal); the SDK maps to the integer expected by the API (Intern→0, Junior→2, Senior→3, Principal→4; see agents.ts:157-165). If you pass an unknown level, it falls through to 0 (Intern).

⚠️ Known SDK gap (v1.x): the helper enum skips autonomy level 1. If you need level 1 (“Apprentice”), pass the integer literal 1 directly. Tracked as an SDK issue.

1const agent = await client.registerAgent({
2 operator: 'did:adi:human…',
3 name: 'Shopping Assistant',
4 modelInfo: { provider: 'OpenAI', name: 'gpt-4o', version: '2026-03-01' },
5 capabilities: ['shopping', 'price-comparison'],
6 autonomyLevel: 'Junior',
7 services: [{ id: '#a2a-1', type: 'A2AEndpoint', serviceEndpoint: 'https://agent.example.com/a2a' }],
8});

Issuing a delegation (IBCT)

1const delegation = await operatorClient.issueAgentDelegation({
2 delegatorDid: 'did:adi:human…',
3 agentDid: agent.did,
4 scope: {
5 actions: ['shopping.search', 'shopping.purchase'],
6 resources: ['catalog:eu-grocery/*'],
7 constraints: { region: 'EU' },
8 budget: { maxAmount: 50, currency: 'GBP', period: '7D' },
9 expiry: '2026-12-31T23:59:59Z',
10 },
11});

The SDK serialises actions joined by comma into the API’s capability field (see agents.ts:97-98) — the API normalises back to an array on the server side.

Verifying a chain

1const chain = await client.discoverAgents({ capability: 'shopping.purchase', limit: 1 });
2// fetch the chain via /agents/{did}/delegation-chain or build manually
3const result = await client.verifyDelegationChain({
4 rootDelegator: 'did:adi:human…',
5 leafAgent: agent.did,
6 hops: [/* … */],
7 effectiveScope: {/* … */},
8 depth: 2,
9});
10console.log('Chain valid?', result.valid);