@vorim/sdk 3.8.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) 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.cjs +280 -0
  30. package/dist/integrations/hermes.cjs.map +1 -0
  31. package/dist/integrations/hermes.d.cts +60 -0
  32. package/dist/integrations/hermes.d.ts +60 -0
  33. package/dist/integrations/hermes.js +242 -0
  34. package/dist/integrations/hermes.js.map +1 -0
  35. package/dist/integrations/langchain.d.cts +1 -1
  36. package/dist/integrations/langchain.d.ts +1 -1
  37. package/dist/integrations/langgraph.d.cts +1 -1
  38. package/dist/integrations/langgraph.d.ts +1 -1
  39. package/dist/integrations/llamaindex.d.cts +1 -1
  40. package/dist/integrations/llamaindex.d.ts +1 -1
  41. package/dist/integrations/nekuda.cjs +165 -0
  42. package/dist/integrations/nekuda.cjs.map +1 -0
  43. package/dist/integrations/nekuda.d.cts +79 -0
  44. package/dist/integrations/nekuda.d.ts +79 -0
  45. package/dist/integrations/nekuda.js +139 -0
  46. package/dist/integrations/nekuda.js.map +1 -0
  47. package/dist/integrations/openai.d.cts +1 -1
  48. package/dist/integrations/openai.d.ts +1 -1
  49. package/dist/integrations/paypal-agent.cjs +215 -0
  50. package/dist/integrations/paypal-agent.cjs.map +1 -0
  51. package/dist/integrations/paypal-agent.d.cts +87 -0
  52. package/dist/integrations/paypal-agent.d.ts +87 -0
  53. package/dist/integrations/paypal-agent.js +189 -0
  54. package/dist/integrations/paypal-agent.js.map +1 -0
  55. package/dist/integrations/siem.d.cts +1 -1
  56. package/dist/integrations/siem.d.ts +1 -1
  57. package/dist/integrations/skyfire.cjs +166 -0
  58. package/dist/integrations/skyfire.cjs.map +1 -0
  59. package/dist/integrations/skyfire.d.cts +80 -0
  60. package/dist/integrations/skyfire.d.ts +80 -0
  61. package/dist/integrations/skyfire.js +140 -0
  62. package/dist/integrations/skyfire.js.map +1 -0
  63. package/dist/integrations/stripe-acp.d.cts +1 -1
  64. package/dist/integrations/stripe-acp.d.ts +1 -1
  65. package/dist/integrations/ucp.d.cts +1 -1
  66. package/dist/integrations/ucp.d.ts +1 -1
  67. package/dist/integrations/vercel-ai.d.cts +1 -1
  68. package/dist/integrations/vercel-ai.d.ts +1 -1
  69. package/dist/integrations/x402.cjs +211 -0
  70. package/dist/integrations/x402.cjs.map +1 -0
  71. package/dist/integrations/x402.d.cts +87 -0
  72. package/dist/integrations/x402.d.ts +87 -0
  73. package/dist/integrations/x402.js +185 -0
  74. package/dist/integrations/x402.js.map +1 -0
  75. package/dist/{types-Cb6V-boJ.d.cts → types-zzK9YOoa.d.cts} +86 -1
  76. package/dist/{types-Cb6V-boJ.d.ts → types-zzK9YOoa.d.ts} +86 -1
  77. package/package.json +83 -2
