@vorim/sdk 3.12.0 → 3.16.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 (127) hide show
  1. package/dist/index.cjs +14 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +14 -2
  4. package/dist/index.d.ts +14 -2
  5. package/dist/index.js +14 -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.d.cts +1 -1
  10. package/dist/integrations/ap2.d.ts +1 -1
  11. package/dist/integrations/aws-iam.cjs +225 -0
  12. package/dist/integrations/aws-iam.cjs.map +1 -0
  13. package/dist/integrations/aws-iam.d.cts +156 -0
  14. package/dist/integrations/aws-iam.d.ts +156 -0
  15. package/dist/integrations/aws-iam.js +199 -0
  16. package/dist/integrations/aws-iam.js.map +1 -0
  17. package/dist/integrations/bank-rails.d.cts +1 -1
  18. package/dist/integrations/bank-rails.d.ts +1 -1
  19. package/dist/integrations/circle.d.cts +1 -1
  20. package/dist/integrations/circle.d.ts +1 -1
  21. package/dist/integrations/cloudflare.d.cts +1 -1
  22. package/dist/integrations/cloudflare.d.ts +1 -1
  23. package/dist/integrations/coinbase-cdp.cjs +230 -0
  24. package/dist/integrations/coinbase-cdp.cjs.map +1 -0
  25. package/dist/integrations/coinbase-cdp.d.cts +169 -0
  26. package/dist/integrations/coinbase-cdp.d.ts +169 -0
  27. package/dist/integrations/coinbase-cdp.js +204 -0
  28. package/dist/integrations/coinbase-cdp.js.map +1 -0
  29. package/dist/integrations/crewai.d.cts +1 -1
  30. package/dist/integrations/crewai.d.ts +1 -1
  31. package/dist/integrations/entra.cjs +225 -0
  32. package/dist/integrations/entra.cjs.map +1 -0
  33. package/dist/integrations/entra.d.cts +155 -0
  34. package/dist/integrations/entra.d.ts +155 -0
  35. package/dist/integrations/entra.js +199 -0
  36. package/dist/integrations/entra.js.map +1 -0
  37. package/dist/integrations/fhir.cjs +304 -0
  38. package/dist/integrations/fhir.cjs.map +1 -0
  39. package/dist/integrations/fhir.d.cts +185 -0
  40. package/dist/integrations/fhir.d.ts +185 -0
  41. package/dist/integrations/fhir.js +278 -0
  42. package/dist/integrations/fhir.js.map +1 -0
  43. package/dist/integrations/guidewire.cjs +363 -0
  44. package/dist/integrations/guidewire.cjs.map +1 -0
  45. package/dist/integrations/guidewire.d.cts +258 -0
  46. package/dist/integrations/guidewire.d.ts +258 -0
  47. package/dist/integrations/guidewire.js +337 -0
  48. package/dist/integrations/guidewire.js.map +1 -0
  49. package/dist/integrations/hermes.d.cts +1 -1
  50. package/dist/integrations/hermes.d.ts +1 -1
  51. package/dist/integrations/langchain.d.cts +1 -1
  52. package/dist/integrations/langchain.d.ts +1 -1
  53. package/dist/integrations/langgraph.d.cts +1 -1
  54. package/dist/integrations/langgraph.d.ts +1 -1
  55. package/dist/integrations/legal.cjs +339 -0
  56. package/dist/integrations/legal.cjs.map +1 -0
  57. package/dist/integrations/legal.d.cts +225 -0
  58. package/dist/integrations/legal.d.ts +225 -0
  59. package/dist/integrations/legal.js +313 -0
  60. package/dist/integrations/legal.js.map +1 -0
  61. package/dist/integrations/life-sciences.cjs +335 -0
  62. package/dist/integrations/life-sciences.cjs.map +1 -0
  63. package/dist/integrations/life-sciences.d.cts +214 -0
  64. package/dist/integrations/life-sciences.d.ts +214 -0
  65. package/dist/integrations/life-sciences.js +309 -0
  66. package/dist/integrations/life-sciences.js.map +1 -0
  67. package/dist/integrations/lithic.cjs +290 -0
  68. package/dist/integrations/lithic.cjs.map +1 -0
  69. package/dist/integrations/lithic.d.cts +130 -0
  70. package/dist/integrations/lithic.d.ts +130 -0
  71. package/dist/integrations/lithic.js +264 -0
  72. package/dist/integrations/lithic.js.map +1 -0
  73. package/dist/integrations/llamaindex.d.cts +1 -1
  74. package/dist/integrations/llamaindex.d.ts +1 -1
  75. package/dist/integrations/marqeta.cjs +285 -0
  76. package/dist/integrations/marqeta.cjs.map +1 -0
  77. package/dist/integrations/marqeta.d.cts +121 -0
  78. package/dist/integrations/marqeta.d.ts +121 -0
  79. package/dist/integrations/marqeta.js +259 -0
  80. package/dist/integrations/marqeta.js.map +1 -0
  81. package/dist/integrations/modern-treasury.d.cts +1 -1
  82. package/dist/integrations/modern-treasury.d.ts +1 -1
  83. package/dist/integrations/nekuda.d.cts +1 -1
  84. package/dist/integrations/nekuda.d.ts +1 -1
  85. package/dist/integrations/okta.cjs +229 -0
  86. package/dist/integrations/okta.cjs.map +1 -0
  87. package/dist/integrations/okta.d.cts +172 -0
  88. package/dist/integrations/okta.d.ts +172 -0
  89. package/dist/integrations/okta.js +203 -0
  90. package/dist/integrations/okta.js.map +1 -0
  91. package/dist/integrations/openai.d.cts +1 -1
  92. package/dist/integrations/openai.d.ts +1 -1
  93. package/dist/integrations/paypal-agent.d.cts +1 -1
  94. package/dist/integrations/paypal-agent.d.ts +1 -1
  95. package/dist/integrations/plaid.d.cts +1 -1
  96. package/dist/integrations/plaid.d.ts +1 -1
  97. package/dist/integrations/ramp.cjs +206 -0
  98. package/dist/integrations/ramp.cjs.map +1 -0
  99. package/dist/integrations/ramp.d.cts +139 -0
  100. package/dist/integrations/ramp.d.ts +139 -0
  101. package/dist/integrations/ramp.js +180 -0
  102. package/dist/integrations/ramp.js.map +1 -0
  103. package/dist/integrations/shopify.d.cts +1 -1
  104. package/dist/integrations/shopify.d.ts +1 -1
  105. package/dist/integrations/siem.d.cts +1 -1
  106. package/dist/integrations/siem.d.ts +1 -1
  107. package/dist/integrations/skyfire.d.cts +1 -1
  108. package/dist/integrations/skyfire.d.ts +1 -1
  109. package/dist/integrations/stripe-acp.d.cts +1 -1
  110. package/dist/integrations/stripe-acp.d.ts +1 -1
  111. package/dist/integrations/stripe-issuing.cjs +316 -0
  112. package/dist/integrations/stripe-issuing.cjs.map +1 -0
  113. package/dist/integrations/stripe-issuing.d.cts +154 -0
  114. package/dist/integrations/stripe-issuing.d.ts +154 -0
  115. package/dist/integrations/stripe-issuing.js +290 -0
  116. package/dist/integrations/stripe-issuing.js.map +1 -0
  117. package/dist/integrations/truanon.d.cts +1 -1
  118. package/dist/integrations/truanon.d.ts +1 -1
  119. package/dist/integrations/ucp.d.cts +1 -1
  120. package/dist/integrations/ucp.d.ts +1 -1
  121. package/dist/integrations/vercel-ai.d.cts +1 -1
  122. package/dist/integrations/vercel-ai.d.ts +1 -1
  123. package/dist/integrations/x402.d.cts +1 -1
  124. package/dist/integrations/x402.d.ts +1 -1
  125. package/dist/{types-zzK9YOoa.d.cts → types-Lp1iHEDz.d.cts} +21 -1
  126. package/dist/{types-zzK9YOoa.d.ts → types-Lp1iHEDz.d.ts} +21 -1
  127. package/package.json +121 -1
