@haven_ai/sdk 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -10
- package/dist/index.cjs +215 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +210 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.cts +0 -850
- package/dist/index.d.ts +0 -850
package/dist/index.js
CHANGED
|
@@ -52,8 +52,16 @@ var AgentPaymentRail = {
|
|
|
52
52
|
Direct: "direct",
|
|
53
53
|
/** x402 HTTP 402 payment flow with a Haven funding leg and merchant retry leg. */
|
|
54
54
|
X402: "x402",
|
|
55
|
-
/** Machine Payment Protocol
|
|
56
|
-
Mpp: "mpp"
|
|
55
|
+
/** Machine Payment Protocol family — categorical value used as a resume-state discriminator. */
|
|
56
|
+
Mpp: "mpp",
|
|
57
|
+
/** Haven internal MPP demo rail. Not for production traffic. */
|
|
58
|
+
MppDemo: "mpp_demo",
|
|
59
|
+
/** Crypto-settled MPP rail. */
|
|
60
|
+
MppCrypto: "mpp_crypto",
|
|
61
|
+
/** Stripe-deposit-backed MPP rail. */
|
|
62
|
+
StripeDeposit: "stripe_deposit",
|
|
63
|
+
/** Stripe Payment Token MPP rail. */
|
|
64
|
+
Spt: "spt"
|
|
57
65
|
};
|
|
58
66
|
var AGENT_PAYMENT_PHASE_VALUES = Object.values(AgentPaymentPhase);
|
|
59
67
|
var AGENT_PAYMENT_NEXT_ACTION_VALUES = Object.values(AgentPaymentNextAction);
|
|
@@ -83,7 +91,11 @@ var AgentPaymentNextActionDescriptions = {
|
|
|
83
91
|
var AgentPaymentRailDescriptions = {
|
|
84
92
|
[AgentPaymentRail.Direct]: "Standard Haven payment from the user-controlled Safe through an approved delegate allowance.",
|
|
85
93
|
[AgentPaymentRail.X402]: "x402 HTTP 402 payment flow with a Haven funding leg and merchant retry leg.",
|
|
86
|
-
[AgentPaymentRail.Mpp]: "
|
|
94
|
+
[AgentPaymentRail.Mpp]: "Categorical MPP rail value used as a resume-state discriminator. Response bodies carry a granular mpp_* value instead.",
|
|
95
|
+
[AgentPaymentRail.MppDemo]: "Haven internal MPP demo rail. Not for production traffic.",
|
|
96
|
+
[AgentPaymentRail.MppCrypto]: "Crypto-settled MPP rail.",
|
|
97
|
+
[AgentPaymentRail.StripeDeposit]: "Stripe-deposit-backed MPP rail.",
|
|
98
|
+
[AgentPaymentRail.Spt]: "Stripe Payment Token MPP rail."
|
|
87
99
|
};
|
|
88
100
|
var AgentPaymentPhaseSchema = {
|
|
89
101
|
type: "string",
|
|
@@ -323,6 +335,23 @@ function selectStandardPaymentOption(accepts) {
|
|
|
323
335
|
}
|
|
324
336
|
return null;
|
|
325
337
|
}
|
|
338
|
+
function x402AuthorizationAmount(option) {
|
|
339
|
+
return option.maxAmountRequired ?? option.amount;
|
|
340
|
+
}
|
|
341
|
+
function buildX402ExpectedMessage(context) {
|
|
342
|
+
return `Haven x402 expected context v1
|
|
343
|
+
${stableStringify({
|
|
344
|
+
version: 1,
|
|
345
|
+
kind: "haven.x402.expected",
|
|
346
|
+
paymentId: context.paymentId,
|
|
347
|
+
payloadHash: context.payloadHash.toLowerCase(),
|
|
348
|
+
resourceUrl: context.resourceUrl,
|
|
349
|
+
merchantTo: context.merchantTo.toLowerCase(),
|
|
350
|
+
amount: context.amount,
|
|
351
|
+
asset: context.asset.toLowerCase(),
|
|
352
|
+
network: context.network
|
|
353
|
+
})}`;
|
|
354
|
+
}
|
|
326
355
|
function toStandardPaymentRequirements(paymentRequired, option) {
|
|
327
356
|
const network = STANDARD_X402_NETWORKS[option.network];
|
|
328
357
|
if (!network) {
|
|
@@ -334,7 +363,7 @@ function toStandardPaymentRequirements(paymentRequired, option) {
|
|
|
334
363
|
return {
|
|
335
364
|
scheme: "exact",
|
|
336
365
|
network,
|
|
337
|
-
maxAmountRequired: option
|
|
366
|
+
maxAmountRequired: x402AuthorizationAmount(option),
|
|
338
367
|
resource: option.resource ?? paymentRequired.resource.url,
|
|
339
368
|
description: option.description ?? paymentRequired.resource.description ?? "Haven x402 payment",
|
|
340
369
|
mimeType: option.mimeType ?? paymentRequired.resource.mimeType ?? "application/octet-stream",
|
|
@@ -351,7 +380,7 @@ function buildX402IdempotencyKey(paymentRequired, option, now = Date.now()) {
|
|
|
351
380
|
paymentRequired.resource.description ?? "",
|
|
352
381
|
option.payTo.toLowerCase(),
|
|
353
382
|
option.asset.toLowerCase(),
|
|
354
|
-
option
|
|
383
|
+
x402AuthorizationAmount(option),
|
|
355
384
|
option.network,
|
|
356
385
|
bucket
|
|
357
386
|
].join("|");
|
|
@@ -380,6 +409,15 @@ function resolveTokenFromAddress(address, network) {
|
|
|
380
409
|
}
|
|
381
410
|
return ALL_TOKENS[lower] ?? null;
|
|
382
411
|
}
|
|
412
|
+
function stableStringify(value) {
|
|
413
|
+
if (value === null || typeof value !== "object") {
|
|
414
|
+
const primitive = JSON.stringify(value);
|
|
415
|
+
return primitive === void 0 ? "undefined" : primitive;
|
|
416
|
+
}
|
|
417
|
+
if (Array.isArray(value)) return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
418
|
+
const object = value;
|
|
419
|
+
return `{${Object.keys(object).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(object[key])}`).join(",")}}`;
|
|
420
|
+
}
|
|
383
421
|
function decodeBase64Json2(value, label) {
|
|
384
422
|
try {
|
|
385
423
|
return JSON.parse(atob(value));
|
|
@@ -657,6 +695,70 @@ var HavenClient = class {
|
|
|
657
695
|
signData: raw.sign_data
|
|
658
696
|
};
|
|
659
697
|
}
|
|
698
|
+
/**
|
|
699
|
+
* Keyless x402 construct.
|
|
700
|
+
*
|
|
701
|
+
* The non-custodial half of an x402 payment: posts the funding request to
|
|
702
|
+
* `/x402` and returns the unsigned funding hash plus the data the caller
|
|
703
|
+
* needs to build and sign the EIP-3009 merchant header itself. Crucially it
|
|
704
|
+
* does **not** sign — neither the funding hash nor the merchant header — so
|
|
705
|
+
* it works without a `delegateKey`. Both delegate signatures happen on the
|
|
706
|
+
* machine that holds the key (the edge); the hosted MCP server relays only.
|
|
707
|
+
*
|
|
708
|
+
* Use this from the hosted, keyless server. The all-in-one `authorizeX402`
|
|
709
|
+
* remains for local clients that hold the key.
|
|
710
|
+
*
|
|
711
|
+
* Throws (via the shared payment-state path) when the amount exceeds the
|
|
712
|
+
* on-chain allowance — there is nothing to sign until the user approves.
|
|
713
|
+
*/
|
|
714
|
+
async createX402Intent(paymentRequired, options = {}) {
|
|
715
|
+
const option = selectStandardPaymentOption(paymentRequired.accepts);
|
|
716
|
+
if (!option) {
|
|
717
|
+
throw new HavenApiError(
|
|
718
|
+
"No compatible payment option found in x402 requirements. Haven supports standard x402 exact payments on Base USDC.",
|
|
719
|
+
400
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
const agent = await this.getAgent();
|
|
723
|
+
const fundingTo = agent.delegateAddress;
|
|
724
|
+
if (!fundingTo) {
|
|
725
|
+
throw new HavenApiError("Authenticated agent has no delegate address registered.", 502);
|
|
726
|
+
}
|
|
727
|
+
const idempotencyKey = options.idempotencyKey ?? buildX402IdempotencyKey(paymentRequired, option);
|
|
728
|
+
const raw = await this.post("/x402", {
|
|
729
|
+
url: paymentRequired.resource.url,
|
|
730
|
+
payTo: fundingTo,
|
|
731
|
+
merchantPayTo: option.payTo,
|
|
732
|
+
amount: x402AuthorizationAmount(option),
|
|
733
|
+
asset: option.asset,
|
|
734
|
+
network: option.network,
|
|
735
|
+
description: paymentRequired.resource.description,
|
|
736
|
+
idempotencyKey
|
|
737
|
+
});
|
|
738
|
+
if (raw.status !== "pending_signature") {
|
|
739
|
+
this.throwPaymentStateError("x402 payment", raw);
|
|
740
|
+
}
|
|
741
|
+
if (!raw.sign_data?.hash) {
|
|
742
|
+
throw new HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
|
|
743
|
+
}
|
|
744
|
+
if (!raw.x402_expected_auth) {
|
|
745
|
+
throw new HavenApiError("No x402 expected-context binding returned from x402/authorize", 500, raw);
|
|
746
|
+
}
|
|
747
|
+
return {
|
|
748
|
+
paymentId: raw.payment_id,
|
|
749
|
+
status: "pending_signature",
|
|
750
|
+
expiresAt: raw.expires_at,
|
|
751
|
+
signData: raw.sign_data,
|
|
752
|
+
accepted: option,
|
|
753
|
+
resourceUrl: paymentRequired.resource.url,
|
|
754
|
+
merchantTo: raw.merchant_to ?? option.payTo,
|
|
755
|
+
amountAtomic: x402AuthorizationAmount(option),
|
|
756
|
+
asset: option.asset,
|
|
757
|
+
network: option.network,
|
|
758
|
+
expectedAuth: raw.x402_expected_auth,
|
|
759
|
+
fundingTo
|
|
760
|
+
};
|
|
761
|
+
}
|
|
660
762
|
/**
|
|
661
763
|
* Step 2: Sign a hash with the delegate key.
|
|
662
764
|
*
|
|
@@ -880,7 +982,7 @@ var HavenClient = class {
|
|
|
880
982
|
url: paymentRequired.resource.url,
|
|
881
983
|
payTo: this.delegateAddress,
|
|
882
984
|
merchantPayTo: option.payTo,
|
|
883
|
-
amount: option
|
|
985
|
+
amount: x402AuthorizationAmount(option),
|
|
884
986
|
asset: option.asset,
|
|
885
987
|
network: option.network,
|
|
886
988
|
description: paymentRequired.resource.description,
|
|
@@ -1317,7 +1419,7 @@ var HavenClient = class {
|
|
|
1317
1419
|
);
|
|
1318
1420
|
}
|
|
1319
1421
|
const approvedAmount = status.amount ? normalizeDecimal(status.amount) : "";
|
|
1320
|
-
const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(option
|
|
1422
|
+
const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(x402AuthorizationAmount(option)));
|
|
1321
1423
|
if (approvedAmount && approvedAmount !== requestedAmount) {
|
|
1322
1424
|
throw new HavenApiError(
|
|
1323
1425
|
"x402 resume request does not match the approved amount.",
|
|
@@ -1393,7 +1495,7 @@ var HavenClient = class {
|
|
|
1393
1495
|
const txHash = execResult?.tx_hash ?? raw.tx_hash ?? "";
|
|
1394
1496
|
const chainId = execResult?.chain_id ?? raw.chain_id ?? chainIdFromNetwork(option.network);
|
|
1395
1497
|
const token = execResult?.token ?? raw.token ?? "USDC";
|
|
1396
|
-
const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(option
|
|
1498
|
+
const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(x402AuthorizationAmount(option));
|
|
1397
1499
|
const to = execResult?.to ?? raw.to ?? this.delegateAddress ?? "";
|
|
1398
1500
|
const explorerUrl = execResult?.explorer_url ?? raw.explorer_url ?? explorerUrlOrEmpty(chainId, txHash);
|
|
1399
1501
|
const merchantTo = execResult?.merchant_to ?? raw.merchant_to ?? option.payTo;
|
|
@@ -1426,7 +1528,7 @@ var HavenClient = class {
|
|
|
1426
1528
|
paymentId: status.paymentId,
|
|
1427
1529
|
txHash: status.txHash,
|
|
1428
1530
|
token: status.token || "USDC",
|
|
1429
|
-
amount: status.amount || decimalFromUsdcAtomic(option
|
|
1531
|
+
amount: status.amount || decimalFromUsdcAtomic(x402AuthorizationAmount(option)),
|
|
1430
1532
|
to: this.delegateAddress ?? "",
|
|
1431
1533
|
resourceUrl: paymentRequired.resource.url,
|
|
1432
1534
|
explorerUrl: explorerUrlOrEmpty(status.chainId, status.txHash),
|
|
@@ -1462,7 +1564,7 @@ var HavenClient = class {
|
|
|
1462
1564
|
payTo: input.merchantTo ?? input.accepted.payTo
|
|
1463
1565
|
},
|
|
1464
1566
|
x402: {
|
|
1465
|
-
amount: input.accepted
|
|
1567
|
+
amount: x402AuthorizationAmount(input.accepted),
|
|
1466
1568
|
token: input.token,
|
|
1467
1569
|
network: input.accepted.network,
|
|
1468
1570
|
asset: input.accepted.asset,
|
|
@@ -1712,8 +1814,8 @@ var HavenClient = class {
|
|
|
1712
1814
|
resourceUrl: paymentRequired.resource.url,
|
|
1713
1815
|
description: paymentRequired.resource.description ?? option.description ?? null,
|
|
1714
1816
|
mimeType: paymentRequired.resource.mimeType ?? option.mimeType ?? null,
|
|
1715
|
-
amountAtomic: option
|
|
1716
|
-
amount: decimalFromUsdcAtomic(option
|
|
1817
|
+
amountAtomic: x402AuthorizationAmount(option),
|
|
1818
|
+
amount: decimalFromUsdcAtomic(x402AuthorizationAmount(option)),
|
|
1717
1819
|
token: token?.symbol ?? "USDC",
|
|
1718
1820
|
asset: option.asset,
|
|
1719
1821
|
network: option.network,
|
|
@@ -1734,8 +1836,8 @@ var HavenClient = class {
|
|
|
1734
1836
|
request: input.request,
|
|
1735
1837
|
resourceUrl: input.paymentRequired.resource.url,
|
|
1736
1838
|
description: input.paymentRequired.resource.description ?? input.accepted.description ?? null,
|
|
1737
|
-
amountAtomic: input.accepted
|
|
1738
|
-
amount: decimalFromUsdcAtomic(input.accepted
|
|
1839
|
+
amountAtomic: x402AuthorizationAmount(input.accepted),
|
|
1840
|
+
amount: decimalFromUsdcAtomic(x402AuthorizationAmount(input.accepted)),
|
|
1739
1841
|
token: token?.symbol ?? "USDC",
|
|
1740
1842
|
asset: input.accepted.asset,
|
|
1741
1843
|
network: input.accepted.network,
|
|
@@ -1930,6 +2032,9 @@ var HavenClient = class {
|
|
|
1930
2032
|
message: result.message
|
|
1931
2033
|
};
|
|
1932
2034
|
}
|
|
2035
|
+
if (toolName === "get_allowances") {
|
|
2036
|
+
return { ...await this.getAllowances() };
|
|
2037
|
+
}
|
|
1933
2038
|
throw new Error(`Unknown tool: ${toolName}`);
|
|
1934
2039
|
}
|
|
1935
2040
|
toolX402PaymentRequired(input) {
|
|
@@ -2187,6 +2292,72 @@ async function responseSnippet(response) {
|
|
|
2187
2292
|
}
|
|
2188
2293
|
}
|
|
2189
2294
|
|
|
2295
|
+
// src/tool-descriptions.ts
|
|
2296
|
+
function composeDescription(d) {
|
|
2297
|
+
return [d.summary, d.selectionGuidance, d.behavior, d.nextActionGuidance].filter(Boolean).join(" ");
|
|
2298
|
+
}
|
|
2299
|
+
var toolDescriptions = {
|
|
2300
|
+
quoteX402: {
|
|
2301
|
+
summary: "Inspect an HTTP 402 x402 paid resource without creating a Haven payment, signature, approval, or on-chain transaction.",
|
|
2302
|
+
behavior: "Probes the merchant directly and parses the 402 response. Pure read-only client behavior \u2014 Haven is not contacted.",
|
|
2303
|
+
nextActionGuidance: ""
|
|
2304
|
+
},
|
|
2305
|
+
payX402: {
|
|
2306
|
+
summary: "Pay an inspected x402 quote. The delegate key signs locally; Haven only validates and relays signed, on-chain-constrained payment transactions.",
|
|
2307
|
+
selectionGuidance: "Do not use this for read-only allowance, budget, spend-limit, remaining-amount, reset-period, or what-can-I-spend questions; use the allowance lookup tool instead.",
|
|
2308
|
+
behavior: "Signs the EIP-3009 payment from the delegate wallet, asks Haven for a Safe AllowanceModule top-up if needed, and returns the merchant response or a pending-approval state.",
|
|
2309
|
+
nextActionGuidance: "If approval is needed, preserve the returned resume_state and wait for nextAction=retry_original_x402_request before resuming."
|
|
2310
|
+
},
|
|
2311
|
+
resumeX402: {
|
|
2312
|
+
summary: "Resume an x402 payment after the Haven wallet owner approved the funding step.",
|
|
2313
|
+
behavior: "Accepts either resume_state or payment_id, validates the original x402 details against the approved Haven funding, and retries the merchant request with the X-PAYMENT header. No new Haven approval is created.",
|
|
2314
|
+
nextActionGuidance: "Only use when get_payment_status returns nextAction=retry_original_x402_request; do not start a new merchant session."
|
|
2315
|
+
},
|
|
2316
|
+
quoteMpp: {
|
|
2317
|
+
summary: "Inspect a Haven MPP challenge or paid MPP URL without creating a Haven payment, signature, approval, or on-chain transaction.",
|
|
2318
|
+
behavior: "Parses an MPP challenge envelope and returns a typed quote with rail tag, amount, asset, and merchant context. Pure read-only \u2014 Haven is not contacted.",
|
|
2319
|
+
nextActionGuidance: ""
|
|
2320
|
+
},
|
|
2321
|
+
payMpp: {
|
|
2322
|
+
summary: "Pay an inspected MPP challenge. The delegate key signs locally; Haven only validates and relays signed, on-chain-constrained payment transactions.",
|
|
2323
|
+
selectionGuidance: "Do not use this for read-only allowance, budget, spend-limit, remaining-amount, reset-period, or what-can-I-spend questions; use the allowance lookup tool instead.",
|
|
2324
|
+
behavior: "Authorizes the payment through Haven within the on-chain allowance, signs the challenge proof, and returns the proof header for retrying the original paid resource.",
|
|
2325
|
+
nextActionGuidance: "If approval is needed, preserve resume_state or payment_id and wait for nextAction=retry_original_x402_request before resuming."
|
|
2326
|
+
},
|
|
2327
|
+
resumeMpp: {
|
|
2328
|
+
summary: "Resume an MPP payment after the Haven wallet owner approved the funding step.",
|
|
2329
|
+
behavior: "Accepts either resume_state or payment_id and retries the original paid resource with the MPP proof header. No new Haven approval is created.",
|
|
2330
|
+
nextActionGuidance: ""
|
|
2331
|
+
},
|
|
2332
|
+
getPaymentStatus: {
|
|
2333
|
+
summary: "Fetch structured Haven payment status, including phase and nextAction taxonomy for agent recovery.",
|
|
2334
|
+
behavior: "Accepts a payment intent or approval request id and returns the full state taxonomy (phase, nextAction, rail, amount, merchant, resource url, idempotency key, message).",
|
|
2335
|
+
nextActionGuidance: ""
|
|
2336
|
+
},
|
|
2337
|
+
getResumeState: {
|
|
2338
|
+
summary: "Rehydrate stored x402 or MPP resume_state by payment_id.",
|
|
2339
|
+
behavior: "Returns the context that the agent originally received in a pending-approval response, reconstructed from Haven's database. This is context only; signing still happens locally when a resume tool is called.",
|
|
2340
|
+
nextActionGuidance: ""
|
|
2341
|
+
},
|
|
2342
|
+
getAgent: {
|
|
2343
|
+
summary: "Return the authenticated agent identity, Haven wallet, delegate address, chain, and status.",
|
|
2344
|
+
behavior: "Read-only identity lookup. Useful for verifying which on-chain Safe and delegate the credential is bound to.",
|
|
2345
|
+
nextActionGuidance: ""
|
|
2346
|
+
},
|
|
2347
|
+
getAllowances: {
|
|
2348
|
+
summary: "Return configured and on-chain allowance state for the authenticated agent. On-chain allowance is the real spend gate.",
|
|
2349
|
+
selectionGuidance: "Use this when the user asks about allowance, budget, spend limit, remaining amount, remaining allowance, remaining budget, daily limit, reset period, what can I spend, or what the agent can still spend.",
|
|
2350
|
+
behavior: "Reads the Safe AllowanceModule snapshot per token (allowance, spent, remaining, reset window). Configured amounts from Haven are returned alongside the on-chain truth.",
|
|
2351
|
+
nextActionGuidance: ""
|
|
2352
|
+
},
|
|
2353
|
+
listReceipts: {
|
|
2354
|
+
summary: "List recent machine-payment receipts and evidence for bookkeeping.",
|
|
2355
|
+
selectionGuidance: "Use this for transaction history, receipts, payment evidence, or bookkeeping; use the allowance tool instead for remaining allowance, budget, spend-limit, or what-can-I-spend questions.",
|
|
2356
|
+
behavior: "Returns the agent's recent machine-payment receipts ordered by recency. Proof header values are not returned.",
|
|
2357
|
+
nextActionGuidance: ""
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
|
|
2190
2361
|
// src/tools.ts
|
|
2191
2362
|
var makePaymentSchema = {
|
|
2192
2363
|
type: "object",
|
|
@@ -2220,6 +2391,11 @@ var getPaymentStatusSchema = {
|
|
|
2220
2391
|
},
|
|
2221
2392
|
required: ["payment_id"]
|
|
2222
2393
|
};
|
|
2394
|
+
var getAllowancesSchema = {
|
|
2395
|
+
type: "object",
|
|
2396
|
+
properties: {},
|
|
2397
|
+
required: []
|
|
2398
|
+
};
|
|
2223
2399
|
var authorizeX402Schema = {
|
|
2224
2400
|
type: "object",
|
|
2225
2401
|
properties: {
|
|
@@ -2302,11 +2478,12 @@ var authorizeMachinePaymentSchema = {
|
|
|
2302
2478
|
},
|
|
2303
2479
|
required: ["challenge"]
|
|
2304
2480
|
};
|
|
2305
|
-
var MAKE_PAYMENT_DESCRIPTION = "Request and sign a payment from the user-controlled Safe within approved on-chain limits. Haven authenticates the agent, validates the signed intent, and relays the Safe AllowanceModule transaction; it does not hold keys or control funds. Gnosis Chain tokens: EURe, USDC.e, xDAI. Base tokens: USDC, ETH.";
|
|
2306
|
-
var GET_STATUS_DESCRIPTION =
|
|
2307
|
-
var
|
|
2308
|
-
var
|
|
2309
|
-
var
|
|
2481
|
+
var MAKE_PAYMENT_DESCRIPTION = "Request and sign a payment from the user-controlled Safe within approved on-chain limits. For read-only allowance, budget, spend-limit, remaining-amount, or reset-period questions, use get_allowances instead of making a payment. Haven authenticates the agent, validates the signed intent, and relays the Safe AllowanceModule transaction; it does not hold keys or control funds. Gnosis Chain tokens: EURe, USDC.e, xDAI. Base tokens: USDC, ETH.";
|
|
2482
|
+
var GET_STATUS_DESCRIPTION = toolDescriptions.getPaymentStatus.summary + " Accepts payment intent IDs and approval request IDs. Returns the current status, phase, next_action, transaction hash if available, and payment details.";
|
|
2483
|
+
var GET_ALLOWANCES_DESCRIPTION = composeDescription(toolDescriptions.getAllowances);
|
|
2484
|
+
var AUTHORIZE_X402_DESCRIPTION = composeDescription(toolDescriptions.payX402) + " In this SDK tool set, the allowance lookup tool is get_allowances. When a paid API returns x402 payment requirements, use this tool to sign with the agent-owned delegate key and request a policy-limited Safe AllowanceModule top-up when needed. Haven relays signed transactions only; the agent key authorizes payment and on-chain limits enforce spend. If this returns pending_approval, tell the user it is waiting in Haven, preserve the original merchant/MCP session and x402 details, call get_payment_status later, and use resume_x402_payment only when next_action is retry_original_x402_request. Do not start a new merchant session or loop retries while approval is pending. Use the returned payment_header as the X-PAYMENT header on the retry request when doing a manual HTTP retry.";
|
|
2485
|
+
var RESUME_X402_DESCRIPTION = toolDescriptions.resumeX402.summary + " Use this only after get_payment_status returns next_action=retry_original_x402_request. It checks the approved payment, validates the original x402 details, and returns a merchant X-PAYMENT header without creating a new approval request or merchant session.";
|
|
2486
|
+
var AUTHORIZE_MACHINE_PAYMENT_DESCRIPTION = composeDescription(toolDescriptions.payMpp) + " In this SDK tool set, the allowance lookup tool is get_allowances. Currently scoped to the internal MPP demo rail. The agent signs the payment, Haven relays it within the on-chain allowance, and the tool returns a proof header for the retry request.";
|
|
2310
2487
|
function claudeTools() {
|
|
2311
2488
|
return [
|
|
2312
2489
|
{
|
|
@@ -2319,6 +2496,11 @@ function claudeTools() {
|
|
|
2319
2496
|
description: GET_STATUS_DESCRIPTION,
|
|
2320
2497
|
input_schema: getPaymentStatusSchema
|
|
2321
2498
|
},
|
|
2499
|
+
{
|
|
2500
|
+
name: "get_allowances",
|
|
2501
|
+
description: GET_ALLOWANCES_DESCRIPTION,
|
|
2502
|
+
input_schema: getAllowancesSchema
|
|
2503
|
+
},
|
|
2322
2504
|
{
|
|
2323
2505
|
name: "authorize_x402_payment",
|
|
2324
2506
|
description: AUTHORIZE_X402_DESCRIPTION,
|
|
@@ -2354,6 +2536,14 @@ function openaiTools() {
|
|
|
2354
2536
|
parameters: getPaymentStatusSchema
|
|
2355
2537
|
}
|
|
2356
2538
|
},
|
|
2539
|
+
{
|
|
2540
|
+
type: "function",
|
|
2541
|
+
function: {
|
|
2542
|
+
name: "get_allowances",
|
|
2543
|
+
description: GET_ALLOWANCES_DESCRIPTION,
|
|
2544
|
+
parameters: getAllowancesSchema
|
|
2545
|
+
}
|
|
2546
|
+
},
|
|
2357
2547
|
{
|
|
2358
2548
|
type: "function",
|
|
2359
2549
|
function: {
|
|
@@ -2387,6 +2577,6 @@ var havenTools = {
|
|
|
2387
2577
|
openai: openaiTools
|
|
2388
2578
|
};
|
|
2389
2579
|
|
|
2390
|
-
export { AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, HavenApiError, HavenClient, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, addressFromKey, buildMachinePaymentIdempotencyKey, encodeMachinePaymentProof, encodePaymentProof, havenTools, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, signHash, verifySignature };
|
|
2580
|
+
export { AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, HavenApiError, HavenClient, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, addressFromKey, buildMachinePaymentIdempotencyKey, buildX402ExpectedMessage, composeDescription, encodeMachinePaymentProof, encodePaymentProof, havenTools, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, toStandardPaymentRequirements, toolDescriptions, verifySignature, x402AuthorizationAmount };
|
|
2391
2581
|
//# sourceMappingURL=index.js.map
|
|
2392
2582
|
//# sourceMappingURL=index.js.map
|