@@ -0,0 +1,87 @@
1
+ import { VorimSDK } from '../index.js';
2
+ import '../types-zzK9YOoa.js';
3
+
4
+ interface X402Config {
5
+ apiKey: string;
6
+ baseUrl?: string;
7
+ minTrustScore?: number;
8
+ requiredScope?: string;
9
+ }
10
+ interface X402PaymentRequest {
11
+ /** The Vorim agent id that will make the payment. */
12
+ agentId: string;
13
+ /** The resource / endpoint being paid for (the thing behind the 402). */
14
+ resource?: string;
15
+ /** Amount in the smallest unit of the currency/asset. */
16
+ amount?: number;
17
+ /** Asset or currency code (e.g. 'USDC', 'usd'). */
18
+ currency?: string;
19
+ /** The recipient address / account the payment settles to. */
20
+ payTo?: string;
21
+ /** The x402 scheme / network hint (e.g. 'exact', 'base-sepolia'). Informational. */
22
+ scheme?: string;
23
+ /** Per-call override of the trust threshold. */
24
+ minTrustScore?: number;
25
+ }
26
+ interface X402Authorization {
27
+ authorized: boolean;
28
+ agentId: string;
29
+ trustScore: number;
30
+ status: string;
31
+ reason?: string;
32
+ scopeVerified: boolean;
33
+ }
34
+ declare class VorimX402 {
35
+ private sdk;
36
+ private minTrustScore;
37
+ private requiredScope;
38
+ /** One-time guard so the no-auth confused-deputy warning logs at most once. */
39
+ private static _warnedNoAuth;
40
+ constructor(sdk: VorimSDK, config?: Partial<X402Config>);
41
+ /**
42
+ * Verify an agent is authorized to settle an x402 payment. Same gate as the
43
+ * ACP integration: transact scope → active status → trust threshold. Every
44
+ * outcome (allow or deny) is recorded on the audit trail.
45
+ */
46
+ authorizePayment(req: X402PaymentRequest): Promise<X402Authorization>;
47
+ /** Log that a 402 payment was settled (proof-of-payment accepted). */
48
+ logPaymentSettled(agentId: string, paymentId: string, req?: Partial<X402PaymentRequest>): Promise<void>;
49
+ /** Log that a 402 payment failed or was rejected by the resource server. */
50
+ logPaymentFailed(agentId: string, paymentId: string, reason?: string, req?: Partial<X402PaymentRequest>): Promise<void>;
51
+ /**
52
+ * Express/Connect middleware for a resource server that gates paid endpoints
53
+ * on agent authorization.
54
+ *
55
+ * ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
56
+ * only; it does NOT prove the HTTP caller controls that agent (any client can
57
+ * send any agent id in the header). Authenticate the caller-to-agent binding
58
+ * upstream, or pass `authenticate` — an async hook that returns true only if
59
+ * the request genuinely speaks for `agentId`. When omitted, a one-time
60
+ * warning is logged.
61
+ */
62
+ middleware(options?: {
63
+ agentIdHeader?: string;
64
+ minTrustScore?: number;
65
+ authenticate?: (agentId: string, req: any) => boolean | Promise<boolean>;
66
+ }): (req: any, res: any, next: any) => Promise<void>;
67
+ private logEvent;
68
+ }
69
+ /**
70
+ * Create a VorimX402 instance.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import createVorim from '@vorim/sdk';
75
+ * import { createVorimX402 } from '@vorim/sdk/integrations/x402';
76
+ *
77
+ * const vorim = createVorim({ apiKey: 'agid_sk_...' });
78
+ * const x402 = createVorimX402(vorim, { minTrustScore: 70 });
79
+ *
80
+ * const auth = await x402.authorizePayment({ agentId: 'agid_abc123', resource: '/report', amount: 1000, currency: 'USDC' });
81
+ *
82
+ * app.get('/paid-endpoint', x402.middleware(), handler);
83
+ * ```
84
+ */
85
+ declare function createVorimX402(sdk: VorimSDK, config?: Partial<X402Config>): VorimX402;
86
+
87
+ export { VorimX402, type X402Authorization, type X402Config, type X402PaymentRequest, createVorimX402 };
@@ -0,0 +1,185 @@
1
+ // src/integrations/x402.ts
2
+ var VorimX402 = class _VorimX402 {
3
+ sdk;
4
+ minTrustScore;
5
+ requiredScope;
6
+ /** One-time guard so the no-auth confused-deputy warning logs at most once. */
7
+ static _warnedNoAuth = false;
8
+ constructor(sdk, config) {
9
+ this.sdk = sdk;
10
+ this.minTrustScore = config?.minTrustScore ?? 50;
11
+ this.requiredScope = config?.requiredScope ?? "agent:transact";
12
+ }
13
+ /**
14
+ * Verify an agent is authorized to settle an x402 payment. Same gate as the
15
+ * ACP integration: transact scope → active status → trust threshold. Every
16
+ * outcome (allow or deny) is recorded on the audit trail.
17
+ */
18
+ async authorizePayment(req) {
19
+ const threshold = req.minTrustScore ?? this.minTrustScore;
20
+ try {
21
+ const perm = await this.sdk.check(req.agentId, this.requiredScope);
22
+ if (!perm.allowed) {
23
+ await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Missing ${this.requiredScope}` });
24
+ return {
25
+ authorized: false,
26
+ agentId: req.agentId,
27
+ trustScore: 0,
28
+ status: "unknown",
29
+ reason: `Agent does not have ${this.requiredScope} permission`,
30
+ scopeVerified: false
31
+ };
32
+ }
33
+ } catch (e) {
34
+ await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: e.message });
35
+ return {
36
+ authorized: false,
37
+ agentId: req.agentId,
38
+ trustScore: 0,
39
+ status: "unknown",
40
+ reason: `Permission check failed: ${e.message}`,
41
+ scopeVerified: false
42
+ };
43
+ }
44
+ let score = 0;
45
+ let status = "unknown";
46
+ try {
47
+ const trust = await this.sdk.verify(req.agentId);
48
+ score = trust.trust_score ?? 0;
49
+ status = trust.status ?? "unknown";
50
+ } catch {
51
+ }
52
+ if (status !== "active") {
53
+ await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Status: ${status}` });
54
+ return {
55
+ authorized: false,
56
+ agentId: req.agentId,
57
+ trustScore: score,
58
+ status,
59
+ reason: `Agent is ${status}, not active`,
60
+ scopeVerified: true
61
+ };
62
+ }
63
+ if (score < threshold) {
64
+ await this.logEvent(req.agentId, "x402.authorize", "denied", req, { reason: `Score ${score} < ${threshold}` });
65
+ return {
66
+ authorized: false,
67
+ agentId: req.agentId,
68
+ trustScore: score,
69
+ status,
70
+ reason: `Trust score ${score} is below minimum ${threshold}`,
71
+ scopeVerified: true
72
+ };
73
+ }
74
+ await this.logEvent(req.agentId, "x402.authorize", "success", req, { trust_score: score });
75
+ return {
76
+ authorized: true,
77
+ agentId: req.agentId,
78
+ trustScore: score,
79
+ status,
80
+ scopeVerified: true
81
+ };
82
+ }
83
+ /** Log that a 402 payment was settled (proof-of-payment accepted). */
84
+ async logPaymentSettled(agentId, paymentId, req) {
85
+ await this.logEvent(agentId, "x402.settled", "success", req, { payment_id: paymentId });
86
+ }
87
+ /** Log that a 402 payment failed or was rejected by the resource server. */
88
+ async logPaymentFailed(agentId, paymentId, reason, req) {
89
+ await this.logEvent(agentId, "x402.failed", "error", req, { payment_id: paymentId, fail_reason: reason });
90
+ }
91
+ /**
92
+ * Express/Connect middleware for a resource server that gates paid endpoints
93
+ * on agent authorization.
94
+ *
95
+ * ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing
96
+ * only; it does NOT prove the HTTP caller controls that agent (any client can
97
+ * send any agent id in the header). Authenticate the caller-to-agent binding
98
+ * upstream, or pass `authenticate` — an async hook that returns true only if
99
+ * the request genuinely speaks for `agentId`. When omitted, a one-time
100
+ * warning is logged.
101
+ */
102
+ middleware(options) {
103
+ const header = options?.agentIdHeader ?? "x-vorim-agent-id";
104
+ const threshold = options?.minTrustScore ?? this.minTrustScore;
105
+ const authenticate = options?.authenticate;
106
+ if (!authenticate && !_VorimX402._warnedNoAuth) {
107
+ _VorimX402._warnedNoAuth = true;
108
+ console.warn(
109
+ "[vorim] VorimX402.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). Authenticate the caller-to-agent binding upstream or pass `authenticate`."
110
+ );
111
+ }
112
+ return async (req, res, next) => {
113
+ const agentId = req.headers?.[header] || req.headers?.[header.toLowerCase()] || "";
114
+ if (!agentId) {
115
+ res.status(401).json({
116
+ error: { code: "MISSING_AGENT_ID", message: `Agent ID required in ${header} header` }
117
+ });
118
+ return;
119
+ }
120
+ if (authenticate) {
121
+ let bound = false;
122
+ try {
123
+ bound = await authenticate(agentId, req);
124
+ } catch {
125
+ bound = false;
126
+ }
127
+ if (!bound) {
128
+ res.status(401).json({
129
+ error: { code: "AGENT_BINDING_UNVERIFIED", message: "Caller is not authenticated as the named agent" }
130
+ });
131
+ return;
132
+ }
133
+ }
134
+ const auth = await this.authorizePayment({
135
+ agentId,
136
+ resource: req.originalUrl || req.url || "",
137
+ amount: req.body?.amount || 0,
138
+ currency: req.body?.currency || "USDC",
139
+ payTo: req.body?.payTo || "",
140
+ minTrustScore: threshold
141
+ });
142
+ if (!auth.authorized) {
143
+ res.status(402).json({
144
+ error: {
145
+ code: "UNAUTHORIZED_AGENT",
146
+ message: auth.reason || "Agent not authorized for x402 payment",
147
+ trust_score: auth.trustScore,
148
+ status: auth.status
149
+ }
150
+ });
151
+ return;
152
+ }
153
+ req.vorimAuthorization = auth;
154
+ next();
155
+ };
156
+ }
157
+ async logEvent(agentId, action, result, req, metadata) {
158
+ try {
159
+ await this.sdk.emit({
160
+ agent_id: agentId,
161
+ event_type: "api_request",
162
+ action,
163
+ result,
164
+ resource: req?.resource || "",
165
+ metadata: {
166
+ resource: req?.resource || "",
167
+ amount: req?.amount || 0,
168
+ currency: req?.currency || "",
169
+ pay_to: req?.payTo || "",
170
+ scheme: req?.scheme || "",
171
+ ...metadata
172
+ }
173
+ });
174
+ } catch {
175
+ }
176
+ }
177
+ };
178
+ function createVorimX402(sdk, config) {
179
+ return new VorimX402(sdk, config);
180
+ }
181
+ export {
182
+ VorimX402,
183
+ createVorimX402
184
+ };
185
+ //# sourceMappingURL=x402.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/x402.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — x402 Integration\n//\n// x402 is an open, HTTP-native payment standard (revived around the HTTP 402\n// \"Payment Required\" status) for machine-to-machine and agentic payments: a\n// server answers a request with 402 + payment requirements, the client pays,\n// and retries with proof of payment. It's a natural fit for AI agents paying\n// per-request for APIs, data, or compute.\n//\n// This integration adds Vorim's identity, permission, and audit layer IN FRONT\n// of an x402 payment: before an agent settles a 402 challenge, it verifies the\n// agent holds the `transact` scope, is active, and clears a trust threshold,\n// then records the payment lifecycle on a signed, tamper-evident audit trail.\n// It does NOT move money or hold keys — it authorizes and attests.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimX402 } from '@vorim/sdk/integrations/x402';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const x402 = createVorimX402(vorim, { minTrustScore: 60 });\n//\n// // A 402 came back from a resource server. Before paying, authorize:\n// const auth = await x402.authorizePayment({\n// agentId: 'agid_abc123',\n// resource: 'https://api.example.com/v1/report',\n// amount: 1000, // smallest currency unit (e.g. 1000 = $0.01 at 6dp, or 1000 cents)\n// currency: 'USDC',\n// payTo: '0xSeller...',\n// });\n// if (auth.authorized) {\n// // ... settle the x402 challenge, then:\n// await x402.logPaymentSettled(auth.agentId, paymentId, { resource, amount });\n// }\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\n\nexport interface X402Config {\n apiKey: string;\n baseUrl?: string;\n minTrustScore?: number;\n requiredScope?: string;\n}\n\nexport interface X402PaymentRequest {\n /** The Vorim agent id that will make the payment. */\n agentId: string;\n /** The resource / endpoint being paid for (the thing behind the 402). */\n resource?: string;\n /** Amount in the smallest unit of the currency/asset. */\n amount?: number;\n /** Asset or currency code (e.g. 'USDC', 'usd'). */\n currency?: string;\n /** The recipient address / account the payment settles to. */\n payTo?: string;\n /** The x402 scheme / network hint (e.g. 'exact', 'base-sepolia'). Informational. */\n scheme?: string;\n /** Per-call override of the trust threshold. */\n minTrustScore?: number;\n}\n\nexport interface X402Authorization {\n authorized: boolean;\n agentId: string;\n trustScore: number;\n status: string;\n reason?: string;\n scopeVerified: boolean;\n}\n\nexport class VorimX402 {\n private sdk: VorimSDK;\n private minTrustScore: number;\n private requiredScope: string;\n /** One-time guard so the no-auth confused-deputy warning logs at most once. */\n private static _warnedNoAuth = false;\n\n constructor(sdk: VorimSDK, config?: Partial<X402Config>) {\n this.sdk = sdk;\n this.minTrustScore = config?.minTrustScore ?? 50;\n this.requiredScope = config?.requiredScope ?? 'agent:transact';\n }\n\n /**\n * Verify an agent is authorized to settle an x402 payment. Same gate as the\n * ACP integration: transact scope → active status → trust threshold. Every\n * outcome (allow or deny) is recorded on the audit trail.\n */\n async authorizePayment(req: X402PaymentRequest): Promise<X402Authorization> {\n const threshold = req.minTrustScore ?? this.minTrustScore;\n\n // 1. Permission: the agent must hold the transact scope.\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, 'x402.authorize', 'denied', req, { reason: `Missing ${this.requiredScope}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: 0,\n status: 'unknown',\n reason: `Agent does not have ${this.requiredScope} permission`,\n scopeVerified: false,\n };\n }\n } catch (e: any) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: e.message });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: 0,\n status: 'unknown',\n reason: `Permission check failed: ${e.message}`,\n scopeVerified: false,\n };\n }\n\n // 2. Trust: verify the agent's public standing.\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 {\n // Trust verification failed — treated as not-active below.\n }\n\n if (status !== 'active') {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Status: ${status}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: score,\n status,\n reason: `Agent is ${status}, not active`,\n scopeVerified: true,\n };\n }\n\n if (score < threshold) {\n await this.logEvent(req.agentId, 'x402.authorize', 'denied', req, { reason: `Score ${score} < ${threshold}` });\n return {\n authorized: false,\n agentId: req.agentId,\n trustScore: score,\n status,\n reason: `Trust score ${score} is below minimum ${threshold}`,\n scopeVerified: true,\n };\n }\n\n await this.logEvent(req.agentId, 'x402.authorize', 'success', req, { trust_score: score });\n\n return {\n authorized: true,\n agentId: req.agentId,\n trustScore: score,\n status,\n scopeVerified: true,\n };\n }\n\n /** Log that a 402 payment was settled (proof-of-payment accepted). */\n async logPaymentSettled(agentId: string, paymentId: string, req?: Partial<X402PaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'x402.settled', 'success', req, { payment_id: paymentId });\n }\n\n /** Log that a 402 payment failed or was rejected by the resource server. */\n async logPaymentFailed(agentId: string, paymentId: string, reason?: string, req?: Partial<X402PaymentRequest>): Promise<void> {\n await this.logEvent(agentId, 'x402.failed', 'error', req, { payment_id: paymentId, fail_reason: reason });\n }\n\n /**\n * Express/Connect middleware for a resource server that gates paid endpoints\n * on agent authorization.\n *\n * ⚠️ CONFUSED-DEPUTY WARNING. This evaluates the *named* agent's standing\n * only; it does NOT prove the HTTP caller controls that agent (any client can\n * send any agent id in the header). Authenticate the caller-to-agent binding\n * upstream, or pass `authenticate` — an async hook that returns true only if\n * the request genuinely speaks for `agentId`. When omitted, a one-time\n * 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 && !VorimX402._warnedNoAuth) {\n VorimX402._warnedNoAuth = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[vorim] VorimX402.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). Authenticate the ' +\n 'caller-to-agent binding upstream or 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\n if (!agentId) {\n res.status(401).json({\n error: { code: 'MISSING_AGENT_ID', message: `Agent ID required in ${header} header` },\n });\n return;\n }\n\n if (authenticate) {\n let bound = false;\n try {\n bound = await authenticate(agentId, req);\n } catch {\n bound = false;\n }\n if (!bound) {\n res.status(401).json({\n error: { code: 'AGENT_BINDING_UNVERIFIED', message: 'Caller is not authenticated as the named agent' },\n });\n return;\n }\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 payTo: req.body?.payTo || '',\n minTrustScore: threshold,\n });\n\n if (!auth.authorized) {\n // 402 is the semantically correct status for x402 payment gating.\n res.status(402).json({\n error: {\n code: 'UNAUTHORIZED_AGENT',\n message: auth.reason || 'Agent not authorized for x402 payment',\n trust_score: auth.trustScore,\n status: auth.status,\n },\n });\n return;\n }\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<X402PaymentRequest>,\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 || '',\n pay_to: req?.payTo || '',\n scheme: req?.scheme || '',\n ...metadata,\n },\n });\n } catch {\n // Never block the payment flow on an audit hiccup.\n }\n }\n}\n\n/**\n * Create a VorimX402 instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimX402 } from '@vorim/sdk/integrations/x402';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const x402 = createVorimX402(vorim, { minTrustScore: 70 });\n *\n * const auth = await x402.authorizePayment({ agentId: 'agid_abc123', resource: '/report', amount: 1000, currency: 'USDC' });\n *\n * app.get('/paid-endpoint', x402.middleware(), handler);\n * ```\n */\nexport function createVorimX402(sdk: VorimSDK, config?: Partial<X402Config>): VorimX402 {\n return new VorimX402(sdk, config);\n}\n"],"mappings":";AAuEO,IAAM,YAAN,MAAM,WAAU;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAER,OAAe,gBAAgB;AAAA,EAE/B,YAAY,KAAe,QAA8B;AACvD,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A,UACR,UAAU,KAAK,YAAY;AAAA,UAC3B,QAAQ,KAAK,UAAU;AAAA,UACvB,UAAU,KAAK,YAAY;AAAA,UAC3B,QAAQ,KAAK,SAAS;AAAA,UACtB,QAAQ,KAAK,UAAU;AAAA,UACvB,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAkBO,SAAS,gBAAgB,KAAe,QAAyC;AACtF,SAAO,IAAI,UAAU,KAAK,MAAM;AAClC;","names":[]}
@@ -154,6 +154,43 @@ interface AgentDelegationRecord {
154
154
  /** Optional ISO8601 expiry. */
155
155
  validUntil: string | null;
156
156
  }
