@vorim/sdk 3.11.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/cloudflare.cjs +134 -0
- package/dist/integrations/cloudflare.cjs.map +1 -0
- package/dist/integrations/cloudflare.d.cts +93 -0
- package/dist/integrations/cloudflare.d.ts +93 -0
- package/dist/integrations/cloudflare.js +108 -0
- package/dist/integrations/cloudflare.js.map +1 -0
- package/dist/integrations/coinbase-cdp.cjs +230 -0
- package/dist/integrations/coinbase-cdp.cjs.map +1 -0
- package/dist/integrations/coinbase-cdp.d.cts +169 -0
- package/dist/integrations/coinbase-cdp.d.ts +169 -0
- package/dist/integrations/coinbase-cdp.js +204 -0
- package/dist/integrations/coinbase-cdp.js.map +1 -0
- package/dist/integrations/fhir.cjs +304 -0
- package/dist/integrations/fhir.cjs.map +1 -0
- package/dist/integrations/fhir.d.cts +185 -0
- package/dist/integrations/fhir.d.ts +185 -0
- package/dist/integrations/fhir.js +278 -0
- package/dist/integrations/fhir.js.map +1 -0
- package/dist/integrations/guidewire.cjs +363 -0
- package/dist/integrations/guidewire.cjs.map +1 -0
- package/dist/integrations/guidewire.d.cts +258 -0
- package/dist/integrations/guidewire.d.ts +258 -0
- package/dist/integrations/guidewire.js +337 -0
- package/dist/integrations/guidewire.js.map +1 -0
- package/dist/integrations/legal.cjs +339 -0
- package/dist/integrations/legal.cjs.map +1 -0
- package/dist/integrations/legal.d.cts +225 -0
- package/dist/integrations/legal.d.ts +225 -0
- package/dist/integrations/legal.js +313 -0
- package/dist/integrations/legal.js.map +1 -0
- package/dist/integrations/life-sciences.cjs +335 -0
- package/dist/integrations/life-sciences.cjs.map +1 -0
- package/dist/integrations/life-sciences.d.cts +214 -0
- package/dist/integrations/life-sciences.d.ts +214 -0
- package/dist/integrations/life-sciences.js +309 -0
- package/dist/integrations/life-sciences.js.map +1 -0
- package/dist/integrations/lithic.cjs +290 -0
- package/dist/integrations/lithic.cjs.map +1 -0
- package/dist/integrations/lithic.d.cts +130 -0
- package/dist/integrations/lithic.d.ts +130 -0
- package/dist/integrations/lithic.js +264 -0
- package/dist/integrations/lithic.js.map +1 -0
- package/dist/integrations/marqeta.cjs +285 -0
- package/dist/integrations/marqeta.cjs.map +1 -0
- package/dist/integrations/marqeta.d.cts +121 -0
- package/dist/integrations/marqeta.d.ts +121 -0
- package/dist/integrations/marqeta.js +259 -0
- package/dist/integrations/marqeta.js.map +1 -0
- package/dist/integrations/ramp.cjs +206 -0
- package/dist/integrations/ramp.cjs.map +1 -0
- package/dist/integrations/ramp.d.cts +139 -0
- package/dist/integrations/ramp.d.ts +139 -0
- package/dist/integrations/ramp.js +180 -0
- package/dist/integrations/ramp.js.map +1 -0
- package/dist/integrations/shopify.cjs +203 -0
- package/dist/integrations/shopify.cjs.map +1 -0
- package/dist/integrations/shopify.d.cts +175 -0
- package/dist/integrations/shopify.d.ts +175 -0
- package/dist/integrations/shopify.js +177 -0
- package/dist/integrations/shopify.js.map +1 -0
- package/dist/integrations/stripe-issuing.cjs +316 -0
- package/dist/integrations/stripe-issuing.cjs.map +1 -0
- package/dist/integrations/stripe-issuing.d.cts +154 -0
- package/dist/integrations/stripe-issuing.d.ts +154 -0
- package/dist/integrations/stripe-issuing.js +290 -0
- package/dist/integrations/stripe-issuing.js.map +1 -0
- package/dist/integrations/web-bot-auth.cjs +143 -0
- package/dist/integrations/web-bot-auth.cjs.map +1 -0
- package/dist/integrations/web-bot-auth.d.cts +51 -0
- package/dist/integrations/web-bot-auth.d.ts +51 -0
- package/dist/integrations/web-bot-auth.js +108 -0
- package/dist/integrations/web-bot-auth.js.map +1 -0
- package/package.json +121 -1
|
@@ -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;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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AClB,YAAY,KAAK;AAAA,MACjB;AAAA,MACA,OAAO,KAAK,SAAS,OAAO,SAAS;AAAA,MACrC,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;AAwBO,SAAS,uBAAuB,KAAe,QAA6C;AACjG,SAAO,IAAI,iBAAiB,KAAK,MAAM;AACzC;","names":[]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.cjs';
|
|
2
|
+
import { P as PermissionScope } from '../types-zzK9YOoa.cjs';
|
|
3
|
+
|
|
4
|
+
type CdpOperation = 'sendTransaction' | 'transfer' | 'signMessage';
|
|
5
|
+
interface CoinbaseCdpConfig {
|
|
6
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
7
|
+
agentId: string;
|
|
8
|
+
/** The person/team the agent acts for. Recorded and default escalation target. */
|
|
9
|
+
humanId?: string;
|
|
10
|
+
/** Attenuation: cap a single transaction's value, in the token's base unit
|
|
11
|
+
* (e.g. wei, or USDC's 6-decimal base unit). Omit for no per-transaction
|
|
12
|
+
* ceiling. */
|
|
13
|
+
maxTransactionAmount?: number;
|
|
14
|
+
/** Attenuation: only allow broadcasts on these networks (e.g. 'base',
|
|
15
|
+
* 'base-sepolia', 'solana'). Omit to allow any network. Case-insensitive. */
|
|
16
|
+
allowedNetworks?: string[];
|
|
17
|
+
/** Attenuation: only allow paying these destination addresses. Omit to allow
|
|
18
|
+
* any destination. Compared case-insensitively. */
|
|
19
|
+
allowedDestinations?: string[];
|
|
20
|
+
/** Over the ceiling, escalate to a named approver instead of denying.
|
|
21
|
+
* Default false. */
|
|
22
|
+
escalateOverCeiling?: boolean;
|
|
23
|
+
/** Named approver for an over-ceiling transaction. Defaults to humanId. */
|
|
24
|
+
approverId?: string;
|
|
25
|
+
/** Max wait for an escalation, ms. Default 60000. */
|
|
26
|
+
escalationTimeoutMs?: number;
|
|
27
|
+
/** Minimum trust score before any op. Default 0. */
|
|
28
|
+
minTrustScore?: number;
|
|
29
|
+
/** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */
|
|
30
|
+
onError?: 'closed' | 'open';
|
|
31
|
+
}
|
|
32
|
+
interface CdpAction {
|
|
33
|
+
/** The CDP operation, e.g. 'sendTransaction'. Drives the scope. */
|
|
34
|
+
operation: CdpOperation | string;
|
|
35
|
+
/** The network the broadcast targets, e.g. 'base'. Checked against
|
|
36
|
+
* allowedNetworks. */
|
|
37
|
+
network?: string;
|
|
38
|
+
/** The destination address (for a transfer / send). Checked against
|
|
39
|
+
* allowedDestinations. */
|
|
40
|
+
to?: string;
|
|
41
|
+
/** The transaction value, in the token's base unit. Checked against the
|
|
42
|
+
* ceiling. */
|
|
43
|
+
amount?: number;
|
|
44
|
+
/** The asset symbol, e.g. 'USDC' or 'ETH'. Recorded. */
|
|
45
|
+
asset?: string;
|
|
46
|
+
/** Optional hash of the transaction body. */
|
|
47
|
+
inputHash?: string;
|
|
48
|
+
}
|
|
49
|
+
type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-denied' | 'over-ceiling' | 'network-blocked' | 'destination-blocked';
|
|
50
|
+
interface CoinbaseCdpReceipt {
|
|
51
|
+
authorized: boolean;
|
|
52
|
+
agentId: string;
|
|
53
|
+
humanId?: string;
|
|
54
|
+
operation: string;
|
|
55
|
+
network?: string;
|
|
56
|
+
to?: string;
|
|
57
|
+
amount?: number;
|
|
58
|
+
asset?: string;
|
|
59
|
+
authOutcome?: AuthOutcome;
|
|
60
|
+
approverId?: string;
|
|
61
|
+
result: 'success' | 'denied' | 'error';
|
|
62
|
+
scope: PermissionScope;
|
|
63
|
+
reason?: string;
|
|
64
|
+
decisionId?: string;
|
|
65
|
+
recorded: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare class VorimCoinbaseCdp {
|
|
68
|
+
private sdk;
|
|
69
|
+
private agentId;
|
|
70
|
+
private humanId?;
|
|
71
|
+
private maxTransactionAmount?;
|
|
72
|
+
private allowedNetworks?;
|
|
73
|
+
private allowedDestinations?;
|
|
74
|
+
private escalateOverCeiling;
|
|
75
|
+
private approverId?;
|
|
76
|
+
private escalationTimeoutMs;
|
|
77
|
+
private minTrustScore;
|
|
78
|
+
private onError;
|
|
79
|
+
constructor(sdk: VorimSDK, config: CoinbaseCdpConfig);
|
|
80
|
+
private scopeFor;
|
|
81
|
+
private isValueMoving;
|
|
82
|
+
/**
|
|
83
|
+
* Decide whether the agent may broadcast, before it runs. Order: network
|
|
84
|
+
* allowlist, destination allowlist, trust floor, amount ceiling (deny or
|
|
85
|
+
* escalate), then permission scope. The allowlists are enforced before any
|
|
86
|
+
* Vorim round-trip.
|
|
87
|
+
*/
|
|
88
|
+
authorize(action: CdpAction): Promise<{
|
|
89
|
+
authorized: boolean;
|
|
90
|
+
reason?: string;
|
|
91
|
+
outcome: AuthOutcome;
|
|
92
|
+
approverId?: string;
|
|
93
|
+
decisionId?: string;
|
|
94
|
+
}>;
|
|
95
|
+
private escalate;
|
|
96
|
+
record(action: CdpAction, result: 'success' | 'denied' | 'error', extra?: {
|
|
97
|
+
reason?: string;
|
|
98
|
+
outcome?: AuthOutcome;
|
|
99
|
+
approverId?: string;
|
|
100
|
+
decisionId?: string;
|
|
101
|
+
}): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* The full flow for one CDP op: authorize (allowlists, trust, ceiling, scope),
|
|
104
|
+
* run the CDP SDK call if allowed, sign a receipt either way. If not
|
|
105
|
+
* authorized, `run` is never called. Rethrows a CDP error from `run` after
|
|
106
|
+
* recording it, with the receipt attached as `vorimReceipt`.
|
|
107
|
+
*/
|
|
108
|
+
guard<T>(action: CdpAction, run: () => Promise<T>): Promise<{
|
|
109
|
+
receipt: CoinbaseCdpReceipt;
|
|
110
|
+
value?: T;
|
|
111
|
+
}>;
|
|
112
|
+
/** Guard broadcasting a transaction. Requires agent:transact; enforces the
|
|
113
|
+
* value ceiling, network allowlist, and destination allowlist. */
|
|
114
|
+
guardedSendTransaction<T>(meta: {
|
|
115
|
+
network?: string;
|
|
116
|
+
to?: string;
|
|
117
|
+
amount?: number;
|
|
118
|
+
asset?: string;
|
|
119
|
+
inputHash?: string;
|
|
120
|
+
}, run: () => Promise<T>): Promise<{
|
|
121
|
+
receipt: CoinbaseCdpReceipt;
|
|
122
|
+
value?: T | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
/** Guard a transfer. Requires agent:transact; same attenuation as send. */
|
|
125
|
+
guardedTransfer<T>(meta: {
|
|
126
|
+
network?: string;
|
|
127
|
+
to?: string;
|
|
128
|
+
amount?: number;
|
|
129
|
+
asset?: string;
|
|
130
|
+
inputHash?: string;
|
|
131
|
+
}, run: () => Promise<T>): Promise<{
|
|
132
|
+
receipt: CoinbaseCdpReceipt;
|
|
133
|
+
value?: T | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
/** Guard signing a message (no value moves). Requires agent:write. */
|
|
136
|
+
guardedSignMessage<T>(meta: {
|
|
137
|
+
network?: string;
|
|
138
|
+
inputHash?: string;
|
|
139
|
+
}, run: () => Promise<T>): Promise<{
|
|
140
|
+
receipt: CoinbaseCdpReceipt;
|
|
141
|
+
value?: T | undefined;
|
|
142
|
+
}>;
|
|
143
|
+
private receipt;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create a VorimCoinbaseCdp guard around a Vorim SDK instance.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* import createVorim from '@vorim/sdk';
|
|
151
|
+
* import { createVorimCoinbaseCdp } from '@vorim/sdk/integrations/coinbase-cdp';
|
|
152
|
+
*
|
|
153
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
154
|
+
* const cdp = createVorimCoinbaseCdp(vorim, {
|
|
155
|
+
* agentId: 'agid_abc123',
|
|
156
|
+
* maxTransactionAmount: 100_000_000,
|
|
157
|
+
* allowedNetworks: ['base'],
|
|
158
|
+
* allowedDestinations: ['0xabc...'],
|
|
159
|
+
* });
|
|
160
|
+
*
|
|
161
|
+
* const { receipt, value } = await cdp.guardedSendTransaction(
|
|
162
|
+
* { network: 'base', to: '0xabc...', amount: 5_000_000, asset: 'USDC' },
|
|
163
|
+
* () => cdpClient.evm.sendTransaction({ address, network, transaction }),
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function createVorimCoinbaseCdp(sdk: VorimSDK, config: CoinbaseCdpConfig): VorimCoinbaseCdp;
|
|
168
|
+
|
|
169
|
+
export { type AuthOutcome, type CdpAction, type CdpOperation, type CoinbaseCdpConfig, type CoinbaseCdpReceipt, VorimCoinbaseCdp, createVorimCoinbaseCdp };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { VorimSDK } from '../index.js';
|
|
2
|
+
import { P as PermissionScope } from '../types-zzK9YOoa.js';
|
|
3
|
+
|
|
4
|
+
type CdpOperation = 'sendTransaction' | 'transfer' | 'signMessage';
|
|
5
|
+
interface CoinbaseCdpConfig {
|
|
6
|
+
/** The acting agent's Vorim id (agid_...). */
|
|
7
|
+
agentId: string;
|
|
8
|
+
/** The person/team the agent acts for. Recorded and default escalation target. */
|
|
9
|
+
humanId?: string;
|
|
10
|
+
/** Attenuation: cap a single transaction's value, in the token's base unit
|
|
11
|
+
* (e.g. wei, or USDC's 6-decimal base unit). Omit for no per-transaction
|
|
12
|
+
* ceiling. */
|
|
13
|
+
maxTransactionAmount?: number;
|
|
14
|
+
/** Attenuation: only allow broadcasts on these networks (e.g. 'base',
|
|
15
|
+
* 'base-sepolia', 'solana'). Omit to allow any network. Case-insensitive. */
|
|
16
|
+
allowedNetworks?: string[];
|
|
17
|
+
/** Attenuation: only allow paying these destination addresses. Omit to allow
|
|
18
|
+
* any destination. Compared case-insensitively. */
|
|
19
|
+
allowedDestinations?: string[];
|
|
20
|
+
/** Over the ceiling, escalate to a named approver instead of denying.
|
|
21
|
+
* Default false. */
|
|
22
|
+
escalateOverCeiling?: boolean;
|
|
23
|
+
/** Named approver for an over-ceiling transaction. Defaults to humanId. */
|
|
24
|
+
approverId?: string;
|
|
25
|
+
/** Max wait for an escalation, ms. Default 60000. */
|
|
26
|
+
escalationTimeoutMs?: number;
|
|
27
|
+
/** Minimum trust score before any op. Default 0. */
|
|
28
|
+
minTrustScore?: number;
|
|
29
|
+
/** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */
|
|
30
|
+
onError?: 'closed' | 'open';
|
|
31
|
+
}
|
|
32
|
+
interface CdpAction {
|
|
33
|
+
/** The CDP operation, e.g. 'sendTransaction'. Drives the scope. */
|
|
34
|
+
operation: CdpOperation | string;
|
|
35
|
+
/** The network the broadcast targets, e.g. 'base'. Checked against
|
|
36
|
+
* allowedNetworks. */
|
|
37
|
+
network?: string;
|
|
38
|
+
/** The destination address (for a transfer / send). Checked against
|
|
39
|
+
* allowedDestinations. */
|
|
40
|
+
to?: string;
|
|
41
|
+
/** The transaction value, in the token's base unit. Checked against the
|
|
42
|
+
* ceiling. */
|
|
43
|
+
amount?: number;
|
|
44
|
+
/** The asset symbol, e.g. 'USDC' or 'ETH'. Recorded. */
|
|
45
|
+
asset?: string;
|
|
46
|
+
/** Optional hash of the transaction body. */
|
|
47
|
+
inputHash?: string;
|
|
48
|
+
}
|
|
49
|
+
type AuthOutcome = 'within' | 'escalated-approved' | 'escalated-denied' | 'over-ceiling' | 'network-blocked' | 'destination-blocked';
|
|
50
|
+
interface CoinbaseCdpReceipt {
|
|
51
|
+
authorized: boolean;
|
|
52
|
+
agentId: string;
|
|
53
|
+
humanId?: string;
|
|
54
|
+
operation: string;
|
|
55
|
+
network?: string;
|
|
56
|
+
to?: string;
|
|
57
|
+
amount?: number;
|
|
58
|
+
asset?: string;
|
|
59
|
+
authOutcome?: AuthOutcome;
|
|
60
|
+
approverId?: string;
|
|
61
|
+
result: 'success' | 'denied' | 'error';
|
|
62
|
+
scope: PermissionScope;
|
|
63
|
+
reason?: string;
|
|
64
|
+
decisionId?: string;
|
|
65
|
+
recorded: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare class VorimCoinbaseCdp {
|
|
68
|
+
private sdk;
|
|
69
|
+
private agentId;
|
|
70
|
+
private humanId?;
|
|
71
|
+
private maxTransactionAmount?;
|
|
72
|
+
private allowedNetworks?;
|
|
73
|
+
private allowedDestinations?;
|
|
74
|
+
private escalateOverCeiling;
|
|
75
|
+
private approverId?;
|
|
76
|
+
private escalationTimeoutMs;
|
|
77
|
+
private minTrustScore;
|
|
78
|
+
private onError;
|
|
79
|
+
constructor(sdk: VorimSDK, config: CoinbaseCdpConfig);
|
|
80
|
+
private scopeFor;
|
|
81
|
+
private isValueMoving;
|
|
82
|
+
/**
|
|
83
|
+
* Decide whether the agent may broadcast, before it runs. Order: network
|
|
84
|
+
* allowlist, destination allowlist, trust floor, amount ceiling (deny or
|
|
85
|
+
* escalate), then permission scope. The allowlists are enforced before any
|
|
86
|
+
* Vorim round-trip.
|
|
87
|
+
*/
|
|
88
|
+
authorize(action: CdpAction): Promise<{
|
|
89
|
+
authorized: boolean;
|
|
90
|
+
reason?: string;
|
|
91
|
+
outcome: AuthOutcome;
|
|
92
|
+
approverId?: string;
|
|
93
|
+
decisionId?: string;
|
|
94
|
+
}>;
|
|
95
|
+
private escalate;
|
|
96
|
+
record(action: CdpAction, result: 'success' | 'denied' | 'error', extra?: {
|
|
97
|
+
reason?: string;
|
|
98
|
+
outcome?: AuthOutcome;
|
|
99
|
+
approverId?: string;
|
|
100
|
+
decisionId?: string;
|
|
101
|
+
}): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* The full flow for one CDP op: authorize (allowlists, trust, ceiling, scope),
|
|
104
|
+
* run the CDP SDK call if allowed, sign a receipt either way. If not
|
|
105
|
+
* authorized, `run` is never called. Rethrows a CDP error from `run` after
|
|
106
|
+
* recording it, with the receipt attached as `vorimReceipt`.
|
|
107
|
+
*/
|
|
108
|
+
guard<T>(action: CdpAction, run: () => Promise<T>): Promise<{
|
|
109
|
+
receipt: CoinbaseCdpReceipt;
|
|
110
|
+
value?: T;
|
|
111
|
+
}>;
|
|
112
|
+
/** Guard broadcasting a transaction. Requires agent:transact; enforces the
|
|
113
|
+
* value ceiling, network allowlist, and destination allowlist. */
|
|
114
|
+
guardedSendTransaction<T>(meta: {
|
|
115
|
+
network?: string;
|
|
116
|
+
to?: string;
|
|
117
|
+
amount?: number;
|
|
118
|
+
asset?: string;
|
|
119
|
+
inputHash?: string;
|
|
120
|
+
}, run: () => Promise<T>): Promise<{
|
|
121
|
+
receipt: CoinbaseCdpReceipt;
|
|
122
|
+
value?: T | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
/** Guard a transfer. Requires agent:transact; same attenuation as send. */
|
|
125
|
+
guardedTransfer<T>(meta: {
|
|
126
|
+
network?: string;
|
|
127
|
+
to?: string;
|
|
128
|
+
amount?: number;
|
|
129
|
+
asset?: string;
|
|
130
|
+
inputHash?: string;
|
|
131
|
+
}, run: () => Promise<T>): Promise<{
|
|
132
|
+
receipt: CoinbaseCdpReceipt;
|
|
133
|
+
value?: T | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
/** Guard signing a message (no value moves). Requires agent:write. */
|
|
136
|
+
guardedSignMessage<T>(meta: {
|
|
137
|
+
network?: string;
|
|
138
|
+
inputHash?: string;
|
|
139
|
+
}, run: () => Promise<T>): Promise<{
|
|
140
|
+
receipt: CoinbaseCdpReceipt;
|
|
141
|
+
value?: T | undefined;
|
|
142
|
+
}>;
|
|
143
|
+
private receipt;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create a VorimCoinbaseCdp guard around a Vorim SDK instance.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* import createVorim from '@vorim/sdk';
|
|
151
|
+
* import { createVorimCoinbaseCdp } from '@vorim/sdk/integrations/coinbase-cdp';
|
|
152
|
+
*
|
|
153
|
+
* const vorim = createVorim({ apiKey: 'agid_sk_...' });
|
|
154
|
+
* const cdp = createVorimCoinbaseCdp(vorim, {
|
|
155
|
+
* agentId: 'agid_abc123',
|
|
156
|
+
* maxTransactionAmount: 100_000_000,
|
|
157
|
+
* allowedNetworks: ['base'],
|
|
158
|
+
* allowedDestinations: ['0xabc...'],
|
|
159
|
+
* });
|
|
160
|
+
*
|
|
161
|
+
* const { receipt, value } = await cdp.guardedSendTransaction(
|
|
162
|
+
* { network: 'base', to: '0xabc...', amount: 5_000_000, asset: 'USDC' },
|
|
163
|
+
* () => cdpClient.evm.sendTransaction({ address, network, transaction }),
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function createVorimCoinbaseCdp(sdk: VorimSDK, config: CoinbaseCdpConfig): VorimCoinbaseCdp;
|
|
168
|
+
|
|
169
|
+
export { type AuthOutcome, type CdpAction, type CdpOperation, type CoinbaseCdpConfig, type CoinbaseCdpReceipt, VorimCoinbaseCdp, createVorimCoinbaseCdp };
|