@absol-labs/agent 0.11.0 → 0.12.0-rc.2
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 +43 -51
- package/dist/capability/invocation-capability.d.ts +2 -2
- package/dist/capability/probe-capability.d.ts +225 -0
- package/dist/capability/probe-capability.d.ts.map +1 -0
- package/dist/capability/probe-capability.js +248 -0
- package/dist/capability/probe-capability.js.map +1 -0
- package/dist/cli/args.d.ts +11 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +23 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/claim.d.ts +32 -0
- package/dist/cli/commands/claim.d.ts.map +1 -1
- package/dist/cli/commands/claim.js +116 -28
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.d.ts.map +1 -1
- package/dist/cli/commands/close.js +35 -3
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/invoke.d.ts +2 -0
- package/dist/cli/commands/invoke.d.ts.map +1 -1
- package/dist/cli/commands/invoke.js +2 -2
- package/dist/cli/commands/invoke.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +15 -2
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/open.d.ts.map +1 -1
- package/dist/cli/commands/open.js +58 -4
- package/dist/cli/commands/open.js.map +1 -1
- package/dist/cli/commands/pay.d.ts +34 -0
- package/dist/cli/commands/pay.d.ts.map +1 -0
- package/dist/cli/commands/pay.js +479 -0
- package/dist/cli/commands/pay.js.map +1 -0
- package/dist/cli/commands/reclaim-unverified.d.ts.map +1 -1
- package/dist/cli/commands/reclaim-unverified.js +3 -2
- package/dist/cli/commands/reclaim-unverified.js.map +1 -1
- package/dist/cli/commands/reclaim.d.ts +23 -2
- package/dist/cli/commands/reclaim.d.ts.map +1 -1
- package/dist/cli/commands/reclaim.js +204 -20
- package/dist/cli/commands/reclaim.js.map +1 -1
- package/dist/cli/commands/refund.d.ts +31 -0
- package/dist/cli/commands/refund.d.ts.map +1 -0
- package/dist/cli/commands/refund.js +397 -0
- package/dist/cli/commands/refund.js.map +1 -0
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +21 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/streams.js +8 -12
- package/dist/cli/commands/streams.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +4 -1
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/config.d.ts +44 -26
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +88 -38
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/context.d.ts +19 -0
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/deps.d.ts +53 -0
- package/dist/cli/deps.d.ts.map +1 -1
- package/dist/cli/deps.js +51 -1
- package/dist/cli/deps.js.map +1 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +21 -1
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/escape-hatch.d.ts +6 -4
- package/dist/cli/escape-hatch.d.ts.map +1 -1
- package/dist/cli/escape-hatch.js +6 -2
- package/dist/cli/escape-hatch.js.map +1 -1
- package/dist/cli/listings.d.ts +18 -0
- package/dist/cli/listings.d.ts.map +1 -1
- package/dist/cli/listings.js +22 -12
- package/dist/cli/listings.js.map +1 -1
- package/dist/cli/preflight.d.ts +20 -14
- package/dist/cli/preflight.d.ts.map +1 -1
- package/dist/cli/preflight.js +34 -20
- package/dist/cli/preflight.js.map +1 -1
- package/dist/cli/privy.d.ts.map +1 -1
- package/dist/cli/privy.js +4 -2
- package/dist/cli/privy.js.map +1 -1
- package/dist/cli/progress.d.ts +13 -1
- package/dist/cli/progress.d.ts.map +1 -1
- package/dist/cli/progress.js +7 -1
- package/dist/cli/progress.js.map +1 -1
- package/dist/cli/reclaimability.d.ts +82 -0
- package/dist/cli/reclaimability.d.ts.map +1 -0
- package/dist/cli/reclaimability.js +80 -0
- package/dist/cli/reclaimability.js.map +1 -0
- package/dist/cli/run.d.ts +2 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +62 -21
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/scan-range.d.ts +2 -2
- package/dist/cli/scan-range.js +2 -2
- package/dist/cli/status.d.ts +106 -1
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +325 -44
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/wallet.d.ts +2 -2
- package/dist/cli/wallet.d.ts.map +1 -1
- package/dist/cli/wallet.js +29 -5
- package/dist/cli/wallet.js.map +1 -1
- package/dist/discovery/rate-band.d.ts +74 -0
- package/dist/discovery/rate-band.d.ts.map +1 -0
- package/dist/discovery/rate-band.js +114 -0
- package/dist/discovery/rate-band.js.map +1 -0
- package/dist/escrow-generation.d.ts +81 -0
- package/dist/escrow-generation.d.ts.map +1 -0
- package/dist/escrow-generation.js +76 -0
- package/dist/escrow-generation.js.map +1 -0
- package/dist/frameworks/agentkit.d.ts +8 -4
- package/dist/frameworks/agentkit.d.ts.map +1 -1
- package/dist/frameworks/agentkit.js +27 -10
- package/dist/frameworks/agentkit.js.map +1 -1
- package/dist/frameworks/eliza.d.ts +3 -3
- package/dist/frameworks/eliza.d.ts.map +1 -1
- package/dist/frameworks/eliza.js +15 -6
- package/dist/frameworks/eliza.js.map +1 -1
- package/dist/frameworks/langchain.d.ts.map +1 -1
- package/dist/frameworks/langchain.js +8 -0
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/gateway/caller-auth-gateway.d.ts +83 -31
- package/dist/gateway/caller-auth-gateway.d.ts.map +1 -1
- package/dist/gateway/caller-auth-gateway.js +180 -27
- package/dist/gateway/caller-auth-gateway.js.map +1 -1
- package/dist/gateway/http-server.d.ts +128 -44
- package/dist/gateway/http-server.d.ts.map +1 -1
- package/dist/gateway/http-server.js +506 -155
- package/dist/gateway/http-server.js.map +1 -1
- package/dist/gateway/probe-auth.d.ts +112 -0
- package/dist/gateway/probe-auth.d.ts.map +1 -0
- package/dist/gateway/probe-auth.js +127 -0
- package/dist/gateway/probe-auth.js.map +1 -0
- package/dist/gateway/signed-rate-bounds.d.ts +51 -0
- package/dist/gateway/signed-rate-bounds.d.ts.map +1 -0
- package/dist/gateway/signed-rate-bounds.js +94 -0
- package/dist/gateway/signed-rate-bounds.js.map +1 -0
- package/dist/gateway/x402-opener-mode.d.ts +252 -0
- package/dist/gateway/x402-opener-mode.d.ts.map +1 -0
- package/dist/gateway/x402-opener-mode.js +772 -0
- package/dist/gateway/x402-opener-mode.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +64 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +247 -37
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/x402-tools.d.ts +109 -0
- package/dist/mcp/x402-tools.d.ts.map +1 -0
- package/dist/mcp/x402-tools.js +554 -0
- package/dist/mcp/x402-tools.js.map +1 -0
- package/dist/network.d.ts +119 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +199 -0
- package/dist/network.js.map +1 -0
- package/dist/sdk/client.d.ts +13 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/client.js +15 -0
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/invoke.d.ts +4 -0
- package/dist/sdk/invoke.d.ts.map +1 -1
- package/dist/sdk/invoke.js +2 -5
- package/dist/sdk/invoke.js.map +1 -1
- package/dist/wallet/autonomous-wallet-broker.d.ts +3 -0
- package/dist/wallet/autonomous-wallet-broker.d.ts.map +1 -1
- package/dist/wallet/autonomous-wallet-broker.js +27 -23
- package/dist/wallet/autonomous-wallet-broker.js.map +1 -1
- package/dist/wallet/autonomous-wallet-protocol.d.ts +8 -2
- package/dist/wallet/autonomous-wallet-protocol.d.ts.map +1 -1
- package/dist/wallet/autonomous-wallet-protocol.js +9 -2
- package/dist/wallet/autonomous-wallet-protocol.js.map +1 -1
- package/dist/wallet/autonomous-wallet.d.ts.map +1 -1
- package/dist/wallet/autonomous-wallet.js +3 -2
- package/dist/wallet/autonomous-wallet.js.map +1 -1
- package/dist/wallet/broker-escrows.d.ts +222 -0
- package/dist/wallet/broker-escrows.d.ts.map +1 -0
- package/dist/wallet/broker-escrows.js +36 -0
- package/dist/wallet/broker-escrows.js.map +1 -0
- package/dist/wallet/lifecycle.d.ts +21 -5
- package/dist/wallet/lifecycle.d.ts.map +1 -1
- package/dist/wallet/lifecycle.js +32 -12
- package/dist/wallet/lifecycle.js.map +1 -1
- package/dist/wallet/privy-broker-server.d.ts.map +1 -1
- package/dist/wallet/privy-broker-server.js +31 -26
- package/dist/wallet/privy-broker-server.js.map +1 -1
- package/dist/wallet/privy-session-broker.d.ts +14 -5
- package/dist/wallet/privy-session-broker.d.ts.map +1 -1
- package/dist/wallet/privy-session-broker.js +29 -17
- package/dist/wallet/privy-session-broker.js.map +1 -1
- package/dist/wallet/privy-session-provider.d.ts +3 -1
- package/dist/wallet/privy-session-provider.d.ts.map +1 -1
- package/dist/wallet/privy-session-provider.js +5 -3
- package/dist/wallet/privy-session-provider.js.map +1 -1
- package/dist/wallet/provider.d.ts.map +1 -1
- package/dist/wallet/provider.js +15 -8
- package/dist/wallet/provider.js.map +1 -1
- package/dist/x402/facilitator.d.ts +3 -30
- package/dist/x402/facilitator.d.ts.map +1 -1
- package/dist/x402/facilitator.js +0 -27
- package/dist/x402/facilitator.js.map +1 -1
- package/dist/x402-buyer/guarded-fetch.d.ts +51 -0
- package/dist/x402-buyer/guarded-fetch.d.ts.map +1 -0
- package/dist/x402-buyer/guarded-fetch.js +147 -0
- package/dist/x402-buyer/guarded-fetch.js.map +1 -0
- package/dist/x402-buyer/index.d.ts +10 -0
- package/dist/x402-buyer/index.d.ts.map +1 -0
- package/dist/x402-buyer/index.js +10 -0
- package/dist/x402-buyer/index.js.map +1 -0
- package/dist/x402-buyer/pay.d.ts +157 -0
- package/dist/x402-buyer/pay.d.ts.map +1 -0
- package/dist/x402-buyer/pay.js +366 -0
- package/dist/x402-buyer/pay.js.map +1 -0
- package/dist/x402-opener/abi.d.ts +684 -0
- package/dist/x402-opener/abi.d.ts.map +1 -0
- package/dist/x402-opener/abi.js +880 -0
- package/dist/x402-opener/abi.js.map +1 -0
- package/dist/x402-opener/facilitator-entry.d.ts +3 -0
- package/dist/x402-opener/facilitator-entry.d.ts.map +1 -0
- package/dist/x402-opener/facilitator-entry.js +40 -0
- package/dist/x402-opener/facilitator-entry.js.map +1 -0
- package/dist/x402-opener/facilitator-server.d.ts +209 -0
- package/dist/x402-opener/facilitator-server.d.ts.map +1 -0
- package/dist/x402-opener/facilitator-server.js +762 -0
- package/dist/x402-opener/facilitator-server.js.map +1 -0
- package/dist/x402-opener/index.d.ts +14 -0
- package/dist/x402-opener/index.d.ts.map +1 -0
- package/dist/x402-opener/index.js +14 -0
- package/dist/x402-opener/index.js.map +1 -0
- package/dist/x402-opener/listing-resolver.d.ts +55 -0
- package/dist/x402-opener/listing-resolver.d.ts.map +1 -0
- package/dist/x402-opener/listing-resolver.js +125 -0
- package/dist/x402-opener/listing-resolver.js.map +1 -0
- package/dist/x402-opener/refund-relay.d.ts +266 -0
- package/dist/x402-opener/refund-relay.d.ts.map +1 -0
- package/dist/x402-opener/refund-relay.js +1341 -0
- package/dist/x402-opener/refund-relay.js.map +1 -0
- package/dist/x402-opener/relayer-queue.d.ts +14 -0
- package/dist/x402-opener/relayer-queue.d.ts.map +1 -0
- package/dist/x402-opener/relayer-queue.js +18 -0
- package/dist/x402-opener/relayer-queue.js.map +1 -0
- package/dist/x402-opener/scheme.d.ts +296 -0
- package/dist/x402-opener/scheme.d.ts.map +1 -0
- package/dist/x402-opener/scheme.js +1035 -0
- package/dist/x402-opener/scheme.js.map +1 -0
- package/dist/x402-opener/terms.d.ts +165 -0
- package/dist/x402-opener/terms.d.ts.map +1 -0
- package/dist/x402-opener/terms.js +304 -0
- package/dist/x402-opener/terms.js.map +1 -0
- package/dist/zktls/reclaim.d.ts +2 -2
- package/dist/zktls/t2-delivery-proof.d.ts +6 -6
- package/docs/agent-layer.md +3 -2
- package/docs/autonomous-privy-wallet.md +188 -0
- package/docs/cli.md +265 -34
- package/docs/langchain.md +5 -0
- package/docs/mcp-reference.md +91 -5
- package/docs/probe-capability.md +191 -0
- package/docs/quickstart.md +39 -4
- package/docs/threat-model.md +20 -0
- package/docs/x402.md +766 -593
- package/package.json +19 -17
- package/src/capability/probe-capability.ts +355 -0
- package/src/cli/args.ts +29 -0
- package/src/cli/commands/claim.ts +168 -33
- package/src/cli/commands/close.ts +36 -3
- package/src/cli/commands/invoke.ts +5 -2
- package/src/cli/commands/mcp.ts +18 -2
- package/src/cli/commands/open.ts +75 -4
- package/src/cli/commands/pay.ts +584 -0
- package/src/cli/commands/reclaim-unverified.ts +8 -2
- package/src/cli/commands/reclaim.ts +277 -19
- package/src/cli/commands/refund.ts +475 -0
- package/src/cli/commands/status.ts +28 -2
- package/src/cli/commands/streams.ts +10 -14
- package/src/cli/commands/watch.ts +11 -1
- package/src/cli/config.ts +139 -52
- package/src/cli/context.ts +16 -0
- package/src/cli/deps.ts +111 -1
- package/src/cli/errors.ts +24 -1
- package/src/cli/escape-hatch.ts +19 -5
- package/src/cli/listings.ts +43 -10
- package/src/cli/preflight.ts +36 -21
- package/src/cli/privy.ts +4 -2
- package/src/cli/progress.ts +21 -2
- package/src/cli/reclaimability.ts +154 -0
- package/src/cli/run.ts +77 -21
- package/src/cli/scan-range.ts +2 -2
- package/src/cli/status.ts +454 -44
- package/src/cli/wallet.ts +45 -8
- package/src/discovery/rate-band.ts +172 -0
- package/src/escrow-generation.ts +135 -0
- package/src/frameworks/agentkit.ts +45 -11
- package/src/frameworks/eliza.ts +27 -5
- package/src/frameworks/langchain.ts +14 -0
- package/src/gateway/caller-auth-gateway.ts +320 -68
- package/src/gateway/http-server.ts +717 -220
- package/src/gateway/probe-auth.ts +191 -0
- package/src/gateway/signed-rate-bounds.ts +164 -0
- package/src/gateway/x402-opener-mode.ts +1171 -0
- package/src/index.ts +82 -19
- package/src/mcp/server.ts +351 -42
- package/src/mcp/x402-tools.ts +785 -0
- package/src/network.ts +302 -0
- package/src/sdk/client.ts +25 -0
- package/src/sdk/invoke.ts +6 -5
- package/src/wallet/autonomous-wallet-broker.ts +46 -20
- package/src/wallet/autonomous-wallet-protocol.ts +11 -2
- package/src/wallet/autonomous-wallet.ts +4 -2
- package/src/wallet/broker-escrows.ts +66 -0
- package/src/wallet/lifecycle.ts +53 -18
- package/src/wallet/privy-broker-server.ts +35 -25
- package/src/wallet/privy-session-broker.ts +58 -25
- package/src/wallet/privy-session-provider.ts +7 -3
- package/src/wallet/provider.ts +20 -15
- package/src/x402/facilitator.ts +3 -43
- package/src/x402-buyer/guarded-fetch.ts +213 -0
- package/src/x402-buyer/index.ts +9 -0
- package/src/x402-buyer/pay.ts +555 -0
- package/src/x402-opener/abi.ts +881 -0
- package/src/x402-opener/facilitator-entry.ts +48 -0
- package/src/x402-opener/facilitator-server.ts +1114 -0
- package/src/x402-opener/index.ts +13 -0
- package/src/x402-opener/listing-resolver.ts +202 -0
- package/src/x402-opener/refund-relay.ts +1873 -0
- package/src/x402-opener/relayer-queue.ts +18 -0
- package/src/x402-opener/scheme.ts +1551 -0
- package/src/x402-opener/terms.ts +453 -0
- package/dist/gateway/x402-mode.d.ts +0 -123
- package/dist/gateway/x402-mode.d.ts.map +0 -1
- package/dist/gateway/x402-mode.js +0 -212
- package/dist/gateway/x402-mode.js.map +0 -1
- package/dist/x402/delivery-oracle.d.ts +0 -108
- package/dist/x402/delivery-oracle.d.ts.map +0 -1
- package/dist/x402/delivery-oracle.js +0 -174
- package/dist/x402/delivery-oracle.js.map +0 -1
- package/dist/x402/facilitator-server-entry.d.ts +0 -3
- package/dist/x402/facilitator-server-entry.d.ts.map +0 -1
- package/dist/x402/facilitator-server-entry.js +0 -27
- package/dist/x402/facilitator-server-entry.js.map +0 -1
- package/dist/x402/facilitator-server.d.ts +0 -73
- package/dist/x402/facilitator-server.d.ts.map +0 -1
- package/dist/x402/facilitator-server.js +0 -305
- package/dist/x402/facilitator-server.js.map +0 -1
- package/dist/x402/payment-requirements.d.ts +0 -106
- package/dist/x402/payment-requirements.d.ts.map +0 -1
- package/dist/x402/payment-requirements.js +0 -138
- package/dist/x402/payment-requirements.js.map +0 -1
- package/dist/x402/relayer.d.ts +0 -41
- package/dist/x402/relayer.d.ts.map +0 -1
- package/dist/x402/relayer.js +0 -64
- package/dist/x402/relayer.js.map +0 -1
- package/dist/x402/resource-index.d.ts +0 -75
- package/dist/x402/resource-index.d.ts.map +0 -1
- package/dist/x402/resource-index.js +0 -126
- package/dist/x402/resource-index.js.map +0 -1
- package/dist/x402/verified-delivery-facilitator.d.ts +0 -285
- package/dist/x402/verified-delivery-facilitator.d.ts.map +0 -1
- package/dist/x402/verified-delivery-facilitator.js +0 -423
- package/dist/x402/verified-delivery-facilitator.js.map +0 -1
- package/src/gateway/x402-mode.ts +0 -350
- package/src/x402/delivery-oracle.ts +0 -285
- package/src/x402/facilitator-server-entry.ts +0 -35
- package/src/x402/facilitator-server.ts +0 -445
- package/src/x402/payment-requirements.ts +0 -231
- package/src/x402/relayer.ts +0 -122
- package/src/x402/resource-index.ts +0 -228
- package/src/x402/verified-delivery-facilitator.ts +0 -744
|
@@ -8,7 +8,8 @@ import { assertWithinOperatorCaps, assertWithinSpendPolicy, } from "../spend-pol
|
|
|
8
8
|
import { cliMandateCaps, signCliMandate } from "../mandate.js";
|
|
9
9
|
import { assertCanFundStream, assertCanPayGas } from "../preflight.js";
|
|
10
10
|
import { isPolicyEnforced, optionalCliWallet, resolveCliWallet, PRIVATE_KEY_ENV, } from "../wallet.js";
|
|
11
|
-
import {
|
|
11
|
+
import { resolveListingRecord } from "../listings.js";
|
|
12
|
+
import { listingRateBand, rateBandRefusal, SignedRateBoundsError, } from "../../discovery/rate-band.js";
|
|
12
13
|
export const openCommand = {
|
|
13
14
|
name: "open",
|
|
14
15
|
summary: "Hire a verified service: escrow USDC into a metered stream",
|
|
@@ -54,13 +55,15 @@ export const openCommand = {
|
|
|
54
55
|
if (account !== null && !dryRun) {
|
|
55
56
|
// Both balances, before anything is signed. Gas first: a wallet with no
|
|
56
57
|
// ETH cannot send the approval that the USDC check exists to protect.
|
|
57
|
-
await assertCanPayGas(read, account.address);
|
|
58
|
-
await assertCanFundStream(read, account.address, budgetUsdc);
|
|
58
|
+
await assertCanPayGas(read, account.address, config.network);
|
|
59
|
+
await assertCanFundStream(read, account.address, budgetUsdc, config.network);
|
|
59
60
|
}
|
|
60
61
|
const operatorOverride = stringFlag(args, "operator");
|
|
61
|
-
const
|
|
62
|
+
const resolution = await resolveListingRecord(context, serviceRef, {
|
|
62
63
|
required: operatorOverride === undefined,
|
|
63
64
|
});
|
|
65
|
+
const listing = resolution.listing;
|
|
66
|
+
await assertRateInSignedBand(context, resolution, ratePerSecondUsdc);
|
|
64
67
|
const operator = (operatorOverride ?? listing?.operator);
|
|
65
68
|
if (operator === undefined) {
|
|
66
69
|
throw configError(`serviceRef ${serviceRef} is not in the registry and no --operator was given`, "run `metrik discover` to find a listed service, or pass --operator explicitly.");
|
|
@@ -285,6 +288,57 @@ export const openCommand = {
|
|
|
285
288
|
out.print(`Next: metrik status ${result.streamId}`);
|
|
286
289
|
},
|
|
287
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* Refuse a `--rate` outside the band the operator SIGNED, before anything is
|
|
293
|
+
* signed or broadcast — dry run included, because the rate is an invalid input
|
|
294
|
+
* for this service exactly like `--rate 0` is.
|
|
295
|
+
*
|
|
296
|
+
* The escrow accepts any non-zero rate; the seller's capability gateway does
|
|
297
|
+
* not, and answers every request on an out-of-band stream with
|
|
298
|
+
* `403 stream-rate-out-of-bounds`. Without this check the CLI locked a buyer's
|
|
299
|
+
* deposit in a stream that could never be served, and said nothing.
|
|
300
|
+
*
|
|
301
|
+
* - Listing found: its signed descriptor is re-verified and the band enforced.
|
|
302
|
+
* A descriptor that does not verify is a refusal (exit 4), never "no band".
|
|
303
|
+
* A legacy binding signs no commercial terms, so there is nothing to enforce.
|
|
304
|
+
* - No listing: only reachable with `--operator`, the CLI's existing,
|
|
305
|
+
* explicit escape hatch for a service the registry cannot vouch for. The
|
|
306
|
+
* check cannot run, so it is skipped LOUDLY rather than silently. Without
|
|
307
|
+
* `--operator` an unreachable registry or a missing listing has already
|
|
308
|
+
* failed the command before this point (`resolveListingRecord`).
|
|
309
|
+
*/
|
|
310
|
+
async function assertRateInSignedBand(context, resolution, ratePerSecondUsdc) {
|
|
311
|
+
const { out } = context;
|
|
312
|
+
if (resolution.record === null) {
|
|
313
|
+
out.note(resolution.registryUnreachable
|
|
314
|
+
? "warning: the operator-signed rate band could NOT be checked because the registry is unreachable. If --rate is outside the band the operator signed, the service's gateway will refuse every request while the deposit stays escrowed. Re-run when the registry answers to have it checked."
|
|
315
|
+
: "note: this serviceRef has no verified listing, so there is no operator-signed rate band to check --rate against.");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
let bounds;
|
|
319
|
+
try {
|
|
320
|
+
bounds = await listingRateBand(resolution.record);
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
if (error instanceof SignedRateBoundsError) {
|
|
324
|
+
throw new CliError(`the listing's operator-signed rate band could not be verified: ${error.message}`, {
|
|
325
|
+
exitCode: 4,
|
|
326
|
+
hint: "nothing was broadcast. The CLI will not open a stream against a rate band it cannot verify.",
|
|
327
|
+
cause: error,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
if (bounds === null)
|
|
333
|
+
return;
|
|
334
|
+
const refusal = rateBandRefusal(ratePerSecondUsdc, bounds, "--rate");
|
|
335
|
+
if (refusal !== undefined) {
|
|
336
|
+
throw new CliError(refusal, {
|
|
337
|
+
exitCode: 2,
|
|
338
|
+
hint: "pick a --rate inside the signed band (`--units atomic` takes base units; see `metrik discover` for each listing's band).",
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
288
342
|
/**
|
|
289
343
|
* What the buyer is actually paying for.
|
|
290
344
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/cli/commands/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EACL,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,4DAA4D;IACrE,KAAK,EACH,sHAAsH;IACxH,KAAK,EAAE;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,UAAU;QACV,OAAO;QACP,UAAU;QACV,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A4B;CAC7B,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CAAC,OAI3B;IACC,MAAM,KAAK,GAAG,OAAO,CAAC,eAAe,CAAC;IACtC,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,iBAAiB,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAC3E,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClD,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { X402QuoteSummary } from "@absol-labs/sdk/x402";
|
|
2
|
+
import { type ServerMandateCaps } from "../../mandates/env.js";
|
|
3
|
+
import type { CommandSpec } from "../context.js";
|
|
4
|
+
export declare const payCommand: CommandSpec;
|
|
5
|
+
/**
|
|
6
|
+
* One line stating what a quote commits the payer to, printed before signing:
|
|
7
|
+
* for an upfront-opener quote, the NON-REFUNDABLE per-call part and the
|
|
8
|
+
* metered, refundable part; for a stream quote, that all of it is metered.
|
|
9
|
+
*/
|
|
10
|
+
export declare function describeQuoteSplit(quote: X402QuoteSummary): string;
|
|
11
|
+
/**
|
|
12
|
+
* The settlement transaction hash from the facilitator's `PAYMENT-RESPONSE`,
|
|
13
|
+
* when it carries a well-formed one. Anything else (absent, empty, not a
|
|
14
|
+
* 32-byte hash) is `null`: a malformed value is never printed as a hash.
|
|
15
|
+
*/
|
|
16
|
+
export declare function settlementTransaction(paymentResponse: {
|
|
17
|
+
readonly transaction?: unknown;
|
|
18
|
+
} | null | undefined): `0x${string}` | null;
|
|
19
|
+
/**
|
|
20
|
+
* The mandate this command signs: a standing `METRIK_AGENT_MANDATE_*` ceiling
|
|
21
|
+
* INTERSECTED with every flag (the most restrictive value wins), or, with no
|
|
22
|
+
* standing ceiling, one sized to the flags. A flag can only tighten a
|
|
23
|
+
* standing ceiling, never loosen or bypass it; an `--operator` outside a
|
|
24
|
+
* standing allowlist is refused outright.
|
|
25
|
+
*/
|
|
26
|
+
export declare function intersectCaps(envCaps: ServerMandateCaps | null, flags: {
|
|
27
|
+
readonly maxAmount: bigint | undefined;
|
|
28
|
+
readonly maxRate: bigint | undefined;
|
|
29
|
+
readonly maxDuration: number | undefined;
|
|
30
|
+
readonly operator: `0x${string}` | undefined;
|
|
31
|
+
}): ServerMandateCaps;
|
|
32
|
+
/** Map the SDK's and the mandate's typed failures onto CLI exit codes. */
|
|
33
|
+
export declare function explainPayFailure(error: unknown): unknown;
|
|
34
|
+
//# sourceMappingURL=pay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/pay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AA2B/B,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAOjE,eAAO,MAAM,UAAU,EAAE,WAsSxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAQlE;AAqBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GACrE,KAAK,MAAM,EAAE,GAAG,IAAI,CAKtB;AAKD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,iBAAiB,GAAG,IAAI,EACjC,KAAK,EAAE;IACL,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS,CAAC;CAC9C,GACA,iBAAiB,CA4CnB;AAqFD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkDzD"}
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { DEFAULT_SERVER_MANDATE_TTL_SECONDS, parseServerMandateCapsEnv, signServerMandate, } from "../../mandates/env.js";
|
|
2
|
+
import { booleanFlag, integerFlag, jsonBodyFlag, stringFlag, stringFlags, } from "../args.js";
|
|
3
|
+
import { formatDuration, formatUsdc, parseAmountUnits, parseDurationSeconds, parseUsdcAmount, } from "../amounts.js";
|
|
4
|
+
import { assertTestnetRpc } from "../config.js";
|
|
5
|
+
import { rpcTransport } from "../deps.js";
|
|
6
|
+
import { CliError, configError, usageError } from "../errors.js";
|
|
7
|
+
import { usdcFundingHint } from "../../network.js";
|
|
8
|
+
import { CDP_ENV_VARS, PRIVATE_KEY_ENV, isPrivyWalletSource, resolveCliWallet, } from "../wallet.js";
|
|
9
|
+
import { hasHeader, parseHeaders } from "./invoke.js";
|
|
10
|
+
/** Default stream window a request-sized mandate allows (one day). */
|
|
11
|
+
const DEFAULT_MAX_DURATION_SECONDS = 86_400;
|
|
12
|
+
/** Longest response body printed in human mode before it is truncated. */
|
|
13
|
+
const MAX_PRINTED_BODY_CHARS = 64 * 1024;
|
|
14
|
+
export const payCommand = {
|
|
15
|
+
name: "pay",
|
|
16
|
+
summary: "Pay an x402 endpoint into a recoverable escrow stream, under a spend mandate",
|
|
17
|
+
usage: 'metrik pay <url> [--json \'{"text":"hi"}\' | --data <body>] [--method POST] [--header "K: V"] --max-amount <usdc> [--max-rate <usdc/s>] [--max-upfront <usdc>] [--max-duration <seconds>] [--min-duration <seconds>] [--operator <address>] [--units atomic]',
|
|
18
|
+
flags: [
|
|
19
|
+
"data",
|
|
20
|
+
"json-body",
|
|
21
|
+
"method",
|
|
22
|
+
"header",
|
|
23
|
+
"max-amount",
|
|
24
|
+
"max-rate",
|
|
25
|
+
"max-upfront",
|
|
26
|
+
"max-duration",
|
|
27
|
+
"min-duration",
|
|
28
|
+
"operator",
|
|
29
|
+
"units",
|
|
30
|
+
"allow-legacy-factory",
|
|
31
|
+
],
|
|
32
|
+
// It moves the payer's USDC (an EIP-3009 authorization the facilitator
|
|
33
|
+
// settles into the escrow). The PAYER broadcasts nothing and needs no gas,
|
|
34
|
+
// but it is a fund-moving command and is gated like one.
|
|
35
|
+
signs: true,
|
|
36
|
+
// ...so the generic "Broadcasts a transaction" help would be false, and so
|
|
37
|
+
// would listing Privy: the command refuses a Privy wallet (its broker does
|
|
38
|
+
// not sign EIP-3009). Say what actually happens.
|
|
39
|
+
walletHelp: {
|
|
40
|
+
tag: "[signs a USDC payment]",
|
|
41
|
+
text: "Broadcasts nothing and needs no gas: the payer signs an EIP-3009 USDC authorization (TransferWithAuthorization) " +
|
|
42
|
+
"that the seller's facilitator settles into an escrow stream. Requires a wallet holding USDC in the environment: " +
|
|
43
|
+
`${PRIVATE_KEY_ENV} or ${CDP_ENV_VARS.join(" + ")}. A Privy wallet cannot pay x402: its broker does not sign EIP-3009.`,
|
|
44
|
+
},
|
|
45
|
+
flagHelp: {
|
|
46
|
+
"max-upfront": "--max-upfront <usdc> (cap on the NON-REFUNDABLE per-call part of an upfront-opener quote; default 0.10 USDC, 0 refuses any)",
|
|
47
|
+
data: "--data <body>",
|
|
48
|
+
"json-body": "--json <body> (alias: --json-body <body>)",
|
|
49
|
+
},
|
|
50
|
+
async run(context) {
|
|
51
|
+
const { args, config, env, out, deps } = context;
|
|
52
|
+
const x402 = requireX402(deps.x402);
|
|
53
|
+
const [urlArg] = args.positionals;
|
|
54
|
+
if (urlArg === undefined) {
|
|
55
|
+
throw usageError("metrik pay requires the <url> of an x402 endpoint");
|
|
56
|
+
}
|
|
57
|
+
const url = parseResourceUrl(urlArg);
|
|
58
|
+
const units = parseAmountUnits(stringFlag(args, "units"));
|
|
59
|
+
const maxAmountRaw = stringFlag(args, "max-amount");
|
|
60
|
+
const maxAmount = maxAmountRaw === undefined
|
|
61
|
+
? undefined
|
|
62
|
+
: parseUsdcAmount(maxAmountRaw, units, "max-amount");
|
|
63
|
+
const maxRateRaw = stringFlag(args, "max-rate");
|
|
64
|
+
const maxRate = maxRateRaw === undefined
|
|
65
|
+
? undefined
|
|
66
|
+
: parseUsdcAmount(maxRateRaw, units, "max-rate");
|
|
67
|
+
const maxUpfrontRaw = stringFlag(args, "max-upfront");
|
|
68
|
+
const maxUpfront = maxUpfrontRaw === undefined
|
|
69
|
+
? undefined
|
|
70
|
+
: parseUsdcAmount(maxUpfrontRaw, units, "max-upfront");
|
|
71
|
+
const maxDurationRaw = stringFlag(args, "max-duration");
|
|
72
|
+
const maxDuration = maxDurationRaw === undefined
|
|
73
|
+
? undefined
|
|
74
|
+
: parseDurationSeconds(maxDurationRaw);
|
|
75
|
+
const minDuration = integerFlag(args, "min-duration");
|
|
76
|
+
const operator = stringFlag(args, "operator");
|
|
77
|
+
if (operator !== undefined && !/^0x[0-9a-fA-F]{40}$/.test(operator)) {
|
|
78
|
+
throw usageError(`--operator must be an EVM address (got "${operator}")`);
|
|
79
|
+
}
|
|
80
|
+
if (maxAmount !== undefined && maxAmount <= 0n) {
|
|
81
|
+
throw usageError("--max-amount must be greater than zero");
|
|
82
|
+
}
|
|
83
|
+
if (maxRate !== undefined && maxRate <= 0n) {
|
|
84
|
+
throw usageError("--max-rate must be greater than zero");
|
|
85
|
+
}
|
|
86
|
+
const init = buildRequest(context);
|
|
87
|
+
// The mandate: an operator-set standing ceiling (METRIK_AGENT_MANDATE_*),
|
|
88
|
+
// or one sized to exactly this payment. Either way it is SIGNED and
|
|
89
|
+
// `checkMandate()` gates the quote before anything is signed for the
|
|
90
|
+
// seller. There is no unbounded path: without standing caps, --max-amount
|
|
91
|
+
// is required.
|
|
92
|
+
const envCaps = parseServerMandateCapsEnv(env);
|
|
93
|
+
if (envCaps === null && maxAmount === undefined) {
|
|
94
|
+
throw usageError("metrik pay needs a spend ceiling: pass --max-amount <usdc> (or configure a standing mandate with METRIK_AGENT_MANDATE_*)", "no spend without a mandate: the seller picks the price, so the buyer must cap it. Nothing was sent.");
|
|
95
|
+
}
|
|
96
|
+
const caps = intersectCaps(envCaps, {
|
|
97
|
+
maxAmount,
|
|
98
|
+
maxRate,
|
|
99
|
+
maxDuration,
|
|
100
|
+
operator: operator,
|
|
101
|
+
});
|
|
102
|
+
const wallet = await resolveCliWallet(env, {
|
|
103
|
+
purpose: "x402-payment",
|
|
104
|
+
note: out.note,
|
|
105
|
+
rpcUrl: config.rpcUrl,
|
|
106
|
+
});
|
|
107
|
+
if (isPrivyWalletSource(wallet.source)) {
|
|
108
|
+
throw configError("metrik pay cannot sign with a Privy wallet", "an x402 payment is an EIP-3009 TransferWithAuthorization signature, and the Privy broker's typed-data policy allows only an InvocationCapability. Pay with METRIK_AGENT_PRIVATE_KEY or a CDP wallet.");
|
|
109
|
+
}
|
|
110
|
+
const { account } = wallet;
|
|
111
|
+
const read = deps.createReadClient(config);
|
|
112
|
+
await assertTestnetRpc(config, () => read.getChainId());
|
|
113
|
+
// The payer needs USDC only — no gas: the facilitator's relayer submits
|
|
114
|
+
// the authorization. A zero balance is a knowable fact before signing.
|
|
115
|
+
const balance = await read.usdcBalance(account.address).catch(() => null);
|
|
116
|
+
if (balance === 0n) {
|
|
117
|
+
throw new CliError(`wallet ${account.address} holds 0 USDC on ${config.network.name}, so it cannot pay`, {
|
|
118
|
+
exitCode: 3,
|
|
119
|
+
hint: `${usdcFundingHint(config.network)}, then re-run. (An x402 payer needs USDC only; no gas.)`,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const signedMandate = await signServerMandate(account, caps, {
|
|
123
|
+
chainId: config.chainId,
|
|
124
|
+
});
|
|
125
|
+
out.note(`paying ${url} (ceiling ${formatUsdc(maxAmount === undefined ? caps.maxPerStreamUsdc : maxAmount < caps.maxPerStreamUsdc ? maxAmount : caps.maxPerStreamUsdc)}, mandate from ${envCaps === null ? "this command" : "METRIK_AGENT_MANDATE_*"}) …`);
|
|
126
|
+
const result = await payOrExplain(x402, {
|
|
127
|
+
url,
|
|
128
|
+
init,
|
|
129
|
+
signer: account,
|
|
130
|
+
network: config.network,
|
|
131
|
+
signedMandate,
|
|
132
|
+
spentSoFarUsdc: 0n,
|
|
133
|
+
nowSeconds: deps.nowSeconds(),
|
|
134
|
+
...(maxAmount === undefined ? {} : { maxAmount }),
|
|
135
|
+
...(maxRate === undefined ? {} : { maxRatePerSecond: maxRate }),
|
|
136
|
+
...(minDuration === undefined ? {} : { minDurationSeconds: minDuration }),
|
|
137
|
+
...(maxUpfront === undefined ? {} : { maxUpfrontAmount: maxUpfront }),
|
|
138
|
+
// The split, stated BEFORE anything is signed (the mandate approved the
|
|
139
|
+
// quote; the SDK signs right after this).
|
|
140
|
+
onApproved: ({ quote }) => {
|
|
141
|
+
out.note(describeQuoteSplit(quote));
|
|
142
|
+
},
|
|
143
|
+
sdkOptions: {
|
|
144
|
+
transport: rpcTransport(config),
|
|
145
|
+
// A LEGACY deployment's factory is refused by the SDK unless the
|
|
146
|
+
// buyer opts in: streams there can still be closed and reclaimed, but
|
|
147
|
+
// nothing new should open on a generation being retired by default.
|
|
148
|
+
...(booleanFlag(args, "allow-legacy-factory")
|
|
149
|
+
? { allowLegacyFactory: true }
|
|
150
|
+
: {}),
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
const bodyText = await result.response.text();
|
|
154
|
+
const opener = result.metrikStreamOpener;
|
|
155
|
+
const quote = result.quote;
|
|
156
|
+
const settlementTx = settlementTransaction(result.paymentResponse);
|
|
157
|
+
out.result({
|
|
158
|
+
paid: result.paid,
|
|
159
|
+
// The facilitator's settlement transaction, from the PAYMENT-RESPONSE
|
|
160
|
+
// header the seller relayed: the facilitator's relayer broadcast it, not
|
|
161
|
+
// the payer. Reported as-is; null when the header carries none.
|
|
162
|
+
settlementTransaction: settlementTx,
|
|
163
|
+
settlementTransactionSource: settlementTx === null ? null : "PAYMENT-RESPONSE",
|
|
164
|
+
httpStatus: result.response.status,
|
|
165
|
+
contentType: result.response.headers.get("content-type"),
|
|
166
|
+
body: bodyText,
|
|
167
|
+
streamId: opener?.streamId ?? null,
|
|
168
|
+
opener: opener?.opener ?? null,
|
|
169
|
+
refundUrl: opener?.refundUrl ?? null,
|
|
170
|
+
escrow: opener?.escrow ?? null,
|
|
171
|
+
deposit: opener?.deposit ?? null,
|
|
172
|
+
openerKind: quote?.openerKind ?? null,
|
|
173
|
+
price: quote?.amount ?? null,
|
|
174
|
+
// The NON-REFUNDABLE part (paid to the seller at settlement) and the
|
|
175
|
+
// metered, refundable part (the most any refund can return).
|
|
176
|
+
upfrontAmount: quote?.upfrontAmount ?? null,
|
|
177
|
+
refundableAmount: quote?.refundableAmount ?? null,
|
|
178
|
+
upfrontFee: opener?.upfrontFee ?? null,
|
|
179
|
+
upfrontOnly: opener?.upfrontOnly ?? quote?.upfrontOnly ?? null,
|
|
180
|
+
// True for an upfront-only payment: nothing was escrowed, nothing to refund.
|
|
181
|
+
final: opener?.upfrontOnly === true,
|
|
182
|
+
ratePerSecond: opener?.ratePerSecond ?? null,
|
|
183
|
+
expiresAt: opener?.expiresAt ?? null,
|
|
184
|
+
operator: quote?.operator ?? null,
|
|
185
|
+
serviceRef: quote?.serviceRef ?? null,
|
|
186
|
+
minEarnSeconds: quote?.minEarnSeconds ?? null,
|
|
187
|
+
mandateSource: envCaps === null ? "request" : "env",
|
|
188
|
+
refundIsAutomatic: false,
|
|
189
|
+
});
|
|
190
|
+
if (!result.paid) {
|
|
191
|
+
out.print(`The endpoint answered ${result.response.status} without asking for payment; nothing was signed or paid.`);
|
|
192
|
+
out.print(truncate(bodyText));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
out.print(`Paid. HTTP ${result.response.status}`);
|
|
196
|
+
out.print(truncate(bodyText));
|
|
197
|
+
out.print("");
|
|
198
|
+
if (opener !== null && opener.streamId === null) {
|
|
199
|
+
// Upfront-only: no stream exists, so there is no refund or reclaim to offer.
|
|
200
|
+
out.table([
|
|
201
|
+
["opener", opener.opener],
|
|
202
|
+
["payer", account.address],
|
|
203
|
+
...splitRows(quote, opener.upfrontFee),
|
|
204
|
+
...(settlementTx === null
|
|
205
|
+
? []
|
|
206
|
+
: [
|
|
207
|
+
[
|
|
208
|
+
"settlement tx",
|
|
209
|
+
`${settlementTx} (reported by the seller's facilitator in PAYMENT-RESPONSE; its relayer broadcast it)`,
|
|
210
|
+
],
|
|
211
|
+
]),
|
|
212
|
+
]);
|
|
213
|
+
out.print("");
|
|
214
|
+
out.print("This payment is FINAL: it was an upfront-only (minimum-charge) payment, the whole price was paid to the seller at settlement as a non-refundable per-call charge, and no escrow stream was opened. There is nothing to refund or reclaim.");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (opener !== null && opener.streamId !== null) {
|
|
218
|
+
out.table([
|
|
219
|
+
["streamId", opener.streamId],
|
|
220
|
+
["opener", opener.opener],
|
|
221
|
+
["payer", account.address],
|
|
222
|
+
...splitRows(quote, opener.upfrontFee),
|
|
223
|
+
...(opener.deposit === null
|
|
224
|
+
? []
|
|
225
|
+
: [["deposit", formatUsdc(opener.deposit)]]),
|
|
226
|
+
...(opener.ratePerSecond === null
|
|
227
|
+
? []
|
|
228
|
+
: [
|
|
229
|
+
["rate", `${formatUsdc(opener.ratePerSecond)} / verified second`],
|
|
230
|
+
]),
|
|
231
|
+
...(quote?.minEarnSeconds === null ||
|
|
232
|
+
quote?.minEarnSeconds === undefined
|
|
233
|
+
? []
|
|
234
|
+
: [
|
|
235
|
+
[
|
|
236
|
+
"fully earned after",
|
|
237
|
+
`${formatDuration(Number(quote.minEarnSeconds))} of verified delivery`,
|
|
238
|
+
],
|
|
239
|
+
]),
|
|
240
|
+
...(opener.expiresAt === null
|
|
241
|
+
? []
|
|
242
|
+
: [
|
|
243
|
+
["expires", new Date(opener.expiresAt * 1000).toISOString()],
|
|
244
|
+
]),
|
|
245
|
+
["refund url", opener.refundUrl ?? "(the seller advertised no relay)"],
|
|
246
|
+
...(settlementTx === null
|
|
247
|
+
? []
|
|
248
|
+
: [
|
|
249
|
+
[
|
|
250
|
+
"settlement tx",
|
|
251
|
+
`${settlementTx} (reported by the seller's facilitator in PAYMENT-RESPONSE; its relayer broadcast it)`,
|
|
252
|
+
],
|
|
253
|
+
]),
|
|
254
|
+
]);
|
|
255
|
+
out.print("");
|
|
256
|
+
// A stream on another (e.g. legacy) registered escrow is reached by
|
|
257
|
+
// naming that escrow; the CLI defaults to the network's current one.
|
|
258
|
+
const escrowFlag = opener.escrow !== null &&
|
|
259
|
+
opener.escrow.toLowerCase() !== config.escrow.toLowerCase()
|
|
260
|
+
? ` --escrow ${opener.escrow}`
|
|
261
|
+
: "";
|
|
262
|
+
out.print(quote?.openerKind === "upfront" &&
|
|
263
|
+
quote.upfrontAmount !== null &&
|
|
264
|
+
quote.upfrontAmount > 0n
|
|
265
|
+
? `Refunds are NOT automatic. The ${formatUsdc(quote.upfrontAmount)} upfront charge is final; of the ${formatUsdc(quote.refundableAmount ?? 0n)} escrowed, the seller earns only verified seconds, and whatever is unearned stays in the escrow until someone reclaims it for you:`
|
|
266
|
+
: "Refunds are NOT automatic. The seller earns only for verified seconds; whatever is unearned stays in the escrow until someone reclaims it for you:");
|
|
267
|
+
out.print(opener.refundUrl === null
|
|
268
|
+
? ` metrik reclaim ${opener.streamId}${escrowFlag} (anyone may send it; the refund always goes to the payer)`
|
|
269
|
+
: ` metrik refund ${opener.streamId} --refund-url ${opener.refundUrl}${escrowFlag} --close --reclaim`);
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* One line stating what a quote commits the payer to, printed before signing:
|
|
275
|
+
* for an upfront-opener quote, the NON-REFUNDABLE per-call part and the
|
|
276
|
+
* metered, refundable part; for a stream quote, that all of it is metered.
|
|
277
|
+
*/
|
|
278
|
+
export function describeQuoteSplit(quote) {
|
|
279
|
+
if (quote.openerKind === "upfront" && quote.upfrontAmount !== null) {
|
|
280
|
+
if (quote.upfrontOnly === true) {
|
|
281
|
+
return `quote: ${formatUsdc(quote.amount)}, ALL of it a NON-REFUNDABLE per-call charge (upfront-only: no stream is opened, nothing is metered, nothing can be refunded). Signing it.`;
|
|
282
|
+
}
|
|
283
|
+
return `quote: ${formatUsdc(quote.amount)} = ${formatUsdc(quote.upfrontAmount)} NON-REFUNDABLE per-call charge (paid to the seller at settlement) + ${formatUsdc(quote.refundableAmount ?? 0n)} metered and refundable (escrowed; the seller earns it only for verified seconds). Signing it.`;
|
|
284
|
+
}
|
|
285
|
+
return `quote: ${formatUsdc(quote.amount)}, all of it escrowed, metered and refundable (the seller earns it only for verified seconds). Signing it.`;
|
|
286
|
+
}
|
|
287
|
+
/** Table rows stating a paid quote's split (upfront quotes only). */
|
|
288
|
+
function splitRows(quote, upfrontFee) {
|
|
289
|
+
if (quote === null || quote.openerKind !== "upfront")
|
|
290
|
+
return [];
|
|
291
|
+
return [
|
|
292
|
+
["price", formatUsdc(quote.amount)],
|
|
293
|
+
[
|
|
294
|
+
"non-refundable",
|
|
295
|
+
`${formatUsdc(quote.upfrontAmount ?? 0n)} (per-call charge, paid to the seller at settlement${upfrontFee === null ? "" : `; protocol fee ${formatUsdc(upfrontFee)} as the seller reports it`})`,
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
"refundable",
|
|
299
|
+
`${formatUsdc(quote.refundableAmount ?? 0n)} (metered; the most any refund can return)`,
|
|
300
|
+
],
|
|
301
|
+
];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The settlement transaction hash from the facilitator's `PAYMENT-RESPONSE`,
|
|
305
|
+
* when it carries a well-formed one. Anything else (absent, empty, not a
|
|
306
|
+
* 32-byte hash) is `null`: a malformed value is never printed as a hash.
|
|
307
|
+
*/
|
|
308
|
+
export function settlementTransaction(paymentResponse) {
|
|
309
|
+
const value = paymentResponse?.transaction;
|
|
310
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value)
|
|
311
|
+
? value
|
|
312
|
+
: null;
|
|
313
|
+
}
|
|
314
|
+
const minBig = (a, b) => b !== undefined && b < a ? b : a;
|
|
315
|
+
/**
|
|
316
|
+
* The mandate this command signs: a standing `METRIK_AGENT_MANDATE_*` ceiling
|
|
317
|
+
* INTERSECTED with every flag (the most restrictive value wins), or, with no
|
|
318
|
+
* standing ceiling, one sized to the flags. A flag can only tighten a
|
|
319
|
+
* standing ceiling, never loosen or bypass it; an `--operator` outside a
|
|
320
|
+
* standing allowlist is refused outright.
|
|
321
|
+
*/
|
|
322
|
+
export function intersectCaps(envCaps, flags) {
|
|
323
|
+
if (envCaps === null) {
|
|
324
|
+
const amount = flags.maxAmount;
|
|
325
|
+
return {
|
|
326
|
+
maxPerStreamUsdc: amount,
|
|
327
|
+
maxTotalUsdc: amount,
|
|
328
|
+
// No --max-rate: the price is the only cap on how fast the seller can
|
|
329
|
+
// earn it. Reported as minEarnSeconds so the buyer can see it.
|
|
330
|
+
maxRatePerSecondUsdc: flags.maxRate ?? amount,
|
|
331
|
+
maxDurationSeconds: flags.maxDuration ?? DEFAULT_MAX_DURATION_SECONDS,
|
|
332
|
+
allowedOperators: flags.operator === undefined ? [] : [flags.operator],
|
|
333
|
+
ttlSeconds: DEFAULT_SERVER_MANDATE_TTL_SECONDS,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
let allowedOperators = envCaps.allowedOperators;
|
|
337
|
+
if (flags.operator !== undefined) {
|
|
338
|
+
if (allowedOperators.length > 0 &&
|
|
339
|
+
!allowedOperators.some((entry) => entry.toLowerCase() === flags.operator?.toLowerCase())) {
|
|
340
|
+
throw new CliError(`--operator ${flags.operator} is not in METRIK_AGENT_MANDATE_ALLOWED_OPERATORS`, {
|
|
341
|
+
exitCode: 3,
|
|
342
|
+
hint: "a flag can only narrow the standing mandate, never widen it. Nothing was sent.",
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
allowedOperators = [flags.operator];
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
maxPerStreamUsdc: minBig(envCaps.maxPerStreamUsdc, flags.maxAmount),
|
|
349
|
+
maxTotalUsdc: minBig(envCaps.maxTotalUsdc, flags.maxAmount),
|
|
350
|
+
maxRatePerSecondUsdc: minBig(envCaps.maxRatePerSecondUsdc, flags.maxRate),
|
|
351
|
+
maxDurationSeconds: flags.maxDuration !== undefined &&
|
|
352
|
+
flags.maxDuration < envCaps.maxDurationSeconds
|
|
353
|
+
? flags.maxDuration
|
|
354
|
+
: envCaps.maxDurationSeconds,
|
|
355
|
+
allowedOperators,
|
|
356
|
+
ttlSeconds: envCaps.ttlSeconds,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function requireX402(x402) {
|
|
360
|
+
if (x402 === undefined) {
|
|
361
|
+
throw new CliError("this CLI build has no x402 dependency wired (CliDependencies.x402)", { exitCode: 4 });
|
|
362
|
+
}
|
|
363
|
+
return x402;
|
|
364
|
+
}
|
|
365
|
+
function parseResourceUrl(raw) {
|
|
366
|
+
let url;
|
|
367
|
+
try {
|
|
368
|
+
url = new URL(raw);
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
throw usageError(`<url> must be an absolute http(s) URL (got "${raw}")`);
|
|
372
|
+
}
|
|
373
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
374
|
+
throw usageError(`<url> must be http(s) (got "${url.protocol}")`);
|
|
375
|
+
}
|
|
376
|
+
return url.toString();
|
|
377
|
+
}
|
|
378
|
+
function buildRequest(context) {
|
|
379
|
+
const { args } = context;
|
|
380
|
+
const data = stringFlag(args, "data");
|
|
381
|
+
const jsonValue = jsonBodyFlag(args);
|
|
382
|
+
const jsonAlias = stringFlag(args, "json-body");
|
|
383
|
+
if (jsonValue !== undefined && jsonAlias !== undefined) {
|
|
384
|
+
throw usageError("give the JSON body once: --json <body> or --json-body <body>");
|
|
385
|
+
}
|
|
386
|
+
const jsonBody = jsonValue ?? jsonAlias;
|
|
387
|
+
if (data !== undefined && jsonBody !== undefined) {
|
|
388
|
+
throw usageError("give either --data or --json <body>, not both");
|
|
389
|
+
}
|
|
390
|
+
if (jsonBody !== undefined) {
|
|
391
|
+
try {
|
|
392
|
+
JSON.parse(jsonBody);
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
throw usageError("--json <body> must be valid JSON");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const body = jsonBody ?? data;
|
|
399
|
+
const method = (stringFlag(args, "method") ?? (body === undefined ? "GET" : "POST")).toUpperCase();
|
|
400
|
+
const headers = parseHeaders(stringFlags(args, "header"));
|
|
401
|
+
if (jsonBody !== undefined && !hasHeader(headers, "content-type")) {
|
|
402
|
+
headers["content-type"] = "application/json";
|
|
403
|
+
}
|
|
404
|
+
for (const name of Object.keys(headers)) {
|
|
405
|
+
if (name === "payment-signature" || name === "x-payment") {
|
|
406
|
+
throw usageError(`do not set the ${name} header: the payment is signed by this command, after the quote passes the mandate`);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
method,
|
|
411
|
+
headers,
|
|
412
|
+
...(body === undefined ? {} : { body }),
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function truncate(text) {
|
|
416
|
+
return text.length <= MAX_PRINTED_BODY_CHARS
|
|
417
|
+
? text
|
|
418
|
+
: `${text.slice(0, MAX_PRINTED_BODY_CHARS)}\n… (${text.length - MAX_PRINTED_BODY_CHARS} more characters; use --json for the whole body)`;
|
|
419
|
+
}
|
|
420
|
+
async function payOrExplain(x402, input) {
|
|
421
|
+
try {
|
|
422
|
+
return await x402.pay(input);
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
throw explainPayFailure(error);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/** Map the SDK's and the mandate's typed failures onto CLI exit codes. */
|
|
429
|
+
export function explainPayFailure(error) {
|
|
430
|
+
if (!(error instanceof Error))
|
|
431
|
+
return error;
|
|
432
|
+
switch (error.name) {
|
|
433
|
+
case "X402MandateDeniedError":
|
|
434
|
+
return new CliError(error.message, {
|
|
435
|
+
exitCode: 3,
|
|
436
|
+
hint: "raise --max-amount / --max-rate / --max-duration (or METRIK_AGENT_MANDATE_*) only if you mean to pay that much, that fast, for that long.",
|
|
437
|
+
cause: error,
|
|
438
|
+
});
|
|
439
|
+
case "X402PaymentRefusedError":
|
|
440
|
+
return new CliError(error.message, {
|
|
441
|
+
exitCode: 3,
|
|
442
|
+
hint: /maxUpfrontAmount/.test(error.message)
|
|
443
|
+
? "the quote's NON-REFUNDABLE upfront (per-call) charge is above your cap (--max-upfront, default 0.10 USDC). Raise --max-upfront only if you accept losing that much per call whatever is delivered. Nothing was signed."
|
|
444
|
+
: /exceeds maxAmount|exceeds maxRatePerSecond/.test(error.message)
|
|
445
|
+
? "that ceiling is your spend mandate's (--max-amount / --max-rate or METRIK_AGENT_MANDATE_*), handed to the SDK as a second gate. Nothing was signed."
|
|
446
|
+
: "the quote failed one of the SDK's protections (wrong network or token, unknown factory, payTo != factory.predict(terms), invalid upfront terms, not an opener payment, ...). Nothing was signed.",
|
|
447
|
+
cause: error,
|
|
448
|
+
});
|
|
449
|
+
case "X402PostSignatureError": {
|
|
450
|
+
// The signature was handed out: never say "nothing moved" unless the
|
|
451
|
+
// chain proves the authorization can never be used.
|
|
452
|
+
const post = error;
|
|
453
|
+
if (post.upfrontOnly && post.state === "used") {
|
|
454
|
+
return new CliError(error.message, {
|
|
455
|
+
exitCode: 4,
|
|
456
|
+
hint: "the money LEFT the payer as an upfront-only (minimum-charge) payment: the whole price was a non-refundable per-call charge and no stream was opened, so there is nothing to refund or reclaim. Keep this output as evidence if the response was not delivered (see docs/x402.md).",
|
|
457
|
+
cause: error,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const recover = post.streamId === null
|
|
461
|
+
? ""
|
|
462
|
+
: ` Recover the unearned part: metrik refund ${post.streamId} --refund-url <the seller's relay> --close --reclaim (or metrik reclaim ${post.streamId}).`;
|
|
463
|
+
return new CliError(error.message, {
|
|
464
|
+
exitCode: 4,
|
|
465
|
+
hint: post.state === "used"
|
|
466
|
+
? `the money LEFT the payer.${post.streamId === null ? " Its stream could not be identified on-chain; keep this output as evidence (see docs/x402.md)." : ` It is in stream ${post.streamId} (opener ${post.opener}).`}${recover}`
|
|
467
|
+
: post.state === "possibly-used"
|
|
468
|
+
? "whether the authorization was used could not be established: treat the payment as SPENT and check USDC.authorizationState before paying again (see docs/x402.md)."
|
|
469
|
+
: post.state === "unused-but-valid"
|
|
470
|
+
? "it has not moved yet, but the seller holds a signature valid until its validBefore: treat it as spent, or cancel it with USDC.cancelAuthorization (needs gas). See docs/x402.md."
|
|
471
|
+
: "the authorization was never used and has expired: nothing moved.",
|
|
472
|
+
cause: error,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
default:
|
|
476
|
+
return error;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
//# sourceMappingURL=pay.js.map
|