157
+ /**
158
+ * One governed shared-memory entry as returned by the API.
159
+ *
160
+ * Every entry is attributed to the agent that wrote it and (when signed)
161
+ * carries that agent's Ed25519 signature over the canonical entry, so a
162
+ * poisoned entry is always traceable to its source (OWASP ASI06).
163
+ */
164
+ interface SharedMemoryEntry {
165
+ namespace: string;
166
+ key: string;
167
+ value: unknown;
168
+ /** Public agent_id (`agid_*`) of the agent that authored the current value. */
169
+ written_by: string;
170
+ /** `sha256:<hex>` of the canonical value, or null. */
171
+ content_hash: string | null;
172
+ /** True iff a (verified) signature is stored for this entry. */
173
+ signed: boolean;
174
+ created_at: string;
175
+ updated_at: string;
176
+ }
177
+ /** Input to {@link VorimSDK.writeMemory} (the entry body; the agent id is a
178
+ * separate positional arg so the SDK can find its signing key). */
179
+ interface SharedMemoryWriteInput {
180
+ namespace: string;
181
+ key: string;
182
+ value: unknown;
183
+ }
184
+ /** Pagination meta returned by {@link VorimSDK.listMemory}. */
185
+ interface SharedMemoryListResult {
186
+ entries: SharedMemoryEntry[];
187
+ meta: {
188
+ page: number;
189
+ per_page: number;
190
+ total: number;
191
+ total_pages: number;
192
+ };
193
+ }
157
194
  interface TrustRecord {
158
195
  agent_id: string;
159
196
  owner: {
@@ -284,5 +321,53 @@ interface RuntimeDecision {
284
321
  */
285
322
  escalationResolution: 'approved' | 'denied' | null;
286
323
  }
324
+ interface WorkflowGraphNode {
325
+ agent_id: string;
326
+ /** 'root' = the chain's originating agent; 'delegate' = received authority. */
327
+ role: 'root' | 'delegate';
328
+ /** Scopes this agent was delegated (empty for the root). */
329
+ scopes: string[];
330
+ /** Count of audit events attributed to this agent within the workflow. */
331
+ event_count: number;
332
+ }
333
+ interface WorkflowGraphEdge {
334
+ /** Delegator agent_id. */
335
+ from: string;
336
+ /** Delegate agent_id. */
337
+ to: string;
338
+ /** Scopes delegated across this edge. */
339
+ scopes: string[];
340
+ depth: number;
341
+ status: string;
342
+ }
343
+ interface WorkflowGraphEvent {
344
+ event_id: string;
345
+ agent_id: string | null;
346
+ agent_name: string | null;
347
+ action: string;
348
+ event_type: string;
349
+ result: string;
350
+ resource: string | null;
351
+ delegation_depth: number | null;
352
+ decision_id: string | null;
353
+ timestamp: string;
354
+ }
355
+ /**
356
+ * The reconstructed provenance graph of a multi-agent workflow: agents (nodes),
357
+ * delegations between them (edges), and the audit events each performed.
358
+ */
359
+ interface WorkflowProvenanceGraph {
360
+ chain_id: string;
361
+ root_agent: string | null;
362
+ nodes: WorkflowGraphNode[];
363
+ edges: WorkflowGraphEdge[];
364
+ events: WorkflowGraphEvent[];
365
+ meta: {
366
+ node_count: number;
367
+ edge_count: number;
368
+ event_count: number;
369
+ events_truncated: boolean;
370
+ };
371
+ }
287
372
 
288
- export type { AgentRegistrationResult as A, BeforeActionInput as B, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, TrustRecord as T, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, TokenBudgetInput as f, TokenBudget as g, BudgetSpend as h, AgentStatus as i, AuditEventType as j, AuditResult as k, BudgetEnforcement as l, BudgetScope as m, DecisionVerdict as n };
373
+ export type { AgentRegistrationResult as A, BeforeActionInput as B, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, SharedMemoryWriteInput as S, TrustRecord as T, WorkflowProvenanceGraph as W, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, SharedMemoryEntry as f, SharedMemoryListResult as g, TokenBudgetInput as h, TokenBudget as i, BudgetSpend as j, AgentStatus as k, AuditEventType as l, AuditResult as m, BudgetEnforcement as n, BudgetScope as o, DecisionVerdict as p, WorkflowGraphEdge as q, WorkflowGraphEvent as r, WorkflowGraphNode as s };
@@ -154,6 +154,43 @@ interface AgentDelegationRecord {
154
154
  /** Optional ISO8601 expiry. */
155
155
  validUntil: string | null;
156
156
  }
157
+ /**
158
+ * One governed shared-memory entry as returned by the API.
159
+ *
160
+ * Every entry is attributed to the agent that wrote it and (when signed)
161
+ * carries that agent's Ed25519 signature over the canonical entry, so a
162
+ * poisoned entry is always traceable to its source (OWASP ASI06).
163
+ */
164
+ interface SharedMemoryEntry {
165
+ namespace: string;
166
+ key: string;
167
+ value: unknown;
168
+ /** Public agent_id (`agid_*`) of the agent that authored the current value. */
169
+ written_by: string;
170
+ /** `sha256:<hex>` of the canonical value, or null. */
171
+ content_hash: string | null;
172
+ /** True iff a (verified) signature is stored for this entry. */
173
+ signed: boolean;
174
+ created_at: string;
175
+ updated_at: string;
176
+ }
177
+ /** Input to {@link VorimSDK.writeMemory} (the entry body; the agent id is a
178
+ * separate positional arg so the SDK can find its signing key). */
179
+ interface SharedMemoryWriteInput {
180
+ namespace: string;
181
+ key: string;
182
+ value: unknown;
183
+ }
184
+ /** Pagination meta returned by {@link VorimSDK.listMemory}. */
185
+ interface SharedMemoryListResult {
186
+ entries: SharedMemoryEntry[];
187
+ meta: {
188
+ page: number;
189
+ per_page: number;
190
+ total: number;
191
+ total_pages: number;
192
+ };
193
+ }
157
194
  interface TrustRecord {
158
195
  agent_id: string;
159
196
  owner: {
@@ -284,5 +321,53 @@ interface RuntimeDecision {
284
321
  */
285
322
  escalationResolution: 'approved' | 'denied' | null;
286
323
  }
324
+ interface WorkflowGraphNode {
325
+ agent_id: string;
326
+ /** 'root' = the chain's originating agent; 'delegate' = received authority. */
327
+ role: 'root' | 'delegate';
328
+ /** Scopes this agent was delegated (empty for the root). */
329
+ scopes: string[];
330
+ /** Count of audit events attributed to this agent within the workflow. */
331
+ event_count: number;
332
+ }
333
+ interface WorkflowGraphEdge {
334
+ /** Delegator agent_id. */
335
+ from: string;
336
+ /** Delegate agent_id. */
337
+ to: string;
338
+ /** Scopes delegated across this edge. */
339
+ scopes: string[];
340
+ depth: number;
341
+ status: string;
342
+ }
343
+ interface WorkflowGraphEvent {
344
+ event_id: string;
345
+ agent_id: string | null;
346
+ agent_name: string | null;
347
+ action: string;
348
+ event_type: string;
349
+ result: string;
350
+ resource: string | null;
351
+ delegation_depth: number | null;
352
+ decision_id: string | null;
353
+ timestamp: string;
354
+ }
355
+ /**
356
+ * The reconstructed provenance graph of a multi-agent workflow: agents (nodes),
357
+ * delegations between them (edges), and the audit events each performed.
358
+ */
359
+ interface WorkflowProvenanceGraph {
360
+ chain_id: string;
361
+ root_agent: string | null;
362
+ nodes: WorkflowGraphNode[];
363
+ edges: WorkflowGraphEdge[];
364
+ events: WorkflowGraphEvent[];
365
+ meta: {
366
+ node_count: number;
367
+ edge_count: number;
368
+ event_count: number;
369
+ events_truncated: boolean;
370
+ };
371
+ }
287
372
 
288
- export type { AgentRegistrationResult as A, BeforeActionInput as B, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, TrustRecord as T, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, TokenBudgetInput as f, TokenBudget as g, BudgetSpend as h, AgentStatus as i, AuditEventType as j, AuditResult as k, BudgetEnforcement as l, BudgetScope as m, DecisionVerdict as n };
373
+ export type { AgentRegistrationResult as A, BeforeActionInput as B, DelegationLinkClaims as D, PermissionScope as P, RuntimeDecision as R, SharedMemoryWriteInput as S, TrustRecord as T, WorkflowProvenanceGraph as W, AuditEventInput as a, AgentRegistrationInput as b, Agent as c, PermissionCheckResult as d, AgentDelegationRecord as e, SharedMemoryEntry as f, SharedMemoryListResult as g, TokenBudgetInput as h, TokenBudget as i, BudgetSpend as j, AgentStatus as k, AuditEventType as l, AuditResult as m, BudgetEnforcement as n, BudgetScope as o, DecisionVerdict as p, WorkflowGraphEdge as q, WorkflowGraphEvent as r, WorkflowGraphNode as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vorim/sdk",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "Official TypeScript SDK for Vorim AI — AI Agent Identity, Permissions & Audit",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -87,6 +87,16 @@
87
87
  "default": "./dist/integrations/vercel-ai.cjs"
88
88
  }
89
89
  },
90
+ "./integrations/hermes": {
91
+ "import": {
92
+ "types": "./dist/integrations/hermes.d.ts",
93
+ "default": "./dist/integrations/hermes.js"
94
+ },
95
+ "require": {
96
+ "types": "./dist/integrations/hermes.d.cts",
97
+ "default": "./dist/integrations/hermes.cjs"
98
+ }
99
+ },
90
100
  "./integrations/stripe-acp": {
91
101
  "import": {
92
102
  "types": "./dist/integrations/stripe-acp.d.ts",
@@ -107,6 +117,76 @@
107
117
  "default": "./dist/integrations/ucp.cjs"
108
118
  }
109
119
  },
120
+ "./integrations/x402": {
121
+ "import": {
122
+ "types": "./dist/integrations/x402.d.ts",
123
+ "default": "./dist/integrations/x402.js"
124
+ },
125
+ "require": {
126
+ "types": "./dist/integrations/x402.d.cts",
127
+ "default": "./dist/integrations/x402.cjs"
128
+ }
129
+ },
130
+ "./integrations/ap2": {
131
+ "import": {
132
+ "types": "./dist/integrations/ap2.d.ts",
133
+ "default": "./dist/integrations/ap2.js"
134
+ },
135
+ "require": {
136
+ "types": "./dist/integrations/ap2.d.cts",
137
+ "default": "./dist/integrations/ap2.cjs"
138
+ }
139
+ },
140
+ "./integrations/paypal-agent": {
141
+ "import": {
142
+ "types": "./dist/integrations/paypal-agent.d.ts",
143
+ "default": "./dist/integrations/paypal-agent.js"
144
+ },
145
+ "require": {
146
+ "types": "./dist/integrations/paypal-agent.d.cts",
147
+ "default": "./dist/integrations/paypal-agent.cjs"
148
+ }
149
+ },
150
+ "./integrations/circle": {
151
+ "import": {
152
+ "types": "./dist/integrations/circle.d.ts",
153
+ "default": "./dist/integrations/circle.js"
154
+ },
155
+ "require": {
156
+ "types": "./dist/integrations/circle.d.cts",
157
+ "default": "./dist/integrations/circle.cjs"
158
+ }
159
+ },
160
+ "./integrations/skyfire": {
161
+ "import": {
162
+ "types": "./dist/integrations/skyfire.d.ts",
163
+ "default": "./dist/integrations/skyfire.js"
164
+ },
165
+ "require": {
166
+ "types": "./dist/integrations/skyfire.d.cts",
167
+ "default": "./dist/integrations/skyfire.cjs"
168
+ }
169
+ },
170
+ "./integrations/nekuda": {
171
+ "import": {
172
+ "types": "./dist/integrations/nekuda.d.ts",
173
+ "default": "./dist/integrations/nekuda.js"
174
+ },
175
+ "require": {
176
+ "types": "./dist/integrations/nekuda.d.cts",
177
+ "default": "./dist/integrations/nekuda.cjs"
178
+ }
179
+ },
180
+ "./integrations/bank-rails": {
181
+ "import": {
182
+ "types": "./dist/integrations/bank-rails.d.ts",
183
+ "default": "./dist/integrations/bank-rails.js"
184
+ },
185
+ "require": {
186
+ "types": "./dist/integrations/bank-rails.d.cts",
187
+ "default": "./dist/integrations/bank-rails.cjs"
188
+ }
189
+ },
110
190
  "./integrations/siem": {
111
191
  "import": {
112
192
  "types": "./dist/integrations/siem.d.ts",
@@ -150,7 +230,8 @@
150
230
  "langgraph",
151
231
  "openai",
152
232
  "crewai",
153
- "llamaindex"
233
+ "llamaindex",
234
+ "hermes"
154
235
  ],
155
236
  "repository": {
156
237
  "type": "git",