@vorim/sdk 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +263 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +387 -2
- package/dist/index.d.ts +387 -2
- package/dist/index.js +252 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.cjs +108 -4
- package/dist/integrations/anthropic.cjs.map +1 -1
- package/dist/integrations/anthropic.d.cts +13 -2
- package/dist/integrations/anthropic.d.ts +13 -2
- package/dist/integrations/anthropic.js +96 -4
- package/dist/integrations/anthropic.js.map +1 -1
- package/dist/integrations/crewai.cjs +8 -2
- package/dist/integrations/crewai.cjs.map +1 -1
- package/dist/integrations/crewai.d.cts +18 -0
- package/dist/integrations/crewai.d.ts +18 -0
- package/dist/integrations/crewai.js +8 -2
- package/dist/integrations/crewai.js.map +1 -1
- package/dist/integrations/langchain.cjs +140 -10
- package/dist/integrations/langchain.cjs.map +1 -1
- package/dist/integrations/langchain.d.cts +23 -2
- package/dist/integrations/langchain.d.ts +23 -2
- package/dist/integrations/langchain.js +128 -10
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/llamaindex.cjs +96 -4
- package/dist/integrations/llamaindex.cjs.map +1 -1
- package/dist/integrations/llamaindex.d.cts +7 -1
- package/dist/integrations/llamaindex.d.ts +7 -1
- package/dist/integrations/llamaindex.js +84 -4
- package/dist/integrations/llamaindex.js.map +1 -1
- package/dist/integrations/openai.cjs +108 -4
- package/dist/integrations/openai.cjs.map +1 -1
- package/dist/integrations/openai.d.cts +15 -2
- package/dist/integrations/openai.d.ts +15 -2
- package/dist/integrations/openai.js +96 -4
- package/dist/integrations/openai.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -52,6 +52,99 @@ interface AuditEventInput {
|
|
|
52
52
|
error_code?: string;
|
|
53
53
|
signature?: string;
|
|
54
54
|
metadata?: Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Replayable agent decision evidence (VAIP -02 schema fields).
|
|
57
|
+
*
|
|
58
|
+
* Stored and exported but NOT covered by the v0 canonical signature
|
|
59
|
+
* form. They will enter canonical bytes in v1 (RFC 8785 JCS) in a
|
|
60
|
+
* follow-up release. Until then, advisory.
|
|
61
|
+
*
|
|
62
|
+
* Use the helpers from this package to compute the hashes:
|
|
63
|
+
* - {@link hashToolCatalogue}
|
|
64
|
+
* - {@link hashSystemPrompt}
|
|
65
|
+
*/
|
|
66
|
+
model_version?: string;
|
|
67
|
+
tool_catalogue_hash?: string;
|
|
68
|
+
system_prompt_hash?: string;
|
|
69
|
+
prev_event_hash?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Canonical-form recipe the `signature` was computed over.
|
|
72
|
+
* Absent/null ↔ 'v0' (pipe-joined six-field form). Set to 'v1' for
|
|
73
|
+
* RFC 8785 JCS over the full event minus signature and canonical_form.
|
|
74
|
+
* The SDK sets this automatically when {@link VorimConfig.canonicalForm}
|
|
75
|
+
* is `"v1"`; you can also pass it on a per-event basis.
|
|
76
|
+
*/
|
|
77
|
+
canonical_form?: 'v0' | 'v1';
|
|
78
|
+
/**
|
|
79
|
+
* Per-event delegation context (VAIP -02 § 6). Populated by the
|
|
80
|
+
* server when the emitting agent is acting via a delegation chain;
|
|
81
|
+
* callers may also set these manually for events recorded outside
|
|
82
|
+
* the standard delegation flow. v1 signatures cover these fields.
|
|
83
|
+
*/
|
|
84
|
+
on_behalf_of?: string;
|
|
85
|
+
delegator_agent_id?: string;
|
|
86
|
+
delegation_chain_id?: string;
|
|
87
|
+
delegation_depth?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Claims structure for one VAIP -02 § 5 delegation link.
|
|
91
|
+
*
|
|
92
|
+
* Each delegation step in a chain is one of these objects, RFC 8785 JCS
|
|
93
|
+
* canonicalised and Ed25519-signed by the delegator. Mirrors the same
|
|
94
|
+
* type in `@vorim/shared-types`; duplicated here so the SDK ships zero
|
|
95
|
+
* runtime dependencies. Byte-equivalence with the shared definition is
|
|
96
|
+
* enforced by the cross-language parity script.
|
|
97
|
+
*/
|
|
98
|
+
interface DelegationLinkClaims {
|
|
99
|
+
v: 0;
|
|
100
|
+
type: 'vaip-delegation-link';
|
|
101
|
+
chain_id: string;
|
|
102
|
+
depth: number;
|
|
103
|
+
delegator: string;
|
|
104
|
+
delegate: string;
|
|
105
|
+
scopes: string[];
|
|
106
|
+
max_chain_depth: number;
|
|
107
|
+
valid_from: string;
|
|
108
|
+
valid_until: string | null;
|
|
109
|
+
parent_link_hash: string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* One step in an agent-to-agent identity delegation chain (VAIP -02 § 5).
|
|
113
|
+
*
|
|
114
|
+
* Returned by {@link VorimSDK.delegateToAgent} and the listing endpoints.
|
|
115
|
+
*/
|
|
116
|
+
interface AgentDelegationRecord {
|
|
117
|
+
/** Internal row id. */
|
|
118
|
+
id: string;
|
|
119
|
+
/** Public chain identifier (format `chain_<32hex>`). Stamped on
|
|
120
|
+
* every audit event in this chain. */
|
|
121
|
+
publicChainId: string;
|
|
122
|
+
/** Organisation id. */
|
|
123
|
+
orgId: string;
|
|
124
|
+
/** Internal DB id of the delegator agent. */
|
|
125
|
+
delegatorAgentId: string;
|
|
126
|
+
/** Internal DB id of the delegate agent. */
|
|
127
|
+
delegateAgentId: string;
|
|
128
|
+
/** Public agent_id of the delegator (e.g. agid_acme_abc). */
|
|
129
|
+
delegatorAgentPublicId: string;
|
|
130
|
+
/** Public agent_id of the delegate. */
|
|
131
|
+
delegateAgentPublicId: string;
|
|
132
|
+
/** Scopes the delegate may exercise. */
|
|
133
|
+
scopesDelegated: string[];
|
|
134
|
+
/** How many further hops the delegate is permitted. */
|
|
135
|
+
maxChainDepth: number;
|
|
136
|
+
/** This step's depth from the root (root delegator step = 1). */
|
|
137
|
+
currentDepth: number;
|
|
138
|
+
/** Active / suspended / revoked / expired. */
|
|
139
|
+
status: 'active' | 'suspended' | 'revoked' | 'expired';
|
|
140
|
+
/** Parent delegation row (null for the root of an identity chain). */
|
|
141
|
+
parentDelegationId: string | null;
|
|
142
|
+
/** Public agent_id of the root principal of this chain. */
|
|
143
|
+
onBehalfOf: string;
|
|
144
|
+
/** ISO8601 creation timestamp. */
|
|
145
|
+
createdAt: string;
|
|
146
|
+
/** Optional ISO8601 expiry. */
|
|
147
|
+
validUntil: string | null;
|
|
55
148
|
}
|
|
56
149
|
interface TrustRecord {
|
|
57
150
|
agent_id: string;
|
|
@@ -68,6 +161,138 @@ interface TrustRecord {
|
|
|
68
161
|
last_active?: string;
|
|
69
162
|
}
|
|
70
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Replayable agent decision evidence helpers.
|
|
166
|
+
*
|
|
167
|
+
* Canonical-form hashing for the VAIP -02 schema fields that the SDK
|
|
168
|
+
* attaches to audit events. The hashes recorded in audit_events.tool_catalogue_hash
|
|
169
|
+
* and audit_events.system_prompt_hash use these functions, so the bytes
|
|
170
|
+
* an auditor or counterparty reconstructs must match what the SDK produced.
|
|
171
|
+
*
|
|
172
|
+
* These helpers are intentionally separate from the signing path. The
|
|
173
|
+
* v0 canonical signature form (event_type|action|resource|input_hash|
|
|
174
|
+
* output_hash|result) does NOT cover model_version, tool_catalogue_hash,
|
|
175
|
+
* or system_prompt_hash. They will enter the canonical bytes in v1
|
|
176
|
+
* (RFC 8785 JCS) in a follow-up release.
|
|
177
|
+
*
|
|
178
|
+
* Stable across SDK versions: the canonical-form version is documented
|
|
179
|
+
* in CANONICAL_TOOL_CATALOGUE_VERSION. Future changes get a v2 etc;
|
|
180
|
+
* never edit the existing v1 logic, or already-recorded hashes lose
|
|
181
|
+
* their meaning.
|
|
182
|
+
*/
|
|
183
|
+
/**
|
|
184
|
+
* Canonical-form version for tool catalogue hashes produced by this SDK.
|
|
185
|
+
* Recorded in tool_catalogue_canon_version on the event metadata (when
|
|
186
|
+
* the metadata field is used) so verifiers know which hash recipe to
|
|
187
|
+
* reproduce. Increment ONLY if the algorithm changes in a way that
|
|
188
|
+
* would change the hash for the same logical catalogue.
|
|
189
|
+
*/
|
|
190
|
+
declare const CANONICAL_TOOL_CATALOGUE_VERSION: "v1";
|
|
191
|
+
/**
|
|
192
|
+
* Minimum shape a tool needs for catalogue hashing. The framework
|
|
193
|
+
* integrations adapt their native tool objects to this shape before
|
|
194
|
+
* calling hashToolCatalogue.
|
|
195
|
+
*/
|
|
196
|
+
interface CatalogueTool {
|
|
197
|
+
/** The name the model sees and calls. Required. */
|
|
198
|
+
name: string;
|
|
199
|
+
/** Human-readable description shown to the model. Optional; absent ↔ empty string. */
|
|
200
|
+
description?: string;
|
|
201
|
+
/**
|
|
202
|
+
* JSON Schema describing the tool's input parameters. Optional;
|
|
203
|
+
* absent ↔ empty object `{}`. The schema gets RFC 8785 JCS-canonicalised
|
|
204
|
+
* before hashing so semantically-equivalent variations (key order,
|
|
205
|
+
* whitespace) produce the same hash.
|
|
206
|
+
*/
|
|
207
|
+
schema?: Record<string, unknown> | null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* RFC 8785 JSON Canonicalization Scheme, sufficient subset for tool
|
|
211
|
+
* catalogue values.
|
|
212
|
+
*
|
|
213
|
+
* Rules:
|
|
214
|
+
* - Object keys sorted lexicographically by UTF-16 code units (which
|
|
215
|
+
* is what JS string comparison does naturally).
|
|
216
|
+
* - No whitespace between tokens.
|
|
217
|
+
* - Numbers: integers as integers, finite floats per ECMAScript
|
|
218
|
+
* Number.prototype.toString. JCS forbids NaN and Infinity.
|
|
219
|
+
* - Strings: JSON-escape using minimal set per RFC 8259 § 7.
|
|
220
|
+
* - null, true, false, arrays: as JSON.stringify produces them, since
|
|
221
|
+
* JSON.stringify already produces the canonical form for these.
|
|
222
|
+
*
|
|
223
|
+
* Not vendoring a full library because tool schemas don't carry
|
|
224
|
+
* non-integer numbers in practice and the JS spec for Number.toString
|
|
225
|
+
* happens to coincide with JCS § 3.2.2.2 for the integer case.
|
|
226
|
+
*/
|
|
227
|
+
declare function jcsCanonicalise(value: unknown): string;
|
|
228
|
+
/**
|
|
229
|
+
* Hash a single tool definition. Returns `sha256:<hex>`.
|
|
230
|
+
*
|
|
231
|
+
* Canonical form (v1):
|
|
232
|
+
* JCS-canonicalised JSON of `{name, description, schema}` where
|
|
233
|
+
* absent fields substitute `description: ""` and `schema: {}`.
|
|
234
|
+
*/
|
|
235
|
+
declare function hashTool(tool: CatalogueTool): Promise<string>;
|
|
236
|
+
/**
|
|
237
|
+
* Hash an entire tool catalogue. Returns `sha256:<hex>`.
|
|
238
|
+
*
|
|
239
|
+
* Reordering tools does NOT change the hash (tool hashes sorted
|
|
240
|
+
* lexicographically before concatenation). Adding, removing, or
|
|
241
|
+
* modifying a tool DOES change the hash.
|
|
242
|
+
*
|
|
243
|
+
* Per-tool hashing first means a verifier comparing two catalogue
|
|
244
|
+
* hashes that differ can also be given the per-tool hashes to
|
|
245
|
+
* identify which specific tool changed.
|
|
246
|
+
*/
|
|
247
|
+
declare function hashToolCatalogue(tools: CatalogueTool[]): Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* Hash a system prompt. Returns `sha256:<hex>`.
|
|
250
|
+
*
|
|
251
|
+
* The prompt is UTF-8 encoded and hashed verbatim — no normalisation.
|
|
252
|
+
* If a caller wants to ignore whitespace or comment differences, they
|
|
253
|
+
* should normalise before calling. The intent here is deterministic
|
|
254
|
+
* reproducibility, not semantic equivalence.
|
|
255
|
+
*/
|
|
256
|
+
declare function hashSystemPrompt(prompt: string): Promise<string>;
|
|
257
|
+
/**
|
|
258
|
+
* Convenience: hash the previous event's canonical bytes for use in
|
|
259
|
+
* the prev_event_hash field of hash-chained ingest. Caller provides
|
|
260
|
+
* the canonical bytes (use canonicalPayloadV0 from the main module).
|
|
261
|
+
*/
|
|
262
|
+
declare function hashPreviousEvent(canonicalBytes: string): Promise<string>;
|
|
263
|
+
/**
|
|
264
|
+
* Raw inputs the integration captures from the framework. Set by the
|
|
265
|
+
* integration's config; turned into hashes by {@link prepareReplayContext}.
|
|
266
|
+
*/
|
|
267
|
+
interface ReplayInputs {
|
|
268
|
+
/** Stable identifier for the model. E.g. `"anthropic:claude-opus-4-8"`. */
|
|
269
|
+
modelVersion?: string;
|
|
270
|
+
/** Tools available to the agent at call time. Hashed via {@link hashToolCatalogue}. */
|
|
271
|
+
tools?: CatalogueTool[];
|
|
272
|
+
/** System prompt active at call time. Hashed via {@link hashSystemPrompt}. */
|
|
273
|
+
systemPrompt?: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Pre-computed hashes ready to attach to audit events. The three keys
|
|
277
|
+
* match the audit_events column names.
|
|
278
|
+
*/
|
|
279
|
+
interface ReplayContext {
|
|
280
|
+
model_version?: string;
|
|
281
|
+
tool_catalogue_hash?: string;
|
|
282
|
+
system_prompt_hash?: string;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Compute replay context once from raw inputs. Use at integration
|
|
286
|
+
* setup time so each emit can attach the hashes without re-hashing.
|
|
287
|
+
*
|
|
288
|
+
* Returns an object suitable for spreading into an AuditEventInput:
|
|
289
|
+
* `await vorim.emit({ ...event, ...replayContext })`
|
|
290
|
+
*
|
|
291
|
+
* If a field is absent in the inputs, it is absent in the result
|
|
292
|
+
* (not the empty string). That keeps the event lean.
|
|
293
|
+
*/
|
|
294
|
+
declare function prepareReplayContext(inputs: ReplayInputs): Promise<ReplayContext>;
|
|
295
|
+
|
|
71
296
|
interface VorimConfig {
|
|
72
297
|
apiKey: string;
|
|
73
298
|
baseUrl?: string;
|
|
@@ -80,6 +305,25 @@ interface VorimConfig {
|
|
|
80
305
|
* {@link VorimSDK.register}. Events for unknown agents pass through unsigned.
|
|
81
306
|
*/
|
|
82
307
|
autoSign?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Canonical form to use when signing. Default `"v0"` for backward-compat
|
|
310
|
+
* with `@vorim/sdk` 3.1.x. Set to `"v1"` to sign the full event object
|
|
311
|
+
* via RFC 8785 JCS, covering replayable-evidence fields (model_version,
|
|
312
|
+
* tool_catalogue_hash, system_prompt_hash, prev_event_hash). v1 events
|
|
313
|
+
* carry `canonical_form: "v1"` on the wire so the server can dispatch
|
|
314
|
+
* verification correctly.
|
|
315
|
+
*/
|
|
316
|
+
canonicalForm?: 'v0' | 'v1';
|
|
317
|
+
/**
|
|
318
|
+
* Hash-chain events per agent so deletion of a single audit row
|
|
319
|
+
* becomes detectable. Default `false` (no chaining). When enabled,
|
|
320
|
+
* the SDK sets `prev_event_hash` on each event to SHA-256 of the
|
|
321
|
+
* previous event's canonical bytes for the same agent. The first
|
|
322
|
+
* event after enable / process restart has `prev_event_hash = null`,
|
|
323
|
+
* which the verifier reports as `chain_restart` (informational, not
|
|
324
|
+
* a failure). Chain integrity is checked by `@vorim/verify`.
|
|
325
|
+
*/
|
|
326
|
+
chainEvents?: boolean;
|
|
83
327
|
}
|
|
84
328
|
/**
|
|
85
329
|
* VAIP v0 canonical bytes used by Vorim's per-event signing.
|
|
@@ -94,11 +338,25 @@ interface VorimConfig {
|
|
|
94
338
|
* edit this one. Old signatures must remain verifiable.
|
|
95
339
|
*/
|
|
96
340
|
declare function canonicalPayloadV0(event: AuditEventInput): string;
|
|
341
|
+
/**
|
|
342
|
+
* VAIP v1 canonical bytes for audit-event signing (RFC 8785 JCS).
|
|
343
|
+
*
|
|
344
|
+
* Signs the full event object excluding `signature` (the field being
|
|
345
|
+
* computed) and `canonical_form` (metadata about the recipe). Unlike v0,
|
|
346
|
+
* v1 covers the replayable-evidence fields and the metadata field.
|
|
347
|
+
*
|
|
348
|
+
* Re-exports `jcsCanonicalise` from `./replay.js` which is the byte-exact
|
|
349
|
+
* twin of `@vorim/shared-types`' implementation. The cross-language parity
|
|
350
|
+
* script enforces equivalence with the Python SDK.
|
|
351
|
+
*/
|
|
352
|
+
declare function canonicalPayloadV1(event: AuditEventInput): string;
|
|
97
353
|
declare class VorimSDK {
|
|
98
354
|
private apiKey;
|
|
99
355
|
private baseUrl;
|
|
100
356
|
private timeout;
|
|
101
357
|
private autoSign;
|
|
358
|
+
private canonicalForm;
|
|
359
|
+
private chainEvents;
|
|
102
360
|
/**
|
|
103
361
|
* In-memory keyring mapping agent_id -> PEM-encoded Ed25519 private key.
|
|
104
362
|
* Populated automatically by register() and registerEphemeral(), or
|
|
@@ -106,6 +364,21 @@ declare class VorimSDK {
|
|
|
106
364
|
* caller is responsible for durable key storage.
|
|
107
365
|
*/
|
|
108
366
|
private agentKeys;
|
|
367
|
+
/**
|
|
368
|
+
* Per-agent hash of the last emitted event's canonical bytes. Used to
|
|
369
|
+
* populate prev_event_hash on the next emit when chainEvents is on.
|
|
370
|
+
* Empty string ↔ no previous event (chain restart). Reset by
|
|
371
|
+
* forgetAgentKey() so reusing an agent_id after revocation doesn't
|
|
372
|
+
* link to the old chain.
|
|
373
|
+
*/
|
|
374
|
+
private lastEventHash;
|
|
375
|
+
/**
|
|
376
|
+
* Per-agent emit promise. Each new emit awaits the previous one so
|
|
377
|
+
* the chain is constructed in order. Concurrent emits to the same
|
|
378
|
+
* agent are serialised (correct); concurrent emits to different
|
|
379
|
+
* agents remain parallel (fast).
|
|
380
|
+
*/
|
|
381
|
+
private chainLocks;
|
|
109
382
|
constructor(config: VorimConfig);
|
|
110
383
|
/**
|
|
111
384
|
* Register a previously-issued agent keypair so this SDK instance can
|
|
@@ -117,7 +390,8 @@ declare class VorimSDK {
|
|
|
117
390
|
/**
|
|
118
391
|
* Forget an agent's signing key (e.g. after revocation). Subsequent emit()
|
|
119
392
|
* calls for that agent will pass through unsigned unless a key is provided
|
|
120
|
-
* inline.
|
|
393
|
+
* inline. Also clears the per-agent chain state — re-using the same
|
|
394
|
+
* agent_id after revocation does NOT link to the old chain.
|
|
121
395
|
*/
|
|
122
396
|
forgetAgentKey(agentId: string): void;
|
|
123
397
|
/**
|
|
@@ -188,6 +462,97 @@ declare class VorimSDK {
|
|
|
188
462
|
* Revoke a specific permission scope from an agent.
|
|
189
463
|
*/
|
|
190
464
|
revokePermission(agentId: string, scope: PermissionScope): Promise<any>;
|
|
465
|
+
/**
|
|
466
|
+
* Delegate the right to act on this agent's behalf to another agent
|
|
467
|
+
* in the same org, with a strict subset of this agent's scopes.
|
|
468
|
+
*
|
|
469
|
+
* Multi-hop chains are supported up to depth 32. Scope subset is
|
|
470
|
+
* enforced at every hop. Audit events emitted by the delegate carry
|
|
471
|
+
* the chain context (`on_behalf_of`, `delegator_agent_id`,
|
|
472
|
+
* `delegation_chain_id`, `delegation_depth`) so a verifier walking
|
|
473
|
+
* the bundle can reconstruct the full chain.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* const chain = await vorim.delegateToAgent('agid_parent_abc', {
|
|
478
|
+
* delegate_agent_id: 'agid_child_xyz',
|
|
479
|
+
* scopes_delegated: ['agent:read', 'agent:execute'],
|
|
480
|
+
* max_chain_depth: 1, // delegate may make ONE further hop
|
|
481
|
+
* valid_until: '2026-12-31T00:00:00Z',
|
|
482
|
+
* });
|
|
483
|
+
* console.log(chain.public_chain_id); // chain_<hex>
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
delegateToAgent(delegatorAgentId: string, input: {
|
|
487
|
+
delegate_agent_id: string;
|
|
488
|
+
scopes_delegated: PermissionScope[];
|
|
489
|
+
max_chain_depth?: number;
|
|
490
|
+
valid_until?: string;
|
|
491
|
+
/**
|
|
492
|
+
* Optional Ed25519-signed delegation link (VAIP -02 § 5). When
|
|
493
|
+
* provided, the server verifies the signature against the
|
|
494
|
+
* delegator's stored public key, persists alongside the chain
|
|
495
|
+
* row, and exports it in bundle delegation_tokens so the chain
|
|
496
|
+
* is offline-verifiable by `@vorim/verify`. Compute via
|
|
497
|
+
* {@link signDelegationLink} or set manually if signing
|
|
498
|
+
* elsewhere.
|
|
499
|
+
*/
|
|
500
|
+
signed_link?: {
|
|
501
|
+
claims: DelegationLinkClaims;
|
|
502
|
+
signature: string;
|
|
503
|
+
};
|
|
504
|
+
}): Promise<AgentDelegationRecord>;
|
|
505
|
+
/**
|
|
506
|
+
* Sign a delegation link with the delegator's private key. Returns
|
|
507
|
+
* the signed link in the shape accepted by `delegateToAgent`'s
|
|
508
|
+
* `signed_link` field.
|
|
509
|
+
*
|
|
510
|
+
* The signature is Ed25519 over the RFC 8785 JCS-canonical bytes of
|
|
511
|
+
* the claims object. Same algorithm the server and `@vorim/verify`
|
|
512
|
+
* use for verification.
|
|
513
|
+
*
|
|
514
|
+
* Use this when the delegator's private key is in this SDK's
|
|
515
|
+
* keyring (i.e. set via `register()` or `useAgentKey()`).
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```ts
|
|
519
|
+
* const signed = await vorim.signDelegationLink({
|
|
520
|
+
* v: 0,
|
|
521
|
+
* type: 'vaip-delegation-link',
|
|
522
|
+
* chain_id: 'chain_abc', // server returns this on first delegation
|
|
523
|
+
* depth: 1,
|
|
524
|
+
* delegator: 'agid_parent',
|
|
525
|
+
* delegate: 'agid_child',
|
|
526
|
+
* scopes: ['agent:read', 'agent:execute'],
|
|
527
|
+
* max_chain_depth: 1,
|
|
528
|
+
* valid_from: new Date().toISOString(),
|
|
529
|
+
* valid_until: null,
|
|
530
|
+
* parent_link_hash: null,
|
|
531
|
+
* });
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
signDelegationLink(claims: DelegationLinkClaims): Promise<{
|
|
535
|
+
claims: DelegationLinkClaims;
|
|
536
|
+
signature: string;
|
|
537
|
+
}>;
|
|
538
|
+
/**
|
|
539
|
+
* List active identity-chain entries this agent participates in
|
|
540
|
+
* (either as delegator or delegate). Useful for showing the current
|
|
541
|
+
* delegation graph in an admin UI.
|
|
542
|
+
*/
|
|
543
|
+
listAgentDelegations(agentId: string): Promise<AgentDelegationRecord[]>;
|
|
544
|
+
/**
|
|
545
|
+
* Walk a delegation chain by its public id. Returns the full chain
|
|
546
|
+
* in depth order.
|
|
547
|
+
*/
|
|
548
|
+
getDelegationChain(agentId: string, chainId: string): Promise<AgentDelegationRecord[]>;
|
|
549
|
+
/**
|
|
550
|
+
* Revoke this agent's delegation in a given chain. Cascades to all
|
|
551
|
+
* descendants beneath this agent's depth in the chain.
|
|
552
|
+
*/
|
|
553
|
+
revokeAgentDelegation(agentId: string, chainId: string): Promise<{
|
|
554
|
+
revoked: number;
|
|
555
|
+
}>;
|
|
191
556
|
/**
|
|
192
557
|
* Emit an audit event for an agent action.
|
|
193
558
|
*
|
|
@@ -220,8 +585,28 @@ declare class VorimSDK {
|
|
|
220
585
|
* signatures on the event are respected (caller-signed events are not
|
|
221
586
|
* re-signed). Per-agent failure is non-fatal: if signing throws, the event
|
|
222
587
|
* still sends unsigned so a single bad key doesn't break a batch.
|
|
588
|
+
*
|
|
589
|
+
* Canonical-form dispatch:
|
|
590
|
+
* - If the event already carries `canonical_form`, that wins (caller
|
|
591
|
+
* opted in/out for this specific event).
|
|
592
|
+
* - Otherwise the SDK-level `canonicalForm` (config) applies.
|
|
593
|
+
* - v0 signs the pipe-joined 6 fields. v1 signs the RFC 8785 JCS
|
|
594
|
+
* bytes over the full event minus signature and canonical_form,
|
|
595
|
+
* and the event goes on the wire with `canonical_form: "v1"`.
|
|
596
|
+
*
|
|
597
|
+
* Chain construction:
|
|
598
|
+
* - When chainEvents is on, the event gets `prev_event_hash` set to
|
|
599
|
+
* the SHA-256 of the previous event's canonical bytes for the
|
|
600
|
+
* same agent, set BEFORE the signature is computed (so v1
|
|
601
|
+
* signatures cover the chain link).
|
|
602
|
+
* - Chain ops are serialised per-agent via `chainLocks` so
|
|
603
|
+
* concurrent emits to the same agent build a deterministic chain.
|
|
223
604
|
*/
|
|
224
605
|
private prepareEvent;
|
|
606
|
+
/** Serialise per-agent and apply chain hash + sign. */
|
|
607
|
+
private prepareEventChained;
|
|
608
|
+
/** Sign an event right now, no chain handling. */
|
|
609
|
+
private signEventNow;
|
|
225
610
|
/**
|
|
226
611
|
* Export a signed audit bundle for a date range.
|
|
227
612
|
*/
|
|
@@ -344,4 +729,4 @@ declare class VorimError extends Error {
|
|
|
344
729
|
}
|
|
345
730
|
declare function createVorim(config: VorimConfig): VorimSDK;
|
|
346
731
|
|
|
347
|
-
export { type Agent, type AgentRegistrationInput, type AgentRegistrationResult, type AgentStatus, type AuditEventInput, type AuditEventType, type AuditResult, type PermissionCheckResult, type PermissionScope, type TrustRecord, type VorimConfig, VorimError, VorimSDK, canonicalPayloadV0, createVorim as default };
|
|
732
|
+
export { type Agent, type AgentDelegationRecord, type AgentRegistrationInput, type AgentRegistrationResult, type AgentStatus, type AuditEventInput, type AuditEventType, type AuditResult, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, type DelegationLinkClaims, type PermissionCheckResult, type PermissionScope, type ReplayContext, type ReplayInputs, type TrustRecord, type VorimConfig, VorimError, VorimSDK, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
|