@agent-score/commerce 1.0.3 → 1.2.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 +28 -1
- package/dist/agent_instructions-d3UWTdam.d.mts +129 -0
- package/dist/agent_instructions-d3UWTdam.d.ts +129 -0
- package/dist/challenge/index.d.mts +3 -110
- package/dist/challenge/index.d.ts +3 -110
- package/dist/challenge/index.js +76 -5
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +82 -5
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/core.d.mts +28 -1
- package/dist/core.d.ts +28 -1
- package/dist/core.js +237 -157
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +246 -157
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +120 -1
- package/dist/discovery/index.d.ts +120 -1
- package/dist/discovery/index.js +204 -0
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +202 -0
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/identity/express.d.mts +18 -2
- package/dist/identity/express.d.ts +18 -2
- package/dist/identity/express.js +227 -164
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +232 -164
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +17 -2
- package/dist/identity/fastify.d.ts +17 -2
- package/dist/identity/fastify.js +227 -164
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +232 -164
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +22 -2
- package/dist/identity/hono.d.ts +22 -2
- package/dist/identity/hono.js +227 -164
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +232 -164
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +8 -1
- package/dist/identity/nextjs.d.ts +8 -1
- package/dist/identity/nextjs.js +213 -166
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +220 -166
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/web.d.mts +15 -1
- package/dist/identity/web.d.ts +15 -1
- package/dist/identity/web.js +213 -166
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +220 -166
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.js +120 -101
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -101
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs.map +1 -1
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm install hono mppx @x402/core @x402/evm @x402/svm stripe # whatever your st
|
|
|
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
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). |
|
|
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. |
|
|
@@ -278,6 +278,33 @@ app.post("/purchase", async (c) => {
|
|
|
278
278
|
});
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
+
## Fail-open behavior
|
|
282
|
+
|
|
283
|
+
By default AgentScore Gate fails closed: any AgentScore-side infrastructure failure (HTTP 429, 5xx, network timeout) returns 503 to the buyer. Set `failOpen: true` on `agentscoreGate({...})` to opt in to graceful degradation:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import { agentscoreGate, getGateDegradedState } from '@agent-score/commerce/identity/hono';
|
|
287
|
+
|
|
288
|
+
const gate = agentscoreGate({ apiKey: process.env.AGENTSCORE_API_KEY!, failOpen: true });
|
|
289
|
+
|
|
290
|
+
app.use('/purchase', gate);
|
|
291
|
+
|
|
292
|
+
app.post('/purchase', async (c) => {
|
|
293
|
+
const { degraded, infraReason } = getGateDegradedState(c);
|
|
294
|
+
if (degraded) {
|
|
295
|
+
// Compliance was NOT enforced this request — log/alert/refund-async/etc.
|
|
296
|
+
console.warn(`[gate] degraded: ${infraReason}`);
|
|
297
|
+
}
|
|
298
|
+
// ...rest of handler
|
|
299
|
+
});
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
When `failOpen: true` AND the failure is infra-shape, the gate carries `degraded: true` + `infraReason: 'quota_exceeded' | 'api_error' | 'network_timeout'` so merchants can log/alert without parsing console output. **Compliance denials (sanctions, age, jurisdiction, signer-mismatch) still deny regardless of `failOpen`** — `failOpen` only covers "AgentScore couldn't tell us," never "AgentScore said no."
|
|
303
|
+
|
|
304
|
+
For regulated commerce (alcohol, age-gated, sanctioned-jurisdiction-relevant) keep the default `failOpen: false` — outage is the correct posture; bypassing compliance on infra failure is a compliance gap. For low-stakes commerce or high-uptime SLAs, opt in and use the `degraded` flag as the audit trail.
|
|
305
|
+
|
|
306
|
+
The `getGateDegradedState` helper is exported by every framework adapter (Hono, Express, Fastify, Next.js, Web Fetch). For `withAgentScoreGate` (Next.js / Web Fetch), the `degraded` + `infraReason` fields land directly on the `gate` object passed to your handler.
|
|
307
|
+
|
|
281
308
|
## Examples
|
|
282
309
|
|
|
283
310
|
The [examples/](./examples) directory has 7 runnable single-file Hono apps covering common merchant scenarios — copy-paste templates, not frameworks. See [examples/README.md](./examples/README.md) for the full table.
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
x402_solana?: 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
|
+
x402_solana?: {
|
|
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
|
+
/** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
|
|
81
|
+
recommended?: string;
|
|
82
|
+
/** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
|
|
83
|
+
* this from their own smoke matrix — defaults to none (avoids vouching for clients the
|
|
84
|
+
* merchant has not tested). When omitted, the field is not emitted. */
|
|
85
|
+
compatibleClients?: CompatibleClients;
|
|
86
|
+
/** Arbitrary additional fields the vendor wants merged into the agent_instructions object. */
|
|
87
|
+
extra?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
interface AgentInstructions {
|
|
90
|
+
how_to_pay: HowToPayBlock;
|
|
91
|
+
recommended_tools: string[];
|
|
92
|
+
wallet_compatibility: string;
|
|
93
|
+
timeout_seconds: number;
|
|
94
|
+
warnings: string[];
|
|
95
|
+
recommended?: string;
|
|
96
|
+
compatible_clients?: CompatibleClients;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Default `compatible_clients` derived from the rails declared in `howToPay`. Lists
|
|
101
|
+
* clients the AgentScore team has smoke-verified end-to-end against an `@agent-score/commerce`
|
|
102
|
+
* merchant; entries appear only for rails the vendor actually offers. Vendors override
|
|
103
|
+
* this in `buildAgentInstructions({compatibleClients: {...}})` to add their own tested
|
|
104
|
+
* clients or remove entries that don't fit their endpoint.
|
|
105
|
+
*
|
|
106
|
+
* Verified state as of the SDK release. The same data is also published as a docs page
|
|
107
|
+
* for humans (rationale, per-rail commands, why some clients don't fully work, last
|
|
108
|
+
* verified date) — this default keeps the merchant-side surface in sync.
|
|
109
|
+
*/
|
|
110
|
+
/** Symbolic rail keys agent-facing surfaces use to talk about a rail without spelling out
|
|
111
|
+
* network/scheme details. Same keys as `CompatibleClients` map keys. */
|
|
112
|
+
type RailKey = 'tempo_mpp' | 'x402_base' | 'x402_solana' | 'stripe';
|
|
113
|
+
/** Returns the smoke-verified client list for a set of rail keys. The single source of
|
|
114
|
+
* truth for "which CLIs we've verified end-to-end on each rail" — consumed both by the
|
|
115
|
+
* 402-body builder (`defaultCompatibleClients`) and by discovery surfaces (skill.md,
|
|
116
|
+
* llms.txt, etc.). Update here, every surface inherits. */
|
|
117
|
+
declare function compatibleClientsByRails(rails: readonly RailKey[]): CompatibleClients | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Build the agent_instructions object for the 402 body. Combines how_to_pay with
|
|
120
|
+
* recommended tools, warnings, wallet-compatibility note, and timeout.
|
|
121
|
+
*
|
|
122
|
+
* Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
|
|
123
|
+
* appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base`/`x402_solana`
|
|
124
|
+
* are set. Stripe-only merchants get neither rail-specific warning. Vendors override
|
|
125
|
+
* `warnings`/`recommendedTools` for full control.
|
|
126
|
+
*/
|
|
127
|
+
declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
|
|
128
|
+
|
|
129
|
+
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, compatibleClientsByRails as c, type HowToPayStripeEntry as d, buildAgentInstructions as e, buildHowToPay as f };
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
x402_solana?: 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
|
+
x402_solana?: {
|
|
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
|
+
/** Recommended rail (e.g., 'tempo', 'x402_base'). Surfaced for agents to default to. */
|
|
81
|
+
recommended?: string;
|
|
82
|
+
/** Per-rail list of client names the merchant has verified work end-to-end. Vendors set
|
|
83
|
+
* this from their own smoke matrix — defaults to none (avoids vouching for clients the
|
|
84
|
+
* merchant has not tested). When omitted, the field is not emitted. */
|
|
85
|
+
compatibleClients?: CompatibleClients;
|
|
86
|
+
/** Arbitrary additional fields the vendor wants merged into the agent_instructions object. */
|
|
87
|
+
extra?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
interface AgentInstructions {
|
|
90
|
+
how_to_pay: HowToPayBlock;
|
|
91
|
+
recommended_tools: string[];
|
|
92
|
+
wallet_compatibility: string;
|
|
93
|
+
timeout_seconds: number;
|
|
94
|
+
warnings: string[];
|
|
95
|
+
recommended?: string;
|
|
96
|
+
compatible_clients?: CompatibleClients;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Default `compatible_clients` derived from the rails declared in `howToPay`. Lists
|
|
101
|
+
* clients the AgentScore team has smoke-verified end-to-end against an `@agent-score/commerce`
|
|
102
|
+
* merchant; entries appear only for rails the vendor actually offers. Vendors override
|
|
103
|
+
* this in `buildAgentInstructions({compatibleClients: {...}})` to add their own tested
|
|
104
|
+
* clients or remove entries that don't fit their endpoint.
|
|
105
|
+
*
|
|
106
|
+
* Verified state as of the SDK release. The same data is also published as a docs page
|
|
107
|
+
* for humans (rationale, per-rail commands, why some clients don't fully work, last
|
|
108
|
+
* verified date) — this default keeps the merchant-side surface in sync.
|
|
109
|
+
*/
|
|
110
|
+
/** Symbolic rail keys agent-facing surfaces use to talk about a rail without spelling out
|
|
111
|
+
* network/scheme details. Same keys as `CompatibleClients` map keys. */
|
|
112
|
+
type RailKey = 'tempo_mpp' | 'x402_base' | 'x402_solana' | 'stripe';
|
|
113
|
+
/** Returns the smoke-verified client list for a set of rail keys. The single source of
|
|
114
|
+
* truth for "which CLIs we've verified end-to-end on each rail" — consumed both by the
|
|
115
|
+
* 402-body builder (`defaultCompatibleClients`) and by discovery surfaces (skill.md,
|
|
116
|
+
* llms.txt, etc.). Update here, every surface inherits. */
|
|
117
|
+
declare function compatibleClientsByRails(rails: readonly RailKey[]): CompatibleClients | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Build the agent_instructions object for the 402 body. Combines how_to_pay with
|
|
120
|
+
* recommended tools, warnings, wallet-compatibility note, and timeout.
|
|
121
|
+
*
|
|
122
|
+
* Defaults adapt to the rails declared in `howToPay`: only tempo-relevant warnings/tools
|
|
123
|
+
* appear if `howToPay.tempo` is set, only x402-relevant ones if `x402_base`/`x402_solana`
|
|
124
|
+
* are set. Stripe-only merchants get neither rail-specific warning. Vendors override
|
|
125
|
+
* `warnings`/`recommendedTools` for full control.
|
|
126
|
+
*/
|
|
127
|
+
declare function buildAgentInstructions(input: BuildAgentInstructionsInput): AgentInstructions;
|
|
128
|
+
|
|
129
|
+
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, compatibleClientsByRails as c, type HowToPayStripeEntry as d, buildAgentInstructions as e, buildHowToPay as f };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { A as AgentInstructions } from '../agent_instructions-d3UWTdam.mjs';
|
|
2
|
+
export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, d as HowToPayStripeEntry, R as RailKey, e as buildAgentInstructions, f as buildHowToPay, c as compatibleClientsByRails } from '../agent_instructions-d3UWTdam.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';
|
|
@@ -95,115 +97,6 @@ interface IdentityMetadataBlock {
|
|
|
95
97
|
*/
|
|
96
98
|
declare function buildIdentityMetadata(input: IdentityMetadataInput): IdentityMetadataBlock;
|
|
97
99
|
|
|
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
100
|
/**
|
|
208
101
|
* Helpers for emitting the cross-merchant `agent_memory` hint on merchant 402 responses.
|
|
209
102
|
*
|
|
@@ -520,4 +413,4 @@ interface ValidationErrorBody {
|
|
|
520
413
|
*/
|
|
521
414
|
declare function buildValidationError(input: BuildValidationErrorInput): ValidationErrorBody;
|
|
522
415
|
|
|
523
|
-
export { type AcceptedMethodEntry,
|
|
416
|
+
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 StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { A as AgentInstructions } from '../agent_instructions-d3UWTdam.js';
|
|
2
|
+
export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as CompatibleClients, H as HowToPayBlock, b as HowToPayRailEntry, d as HowToPayStripeEntry, R as RailKey, e as buildAgentInstructions, f as buildHowToPay, c as compatibleClientsByRails } from '../agent_instructions-d3UWTdam.js';
|
|
1
3
|
import { AgentMemoryHint } from '../core.js';
|
|
2
4
|
export { buildAgentMemoryHint } from '../core.js';
|
|
3
5
|
import { P as PaymentRequiredHeaderInput } from '../wwwauthenticate-CU1eNvMQ.js';
|
|
@@ -95,115 +97,6 @@ interface IdentityMetadataBlock {
|
|
|
95
97
|
*/
|
|
96
98
|
declare function buildIdentityMetadata(input: IdentityMetadataInput): IdentityMetadataBlock;
|
|
97
99
|
|
|
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
100
|
/**
|
|
208
101
|
* Helpers for emitting the cross-merchant `agent_memory` hint on merchant 402 responses.
|
|
209
102
|
*
|
|
@@ -520,4 +413,4 @@ interface ValidationErrorBody {
|
|
|
520
413
|
*/
|
|
521
414
|
declare function buildValidationError(input: BuildValidationErrorInput): ValidationErrorBody;
|
|
522
415
|
|
|
523
|
-
export { type AcceptedMethodEntry,
|
|
416
|
+
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 StripeMethodEntry, type TempoMethodEntry, type ValidationErrorBody, type X402MethodEntry, build402Body, buildAcceptedMethods, buildIdentityMetadata, buildPricingBlock, buildValidationError, firstEncounterAgentMemory, respond402 };
|