@vorim/sdk 3.7.5 → 3.8.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/README.md +1 -1
- package/dist/_runtime-gate-DOJUKJBu.d.cts +23 -0
- package/dist/_runtime-gate-DOJUKJBu.d.ts +23 -0
- package/dist/index.cjs +47 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.cjs +4 -1
- package/dist/integrations/anthropic.cjs.map +1 -1
- package/dist/integrations/anthropic.d.cts +9 -2
- package/dist/integrations/anthropic.d.ts +9 -2
- package/dist/integrations/anthropic.js +4 -1
- package/dist/integrations/anthropic.js.map +1 -1
- package/dist/integrations/crewai.cjs +56 -2
- package/dist/integrations/crewai.cjs.map +1 -1
- package/dist/integrations/crewai.d.cts +23 -3
- package/dist/integrations/crewai.d.ts +23 -3
- package/dist/integrations/crewai.js +54 -2
- package/dist/integrations/crewai.js.map +1 -1
- package/dist/integrations/langchain.cjs +99 -8
- package/dist/integrations/langchain.cjs.map +1 -1
- package/dist/integrations/langchain.d.cts +24 -1
- package/dist/integrations/langchain.d.ts +24 -1
- package/dist/integrations/langchain.js +99 -8
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/langgraph.cjs +78 -6
- package/dist/integrations/langgraph.cjs.map +1 -1
- package/dist/integrations/langgraph.d.cts +2 -1
- package/dist/integrations/langgraph.d.ts +2 -1
- package/dist/integrations/langgraph.js +78 -6
- package/dist/integrations/langgraph.js.map +1 -1
- package/dist/integrations/llamaindex.cjs +96 -8
- package/dist/integrations/llamaindex.cjs.map +1 -1
- package/dist/integrations/llamaindex.d.cts +24 -1
- package/dist/integrations/llamaindex.d.ts +24 -1
- package/dist/integrations/llamaindex.js +96 -8
- package/dist/integrations/llamaindex.js.map +1 -1
- package/dist/integrations/openai.cjs +4 -1
- package/dist/integrations/openai.cjs.map +1 -1
- package/dist/integrations/openai.d.cts +9 -2
- package/dist/integrations/openai.d.ts +9 -2
- package/dist/integrations/openai.js +4 -1
- package/dist/integrations/openai.js.map +1 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- 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.cjs +2 -1
- package/dist/integrations/vercel-ai.cjs.map +1 -1
- package/dist/integrations/vercel-ai.d.cts +8 -2
- package/dist/integrations/vercel-ai.d.ts +8 -2
- package/dist/integrations/vercel-ai.js +2 -1
- package/dist/integrations/vercel-ai.js.map +1 -1
- package/dist/{types-B22WnXEW.d.cts → types-Cb6V-boJ.d.cts} +55 -1
- package/dist/{types-B22WnXEW.d.ts → types-Cb6V-boJ.d.ts} +55 -1
- package/package.json +1 -1
- package/dist/_runtime-gate-DZQTkw4J.d.cts +0 -11
- package/dist/_runtime-gate-DZQTkw4J.d.ts +0 -11
|
@@ -28,6 +28,45 @@ __export(crewai_exports, {
|
|
|
28
28
|
verifyCrewTrust: () => verifyCrewTrust
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(crewai_exports);
|
|
31
|
+
|
|
32
|
+
// src/integrations/_runtime-gate.ts
|
|
33
|
+
function isAllowVerdict(decision) {
|
|
34
|
+
return decision === "allow" || decision === "modify";
|
|
35
|
+
}
|
|
36
|
+
async function runtimeGate(vorim, agentId, actionTarget, scope, payload, opts = {}) {
|
|
37
|
+
const onEscalation = opts.onEscalation ?? "wait";
|
|
38
|
+
const onTransportFailure = opts.onTransportFailure ?? "deny";
|
|
39
|
+
const d = await vorim.beforeAction(
|
|
40
|
+
{ agentId, actionType: "tool_call", actionTarget, requiredScope: scope, payload },
|
|
41
|
+
{ throwOnDeny: false }
|
|
42
|
+
);
|
|
43
|
+
if (d.isFallback || d.decision === "fallback") {
|
|
44
|
+
if (onTransportFailure === "allow") {
|
|
45
|
+
return { allowed: true, reason: d.reason ?? "control plane unreachable (fail-open)", decisionId: d.decisionId || void 0 };
|
|
46
|
+
}
|
|
47
|
+
return { allowed: false, reason: d.reason ?? "control plane unreachable (failed closed)", decisionId: d.decisionId || void 0 };
|
|
48
|
+
}
|
|
49
|
+
if (d.decision !== "escalate") {
|
|
50
|
+
return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || void 0 };
|
|
51
|
+
}
|
|
52
|
+
if (onEscalation === "allow") {
|
|
53
|
+
return { allowed: true, reason: d.reason ?? "escalated (auto-allowed)", decisionId: d.decisionId || void 0 };
|
|
54
|
+
}
|
|
55
|
+
if (onEscalation === "deny") {
|
|
56
|
+
return { allowed: false, reason: d.reason ?? "escalated (auto-denied \u2014 awaiting human)", decisionId: d.decisionId || void 0 };
|
|
57
|
+
}
|
|
58
|
+
if (!d.decisionId) {
|
|
59
|
+
return { allowed: false, reason: "escalated but no decisionId to poll", decisionId: void 0 };
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });
|
|
63
|
+
return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };
|
|
64
|
+
} catch {
|
|
65
|
+
return { allowed: false, reason: "escalation not resolved before timeout", decisionId: d.decisionId };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/integrations/crewai.ts
|
|
31
70
|
async function registerCrew(vorim, manifest) {
|
|
32
71
|
const members = [];
|
|
33
72
|
for (const member of manifest.members) {
|
|
@@ -103,12 +142,27 @@ async function emitCrewRunEvents(vorim, events) {
|
|
|
103
142
|
}));
|
|
104
143
|
return vorim.emitBatch(auditEvents);
|
|
105
144
|
}
|
|
106
|
-
async function checkCrewPermission(vorim, crew, role, scope) {
|
|
145
|
+
async function checkCrewPermission(vorim, crew, role, scope, opts) {
|
|
107
146
|
const member = crew.getMember(role);
|
|
108
147
|
if (!member) {
|
|
109
148
|
return { allowed: false, reason: `Unknown crew member: ${role}` };
|
|
110
149
|
}
|
|
111
|
-
|
|
150
|
+
if (opts?.useRuntimeControl) {
|
|
151
|
+
try {
|
|
152
|
+
return await runtimeGate(vorim, member.agentId, role, scope, opts.payload, {
|
|
153
|
+
onEscalation: opts.onEscalation,
|
|
154
|
+
escalationTimeoutMs: opts.escalationTimeoutMs,
|
|
155
|
+
onTransportFailure: opts.onTransportFailure
|
|
156
|
+
});
|
|
157
|
+
} catch {
|
|
158
|
+
return { allowed: false, reason: "runtime gate unavailable (failed closed)" };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
return await vorim.check(member.agentId, scope);
|
|
163
|
+
} catch {
|
|
164
|
+
return { allowed: false, reason: "permission check unavailable (failed closed)" };
|
|
165
|
+
}
|
|
112
166
|
}
|
|
113
167
|
async function checkDelegationPermission(vorim, crew, fromRole, toRole) {
|
|
114
168
|
const from = crew.getMember(fromRole);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/integrations/crewai.ts"],"sourcesContent":["// ============================================================================\n// VORIM SDK — CrewAI Integration\n// CrewAI is Python-only, so this module provides:\n// 1. A TypeScript helper for managing CrewAI agent identities via Vorim\n// 2. Audit utilities for logging crew task execution\n// 3. A \"crew manifest\" pattern for registering entire crews at once\n//\n// Use this from a TypeScript orchestration layer that triggers CrewAI\n// runs via REST, CLI, or subprocess. For native Python integration,\n// use the Vorim REST API directly (see docs).\n//\n// No peer dependencies required — uses @vorim/sdk only.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type {\n PermissionScope, AuditEventInput, AgentRegistrationResult,\n} from '../types.js';\n\n// ─── Crew Configuration ──────────────────────────────────────────────────\n\nexport interface CrewMemberConfig {\n /** Unique role name within the crew (e.g. \"researcher\", \"writer\"). */\n role: string;\n /** Display name for the Vorim agent. */\n name: string;\n /** Description of this crew member's responsibilities. */\n description?: string;\n /** Tools this agent can use (e.g. [\"web_search\", \"file_read\"]). */\n capabilities: string[];\n /** Permission scopes to grant. */\n scopes: PermissionScope[];\n /** Whether this agent can delegate to other crew members. */\n allowDelegation?: boolean;\n}\n\nexport interface CrewManifest {\n /** Name for the overall crew. */\n crewName: string;\n /** Members of the crew. */\n members: CrewMemberConfig[];\n /** Optional metadata for the crew. */\n metadata?: Record<string, unknown>;\n}\n\nexport interface RegisteredCrewMember {\n role: string;\n agentId: string;\n registration: AgentRegistrationResult;\n privateKey: string;\n}\n\nexport interface RegisteredCrew {\n crewName: string;\n members: RegisteredCrewMember[];\n /** Lookup a member by role. */\n getMember(role: string): RegisteredCrewMember | undefined;\n /** Get all agent IDs in the crew. */\n agentIds(): string[];\n}\n\n// ─── Crew Registration ──────────────────────────────────────────────────\n\n/**\n * Registers an entire CrewAI crew with Vorim. Each crew member gets a\n * unique Vorim agent identity with Ed25519 keypair and scoped permissions.\n *\n * @example\n * ```ts\n * import createVorim from \"@vorim/sdk\";\n * import { registerCrew } from \"@vorim/sdk/integrations/crewai\";\n *\n * const vorim = createVorim({ apiKey: \"agid_sk_live_...\" });\n *\n * const crew = await registerCrew(vorim, {\n * crewName: \"content-pipeline\",\n * members: [\n * {\n * role: \"researcher\",\n * name: \"crew-researcher\",\n * capabilities: [\"web_search\", \"summarization\"],\n * scopes: [\"agent:read\", \"agent:execute\"],\n * },\n * {\n * role: \"writer\",\n * name: \"crew-writer\",\n * capabilities: [\"file_write\", \"formatting\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * },\n * {\n * role: \"editor\",\n * name: \"crew-editor\",\n * capabilities: [\"review\", \"approval\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * allowDelegation: true,\n * },\n * ],\n * });\n *\n * // Access individual members\n * const researcher = crew.getMember(\"researcher\");\n * console.log(researcher.agentId); // agid_acme_...\n *\n * // Grant delegation permission to editor\n * // (done automatically if allowDelegation is true)\n * ```\n */\nexport async function registerCrew(\n vorim: VorimSDK,\n manifest: CrewManifest,\n): Promise<RegisteredCrew> {\n const members: RegisteredCrewMember[] = [];\n\n for (const member of manifest.members) {\n const scopes = [...member.scopes];\n\n // Auto-add delegate scope if delegation is allowed\n if (member.allowDelegation && !scopes.includes('agent:delegate')) {\n scopes.push('agent:delegate');\n }\n\n const registration = await vorim.register({\n name: member.name,\n description: member.description ?? `CrewAI ${member.role} — ${manifest.crewName}`,\n capabilities: member.capabilities,\n scopes,\n });\n\n members.push({\n role: member.role,\n agentId: registration.agent.agent_id,\n registration,\n privateKey: registration.private_key,\n });\n }\n\n return {\n crewName: manifest.crewName,\n members,\n getMember(role: string) {\n return members.find(m => m.role === role);\n },\n agentIds() {\n return members.map(m => m.agentId);\n },\n };\n}\n\n// ─── Task Audit ──────────────────────────────────────────────────────────\n\nexport interface CrewTaskEvent {\n /** The role of the crew member performing the task. */\n role: string;\n /** The Vorim agent_id (looked up from the crew). */\n agentId: string;\n /** Task description or name. */\n task: string;\n /** Tool used (if any). */\n tool?: string;\n /** Result of the action. */\n result: 'success' | 'denied' | 'error';\n /** Duration in milliseconds. */\n latencyMs?: number;\n /** Error details if result is 'error'. */\n error?: string;\n /** Whether this was a delegation to another crew member. */\n delegatedTo?: string;\n /** Additional context. */\n metadata?: Record<string, unknown>;\n /**\n * Replayable agent decision evidence (VAIP -02).\n *\n * Stable identifier for the model that produced this task. Free-form\n * but recommended convention is `provider:model-name-version`.\n */\n modelVersion?: string;\n /**\n * SHA-256 of the canonicalised tool catalogue available to the\n * crew member at task time. Compute via {@link hashToolCatalogue}\n * from `@vorim/sdk`.\n */\n toolCatalogueHash?: string;\n /**\n * SHA-256 of the system prompt active at task time. Compute via\n * {@link hashSystemPrompt} from `@vorim/sdk`.\n */\n systemPromptHash?: string;\n}\n\n/**\n * Emits a Vorim audit event for a CrewAI task execution.\n * Call this from your orchestration layer after each CrewAI step completes.\n *\n * @example\n * ```ts\n * import { emitCrewTaskEvent } from \"@vorim/sdk/integrations/crewai\";\n *\n * // After a CrewAI task completes\n * await emitCrewTaskEvent(vorim, {\n * role: \"researcher\",\n * agentId: crew.getMember(\"researcher\").agentId,\n * task: \"research_competitors\",\n * tool: \"web_search\",\n * result: \"success\",\n * latencyMs: 3200,\n * });\n * ```\n */\nexport async function emitCrewTaskEvent(\n vorim: VorimSDK,\n event: CrewTaskEvent,\n): Promise<void> {\n const auditEvent: AuditEventInput = {\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n };\n\n await vorim.emit(auditEvent);\n}\n\n/**\n * Emits audit events for an entire crew run (batch of task results).\n *\n * @example\n * ```ts\n * await emitCrewRunEvents(vorim, [\n * { role: \"researcher\", agentId: \"...\", task: \"research\", result: \"success\" },\n * { role: \"writer\", agentId: \"...\", task: \"draft_article\", result: \"success\" },\n * { role: \"editor\", agentId: \"...\", task: \"review\", result: \"success\" },\n * ]);\n * ```\n */\nexport async function emitCrewRunEvents(\n vorim: VorimSDK,\n events: CrewTaskEvent[],\n): Promise<{ ingested: number }> {\n const auditEvents: AuditEventInput[] = events.map(event => ({\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n }));\n\n return vorim.emitBatch(auditEvents);\n}\n\n// ─── Permission Helpers ──────────────────────────────────────────────────\n\n/**\n * Check if a crew member has permission before executing a task.\n * Returns the check result — does not throw.\n *\n * @example\n * ```ts\n * const { allowed } = await checkCrewPermission(vorim, crew, \"writer\", \"agent:write\");\n * if (!allowed) {\n * console.log(\"Writer lacks write permission\");\n * }\n * ```\n */\nexport async function checkCrewPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n role: string,\n scope: PermissionScope,\n): Promise<{ allowed: boolean; reason?: string }> {\n const member = crew.getMember(role);\n if (!member) {\n return { allowed: false, reason: `Unknown crew member: ${role}` };\n }\n return vorim.check(member.agentId, scope);\n}\n\n/**\n * Check if delegation between two crew members is permitted.\n * The delegating agent must have the `agent:delegate` scope.\n */\nexport async function checkDelegationPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n fromRole: string,\n toRole: string,\n): Promise<{ allowed: boolean; reason?: string }> {\n const from = crew.getMember(fromRole);\n const to = crew.getMember(toRole);\n if (!from) return { allowed: false, reason: `Unknown crew member: ${fromRole}` };\n if (!to) return { allowed: false, reason: `Unknown crew member: ${toRole}` };\n\n const result = await vorim.check(from.agentId, 'agent:delegate');\n if (!result.allowed) {\n return { allowed: false, reason: `${fromRole} lacks agent:delegate permission` };\n }\n return { allowed: true };\n}\n\n// ─── Trust Verification ──────────────────────────────────────────────────\n\n/**\n * Verify trust scores for all members of a crew.\n * Useful before starting a crew run to ensure all agents are active and trusted.\n */\nexport async function verifyCrewTrust(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n): Promise<{ role: string; agentId: string; trustScore: number; status: string }[]> {\n const results = await Promise.all(\n crew.members.map(async (member) => {\n const trust = await vorim.verify(member.agentId);\n return {\n role: member.role,\n agentId: member.agentId,\n trustScore: trust.trust_score,\n status: trust.status,\n };\n }),\n );\n return results;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2GA,eAAsB,aACpB,OACA,UACyB;AACzB,QAAM,UAAkC,CAAC;AAEzC,aAAW,UAAU,SAAS,SAAS;AACrC,UAAM,SAAS,CAAC,GAAG,OAAO,MAAM;AAGhC,QAAI,OAAO,mBAAmB,CAAC,OAAO,SAAS,gBAAgB,GAAG;AAChE,aAAO,KAAK,gBAAgB;AAAA,IAC9B;AAEA,UAAM,eAAe,MAAM,MAAM,SAAS;AAAA,MACxC,MAAM,OAAO;AAAA,MACb,aAAa,OAAO,eAAe,UAAU,OAAO,IAAI,WAAM,SAAS,QAAQ;AAAA,MAC/E,cAAc,OAAO;AAAA,MACrB;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,MACX,MAAM,OAAO;AAAA,MACb,SAAS,aAAa,MAAM;AAAA,MAC5B;AAAA,MACA,YAAY,aAAa;AAAA,IAC3B,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,UAAU,SAAS;AAAA,IACnB;AAAA,IACA,UAAU,MAAc;AACtB,aAAO,QAAQ,KAAK,OAAK,EAAE,SAAS,IAAI;AAAA,IAC1C;AAAA,IACA,WAAW;AACT,aAAO,QAAQ,IAAI,OAAK,EAAE,OAAO;AAAA,IACnC;AAAA,EACF;AACF;AA8DA,eAAsB,kBACpB,OACA,OACe;AACf,QAAM,aAA8B;AAAA,IAClC,UAAU,MAAM;AAAA,IAChB,YAAY,MAAM,OAAO,cAAc;AAAA,IACvC,QAAQ,MAAM;AAAA,IACd,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM;AAAA,IACd,YAAY,MAAM;AAAA,IAClB,YAAY,MAAM,QA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AAEF,SAAO,MAAM,UAAU,WAAW;AACpC;AAgBA,eAAsB,oBACpB,OACA,MACA,MACA,OACgD;AAChD,QAAM,SAAS,KAAK,UAAU,IAAI;AAClC,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,IAAI,GAAG;AAAA,EAClE;AACA,SAAO,MAAM,MAAM,OAAO,SAAS,KAAK;AAC1C;AAMA,eAAsB,0BACpB,OACA,MACA,UACA,QACgD;AAChD,QAAM,OAAO,KAAK,UAAU,QAAQ;AACpC,QAAM,KAAK,KAAK,UAAU,MAAM;AAChC,MAAI,CAAC,KAAM,QAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,QAAQ,GAAG;AAC/E,MAAI,CAAC,GAAI,QAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,MAAM,GAAG;AAE3E,QAAM,SAAS,MAAM,MAAM,MAAM,KAAK,SAAS,gBAAgB;AAC/D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,QAAQ,mCAAmC;AAAA,EACjF;AACA,SAAO,EAAE,SAAS,KAAK;AACzB;AAQA,eAAsB,gBACpB,OACA,MACkF;AAClF,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,KAAK,QAAQ,IAAI,OAAO,WAAW;AACjC,YAAM,QAAQ,MAAM,MAAM,OAAO,OAAO,OAAO;AAC/C,aAAO;AAAA,QACL,MAAM,OAAO;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,YAAY,MAAM;AAAA,QAClB,QAAQ,MAAM;AAAA,MAChB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/crewai.ts","../../src/integrations/_runtime-gate.ts"],"sourcesContent":["// ============================================================================\n// VORIM SDK — CrewAI Integration\n// CrewAI is Python-only, so this module provides:\n// 1. A TypeScript helper for managing CrewAI agent identities via Vorim\n// 2. Audit utilities for logging crew task execution\n// 3. A \"crew manifest\" pattern for registering entire crews at once\n//\n// Use this from a TypeScript orchestration layer that triggers CrewAI\n// runs via REST, CLI, or subprocess. For native Python integration,\n// use the Vorim REST API directly (see docs).\n//\n// No peer dependencies required — uses @vorim/sdk only.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type {\n PermissionScope, AuditEventInput, AgentRegistrationResult,\n} from '../types.js';\nimport { runtimeGate, type EscalationPolicy, type TransportFailurePolicy } from './_runtime-gate.js';\n\n/**\n * Runtime-control options for crew permission gating. When `useRuntimeControl`\n * is set, checkCrewPermission routes through the full runtime decision\n * (`beforeAction`) instead of the lightweight permission check, giving CrewAI\n * parity with the OpenAI/Anthropic integrations. Requires the runtime_control\n * plan feature (Growth+).\n */\nexport interface CrewRuntimeControlOptions {\n useRuntimeControl?: boolean;\n /** What to do on an `escalate` verdict. @default 'wait' */\n onEscalation?: EscalationPolicy;\n /** Timeout (ms) for `onEscalation: 'wait'`. @default 300000 */\n escalationTimeoutMs?: number;\n /** Policy when the gate can't reach the control plane. @default 'deny' */\n onTransportFailure?: TransportFailurePolicy;\n /** Optional action payload passed to the runtime decision. */\n payload?: Record<string, unknown>;\n}\n\n// ─── Crew Configuration ──────────────────────────────────────────────────\n\nexport interface CrewMemberConfig {\n /** Unique role name within the crew (e.g. \"researcher\", \"writer\"). */\n role: string;\n /** Display name for the Vorim agent. */\n name: string;\n /** Description of this crew member's responsibilities. */\n description?: string;\n /** Tools this agent can use (e.g. [\"web_search\", \"file_read\"]). */\n capabilities: string[];\n /** Permission scopes to grant. */\n scopes: PermissionScope[];\n /** Whether this agent can delegate to other crew members. */\n allowDelegation?: boolean;\n}\n\nexport interface CrewManifest {\n /** Name for the overall crew. */\n crewName: string;\n /** Members of the crew. */\n members: CrewMemberConfig[];\n /** Optional metadata for the crew. */\n metadata?: Record<string, unknown>;\n}\n\nexport interface RegisteredCrewMember {\n role: string;\n agentId: string;\n registration: AgentRegistrationResult;\n privateKey: string;\n}\n\nexport interface RegisteredCrew {\n crewName: string;\n members: RegisteredCrewMember[];\n /** Lookup a member by role. */\n getMember(role: string): RegisteredCrewMember | undefined;\n /** Get all agent IDs in the crew. */\n agentIds(): string[];\n}\n\n// ─── Crew Registration ──────────────────────────────────────────────────\n\n/**\n * Registers an entire CrewAI crew with Vorim. Each crew member gets a\n * unique Vorim agent identity with Ed25519 keypair and scoped permissions.\n *\n * @example\n * ```ts\n * import createVorim from \"@vorim/sdk\";\n * import { registerCrew } from \"@vorim/sdk/integrations/crewai\";\n *\n * const vorim = createVorim({ apiKey: \"agid_sk_live_...\" });\n *\n * const crew = await registerCrew(vorim, {\n * crewName: \"content-pipeline\",\n * members: [\n * {\n * role: \"researcher\",\n * name: \"crew-researcher\",\n * capabilities: [\"web_search\", \"summarization\"],\n * scopes: [\"agent:read\", \"agent:execute\"],\n * },\n * {\n * role: \"writer\",\n * name: \"crew-writer\",\n * capabilities: [\"file_write\", \"formatting\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * },\n * {\n * role: \"editor\",\n * name: \"crew-editor\",\n * capabilities: [\"review\", \"approval\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * allowDelegation: true,\n * },\n * ],\n * });\n *\n * // Access individual members\n * const researcher = crew.getMember(\"researcher\");\n * console.log(researcher.agentId); // agid_acme_...\n *\n * // Grant delegation permission to editor\n * // (done automatically if allowDelegation is true)\n * ```\n */\nexport async function registerCrew(\n vorim: VorimSDK,\n manifest: CrewManifest,\n): Promise<RegisteredCrew> {\n const members: RegisteredCrewMember[] = [];\n\n for (const member of manifest.members) {\n const scopes = [...member.scopes];\n\n // Auto-add delegate scope if delegation is allowed\n if (member.allowDelegation && !scopes.includes('agent:delegate')) {\n scopes.push('agent:delegate');\n }\n\n const registration = await vorim.register({\n name: member.name,\n description: member.description ?? `CrewAI ${member.role} — ${manifest.crewName}`,\n capabilities: member.capabilities,\n scopes,\n });\n\n members.push({\n role: member.role,\n agentId: registration.agent.agent_id,\n registration,\n privateKey: registration.private_key,\n });\n }\n\n return {\n crewName: manifest.crewName,\n members,\n getMember(role: string) {\n return members.find(m => m.role === role);\n },\n agentIds() {\n return members.map(m => m.agentId);\n },\n };\n}\n\n// ─── Task Audit ──────────────────────────────────────────────────────────\n\nexport interface CrewTaskEvent {\n /** The role of the crew member performing the task. */\n role: string;\n /** The Vorim agent_id (looked up from the crew). */\n agentId: string;\n /** Task description or name. */\n task: string;\n /** Tool used (if any). */\n tool?: string;\n /** Result of the action. */\n result: 'success' | 'denied' | 'error';\n /** Duration in milliseconds. */\n latencyMs?: number;\n /** Error details if result is 'error'. */\n error?: string;\n /** Whether this was a delegation to another crew member. */\n delegatedTo?: string;\n /** Additional context. */\n metadata?: Record<string, unknown>;\n /**\n * Replayable agent decision evidence (VAIP -02).\n *\n * Stable identifier for the model that produced this task. Free-form\n * but recommended convention is `provider:model-name-version`.\n */\n modelVersion?: string;\n /**\n * SHA-256 of the canonicalised tool catalogue available to the\n * crew member at task time. Compute via {@link hashToolCatalogue}\n * from `@vorim/sdk`.\n */\n toolCatalogueHash?: string;\n /**\n * SHA-256 of the system prompt active at task time. Compute via\n * {@link hashSystemPrompt} from `@vorim/sdk`.\n */\n systemPromptHash?: string;\n}\n\n/**\n * Emits a Vorim audit event for a CrewAI task execution.\n * Call this from your orchestration layer after each CrewAI step completes.\n *\n * @example\n * ```ts\n * import { emitCrewTaskEvent } from \"@vorim/sdk/integrations/crewai\";\n *\n * // After a CrewAI task completes\n * await emitCrewTaskEvent(vorim, {\n * role: \"researcher\",\n * agentId: crew.getMember(\"researcher\").agentId,\n * task: \"research_competitors\",\n * tool: \"web_search\",\n * result: \"success\",\n * latencyMs: 3200,\n * });\n * ```\n */\nexport async function emitCrewTaskEvent(\n vorim: VorimSDK,\n event: CrewTaskEvent,\n): Promise<void> {\n const auditEvent: AuditEventInput = {\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n };\n\n await vorim.emit(auditEvent);\n}\n\n/**\n * Emits audit events for an entire crew run (batch of task results).\n *\n * @example\n * ```ts\n * await emitCrewRunEvents(vorim, [\n * { role: \"researcher\", agentId: \"...\", task: \"research\", result: \"success\" },\n * { role: \"writer\", agentId: \"...\", task: \"draft_article\", result: \"success\" },\n * { role: \"editor\", agentId: \"...\", task: \"review\", result: \"success\" },\n * ]);\n * ```\n */\nexport async function emitCrewRunEvents(\n vorim: VorimSDK,\n events: CrewTaskEvent[],\n): Promise<{ ingested: number }> {\n const auditEvents: AuditEventInput[] = events.map(event => ({\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n }));\n\n return vorim.emitBatch(auditEvents);\n}\n\n// ─── Permission Helpers ──────────────────────────────────────────────────\n\n/**\n * Check if a crew member has permission before executing a task.\n * Returns the check result — does not throw.\n *\n * @example\n * ```ts\n * const { allowed } = await checkCrewPermission(vorim, crew, \"writer\", \"agent:write\");\n * if (!allowed) {\n * console.log(\"Writer lacks write permission\");\n * }\n * ```\n */\nexport async function checkCrewPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n role: string,\n scope: PermissionScope,\n opts?: CrewRuntimeControlOptions,\n): Promise<{ allowed: boolean; reason?: string; decisionId?: string }> {\n const member = crew.getMember(role);\n if (!member) {\n return { allowed: false, reason: `Unknown crew member: ${role}` };\n }\n // With useRuntimeControl, run the full runtime decision (beforeAction) and\n // surface its decisionId for audit linkage; otherwise use the lightweight\n // permission check. Both fail closed on a transport error rather than letting\n // the rejection crash the host crew loop (matches the openai/anthropic gate).\n if (opts?.useRuntimeControl) {\n try {\n return await runtimeGate(vorim, member.agentId, role, scope, opts.payload, {\n onEscalation: opts.onEscalation,\n escalationTimeoutMs: opts.escalationTimeoutMs,\n onTransportFailure: opts.onTransportFailure,\n });\n } catch {\n return { allowed: false, reason: 'runtime gate unavailable (failed closed)' };\n }\n }\n try {\n return await vorim.check(member.agentId, scope);\n } catch {\n return { allowed: false, reason: 'permission check unavailable (failed closed)' };\n }\n}\n\n/**\n * Check if delegation between two crew members is permitted.\n * The delegating agent must have the `agent:delegate` scope.\n */\nexport async function checkDelegationPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n fromRole: string,\n toRole: string,\n): Promise<{ allowed: boolean; reason?: string }> {\n const from = crew.getMember(fromRole);\n const to = crew.getMember(toRole);\n if (!from) return { allowed: false, reason: `Unknown crew member: ${fromRole}` };\n if (!to) return { allowed: false, reason: `Unknown crew member: ${toRole}` };\n\n const result = await vorim.check(from.agentId, 'agent:delegate');\n if (!result.allowed) {\n return { allowed: false, reason: `${fromRole} lacks agent:delegate permission` };\n }\n return { allowed: true };\n}\n\n// ─── Trust Verification ──────────────────────────────────────────────────\n\n/**\n * Verify trust scores for all members of a crew.\n * Useful before starting a crew run to ensure all agents are active and trusted.\n */\nexport async function verifyCrewTrust(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n): Promise<{ role: string; agentId: string; trustScore: number; status: string }[]> {\n const results = await Promise.all(\n crew.members.map(async (member) => {\n const trust = await vorim.verify(member.agentId);\n return {\n role: member.role,\n agentId: member.agentId,\n trustScore: trust.trust_score,\n status: trust.status,\n };\n }),\n );\n return results;\n}\n","// ============================================================================\n// VORIM SDK — Shared runtime-gate helper for framework integrations\n//\n// All tool-wrapping integrations (Vercel, OpenAI, Anthropic, …) turn a\n// `beforeAction` runtime decision into a simple { allowed, reason, decisionId }\n// the wrapper can act on. The subtlety is the `escalate` verdict: it is NOT a\n// denial — it means a human must approve the action. Folding it into\n// `allowed=false` silently breaks every human-in-the-loop flow; folding it into\n// `allowed=true` is a fail-open security hole. So this helper resolves the\n// escalation explicitly, driven by the caller's `onEscalation` preference.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { RuntimeDecision, PermissionScope } from '../types.js';\n\n/**\n * How a framework integration should treat a runtime `escalate` verdict.\n * - `wait` — block and poll {@link VorimSDK.waitForDecisionResolution} until a\n * human approves/denies (or the timeout elapses → deny). The correct\n * default for human-in-the-loop: an escalation means \"ask a human\".\n * - `deny` — treat escalate as a denial (fail closed without waiting).\n * - `allow` — treat escalate as allowed (fail OPEN — only for trusted/dev use).\n */\nexport type EscalationPolicy = 'wait' | 'deny' | 'allow';\n\n/**\n * How a framework integration should treat a transport-failure `fallback`\n * decision (the control plane was unreachable and the SDK's\n * `runtimeFailOpen` produced a synthetic `decision: 'fallback'`,\n * `isFallback: true`).\n * - `deny` — fail closed: a control-plane outage denies the tool call.\n * The correct default for a SECURITY gate the caller opted into\n * via `useRuntimeControl: true`.\n * - `allow` — fail open: let the action proceed when the policy plane is\n * down (matches the raw SDK `runtimeFailOpen` behaviour).\n */\nexport type TransportFailurePolicy = 'deny' | 'allow';\n\nexport interface RuntimeGateOptions {\n /** What to do on an `escalate` verdict. @default 'wait' */\n onEscalation?: EscalationPolicy;\n /** Timeout (ms) for `onEscalation: 'wait'`. @default 300000 (5 min) */\n escalationTimeoutMs?: number;\n /**\n * What to do when the control plane is unreachable and `beforeAction`\n * returns a synthetic `fallback` decision. @default 'deny'\n *\n * The gate fails CLOSED on a policy-plane outage by default: a user who\n * turned on `useRuntimeControl: true` wants live deny/escalate\n * enforcement, so an outage should not silently auto-allow. Set to\n * `'allow'` to keep the old fail-open behaviour.\n */\n onTransportFailure?: TransportFailurePolicy;\n}\n\nexport interface GateResult {\n allowed: boolean;\n reason?: string;\n decisionId?: string;\n}\n\n/**\n * True for verdicts that permit the action to proceed. `escalate` is handled\n * separately. `fallback` is NOT treated as an allow here — a transport-failure\n * fallback is resolved explicitly via `onTransportFailure` so a control-plane\n * outage can't silently auto-allow inside a security gate.\n */\nfunction isAllowVerdict(decision: RuntimeDecision['decision']): boolean {\n return decision === 'allow' || decision === 'modify';\n}\n\n/**\n * Run a `beforeAction` runtime decision and collapse it to a {@link GateResult},\n * resolving `escalate` per {@link RuntimeGateOptions.onEscalation}.\n *\n * Requires (for `onEscalation: 'wait'`) an API key with the `runtime:decide`\n * scope — the same scope `beforeAction` itself uses.\n */\nexport async function runtimeGate(\n vorim: VorimSDK,\n agentId: string,\n actionTarget: string,\n scope: PermissionScope,\n payload: Record<string, unknown> | undefined,\n opts: RuntimeGateOptions = {},\n): Promise<GateResult> {\n const onEscalation = opts.onEscalation ?? 'wait';\n const onTransportFailure = opts.onTransportFailure ?? 'deny';\n const d = await vorim.beforeAction(\n { agentId, actionType: 'tool_call', actionTarget, requiredScope: scope, payload },\n { throwOnDeny: false },\n );\n\n // Control-plane outage: beforeAction returned a synthetic fallback\n // (isFallback). Govern it by onTransportFailure (default 'deny') rather\n // than auto-allowing — the caller turned on runtime control for live\n // enforcement, so an outage should fail closed unless they opt out.\n if (d.isFallback || d.decision === 'fallback') {\n if (onTransportFailure === 'allow') {\n return { allowed: true, reason: d.reason ?? 'control plane unreachable (fail-open)', decisionId: d.decisionId || undefined };\n }\n return { allowed: false, reason: d.reason ?? 'control plane unreachable (failed closed)', decisionId: d.decisionId || undefined };\n }\n\n if (d.decision !== 'escalate') {\n return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || undefined };\n }\n\n // escalate ── a human must decide.\n if (onEscalation === 'allow') {\n return { allowed: true, reason: d.reason ?? 'escalated (auto-allowed)', decisionId: d.decisionId || undefined };\n }\n if (onEscalation === 'deny') {\n return { allowed: false, reason: d.reason ?? 'escalated (auto-denied — awaiting human)', decisionId: d.decisionId || undefined };\n }\n // 'wait' — poll for the human decision. On timeout, fail closed (deny).\n if (!d.decisionId) {\n return { allowed: false, reason: 'escalated but no decisionId to poll', decisionId: undefined };\n }\n try {\n const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });\n return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };\n } catch {\n // ESCALATION_TIMEOUT (or any poll error) → fail closed.\n return { allowed: false, reason: 'escalation not resolved before timeout', decisionId: d.decisionId };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmEA,SAAS,eAAe,UAAgD;AACtE,SAAO,aAAa,WAAW,aAAa;AAC9C;AASA,eAAsB,YACpB,OACA,SACA,cACA,OACA,SACA,OAA2B,CAAC,GACP;AACrB,QAAM,eAAe,KAAK,gBAAgB;AAC1C,QAAM,qBAAqB,KAAK,sBAAsB;AACtD,QAAM,IAAI,MAAM,MAAM;AAAA,IACpB,EAAE,SAAS,YAAY,aAAa,cAAc,eAAe,OAAO,QAAQ;AAAA,IAChF,EAAE,aAAa,MAAM;AAAA,EACvB;AAMA,MAAI,EAAE,cAAc,EAAE,aAAa,YAAY;AAC7C,QAAI,uBAAuB,SAAS;AAClC,aAAO,EAAE,SAAS,MAAM,QAAQ,EAAE,UAAU,yCAAyC,YAAY,EAAE,cAAc,OAAU;AAAA,IAC7H;AACA,WAAO,EAAE,SAAS,OAAO,QAAQ,E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ACF;AAMA,eAAsB,0BACpB,OACA,MACA,UACA,QACgD;AAChD,QAAM,OAAO,KAAK,UAAU,QAAQ;AACpC,QAAM,KAAK,KAAK,UAAU,MAAM;AAChC,MAAI,CAAC,KAAM,QAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,QAAQ,GAAG;AAC/E,MAAI,CAAC,GAAI,QAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,MAAM,GAAG;AAE3E,QAAM,SAAS,MAAM,MAAM,MAAM,KAAK,SAAS,gBAAgB;AAC/D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,QAAQ,mCAAmC;AAAA,EACjF;AACA,SAAO,EAAE,SAAS,KAAK;AACzB;AAQA,eAAsB,gBACpB,OACA,MACkF;AAClF,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,KAAK,QAAQ,IAAI,OAAO,WAAW;AACjC,YAAM,QAAQ,MAAM,MAAM,OAAO,OAAO,OAAO;AAC/C,aAAO;AAAA,QACL,MAAM,OAAO;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,YAAY,MAAM;AAAA,QAClB,QAAQ,MAAM;AAAA,MAChB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { VorimSDK } from '../index.cjs';
|
|
2
|
-
import { P as PermissionScope, A as AgentRegistrationResult } from '../types-
|
|
2
|
+
import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.cjs';
|
|
3
|
+
import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Runtime-control options for crew permission gating. When `useRuntimeControl`
|
|
7
|
+
* is set, checkCrewPermission routes through the full runtime decision
|
|
8
|
+
* (`beforeAction`) instead of the lightweight permission check, giving CrewAI
|
|
9
|
+
* parity with the OpenAI/Anthropic integrations. Requires the runtime_control
|
|
10
|
+
* plan feature (Growth+).
|
|
11
|
+
*/
|
|
12
|
+
interface CrewRuntimeControlOptions {
|
|
13
|
+
useRuntimeControl?: boolean;
|
|
14
|
+
/** What to do on an `escalate` verdict. @default 'wait' */
|
|
15
|
+
onEscalation?: EscalationPolicy;
|
|
16
|
+
/** Timeout (ms) for `onEscalation: 'wait'`. @default 300000 */
|
|
17
|
+
escalationTimeoutMs?: number;
|
|
18
|
+
/** Policy when the gate can't reach the control plane. @default 'deny' */
|
|
19
|
+
onTransportFailure?: TransportFailurePolicy;
|
|
20
|
+
/** Optional action payload passed to the runtime decision. */
|
|
21
|
+
payload?: Record<string, unknown>;
|
|
22
|
+
}
|
|
4
23
|
interface CrewMemberConfig {
|
|
5
24
|
/** Unique role name within the crew (e.g. "researcher", "writer"). */
|
|
6
25
|
role: string;
|
|
@@ -167,9 +186,10 @@ declare function emitCrewRunEvents(vorim: VorimSDK, events: CrewTaskEvent[]): Pr
|
|
|
167
186
|
* }
|
|
168
187
|
* ```
|
|
169
188
|
*/
|
|
170
|
-
declare function checkCrewPermission(vorim: VorimSDK, crew: RegisteredCrew, role: string, scope: PermissionScope): Promise<{
|
|
189
|
+
declare function checkCrewPermission(vorim: VorimSDK, crew: RegisteredCrew, role: string, scope: PermissionScope, opts?: CrewRuntimeControlOptions): Promise<{
|
|
171
190
|
allowed: boolean;
|
|
172
191
|
reason?: string;
|
|
192
|
+
decisionId?: string;
|
|
173
193
|
}>;
|
|
174
194
|
/**
|
|
175
195
|
* Check if delegation between two crew members is permitted.
|
|
@@ -190,4 +210,4 @@ declare function verifyCrewTrust(vorim: VorimSDK, crew: RegisteredCrew): Promise
|
|
|
190
210
|
status: string;
|
|
191
211
|
}[]>;
|
|
192
212
|
|
|
193
|
-
export { type CrewManifest, type CrewMemberConfig, type CrewTaskEvent, type RegisteredCrew, type RegisteredCrewMember, checkCrewPermission, checkDelegationPermission, emitCrewRunEvents, emitCrewTaskEvent, registerCrew, verifyCrewTrust };
|
|
213
|
+
export { type CrewManifest, type CrewMemberConfig, type CrewRuntimeControlOptions, type CrewTaskEvent, type RegisteredCrew, type RegisteredCrewMember, checkCrewPermission, checkDelegationPermission, emitCrewRunEvents, emitCrewTaskEvent, registerCrew, verifyCrewTrust };
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { VorimSDK } from '../index.js';
|
|
2
|
-
import { P as PermissionScope, A as AgentRegistrationResult } from '../types-
|
|
2
|
+
import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.js';
|
|
3
|
+
import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Runtime-control options for crew permission gating. When `useRuntimeControl`
|
|
7
|
+
* is set, checkCrewPermission routes through the full runtime decision
|
|
8
|
+
* (`beforeAction`) instead of the lightweight permission check, giving CrewAI
|
|
9
|
+
* parity with the OpenAI/Anthropic integrations. Requires the runtime_control
|
|
10
|
+
* plan feature (Growth+).
|
|
11
|
+
*/
|
|
12
|
+
interface CrewRuntimeControlOptions {
|
|
13
|
+
useRuntimeControl?: boolean;
|
|
14
|
+
/** What to do on an `escalate` verdict. @default 'wait' */
|
|
15
|
+
onEscalation?: EscalationPolicy;
|
|
16
|
+
/** Timeout (ms) for `onEscalation: 'wait'`. @default 300000 */
|
|
17
|
+
escalationTimeoutMs?: number;
|
|
18
|
+
/** Policy when the gate can't reach the control plane. @default 'deny' */
|
|
19
|
+
onTransportFailure?: TransportFailurePolicy;
|
|
20
|
+
/** Optional action payload passed to the runtime decision. */
|
|
21
|
+
payload?: Record<string, unknown>;
|
|
22
|
+
}
|
|
4
23
|
interface CrewMemberConfig {
|
|
5
24
|
/** Unique role name within the crew (e.g. "researcher", "writer"). */
|
|
6
25
|
role: string;
|
|
@@ -167,9 +186,10 @@ declare function emitCrewRunEvents(vorim: VorimSDK, events: CrewTaskEvent[]): Pr
|
|
|
167
186
|
* }
|
|
168
187
|
* ```
|
|
169
188
|
*/
|
|
170
|
-
declare function checkCrewPermission(vorim: VorimSDK, crew: RegisteredCrew, role: string, scope: PermissionScope): Promise<{
|
|
189
|
+
declare function checkCrewPermission(vorim: VorimSDK, crew: RegisteredCrew, role: string, scope: PermissionScope, opts?: CrewRuntimeControlOptions): Promise<{
|
|
171
190
|
allowed: boolean;
|
|
172
191
|
reason?: string;
|
|
192
|
+
decisionId?: string;
|
|
173
193
|
}>;
|
|
174
194
|
/**
|
|
175
195
|
* Check if delegation between two crew members is permitted.
|
|
@@ -190,4 +210,4 @@ declare function verifyCrewTrust(vorim: VorimSDK, crew: RegisteredCrew): Promise
|
|
|
190
210
|
status: string;
|
|
191
211
|
}[]>;
|
|
192
212
|
|
|
193
|
-
export { type CrewManifest, type CrewMemberConfig, type CrewTaskEvent, type RegisteredCrew, type RegisteredCrewMember, checkCrewPermission, checkDelegationPermission, emitCrewRunEvents, emitCrewTaskEvent, registerCrew, verifyCrewTrust };
|
|
213
|
+
export { type CrewManifest, type CrewMemberConfig, type CrewRuntimeControlOptions, type CrewTaskEvent, type RegisteredCrew, type RegisteredCrewMember, checkCrewPermission, checkDelegationPermission, emitCrewRunEvents, emitCrewTaskEvent, registerCrew, verifyCrewTrust };
|
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
// src/integrations/_runtime-gate.ts
|
|
2
|
+
function isAllowVerdict(decision) {
|
|
3
|
+
return decision === "allow" || decision === "modify";
|
|
4
|
+
}
|
|
5
|
+
async function runtimeGate(vorim, agentId, actionTarget, scope, payload, opts = {}) {
|
|
6
|
+
const onEscalation = opts.onEscalation ?? "wait";
|
|
7
|
+
const onTransportFailure = opts.onTransportFailure ?? "deny";
|
|
8
|
+
const d = await vorim.beforeAction(
|
|
9
|
+
{ agentId, actionType: "tool_call", actionTarget, requiredScope: scope, payload },
|
|
10
|
+
{ throwOnDeny: false }
|
|
11
|
+
);
|
|
12
|
+
if (d.isFallback || d.decision === "fallback") {
|
|
13
|
+
if (onTransportFailure === "allow") {
|
|
14
|
+
return { allowed: true, reason: d.reason ?? "control plane unreachable (fail-open)", decisionId: d.decisionId || void 0 };
|
|
15
|
+
}
|
|
16
|
+
return { allowed: false, reason: d.reason ?? "control plane unreachable (failed closed)", decisionId: d.decisionId || void 0 };
|
|
17
|
+
}
|
|
18
|
+
if (d.decision !== "escalate") {
|
|
19
|
+
return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || void 0 };
|
|
20
|
+
}
|
|
21
|
+
if (onEscalation === "allow") {
|
|
22
|
+
return { allowed: true, reason: d.reason ?? "escalated (auto-allowed)", decisionId: d.decisionId || void 0 };
|
|
23
|
+
}
|
|
24
|
+
if (onEscalation === "deny") {
|
|
25
|
+
return { allowed: false, reason: d.reason ?? "escalated (auto-denied \u2014 awaiting human)", decisionId: d.decisionId || void 0 };
|
|
26
|
+
}
|
|
27
|
+
if (!d.decisionId) {
|
|
28
|
+
return { allowed: false, reason: "escalated but no decisionId to poll", decisionId: void 0 };
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });
|
|
32
|
+
return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };
|
|
33
|
+
} catch {
|
|
34
|
+
return { allowed: false, reason: "escalation not resolved before timeout", decisionId: d.decisionId };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
1
38
|
// src/integrations/crewai.ts
|
|
2
39
|
async function registerCrew(vorim, manifest) {
|
|
3
40
|
const members = [];
|
|
@@ -74,12 +111,27 @@ async function emitCrewRunEvents(vorim, events) {
|
|
|
74
111
|
}));
|
|
75
112
|
return vorim.emitBatch(auditEvents);
|
|
76
113
|
}
|
|
77
|
-
async function checkCrewPermission(vorim, crew, role, scope) {
|
|
114
|
+
async function checkCrewPermission(vorim, crew, role, scope, opts) {
|
|
78
115
|
const member = crew.getMember(role);
|
|
79
116
|
if (!member) {
|
|
80
117
|
return { allowed: false, reason: `Unknown crew member: ${role}` };
|
|
81
118
|
}
|
|
82
|
-
|
|
119
|
+
if (opts?.useRuntimeControl) {
|
|
120
|
+
try {
|
|
121
|
+
return await runtimeGate(vorim, member.agentId, role, scope, opts.payload, {
|
|
122
|
+
onEscalation: opts.onEscalation,
|
|
123
|
+
escalationTimeoutMs: opts.escalationTimeoutMs,
|
|
124
|
+
onTransportFailure: opts.onTransportFailure
|
|
125
|
+
});
|
|
126
|
+
} catch {
|
|
127
|
+
return { allowed: false, reason: "runtime gate unavailable (failed closed)" };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
return await vorim.check(member.agentId, scope);
|
|
132
|
+
} catch {
|
|
133
|
+
return { allowed: false, reason: "permission check unavailable (failed closed)" };
|
|
134
|
+
}
|
|
83
135
|
}
|
|
84
136
|
async function checkDelegationPermission(vorim, crew, fromRole, toRole) {
|
|
85
137
|
const from = crew.getMember(fromRole);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/integrations/crewai.ts"],"sourcesContent":["// ============================================================================\n// VORIM SDK — CrewAI Integration\n// CrewAI is Python-only, so this module provides:\n// 1. A TypeScript helper for managing CrewAI agent identities via Vorim\n// 2. Audit utilities for logging crew task execution\n// 3. A \"crew manifest\" pattern for registering entire crews at once\n//\n// Use this from a TypeScript orchestration layer that triggers CrewAI\n// runs via REST, CLI, or subprocess. For native Python integration,\n// use the Vorim REST API directly (see docs).\n//\n// No peer dependencies required — uses @vorim/sdk only.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type {\n PermissionScope, AuditEventInput, AgentRegistrationResult,\n} from '../types.js';\n\n// ─── Crew Configuration ──────────────────────────────────────────────────\n\nexport interface CrewMemberConfig {\n /** Unique role name within the crew (e.g. \"researcher\", \"writer\"). */\n role: string;\n /** Display name for the Vorim agent. */\n name: string;\n /** Description of this crew member's responsibilities. */\n description?: string;\n /** Tools this agent can use (e.g. [\"web_search\", \"file_read\"]). */\n capabilities: string[];\n /** Permission scopes to grant. */\n scopes: PermissionScope[];\n /** Whether this agent can delegate to other crew members. */\n allowDelegation?: boolean;\n}\n\nexport interface CrewManifest {\n /** Name for the overall crew. */\n crewName: string;\n /** Members of the crew. */\n members: CrewMemberConfig[];\n /** Optional metadata for the crew. */\n metadata?: Record<string, unknown>;\n}\n\nexport interface RegisteredCrewMember {\n role: string;\n agentId: string;\n registration: AgentRegistrationResult;\n privateKey: string;\n}\n\nexport interface RegisteredCrew {\n crewName: string;\n members: RegisteredCrewMember[];\n /** Lookup a member by role. */\n getMember(role: string): RegisteredCrewMember | undefined;\n /** Get all agent IDs in the crew. */\n agentIds(): string[];\n}\n\n// ─── Crew Registration ──────────────────────────────────────────────────\n\n/**\n * Registers an entire CrewAI crew with Vorim. Each crew member gets a\n * unique Vorim agent identity with Ed25519 keypair and scoped permissions.\n *\n * @example\n * ```ts\n * import createVorim from \"@vorim/sdk\";\n * import { registerCrew } from \"@vorim/sdk/integrations/crewai\";\n *\n * const vorim = createVorim({ apiKey: \"agid_sk_live_...\" });\n *\n * const crew = await registerCrew(vorim, {\n * crewName: \"content-pipeline\",\n * members: [\n * {\n * role: \"researcher\",\n * name: \"crew-researcher\",\n * capabilities: [\"web_search\", \"summarization\"],\n * scopes: [\"agent:read\", \"agent:execute\"],\n * },\n * {\n * role: \"writer\",\n * name: \"crew-writer\",\n * capabilities: [\"file_write\", \"formatting\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * },\n * {\n * role: \"editor\",\n * name: \"crew-editor\",\n * capabilities: [\"review\", \"approval\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * allowDelegation: true,\n * },\n * ],\n * });\n *\n * // Access individual members\n * const researcher = crew.getMember(\"researcher\");\n * console.log(researcher.agentId); // agid_acme_...\n *\n * // Grant delegation permission to editor\n * // (done automatically if allowDelegation is true)\n * ```\n */\nexport async function registerCrew(\n vorim: VorimSDK,\n manifest: CrewManifest,\n): Promise<RegisteredCrew> {\n const members: RegisteredCrewMember[] = [];\n\n for (const member of manifest.members) {\n const scopes = [...member.scopes];\n\n // Auto-add delegate scope if delegation is allowed\n if (member.allowDelegation && !scopes.includes('agent:delegate')) {\n scopes.push('agent:delegate');\n }\n\n const registration = await vorim.register({\n name: member.name,\n description: member.description ?? `CrewAI ${member.role} — ${manifest.crewName}`,\n capabilities: member.capabilities,\n scopes,\n });\n\n members.push({\n role: member.role,\n agentId: registration.agent.agent_id,\n registration,\n privateKey: registration.private_key,\n });\n }\n\n return {\n crewName: manifest.crewName,\n members,\n getMember(role: string) {\n return members.find(m => m.role === role);\n },\n agentIds() {\n return members.map(m => m.agentId);\n },\n };\n}\n\n// ─── Task Audit ──────────────────────────────────────────────────────────\n\nexport interface CrewTaskEvent {\n /** The role of the crew member performing the task. */\n role: string;\n /** The Vorim agent_id (looked up from the crew). */\n agentId: string;\n /** Task description or name. */\n task: string;\n /** Tool used (if any). */\n tool?: string;\n /** Result of the action. */\n result: 'success' | 'denied' | 'error';\n /** Duration in milliseconds. */\n latencyMs?: number;\n /** Error details if result is 'error'. */\n error?: string;\n /** Whether this was a delegation to another crew member. */\n delegatedTo?: string;\n /** Additional context. */\n metadata?: Record<string, unknown>;\n /**\n * Replayable agent decision evidence (VAIP -02).\n *\n * Stable identifier for the model that produced this task. Free-form\n * but recommended convention is `provider:model-name-version`.\n */\n modelVersion?: string;\n /**\n * SHA-256 of the canonicalised tool catalogue available to the\n * crew member at task time. Compute via {@link hashToolCatalogue}\n * from `@vorim/sdk`.\n */\n toolCatalogueHash?: string;\n /**\n * SHA-256 of the system prompt active at task time. Compute via\n * {@link hashSystemPrompt} from `@vorim/sdk`.\n */\n systemPromptHash?: string;\n}\n\n/**\n * Emits a Vorim audit event for a CrewAI task execution.\n * Call this from your orchestration layer after each CrewAI step completes.\n *\n * @example\n * ```ts\n * import { emitCrewTaskEvent } from \"@vorim/sdk/integrations/crewai\";\n *\n * // After a CrewAI task completes\n * await emitCrewTaskEvent(vorim, {\n * role: \"researcher\",\n * agentId: crew.getMember(\"researcher\").agentId,\n * task: \"research_competitors\",\n * tool: \"web_search\",\n * result: \"success\",\n * latencyMs: 3200,\n * });\n * ```\n */\nexport async function emitCrewTaskEvent(\n vorim: VorimSDK,\n event: CrewTaskEvent,\n): Promise<void> {\n const auditEvent: AuditEventInput = {\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n };\n\n await vorim.emit(auditEvent);\n}\n\n/**\n * Emits audit events for an entire crew run (batch of task results).\n *\n * @example\n * ```ts\n * await emitCrewRunEvents(vorim, [\n * { role: \"researcher\", agentId: \"...\", task: \"research\", result: \"success\" },\n * { role: \"writer\", agentId: \"...\", task: \"draft_article\", result: \"success\" },\n * { role: \"editor\", agentId: \"...\", task: \"review\", result: \"success\" },\n * ]);\n * ```\n */\nexport async function emitCrewRunEvents(\n vorim: VorimSDK,\n events: CrewTaskEvent[],\n): Promise<{ ingested: number }> {\n const auditEvents: AuditEventInput[] = events.map(event => ({\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n }));\n\n return vorim.emitBatch(auditEvents);\n}\n\n// ─── Permission Helpers ──────────────────────────────────────────────────\n\n/**\n * Check if a crew member has permission before executing a task.\n * Returns the check result — does not throw.\n *\n * @example\n * ```ts\n * const { allowed } = await checkCrewPermission(vorim, crew, \"writer\", \"agent:write\");\n * if (!allowed) {\n * console.log(\"Writer lacks write permission\");\n * }\n * ```\n */\nexport async function checkCrewPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n role: string,\n scope: PermissionScope,\n): Promise<{ allowed: boolean; reason?: string }> {\n const member = crew.getMember(role);\n if (!member) {\n return { allowed: false, reason: `Unknown crew member: ${role}` };\n }\n return vorim.check(member.agentId, scope);\n}\n\n/**\n * Check if delegation between two crew members is permitted.\n * The delegating agent must have the `agent:delegate` scope.\n */\nexport async function checkDelegationPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n fromRole: string,\n toRole: string,\n): Promise<{ allowed: boolean; reason?: string }> {\n const from = crew.getMember(fromRole);\n const to = crew.getMember(toRole);\n if (!from) return { allowed: false, reason: `Unknown crew member: ${fromRole}` };\n if (!to) return { allowed: false, reason: `Unknown crew member: ${toRole}` };\n\n const result = await vorim.check(from.agentId, 'agent:delegate');\n if (!result.allowed) {\n return { allowed: false, reason: `${fromRole} lacks agent:delegate permission` };\n }\n return { allowed: true };\n}\n\n// ─── Trust Verification ──────────────────────────────────────────────────\n\n/**\n * Verify trust scores for all members of a crew.\n * Useful before starting a crew run to ensure all agents are active and trusted.\n */\nexport async function verifyCrewTrust(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n): Promise<{ role: string; agentId: string; trustScore: number; status: string }[]> {\n const results = await Promise.all(\n crew.members.map(async (member) => {\n const trust = await vorim.verify(member.agentId);\n return {\n role: member.role,\n agentId: member.agentId,\n trustScore: trust.trust_score,\n status: trust.status,\n };\n }),\n );\n return results;\n}\n"],"mappings":";AA2GA,eAAsB,aACpB,OACA,UACyB;AACzB,QAAM,UAAkC,CAAC;AAEzC,aAAW,UAAU,SAAS,SAAS;AACrC,UAAM,SAAS,CAAC,GAAG,OAAO,MAAM;AAGhC,QAAI,OAAO,mBAAmB,CAAC,OAAO,SAAS,gBAAgB,GAAG;AAChE,aAAO,KAAK,gBAAgB;AAAA,IAC9B;AAEA,UAAM,eAAe,MAAM,MAAM,SAAS;AAAA,MACxC,MAAM,OAAO;AAAA,MACb,aAAa,OAAO,eAAe,UAAU,OAAO,IAAI,WAAM,SAAS,QAAQ;AAAA,MAC/E,cAAc,OAAO;AAAA,MACrB;AAAA,IACF,CAAC;AAED,YAAQ,KAAK;AAAA,MACX,MAAM,OAAO;AAAA,MACb,SAAS,aAAa,MAAM;AAAA,MAC5B;AAAA,MACA,YAAY,aAAa;AAAA,IAC3B,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,UAAU,SAAS;AAAA,IACnB;AAAA,IACA,UAAU,MAAc;AACtB,aAAO,QAAQ,KAAK,OAAK,EAAE,SAAS,IAAI;AAAA,IAC1C;AAAA,IACA,WAAW;AACT,aAAO,QAAQ,IAAI,OAAK,EAAE,OAAO;AAAA,IACnC;AAAA,EACF;AACF;AA8DA,eAAsB,kBACpB,OACA,OACe;AACf,QAAM,aAA8B;AAAA,IAClC,UAAU,MAAM;AAAA,IAChB,YAAY,MAAM,OAAO,cAAc;AAAA,IACvC,QAAQ,MAAM;AAAA,IACd,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM;AAAA,IACd,YAAY,MAAM;AAAA,IAClB,YAAY,MAAM,QAAQ,oBAAoB;AAAA,IAC9C,UAAU;AAAA,MACR,WAAW;AAAA,MACX,MAAM,MAAM;AAAA,MACZ,GAAI,MAAM,cAAc,EAAE,cAAc,MAAM,YAAY,IAAI,CAAC;A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AACX,WAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,IAAI,GAAG;AAAA,EAClE;AACA,SAAO,MAAM,MAAM,OAAO,SAAS,KAAK;AAC1C;AAMA,eAAsB,0BACpB,OACA,MACA,UACA,QACgD;AAChD,QAAM,OAAO,KAAK,UAAU,QAAQ;AACpC,QAAM,KAAK,KAAK,UAAU,MAAM;AAChC,MAAI,CAAC,KAAM,QAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,QAAQ,GAAG;AAC/E,MAAI,CAAC,GAAI,QAAO,EAAE,SAAS,OAAO,QAAQ,wBAAwB,MAAM,GAAG;AAE3E,QAAM,SAAS,MAAM,MAAM,MAAM,KAAK,SAAS,gBAAgB;AAC/D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,QAAQ,mCAAmC;AAAA,EACjF;AACA,SAAO,EAAE,SAAS,KAAK;AACzB;AAQA,eAAsB,gBACpB,OACA,MACkF;AAClF,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,KAAK,QAAQ,IAAI,OAAO,WAAW;AACjC,YAAM,QAAQ,MAAM,MAAM,OAAO,OAAO,OAAO;AAC/C,aAAO;AAAA,QACL,MAAM,OAAO;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,YAAY,MAAM;AAAA,QAClB,QAAQ,MAAM;AAAA,MAChB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/_runtime-gate.ts","../../src/integrations/crewai.ts"],"sourcesContent":["// ============================================================================\n// VORIM SDK — Shared runtime-gate helper for framework integrations\n//\n// All tool-wrapping integrations (Vercel, OpenAI, Anthropic, …) turn a\n// `beforeAction` runtime decision into a simple { allowed, reason, decisionId }\n// the wrapper can act on. The subtlety is the `escalate` verdict: it is NOT a\n// denial — it means a human must approve the action. Folding it into\n// `allowed=false` silently breaks every human-in-the-loop flow; folding it into\n// `allowed=true` is a fail-open security hole. So this helper resolves the\n// escalation explicitly, driven by the caller's `onEscalation` preference.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { RuntimeDecision, PermissionScope } from '../types.js';\n\n/**\n * How a framework integration should treat a runtime `escalate` verdict.\n * - `wait` — block and poll {@link VorimSDK.waitForDecisionResolution} until a\n * human approves/denies (or the timeout elapses → deny). The correct\n * default for human-in-the-loop: an escalation means \"ask a human\".\n * - `deny` — treat escalate as a denial (fail closed without waiting).\n * - `allow` — treat escalate as allowed (fail OPEN — only for trusted/dev use).\n */\nexport type EscalationPolicy = 'wait' | 'deny' | 'allow';\n\n/**\n * How a framework integration should treat a transport-failure `fallback`\n * decision (the control plane was unreachable and the SDK's\n * `runtimeFailOpen` produced a synthetic `decision: 'fallback'`,\n * `isFallback: true`).\n * - `deny` — fail closed: a control-plane outage denies the tool call.\n * The correct default for a SECURITY gate the caller opted into\n * via `useRuntimeControl: true`.\n * - `allow` — fail open: let the action proceed when the policy plane is\n * down (matches the raw SDK `runtimeFailOpen` behaviour).\n */\nexport type TransportFailurePolicy = 'deny' | 'allow';\n\nexport interface RuntimeGateOptions {\n /** What to do on an `escalate` verdict. @default 'wait' */\n onEscalation?: EscalationPolicy;\n /** Timeout (ms) for `onEscalation: 'wait'`. @default 300000 (5 min) */\n escalationTimeoutMs?: number;\n /**\n * What to do when the control plane is unreachable and `beforeAction`\n * returns a synthetic `fallback` decision. @default 'deny'\n *\n * The gate fails CLOSED on a policy-plane outage by default: a user who\n * turned on `useRuntimeControl: true` wants live deny/escalate\n * enforcement, so an outage should not silently auto-allow. Set to\n * `'allow'` to keep the old fail-open behaviour.\n */\n onTransportFailure?: TransportFailurePolicy;\n}\n\nexport interface GateResult {\n allowed: boolean;\n reason?: string;\n decisionId?: string;\n}\n\n/**\n * True for verdicts that permit the action to proceed. `escalate` is handled\n * separately. `fallback` is NOT treated as an allow here — a transport-failure\n * fallback is resolved explicitly via `onTransportFailure` so a control-plane\n * outage can't silently auto-allow inside a security gate.\n */\nfunction isAllowVerdict(decision: RuntimeDecision['decision']): boolean {\n return decision === 'allow' || decision === 'modify';\n}\n\n/**\n * Run a `beforeAction` runtime decision and collapse it to a {@link GateResult},\n * resolving `escalate` per {@link RuntimeGateOptions.onEscalation}.\n *\n * Requires (for `onEscalation: 'wait'`) an API key with the `runtime:decide`\n * scope — the same scope `beforeAction` itself uses.\n */\nexport async function runtimeGate(\n vorim: VorimSDK,\n agentId: string,\n actionTarget: string,\n scope: PermissionScope,\n payload: Record<string, unknown> | undefined,\n opts: RuntimeGateOptions = {},\n): Promise<GateResult> {\n const onEscalation = opts.onEscalation ?? 'wait';\n const onTransportFailure = opts.onTransportFailure ?? 'deny';\n const d = await vorim.beforeAction(\n { agentId, actionType: 'tool_call', actionTarget, requiredScope: scope, payload },\n { throwOnDeny: false },\n );\n\n // Control-plane outage: beforeAction returned a synthetic fallback\n // (isFallback). Govern it by onTransportFailure (default 'deny') rather\n // than auto-allowing — the caller turned on runtime control for live\n // enforcement, so an outage should fail closed unless they opt out.\n if (d.isFallback || d.decision === 'fallback') {\n if (onTransportFailure === 'allow') {\n return { allowed: true, reason: d.reason ?? 'control plane unreachable (fail-open)', decisionId: d.decisionId || undefined };\n }\n return { allowed: false, reason: d.reason ?? 'control plane unreachable (failed closed)', decisionId: d.decisionId || undefined };\n }\n\n if (d.decision !== 'escalate') {\n return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || undefined };\n }\n\n // escalate ── a human must decide.\n if (onEscalation === 'allow') {\n return { allowed: true, reason: d.reason ?? 'escalated (auto-allowed)', decisionId: d.decisionId || undefined };\n }\n if (onEscalation === 'deny') {\n return { allowed: false, reason: d.reason ?? 'escalated (auto-denied — awaiting human)', decisionId: d.decisionId || undefined };\n }\n // 'wait' — poll for the human decision. On timeout, fail closed (deny).\n if (!d.decisionId) {\n return { allowed: false, reason: 'escalated but no decisionId to poll', decisionId: undefined };\n }\n try {\n const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });\n return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };\n } catch {\n // ESCALATION_TIMEOUT (or any poll error) → fail closed.\n return { allowed: false, reason: 'escalation not resolved before timeout', decisionId: d.decisionId };\n }\n}\n","// ============================================================================\n// VORIM SDK — CrewAI Integration\n// CrewAI is Python-only, so this module provides:\n// 1. A TypeScript helper for managing CrewAI agent identities via Vorim\n// 2. Audit utilities for logging crew task execution\n// 3. A \"crew manifest\" pattern for registering entire crews at once\n//\n// Use this from a TypeScript orchestration layer that triggers CrewAI\n// runs via REST, CLI, or subprocess. For native Python integration,\n// use the Vorim REST API directly (see docs).\n//\n// No peer dependencies required — uses @vorim/sdk only.\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type {\n PermissionScope, AuditEventInput, AgentRegistrationResult,\n} from '../types.js';\nimport { runtimeGate, type EscalationPolicy, type TransportFailurePolicy } from './_runtime-gate.js';\n\n/**\n * Runtime-control options for crew permission gating. When `useRuntimeControl`\n * is set, checkCrewPermission routes through the full runtime decision\n * (`beforeAction`) instead of the lightweight permission check, giving CrewAI\n * parity with the OpenAI/Anthropic integrations. Requires the runtime_control\n * plan feature (Growth+).\n */\nexport interface CrewRuntimeControlOptions {\n useRuntimeControl?: boolean;\n /** What to do on an `escalate` verdict. @default 'wait' */\n onEscalation?: EscalationPolicy;\n /** Timeout (ms) for `onEscalation: 'wait'`. @default 300000 */\n escalationTimeoutMs?: number;\n /** Policy when the gate can't reach the control plane. @default 'deny' */\n onTransportFailure?: TransportFailurePolicy;\n /** Optional action payload passed to the runtime decision. */\n payload?: Record<string, unknown>;\n}\n\n// ─── Crew Configuration ──────────────────────────────────────────────────\n\nexport interface CrewMemberConfig {\n /** Unique role name within the crew (e.g. \"researcher\", \"writer\"). */\n role: string;\n /** Display name for the Vorim agent. */\n name: string;\n /** Description of this crew member's responsibilities. */\n description?: string;\n /** Tools this agent can use (e.g. [\"web_search\", \"file_read\"]). */\n capabilities: string[];\n /** Permission scopes to grant. */\n scopes: PermissionScope[];\n /** Whether this agent can delegate to other crew members. */\n allowDelegation?: boolean;\n}\n\nexport interface CrewManifest {\n /** Name for the overall crew. */\n crewName: string;\n /** Members of the crew. */\n members: CrewMemberConfig[];\n /** Optional metadata for the crew. */\n metadata?: Record<string, unknown>;\n}\n\nexport interface RegisteredCrewMember {\n role: string;\n agentId: string;\n registration: AgentRegistrationResult;\n privateKey: string;\n}\n\nexport interface RegisteredCrew {\n crewName: string;\n members: RegisteredCrewMember[];\n /** Lookup a member by role. */\n getMember(role: string): RegisteredCrewMember | undefined;\n /** Get all agent IDs in the crew. */\n agentIds(): string[];\n}\n\n// ─── Crew Registration ──────────────────────────────────────────────────\n\n/**\n * Registers an entire CrewAI crew with Vorim. Each crew member gets a\n * unique Vorim agent identity with Ed25519 keypair and scoped permissions.\n *\n * @example\n * ```ts\n * import createVorim from \"@vorim/sdk\";\n * import { registerCrew } from \"@vorim/sdk/integrations/crewai\";\n *\n * const vorim = createVorim({ apiKey: \"agid_sk_live_...\" });\n *\n * const crew = await registerCrew(vorim, {\n * crewName: \"content-pipeline\",\n * members: [\n * {\n * role: \"researcher\",\n * name: \"crew-researcher\",\n * capabilities: [\"web_search\", \"summarization\"],\n * scopes: [\"agent:read\", \"agent:execute\"],\n * },\n * {\n * role: \"writer\",\n * name: \"crew-writer\",\n * capabilities: [\"file_write\", \"formatting\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * },\n * {\n * role: \"editor\",\n * name: \"crew-editor\",\n * capabilities: [\"review\", \"approval\"],\n * scopes: [\"agent:read\", \"agent:write\"],\n * allowDelegation: true,\n * },\n * ],\n * });\n *\n * // Access individual members\n * const researcher = crew.getMember(\"researcher\");\n * console.log(researcher.agentId); // agid_acme_...\n *\n * // Grant delegation permission to editor\n * // (done automatically if allowDelegation is true)\n * ```\n */\nexport async function registerCrew(\n vorim: VorimSDK,\n manifest: CrewManifest,\n): Promise<RegisteredCrew> {\n const members: RegisteredCrewMember[] = [];\n\n for (const member of manifest.members) {\n const scopes = [...member.scopes];\n\n // Auto-add delegate scope if delegation is allowed\n if (member.allowDelegation && !scopes.includes('agent:delegate')) {\n scopes.push('agent:delegate');\n }\n\n const registration = await vorim.register({\n name: member.name,\n description: member.description ?? `CrewAI ${member.role} — ${manifest.crewName}`,\n capabilities: member.capabilities,\n scopes,\n });\n\n members.push({\n role: member.role,\n agentId: registration.agent.agent_id,\n registration,\n privateKey: registration.private_key,\n });\n }\n\n return {\n crewName: manifest.crewName,\n members,\n getMember(role: string) {\n return members.find(m => m.role === role);\n },\n agentIds() {\n return members.map(m => m.agentId);\n },\n };\n}\n\n// ─── Task Audit ──────────────────────────────────────────────────────────\n\nexport interface CrewTaskEvent {\n /** The role of the crew member performing the task. */\n role: string;\n /** The Vorim agent_id (looked up from the crew). */\n agentId: string;\n /** Task description or name. */\n task: string;\n /** Tool used (if any). */\n tool?: string;\n /** Result of the action. */\n result: 'success' | 'denied' | 'error';\n /** Duration in milliseconds. */\n latencyMs?: number;\n /** Error details if result is 'error'. */\n error?: string;\n /** Whether this was a delegation to another crew member. */\n delegatedTo?: string;\n /** Additional context. */\n metadata?: Record<string, unknown>;\n /**\n * Replayable agent decision evidence (VAIP -02).\n *\n * Stable identifier for the model that produced this task. Free-form\n * but recommended convention is `provider:model-name-version`.\n */\n modelVersion?: string;\n /**\n * SHA-256 of the canonicalised tool catalogue available to the\n * crew member at task time. Compute via {@link hashToolCatalogue}\n * from `@vorim/sdk`.\n */\n toolCatalogueHash?: string;\n /**\n * SHA-256 of the system prompt active at task time. Compute via\n * {@link hashSystemPrompt} from `@vorim/sdk`.\n */\n systemPromptHash?: string;\n}\n\n/**\n * Emits a Vorim audit event for a CrewAI task execution.\n * Call this from your orchestration layer after each CrewAI step completes.\n *\n * @example\n * ```ts\n * import { emitCrewTaskEvent } from \"@vorim/sdk/integrations/crewai\";\n *\n * // After a CrewAI task completes\n * await emitCrewTaskEvent(vorim, {\n * role: \"researcher\",\n * agentId: crew.getMember(\"researcher\").agentId,\n * task: \"research_competitors\",\n * tool: \"web_search\",\n * result: \"success\",\n * latencyMs: 3200,\n * });\n * ```\n */\nexport async function emitCrewTaskEvent(\n vorim: VorimSDK,\n event: CrewTaskEvent,\n): Promise<void> {\n const auditEvent: AuditEventInput = {\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n };\n\n await vorim.emit(auditEvent);\n}\n\n/**\n * Emits audit events for an entire crew run (batch of task results).\n *\n * @example\n * ```ts\n * await emitCrewRunEvents(vorim, [\n * { role: \"researcher\", agentId: \"...\", task: \"research\", result: \"success\" },\n * { role: \"writer\", agentId: \"...\", task: \"draft_article\", result: \"success\" },\n * { role: \"editor\", agentId: \"...\", task: \"review\", result: \"success\" },\n * ]);\n * ```\n */\nexport async function emitCrewRunEvents(\n vorim: VorimSDK,\n events: CrewTaskEvent[],\n): Promise<{ ingested: number }> {\n const auditEvents: AuditEventInput[] = events.map(event => ({\n agent_id: event.agentId,\n event_type: event.tool ? 'tool_call' : 'api_request',\n action: event.task,\n resource: event.tool,\n result: event.result,\n latency_ms: event.latencyMs,\n error_code: event.error ? 'CREW_TASK_ERROR' : undefined,\n metadata: {\n framework: 'crewai',\n role: event.role,\n ...(event.delegatedTo ? { delegated_to: event.delegatedTo } : {}),\n ...(event.error ? { error: event.error } : {}),\n ...event.metadata,\n },\n ...(event.modelVersion ? { model_version: event.modelVersion } : {}),\n ...(event.toolCatalogueHash ? { tool_catalogue_hash: event.toolCatalogueHash } : {}),\n ...(event.systemPromptHash ? { system_prompt_hash: event.systemPromptHash } : {}),\n }));\n\n return vorim.emitBatch(auditEvents);\n}\n\n// ─── Permission Helpers ──────────────────────────────────────────────────\n\n/**\n * Check if a crew member has permission before executing a task.\n * Returns the check result — does not throw.\n *\n * @example\n * ```ts\n * const { allowed } = await checkCrewPermission(vorim, crew, \"writer\", \"agent:write\");\n * if (!allowed) {\n * console.log(\"Writer lacks write permission\");\n * }\n * ```\n */\nexport async function checkCrewPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n role: string,\n scope: PermissionScope,\n opts?: CrewRuntimeControlOptions,\n): Promise<{ allowed: boolean; reason?: string; decisionId?: string }> {\n const member = crew.getMember(role);\n if (!member) {\n return { allowed: false, reason: `Unknown crew member: ${role}` };\n }\n // With useRuntimeControl, run the full runtime decision (beforeAction) and\n // surface its decisionId for audit linkage; otherwise use the lightweight\n // permission check. Both fail closed on a transport error rather than letting\n // the rejection crash the host crew loop (matches the openai/anthropic gate).\n if (opts?.useRuntimeControl) {\n try {\n return await runtimeGate(vorim, member.agentId, role, scope, opts.payload, {\n onEscalation: opts.onEscalation,\n escalationTimeoutMs: opts.escalationTimeoutMs,\n onTransportFailure: opts.onTransportFailure,\n });\n } catch {\n return { allowed: false, reason: 'runtime gate unavailable (failed closed)' };\n }\n }\n try {\n return await vorim.check(member.agentId, scope);\n } catch {\n return { allowed: false, reason: 'permission check unavailable (failed closed)' };\n }\n}\n\n/**\n * Check if delegation between two crew members is permitted.\n * The delegating agent must have the `agent:delegate` scope.\n */\nexport async function checkDelegationPermission(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n fromRole: string,\n toRole: string,\n): Promise<{ allowed: boolean; reason?: string }> {\n const from = crew.getMember(fromRole);\n const to = crew.getMember(toRole);\n if (!from) return { allowed: false, reason: `Unknown crew member: ${fromRole}` };\n if (!to) return { allowed: false, reason: `Unknown crew member: ${toRole}` };\n\n const result = await vorim.check(from.agentId, 'agent:delegate');\n if (!result.allowed) {\n return { allowed: false, reason: `${fromRole} lacks agent:delegate permission` };\n }\n return { allowed: true };\n}\n\n// ─── Trust Verification ──────────────────────────────────────────────────\n\n/**\n * Verify trust scores for all members of a crew.\n * Useful before starting a crew run to ensure all agents are active and trusted.\n */\nexport async function verifyCrewTrust(\n vorim: VorimSDK,\n crew: RegisteredCrew,\n): Promise<{ role: string; agentId: string; trustScore: number; status: string }[]> {\n const results = await Promise.all(\n crew.members.map(async (member) => {\n const trust = await vorim.verify(member.agentId);\n return {\n role: member.role,\n agentId: member.agentId,\n trustScore: trust.trust_score,\n status: trust.status,\n };\n }),\n );\n return results;\n}\n"],"mappings":";AAmEA,SAAS,eAAe,UAAgD;AACtE,SAAO,aAAa,WAAW,aAAa;AAC9C;AASA,eAAsB,YACpB,OACA,SACA,cACA,OACA,SACA,OAA2B,CAAC,GACP;AACrB,QAAM,eAAe,KAAK,gBAAgB;AAC1C,QAAM,qBAAqB,KAAK,sBAAsB;AACtD,QAAM,IAAI,MAAM,MAAM;AAAA,IACpB,EAAE,SAAS,YAAY,aAAa,cAAc,eAAe,OAAO,QAAQ;AAAA,IAChF,EAAE,aAAa,MAAM;AAAA,EACvB;AAMA,MAAI,EAAE,cAAc,EAAE,aAAa,YAAY;AAC7C,QAAI,uBAAuB,SAAS;AAClC,aAAO,EAAE,SAAS,MAAM,QAAQ,EAAE,UAAU,yCAAyC,YAAY,EAAE,cAAc,OAAU;AAAA,IAC7H;AACA,WAAO,EAAE,SAAS,OAAO,QAAQ,EAAE,UAAU,6CAA6C,YAAY,EAAE,cAAc,OAAU;AAAA,EAClI;AAEA,MAAI,EAAE,aAAa,YAAY;AAC7B,WAAO,EAAE,SAAS,eAAe,EAAE,QAAQ,GAAG,QAAQ,EAAE,QAAQ,YAAY,EAAE,cAAc,OAAU;AAAA,EACxG;AAGA,MAAI,iBAAiB,SAAS;AAC5B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,EAAE,SAAS,OAAO,QAAQ,wBAAwB,MAAM,GAAG;AAE3E,QAAM,SAAS,MAAM,MAAM,MAAM,KAAK,SAAS,gBAAgB;AAC/D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,QAAQ,mCAAmC;AAAA,EACjF;AACA,SAAO,EAAE,SAAS,KAAK;AACzB;AAQA,eAAsB,gBACpB,OACA,MACkF;AAClF,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,KAAK,QAAQ,IAAI,OAAO,WAAW;AACjC,YAAM,QAAQ,MAAM,MAAM,OAAO,OAAO,OAAO;AAC/C,aAAO;AAAA,QACL,MAAM,OAAO;AAAA,QACb,SAAS,OAAO;AAAA,QAChB,YAAY,MAAM;AAAA,QAClB,QAAQ,MAAM;AAAA,MAChB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
@@ -5665,6 +5665,43 @@ __export(langchain_exports, {
|
|
|
5665
5665
|
});
|
|
5666
5666
|
module.exports = __toCommonJS(langchain_exports);
|
|
5667
5667
|
|
|
5668
|
+
// src/integrations/_runtime-gate.ts
|
|
5669
|
+
function isAllowVerdict(decision) {
|
|
5670
|
+
return decision === "allow" || decision === "modify";
|
|
5671
|
+
}
|
|
5672
|
+
async function runtimeGate(vorim, agentId, actionTarget, scope, payload, opts = {}) {
|
|
5673
|
+
const onEscalation = opts.onEscalation ?? "wait";
|
|
5674
|
+
const onTransportFailure = opts.onTransportFailure ?? "deny";
|
|
5675
|
+
const d = await vorim.beforeAction(
|
|
5676
|
+
{ agentId, actionType: "tool_call", actionTarget, requiredScope: scope, payload },
|
|
5677
|
+
{ throwOnDeny: false }
|
|
5678
|
+
);
|
|
5679
|
+
if (d.isFallback || d.decision === "fallback") {
|
|
5680
|
+
if (onTransportFailure === "allow") {
|
|
5681
|
+
return { allowed: true, reason: d.reason ?? "control plane unreachable (fail-open)", decisionId: d.decisionId || void 0 };
|
|
5682
|
+
}
|
|
5683
|
+
return { allowed: false, reason: d.reason ?? "control plane unreachable (failed closed)", decisionId: d.decisionId || void 0 };
|
|
5684
|
+
}
|
|
5685
|
+
if (d.decision !== "escalate") {
|
|
5686
|
+
return { allowed: isAllowVerdict(d.decision), reason: d.reason, decisionId: d.decisionId || void 0 };
|
|
5687
|
+
}
|
|
5688
|
+
if (onEscalation === "allow") {
|
|
5689
|
+
return { allowed: true, reason: d.reason ?? "escalated (auto-allowed)", decisionId: d.decisionId || void 0 };
|
|
5690
|
+
}
|
|
5691
|
+
if (onEscalation === "deny") {
|
|
5692
|
+
return { allowed: false, reason: d.reason ?? "escalated (auto-denied \u2014 awaiting human)", decisionId: d.decisionId || void 0 };
|
|
5693
|
+
}
|
|
5694
|
+
if (!d.decisionId) {
|
|
5695
|
+
return { allowed: false, reason: "escalated but no decisionId to poll", decisionId: void 0 };
|
|
5696
|
+
}
|
|
5697
|
+
try {
|
|
5698
|
+
const resolved = await vorim.waitForDecisionResolution(d.decisionId, { timeoutMs: opts.escalationTimeoutMs });
|
|
5699
|
+
return { allowed: isAllowVerdict(resolved.decision), reason: resolved.reason, decisionId: resolved.decisionId || d.decisionId };
|
|
5700
|
+
} catch {
|
|
5701
|
+
return { allowed: false, reason: "escalation not resolved before timeout", decisionId: d.decisionId };
|
|
5702
|
+
}
|
|
5703
|
+
}
|
|
5704
|
+
|
|
5668
5705
|
// src/replay.ts
|
|
5669
5706
|
function jcsCanonicalise(value) {
|
|
5670
5707
|
if (value === null) return "null";
|
|
@@ -5738,18 +5775,50 @@ async function prepareReplayContext(inputs) {
|
|
|
5738
5775
|
|
|
5739
5776
|
// src/integrations/langchain.ts
|
|
5740
5777
|
function wrapTool(tool, config) {
|
|
5741
|
-
const {
|
|
5778
|
+
const {
|
|
5779
|
+
vorim,
|
|
5780
|
+
agentId,
|
|
5781
|
+
permissionMap = {},
|
|
5782
|
+
defaultPermission = "agent:execute",
|
|
5783
|
+
asyncAudit = true,
|
|
5784
|
+
replay,
|
|
5785
|
+
framework = "langchain",
|
|
5786
|
+
useRuntimeControl = false,
|
|
5787
|
+
onEscalation,
|
|
5788
|
+
escalationTimeoutMs,
|
|
5789
|
+
onTransportFailure
|
|
5790
|
+
} = config;
|
|
5742
5791
|
const originalCall = tool._call.bind(tool);
|
|
5743
5792
|
const getReplayCtx = makeReplayContextGetter(replay);
|
|
5744
5793
|
tool._call = async function vorimGuardedCall(arg, runManager, parentConfig) {
|
|
5745
5794
|
const scope = permissionMap[tool.name] ?? defaultPermission;
|
|
5746
5795
|
let allowed;
|
|
5747
5796
|
let reason;
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5797
|
+
let decisionId;
|
|
5798
|
+
if (useRuntimeControl) {
|
|
5799
|
+
try {
|
|
5800
|
+
const gateRes = await runtimeGate(
|
|
5801
|
+
vorim,
|
|
5802
|
+
agentId,
|
|
5803
|
+
tool.name,
|
|
5804
|
+
scope,
|
|
5805
|
+
arg,
|
|
5806
|
+
{ onEscalation, escalationTimeoutMs, onTransportFailure }
|
|
5807
|
+
);
|
|
5808
|
+
allowed = gateRes.allowed;
|
|
5809
|
+
reason = gateRes.reason;
|
|
5810
|
+
decisionId = gateRes.decisionId;
|
|
5811
|
+
} catch {
|
|
5812
|
+
allowed = false;
|
|
5813
|
+
reason = "runtime gate unavailable (failed closed)";
|
|
5814
|
+
}
|
|
5815
|
+
} else {
|
|
5816
|
+
try {
|
|
5817
|
+
({ allowed, reason } = await vorim.check(agentId, scope));
|
|
5818
|
+
} catch {
|
|
5819
|
+
allowed = false;
|
|
5820
|
+
reason = "permission check unavailable (failed closed)";
|
|
5821
|
+
}
|
|
5753
5822
|
}
|
|
5754
5823
|
const replayCtx = await getReplayCtx();
|
|
5755
5824
|
if (!allowed) {
|
|
@@ -5760,6 +5829,7 @@ function wrapTool(tool, config) {
|
|
|
5760
5829
|
resource: truncate(JSON.stringify(arg), 500),
|
|
5761
5830
|
permission: scope,
|
|
5762
5831
|
result: "denied",
|
|
5832
|
+
...decisionId ? { decision_id: decisionId } : {},
|
|
5763
5833
|
metadata: { reason, framework },
|
|
5764
5834
|
...replayCtx
|
|
5765
5835
|
};
|
|
@@ -5780,6 +5850,7 @@ function wrapTool(tool, config) {
|
|
|
5780
5850
|
result: "error",
|
|
5781
5851
|
latency_ms: Date.now() - start,
|
|
5782
5852
|
error_code: err instanceof Error ? err.name : "UNKNOWN",
|
|
5853
|
+
...decisionId ? { decision_id: decisionId } : {},
|
|
5783
5854
|
metadata: { error: err instanceof Error ? err.message : String(err), framework },
|
|
5784
5855
|
...replayCtx
|
|
5785
5856
|
};
|
|
@@ -5794,6 +5865,7 @@ function wrapTool(tool, config) {
|
|
|
5794
5865
|
permission: scope,
|
|
5795
5866
|
result: "success",
|
|
5796
5867
|
latency_ms: Date.now() - start,
|
|
5868
|
+
...decisionId ? { decision_id: decisionId } : {},
|
|
5797
5869
|
metadata: { framework },
|
|
5798
5870
|
...replayCtx
|
|
5799
5871
|
};
|
|
@@ -5895,7 +5967,22 @@ var VorimCallbackHandler = class _VorimCallbackHandler {
|
|
|
5895
5967
|
}
|
|
5896
5968
|
};
|
|
5897
5969
|
async function createVorimAgent(config) {
|
|
5898
|
-
const {
|
|
5970
|
+
const {
|
|
5971
|
+
vorim,
|
|
5972
|
+
name,
|
|
5973
|
+
capabilities,
|
|
5974
|
+
scopes,
|
|
5975
|
+
description,
|
|
5976
|
+
tools: rawTools,
|
|
5977
|
+
permissionMap,
|
|
5978
|
+
defaultPermission,
|
|
5979
|
+
asyncAudit,
|
|
5980
|
+
replay,
|
|
5981
|
+
useRuntimeControl,
|
|
5982
|
+
onEscalation,
|
|
5983
|
+
escalationTimeoutMs,
|
|
5984
|
+
onTransportFailure
|
|
5985
|
+
} = config;
|
|
5899
5986
|
const registration = await vorim.register({
|
|
5900
5987
|
name,
|
|
5901
5988
|
description,
|
|
@@ -5910,7 +5997,11 @@ async function createVorimAgent(config) {
|
|
|
5910
5997
|
permissionMap,
|
|
5911
5998
|
defaultPermission,
|
|
5912
5999
|
asyncAudit,
|
|
5913
|
-
replay: derivedReplay
|
|
6000
|
+
replay: derivedReplay,
|
|
6001
|
+
useRuntimeControl,
|
|
6002
|
+
onEscalation,
|
|
6003
|
+
escalationTimeoutMs,
|
|
6004
|
+
onTransportFailure
|
|
5914
6005
|
};
|
|
5915
6006
|
const tools = wrapTools(rawTools, agentConfig);
|
|
5916
6007
|
const callbackHandler = new VorimCallbackHandler(vorim, agentId, derivedReplay);
|