@vorim/sdk 3.8.0 → 3.9.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 +208 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -3
- package/dist/index.d.ts +133 -3
- package/dist/index.js +208 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.cjs +218 -0
- package/dist/integrations/ap2.cjs.map +1 -0
- package/dist/integrations/ap2.d.cts +95 -0
- package/dist/integrations/ap2.d.ts +95 -0
- package/dist/integrations/ap2.js +192 -0
- package/dist/integrations/ap2.js.map +1 -0
- package/dist/integrations/bank-rails.cjs +173 -0
- package/dist/integrations/bank-rails.cjs.map +1 -0
- package/dist/integrations/bank-rails.d.cts +87 -0
- package/dist/integrations/bank-rails.d.ts +87 -0
- package/dist/integrations/bank-rails.js +147 -0
- package/dist/integrations/bank-rails.js.map +1 -0
- package/dist/integrations/circle.cjs +159 -0
- package/dist/integrations/circle.cjs.map +1 -0
- package/dist/integrations/circle.d.cts +75 -0
- package/dist/integrations/circle.d.ts +75 -0
- package/dist/integrations/circle.js +133 -0
- package/dist/integrations/circle.js.map +1 -0
- package/dist/integrations/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/hermes.cjs +280 -0
- package/dist/integrations/hermes.cjs.map +1 -0
- package/dist/integrations/hermes.d.cts +60 -0
- package/dist/integrations/hermes.d.ts +60 -0
- package/dist/integrations/hermes.js +242 -0
- package/dist/integrations/hermes.js.map +1 -0
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- package/dist/integrations/nekuda.cjs +165 -0
- package/dist/integrations/nekuda.cjs.map +1 -0
- package/dist/integrations/nekuda.d.cts +79 -0
- package/dist/integrations/nekuda.d.ts +79 -0
- package/dist/integrations/nekuda.js +139 -0
- package/dist/integrations/nekuda.js.map +1 -0
- package/dist/integrations/openai.d.cts +1 -1
- package/dist/integrations/openai.d.ts +1 -1
- package/dist/integrations/paypal-agent.cjs +215 -0
- package/dist/integrations/paypal-agent.cjs.map +1 -0
- package/dist/integrations/paypal-agent.d.cts +87 -0
- package/dist/integrations/paypal-agent.d.ts +87 -0
- package/dist/integrations/paypal-agent.js +189 -0
- package/dist/integrations/paypal-agent.js.map +1 -0
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.cjs +166 -0
- package/dist/integrations/skyfire.cjs.map +1 -0
- package/dist/integrations/skyfire.d.cts +80 -0
- package/dist/integrations/skyfire.d.ts +80 -0
- package/dist/integrations/skyfire.js +140 -0
- package/dist/integrations/skyfire.js.map +1 -0
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/x402.cjs +211 -0
- package/dist/integrations/x402.cjs.map +1 -0
- package/dist/integrations/x402.d.cts +87 -0
- package/dist/integrations/x402.d.ts +87 -0
- package/dist/integrations/x402.js +185 -0
- package/dist/integrations/x402.js.map +1 -0
- package/dist/{types-Cb6V-boJ.d.cts → types-zzK9YOoa.d.cts} +86 -1
- package/dist/{types-Cb6V-boJ.d.ts → types-zzK9YOoa.d.ts} +86 -1
- package/package.json +83 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AgentRegistrationResult, R as RuntimeDecision, b as AgentRegistrationInput, T as TrustRecord, c as Agent, P as PermissionScope, d as PermissionCheckResult, D as DelegationLinkClaims, e as AgentDelegationRecord, B as BeforeActionInput,
|
|
2
|
-
export {
|
|
1
|
+
import { A as AgentRegistrationResult, R as RuntimeDecision, b as AgentRegistrationInput, T as TrustRecord, c as Agent, P as PermissionScope, d as PermissionCheckResult, D as DelegationLinkClaims, e as AgentDelegationRecord, W as WorkflowProvenanceGraph, S as SharedMemoryWriteInput, f as SharedMemoryEntry, g as SharedMemoryListResult, B as BeforeActionInput, h as TokenBudgetInput, i as TokenBudget, j as BudgetSpend, a as AuditEventInput } from './types-zzK9YOoa.js';
|
|
2
|
+
export { k as AgentStatus, l as AuditEventType, m as AuditResult, n as BudgetEnforcement, o as BudgetScope, p as DecisionVerdict, q as WorkflowGraphEdge, r as WorkflowGraphEvent, s as WorkflowGraphNode } from './types-zzK9YOoa.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Replayable agent decision evidence helpers.
|
|
@@ -430,6 +430,136 @@ declare class VorimSDK {
|
|
|
430
430
|
revokeAgentDelegation(agentId: string, chainId: string): Promise<{
|
|
431
431
|
revoked: number;
|
|
432
432
|
}>;
|
|
433
|
+
/**
|
|
434
|
+
* Reconstruct a multi-agent workflow's provenance graph from a delegation
|
|
435
|
+
* chain id — the nodes (agents), edges (who delegated what to whom), and the
|
|
436
|
+
* audit events attributed to each agent within that workflow. Multi-agent
|
|
437
|
+
* fabric Phase 1: the tamper-evident answer to "which agents did what, and
|
|
438
|
+
* who authorised whom?" across a whole hand-off chain.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* const graph = await vorim.getWorkflowGraph('chain_abc123');
|
|
443
|
+
* for (const edge of graph.edges) {
|
|
444
|
+
* console.log(`${edge.from} -> ${edge.to} [${edge.scopes.join(', ')}]`);
|
|
445
|
+
* }
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
getWorkflowGraph(chainId: string, options?: {
|
|
449
|
+
maxEvents?: number;
|
|
450
|
+
}): Promise<WorkflowProvenanceGraph>;
|
|
451
|
+
/**
|
|
452
|
+
* Write (upsert) an entry into the org's governed shared-memory pool,
|
|
453
|
+
* attributed to `agentId`.
|
|
454
|
+
*
|
|
455
|
+
* If the SDK holds the agent's private key (via {@link VorimSDK.register}
|
|
456
|
+
* or {@link VorimSDK.useAgentKey}), the entry is signed at source with the
|
|
457
|
+
* agent's Ed25519 key over the canonical entry (namespace + key + value +
|
|
458
|
+
* agent_id) before it leaves the process, and the server verifies it against
|
|
459
|
+
* the agent's stored public key — rejecting a bad signature (fail closed).
|
|
460
|
+
* This is what makes a poisoned entry always traceable to its source
|
|
461
|
+
* (OWASP ASI06). If no key is available, the entry is written unsigned.
|
|
462
|
+
*
|
|
463
|
+
* A write to an existing (namespace, key) updates it, recording the new
|
|
464
|
+
* writer + signature.
|
|
465
|
+
*
|
|
466
|
+
* Requires an API key with the `memory:write` scope.
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* await vorim.writeMemory('agid_researcher_abc', {
|
|
471
|
+
* namespace: 'research-run-42',
|
|
472
|
+
* key: 'sources',
|
|
473
|
+
* value: { urls: ['https://…'], gathered_at: '2026-07-25T…' },
|
|
474
|
+
* });
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
writeMemory(agentId: string, entry: SharedMemoryWriteInput): Promise<SharedMemoryEntry>;
|
|
478
|
+
/**
|
|
479
|
+
* Read one shared-memory entry by (namespace, key). Throws a 404
|
|
480
|
+
* {@link VorimError} if it does not exist. Returns the value plus
|
|
481
|
+
* provenance (which agent wrote it, content hash, whether it is signed).
|
|
482
|
+
*
|
|
483
|
+
* Requires an API key with the `memory:read` scope.
|
|
484
|
+
*/
|
|
485
|
+
readMemory(input: {
|
|
486
|
+
namespace: string;
|
|
487
|
+
key: string;
|
|
488
|
+
}): Promise<SharedMemoryEntry>;
|
|
489
|
+
/**
|
|
490
|
+
* List entries in a namespace (paginated). Returns `{ entries, meta }`.
|
|
491
|
+
*
|
|
492
|
+
* Requires an API key with the `memory:read` scope.
|
|
493
|
+
*/
|
|
494
|
+
listMemory(input: {
|
|
495
|
+
namespace: string;
|
|
496
|
+
page?: number;
|
|
497
|
+
perPage?: number;
|
|
498
|
+
}): Promise<SharedMemoryListResult>;
|
|
499
|
+
/**
|
|
500
|
+
* Delete one shared-memory entry by (namespace, key).
|
|
501
|
+
*
|
|
502
|
+
* Requires an API key with the `memory:write` scope.
|
|
503
|
+
*/
|
|
504
|
+
deleteMemory(input: {
|
|
505
|
+
namespace: string;
|
|
506
|
+
key: string;
|
|
507
|
+
}): Promise<{
|
|
508
|
+
deleted: true;
|
|
509
|
+
namespace: string;
|
|
510
|
+
key: string;
|
|
511
|
+
}>;
|
|
512
|
+
/**
|
|
513
|
+
* Verified hand-off — the multi-agent-fabric primitive.
|
|
514
|
+
*
|
|
515
|
+
* Hands a task from one agent to another as ONE auditable operation that
|
|
516
|
+
* composes the three trust primitives:
|
|
517
|
+
* 1. (optional) VERIFY the receiving agent is trusted + active before
|
|
518
|
+
* handing it anything — fails closed if it is not (unless you opt out).
|
|
519
|
+
* 2. DELEGATE a strictly-attenuated subset of the sender's scopes to the
|
|
520
|
+
* receiver (the server enforces child ⊆ parent + depth; a scope the
|
|
521
|
+
* sender doesn't hold is rejected). Optionally as a signed capability
|
|
522
|
+
* link so the hand-off is offline-verifiable by `@vorim/verify`.
|
|
523
|
+
* 3. EMIT a signed audit event recording the hand-off, stamped with the
|
|
524
|
+
* delegation-chain provenance so the whole multi-agent workflow is
|
|
525
|
+
* reconstructable later.
|
|
526
|
+
*
|
|
527
|
+
* Returns the delegation record (with `public_chain_id`) plus the verification
|
|
528
|
+
* result. Throws before delegating if verification fails.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```ts
|
|
532
|
+
* const { chain } = await vorim.handOff('agid_planner', {
|
|
533
|
+
* to: 'agid_researcher',
|
|
534
|
+
* scopes: ['agent:read'], // researcher gets read-only, nothing more
|
|
535
|
+
* task: 'gather sources for Q3 report',
|
|
536
|
+
* maxChainDepth: 0, // researcher cannot re-delegate
|
|
537
|
+
* minTrustScore: 60,
|
|
538
|
+
* });
|
|
539
|
+
* console.log(chain.publicChainId);
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
handOff(fromAgentId: string, input: {
|
|
543
|
+
/** The receiving agent's id. */
|
|
544
|
+
to: string;
|
|
545
|
+
/** Scopes to delegate — must be a subset of what `fromAgentId` holds. */
|
|
546
|
+
scopes: PermissionScope[];
|
|
547
|
+
/** Human-readable description of the handed-off task (recorded in audit). */
|
|
548
|
+
task?: string;
|
|
549
|
+
/** How many further hops the receiver may make (default 0 — no re-delegation). */
|
|
550
|
+
maxChainDepth?: number;
|
|
551
|
+
/** Delegation expiry (ISO 8601). */
|
|
552
|
+
validUntil?: string;
|
|
553
|
+
/** Minimum trust score the receiver must have to accept the hand-off (default 50). */
|
|
554
|
+
minTrustScore?: number;
|
|
555
|
+
/** Skip the pre-delegation trust verification (NOT recommended). @default false */
|
|
556
|
+
skipVerify?: boolean;
|
|
557
|
+
/** Sign the delegation link so the hand-off is offline-verifiable. @default false */
|
|
558
|
+
signed?: boolean;
|
|
559
|
+
}): Promise<{
|
|
560
|
+
chain: AgentDelegationRecord;
|
|
561
|
+
verification?: TrustRecord;
|
|
562
|
+
}>;
|
|
433
563
|
/**
|
|
434
564
|
* Gate an agent action BEFORE it is performed. Calls
|
|
435
565
|
* `POST /v1/runtime/decisions` and returns a typed {@link RuntimeDecision}.
|
|
@@ -775,4 +905,4 @@ interface DeviceLoginResult {
|
|
|
775
905
|
*/
|
|
776
906
|
declare function deviceLogin(opts: DeviceLoginOptions): Promise<DeviceLoginResult>;
|
|
777
907
|
|
|
778
|
-
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, deviceLogin, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
|
|
908
|
+
export { Agent, AgentDelegationRecord, AgentRegistrationInput, AgentRegistrationResult, AuditEventInput, BeforeActionInput, BudgetSpend, CANONICAL_TOOL_CATALOGUE_VERSION, type CatalogueTool, DelegationLinkClaims, type DeviceLoginOptions, type DeviceLoginResult, PermissionCheckResult, PermissionScope, type ReplayContext, type ReplayInputs, RuntimeDecision, SharedMemoryEntry, SharedMemoryListResult, SharedMemoryWriteInput, TokenBudget, TokenBudgetInput, TrustRecord, type VorimConfig, VorimDeniedError, VorimError, VorimSDK, WorkflowProvenanceGraph, canonicalPayloadV0, canonicalPayloadV1, createVorim as default, deviceLogin, hashPreviousEvent, hashSystemPrompt, hashTool, hashToolCatalogue, jcsCanonicalise, prepareReplayContext };
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ async function prepareReplayContext(inputs) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// src/index.ts
|
|
78
|
-
var SDK_VERSION = true ? "3.
|
|
78
|
+
var SDK_VERSION = true ? "3.9.0" : "0.0.0";
|
|
79
79
|
var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
|
|
80
80
|
function sleep(ms) {
|
|
81
81
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -374,6 +374,213 @@ var VorimSDK = class _VorimSDK {
|
|
|
374
374
|
async revokeAgentDelegation(agentId, chainId) {
|
|
375
375
|
return this.delete(`/agents/${agentId}/delegations/${chainId}`);
|
|
376
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Reconstruct a multi-agent workflow's provenance graph from a delegation
|
|
379
|
+
* chain id — the nodes (agents), edges (who delegated what to whom), and the
|
|
380
|
+
* audit events attributed to each agent within that workflow. Multi-agent
|
|
381
|
+
* fabric Phase 1: the tamper-evident answer to "which agents did what, and
|
|
382
|
+
* who authorised whom?" across a whole hand-off chain.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* const graph = await vorim.getWorkflowGraph('chain_abc123');
|
|
387
|
+
* for (const edge of graph.edges) {
|
|
388
|
+
* console.log(`${edge.from} -> ${edge.to} [${edge.scopes.join(', ')}]`);
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
async getWorkflowGraph(chainId, options) {
|
|
393
|
+
const qs = options?.maxEvents ? `?max_events=${options.maxEvents}` : "";
|
|
394
|
+
return this.get(`/audit/workflow-graph/${chainId}${qs}`);
|
|
395
|
+
}
|
|
396
|
+
// ─── Governed Shared Memory (multi-agent fabric, Phase 2) ──────────
|
|
397
|
+
/**
|
|
398
|
+
* Write (upsert) an entry into the org's governed shared-memory pool,
|
|
399
|
+
* attributed to `agentId`.
|
|
400
|
+
*
|
|
401
|
+
* If the SDK holds the agent's private key (via {@link VorimSDK.register}
|
|
402
|
+
* or {@link VorimSDK.useAgentKey}), the entry is signed at source with the
|
|
403
|
+
* agent's Ed25519 key over the canonical entry (namespace + key + value +
|
|
404
|
+
* agent_id) before it leaves the process, and the server verifies it against
|
|
405
|
+
* the agent's stored public key — rejecting a bad signature (fail closed).
|
|
406
|
+
* This is what makes a poisoned entry always traceable to its source
|
|
407
|
+
* (OWASP ASI06). If no key is available, the entry is written unsigned.
|
|
408
|
+
*
|
|
409
|
+
* A write to an existing (namespace, key) updates it, recording the new
|
|
410
|
+
* writer + signature.
|
|
411
|
+
*
|
|
412
|
+
* Requires an API key with the `memory:write` scope.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* await vorim.writeMemory('agid_researcher_abc', {
|
|
417
|
+
* namespace: 'research-run-42',
|
|
418
|
+
* key: 'sources',
|
|
419
|
+
* value: { urls: ['https://…'], gathered_at: '2026-07-25T…' },
|
|
420
|
+
* });
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
async writeMemory(agentId, entry) {
|
|
424
|
+
const body = {
|
|
425
|
+
agent_id: agentId,
|
|
426
|
+
namespace: entry.namespace,
|
|
427
|
+
key: entry.key,
|
|
428
|
+
value: entry.value
|
|
429
|
+
};
|
|
430
|
+
const key = this.agentKeys.get(agentId);
|
|
431
|
+
if (key) {
|
|
432
|
+
try {
|
|
433
|
+
const canonical = jcsCanonicalise({
|
|
434
|
+
agent_id: agentId,
|
|
435
|
+
key: entry.key,
|
|
436
|
+
namespace: entry.namespace,
|
|
437
|
+
value: entry.value
|
|
438
|
+
});
|
|
439
|
+
body.signature = await this.sign(canonical, key);
|
|
440
|
+
} catch {
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return this.post("/memory", body);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Read one shared-memory entry by (namespace, key). Throws a 404
|
|
447
|
+
* {@link VorimError} if it does not exist. Returns the value plus
|
|
448
|
+
* provenance (which agent wrote it, content hash, whether it is signed).
|
|
449
|
+
*
|
|
450
|
+
* Requires an API key with the `memory:read` scope.
|
|
451
|
+
*/
|
|
452
|
+
async readMemory(input) {
|
|
453
|
+
return this.get(`/memory/${encodeURIComponent(input.namespace)}/${encodeURIComponent(input.key)}`);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* List entries in a namespace (paginated). Returns `{ entries, meta }`.
|
|
457
|
+
*
|
|
458
|
+
* Requires an API key with the `memory:read` scope.
|
|
459
|
+
*/
|
|
460
|
+
async listMemory(input) {
|
|
461
|
+
const params = new URLSearchParams();
|
|
462
|
+
if (input.page) params.set("page", String(input.page));
|
|
463
|
+
if (input.perPage) params.set("per_page", String(input.perPage));
|
|
464
|
+
const qs = params.toString();
|
|
465
|
+
const envelope = await this.requestEnvelope(
|
|
466
|
+
"GET",
|
|
467
|
+
`/memory/${encodeURIComponent(input.namespace)}${qs ? `?${qs}` : ""}`
|
|
468
|
+
);
|
|
469
|
+
return {
|
|
470
|
+
entries: envelope.data ?? [],
|
|
471
|
+
meta: envelope.meta
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Delete one shared-memory entry by (namespace, key).
|
|
476
|
+
*
|
|
477
|
+
* Requires an API key with the `memory:write` scope.
|
|
478
|
+
*/
|
|
479
|
+
async deleteMemory(input) {
|
|
480
|
+
return this.delete(`/memory/${encodeURIComponent(input.namespace)}/${encodeURIComponent(input.key)}`);
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Verified hand-off — the multi-agent-fabric primitive.
|
|
484
|
+
*
|
|
485
|
+
* Hands a task from one agent to another as ONE auditable operation that
|
|
486
|
+
* composes the three trust primitives:
|
|
487
|
+
* 1. (optional) VERIFY the receiving agent is trusted + active before
|
|
488
|
+
* handing it anything — fails closed if it is not (unless you opt out).
|
|
489
|
+
* 2. DELEGATE a strictly-attenuated subset of the sender's scopes to the
|
|
490
|
+
* receiver (the server enforces child ⊆ parent + depth; a scope the
|
|
491
|
+
* sender doesn't hold is rejected). Optionally as a signed capability
|
|
492
|
+
* link so the hand-off is offline-verifiable by `@vorim/verify`.
|
|
493
|
+
* 3. EMIT a signed audit event recording the hand-off, stamped with the
|
|
494
|
+
* delegation-chain provenance so the whole multi-agent workflow is
|
|
495
|
+
* reconstructable later.
|
|
496
|
+
*
|
|
497
|
+
* Returns the delegation record (with `public_chain_id`) plus the verification
|
|
498
|
+
* result. Throws before delegating if verification fails.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```ts
|
|
502
|
+
* const { chain } = await vorim.handOff('agid_planner', {
|
|
503
|
+
* to: 'agid_researcher',
|
|
504
|
+
* scopes: ['agent:read'], // researcher gets read-only, nothing more
|
|
505
|
+
* task: 'gather sources for Q3 report',
|
|
506
|
+
* maxChainDepth: 0, // researcher cannot re-delegate
|
|
507
|
+
* minTrustScore: 60,
|
|
508
|
+
* });
|
|
509
|
+
* console.log(chain.publicChainId);
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
async handOff(fromAgentId, input) {
|
|
513
|
+
let verification;
|
|
514
|
+
if (!input.skipVerify) {
|
|
515
|
+
try {
|
|
516
|
+
verification = await this.verify(input.to);
|
|
517
|
+
} catch {
|
|
518
|
+
throw new VorimError(
|
|
519
|
+
400,
|
|
520
|
+
"HANDOFF_VERIFY_FAILED",
|
|
521
|
+
`Could not verify receiving agent ${input.to} \u2014 refusing hand-off (fail closed).`
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
const minScore = input.minTrustScore ?? 50;
|
|
525
|
+
if (verification.status !== "active") {
|
|
526
|
+
throw new VorimError(
|
|
527
|
+
403,
|
|
528
|
+
"HANDOFF_RECEIVER_INACTIVE",
|
|
529
|
+
`Receiving agent ${input.to} is ${verification.status}, not active \u2014 refusing hand-off.`
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
if ((verification.trust_score ?? 0) < minScore) {
|
|
533
|
+
throw new VorimError(
|
|
534
|
+
403,
|
|
535
|
+
"HANDOFF_RECEIVER_UNTRUSTED",
|
|
536
|
+
`Receiving agent ${input.to} trust score ${verification.trust_score} is below minimum ${minScore}.`
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
const delegationInput = {
|
|
541
|
+
delegate_agent_id: input.to,
|
|
542
|
+
scopes_delegated: input.scopes,
|
|
543
|
+
max_chain_depth: input.maxChainDepth ?? 0,
|
|
544
|
+
...input.validUntil ? { valid_until: input.validUntil } : {}
|
|
545
|
+
};
|
|
546
|
+
if (input.signed) {
|
|
547
|
+
const chainId = `chain_pending_${input.to}`;
|
|
548
|
+
const signed = await this.signDelegationLink({
|
|
549
|
+
v: 0,
|
|
550
|
+
type: "vaip-delegation-link",
|
|
551
|
+
chain_id: chainId,
|
|
552
|
+
depth: 1,
|
|
553
|
+
delegator: fromAgentId,
|
|
554
|
+
delegate: input.to,
|
|
555
|
+
scopes: input.scopes,
|
|
556
|
+
max_chain_depth: input.maxChainDepth ?? 0,
|
|
557
|
+
valid_from: (/* @__PURE__ */ new Date()).toISOString(),
|
|
558
|
+
valid_until: input.validUntil ?? null,
|
|
559
|
+
parent_link_hash: null
|
|
560
|
+
});
|
|
561
|
+
delegationInput.signed_link = signed;
|
|
562
|
+
}
|
|
563
|
+
const chain = await this.delegateToAgent(fromAgentId, delegationInput);
|
|
564
|
+
try {
|
|
565
|
+
await this.emit({
|
|
566
|
+
agent_id: fromAgentId,
|
|
567
|
+
event_type: "permission_change",
|
|
568
|
+
action: "agent.handoff",
|
|
569
|
+
resource: input.to,
|
|
570
|
+
result: "success",
|
|
571
|
+
delegation_chain_id: chain.publicChainId,
|
|
572
|
+
metadata: {
|
|
573
|
+
framework: "fabric",
|
|
574
|
+
to: input.to,
|
|
575
|
+
scopes: input.scopes,
|
|
576
|
+
task: input.task,
|
|
577
|
+
receiver_trust_score: verification?.trust_score
|
|
578
|
+
}
|
|
579
|
+
}, { sign: true });
|
|
580
|
+
} catch {
|
|
581
|
+
}
|
|
582
|
+
return { chain, verification };
|
|
583
|
+
}
|
|
377
584
|
// ─── Runtime Control (Strategy A) ──────────────────────────────────
|
|
378
585
|
/**
|
|
379
586
|
* Gate an agent action BEFORE it is performed. Calls
|