@vorim/sdk 3.8.1 → 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.
Files changed (73) hide show
  1. package/dist/index.cjs +208 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +133 -3
  4. package/dist/index.d.ts +133 -3
  5. package/dist/index.js +208 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/integrations/anthropic.d.cts +1 -1
  8. package/dist/integrations/anthropic.d.ts +1 -1
  9. package/dist/integrations/ap2.cjs +218 -0
  10. package/dist/integrations/ap2.cjs.map +1 -0
  11. package/dist/integrations/ap2.d.cts +95 -0
  12. package/dist/integrations/ap2.d.ts +95 -0
  13. package/dist/integrations/ap2.js +192 -0
  14. package/dist/integrations/ap2.js.map +1 -0
  15. package/dist/integrations/bank-rails.cjs +173 -0
  16. package/dist/integrations/bank-rails.cjs.map +1 -0
  17. package/dist/integrations/bank-rails.d.cts +87 -0
  18. package/dist/integrations/bank-rails.d.ts +87 -0
  19. package/dist/integrations/bank-rails.js +147 -0
  20. package/dist/integrations/bank-rails.js.map +1 -0
  21. package/dist/integrations/circle.cjs +159 -0
  22. package/dist/integrations/circle.cjs.map +1 -0
  23. package/dist/integrations/circle.d.cts +75 -0
  24. package/dist/integrations/circle.d.ts +75 -0
  25. package/dist/integrations/circle.js +133 -0
  26. package/dist/integrations/circle.js.map +1 -0
  27. package/dist/integrations/crewai.d.cts +1 -1
  28. package/dist/integrations/crewai.d.ts +1 -1
  29. package/dist/integrations/hermes.d.cts +1 -1
  30. package/dist/integrations/hermes.d.ts +1 -1
  31. package/dist/integrations/langchain.d.cts +1 -1
  32. package/dist/integrations/langchain.d.ts +1 -1
  33. package/dist/integrations/langgraph.d.cts +1 -1
  34. package/dist/integrations/langgraph.d.ts +1 -1
  35. package/dist/integrations/llamaindex.d.cts +1 -1
  36. package/dist/integrations/llamaindex.d.ts +1 -1
  37. package/dist/integrations/nekuda.cjs +165 -0
  38. package/dist/integrations/nekuda.cjs.map +1 -0
  39. package/dist/integrations/nekuda.d.cts +79 -0
  40. package/dist/integrations/nekuda.d.ts +79 -0
  41. package/dist/integrations/nekuda.js +139 -0
  42. package/dist/integrations/nekuda.js.map +1 -0
  43. package/dist/integrations/openai.d.cts +1 -1
  44. package/dist/integrations/openai.d.ts +1 -1
  45. package/dist/integrations/paypal-agent.cjs +215 -0
  46. package/dist/integrations/paypal-agent.cjs.map +1 -0
  47. package/dist/integrations/paypal-agent.d.cts +87 -0
  48. package/dist/integrations/paypal-agent.d.ts +87 -0
  49. package/dist/integrations/paypal-agent.js +189 -0
  50. package/dist/integrations/paypal-agent.js.map +1 -0
  51. package/dist/integrations/siem.d.cts +1 -1
  52. package/dist/integrations/siem.d.ts +1 -1
  53. package/dist/integrations/skyfire.cjs +166 -0
  54. package/dist/integrations/skyfire.cjs.map +1 -0
  55. package/dist/integrations/skyfire.d.cts +80 -0
  56. package/dist/integrations/skyfire.d.ts +80 -0
  57. package/dist/integrations/skyfire.js +140 -0
  58. package/dist/integrations/skyfire.js.map +1 -0
  59. package/dist/integrations/stripe-acp.d.cts +1 -1
  60. package/dist/integrations/stripe-acp.d.ts +1 -1
  61. package/dist/integrations/ucp.d.cts +1 -1
  62. package/dist/integrations/ucp.d.ts +1 -1
  63. package/dist/integrations/vercel-ai.d.cts +1 -1
  64. package/dist/integrations/vercel-ai.d.ts +1 -1
  65. package/dist/integrations/x402.cjs +211 -0
  66. package/dist/integrations/x402.cjs.map +1 -0
  67. package/dist/integrations/x402.d.cts +87 -0
  68. package/dist/integrations/x402.d.ts +87 -0
  69. package/dist/integrations/x402.js +185 -0
  70. package/dist/integrations/x402.js.map +1 -0
  71. package/dist/{types-Cb6V-boJ.d.cts → types-zzK9YOoa.d.cts} +86 -1
  72. package/dist/{types-Cb6V-boJ.d.ts → types-zzK9YOoa.d.ts} +86 -1
  73. package/package.json +71 -1
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/integrations/circle.ts
21
+ var circle_exports = {};
22
+ __export(circle_exports, {
23
+ VorimCircle: () => VorimCircle,
24
+ createVorimCircle: () => createVorimCircle
25
+ });
26
+ module.exports = __toCommonJS(circle_exports);
27
+ var VorimCircle = class _VorimCircle {
28
+ sdk;
29
+ minTrustScore;
30
+ requiredScope;
31
+ static _warnedNoAuth = false;
32
+ constructor(sdk, config) {
33
+ this.sdk = sdk;
34
+ this.minTrustScore = config?.minTrustScore ?? 50;
35
+ this.requiredScope = config?.requiredScope ?? "agent:transact";
36
+ }
37
+ /** Verify an agent is authorized to make a Circle USDC payment. */
38
+ async authorizePayment(req) {
39
+ const threshold = req.minTrustScore ?? this.minTrustScore;
40
+ try {
41
+ const perm = await this.sdk.check(req.agentId, this.requiredScope);
42
+ if (!perm.allowed) {
43
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
44
+ return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };
45
+ }
46
+ } catch (e) {
47
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: e.message });
48
+ return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Permission check failed: ${e.message}`, scopeVerified: false };
49
+ }
50
+ let score = 0;
51
+ let status = "unknown";
52
+ try {
53
+ const trust = await this.sdk.verify(req.agentId);
54
+ score = trust.trust_score ?? 0;
55
+ status = trust.status ?? "unknown";
56
+ } catch {
57
+ }
58
+ if (status !== "active") {
59
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: `Status: ${status}` });
60
+ return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };
61
+ }
62
+ if (score < threshold) {
63
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
64
+ return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };
65
+ }
66
+ await this.logEvent(req.agentId, "circle.pay.authorize", "success", req, { trust_score: score });
67
+ return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };
68
+ }
69
+ /** Log that a Circle USDC payment settled on-chain. */
70
+ async logPaymentSent(agentId, txHash, req) {
71
+ await this.logEvent(agentId, "circle.pay.sent", "success", req, { tx_hash: txHash });
72
+ }
73
+ /** Log that a Circle USDC payment failed. */
74
+ async logPaymentFailed(agentId, reason, req) {
75
+ await this.logEvent(agentId, "circle.pay.failed", "error", req, { fail_reason: reason });
76
+ }
77
+ /**
78
+ * Express/Connect middleware for a service that gates paid endpoints on agent
79
+ * authorization.
80
+ *
81
+ * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; it does NOT
82
+ * prove the caller controls that agent. Pass `authenticate` to verify the
83
+ * caller-to-agent binding. When omitted, a one-time warning is logged.
84
+ */
85
+ middleware(options) {
86
+ const header = options?.agentIdHeader ?? "x-vorim-agent-id";
87
+ const threshold = options?.minTrustScore ?? this.minTrustScore;
88
+ const authenticate = options?.authenticate;
89
+ if (!authenticate && !_VorimCircle._warnedNoAuth) {
90
+ _VorimCircle._warnedNoAuth = true;
91
+ console.warn(
92
+ "[vorim] VorimCircle.middleware() called without an `authenticate` hook: it authorizes the agent NAMED in the header but does not verify the caller controls that agent (confused-deputy risk). Pass `authenticate`."
93
+ );
94
+ }
95
+ return async (req, res, next) => {
96
+ const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
97
+ if (!agentId) {
98
+ res.status(401).json({ error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` } });
99
+ return;
100
+ }
101
+ if (authenticate) {
102
+ let bound = false;
103
+ try {
104
+ bound = await authenticate(agentId, req);
105
+ } catch {
106
+ bound = false;
107
+ }
108
+ if (!bound) {
109
+ res.status(401).json({ error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" } });
110
+ return;
111
+ }
112
+ }
113
+ const auth = await this.authorizePayment({
114
+ agentId,
115
+ resource: req.originalUrl || req.url || "",
116
+ amount: req.body?.amount || 0,
117
+ currency: req.body?.currency || "USDC",
118
+ chain: req.body?.chain || "",
119
+ payTo: req.body?.payTo || "",
120
+ minTrustScore: threshold
121
+ });
122
+ if (!auth.authorized) {
123
+ res.status(402).json({ error: { code: "UNAUTHORIZED_AGENT", message: auth.reason || "Agent not authorized for Circle payment", trust_score: auth.trustScore, status: auth.status } });
124
+ return;
125
+ }
126
+ req.vorimAuthorization = auth;
127
+ next();
128
+ };
129
+ }
130
+ async logEvent(agentId, action, result, req, metadata) {
131
+ try {
132
+ await this.sdk.emit({
133
+ agent_id: agentId,
134
+ event_type: "api_request",
135
+ action,
136
+ result,
137
+ resource: req?.resource || "",
138
+ metadata: {
139
+ resource: req?.resource || "",
140
+ amount: req?.amount || 0,
141
+ currency: req?.currency || "USDC",
142
+ chain: req?.chain || "",
143
+ pay_to: req?.payTo || "",
144
+ ...metadata
145
+ }
146
+ });
147
+ } catch {
148
+ }
149
+ }
150
+ };
151
+ function createVorimCircle(sdk, config) {
152
+ return new VorimCircle(sdk, config);
153
+ }
154
+ // Annotate the CommonJS export names for ESM import in node:
155
+ 0 && (module.exports = {
156
+ VorimCircle,
157
+ createVorimCircle
158
+ });
159
+ //# sourceMappingURL=circle.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/circle.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Circle Agent Stack Integration\n//\n// Circle Agent Stack is Circle's agent-payments product (Agent Wallets +\n// Nanopayments + Circle CLI): an agent pays for a service in USDC, typically\n// via the x402 flow (an EIP-712 X-PAYMENT authorization) settled by Circle.\n// The discrete step is `circle services pay <url> --max-amount ...`.\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of a Circle agent payment: before an agent pays, it verifies the agent holds\n// `transact`, is active, and clears a trust threshold, then records the payment\n// lifecycle on a signed, tamper-evident audit trail. It does NOT move money or\n// hold wallet keys — Circle does the settlement; Vorim authorizes and attests.\n//\n// Note: Circle wallets ship native spend caps; this layer is complementary —\n// it adds cross-provider agent identity and an independent signed audit trail.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimCircle } from '@vorim/sdk/integrations/circle';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const circle = createVorimCircle(vorim, { minTrustScore: 60 });\n//\n// const auth = await circle.authorizePayment({\n// agentId: 'agid_abc123',\n// resource: 'https://api.example.com/v1/data',\n// amount: 1000000, // smallest unit (USDC has 6 decimals)\n// chain: 'base',\n// payTo: '0xSeller...',\n// });\n// if (auth.authorized) {\n// // ... run `circle services pay ...`, then:\n// await circle.logPaymentSent(auth.agentId, txHash, { resource, amount });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport interface CircleConfig {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface CirclePaymentRequest {\n /** The Vorim agent id making the payment. */\n agentId: string;\n /** The resource / service URL being paid for. */\n resource?: string;\n /** Amount in the smallest unit of the asset (USDC = 6 decimals). */\n amount?: number;\n /** Asset code (default USDC). */\n currency?: string;\n /** Chain the settlement runs on (e.g. 'base', 'polygon', 'solana'). */\n chain?: string;\n /** The recipient wallet address. */\n payTo?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface CircleAuthorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimCircle {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<CircleConfig>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n }\n\n /** Verify an agent is authorized to make a Circle USDC payment. */\n async authorizePayment(req: CirclePaymentRequest): Promise<CircleAuthorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\n\n try {\n const perm = await this.sdk.check(req.agentId, this.requiredScope as any);\n if (!(perm as any).allowed) {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: `Missing ${this.requiredScope}` });\n return { authorized: false, agentId: req.agentId, trustScore: 0, status: 'unknown', reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };\n }\n } catch (e: any) {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: e.message });\n return { authorized: false, agentId: req.agentId, trustScore: 0, status: 'unknown', reason: `Permission check failed: ${e.message}`, scopeVerified: false };\n }\n\n let score = 0;\n let status = 'unknown';\n try {\n const trust = await this.sdk.verify(req.agentId);\n score = (trust as any).trust_score ?? 0;\n status = (trust as any).status ?? 'unknown';\n } catch { /* treated as not-active below */ }\n\n if (status !== 'active') {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: `Status: ${status}` });\n return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };\n }\n\n if (score < threshold) {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: `Score ${score} < ${threshold}` });\n return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };\n }\n\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'success', req, { trust_score: score });\n return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };\n }\n\n /** Log that a Circle USDC payment settled on-chain. */\n async logPaymentSent(agentId: string, txHash: string, req?: Partial<CirclePaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'circle.pay.sent', 'success', req, { tx_hash: txHash });\n }\n\n /** Log that a Circle USDC payment failed. */\n async logPaymentFailed(agentId: string, reason?: string, req?: Partial<CirclePaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'circle.pay.failed', 'error', req, { fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware for a service that gates paid endpoints on agent\n * authorization.\n *\n * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; it does NOT\n * prove the caller controls that agent. Pass `authenticate` to verify the\n * caller-to-agent binding. When omitted, a one-time warning is logged.\n */\n middleware(options?: {\n agentIdHeader?: string;\n minTrustScore?: number;\n authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;\n }) {\n const header = options?.agentIdHeader ?? 'x-vorim-agent-id';\n const threshold = options?.minTrustScore ?? this.minTrustScore;\n const authenticate = options?.authenticate;\n\n if (!authenticate && !VorimCircle._warnedNoAuth) {\n VorimCircle._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimCircle.middleware() called without an `authenticate` hook: ' +\n 'it authorizes the agent NAMED in the header but does not verify the ' +\n 'caller controls that agent (confused-deputy risk). Pass `authenticate`.'\n );\n }\n\n return async (req: any, res: any, next: any) => {\n const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || '';\n if (!agentId) {\n res.status(401).json({ error: { code: 'MISSING_AGENT_ID', message: `Agent ID required in ${header} header` } });\n return;\n }\n if (authenticate) {\n let bound = false;\n try { bound = await authenticate(agentId, req); } catch { bound = false; }\n if (!bound) {\n res.status(401).json({ error: { code: 'AGENT_BINDING_UNVERIFIED', message: 'Caller is not authenticated as the named agent' } });\n return;\n }\n }\n const auth = await this.authorizePayment({\n agentId,\n resource: req.originalUrl || req.url || '',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'USDC',\n chain: req.body?.chain || '',\n payTo: req.body?.payTo || '',\n minTrustScore: threshold,\n });\n if (!auth.authorized) {\n res.status(402).json({ error: { code: 'UNAUTHORIZED_AGENT', message: auth.reason || 'Agent not authorized for Circle payment', trust_score: auth.trustScore, status: auth.status } });\n return;\n }\n req.vorimAuthorization = auth;\n next();\n };\n }\n\n private async logEvent(\n agentId: string,\n action: string,\n result: 'success' | 'denied' | 'error',\n req?: Partial<CirclePaymentRequest>,\n metadata?: Record<string, any>,\n ): Promise<void> {\n try {\n await this.sdk.emit({\n agent_id: agentId,\n event_type: 'api_request',\n action,\n result,\n resource: req?.resource || '',\n metadata: {\n resource: req?.resource || '',\n amount: req?.amount || 0,\n currency: req?.currency || 'USDC',\n chain: req?.chain || '',\n pay_to: req?.payTo || '',\n ...metadata,\n },\n });\n } catch { /* never block the payment flow */ }\n }\n}\n\n/**\n * Create a VorimCircle instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimCircle } from '@vorim/sdk/integrations/circle';\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const circle = createVorimCircle(vorim, { minTrustScore: 70 });\n * const auth = await circle.authorizePayment({ agentId: 'agid_abc', resource: '/data', amount: 1000000, chain: 'base' });\n * ```\n */\nexport function createVorimCircle(sdk: VorimSDK, config?: Partial<CircleConfig>): VorimCircle {\n return new VorimCircle(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwEO,IAAM,cAAN,MAAM,aAAY;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACR,OAAe,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ACH,QAAQ;AAAA,IAAqC;AAAA,EAC/C;AACF;AAcO,SAAS,kBAAkB,KAAe,QAA6C;AAC5F,SAAO,IAAI,YAAY,KAAK,MAAM;AACpC;","names":[]}
@@ -0,0 +1,75 @@
1
+ import { VorimSDK } from '../index.cjs';
2
+ import '../types-zzK9YOoa.cjs';
3
+
4
+ interface CircleConfig {
5
+ apiKey: string;
6
+ baseUrl?: string;
7
+ minTrustScore?: number;
8
+ requiredScope?: string;
9
+ }
10
+ interface CirclePaymentRequest {
11
+ /** The Vorim agent id making the payment. */
12
+ agentId: string;
13
+ /** The resource / service URL being paid for. */
14
+ resource?: string;
15
+ /** Amount in the smallest unit of the asset (USDC = 6 decimals). */
16
+ amount?: number;
17
+ /** Asset code (default USDC). */
18
+ currency?: string;
19
+ /** Chain the settlement runs on (e.g. 'base', 'polygon', 'solana'). */
20
+ chain?: string;
21
+ /** The recipient wallet address. */
22
+ payTo?: string;
23
+ /** Per-call override of the trust threshold. */
24
+ minTrustScore?: number;
25
+ }
26
+ interface CircleAuthorization {
27
+ authorized: boolean;
28
+ agentId: string;
29
+ trustScore: number;
30
+ status: string;
31
+ reason?: string;
32
+ scopeVerified: boolean;
33
+ }
34
+ declare class VorimCircle {
35
+ private sdk;
36
+ private minTrustScore;
37
+ private requiredScope;
38
+ private static _warnedNoAuth;
39
+ constructor(sdk: VorimSDK, config?: Partial<CircleConfig>);
40
+ /** Verify an agent is authorized to make a Circle USDC payment. */
41
+ authorizePayment(req: CirclePaymentRequest): Promise<CircleAuthorization>;
42
+ /** Log that a Circle USDC payment settled on-chain. */
43
+ logPaymentSent(agentId: string, txHash: string, req?: Partial<CirclePaymentRequest>): Promise<void>;
44
+ /** Log that a Circle USDC payment failed. */
45
+ logPaymentFailed(agentId: string, reason?: string, req?: Partial<CirclePaymentRequest>): Promise<void>;
46
+ /**
47
+ * Express/Connect middleware for a service that gates paid endpoints on agent
48
+ * authorization.
49
+ *
50
+ * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; it does NOT
51
+ * prove the caller controls that agent. Pass `authenticate` to verify the
52
+ * caller-to-agent binding. When omitted, a one-time warning is logged.
53
+ */
54
+ middleware(options?: {
55
+ agentIdHeader?: string;
56
+ minTrustScore?: number;
57
+ authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
58
+ }): (req: any, res: any, next: any) => Promise<void>;
59
+ private logEvent;
60
+ }
61
+ /**
62
+ * Create a VorimCircle instance.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * import createVorim from '@vorim/sdk';
67
+ * import { createVorimCircle } from '@vorim/sdk/integrations/circle';
68
+ * const vorim = createVorim({ apiKey: 'agid_sk_...' });
69
+ * const circle = createVorimCircle(vorim, { minTrustScore: 70 });
70
+ * const auth = await circle.authorizePayment({ agentId: 'agid_abc', resource: '/data', amount: 1000000, chain: 'base' });
71
+ * ```
72
+ */
73
+ declare function createVorimCircle(sdk: VorimSDK, config?: Partial<CircleConfig>): VorimCircle;
74
+
75
+ export { type CircleAuthorization, type CircleConfig, type CirclePaymentRequest, VorimCircle, createVorimCircle };
@@ -0,0 +1,75 @@
1
+ import { VorimSDK } from '../index.js';
2
+ import '../types-zzK9YOoa.js';
3
+
4
+ interface CircleConfig {
5
+ apiKey: string;
6
+ baseUrl?: string;
7
+ minTrustScore?: number;
8
+ requiredScope?: string;
9
+ }
10
+ interface CirclePaymentRequest {
11
+ /** The Vorim agent id making the payment. */
12
+ agentId: string;
13
+ /** The resource / service URL being paid for. */
14
+ resource?: string;
15
+ /** Amount in the smallest unit of the asset (USDC = 6 decimals). */
16
+ amount?: number;
17
+ /** Asset code (default USDC). */
18
+ currency?: string;
19
+ /** Chain the settlement runs on (e.g. 'base', 'polygon', 'solana'). */
20
+ chain?: string;
21
+ /** The recipient wallet address. */
22
+ payTo?: string;
23
+ /** Per-call override of the trust threshold. */
24
+ minTrustScore?: number;
25
+ }
26
+ interface CircleAuthorization {
27
+ authorized: boolean;
28
+ agentId: string;
29
+ trustScore: number;
30
+ status: string;
31
+ reason?: string;
32
+ scopeVerified: boolean;
33
+ }
34
+ declare class VorimCircle {
35
+ private sdk;
36
+ private minTrustScore;
37
+ private requiredScope;
38
+ private static _warnedNoAuth;
39
+ constructor(sdk: VorimSDK, config?: Partial<CircleConfig>);
40
+ /** Verify an agent is authorized to make a Circle USDC payment. */
41
+ authorizePayment(req: CirclePaymentRequest): Promise<CircleAuthorization>;
42
+ /** Log that a Circle USDC payment settled on-chain. */
43
+ logPaymentSent(agentId: string, txHash: string, req?: Partial<CirclePaymentRequest>): Promise<void>;
44
+ /** Log that a Circle USDC payment failed. */
45
+ logPaymentFailed(agentId: string, reason?: string, req?: Partial<CirclePaymentRequest>): Promise<void>;
46
+ /**
47
+ * Express/Connect middleware for a service that gates paid endpoints on agent
48
+ * authorization.
49
+ *
50
+ * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; it does NOT
51
+ * prove the caller controls that agent. Pass `authenticate` to verify the
52
+ * caller-to-agent binding. When omitted, a one-time warning is logged.
53
+ */
54
+ middleware(options?: {
55
+ agentIdHeader?: string;
56
+ minTrustScore?: number;
57
+ authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
58
+ }): (req: any, res: any, next: any) => Promise<void>;
59
+ private logEvent;
60
+ }
61
+ /**
62
+ * Create a VorimCircle instance.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * import createVorim from '@vorim/sdk';
67
+ * import { createVorimCircle } from '@vorim/sdk/integrations/circle';
68
+ * const vorim = createVorim({ apiKey: 'agid_sk_...' });
69
+ * const circle = createVorimCircle(vorim, { minTrustScore: 70 });
70
+ * const auth = await circle.authorizePayment({ agentId: 'agid_abc', resource: '/data', amount: 1000000, chain: 'base' });
71
+ * ```
72
+ */
73
+ declare function createVorimCircle(sdk: VorimSDK, config?: Partial<CircleConfig>): VorimCircle;
74
+
75
+ export { type CircleAuthorization, type CircleConfig, type CirclePaymentRequest, VorimCircle, createVorimCircle };
@@ -0,0 +1,133 @@
1
+ // src/integrations/circle.ts
2
+ var VorimCircle = class _VorimCircle {
3
+ sdk;
4
+ minTrustScore;
5
+ requiredScope;
6
+ static _warnedNoAuth = false;
7
+ constructor(sdk, config) {
8
+ this.sdk = sdk;
9
+ this.minTrustScore = config?.minTrustScore ?? 50;
10
+ this.requiredScope = config?.requiredScope ?? "agent:transact";
11
+ }
12
+ /** Verify an agent is authorized to make a Circle USDC payment. */
13
+ async authorizePayment(req) {
14
+ const threshold = req.minTrustScore ?? this.minTrustScore;
15
+ try {
16
+ const perm = await this.sdk.check(req.agentId, this.requiredScope);
17
+ if (!perm.allowed) {
18
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
19
+ return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };
20
+ }
21
+ } catch (e) {
22
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: e.message });
23
+ return { authorized: false, agentId: req.agentId, trustScore: 0, status: "unknown", reason: `Permission check failed: ${e.message}`, scopeVerified: false };
24
+ }
25
+ let score = 0;
26
+ let status = "unknown";
27
+ try {
28
+ const trust = await this.sdk.verify(req.agentId);
29
+ score = trust.trust_score ?? 0;
30
+ status = trust.status ?? "unknown";
31
+ } catch {
32
+ }
33
+ if (status !== "active") {
34
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: `Status: ${status}` });
35
+ return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };
36
+ }
37
+ if (score < threshold) {
38
+ await this.logEvent(req.agentId, "circle.pay.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
39
+ return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };
40
+ }
41
+ await this.logEvent(req.agentId, "circle.pay.authorize", "success", req, { trust_score: score });
42
+ return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };
43
+ }
44
+ /** Log that a Circle USDC payment settled on-chain. */
45
+ async logPaymentSent(agentId, txHash, req) {
46
+ await this.logEvent(agentId, "circle.pay.sent", "success", req, { tx_hash: txHash });
47
+ }
48
+ /** Log that a Circle USDC payment failed. */
49
+ async logPaymentFailed(agentId, reason, req) {
50
+ await this.logEvent(agentId, "circle.pay.failed", "error", req, { fail_reason: reason });
51
+ }
52
+ /**
53
+ * Express/Connect middleware for a service that gates paid endpoints on agent
54
+ * authorization.
55
+ *
56
+ * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; it does NOT
57
+ * prove the caller controls that agent. Pass `authenticate` to verify the
58
+ * caller-to-agent binding. When omitted, a one-time warning is logged.
59
+ */
60
+ middleware(options) {
61
+ const header = options?.agentIdHeader ?? "x-vorim-agent-id";
62
+ const threshold = options?.minTrustScore ?? this.minTrustScore;
63
+ const authenticate = options?.authenticate;
64
+ if (!authenticate && !_VorimCircle._warnedNoAuth) {
65
+ _VorimCircle._warnedNoAuth = true;
66
+ console.warn(
67
+ "[vorim] VorimCircle.middleware() called without an `authenticate` hook: it authorizes the agent NAMED in the header but does not verify the caller controls that agent (confused-deputy risk). Pass `authenticate`."
68
+ );
69
+ }
70
+ return async (req, res, next) => {
71
+ const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
72
+ if (!agentId) {
73
+ res.status(401).json({ error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` } });
74
+ return;
75
+ }
76
+ if (authenticate) {
77
+ let bound = false;
78
+ try {
79
+ bound = await authenticate(agentId, req);
80
+ } catch {
81
+ bound = false;
82
+ }
83
+ if (!bound) {
84
+ res.status(401).json({ error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" } });
85
+ return;
86
+ }
87
+ }
88
+ const auth = await this.authorizePayment({
89
+ agentId,
90
+ resource: req.originalUrl || req.url || "",
91
+ amount: req.body?.amount || 0,
92
+ currency: req.body?.currency || "USDC",
93
+ chain: req.body?.chain || "",
94
+ payTo: req.body?.payTo || "",
95
+ minTrustScore: threshold
96
+ });
97
+ if (!auth.authorized) {
98
+ res.status(402).json({ error: { code: "UNAUTHORIZED_AGENT", message: auth.reason || "Agent not authorized for Circle payment", trust_score: auth.trustScore, status: auth.status } });
99
+ return;
100
+ }
101
+ req.vorimAuthorization = auth;
102
+ next();
103
+ };
104
+ }
105
+ async logEvent(agentId, action, result, req, metadata) {
106
+ try {
107
+ await this.sdk.emit({
108
+ agent_id: agentId,
109
+ event_type: "api_request",
110
+ action,
111
+ result,
112
+ resource: req?.resource || "",
113
+ metadata: {
114
+ resource: req?.resource || "",
115
+ amount: req?.amount || 0,
116
+ currency: req?.currency || "USDC",
117
+ chain: req?.chain || "",
118
+ pay_to: req?.payTo || "",
119
+ ...metadata
120
+ }
121
+ });
122
+ } catch {
123
+ }
124
+ }
125
+ };
126
+ function createVorimCircle(sdk, config) {
127
+ return new VorimCircle(sdk, config);
128
+ }
129
+ export {
130
+ VorimCircle,
131
+ createVorimCircle
132
+ };
133
+ //# sourceMappingURL=circle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/circle.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Circle Agent Stack Integration\n//\n// Circle Agent Stack is Circle's agent-payments product (Agent Wallets +\n// Nanopayments + Circle CLI): an agent pays for a service in USDC, typically\n// via the x402 flow (an EIP-712 X-PAYMENT authorization) settled by Circle.\n// The discrete step is `circle services pay <url> --max-amount ...`.\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of a Circle agent payment: before an agent pays, it verifies the agent holds\n// `transact`, is active, and clears a trust threshold, then records the payment\n// lifecycle on a signed, tamper-evident audit trail. It does NOT move money or\n// hold wallet keys — Circle does the settlement; Vorim authorizes and attests.\n//\n// Note: Circle wallets ship native spend caps; this layer is complementary —\n// it adds cross-provider agent identity and an independent signed audit trail.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimCircle } from '@vorim/sdk/integrations/circle';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const circle = createVorimCircle(vorim, { minTrustScore: 60 });\n//\n// const auth = await circle.authorizePayment({\n// agentId: 'agid_abc123',\n// resource: 'https://api.example.com/v1/data',\n// amount: 1000000, // smallest unit (USDC has 6 decimals)\n// chain: 'base',\n// payTo: '0xSeller...',\n// });\n// if (auth.authorized) {\n// // ... run `circle services pay ...`, then:\n// await circle.logPaymentSent(auth.agentId, txHash, { resource, amount });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport interface CircleConfig {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface CirclePaymentRequest {\n /** The Vorim agent id making the payment. */\n agentId: string;\n /** The resource / service URL being paid for. */\n resource?: string;\n /** Amount in the smallest unit of the asset (USDC = 6 decimals). */\n amount?: number;\n /** Asset code (default USDC). */\n currency?: string;\n /** Chain the settlement runs on (e.g. 'base', 'polygon', 'solana'). */\n chain?: string;\n /** The recipient wallet address. */\n payTo?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface CircleAuthorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimCircle {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<CircleConfig>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n }\n\n /** Verify an agent is authorized to make a Circle USDC payment. */\n async authorizePayment(req: CirclePaymentRequest): Promise<CircleAuthorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\n\n try {\n const perm = await this.sdk.check(req.agentId, this.requiredScope as any);\n if (!(perm as any).allowed) {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: `Missing ${this.requiredScope}` });\n return { authorized: false, agentId: req.agentId, trustScore: 0, status: 'unknown', reason: `Agent does not have ${this.requiredScope} permission`, scopeVerified: false };\n }\n } catch (e: any) {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: e.message });\n return { authorized: false, agentId: req.agentId, trustScore: 0, status: 'unknown', reason: `Permission check failed: ${e.message}`, scopeVerified: false };\n }\n\n let score = 0;\n let status = 'unknown';\n try {\n const trust = await this.sdk.verify(req.agentId);\n score = (trust as any).trust_score ?? 0;\n status = (trust as any).status ?? 'unknown';\n } catch { /* treated as not-active below */ }\n\n if (status !== 'active') {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: `Status: ${status}` });\n return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Agent is ${status}, not active`, scopeVerified: true };\n }\n\n if (score < threshold) {\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'denied', req, { reason: `Score ${score} < ${threshold}` });\n return { authorized: false, agentId: req.agentId, trustScore: score, status, reason: `Trust score ${score} is below minimum ${threshold}`, scopeVerified: true };\n }\n\n await this.logEvent(req.agentId, 'circle.pay.authorize', 'success', req, { trust_score: score });\n return { authorized: true, agentId: req.agentId, trustScore: score, status, scopeVerified: true };\n }\n\n /** Log that a Circle USDC payment settled on-chain. */\n async logPaymentSent(agentId: string, txHash: string, req?: Partial<CirclePaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'circle.pay.sent', 'success', req, { tx_hash: txHash });\n }\n\n /** Log that a Circle USDC payment failed. */\n async logPaymentFailed(agentId: string, reason?: string, req?: Partial<CirclePaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'circle.pay.failed', 'error', req, { fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware for a service that gates paid endpoints on agent\n * authorization.\n *\n * ⚠️ CONFUSED-DEPUTY WARNING. Evaluates the *named* agent only; it does NOT\n * prove the caller controls that agent. Pass `authenticate` to verify the\n * caller-to-agent binding. When omitted, a one-time warning is logged.\n */\n middleware(options?: {\n agentIdHeader?: string;\n minTrustScore?: number;\n authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;\n }) {\n const header = options?.agentIdHeader ?? 'x-vorim-agent-id';\n const threshold = options?.minTrustScore ?? this.minTrustScore;\n const authenticate = options?.authenticate;\n\n if (!authenticate && !VorimCircle._warnedNoAuth) {\n VorimCircle._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimCircle.middleware() called without an `authenticate` hook: ' +\n 'it authorizes the agent NAMED in the header but does not verify the ' +\n 'caller controls that agent (confused-deputy risk). Pass `authenticate`.'\n );\n }\n\n return async (req: any, res: any, next: any) => {\n const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || '';\n if (!agentId) {\n res.status(401).json({ error: { code: 'MISSING_AGENT_ID', message: `Agent ID required in ${header} header` } });\n return;\n }\n if (authenticate) {\n let bound = false;\n try { bound = await authenticate(agentId, req); } catch { bound = false; }\n if (!bound) {\n res.status(401).json({ error: { code: 'AGENT_BINDING_UNVERIFIED', message: 'Caller is not authenticated as the named agent' } });\n return;\n }\n }\n const auth = await this.authorizePayment({\n agentId,\n resource: req.originalUrl || req.url || '',\n amount: req.body?.amount || 0,\n currency: req.body?.currency || 'USDC',\n chain: req.body?.chain || '',\n payTo: req.body?.payTo || '',\n minTrustScore: threshold,\n });\n if (!auth.authorized) {\n res.status(402).json({ error: { code: 'UNAUTHORIZED_AGENT', message: auth.reason || 'Agent not authorized for Circle payment', trust_score: auth.trustScore, status: auth.status } });\n return;\n }\n req.vorimAuthorization = auth;\n next();\n };\n }\n\n private async logEvent(\n agentId: string,\n action: string,\n result: 'success' | 'denied' | 'error',\n req?: Partial<CirclePaymentRequest>,\n metadata?: Record<string, any>,\n ): Promise<void> {\n try {\n await this.sdk.emit({\n agent_id: agentId,\n event_type: 'api_request',\n action,\n result,\n resource: req?.resource || '',\n metadata: {\n resource: req?.resource || '',\n amount: req?.amount || 0,\n currency: req?.currency || 'USDC',\n chain: req?.chain || '',\n pay_to: req?.payTo || '',\n ...metadata,\n },\n });\n } catch { /* never block the payment flow */ }\n }\n}\n\n/**\n * Create a VorimCircle instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimCircle } from '@vorim/sdk/integrations/circle';\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const circle = createVorimCircle(vorim, { minTrustScore: 70 });\n * const auth = await circle.authorizePayment({ agentId: 'agid_abc', resource: '/data', amount: 1000000, chain: 'base' });\n * ```\n */\nexport function createVorimCircle(sdk: VorimSDK, config?: Partial<CircleConfig>): VorimCircle {\n return new VorimCircle(sdk, config);\n}\n"],"mappings":";AAwEO,IAAM,cAAN,MAAM,aAAY;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACR,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAAgC;AACzD,SAAK,MAAM;AACX,SAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,SAAK,gBAAgB,QAAQ,iBAAiB;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,iBAAiB,KAAyD;AAC9E,UAAM,YAAY,IAAI,iBAAiB,KAAK;AAE5C,QAAI;AACF,YAAM,OAAO,MAAM,KAAK,IAAI,MAAM,IAAI,SAAS,KAAK,aAAoB;AACxE,UAAI,CAAE,KAAa,SAAS;AAC1B,cAAM,KAAK,SAAS,IAAI,SAAS,wBAAwB,UAAU,KAAK,EAAE,QAAQ,WAAW,KAAK,aAAa,GAAG,CAAC;AACnH,eAAO,EAAE,YAAY,OAAO,SAAS,IAAI,SAAS,YAAY,GAAG,QAAQ,WAAW,QAAQ,uBAAuB,KAAK,aAAa,eAAe,eAAe,MAAM;AAAA,MAC3K;AAAA,IACF,SAAS,GAAQ;AACf,YAAM,KAAK,SAAS,IAAI,SAAS,wBAAwB,UAAU,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAC7F,aAAO,EAAE,YAAY,O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2CAA2C,aAAa,KAAK,YAAY,QAAQ,KAAK,OAAO,EAAE,CAAC;AACpL;AAAA,MACF;AACA,UAAI,qBAAqB;AACzB,WAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEA,MAAc,SACZ,SACA,QACA,QACA,KACA,UACe;AACf,QAAI;AACF,YAAM,KAAK,IAAI,KAAK;AAAA,QAClB,UAAU;AAAA,QACV,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA,UAAU,KAAK,YAAY;AAAA,QAC3B,UAAU;AAAA,UACR,UAAU,KAAK,YAAY;AAAA,UAC3B,QAAQ,KAAK,UAAU;AAAA,UACvB,UAAU,KAAK,YAAY;AAAA,UAC3B,OAAO,KAAK,SAAS;AAAA,UACrB,QAAQ,KAAK,SAAS;AAAA,UACtB,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAAA,IAAqC;AAAA,EAC/C;AACF;AAcO,SAAS,kBAAkB,KAAe,QAA6C;AAC5F,SAAO,IAAI,YAAY,KAAK,MAAM;AACpC;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.cjs';
2
- import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.cjs';
2
+ import { P as PermissionScope, A as AgentRegistrationResult } from '../types-zzK9YOoa.cjs';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.js';
2
- import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.js';
2
+ import { P as PermissionScope, A as AgentRegistrationResult } from '../types-zzK9YOoa.js';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK, ReplayInputs } from '../index.cjs';
2
- import { P as PermissionScope } from '../types-Cb6V-boJ.cjs';
2
+ import { P as PermissionScope } from '../types-zzK9YOoa.cjs';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
4
4
 
5
5
  interface HermesTool {
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK, ReplayInputs } from '../index.js';
2
- import { P as PermissionScope } from '../types-Cb6V-boJ.js';
2
+ import { P as PermissionScope } from '../types-zzK9YOoa.js';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
4
4
 
5
5
  interface HermesTool {
@@ -1,4 +1,4 @@
1
- import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.cjs';
1
+ import { P as PermissionScope, A as AgentRegistrationResult } from '../types-zzK9YOoa.cjs';
2
2
  import { VorimSDK, ReplayInputs } from '../index.cjs';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.js';
1
+ import { P as PermissionScope, A as AgentRegistrationResult } from '../types-zzK9YOoa.js';
2
2
  import { VorimSDK, ReplayInputs } from '../index.js';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { VorimLangChainConfig } from './langchain.cjs';
2
- import '../types-Cb6V-boJ.cjs';
2
+ import '../types-zzK9YOoa.cjs';
3
3
  import '../index.cjs';
4
4
  import '../_runtime-gate-DOJUKJBu.cjs';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { VorimLangChainConfig } from './langchain.js';
2
- import '../types-Cb6V-boJ.js';
2
+ import '../types-zzK9YOoa.js';
3
3
  import '../index.js';
4
4
  import '../_runtime-gate-DOJUKJBu.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.cjs';
1
+ import { P as PermissionScope, A as AgentRegistrationResult } from '../types-zzK9YOoa.cjs';
2
2
  import { VorimSDK, ReplayInputs } from '../index.cjs';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { P as PermissionScope, A as AgentRegistrationResult } from '../types-Cb6V-boJ.js';
1
+ import { P as PermissionScope, A as AgentRegistrationResult } from '../types-zzK9YOoa.js';
2
2
  import { VorimSDK, ReplayInputs } from '../index.js';
3
3
  import { E as EscalationPolicy, T as TransportFailurePolicy } from '../_runtime-gate-DOJUKJBu.js';
4
4