@agent-score/commerce 1.1.0 → 1.3.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/README.md +27 -12
- package/dist/{_response-RpEB7-vl.d.ts → _response-C2yFQoIA.d.ts} +1 -1
- package/dist/{_response-DS-LR590.d.mts → _response-DpB-cm2c.d.mts} +1 -1
- package/dist/agent_instructions-DiMSGkdm.d.mts +133 -0
- package/dist/agent_instructions-DiMSGkdm.d.ts +133 -0
- package/dist/challenge/index.d.mts +18 -116
- package/dist/challenge/index.d.ts +18 -116
- package/dist/challenge/index.js +41 -27
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +40 -27
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +245 -2
- package/dist/discovery/index.d.ts +245 -2
- package/dist/discovery/index.js +276 -56
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +269 -55
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/identity/express.d.mts +2 -2
- package/dist/identity/express.d.ts +2 -2
- package/dist/identity/express.js +48 -25
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +48 -25
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +2 -2
- package/dist/identity/fastify.d.ts +2 -2
- package/dist/identity/fastify.js +48 -25
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +48 -25
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +2 -2
- package/dist/identity/hono.d.ts +2 -2
- package/dist/identity/hono.js +48 -25
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +48 -25
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +2 -2
- package/dist/identity/nextjs.d.ts +2 -2
- package/dist/identity/nextjs.js +48 -25
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +48 -25
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/web.d.mts +2 -2
- package/dist/identity/web.d.ts +2 -2
- package/dist/identity/web.js +48 -25
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +48 -25
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +47 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -24
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +136 -49
- package/dist/payment/index.d.ts +136 -49
- package/dist/payment/index.js +161 -73
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +160 -72
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{signer-Cvdwn6Cs.d.mts → signer-kCAJUZwp.d.mts} +10 -12
- package/dist/{signer-Cvdwn6Cs.d.ts → signer-kCAJUZwp.d.ts} +10 -12
- package/dist/stripe-multichain/index.d.mts +2 -2
- package/dist/stripe-multichain/index.d.ts +2 -2
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ bun add @agent-score/commerce
|
|
|
16
16
|
Framework + protocol packages are optional peer deps — install only what you use:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install hono mppx @x402/core @x402/evm @
|
|
19
|
+
npm install hono mppx @x402/core @x402/evm @solana/mpp @solana/kit stripe # whatever your stack needs
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## What's in the package
|
|
@@ -24,8 +24,8 @@ npm install hono mppx @x402/core @x402/evm @x402/svm stripe # whatever your st
|
|
|
24
24
|
| Subpath | What it provides |
|
|
25
25
|
|---|---|
|
|
26
26
|
| `/identity/{hono,express,fastify,nextjs,web}` | Trust gate middleware: KYC, sanctions, age, jurisdiction. `agentscoreGate(...)`, `getAgentScoreData(c)`, `captureWallet(...)`, `verifyWalletSignerMatch(...)`. Plus shared denial helpers: `denialReasonStatus`, `denialReasonToBody`, `buildSignerMismatchBody`, `buildContactSupportNextSteps`, `verificationAgentInstructions`, `isFixableDenial`, `FIXABLE_DENIAL_REASONS`. |
|
|
27
|
-
| `/payment` | `networks`, `USDC`, `rails` registries; `paymentDirective`, `buildPaymentDirective`, `wwwAuthenticateHeader`, `paymentRequiredHeader`, `aliasAmountFields` (v1↔v2 amount field shim — emits both `amount` and `maxAmountRequired` so v1-only x402 parsers like Coinbase awal can read v2 bodies), `settlementOverrideHeader`, `dispatchSettlementByNetwork`, `extractPaymentSigner` (returns `{address, network}`); `createX402Server`, `createMppxServer`; drop-in x402 helpers: `validateX402NetworkConfig` (boot-time guard), `verifyX402Request` (parse + validate inbound X-Payment), `processX402Settle` (verify-then-settle with one call). |
|
|
28
|
-
| `/discovery` | `isDiscoveryProbeRequest`, `buildDiscoveryProbeResponse` (with optional `x402Sample` for x402-aware crawlers — `awal x402 details` etc.), `sampleX402AcceptForNetwork` (USDC sample-accept builder for known CAIP-2 networks), `buildWellKnownMpp`, `buildLlmsTxt` + `llmsTxtIdentitySection` + `llmsTxtPaymentSection` (compact + verbose modes), `agentscoreOpenApiSnippets`, `createBazaarDiscovery`, `noindexNonDiscoveryPaths` (Hono middleware that emits `X-Robots-Tag: noindex` on every path except the agent-discovery surfaces — defaults cover `/openapi.json`, `/llms.txt`, `/.well-known/{mpp.json,agent-card.json,ucp}`, `/favicon.{png,ico}`; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks). |
|
|
27
|
+
| `/payment` | `networks`, `USDC`, `rails` registries; `paymentDirective`, `buildPaymentDirective`, `wwwAuthenticateHeader`, `paymentRequiredHeader`, `aliasAmountFields` (v1↔v2 amount field shim — emits both `amount` and `maxAmountRequired` so v1-only x402 parsers like Coinbase awal can read v2 bodies), `settlementOverrideHeader`, `dispatchSettlementByNetwork`, `extractPaymentSigner` (returns `{address, network}`); `createX402Server`, `createMppxServer`; drop-in x402 helpers: `validateX402NetworkConfig` (boot-time guard), `verifyX402Request` (parse + validate inbound X-Payment), `processX402Settle` (verify-then-settle with one call), `classifyX402SettleResult` (maps the tagged settle result to a recommended HTTP status / code / nextSteps so merchants get a controlled envelope without coupling to facilitator-specific error text). |
|
|
28
|
+
| `/discovery` | `isDiscoveryProbeRequest`, `buildDiscoveryProbeResponse` (with optional `x402Sample` for x402-aware crawlers — `awal x402 details` etc.), `sampleX402AcceptForNetwork` (USDC sample-accept builder for known CAIP-2 networks), `buildWellKnownMpp`, `buildLlmsTxt` + `llmsTxtIdentitySection` + `llmsTxtPaymentSection` (compact + verbose modes), `buildSkillMd` (Claude-Skill-compatible `/skill.md` agent-discovery manifest — strictly agent-facing data only, no internal posture), `agentscoreOpenApiSnippets`, `createBazaarDiscovery`, `noindexNonDiscoveryPaths` (Hono middleware that emits `X-Robots-Tag: noindex` on every path except the agent-discovery surfaces — defaults cover `/openapi.json`, `/llms.txt`, `/skill.md`, `/.well-known/{mpp.json,agent-card.json,ucp}`, `/favicon.{png,ico}`; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks). |
|
|
29
29
|
| `/challenge` | `build402Body`, `buildAcceptedMethods`, `buildIdentityMetadata`, `buildHowToPay`, `buildAgentInstructions` (auto-emits per-rail `compatible_clients` — smoke-verified CLIs the agent should use; vendor override supported), `buildPricingBlock`, `firstEncounterAgentMemory`, `OrderReceipt`; `respond402` — drop-in 402 emit that preserves mppx's `WWW-Authenticate` and layers x402's `PAYMENT-REQUIRED`. `buildValidationError` — structured 4xx body builder (`{error: {code, message}, required_fields?, example_body?, next_steps?, ...extra}`) so vendors compose body shapes by name instead of inlining at every validation site. |
|
|
30
30
|
| `/stripe-multichain` | `createMultichainPaymentIntent`, `getDepositAddress`, `simulateCryptoDeposit`, `createMppxStripe`; `createPiCache` (TTL'd PI / deposit-address cache, Redis-backed when `redisUrl` set, in-memory otherwise), `simulateDepositIfTestMode` (gates on `sk_test_` and looks up the PI for you), `STRIPE_TEST_TX_HASH_SUCCESS` / `STRIPE_TEST_TX_HASH_FAILED` constants. Peer dep on `stripe`. |
|
|
31
31
|
| `/api` | Everything from `@agent-score/sdk` re-exported in one place: `AgentScore` + `AgentScoreError`, `AGENTSCORE_TEST_ADDRESSES` + `isAgentScoreTestAddress`. **Don't add `@agent-score/sdk` as a separate dep** — the two can drift versions and cause subtle type mismatches. |
|
|
@@ -89,13 +89,16 @@ import {
|
|
|
89
89
|
|
|
90
90
|
// Build paymentauth.org directives by symbolic rail name (decimals + currency from registry)
|
|
91
91
|
const directives = [
|
|
92
|
-
buildPaymentDirective({ rail: "tempo-mainnet",
|
|
93
|
-
buildPaymentDirective({ rail: "x402-base-mainnet",
|
|
94
|
-
buildPaymentDirective({ rail: "
|
|
92
|
+
buildPaymentDirective({ rail: "tempo-mainnet", id: "chg_t", realm: "ex.com", recipient: TEMPO_ADDR, amountUsd: 0.01 }),
|
|
93
|
+
buildPaymentDirective({ rail: "x402-base-mainnet", id: "chg_b", realm: "ex.com", recipient: BASE_ADDR, amountUsd: 0.01 }),
|
|
94
|
+
buildPaymentDirective({ rail: "mpp-solana-mainnet", id: "chg_s", realm: "ex.com", recipient: SOL_ADDR, amountUsd: 0.01 }),
|
|
95
95
|
];
|
|
96
96
|
const wwwAuth = wwwAuthenticateHeader(directives);
|
|
97
97
|
|
|
98
|
-
// Recover the on-chain signer from the inbound credential — returns {address, network}
|
|
98
|
+
// Recover the on-chain signer from the inbound credential — returns {address, network}.
|
|
99
|
+
// Covers x402 EIP-3009 (EVM `from` address), Tempo MPP (`did:pkh:eip155` source),
|
|
100
|
+
// and Solana MPP `solana/charge` (via `did:pkh:solana` source when set, else by
|
|
101
|
+
// decoding the credential's signed-tx payload — `@solana/kit` optional peer).
|
|
99
102
|
const signer = await extractPaymentSigner(req, req.headers.get("x-payment") ?? undefined);
|
|
100
103
|
```
|
|
101
104
|
|
|
@@ -106,12 +109,17 @@ import { createX402Server, createMppxServer } from "@agent-score/commerce/paymen
|
|
|
106
109
|
|
|
107
110
|
const x402 = await createX402Server({
|
|
108
111
|
facilitator: "coinbase", // or "http", or pass a custom facilitator instance
|
|
109
|
-
rails: ["x402-base-mainnet", "x402-
|
|
112
|
+
rails: ["x402-base-mainnet", "x402-base-mainnet-upto"],
|
|
110
113
|
});
|
|
111
114
|
|
|
112
115
|
const mppx = await createMppxServer({
|
|
113
116
|
rails: {
|
|
114
117
|
tempo: { recipient: process.env.TEMPO_RECIPIENT! },
|
|
118
|
+
solana: {
|
|
119
|
+
recipient: process.env.SOLANA_RECIPIENT!,
|
|
120
|
+
// Optional fee sponsor — pass any `TransactionPartialSigner` from `@solana/kit`.
|
|
121
|
+
// signer: solanaFeePayerSigner,
|
|
122
|
+
},
|
|
115
123
|
stripe: { profileId: process.env.STRIPE_PROFILE_ID!, secretKey: process.env.STRIPE_SECRET_KEY! },
|
|
116
124
|
},
|
|
117
125
|
secretKey: process.env.MPP_SECRET_KEY!,
|
|
@@ -132,7 +140,7 @@ import {
|
|
|
132
140
|
const acceptedMethods = buildAcceptedMethods({
|
|
133
141
|
tempo: { recipient: TEMPO_ADDR },
|
|
134
142
|
x402_base: { recipient: BASE_ADDR },
|
|
135
|
-
|
|
143
|
+
solana_mpp: { recipient: SOL_ADDR, feePayerKey: SOLANA_FEE_PAYER },
|
|
136
144
|
stripe: { profileId: STRIPE_PROFILE_ID },
|
|
137
145
|
});
|
|
138
146
|
|
|
@@ -236,6 +244,7 @@ await simulateDepositIfTestMode({
|
|
|
236
244
|
|
|
237
245
|
```typescript
|
|
238
246
|
import {
|
|
247
|
+
classifyX402SettleResult,
|
|
239
248
|
processX402Settle,
|
|
240
249
|
validateX402NetworkConfig,
|
|
241
250
|
verifyX402Request,
|
|
@@ -243,7 +252,7 @@ import {
|
|
|
243
252
|
import { respond402 } from "@agent-score/commerce/challenge";
|
|
244
253
|
|
|
245
254
|
// Boot-time guard — raises if a configured network isn't supported.
|
|
246
|
-
validateX402NetworkConfig({ baseNetwork: X402_BASE
|
|
255
|
+
validateX402NetworkConfig({ baseNetwork: X402_BASE });
|
|
247
256
|
|
|
248
257
|
app.post("/purchase", async (c) => {
|
|
249
258
|
// Path A — agent presented an x402 X-Payment header
|
|
@@ -251,7 +260,7 @@ app.post("/purchase", async (c) => {
|
|
|
251
260
|
const verified = await verifyX402Request({
|
|
252
261
|
request: c.req.raw,
|
|
253
262
|
isCachedAddress: piCache.hasAddress,
|
|
254
|
-
|
|
263
|
+
acceptedNetwork: X402_BASE,
|
|
255
264
|
});
|
|
256
265
|
if (!verified.ok) return c.json(verified.body, verified.status);
|
|
257
266
|
|
|
@@ -261,7 +270,13 @@ app.post("/purchase", async (c) => {
|
|
|
261
270
|
resourceConfig: { scheme: "exact", network: verified.signedNetwork, price: `$${total}`, payTo: verified.signedPayTo, maxTimeoutSeconds: 300 },
|
|
262
271
|
resourceMeta: { url: c.req.url, mimeType: "application/json" },
|
|
263
272
|
});
|
|
264
|
-
|
|
273
|
+
const classified = classifyX402SettleResult(settle);
|
|
274
|
+
if (classified) {
|
|
275
|
+
// Log raw `settle` server-side; return controlled phase-based response to the agent.
|
|
276
|
+
console.error("[x402-settle]", { phase: settle.success ? null : settle.phase, raw: settle });
|
|
277
|
+
return c.json({ error: { code: classified.code, message: classified.message }, next_steps: classified.nextSteps }, classified.status);
|
|
278
|
+
}
|
|
279
|
+
if (!settle.success) throw new Error("unreachable: classified covers every non-success phase");
|
|
265
280
|
|
|
266
281
|
const headers: Record<string, string> = {};
|
|
267
282
|
if (settle.paymentResponseHeader) headers["payment-response"] = settle.paymentResponseHeader;
|
|
@@ -77,7 +77,7 @@ declare function buildSignerMismatchBody(input: SignerMismatchBodyInput): Record
|
|
|
77
77
|
* return c.json({
|
|
78
78
|
* error: { code: 'compliance_denied', message: '...' },
|
|
79
79
|
* reasons,
|
|
80
|
-
* next_steps: buildContactSupportNextSteps('support@
|
|
80
|
+
* next_steps: buildContactSupportNextSteps('support@example.com'),
|
|
81
81
|
* }, 403);
|
|
82
82
|
*/
|
|
83
83
|
declare function buildContactSupportNextSteps(supportEmail: string, message?: string): {
|
|
@@ -77,7 +77,7 @@ declare function buildSignerMismatchBody(input: SignerMismatchBodyInput): Record
|
|
|
77
77
|
* return c.json({
|
|
78
78
|
* error: { code: 'compliance_denied', message: '...' },
|
|
79
79
|
* reasons,
|
|
80
|
-
* next_steps: buildContactSupportNextSteps('support@
|
|
80
|
+
* next_steps: buildContactSupportNextSteps('support@example.com'),
|
|
81
81
|
* }, 403);
|
|
82
82
|
*/
|
|
83
83
|
declare function buildContactSupportNextSteps(supportEmail: string, message?: string): {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
interface HowToPayRailEntry {
|
|
2
|
+
setup?: string[];
|
|
3
|
+
prerequisite?: string;
|
|
4
|
+
command: string;
|
|
5
|
+
alternative_command?: string;
|
|
6
|
+
what_it_does: string;
|
|
7
|
+
}
|
|
8
|
+
interface HowToPayStripeEntry {
|
|
9
|
+
prerequisite: string;
|
|
10
|
+
instructions: string;
|
|
11
|
+
setup_link_cli?: string[];
|
|
12
|
+
command_link_cli?: string[];
|
|
13
|
+
what_it_does_link_cli?: string;
|
|
14
|
+
note?: string;
|
|
15
|
+
}
|
|
16
|
+
interface HowToPayBlock {
|
|
17
|
+
tempo?: HowToPayRailEntry;
|
|
18
|
+
x402_base?: HowToPayRailEntry;
|
|
19
|
+
solana_mpp?: HowToPayRailEntry;
|
|
20
|
+
stripe?: HowToPayStripeEntry;
|
|
21
|
+
}
|
|
22
|
+
interface BuildHowToPayInput {
|
|
23
|
+
/** The merchant's full URL (e.g., 'https://agents.merchant.example/api/buy'). */
|
|
24
|
+
url: string;
|
|
25
|
+
/** JSON string of the body the agent should retry with — typically the original request body. */
|
|
26
|
+
retryBodyJson: string;
|
|
27
|
+
/** Total amount in USD (string or number). Used to compute max-spend defaults and stripe context. */
|
|
28
|
+
totalUsd: string | number;
|
|
29
|
+
/** Per-rail config — each is optional. Pass only the rails you support. */
|
|
30
|
+
rails: {
|
|
31
|
+
tempo?: {
|
|
32
|
+
recipient: string;
|
|
33
|
+
networkName?: string;
|
|
34
|
+
chainId?: number;
|
|
35
|
+
recommend?: 'tempo' | 'agentscore-pay' | 'both';
|
|
36
|
+
};
|
|
37
|
+
x402_base?: {
|
|
38
|
+
recipient: string;
|
|
39
|
+
network?: string;
|
|
40
|
+
};
|
|
41
|
+
solana_mpp?: {
|
|
42
|
+
recipient: string;
|
|
43
|
+
network?: string;
|
|
44
|
+
};
|
|
45
|
+
stripe?: {
|
|
46
|
+
profileId?: string | null;
|
|
47
|
+
productName?: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'. */
|
|
51
|
+
opTokenPlaceholder?: string;
|
|
52
|
+
/** Override max-spend value used in commands. Default: ceil(totalUsd) + 1. */
|
|
53
|
+
maxSpend?: string | number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the agent_instructions.how_to_pay block. Generates per-rail setup/command/what_it_does
|
|
57
|
+
* boilerplate so agents see concrete commands per rail in the 402 body. Vendors pass the rails
|
|
58
|
+
* they support; the helper produces the right command for each.
|
|
59
|
+
*
|
|
60
|
+
* Tool recommendations (tempo CLI vs agentscore-pay vs link-cli) are configurable per rail.
|
|
61
|
+
*/
|
|
62
|
+
declare function buildHowToPay(input: BuildHowToPayInput): HowToPayBlock;
|
|
63
|
+
|
|
64
|
+
/** Map of rail key (e.g. 'x402_base', 'tempo_mpp', 'stripe') → list of client identifiers
|
|
65
|
+
* that have been smoke-verified by the merchant against the protocol shape they emit.
|
|
66
|
+
* Strings are display labels, not install commands — agents already get install commands
|
|
67
|
+
* via `how_to_pay.<rail>.setup`. Use these as a "what's known to work" hint. */
|
|
68
|
+
type CompatibleClients = Record<string, string[]>;
|
|
69
|
+
interface BuildAgentInstructionsInput {
|
|
70
|
+
/** Per-rail commands. Build with `buildHowToPay`. */
|
|
71
|
+
howToPay: HowToPayBlock;
|
|
72
|
+
/** Tool recommendations as human-readable strings. Defaults to a sensible set covering tempo + agentscore-pay. */
|
|
73
|
+
recommendedTools?: string[];
|
|
74
|
+
/** Wallet-stack compatibility note for the agent. Default: rail-neutral, no specific wallet stack required. */
|
|
75
|
+
walletCompatibility?: string;
|
|
76
|
+
/** How long the merchant will wait for payment after the 402. Default 300 (5 minutes). */
|
|
77
|
+
timeoutSeconds?: number;
|
|
78
|
+
/** Warnings about common footguns. Defaults include tempo wallet transfer + raw on-chain x402 deposits. */
|
|
79
|
+
warnings?: string[];
|
|
80
|
+
/** Additional warnings appended to the default protocol-footgun set. Use this when you want
|
|
81
|
+
* to keep the SDK's protocol warnings AND add merchant-specific notes (e.g., a per-order
|
|
82
|
+
* rail-availability message). Ignored when `warnings` is set explicitly. */
|
|
83
|
+
extraWarnings?: string[];
|
|
84
|
+
/** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
|
|
85
|
+
recommended?: string;
|
|
86
|
+
/** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
|
|
87
|
+
* this from their own smoke matrix — defaults to none (avoids vouching for clients the
|
|
88
|
+
* merchant has not tested). When omitted, the field is not emitted. */
|
|
89
|
+
compatibleClients?: CompatibleClients;
|
|
90
|
+
/** Arbitrary additional fields the vendor wants merged into the agent_instructions object. */
|
|
91
|
+
extra?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
interface AgentInstructions {
|
|
94
|
+
how_to_pay: HowToPayBlock;
|
|
95
|
+
recommended_tools: string[];
|
|
96
|
+
wallet_compatibility: string;
|
|
97
|
+
timeout_seconds: number;
|
|
98
|
+
warnings: string[];
|
|
99
|
+
recommended?: string;
|
|
100
|
+
compatible_clients?: CompatibleClients;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Default `compatible_clients` derived from the rails declared in `howToPay`. Lists
|
|
105
|
+
* clients the AgentScore team has smoke-verified end-to-end against an `@agent-score/commerce`
|
|
106
|
+
* merchant; entries appear only for rails the vendor actually offers. Vendors override
|
|
107
|
+
* this in `buildAgentInstructions({compatibleClients: {...}})` to add their own tested
|
|
108
|
+
* clients or remove entries that don't fit their endpoint.
|
|
109
|
+
*
|
|
110
|
+
* Verified state as of the SDK release. The same data is also published as a docs page
|
|
111
|
+
* for humans (rationale, per-rail commands, why some clients don't fully work, last
|
|
112
|
+
* verified date) — this default keeps the merchant-side surface in sync.
|
|
113
|
+
*/
|
|
114
|
+
/** Symbolic rail keys agent-facing surfaces use to talk about a rail without spelling out
|
|
115
|
+
* network/scheme details. Same keys as `CompatibleClients` map keys. */
|
|
116
|
+
type RailKey = 'tempo_mpp' | 'x402_base' | 'solana_mpp' | 'stripe';
|
|
117
|
+
/** Returns the smoke-verified client list for a set of rail keys. The single source of
|
|
118
|
+
* truth for "which CLIs we've verified end-to-end on each rail" — consumed both by the
|
|
119
|
+
* 402-body builder (`defaultCompatibleClients`) and by discovery surfaces (skill.md,
|
|
120
|
+
* llms.txt, etc.). Update here, every surface inherits. */
|
|
121
|
+
declare function compatibleClientsByRails(rails: readonly RailKey[]): CompatibleClients | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Build the agent_instructions object for the 402 body. Combines how_to_pay with
|
|
124
|
+
* recommended tools, warnings, wallet-compatibility note, and timeout.
|
|
125
|
+
*
|
|
126
|
+
* Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
|
|
127
|
+
* appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base` is set.
|
|
128
|
+
* Stripe-only merchants get neither rail-specific warning. Vendors override
|
|
129
|
+
* `warnings`/`recommendedTools` for full control.
|
|
130
|
+
*/
|
|
131
|
+
declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
|
|
132
|
+
|
|
133
|
+
export { type AgentInstructions as A, type BuildAgentInstructionsInput as B, type CompatibleClients as C, type HowToPayBlock as H, type RailKey as R, type BuildHowToPayInput as a, type HowToPayRailEntry as b, type HowToPayStripeEntry as c, buildAgentInstructions as d, buildHowToPay as e, compatibleClientsByRails as f };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
interface HowToPayRailEntry {
|
|
2
|
+
setup?: string[];
|
|
3
|
+
prerequisite?: string;
|
|
4
|
+
command: string;
|
|
5
|
+
alternative_command?: string;
|
|
6
|
+
what_it_does: string;
|
|
7
|
+
}
|
|
8
|
+
interface HowToPayStripeEntry {
|
|
9
|
+
prerequisite: string;
|
|
10
|
+
instructions: string;
|
|
11
|
+
setup_link_cli?: string[];
|
|
12
|
+
command_link_cli?: string[];
|
|
13
|
+
what_it_does_link_cli?: string;
|
|
14
|
+
note?: string;
|
|
15
|
+
}
|
|
16
|
+
interface HowToPayBlock {
|
|
17
|
+
tempo?: HowToPayRailEntry;
|
|
18
|
+
x402_base?: HowToPayRailEntry;
|
|
19
|
+
solana_mpp?: HowToPayRailEntry;
|
|
20
|
+
stripe?: HowToPayStripeEntry;
|
|
21
|
+
}
|
|
22
|
+
interface BuildHowToPayInput {
|
|
23
|
+
/** The merchant's full URL (e.g., 'https://agents.merchant.example/api/buy'). */
|
|
24
|
+
url: string;
|
|
25
|
+
/** JSON string of the body the agent should retry with — typically the original request body. */
|
|
26
|
+
retryBodyJson: string;
|
|
27
|
+
/** Total amount in USD (string or number). Used to compute max-spend defaults and stripe context. */
|
|
28
|
+
totalUsd: string | number;
|
|
29
|
+
/** Per-rail config — each is optional. Pass only the rails you support. */
|
|
30
|
+
rails: {
|
|
31
|
+
tempo?: {
|
|
32
|
+
recipient: string;
|
|
33
|
+
networkName?: string;
|
|
34
|
+
chainId?: number;
|
|
35
|
+
recommend?: 'tempo' | 'agentscore-pay' | 'both';
|
|
36
|
+
};
|
|
37
|
+
x402_base?: {
|
|
38
|
+
recipient: string;
|
|
39
|
+
network?: string;
|
|
40
|
+
};
|
|
41
|
+
solana_mpp?: {
|
|
42
|
+
recipient: string;
|
|
43
|
+
network?: string;
|
|
44
|
+
};
|
|
45
|
+
stripe?: {
|
|
46
|
+
profileId?: string | null;
|
|
47
|
+
productName?: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'. */
|
|
51
|
+
opTokenPlaceholder?: string;
|
|
52
|
+
/** Override max-spend value used in commands. Default: ceil(totalUsd) + 1. */
|
|
53
|
+
maxSpend?: string | number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the agent_instructions.how_to_pay block. Generates per-rail setup/command/what_it_does
|
|
57
|
+
* boilerplate so agents see concrete commands per rail in the 402 body. Vendors pass the rails
|
|
58
|
+
* they support; the helper produces the right command for each.
|
|
59
|
+
*
|
|
60
|
+
* Tool recommendations (tempo CLI vs agentscore-pay vs link-cli) are configurable per rail.
|
|
61
|
+
*/
|
|
62
|
+
declare function buildHowToPay(input: BuildHowToPayInput): HowToPayBlock;
|
|
63
|
+
|
|
64
|
+
/** Map of rail key (e.g. 'x402_base', 'tempo_mpp', 'stripe') → list of client identifiers
|
|
65
|
+
* that have been smoke-verified by the merchant against the protocol shape they emit.
|
|
66
|
+
* Strings are display labels, not install commands — agents already get install commands
|
|
67
|
+
* via `how_to_pay.<rail>.setup`. Use these as a "what's known to work" hint. */
|
|
68
|
+
type CompatibleClients = Record<string, string[]>;
|
|
69
|
+
interface BuildAgentInstructionsInput {
|
|
70
|
+
/** Per-rail commands. Build with `buildHowToPay`. */
|
|
71
|
+
howToPay: HowToPayBlock;
|
|
72
|
+
/** Tool recommendations as human-readable strings. Defaults to a sensible set covering tempo + agentscore-pay. */
|
|
73
|
+
recommendedTools?: string[];
|
|
74
|
+
/** Wallet-stack compatibility note for the agent. Default: rail-neutral, no specific wallet stack required. */
|
|
75
|
+
walletCompatibility?: string;
|
|
76
|
+
/** How long the merchant will wait for payment after the 402. Default 300 (5 minutes). */
|
|
77
|
+
timeoutSeconds?: number;
|
|
78
|
+
/** Warnings about common footguns. Defaults include tempo wallet transfer + raw on-chain x402 deposits. */
|
|
79
|
+
warnings?: string[];
|
|
80
|
+
/** Additional warnings appended to the default protocol-footgun set. Use this when you want
|
|
81
|
+
* to keep the SDK's protocol warnings AND add merchant-specific notes (e.g., a per-order
|
|
82
|
+
* rail-availability message). Ignored when `warnings` is set explicitly. */
|
|
83
|
+
extraWarnings?: string[];
|
|
84
|
+
/** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
|
|
85
|
+
recommended?: string;
|
|
86
|
+
/** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
|
|
87
|
+
* this from their own smoke matrix — defaults to none (avoids vouching for clients the
|
|
88
|
+
* merchant has not tested). When omitted, the field is not emitted. */
|
|
89
|
+
compatibleClients?: CompatibleClients;
|
|
90
|
+
/** Arbitrary additional fields the vendor wants merged into the agent_instructions object. */
|
|
91
|
+
extra?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
interface AgentInstructions {
|
|
94
|
+
how_to_pay: HowToPayBlock;
|
|
95
|
+
recommended_tools: string[];
|
|
96
|
+
wallet_compatibility: string;
|
|
97
|
+
timeout_seconds: number;
|
|
98
|
+
warnings: string[];
|
|
99
|
+
recommended?: string;
|
|
100
|
+
compatible_clients?: CompatibleClients;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Default `compatible_clients` derived from the rails declared in `howToPay`. Lists
|
|
105
|
+
* clients the AgentScore team has smoke-verified end-to-end against an `@agent-score/commerce`
|
|
106
|
+
* merchant; entries appear only for rails the vendor actually offers. Vendors override
|
|
107
|
+
* this in `buildAgentInstructions({compatibleClients: {...}})` to add their own tested
|
|
108
|
+
* clients or remove entries that don't fit their endpoint.
|
|
109
|
+
*
|
|
110
|
+
* Verified state as of the SDK release. The same data is also published as a docs page
|
|
111
|
+
* for humans (rationale, per-rail commands, why some clients don't fully work, last
|
|
112
|
+
* verified date) — this default keeps the merchant-side surface in sync.
|
|
113
|
+
*/
|
|
114
|
+
/** Symbolic rail keys agent-facing surfaces use to talk about a rail without spelling out
|
|
115
|
+
* network/scheme details. Same keys as `CompatibleClients` map keys. */
|
|
116
|
+
type RailKey = 'tempo_mpp' | 'x402_base' | 'solana_mpp' | 'stripe';
|
|
117
|
+
/** Returns the smoke-verified client list for a set of rail keys. The single source of
|
|
118
|
+
* truth for "which CLIs we've verified end-to-end on each rail" — consumed both by the
|
|
119
|
+
* 402-body builder (`defaultCompatibleClients`) and by discovery surfaces (skill.md,
|
|
120
|
+
* llms.txt, etc.). Update here, every surface inherits. */
|
|
121
|
+
declare function compatibleClientsByRails(rails: readonly RailKey[]): CompatibleClients | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Build the agent_instructions object for the 402 body. Combines how_to_pay with
|
|
124
|
+
* recommended tools, warnings, wallet-compatibility note, and timeout.
|
|
125
|
+
*
|
|
126
|
+
* Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
|
|
127
|
+
* appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base` is set.
|
|
128
|
+
* Stripe-only merchants get neither rail-specific warning. Vendors override
|
|
129
|
+
* `warnings`/`recommendedTools` for full control.
|
|
130
|
+
*/
|
|
131
|
+
declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
|
|
132
|
+
|
|
133
|
+
export { type AgentInstructions as A, type BuildAgentInstructionsInput as B, type CompatibleClients as C, type HowToPayBlock as H, type RailKey as R, type BuildHowToPayInput as a, type HowToPayRailEntry as b, type HowToPayStripeEntry as c, buildAgentInstructions as d, buildHowToPay as e, compatibleClientsByRails as f };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { A as AgentInstructions } from '../agent_instructions-DiMSGkdm.mjs';
|
|
2
|
+
export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, c as HowToPayStripeEntry, R as RailKey, d as buildAgentInstructions, e as buildHowToPay, f as compatibleClientsByRails } from '../agent_instructions-DiMSGkdm.mjs';
|
|
1
3
|
import { AgentMemoryHint } from '../core.mjs';
|
|
2
4
|
export { buildAgentMemoryHint } from '../core.mjs';
|
|
3
5
|
import { P as PaymentRequiredHeaderInput } from '../wwwauthenticate-CU1eNvMQ.mjs';
|
|
@@ -20,12 +22,21 @@ interface X402MethodEntry {
|
|
|
20
22
|
decimals: number;
|
|
21
23
|
pay_to: string;
|
|
22
24
|
}
|
|
25
|
+
interface SolanaMppMethodEntry {
|
|
26
|
+
method: 'solana/charge';
|
|
27
|
+
network: string;
|
|
28
|
+
token: string;
|
|
29
|
+
symbol: string;
|
|
30
|
+
decimals: number;
|
|
31
|
+
pay_to: string;
|
|
32
|
+
fee_payer_key?: string;
|
|
33
|
+
}
|
|
23
34
|
interface StripeMethodEntry {
|
|
24
35
|
method: 'stripe/charge';
|
|
25
36
|
rails: ('card' | 'link' | 'shared_payment_token')[];
|
|
26
37
|
profile_id: string | null;
|
|
27
38
|
}
|
|
28
|
-
type AcceptedMethodEntry = TempoMethodEntry | X402MethodEntry | StripeMethodEntry;
|
|
39
|
+
type AcceptedMethodEntry = TempoMethodEntry | X402MethodEntry | SolanaMppMethodEntry | StripeMethodEntry;
|
|
29
40
|
interface BuildAcceptedMethodsInput {
|
|
30
41
|
tempo?: {
|
|
31
42
|
recipient: string;
|
|
@@ -43,12 +54,13 @@ interface BuildAcceptedMethodsInput {
|
|
|
43
54
|
symbol?: string;
|
|
44
55
|
decimals?: number;
|
|
45
56
|
};
|
|
46
|
-
|
|
57
|
+
solana_mpp?: {
|
|
47
58
|
recipient: string;
|
|
48
59
|
network?: string;
|
|
49
60
|
token?: string;
|
|
50
61
|
symbol?: string;
|
|
51
62
|
decimals?: number;
|
|
63
|
+
feePayerKey?: string;
|
|
52
64
|
};
|
|
53
65
|
stripe?: {
|
|
54
66
|
profileId?: string | null;
|
|
@@ -95,115 +107,6 @@ interface IdentityMetadataBlock {
|
|
|
95
107
|
*/
|
|
96
108
|
declare function buildIdentityMetadata(input: IdentityMetadataInput): IdentityMetadataBlock;
|
|
97
109
|
|
|
98
|
-
interface HowToPayRailEntry {
|
|
99
|
-
setup?: string[];
|
|
100
|
-
prerequisite?: string;
|
|
101
|
-
command: string;
|
|
102
|
-
alternative_command?: string;
|
|
103
|
-
what_it_does: string;
|
|
104
|
-
}
|
|
105
|
-
interface HowToPayStripeEntry {
|
|
106
|
-
prerequisite: string;
|
|
107
|
-
instructions: string;
|
|
108
|
-
setup_link_cli?: string[];
|
|
109
|
-
command_link_cli?: string[];
|
|
110
|
-
what_it_does_link_cli?: string;
|
|
111
|
-
note?: string;
|
|
112
|
-
}
|
|
113
|
-
interface HowToPayBlock {
|
|
114
|
-
tempo?: HowToPayRailEntry;
|
|
115
|
-
x402_base?: HowToPayRailEntry;
|
|
116
|
-
x402_solana?: HowToPayRailEntry;
|
|
117
|
-
stripe?: HowToPayStripeEntry;
|
|
118
|
-
}
|
|
119
|
-
interface BuildHowToPayInput {
|
|
120
|
-
/** The merchant's full URL (e.g., 'https://agents.merchant.example/api/buy'). */
|
|
121
|
-
url: string;
|
|
122
|
-
/** JSON string of the body the agent should retry with — typically the original request body. */
|
|
123
|
-
retryBodyJson: string;
|
|
124
|
-
/** Total amount in USD (string or number). Used to compute max-spend defaults and stripe context. */
|
|
125
|
-
totalUsd: string | number;
|
|
126
|
-
/** Per-rail config — each is optional. Pass only the rails you support. */
|
|
127
|
-
rails: {
|
|
128
|
-
tempo?: {
|
|
129
|
-
recipient: string;
|
|
130
|
-
networkName?: string;
|
|
131
|
-
chainId?: number;
|
|
132
|
-
recommend?: 'tempo' | 'agentscore-pay' | 'both';
|
|
133
|
-
};
|
|
134
|
-
x402_base?: {
|
|
135
|
-
recipient: string;
|
|
136
|
-
network?: string;
|
|
137
|
-
};
|
|
138
|
-
x402_solana?: {
|
|
139
|
-
recipient: string;
|
|
140
|
-
network?: string;
|
|
141
|
-
};
|
|
142
|
-
stripe?: {
|
|
143
|
-
profileId?: string | null;
|
|
144
|
-
productName?: string;
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'. */
|
|
148
|
-
opTokenPlaceholder?: string;
|
|
149
|
-
/** Override max-spend value used in commands. Default: ceil(totalUsd) + 1. */
|
|
150
|
-
maxSpend?: string | number;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Build the agent_instructions.how_to_pay block. Generates per-rail setup/command/what_it_does
|
|
154
|
-
* boilerplate so agents see concrete commands per rail in the 402 body. Vendors pass the rails
|
|
155
|
-
* they support; the helper produces the right command for each.
|
|
156
|
-
*
|
|
157
|
-
* Tool recommendations (tempo CLI vs agentscore-pay vs link-cli) are configurable per rail.
|
|
158
|
-
*/
|
|
159
|
-
declare function buildHowToPay(input: BuildHowToPayInput): HowToPayBlock;
|
|
160
|
-
|
|
161
|
-
/** Map of rail key (e.g. 'x402_base', 'tempo_mpp', 'stripe') → list of client identifiers
|
|
162
|
-
* that have been smoke-verified by the merchant against the protocol shape they emit.
|
|
163
|
-
* Strings are display labels, not install commands — agents already get install commands
|
|
164
|
-
* via `how_to_pay.<rail>.setup`. Use these as a "what's known to work" hint. */
|
|
165
|
-
type CompatibleClients = Record<string, string[]>;
|
|
166
|
-
interface BuildAgentInstructionsInput {
|
|
167
|
-
/** Per-rail commands. Build with `buildHowToPay`. */
|
|
168
|
-
howToPay: HowToPayBlock;
|
|
169
|
-
/** Tool recommendations as human-readable strings. Defaults to a sensible set covering tempo + agentscore-pay. */
|
|
170
|
-
recommendedTools?: string[];
|
|
171
|
-
/** Wallet-stack compatibility note for the agent. Default: rail-neutral, no specific wallet stack required. */
|
|
172
|
-
walletCompatibility?: string;
|
|
173
|
-
/** How long the merchant will wait for payment after the 402. Default 300 (5 minutes). */
|
|
174
|
-
timeoutSeconds?: number;
|
|
175
|
-
/** Warnings about common footguns. Defaults include tempo wallet transfer + raw on-chain x402 deposits. */
|
|
176
|
-
warnings?: string[];
|
|
177
|
-
/** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
|
|
178
|
-
recommended?: string;
|
|
179
|
-
/** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
|
|
180
|
-
* this from their own smoke matrix — defaults to none (avoids vouching for clients the
|
|
181
|
-
* merchant has not tested). When omitted, the field is not emitted. */
|
|
182
|
-
compatibleClients?: CompatibleClients;
|
|
183
|
-
/** Arbitrary additional fields the vendor wants merged into the agent_instructions object. */
|
|
184
|
-
extra?: Record<string, unknown>;
|
|
185
|
-
}
|
|
186
|
-
interface AgentInstructions {
|
|
187
|
-
how_to_pay: HowToPayBlock;
|
|
188
|
-
recommended_tools: string[];
|
|
189
|
-
wallet_compatibility: string;
|
|
190
|
-
timeout_seconds: number;
|
|
191
|
-
warnings: string[];
|
|
192
|
-
recommended?: string;
|
|
193
|
-
compatible_clients?: CompatibleClients;
|
|
194
|
-
[key: string]: unknown;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Build the agent_instructions object for the 402 body. Combines how_to_pay with
|
|
198
|
-
* recommended tools, warnings, wallet-compatibility note, and timeout.
|
|
199
|
-
*
|
|
200
|
-
* Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
|
|
201
|
-
* appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base`/`x402_solana`
|
|
202
|
-
* are set. Stripe-only merchants get neither rail-specific warning. Vendors override
|
|
203
|
-
* `warnings`/`recommendedTools` for full control.
|
|
204
|
-
*/
|
|
205
|
-
declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
|
|
206
|
-
|
|
207
110
|
/**
|
|
208
111
|
* Helpers for emitting the cross-merchant `agent_memory` hint on merchant 402 responses.
|
|
209
112
|
*
|
|
@@ -366,10 +269,9 @@ declare function build402Body(input: Build402BodyInput): Record<string, unknown>
|
|
|
366
269
|
/**
|
|
367
270
|
* Canonical order-receipt shape returned to agents on the 200 after a successful settlement.
|
|
368
271
|
*
|
|
369
|
-
* Merchants own their order schema, but converging on this shape across
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* care about, and ignore (or extend via `extras`) what you don't.
|
|
272
|
+
* Merchants own their order schema, but converging on this shape across AgentScore-gated
|
|
273
|
+
* merchants means agents can render and post-process orders consistently. Lift this type,
|
|
274
|
+
* fill the fields you care about, and ignore (or extend via `extras`) what you don't.
|
|
373
275
|
*
|
|
374
276
|
* All money fields are dollar-strings (e.g. `"250.00"`). Use `buildPricingBlock` from
|
|
375
277
|
* `@agent-score/commerce/challenge` to compose the pricing fields from cents.
|
|
@@ -520,4 +422,4 @@ interface ValidationErrorBody {
|
|
|
520
422
|
*/
|
|
521
423
|
declare function buildValidationError(input: BuildValidationErrorInput): ValidationErrorBody;
|
|
522
424
|
|
|
523
|
-
export { type AcceptedMethodEntry,
|
|
425
|
+
export { type AcceptedMethodEntry, AgentInstructions, AgentMemoryHint, type Build402BodyInput, type BuildAcceptedMethodsInput, type BuildPricingBlockInput, type BuildValidationErrorInput, type FirstEncounterAgentMemoryInput, type IdentityMetadataBlock, type IdentityMetadataInput, type IdentityMode, type OrderReceipt, type PricingBlock, type Respond402Input, type SignerMatchResultLike, type SolanaMppMethodEntry, type StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
|