@@ -0,0 +1,199 @@
1
+ // src/integrations/aws-iam.ts
2
+ var ESCALATION_OPS = /* @__PURE__ */ new Set(["CreateAccessKey", "CreateRole", "AttachRolePolicy", "PutRolePolicy"]);
3
+ var OPERATION_SCOPE = {
4
+ read: "agent:read",
5
+ CreateUser: "agent:write",
6
+ AssumeRole: "agent:write",
7
+ CreateRole: "agent:elevate",
8
+ AttachRolePolicy: "agent:elevate",
9
+ PutRolePolicy: "agent:elevate",
10
+ CreateAccessKey: "agent:elevate"
11
+ };
12
+ var VorimAwsIam = class {
13
+ sdk;
14
+ agentId;
15
+ accountId;
16
+ adminId;
17
+ minTrustScore;
18
+ escalatePrivileged;
19
+ escalationTimeoutMs;
20
+ onError;
21
+ constructor(sdk, config) {
22
+ if (!config?.agentId) throw new Error("[vorim] AWS IAM integration requires an agentId.");
23
+ if (!config?.accountId) throw new Error("[vorim] AWS IAM integration requires an accountId.");
24
+ this.sdk = sdk;
25
+ this.agentId = config.agentId;
26
+ this.accountId = config.accountId;
27
+ this.adminId = config.adminId;
28
+ this.minTrustScore = config.minTrustScore ?? 0;
29
+ this.escalatePrivileged = config.escalatePrivileged ?? true;
30
+ this.escalationTimeoutMs = config.escalationTimeoutMs ?? 3e5;
31
+ this.onError = config.onError ?? "closed";
32
+ }
33
+ isPrivileged(operation) {
34
+ return ESCALATION_OPS.has(operation);
35
+ }
36
+ scopeFor(operation) {
37
+ return OPERATION_SCOPE[operation] ?? "agent:write";
38
+ }
39
+ async authorize(action) {
40
+ const privileged = this.isPrivileged(action.operation);
41
+ const scope = this.scopeFor(action.operation);
42
+ try {
43
+ if (this.minTrustScore > 0) {
44
+ const trust = await this.sdk.verify(this.agentId);
45
+ if ((trust?.trust_score ?? 0) < this.minTrustScore) {
46
+ return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: privileged ? "privileged-denied" : "ordinary" };
47
+ }
48
+ }
49
+ if (privileged) {
50
+ if (!this.escalatePrivileged) {
51
+ return { authorized: false, reason: `${action.operation} requires a human admin and escalatePrivileged is off`, outcome: "privileged-denied" };
52
+ }
53
+ if (!this.adminId) {
54
+ return {
55
+ authorized: false,
56
+ reason: `${action.operation} requires a configured adminId (the approving human admin)`,
57
+ outcome: "privileged-denied"
58
+ };
59
+ }
60
+ const esc = await this.escalate(action, scope);
61
+ return {
62
+ authorized: esc.approved,
63
+ reason: esc.approved ? void 0 : esc.reason ?? "admin did not approve",
64
+ outcome: esc.approved ? "approved-by-admin" : "privileged-denied",
65
+ adminId: esc.approved ? this.adminId : void 0,
66
+ decisionId: esc.decisionId
67
+ };
68
+ }
69
+ const perm = await this.sdk.check(this.agentId, scope);
70
+ return perm.allowed ? { authorized: true, outcome: "ordinary", adminId: this.adminId } : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: "ordinary" };
71
+ } catch (e) {
72
+ return this.onError === "open" ? { authorized: true, reason: "vorim unreachable, failed open", outcome: privileged ? "approved-by-admin" : "ordinary" } : { authorized: false, reason: `vorim unreachable: ${e?.message ?? "error"}`, outcome: privileged ? "privileged-denied" : "ordinary" };
73
+ }
74
+ }
75
+ async escalate(action, scope) {
76
+ const decision = await this.sdk.beforeAction(
77
+ {
78
+ agentId: this.agentId,
79
+ actionType: "api_request",
80
+ actionTarget: `aws-iam:${action.operation}`,
81
+ requiredScope: scope,
82
+ payload: { operation: action.operation, target_id: action.targetId, policy: action.policy },
83
+ context: { integration: "aws-iam", account_id: this.accountId, requires_human_admin: true, admin_hint: this.adminId }
84
+ },
85
+ { throwOnDeny: false }
86
+ );
87
+ if (decision.decision === "escalate") {
88
+ const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
89
+ const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
90
+ return { approved, reason: approved ? void 0 : "admin refused", decisionId: decision.decisionId };
91
+ }
92
+ if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
93
+ if (decision.decision === "fallback")
94
+ return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
95
+ return { approved: false, reason: decision.reason ?? "denied", decisionId: decision.decisionId };
96
+ }
97
+ async record(action, result, extra = {}) {
98
+ const scope = this.scopeFor(action.operation);
99
+ try {
100
+ await this.sdk.emit(
101
+ {
102
+ agent_id: this.agentId,
103
+ event_type: "api_request",
104
+ action: `aws-iam:${action.operation}${action.targetId ? " " + action.targetId : ""}`,
105
+ resource: action.targetId || this.accountId,
106
+ permission: scope,
107
+ result,
108
+ input_hash: action.inputHash,
109
+ metadata: {
110
+ integration: "aws-iam",
111
+ account_id: this.accountId,
112
+ operation: action.operation,
113
+ privileged: this.isPrivileged(action.operation),
114
+ ...action.policy ? { policy: action.policy } : {},
115
+ ...extra.outcome ? { outcome: extra.outcome } : {},
116
+ ...extra.adminId ?? this.adminId ? { approved_by_admin: extra.adminId ?? this.adminId } : {},
117
+ ...extra.decisionId ? { decision_id: extra.decisionId } : {},
118
+ ...extra.reason ? { reason: extra.reason } : {}
119
+ }
120
+ },
121
+ { sign: true }
122
+ );
123
+ return true;
124
+ } catch {
125
+ return false;
126
+ }
127
+ }
128
+ async guard(action, run) {
129
+ const auth = await this.authorize(action);
130
+ if (!auth.authorized) {
131
+ const recorded = await this.record(action, "denied", { reason: auth.reason, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
132
+ return { receipt: this.receipt(action, false, "denied", auth, recorded) };
133
+ }
134
+ try {
135
+ const value = await run();
136
+ const recorded = await this.record(action, "success", { outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
137
+ return { receipt: this.receipt(action, true, "success", auth, recorded), value };
138
+ } catch (e) {
139
+ const recorded = await this.record(action, "error", { reason: e?.message, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });
140
+ throw Object.assign(e ?? new Error("aws iam operation failed"), {
141
+ vorimReceipt: this.receipt(action, true, "error", { ...auth, reason: e?.message }, recorded)
142
+ });
143
+ }
144
+ }
145
+ // --- Named helpers ---------------------------------------------------------
146
+ /** Guard iam:CreateUser. Requires agent:write. */
147
+ guardedCreateUser(meta, run) {
148
+ return this.guard({ operation: "CreateUser", targetId: meta.targetId, inputHash: meta.inputHash }, run);
149
+ }
150
+ /** Guard iam:CreateRole (creates a role + its trust policy). Always escalates. */
151
+ guardedCreateRole(meta, run) {
152
+ return this.guard({ operation: "CreateRole", targetId: meta.targetId, inputHash: meta.inputHash }, run);
153
+ }
154
+ /** Guard iam:AttachRolePolicy (attach a managed policy). Always escalates.
155
+ * Pass the policy arn (e.g. AdministratorAccess) so it lands in the record. */
156
+ guardedAttachRolePolicy(meta, run) {
157
+ return this.guard({ operation: "AttachRolePolicy", targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);
158
+ }
159
+ /** Guard iam:PutRolePolicy (embed an inline policy). Always escalates. */
160
+ guardedPutRolePolicy(meta, run) {
161
+ return this.guard({ operation: "PutRolePolicy", targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);
162
+ }
163
+ /** Guard iam:CreateAccessKey (mints a long-lived static credential). Always
164
+ * escalates to the named admin — the single highest-stakes IAM op. */
165
+ guardedCreateAccessKey(meta, run) {
166
+ return this.guard({ operation: "CreateAccessKey", targetId: meta.targetId, inputHash: meta.inputHash }, run);
167
+ }
168
+ /** Guard sts:AssumeRole (short-lived credential). Requires agent:write —
169
+ * lighter friction than CreateAccessKey, the safer path to nudge agents to. */
170
+ guardedAssumeRole(meta, run) {
171
+ return this.guard({ operation: "AssumeRole", targetId: meta.targetId, inputHash: meta.inputHash }, run);
172
+ }
173
+ receipt(action, authorized, result, auth, recorded) {
174
+ return {
175
+ authorized,
176
+ agentId: this.agentId,
177
+ accountId: this.accountId,
178
+ operation: action.operation,
179
+ targetId: action.targetId,
180
+ policy: action.policy,
181
+ privileged: this.isPrivileged(action.operation),
182
+ outcome: auth.outcome ?? "ordinary",
183
+ adminId: auth.adminId ?? this.adminId,
184
+ result,
185
+ scope: this.scopeFor(action.operation),
186
+ reason: auth.reason,
187
+ decisionId: auth.decisionId,
188
+ recorded
189
+ };
190
+ }
191
+ };
192
+ function createVorimAwsIam(sdk, config) {
193
+ return new VorimAwsIam(sdk, config);
194
+ }
195
+ export {
196
+ VorimAwsIam,
197
+ createVorimAwsIam
198
+ };
199
+ //# sourceMappingURL=aws-iam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/aws-iam.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — AWS IAM / STS Integration\n//\n// This guards an AI agent that manages AWS identity through IAM and STS —\n// creating users and roles, attaching policies, minting access keys, assuming\n// roles. Before each write runs it verifies the agent's Vorim identity and\n// scoped permission, and for the highest-stakes operations (minting a long-lived\n// access key, escalating privilege via a role/policy change) it escalates to a\n// named human admin and waits. Either way it signs a tamper-evident record.\n//\n// WHY IAM, NOT AGENTCORE\n// This connector guards the stable, universally-available IAM/STS admin surface\n// (free on any AWS account, no Bedrock/region gating). It is NOT Bedrock\n// AgentCore Identity: that is a separate, agent-native product that presupposes\n// a billable, Bedrock-enabled account. IAM is where the real privilege-\n// escalation and long-lived-credential minting happen, so it is the right first\n// target. An AgentCore connector can be a second wave.\n//\n// THE ESCALATION RULE (the wedge)\n// CreateAccessKey mints a long-lived, non-expiring static credential (the secret\n// is shown once, defaults to Active) — the single highest-stakes IAM op, and it\n// always escalates to a named human admin. Broad privilege-escalation ops\n// (CreateRole, AttachRolePolicy, PutRolePolicy) also escalate. Prefer steering\n// agents to AssumeRole (short-lived STS credentials), which passes with lighter\n// friction.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// read IAM -> agent:read\n// create user, assume role (STS) -> agent:write\n// create access key / create role / -> agent:elevate (named-admin approval)\n// attach or put role policy\n//\n// HONEST COMPLIANCE FRAMING\n// A signed, attributable record of each IAM change supports SOC 2 (CC6 logical\n// access, CC7 change monitoring). No regime mandates cryptographic signatures on\n// audit logs; signing satisfies the tamper-evident + attributable intent. Say\n// \"cryptographic proof of which agent made which change\", never \"required for\n// compliance\".\n//\n// This layer never holds AWS credentials and never calls AWS itself. You pass\n// the AWS SDK call as a closure; it authorizes, escalates if needed, runs it,\n// and signs the receipt.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimAwsIam } from '@vorim/sdk/integrations/aws-iam';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const iam = createVorimAwsIam(vorim, {\n// agentId: 'agid_abc123',\n// accountId: '123456789012',\n// adminId: 'admin_42',\n// });\n//\n// const { receipt, value } = await iam.guardedCreateAccessKey(\n// { targetId: 'ci-bot' },\n// () => iamClient.send(new CreateAccessKeyCommand({ UserName: 'ci-bot' })),\n// );\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** The AWS IAM / STS operations this guard classifies (real API call names). */\nexport type AwsIamOperation =\n | 'CreateUser' // iam:CreateUser\n | 'CreateRole' // iam:CreateRole (+ trust/assume-role policy)\n | 'AttachRolePolicy' // iam:AttachRolePolicy (managed policy)\n | 'PutRolePolicy' // iam:PutRolePolicy (inline policy)\n | 'CreateAccessKey' // iam:CreateAccessKey (long-lived static credential)\n | 'AssumeRole' // sts:AssumeRole (short-lived credential)\n | 'read';\n\n/** Operations that mint a long-lived credential or escalate privilege — always\n * escalate to a named human admin. */\nconst ESCALATION_OPS = new Set<string>(['CreateAccessKey', 'CreateRole', 'AttachRolePolicy', 'PutRolePolicy']);\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n read: 'agent:read',\n CreateUser: 'agent:write',\n AssumeRole: 'agent:write',\n CreateRole: 'agent:elevate',\n AttachRolePolicy: 'agent:elevate',\n PutRolePolicy: 'agent:elevate',\n CreateAccessKey: 'agent:elevate',\n};\n\nexport interface AwsIamGuardConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The AWS account id, e.g. '123456789012'. Recorded on every receipt. */\n accountId: string;\n /** The human admin who approves privileged operations. Required if any\n * escalation-class op will be run. */\n adminId?: string;\n minTrustScore?: number;\n /** For a privileged op, escalate to the named admin and wait. Default true. */\n escalatePrivileged?: boolean;\n escalationTimeoutMs?: number;\n onError?: 'closed' | 'open';\n}\n\nexport interface AwsIamAction {\n /** The IAM/STS operation, e.g. 'CreateAccessKey'. Drives scope + escalation. */\n operation: AwsIamOperation | string;\n /** The target the action affects (user name, role name/arn). Recorded. */\n targetId?: string;\n /** For AttachRolePolicy / PutRolePolicy: the policy arn/name being granted,\n * e.g. 'arn:aws:iam::aws:policy/AdministratorAccess'. Recorded. */\n policy?: string;\n inputHash?: string;\n}\n\nexport type AwsIamOutcome = 'ordinary' | 'approved-by-admin' | 'privileged-denied';\n\nexport interface AwsIamReceipt {\n authorized: boolean;\n agentId: string;\n accountId: string;\n operation: string;\n targetId?: string;\n policy?: string;\n privileged: boolean;\n outcome: AwsIamOutcome;\n adminId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\nexport class VorimAwsIam {\n private sdk: VorimSDK;\n private agentId: string;\n private accountId: string;\n private adminId?: string;\n private minTrustScore: number;\n private escalatePrivileged: boolean;\n private escalationTimeoutMs: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: AwsIamGuardConfig) {\n if (!config?.agentId) throw new Error('[vorim] AWS IAM integration requires an agentId.');\n if (!config?.accountId) throw new Error('[vorim] AWS IAM integration requires an accountId.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.accountId = config.accountId;\n this.adminId = config.adminId;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.escalatePrivileged = config.escalatePrivileged ?? true;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 300_000;\n this.onError = config.onError ?? 'closed';\n }\n\n private isPrivileged(operation: string): boolean {\n return ESCALATION_OPS.has(operation);\n }\n\n private scopeFor(operation: string): PermissionScope {\n return OPERATION_SCOPE[operation] ?? 'agent:write';\n }\n\n async authorize(\n action: AwsIamAction,\n ): Promise<{ authorized: boolean; reason?: string; outcome: AwsIamOutcome; adminId?: string; decisionId?: string }> {\n const privileged = this.isPrivileged(action.operation);\n const scope = this.scopeFor(action.operation);\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: privileged ? 'privileged-denied' : 'ordinary' };\n }\n }\n\n if (privileged) {\n if (!this.escalatePrivileged) {\n return { authorized: false, reason: `${action.operation} requires a human admin and escalatePrivileged is off`, outcome: 'privileged-denied' };\n }\n if (!this.adminId) {\n return {\n authorized: false,\n reason: `${action.operation} requires a configured adminId (the approving human admin)`,\n outcome: 'privileged-denied',\n };\n }\n const esc = await this.escalate(action, scope);\n return {\n authorized: esc.approved,\n reason: esc.approved ? undefined : (esc.reason ?? 'admin did not approve'),\n outcome: esc.approved ? 'approved-by-admin' : 'privileged-denied',\n adminId: esc.approved ? this.adminId : undefined,\n decisionId: esc.decisionId,\n };\n }\n\n const perm = await this.sdk.check(this.agentId, scope);\n return perm.allowed\n ? { authorized: true, outcome: 'ordinary', adminId: this.adminId }\n : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: 'ordinary' };\n } catch (e: any) {\n return this.onError === 'open'\n ? { authorized: true, reason: 'vorim unreachable, failed open', outcome: privileged ? 'approved-by-admin' : 'ordinary' }\n : { authorized: false, reason: `vorim unreachable: ${e?.message ?? 'error'}`, outcome: privileged ? 'privileged-denied' : 'ordinary' };\n }\n }\n\n private async escalate(action: AwsIamAction, scope: PermissionScope): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: `aws-iam:${action.operation}`,\n requiredScope: scope,\n payload: { operation: action.operation, target_id: action.targetId, policy: action.policy },\n context: { integration: 'aws-iam', account_id: this.accountId, requires_human_admin: true, admin_hint: this.adminId },\n },\n { throwOnDeny: false },\n );\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return { approved, reason: approved ? undefined : 'admin refused', decisionId: decision.decisionId };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'denied', decisionId: decision.decisionId };\n }\n\n async record(\n action: AwsIamAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; outcome?: AwsIamOutcome; adminId?: string; decisionId?: string } = {},\n ): Promise<boolean> {\n const scope = this.scopeFor(action.operation);\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `aws-iam:${action.operation}${action.targetId ? ' ' + action.targetId : ''}`,\n resource: action.targetId || this.accountId,\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: 'aws-iam',\n account_id: this.accountId,\n operation: action.operation,\n privileged: this.isPrivileged(action.operation),\n ...(action.policy ? { policy: action.policy } : {}),\n ...(extra.outcome ? { outcome: extra.outcome } : {}),\n ...(extra.adminId ?? this.adminId ? { approved_by_admin: extra.adminId ?? this.adminId } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n async guard<T>(action: AwsIamAction, run: () => Promise<T>): Promise<{ receipt: AwsIamReceipt; value?: T }> {\n const auth = await this.authorize(action);\n if (!auth.authorized) {\n const recorded = await this.record(action, 'denied', { reason: auth.reason, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });\n return { receipt: this.receipt(action, false, 'denied', auth, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.record(action, 'success', { outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });\n return { receipt: this.receipt(action, true, 'success', auth, recorded), value };\n } catch (e: any) {\n const recorded = await this.record(action, 'error', { reason: e?.message, outcome: auth.outcome, adminId: auth.adminId, decisionId: auth.decisionId });\n throw Object.assign(e ?? new Error('aws iam operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers ---------------------------------------------------------\n\n /** Guard iam:CreateUser. Requires agent:write. */\n guardedCreateUser<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'CreateUser', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:CreateRole (creates a role + its trust policy). Always escalates. */\n guardedCreateRole<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'CreateRole', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:AttachRolePolicy (attach a managed policy). Always escalates.\n * Pass the policy arn (e.g. AdministratorAccess) so it lands in the record. */\n guardedAttachRolePolicy<T>(meta: { targetId?: string; policy?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'AttachRolePolicy', targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:PutRolePolicy (embed an inline policy). Always escalates. */\n guardedPutRolePolicy<T>(meta: { targetId?: string; policy?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'PutRolePolicy', targetId: meta.targetId, policy: meta.policy, inputHash: meta.inputHash }, run);\n }\n\n /** Guard iam:CreateAccessKey (mints a long-lived static credential). Always\n * escalates to the named admin — the single highest-stakes IAM op. */\n guardedCreateAccessKey<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'CreateAccessKey', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard sts:AssumeRole (short-lived credential). Requires agent:write —\n * lighter friction than CreateAccessKey, the safer path to nudge agents to. */\n guardedAssumeRole<T>(meta: { targetId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'AssumeRole', targetId: meta.targetId, inputHash: meta.inputHash }, run);\n }\n\n private receipt(\n action: AwsIamAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; outcome?: AwsIamOutcome; adminId?: string; decisionId?: string },\n recorded: boolean,\n ): AwsIamReceipt {\n return {\n authorized,\n agentId: this.agentId,\n accountId: this.accountId,\n operation: action.operation,\n targetId: action.targetId,\n policy: action.policy,\n privileged: this.isPrivileged(action.operation),\n outcome: auth.outcome ?? 'ordinary',\n adminId: auth.adminId ?? this.adminId,\n result,\n scope: this.scopeFor(action.operation),\n reason: auth.reason,\n decisionId: auth.decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimAwsIam guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimAwsIam } from '@vorim/sdk/integrations/aws-iam';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const iam = createVorimAwsIam(vorim, {\n * agentId: 'agid_abc123',\n * accountId: '123456789012',\n * adminId: 'admin_42',\n * });\n *\n * // Minting a long-lived access key always escalates to the named admin:\n * const { receipt } = await iam.guardedCreateAccessKey(\n * { targetId: 'ci-bot' },\n * () => iamClient.send(new CreateAccessKeyCommand({ UserName: 'ci-bot' })),\n * );\n * ```\n */\nexport function createVorimAwsIam(sdk: VorimSDK, config: AwsIamGuardConfig): VorimAwsIam {\n return new VorimAwsIam(sdk, config);\n}\n"],"mappings":";AA2EA,IAAM,iBAAiB,oBAAI,IAAY,CAAC,mBAAmB,cAAc,oBAAoB,eAAe,CAAC;AAE7G,IAAM,kBAAmD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,iBAAiB;AACnB;AA+CO,IAAM,cAAN,MAAkB;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,KAAe,QAA2B;AACpD,QAAI,CAAC,QAAQ,QAAS,OAAM,IAAI,MAAM,kDAAkD;AACxF,QAAI,CAAC,QAAQ,UAAW,OAAM,IAAI,MAAM,oDAAoD;AAC5F,SAAK,MAAM;AACX,SAAK,UAAU,OAAO;AACtB,SAAK,YAAY,OAAO;AACxB,SAAK,UAAU,OAAO;AACtB,SAAK,gBAAgB,OAAO,iBAAiB;AAC7C,SAAK,qBAAqB,OAAO,sBAAsB;AACvD,SAAK,sBAAsB,OAAO,uBAAuB;AACzD,SAAK,UAAU,OAAO,WAAW;AAAA,EACnC;AAAA,EAEQ,aAAa,WAA4B;AAC/C,WAAO,eAAe,IAAI,SAAS;AAAA,EACrC;AAAA,EAEQ,SAAS,WAAoC;AACnD,WAAO,gBAAgB,SAAS,KAAK;AAAA,EACvC;AAAA,EAEA,MAAM,UACJ,QACkH;AAClH,UAAM,aAAa,KAAK,aAAa,OAAO,SAAS;AACrD,UAAM,QAAQ,KAAK,SAAS,OAAO,SAAS;AAE5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U,KAAK,UAAU,WAAW,KAAK,UAAU,GAAG,GAAG;AAAA,EACxG;AAAA,EAEQ,QACN,QACA,YACA,QACA,MACA,UACe;AACf,WAAO;AAAA,MACL;AAAA,MACA,SAAS,KAAK;AAAA,MACd,WAAW,KAAK;AAAA,MAChB,WAAW,OAAO;AAAA,MAClB,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,MACf,YAAY,KAAK,aAAa,OAAO,SAAS;AAAA,MAC9C,SAAS,KAAK,WAAW;AAAA,MACzB,SAAS,KAAK,WAAW,KAAK;AAAA,MAC9B;AAAA,MACA,OAAO,KAAK,SAAS,OAAO,SAAS;AAAA,MACrC,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;AAwBO,SAAS,kBAAkB,KAAe,QAAwC;AACvF,SAAO,IAAI,YAAY,KAAK,MAAM;AACpC;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.cjs';
2
- import '../types-zzK9YOoa.cjs';
2
+ import '../types-Lp1iHEDz.cjs';
3
3
 
4
4
  type BankRail = 'ach' | 'wire' | 'rtp' | 'book';
5
5
  type BankProvider = 'increase' | 'column' | 'generic';
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.js';
2
- import '../types-zzK9YOoa.js';
2
+ import '../types-Lp1iHEDz.js';
3
3
 
4
4
  type BankRail = 'ach' | 'wire' | 'rtp' | 'book';
5
5
  type BankProvider = 'increase' | 'column' | 'generic';
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.cjs';
2
- import '../types-zzK9YOoa.cjs';
2
+ import '../types-Lp1iHEDz.cjs';
3
3
 
4
4
  interface CircleConfig {
5
5
  apiKey: string;
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.js';
2
- import '../types-zzK9YOoa.js';
2
+ import '../types-Lp1iHEDz.js';
3
3
 
4
4
  interface CircleConfig {
5
5
  apiKey: string;
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.cjs';
2
- import { P as PermissionScope } from '../types-zzK9YOoa.cjs';
2
+ import { P as PermissionScope } from '../types-Lp1iHEDz.cjs';
3
3
 
4
4
  interface CloudflareGuardConfig {
5
5
  /** The acting agent's Vorim id (agid_...). */
@@ -1,5 +1,5 @@
1
1
  import { VorimSDK } from '../index.js';
2
- import { P as PermissionScope } from '../types-zzK9YOoa.js';
2
+ import { P as PermissionScope } from '../types-Lp1iHEDz.js';
3
3
 
4
4
  interface CloudflareGuardConfig {
5
5
  /** The acting agent's Vorim id (agid_...). */
@@ -0,0 +1,230 @@
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/coinbase-cdp.ts
21
+ var coinbase_cdp_exports = {};
22
+ __export(coinbase_cdp_exports, {
23
+ VorimCoinbaseCdp: () => VorimCoinbaseCdp,
24
+ createVorimCoinbaseCdp: () => createVorimCoinbaseCdp
25
+ });
26
+ module.exports = __toCommonJS(coinbase_cdp_exports);
27
+ var OPERATION_SCOPE = {
28
+ signMessage: "agent:write",
29
+ sendTransaction: "agent:transact",
30
+ transfer: "agent:transact"
31
+ };
32
+ var VorimCoinbaseCdp = class {
33
+ sdk;
34
+ agentId;
35
+ humanId;
36
+ maxTransactionAmount;
37
+ allowedNetworks;
38
+ allowedDestinations;
39
+ escalateOverCeiling;
40
+ approverId;
41
+ escalationTimeoutMs;
42
+ minTrustScore;
43
+ onError;
44
+ constructor(sdk, config) {
45
+ if (!config?.agentId) throw new Error("[vorim] Coinbase CDP integration requires an agentId.");
46
+ this.sdk = sdk;
47
+ this.agentId = config.agentId;
48
+ this.humanId = config.humanId;
49
+ this.maxTransactionAmount = config.maxTransactionAmount;
50
+ this.allowedNetworks = config.allowedNetworks ? new Set(config.allowedNetworks.map((n) => n.toLowerCase())) : void 0;
51
+ this.allowedDestinations = config.allowedDestinations ? new Set(config.allowedDestinations.map((a) => a.toLowerCase())) : void 0;
52
+ this.escalateOverCeiling = config.escalateOverCeiling ?? false;
53
+ this.approverId = config.approverId ?? config.humanId;
54
+ this.escalationTimeoutMs = config.escalationTimeoutMs ?? 6e4;
55
+ this.minTrustScore = config.minTrustScore ?? 0;
56
+ this.onError = config.onError ?? "closed";
57
+ }
58
+ scopeFor(operation) {
59
+ return OPERATION_SCOPE[operation] ?? "agent:transact";
60
+ }
61
+ isValueMoving(operation) {
62
+ return operation === "sendTransaction" || operation === "transfer";
63
+ }
64
+ /**
65
+ * Decide whether the agent may broadcast, before it runs. Order: network
66
+ * allowlist, destination allowlist, trust floor, amount ceiling (deny or
67
+ * escalate), then permission scope. The allowlists are enforced before any
68
+ * Vorim round-trip.
69
+ */
70
+ async authorize(action) {
71
+ const scope = this.scopeFor(action.operation);
72
+ const valueMoving = this.isValueMoving(action.operation);
73
+ if (valueMoving && this.allowedNetworks && action.network && !this.allowedNetworks.has(action.network.toLowerCase())) {
74
+ return { authorized: false, reason: `network ${action.network} is not in this agent's allowed set`, outcome: "network-blocked" };
75
+ }
76
+ if (valueMoving && this.allowedDestinations && action.to && !this.allowedDestinations.has(action.to.toLowerCase())) {
77
+ return { authorized: false, reason: `destination ${action.to} is not in this agent's allowed set`, outcome: "destination-blocked" };
78
+ }
79
+ const overCeiling = valueMoving && this.maxTransactionAmount != null && typeof action.amount === "number" && action.amount > this.maxTransactionAmount;
80
+ try {
81
+ if (this.minTrustScore > 0) {
82
+ const trust = await this.sdk.verify(this.agentId);
83
+ if ((trust?.trust_score ?? 0) < this.minTrustScore) {
84
+ return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: overCeiling ? "over-ceiling" : "within" };
85
+ }
86
+ }
87
+ if (overCeiling) {
88
+ if (!this.escalateOverCeiling) {
89
+ return {
90
+ authorized: false,
91
+ reason: `transaction ${action.amount} exceeds this agent's ceiling of ${this.maxTransactionAmount}`,
92
+ outcome: "over-ceiling"
93
+ };
94
+ }
95
+ const esc = await this.escalate(action, scope);
96
+ return {
97
+ authorized: esc.approved,
98
+ reason: esc.approved ? void 0 : esc.reason ?? "named approver denied",
99
+ outcome: esc.approved ? "escalated-approved" : "escalated-denied",
100
+ approverId: this.approverId,
101
+ decisionId: esc.decisionId
102
+ };
103
+ }
104
+ const perm = await this.sdk.check(this.agentId, scope);
105
+ return perm.allowed ? { authorized: true, outcome: "within" } : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: "within" };
106
+ } catch (e) {
107
+ return this.onError === "open" ? { authorized: true, reason: "vorim unreachable, failed open", outcome: overCeiling ? "over-ceiling" : "within" } : { authorized: false, reason: `vorim unreachable: ${e?.message ?? "error"}`, outcome: overCeiling ? "over-ceiling" : "within" };
108
+ }
109
+ }
110
+ async escalate(action, scope) {
111
+ const decision = await this.sdk.beforeAction(
112
+ {
113
+ agentId: this.agentId,
114
+ actionType: "api_request",
115
+ actionTarget: `coinbase-cdp:${action.operation}`,
116
+ requiredScope: scope,
117
+ payload: { amount: action.amount, asset: action.asset, network: action.network, to: action.to, limit: this.maxTransactionAmount },
118
+ context: { integration: "coinbase-cdp", requires_named_approver: true, approver_hint: this.approverId }
119
+ },
120
+ { throwOnDeny: false }
121
+ );
122
+ if (decision.decision === "escalate") {
123
+ const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });
124
+ const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
125
+ return { approved, reason: approved ? void 0 : "named approver denied", decisionId: decision.decisionId };
126
+ }
127
+ if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
128
+ if (decision.decision === "fallback")
129
+ return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
130
+ return { approved: false, reason: decision.reason ?? "denied", decisionId: decision.decisionId };
131
+ }
132
+ async record(action, result, extra = {}) {
133
+ const scope = this.scopeFor(action.operation);
134
+ try {
135
+ await this.sdk.emit(
136
+ {
137
+ agent_id: this.agentId,
138
+ event_type: "api_request",
139
+ action: `coinbase-cdp:${action.operation}${action.to ? " " + action.to : ""}`,
140
+ resource: action.to || action.network || "coinbase-cdp",
141
+ permission: scope,
142
+ result,
143
+ input_hash: action.inputHash,
144
+ metadata: {
145
+ integration: "coinbase-cdp",
146
+ operation: action.operation,
147
+ acts_for_human: this.humanId,
148
+ ...action.network ? { network: action.network } : {},
149
+ ...action.to ? { to: action.to } : {},
150
+ ...action.amount != null ? { amount: action.amount } : {},
151
+ ...action.asset ? { asset: action.asset } : {},
152
+ ...extra.outcome ? { auth_outcome: extra.outcome } : {},
153
+ ...extra.approverId ? { approver_id: extra.approverId } : {},
154
+ ...extra.decisionId ? { decision_id: extra.decisionId } : {},
155
+ ...extra.reason ? { reason: extra.reason } : {}
156
+ }
157
+ },
158
+ { sign: true }
159
+ );
160
+ return true;
161
+ } catch {
162
+ return false;
163
+ }
164
+ }
165
+ /**
166
+ * The full flow for one CDP op: authorize (allowlists, trust, ceiling, scope),
167
+ * run the CDP SDK call if allowed, sign a receipt either way. If not
168
+ * authorized, `run` is never called. Rethrows a CDP error from `run` after
169
+ * recording it, with the receipt attached as `vorimReceipt`.
170
+ */
171
+ async guard(action, run) {
172
+ const auth = await this.authorize(action);
173
+ if (!auth.authorized) {
174
+ const recorded = await this.record(action, "denied", { reason: auth.reason, outcome: auth.outcome, approverId: auth.approverId, decisionId: auth.decisionId });
175
+ return { receipt: this.receipt(action, false, "denied", auth, recorded) };
176
+ }
177
+ try {
178
+ const value = await run();
179
+ const recorded = await this.record(action, "success", { outcome: auth.outcome, approverId: auth.approverId, decisionId: auth.decisionId });
180
+ return { receipt: this.receipt(action, true, "success", auth, recorded), value };
181
+ } catch (e) {
182
+ const recorded = await this.record(action, "error", { reason: e?.message, outcome: auth.outcome, approverId: auth.approverId, decisionId: auth.decisionId });
183
+ throw Object.assign(e ?? new Error("coinbase cdp operation failed"), {
184
+ vorimReceipt: this.receipt(action, true, "error", { ...auth, reason: e?.message }, recorded)
185
+ });
186
+ }
187
+ }
188
+ // --- Named helpers ---------------------------------------------------------
189
+ /** Guard broadcasting a transaction. Requires agent:transact; enforces the
190
+ * value ceiling, network allowlist, and destination allowlist. */
191
+ guardedSendTransaction(meta, run) {
192
+ return this.guard({ operation: "sendTransaction", ...meta }, run);
193
+ }
194
+ /** Guard a transfer. Requires agent:transact; same attenuation as send. */
195
+ guardedTransfer(meta, run) {
196
+ return this.guard({ operation: "transfer", ...meta }, run);
197
+ }
198
+ /** Guard signing a message (no value moves). Requires agent:write. */
199
+ guardedSignMessage(meta, run) {
200
+ return this.guard({ operation: "signMessage", ...meta }, run);
201
+ }
202
+ receipt(action, authorized, result, auth, recorded) {
203
+ return {
204
+ authorized,
205
+ agentId: this.agentId,
206
+ humanId: this.humanId,
207
+ operation: action.operation,
208
+ network: action.network,
209
+ to: action.to,
210
+ amount: action.amount,
211
+ asset: action.asset,
212
+ authOutcome: auth.outcome,
213
+ approverId: auth.approverId,
214
+ result,
215
+ scope: this.scopeFor(action.operation),
216
+ reason: auth.reason,
217
+ decisionId: auth.decisionId,
218
+ recorded
219
+ };
220
+ }
221
+ };
222
+ function createVorimCoinbaseCdp(sdk, config) {
223
+ return new VorimCoinbaseCdp(sdk, config);
224
+ }
225
+ // Annotate the CommonJS export names for ESM import in node:
226
+ 0 && (module.exports = {
227
+ VorimCoinbaseCdp,
228
+ createVorimCoinbaseCdp
229
+ });
230
+ //# sourceMappingURL=coinbase-cdp.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/coinbase-cdp.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Coinbase CDP Wallet (agentic onchain wallet) Integration\n//\n// This guards an AI agent that holds a Coinbase Developer Platform (CDP) wallet\n// and broadcasts onchain transactions. It is DISTINCT from the shipped x402\n// connector: x402 is the payment protocol; this is the wallet that signs and\n// broadcasts. Before each broadcast this layer verifies the agent's identity and\n// scoped permission, enforces a per-transaction ceiling, a network allowlist,\n// and a destination-address allowlist, escalates above the ceiling to a named\n// approver, then signs a tamper-evident record of the broadcast (intent + result).\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// sign a message -> agent:write\n// send a transaction / transfer -> agent:transact + amount + allowlists\n//\n// This layer never holds the CDP Secret API Key or the Wallet Secret. You pass\n// the CDP SDK call (`cdp.evm.sendTransaction`, `cdp.solana.sendTransaction`, a\n// transfer, a sign-message) as a closure; this layer authorizes, escalates if\n// needed, runs it, and signs the receipt.\n//\n// ONCHAIN ATTENUATION (the wedge)\n// A fiat spend ceiling is a number; an onchain intent is a value + a destination\n// + a network. So attenuation here is three-part: per-transaction value ceiling,\n// destination-address allowlist (an agent can only pay addresses it was granted),\n// and network allowlist. Everything is enforced before the broadcast and signed.\n//\n// COMPLIANCE FRAMING (honest)\n// No regime mandates cryptographic signing of onchain activity (the chain is\n// already immutable). Vorim's value is the ATTRIBUTABLE, POLICY-LEVEL record: it\n// binds a broadcast to a specific agent identity, the human it acts for, the\n// ceiling it was under, and the approval that authorized it, above what the chain\n// itself records. Say \"attributable, policy-signed record of every broadcast\".\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimCoinbaseCdp } from '@vorim/sdk/integrations/coinbase-cdp';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const cdp = createVorimCoinbaseCdp(vorim, {\n// agentId: 'agid_abc123',\n// maxTransactionAmount: 100_000_000, // ceiling in the token's base unit\n// allowedNetworks: ['base', 'base-sepolia'],\n// allowedDestinations: ['0xabc...'], // pay only these addresses\n// escalateOverCeiling: true, approverId: 'treasury_ops',\n// });\n//\n// const { receipt, value } = await cdp.guardedSendTransaction(\n// { network: 'base', to: '0xabc...', amount: 5_000_000 },\n// () => cdpClient.evm.sendTransaction({ address, network, transaction }),\n// );\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\nexport type CdpOperation = 'sendTransaction' | 'transfer' | 'signMessage';\n\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n signMessage: 'agent:write',\n sendTransaction: 'agent:transact',\n transfer: 'agent:transact',\n};\n\nexport interface CoinbaseCdpConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The person/team the agent acts for. Recorded and default escalation target. */\n humanId?: string;\n /** Attenuation: cap a single transaction's value, in the token's base unit\n * (e.g. wei, or USDC's 6-decimal base unit). Omit for no per-transaction\n * ceiling. */\n maxTransactionAmount?: number;\n /** Attenuation: only allow broadcasts on these networks (e.g. 'base',\n * 'base-sepolia', 'solana'). Omit to allow any network. Case-insensitive. */\n allowedNetworks?: string[];\n /** Attenuation: only allow paying these destination addresses. Omit to allow\n * any destination. Compared case-insensitively. */\n allowedDestinations?: string[];\n /** Over the ceiling, escalate to a named approver instead of denying.\n * Default false. */\n escalateOverCeiling?: boolean;\n /** Named approver for an over-ceiling transaction. Defaults to humanId. */\n approverId?: string;\n /** Max wait for an escalation, ms. Default 60000. */\n escalationTimeoutMs?: number;\n /** Minimum trust score before any op. Default 0. */\n minTrustScore?: number;\n /** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface CdpAction {\n /** The CDP operation, e.g. 'sendTransaction'. Drives the scope. */\n operation: CdpOperation | string;\n /** The network the broadcast targets, e.g. 'base'. Checked against\n * allowedNetworks. */\n network?: string;\n /** The destination address (for a transfer / send). Checked against\n * allowedDestinations. */\n to?: string;\n /** The transaction value, in the token's base unit. Checked against the\n * ceiling. */\n amount?: number;\n /** The asset symbol, e.g. 'USDC' or 'ETH'. Recorded. */\n asset?: string;\n /** Optional hash of the transaction body. */\n inputHash?: string;\n}\n\nexport type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-denied' | 'over-ceiling' | 'network-blocked' | 'destination-blocked';\n\nexport interface CoinbaseCdpReceipt {\n authorized: boolean;\n agentId: string;\n humanId?: string;\n operation: string;\n network?: string;\n to?: string;\n amount?: number;\n asset?: string;\n authOutcome?: AuthOutcome;\n approverId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\nexport class VorimCoinbaseCdp {\n private sdk: VorimSDK;\n private agentId: string;\n private humanId?: string;\n private maxTransactionAmount?: number;\n private allowedNetworks?: Set<string>;\n private allowedDestinations?: Set<string>;\n private escalateOverCeiling: boolean;\n private approverId?: string;\n private escalationTimeoutMs: number;\n private minTrustScore: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: CoinbaseCdpConfig) {\n if (!config?.agentId) throw new Error('[vorim] Coinbase CDP integration requires an agentId.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.humanId = config.humanId;\n this.maxTransactionAmount = config.maxTransactionAmount;\n this.allowedNetworks = config.allowedNetworks ? new Set(config.allowedNetworks.map((n) => n.toLowerCase())) : undefined;\n this.allowedDestinations = config.allowedDestinations ? new Set(config.allowedDestinations.map((a) => a.toLowerCase())) : undefined;\n this.escalateOverCeiling = config.escalateOverCeiling ?? false;\n this.approverId = config.approverId ?? config.humanId;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 60_000;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.onError = config.onError ?? 'closed';\n }\n\n private scopeFor(operation: string): PermissionScope {\n return OPERATION_SCOPE[operation] ?? 'agent:transact';\n }\n\n private isValueMoving(operation: string): boolean {\n return operation === 'sendTransaction' || operation === 'transfer';\n }\n\n /**\n * Decide whether the agent may broadcast, before it runs. Order: network\n * allowlist, destination allowlist, trust floor, amount ceiling (deny or\n * escalate), then permission scope. The allowlists are enforced before any\n * Vorim round-trip.\n */\n async authorize(\n action: CdpAction,\n ): Promise<{ authorized: boolean; reason?: string; outcome: AuthOutcome; approverId?: string; decisionId?: string }> {\n const scope = this.scopeFor(action.operation);\n const valueMoving = this.isValueMoving(action.operation);\n\n // Network allowlist (value-moving ops).\n if (valueMoving && this.allowedNetworks && action.network && !this.allowedNetworks.has(action.network.toLowerCase())) {\n return { authorized: false, reason: `network ${action.network} is not in this agent's allowed set`, outcome: 'network-blocked' };\n }\n // Destination allowlist.\n if (valueMoving && this.allowedDestinations && action.to && !this.allowedDestinations.has(action.to.toLowerCase())) {\n return { authorized: false, reason: `destination ${action.to} is not in this agent's allowed set`, outcome: 'destination-blocked' };\n }\n\n const overCeiling =\n valueMoving && this.maxTransactionAmount != null && typeof action.amount === 'number' && action.amount > this.maxTransactionAmount;\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n return { authorized: false, reason: `trust score below ${this.minTrustScore}`, outcome: overCeiling ? 'over-ceiling' : 'within' };\n }\n }\n\n if (overCeiling) {\n if (!this.escalateOverCeiling) {\n return {\n authorized: false,\n reason: `transaction ${action.amount} exceeds this agent's ceiling of ${this.maxTransactionAmount}`,\n outcome: 'over-ceiling',\n };\n }\n const esc = await this.escalate(action, scope);\n return {\n authorized: esc.approved,\n reason: esc.approved ? undefined : (esc.reason ?? 'named approver denied'),\n outcome: esc.approved ? 'escalated-approved' : 'escalated-denied',\n approverId: this.approverId,\n decisionId: esc.decisionId,\n };\n }\n\n const perm = await this.sdk.check(this.agentId, scope);\n return perm.allowed\n ? { authorized: true, outcome: 'within' }\n : { authorized: false, reason: perm.reason ?? `missing scope ${scope}`, outcome: 'within' };\n } catch (e: any) {\n return this.onError === 'open'\n ? { authorized: true, reason: 'vorim unreachable, failed open', outcome: overCeiling ? 'over-ceiling' : 'within' }\n : { authorized: false, reason: `vorim unreachable: ${e?.message ?? 'error'}`, outcome: overCeiling ? 'over-ceiling' : 'within' };\n }\n }\n\n private async escalate(action: CdpAction, scope: PermissionScope): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: `coinbase-cdp:${action.operation}`,\n requiredScope: scope,\n payload: { amount: action.amount, asset: action.asset, network: action.network, to: action.to, limit: this.maxTransactionAmount },\n context: { integration: 'coinbase-cdp', requires_named_approver: true, approver_hint: this.approverId },\n },\n { throwOnDeny: false },\n );\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, { timeoutMs: this.escalationTimeoutMs });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return { approved, reason: approved ? undefined : 'named approver denied', decisionId: decision.decisionId };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'denied', decisionId: decision.decisionId };\n }\n\n async record(\n action: CdpAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; outcome?: AuthOutcome; approverId?: string; decisionId?: string } = {},\n ): Promise<boolean> {\n const scope = this.scopeFor(action.operation);\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `coinbase-cdp:${action.operation}${action.to ? ' ' + action.to : ''}`,\n resource: action.to || action.network || 'coinbase-cdp',\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: 'coinbase-cdp',\n operation: action.operation,\n acts_for_human: this.humanId,\n ...(action.network ? { network: action.network } : {}),\n ...(action.to ? { to: action.to } : {}),\n ...(action.amount != null ? { amount: action.amount } : {}),\n ...(action.asset ? { asset: action.asset } : {}),\n ...(extra.outcome ? { auth_outcome: extra.outcome } : {}),\n ...(extra.approverId ? { approver_id: extra.approverId } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true },\n );\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * The full flow for one CDP op: authorize (allowlists, trust, ceiling, scope),\n * run the CDP SDK call if allowed, sign a receipt either way. If not\n * authorized, `run` is never called. Rethrows a CDP error from `run` after\n * recording it, with the receipt attached as `vorimReceipt`.\n */\n async guard<T>(action: CdpAction, run: () => Promise<T>): Promise<{ receipt: CoinbaseCdpReceipt; value?: T }> {\n const auth = await this.authorize(action);\n if (!auth.authorized) {\n const recorded = await this.record(action, 'denied', { reason: auth.reason, outcome: auth.outcome, approverId: auth.approverId, decisionId: auth.decisionId });\n return { receipt: this.receipt(action, false, 'denied', auth, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.record(action, 'success', { outcome: auth.outcome, approverId: auth.approverId, decisionId: auth.decisionId });\n return { receipt: this.receipt(action, true, 'success', auth, recorded), value };\n } catch (e: any) {\n const recorded = await this.record(action, 'error', { reason: e?.message, outcome: auth.outcome, approverId: auth.approverId, decisionId: auth.decisionId });\n throw Object.assign(e ?? new Error('coinbase cdp operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers ---------------------------------------------------------\n\n /** Guard broadcasting a transaction. Requires agent:transact; enforces the\n * value ceiling, network allowlist, and destination allowlist. */\n guardedSendTransaction<T>(meta: { network?: string; to?: string; amount?: number; asset?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'sendTransaction', ...meta }, run);\n }\n\n /** Guard a transfer. Requires agent:transact; same attenuation as send. */\n guardedTransfer<T>(meta: { network?: string; to?: string; amount?: number; asset?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'transfer', ...meta }, run);\n }\n\n /** Guard signing a message (no value moves). Requires agent:write. */\n guardedSignMessage<T>(meta: { network?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'signMessage', ...meta }, run);\n }\n\n private receipt(\n action: CdpAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; outcome?: AuthOutcome; approverId?: string; decisionId?: string },\n recorded: boolean,\n ): CoinbaseCdpReceipt {\n return {\n authorized,\n agentId: this.agentId,\n humanId: this.humanId,\n operation: action.operation,\n network: action.network,\n to: action.to,\n amount: action.amount,\n asset: action.asset,\n authOutcome: auth.outcome,\n approverId: auth.approverId,\n result,\n scope: this.scopeFor(action.operation),\n reason: auth.reason,\n decisionId: auth.decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimCoinbaseCdp guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimCoinbaseCdp } from '@vorim/sdk/integrations/coinbase-cdp';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const cdp = createVorimCoinbaseCdp(vorim, {\n * agentId: 'agid_abc123',\n * maxTransactionAmount: 100_000_000,\n * allowedNetworks: ['base'],\n * allowedDestinations: ['0xabc...'],\n * });\n *\n * const { receipt, value } = await cdp.guardedSendTransaction(\n * { network: 'base', to: '0xabc...', amount: 5_000_000, asset: 'USDC' },\n * () => cdpClient.evm.sendTransaction({ address, network, transaction }),\n * );\n * ```\n */\nexport function createVorimCoinbaseCdp(sdk: VorimSDK, config: CoinbaseCdpConfig): VorimCoinbaseCdp {\n return new VorimCoinbaseCdp(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDA,IAAM,kBAAmD;AAAA,EACvD,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,UAAU;AACZ;AAoEO,IAAM,mBAAN,MAAuB;AA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