@absol-labs/agent 0.10.0 → 0.12.0-rc.1
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 +106 -30
- package/dist/capability/invocation-capability.d.ts +20 -8
- package/dist/capability/invocation-capability.d.ts.map +1 -1
- package/dist/capability/invocation-capability.js.map +1 -1
- 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.map +1 -1
- package/dist/cli/commands/claim.js +21 -5
- 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 +51 -7
- 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 +3 -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 +121 -15
- package/dist/cli/commands/open.js.map +1 -1
- package/dist/cli/commands/pay.d.ts +19 -0
- package/dist/cli/commands/pay.d.ts.map +1 -0
- package/dist/cli/commands/pay.js +355 -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 +15 -6
- 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 +200 -21
- package/dist/cli/commands/reclaim.js.map +1 -1
- package/dist/cli/commands/refund.d.ts +13 -0
- package/dist/cli/commands/refund.d.ts.map +1 -0
- package/dist/cli/commands/refund.js +224 -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 +10 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/streams.js +9 -13
- 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 +2 -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/deps.d.ts +86 -7
- package/dist/cli/deps.d.ts.map +1 -1
- package/dist/cli/deps.js +102 -16
- 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 +83 -0
- package/dist/cli/privy.d.ts.map +1 -0
- package/dist/cli/privy.js +232 -0
- package/dist/cli/privy.js.map +1 -0
- 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 +40 -11
- 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/spend-policy.d.ts +60 -0
- package/dist/cli/spend-policy.d.ts.map +1 -0
- package/dist/cli/spend-policy.js +65 -0
- package/dist/cli/spend-policy.js.map +1 -0
- package/dist/cli/status.d.ts +3 -1
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +15 -3
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/wallet.d.ts +109 -40
- package/dist/cli/wallet.d.ts.map +1 -1
- package/dist/cli/wallet.js +109 -44
- 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 +91 -4
- package/dist/gateway/caller-auth-gateway.d.ts.map +1 -1
- package/dist/gateway/caller-auth-gateway.js +184 -7
- package/dist/gateway/caller-auth-gateway.js.map +1 -1
- package/dist/gateway/http-server.d.ts +121 -1
- package/dist/gateway/http-server.d.ts.map +1 -1
- package/dist/gateway/http-server.js +474 -5
- 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 +215 -0
- package/dist/gateway/x402-opener-mode.d.ts.map +1 -0
- package/dist/gateway/x402-opener-mode.js +639 -0
- package/dist/gateway/x402-opener-mode.js.map +1 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/mandates/env.d.ts +3 -2
- package/dist/mandates/env.d.ts.map +1 -1
- package/dist/mandates/env.js +3 -2
- package/dist/mandates/env.js.map +1 -1
- package/dist/mcp/server.d.ts +100 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +719 -39
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/service-invoker.d.ts +97 -0
- package/dist/mcp/service-invoker.d.ts.map +1 -0
- package/dist/mcp/service-invoker.js +167 -0
- package/dist/mcp/service-invoker.js.map +1 -0
- package/dist/mcp/x402-tools.d.ts +104 -0
- package/dist/mcp/x402-tools.d.ts.map +1 -0
- package/dist/mcp/x402-tools.js +434 -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/invoke.d.ts +23 -4
- package/dist/sdk/invoke.d.ts.map +1 -1
- package/dist/sdk/invoke.js +71 -10
- 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 +42 -17
- package/dist/x402/facilitator.d.ts.map +1 -1
- package/dist/x402/facilitator.js +49 -33
- 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 +135 -0
- package/dist/x402-buyer/pay.d.ts.map +1 -0
- package/dist/x402-buyer/pay.js +336 -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 +37 -0
- package/dist/x402-opener/facilitator-entry.js.map +1 -0
- package/dist/x402-opener/facilitator-server.d.ts +180 -0
- package/dist/x402-opener/facilitator-server.d.ts.map +1 -0
- package/dist/x402-opener/facilitator-server.js +696 -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 +240 -0
- package/dist/x402-opener/refund-relay.d.ts.map +1 -0
- package/dist/x402-opener/refund-relay.js +1240 -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 +217 -0
- package/dist/x402-opener/scheme.d.ts.map +1 -0
- package/dist/x402-opener/scheme.js +749 -0
- package/dist/x402-opener/scheme.js.map +1 -0
- package/dist/x402-opener/terms.d.ts +105 -0
- package/dist/x402-opener/terms.d.ts.map +1 -0
- package/dist/x402-opener/terms.js +212 -0
- package/dist/x402-opener/terms.js.map +1 -0
- package/dist/zktls/reclaim.d.ts +2 -2
- package/docs/agent-layer.md +13 -8
- package/docs/autonomous-privy-wallet.md +188 -0
- package/docs/cli.md +342 -53
- package/docs/langchain.md +5 -0
- package/docs/mcp-hosted.md +4 -3
- package/docs/mcp-reference.md +245 -0
- package/docs/probe-capability.md +191 -0
- package/docs/quickstart.md +54 -5
- package/docs/threat-model.md +24 -3
- package/docs/x402.md +681 -0
- package/package.json +19 -6
- package/src/capability/invocation-capability.ts +17 -1
- package/src/capability/probe-capability.ts +355 -0
- package/src/cli/args.ts +29 -0
- package/src/cli/commands/claim.ts +31 -5
- package/src/cli/commands/close.ts +56 -7
- package/src/cli/commands/invoke.ts +6 -2
- package/src/cli/commands/mcp.ts +18 -2
- package/src/cli/commands/open.ts +151 -14
- package/src/cli/commands/pay.ts +442 -0
- package/src/cli/commands/reclaim-unverified.ts +24 -6
- package/src/cli/commands/reclaim.ts +274 -19
- package/src/cli/commands/refund.ts +277 -0
- package/src/cli/commands/status.ts +17 -1
- package/src/cli/commands/streams.ts +11 -15
- package/src/cli/commands/watch.ts +7 -1
- package/src/cli/config.ts +139 -52
- package/src/cli/deps.ts +189 -25
- 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 +398 -0
- package/src/cli/reclaimability.ts +154 -0
- package/src/cli/run.ts +54 -11
- package/src/cli/scan-range.ts +2 -2
- package/src/cli/spend-policy.ts +139 -0
- package/src/cli/status.ts +14 -1
- package/src/cli/wallet.ts +189 -58
- 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 +336 -13
- package/src/gateway/http-server.ts +690 -7
- package/src/gateway/probe-auth.ts +191 -0
- package/src/gateway/signed-rate-bounds.ts +164 -0
- package/src/gateway/x402-opener-mode.ts +974 -0
- package/src/index.ts +112 -14
- package/src/mandates/env.ts +3 -2
- package/src/mcp/server.ts +973 -44
- package/src/mcp/service-invoker.ts +285 -0
- package/src/mcp/x402-tools.ts +621 -0
- package/src/network.ts +302 -0
- package/src/sdk/invoke.ts +96 -17
- 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 +85 -46
- package/src/x402-buyer/guarded-fetch.ts +213 -0
- package/src/x402-buyer/index.ts +9 -0
- package/src/x402-buyer/pay.ts +517 -0
- package/src/x402-opener/abi.ts +881 -0
- package/src/x402-opener/facilitator-entry.ts +45 -0
- package/src/x402-opener/facilitator-server.ts +1014 -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 +1743 -0
- package/src/x402-opener/relayer-queue.ts +18 -0
- package/src/x402-opener/scheme.ts +1133 -0
- package/src/x402-opener/terms.ts +300 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/cli/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EA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"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/open.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,WAuUzB,CAAC"}
|
|
@@ -2,11 +2,14 @@ import { MandateDeniedError } from "../../sdk/client.js";
|
|
|
2
2
|
import { booleanFlag, requiredStringFlag, stringFlag } from "../args.js";
|
|
3
3
|
import { formatDuration, formatUsdc, parseAmountUnits, parseDurationSeconds, parseUsdcAmount, } from "../amounts.js";
|
|
4
4
|
import { assertTestnetRpc, parseBytes32 } from "../config.js";
|
|
5
|
+
import { writeClientOptions } from "../deps.js";
|
|
5
6
|
import { CliError, configError } from "../errors.js";
|
|
7
|
+
import { assertWithinOperatorCaps, assertWithinSpendPolicy, } from "../spend-policy.js";
|
|
6
8
|
import { cliMandateCaps, signCliMandate } from "../mandate.js";
|
|
7
9
|
import { assertCanFundStream, assertCanPayGas } from "../preflight.js";
|
|
8
|
-
import { optionalCliWallet, resolveCliWallet, PRIVATE_KEY_ENV, } from "../wallet.js";
|
|
9
|
-
import {
|
|
10
|
+
import { isPolicyEnforced, optionalCliWallet, resolveCliWallet, PRIVATE_KEY_ENV, } from "../wallet.js";
|
|
11
|
+
import { resolveListingRecord } from "../listings.js";
|
|
12
|
+
import { listingRateBand, rateBandRefusal, SignedRateBoundsError, } from "../../discovery/rate-band.js";
|
|
10
13
|
export const openCommand = {
|
|
11
14
|
name: "open",
|
|
12
15
|
summary: "Hire a verified service: escrow USDC into a metered stream",
|
|
@@ -44,34 +47,54 @@ export const openCommand = {
|
|
|
44
47
|
// the intended call and says which parts (allowance, simulation, mandate
|
|
45
48
|
// signature) could not be produced, rather than inventing them.
|
|
46
49
|
const wallet = dryRun
|
|
47
|
-
? await optionalCliWallet(env, { note: out.note })
|
|
48
|
-
: await resolveCliWallet(env, { note: out.note });
|
|
50
|
+
? await optionalCliWallet(env, { note: out.note, rpcUrl: config.rpcUrl })
|
|
51
|
+
: await resolveCliWallet(env, { note: out.note, rpcUrl: config.rpcUrl });
|
|
49
52
|
const account = wallet?.account ?? null;
|
|
50
53
|
const read = deps.createReadClient(config);
|
|
51
54
|
await assertTestnetRpc(config, () => read.getChainId());
|
|
52
55
|
if (account !== null && !dryRun) {
|
|
53
56
|
// Both balances, before anything is signed. Gas first: a wallet with no
|
|
54
57
|
// ETH cannot send the approval that the USDC check exists to protect.
|
|
55
|
-
await assertCanPayGas(read, account.address);
|
|
56
|
-
await assertCanFundStream(read, account.address, budgetUsdc);
|
|
58
|
+
await assertCanPayGas(read, account.address, config.network);
|
|
59
|
+
await assertCanFundStream(read, account.address, budgetUsdc, config.network);
|
|
57
60
|
}
|
|
58
61
|
const operatorOverride = stringFlag(args, "operator");
|
|
59
|
-
const
|
|
62
|
+
const resolution = await resolveListingRecord(context, serviceRef, {
|
|
60
63
|
required: operatorOverride === undefined,
|
|
61
64
|
});
|
|
65
|
+
const listing = resolution.listing;
|
|
66
|
+
await assertRateInSignedBand(context, resolution, ratePerSecondUsdc);
|
|
62
67
|
const operator = (operatorOverride ?? listing?.operator);
|
|
63
68
|
if (operator === undefined) {
|
|
64
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.");
|
|
65
70
|
}
|
|
66
71
|
const spend = { operator, budgetUsdc, ratePerSecondUsdc, durationSeconds };
|
|
67
|
-
const
|
|
72
|
+
const mandateCaps = cliMandateCaps(spend, env);
|
|
73
|
+
// A policy-enforced wallet (Privy) is capped by its broker, not by a
|
|
74
|
+
// mandate this process signs for itself. Read the REAL ceiling and hold it
|
|
75
|
+
// to that instead — see `../spend-policy.ts` for why that substitution is
|
|
76
|
+
// the stronger of the two, and why re-adding the self-signed mandate here
|
|
77
|
+
// would both weaken it and break the wallet outright.
|
|
78
|
+
const policy = wallet !== null && isPolicyEnforced(wallet)
|
|
79
|
+
? await wallet.readSpendPolicy()
|
|
80
|
+
: null;
|
|
81
|
+
if (policy !== null && !dryRun) {
|
|
82
|
+
assertWithinSpendPolicy(policy, spend);
|
|
83
|
+
// The operator's own standing ceiling still applies, and may be TIGHTER
|
|
84
|
+
// than the broker's. Enforced here because no mandate is signed to carry
|
|
85
|
+
// it — "policy-enforced" retires the self-signed mandate, not the caps
|
|
86
|
+
// the operator deliberately configured.
|
|
87
|
+
if (mandateCaps.source === "env") {
|
|
88
|
+
assertWithinOperatorCaps(mandateCaps.caps, spend);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const mandate = account === null || policy !== null
|
|
68
92
|
? null
|
|
69
93
|
: await signCliMandate(account, spend, {
|
|
70
94
|
chainId: config.chainId,
|
|
71
95
|
env,
|
|
72
96
|
});
|
|
73
|
-
const
|
|
74
|
-
const write = deps.createWriteClient(config, account);
|
|
97
|
+
const write = deps.createWriteClient(config, account, writeClientOptions(wallet));
|
|
75
98
|
const hire = {
|
|
76
99
|
operator,
|
|
77
100
|
serviceRef,
|
|
@@ -104,6 +127,17 @@ export const openCommand = {
|
|
|
104
127
|
durationSeconds,
|
|
105
128
|
mandateSource: mandateCaps.source,
|
|
106
129
|
mandateSigned: mandate !== null,
|
|
130
|
+
spendPolicy: policy === null
|
|
131
|
+
? null
|
|
132
|
+
: {
|
|
133
|
+
brokerUrl: policy.brokerUrl,
|
|
134
|
+
maxTotalUsdc: policy.maxTotalUsdc,
|
|
135
|
+
maxRatePerSecondUsdc: policy.maxRatePerSecondUsdc,
|
|
136
|
+
maxDurationSeconds: policy.maxDurationSeconds,
|
|
137
|
+
fits: budgetUsdc <= policy.maxTotalUsdc &&
|
|
138
|
+
ratePerSecondUsdc <= policy.maxRatePerSecondUsdc &&
|
|
139
|
+
durationSeconds <= policy.maxDurationSeconds,
|
|
140
|
+
},
|
|
107
141
|
to: preview.to,
|
|
108
142
|
data: preview.data,
|
|
109
143
|
chainId: preview.chainId,
|
|
@@ -139,10 +173,28 @@ export const openCommand = {
|
|
|
139
173
|
["duration", formatDuration(durationSeconds)],
|
|
140
174
|
[
|
|
141
175
|
"mandate",
|
|
142
|
-
mandate
|
|
143
|
-
? `
|
|
144
|
-
:
|
|
176
|
+
mandate !== null
|
|
177
|
+
? `self-signed, caps from ${mandateCaps.source}`
|
|
178
|
+
: policy !== null
|
|
179
|
+
? "not signed — this wallet's ceiling is enforced by its broker, which is stronger"
|
|
180
|
+
: `not signed (no wallet); caps would come from ${mandateCaps.source}`,
|
|
145
181
|
],
|
|
182
|
+
...(policy === null
|
|
183
|
+
? []
|
|
184
|
+
: [
|
|
185
|
+
[
|
|
186
|
+
"spend policy",
|
|
187
|
+
`${formatUsdc(policy.maxTotalUsdc)} total, ${policy.maxRatePerSecondUsdc} atomic/second, ${formatDuration(policy.maxDurationSeconds)} max — enforced by ${policy.brokerUrl}`,
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
"fits policy",
|
|
191
|
+
budgetUsdc <= policy.maxTotalUsdc &&
|
|
192
|
+
ratePerSecondUsdc <= policy.maxRatePerSecondUsdc &&
|
|
193
|
+
durationSeconds <= policy.maxDurationSeconds
|
|
194
|
+
? "yes"
|
|
195
|
+
: "NO — a real open would be refused before broadcasting",
|
|
196
|
+
],
|
|
197
|
+
]),
|
|
146
198
|
["escrow", preview.to],
|
|
147
199
|
[
|
|
148
200
|
"usdc balance",
|
|
@@ -175,7 +227,7 @@ export const openCommand = {
|
|
|
175
227
|
out.note(`opening a stream on chain ${config.chainId} for ${formatUsdc(budgetUsdc)} …`);
|
|
176
228
|
// Unreachable without a wallet: `resolveCliWallet` above throws when the
|
|
177
229
|
// command is not a dry run. The narrowing keeps that a type-level fact.
|
|
178
|
-
if (account === null
|
|
230
|
+
if (account === null) {
|
|
179
231
|
throw configError("this command signs a transaction and needs a wallet, and none was resolved");
|
|
180
232
|
}
|
|
181
233
|
let result;
|
|
@@ -186,7 +238,10 @@ export const openCommand = {
|
|
|
186
238
|
budgetUsdc,
|
|
187
239
|
ratePerSecondUsdc,
|
|
188
240
|
maxDurationSeconds: durationSeconds,
|
|
189
|
-
|
|
241
|
+
// `null` for a policy-enforced wallet: the ceiling was checked against
|
|
242
|
+
// the broker's own policy above, and the broker checks it again on the
|
|
243
|
+
// transaction it signs.
|
|
244
|
+
signedMandate: mandate === null ? null : mandate.signed,
|
|
190
245
|
spentSoFarUsdc: 0n,
|
|
191
246
|
nowSeconds: deps.nowSeconds(),
|
|
192
247
|
});
|
|
@@ -233,6 +288,57 @@ export const openCommand = {
|
|
|
233
288
|
out.print(`Next: metrik status ${result.streamId}`);
|
|
234
289
|
},
|
|
235
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
|
+
}
|
|
236
342
|
/**
|
|
237
343
|
* What the buyer is actually paying for.
|
|
238
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,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,MAAM,aAAa,GACjB,sUAAsU,CAAC;AAEzU;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAsB;IAC7C,oCAAoC;IACpC,yBAAyB;IACzB,4BAA4B;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,19 @@
|
|
|
1
|
+
import { type ServerMandateCaps } from "../../mandates/env.js";
|
|
2
|
+
import type { CommandSpec } from "../context.js";
|
|
3
|
+
export declare const payCommand: CommandSpec;
|
|
4
|
+
/**
|
|
5
|
+
* The mandate this command signs: a standing `METRIK_AGENT_MANDATE_*` ceiling
|
|
6
|
+
* INTERSECTED with every flag (the most restrictive value wins), or, with no
|
|
7
|
+
* standing ceiling, one sized to the flags. A flag can only tighten a
|
|
8
|
+
* standing ceiling, never loosen or bypass it; an `--operator` outside a
|
|
9
|
+
* standing allowlist is refused outright.
|
|
10
|
+
*/
|
|
11
|
+
export declare function intersectCaps(envCaps: ServerMandateCaps | null, flags: {
|
|
12
|
+
readonly maxAmount: bigint | undefined;
|
|
13
|
+
readonly maxRate: bigint | undefined;
|
|
14
|
+
readonly maxDuration: number | undefined;
|
|
15
|
+
readonly operator: `0x${string}` | undefined;
|
|
16
|
+
}): ServerMandateCaps;
|
|
17
|
+
/** Map the SDK's and the mandate's typed failures onto CLI exit codes. */
|
|
18
|
+
export declare function explainPayFailure(error: unknown): unknown;
|
|
19
|
+
//# sourceMappingURL=pay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/pay.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAsB/B,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAOjE,eAAO,MAAM,UAAU,EAAE,WAsNxB,CAAC;AAKF;;;;;;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,CAyCzD"}
|
|
@@ -0,0 +1,355 @@
|
|
|
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 { 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-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-duration",
|
|
26
|
+
"min-duration",
|
|
27
|
+
"operator",
|
|
28
|
+
"units",
|
|
29
|
+
"allow-legacy-factory",
|
|
30
|
+
],
|
|
31
|
+
// It moves the payer's USDC (an EIP-3009 authorization the facilitator
|
|
32
|
+
// settles into the escrow). The PAYER broadcasts nothing and needs no gas,
|
|
33
|
+
// but it is a fund-moving command and is gated like one.
|
|
34
|
+
signs: true,
|
|
35
|
+
async run(context) {
|
|
36
|
+
const { args, config, env, out, deps } = context;
|
|
37
|
+
const x402 = requireX402(deps.x402);
|
|
38
|
+
const [urlArg] = args.positionals;
|
|
39
|
+
if (urlArg === undefined) {
|
|
40
|
+
throw usageError("metrik pay requires the <url> of an x402 endpoint");
|
|
41
|
+
}
|
|
42
|
+
const url = parseResourceUrl(urlArg);
|
|
43
|
+
const units = parseAmountUnits(stringFlag(args, "units"));
|
|
44
|
+
const maxAmountRaw = stringFlag(args, "max-amount");
|
|
45
|
+
const maxAmount = maxAmountRaw === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: parseUsdcAmount(maxAmountRaw, units, "max-amount");
|
|
48
|
+
const maxRateRaw = stringFlag(args, "max-rate");
|
|
49
|
+
const maxRate = maxRateRaw === undefined
|
|
50
|
+
? undefined
|
|
51
|
+
: parseUsdcAmount(maxRateRaw, units, "max-rate");
|
|
52
|
+
const maxDurationRaw = stringFlag(args, "max-duration");
|
|
53
|
+
const maxDuration = maxDurationRaw === undefined
|
|
54
|
+
? undefined
|
|
55
|
+
: parseDurationSeconds(maxDurationRaw);
|
|
56
|
+
const minDuration = integerFlag(args, "min-duration");
|
|
57
|
+
const operator = stringFlag(args, "operator");
|
|
58
|
+
if (operator !== undefined && !/^0x[0-9a-fA-F]{40}$/.test(operator)) {
|
|
59
|
+
throw usageError(`--operator must be an EVM address (got "${operator}")`);
|
|
60
|
+
}
|
|
61
|
+
if (maxAmount !== undefined && maxAmount <= 0n) {
|
|
62
|
+
throw usageError("--max-amount must be greater than zero");
|
|
63
|
+
}
|
|
64
|
+
if (maxRate !== undefined && maxRate <= 0n) {
|
|
65
|
+
throw usageError("--max-rate must be greater than zero");
|
|
66
|
+
}
|
|
67
|
+
const init = buildRequest(context);
|
|
68
|
+
// The mandate: an operator-set standing ceiling (METRIK_AGENT_MANDATE_*),
|
|
69
|
+
// or one sized to exactly this payment. Either way it is SIGNED and
|
|
70
|
+
// `checkMandate()` gates the quote before anything is signed for the
|
|
71
|
+
// seller. There is no unbounded path: without standing caps, --max-amount
|
|
72
|
+
// is required.
|
|
73
|
+
const envCaps = parseServerMandateCapsEnv(env);
|
|
74
|
+
if (envCaps === null && maxAmount === undefined) {
|
|
75
|
+
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.");
|
|
76
|
+
}
|
|
77
|
+
const caps = intersectCaps(envCaps, {
|
|
78
|
+
maxAmount,
|
|
79
|
+
maxRate,
|
|
80
|
+
maxDuration,
|
|
81
|
+
operator: operator,
|
|
82
|
+
});
|
|
83
|
+
const wallet = await resolveCliWallet(env, {
|
|
84
|
+
note: out.note,
|
|
85
|
+
rpcUrl: config.rpcUrl,
|
|
86
|
+
});
|
|
87
|
+
if (isPrivyWalletSource(wallet.source)) {
|
|
88
|
+
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.");
|
|
89
|
+
}
|
|
90
|
+
const { account } = wallet;
|
|
91
|
+
const read = deps.createReadClient(config);
|
|
92
|
+
await assertTestnetRpc(config, () => read.getChainId());
|
|
93
|
+
// The payer needs USDC only — no gas: the facilitator's relayer submits
|
|
94
|
+
// the authorization. A zero balance is a knowable fact before signing.
|
|
95
|
+
const balance = await read.usdcBalance(account.address).catch(() => null);
|
|
96
|
+
if (balance === 0n) {
|
|
97
|
+
throw new CliError(`wallet ${account.address} holds 0 USDC on ${config.network.name}, so it cannot pay`, {
|
|
98
|
+
exitCode: 3,
|
|
99
|
+
hint: `${usdcFundingHint(config.network)}, then re-run. (An x402 payer needs USDC only; no gas.)`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const signedMandate = await signServerMandate(account, caps, {
|
|
103
|
+
chainId: config.chainId,
|
|
104
|
+
});
|
|
105
|
+
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_*"}) …`);
|
|
106
|
+
const result = await payOrExplain(x402, {
|
|
107
|
+
url,
|
|
108
|
+
init,
|
|
109
|
+
signer: account,
|
|
110
|
+
network: config.network,
|
|
111
|
+
signedMandate,
|
|
112
|
+
spentSoFarUsdc: 0n,
|
|
113
|
+
nowSeconds: deps.nowSeconds(),
|
|
114
|
+
...(maxAmount === undefined ? {} : { maxAmount }),
|
|
115
|
+
...(maxRate === undefined ? {} : { maxRatePerSecond: maxRate }),
|
|
116
|
+
...(minDuration === undefined ? {} : { minDurationSeconds: minDuration }),
|
|
117
|
+
sdkOptions: {
|
|
118
|
+
transport: rpcTransport(config),
|
|
119
|
+
// A LEGACY deployment's factory is refused by the SDK unless the
|
|
120
|
+
// buyer opts in: streams there can still be closed and reclaimed, but
|
|
121
|
+
// nothing new should open on a generation being retired by default.
|
|
122
|
+
...(booleanFlag(args, "allow-legacy-factory")
|
|
123
|
+
? { allowLegacyFactory: true }
|
|
124
|
+
: {}),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
const bodyText = await result.response.text();
|
|
128
|
+
const opener = result.metrikStreamOpener;
|
|
129
|
+
const quote = result.quote;
|
|
130
|
+
out.result({
|
|
131
|
+
paid: result.paid,
|
|
132
|
+
httpStatus: result.response.status,
|
|
133
|
+
contentType: result.response.headers.get("content-type"),
|
|
134
|
+
body: bodyText,
|
|
135
|
+
streamId: opener?.streamId ?? null,
|
|
136
|
+
opener: opener?.opener ?? null,
|
|
137
|
+
refundUrl: opener?.refundUrl ?? null,
|
|
138
|
+
escrow: opener?.escrow ?? null,
|
|
139
|
+
deposit: opener?.deposit ?? null,
|
|
140
|
+
ratePerSecond: opener?.ratePerSecond ?? null,
|
|
141
|
+
expiresAt: opener?.expiresAt ?? null,
|
|
142
|
+
operator: quote?.operator ?? null,
|
|
143
|
+
serviceRef: quote?.serviceRef ?? null,
|
|
144
|
+
minEarnSeconds: quote?.minEarnSeconds ?? null,
|
|
145
|
+
mandateSource: envCaps === null ? "request" : "env",
|
|
146
|
+
refundIsAutomatic: false,
|
|
147
|
+
});
|
|
148
|
+
if (!result.paid) {
|
|
149
|
+
out.print(`The endpoint answered ${result.response.status} without asking for payment; nothing was signed or paid.`);
|
|
150
|
+
out.print(truncate(bodyText));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
out.print(`Paid. HTTP ${result.response.status}`);
|
|
154
|
+
out.print(truncate(bodyText));
|
|
155
|
+
out.print("");
|
|
156
|
+
if (opener !== null) {
|
|
157
|
+
out.table([
|
|
158
|
+
["streamId", opener.streamId],
|
|
159
|
+
["opener", opener.opener],
|
|
160
|
+
["payer", account.address],
|
|
161
|
+
...(opener.deposit === null
|
|
162
|
+
? []
|
|
163
|
+
: [["deposit", formatUsdc(opener.deposit)]]),
|
|
164
|
+
...(opener.ratePerSecond === null
|
|
165
|
+
? []
|
|
166
|
+
: [
|
|
167
|
+
["rate", `${formatUsdc(opener.ratePerSecond)} / verified second`],
|
|
168
|
+
]),
|
|
169
|
+
...(quote?.minEarnSeconds === null ||
|
|
170
|
+
quote?.minEarnSeconds === undefined
|
|
171
|
+
? []
|
|
172
|
+
: [
|
|
173
|
+
[
|
|
174
|
+
"fully earned after",
|
|
175
|
+
`${formatDuration(Number(quote.minEarnSeconds))} of verified delivery`,
|
|
176
|
+
],
|
|
177
|
+
]),
|
|
178
|
+
...(opener.expiresAt === null
|
|
179
|
+
? []
|
|
180
|
+
: [
|
|
181
|
+
["expires", new Date(opener.expiresAt * 1000).toISOString()],
|
|
182
|
+
]),
|
|
183
|
+
["refund url", opener.refundUrl ?? "(the seller advertised no relay)"],
|
|
184
|
+
]);
|
|
185
|
+
out.print("");
|
|
186
|
+
// A stream on another (e.g. legacy) registered escrow is reached by
|
|
187
|
+
// naming that escrow; the CLI defaults to the network's current one.
|
|
188
|
+
const escrowFlag = opener.escrow !== null &&
|
|
189
|
+
opener.escrow.toLowerCase() !== config.escrow.toLowerCase()
|
|
190
|
+
? ` --escrow ${opener.escrow}`
|
|
191
|
+
: "";
|
|
192
|
+
out.print("Refunds are NOT automatic. The seller earns only for verified seconds; whatever is unearned stays in the escrow until someone reclaims it for you:");
|
|
193
|
+
out.print(opener.refundUrl === null
|
|
194
|
+
? ` metrik reclaim ${opener.streamId}${escrowFlag} (anyone may send it; the refund always goes to the payer)`
|
|
195
|
+
: ` metrik refund ${opener.streamId} --refund-url ${opener.refundUrl}${escrowFlag} --close --reclaim`);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
const minBig = (a, b) => b !== undefined && b < a ? b : a;
|
|
200
|
+
/**
|
|
201
|
+
* The mandate this command signs: a standing `METRIK_AGENT_MANDATE_*` ceiling
|
|
202
|
+
* INTERSECTED with every flag (the most restrictive value wins), or, with no
|
|
203
|
+
* standing ceiling, one sized to the flags. A flag can only tighten a
|
|
204
|
+
* standing ceiling, never loosen or bypass it; an `--operator` outside a
|
|
205
|
+
* standing allowlist is refused outright.
|
|
206
|
+
*/
|
|
207
|
+
export function intersectCaps(envCaps, flags) {
|
|
208
|
+
if (envCaps === null) {
|
|
209
|
+
const amount = flags.maxAmount;
|
|
210
|
+
return {
|
|
211
|
+
maxPerStreamUsdc: amount,
|
|
212
|
+
maxTotalUsdc: amount,
|
|
213
|
+
// No --max-rate: the price is the only cap on how fast the seller can
|
|
214
|
+
// earn it. Reported as minEarnSeconds so the buyer can see it.
|
|
215
|
+
maxRatePerSecondUsdc: flags.maxRate ?? amount,
|
|
216
|
+
maxDurationSeconds: flags.maxDuration ?? DEFAULT_MAX_DURATION_SECONDS,
|
|
217
|
+
allowedOperators: flags.operator === undefined ? [] : [flags.operator],
|
|
218
|
+
ttlSeconds: DEFAULT_SERVER_MANDATE_TTL_SECONDS,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
let allowedOperators = envCaps.allowedOperators;
|
|
222
|
+
if (flags.operator !== undefined) {
|
|
223
|
+
if (allowedOperators.length > 0 &&
|
|
224
|
+
!allowedOperators.some((entry) => entry.toLowerCase() === flags.operator?.toLowerCase())) {
|
|
225
|
+
throw new CliError(`--operator ${flags.operator} is not in METRIK_AGENT_MANDATE_ALLOWED_OPERATORS`, {
|
|
226
|
+
exitCode: 3,
|
|
227
|
+
hint: "a flag can only narrow the standing mandate, never widen it. Nothing was sent.",
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
allowedOperators = [flags.operator];
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
maxPerStreamUsdc: minBig(envCaps.maxPerStreamUsdc, flags.maxAmount),
|
|
234
|
+
maxTotalUsdc: minBig(envCaps.maxTotalUsdc, flags.maxAmount),
|
|
235
|
+
maxRatePerSecondUsdc: minBig(envCaps.maxRatePerSecondUsdc, flags.maxRate),
|
|
236
|
+
maxDurationSeconds: flags.maxDuration !== undefined &&
|
|
237
|
+
flags.maxDuration < envCaps.maxDurationSeconds
|
|
238
|
+
? flags.maxDuration
|
|
239
|
+
: envCaps.maxDurationSeconds,
|
|
240
|
+
allowedOperators,
|
|
241
|
+
ttlSeconds: envCaps.ttlSeconds,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function requireX402(x402) {
|
|
245
|
+
if (x402 === undefined) {
|
|
246
|
+
throw new CliError("this CLI build has no x402 dependency wired (CliDependencies.x402)", { exitCode: 4 });
|
|
247
|
+
}
|
|
248
|
+
return x402;
|
|
249
|
+
}
|
|
250
|
+
function parseResourceUrl(raw) {
|
|
251
|
+
let url;
|
|
252
|
+
try {
|
|
253
|
+
url = new URL(raw);
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
throw usageError(`<url> must be an absolute http(s) URL (got "${raw}")`);
|
|
257
|
+
}
|
|
258
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
259
|
+
throw usageError(`<url> must be http(s) (got "${url.protocol}")`);
|
|
260
|
+
}
|
|
261
|
+
return url.toString();
|
|
262
|
+
}
|
|
263
|
+
function buildRequest(context) {
|
|
264
|
+
const { args } = context;
|
|
265
|
+
const data = stringFlag(args, "data");
|
|
266
|
+
const jsonValue = jsonBodyFlag(args);
|
|
267
|
+
const jsonAlias = stringFlag(args, "json-body");
|
|
268
|
+
if (jsonValue !== undefined && jsonAlias !== undefined) {
|
|
269
|
+
throw usageError("give the JSON body once: --json <body> or --json-body <body>");
|
|
270
|
+
}
|
|
271
|
+
const jsonBody = jsonValue ?? jsonAlias;
|
|
272
|
+
if (data !== undefined && jsonBody !== undefined) {
|
|
273
|
+
throw usageError("give either --data or --json <body>, not both");
|
|
274
|
+
}
|
|
275
|
+
if (jsonBody !== undefined) {
|
|
276
|
+
try {
|
|
277
|
+
JSON.parse(jsonBody);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
throw usageError("--json <body> must be valid JSON");
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const body = jsonBody ?? data;
|
|
284
|
+
const method = (stringFlag(args, "method") ?? (body === undefined ? "GET" : "POST")).toUpperCase();
|
|
285
|
+
const headers = parseHeaders(stringFlags(args, "header"));
|
|
286
|
+
if (jsonBody !== undefined && !hasHeader(headers, "content-type")) {
|
|
287
|
+
headers["content-type"] = "application/json";
|
|
288
|
+
}
|
|
289
|
+
for (const name of Object.keys(headers)) {
|
|
290
|
+
if (name === "payment-signature" || name === "x-payment") {
|
|
291
|
+
throw usageError(`do not set the ${name} header: the payment is signed by this command, after the quote passes the mandate`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
method,
|
|
296
|
+
headers,
|
|
297
|
+
...(body === undefined ? {} : { body }),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function truncate(text) {
|
|
301
|
+
return text.length <= MAX_PRINTED_BODY_CHARS
|
|
302
|
+
? text
|
|
303
|
+
: `${text.slice(0, MAX_PRINTED_BODY_CHARS)}\n… (${text.length - MAX_PRINTED_BODY_CHARS} more characters; use --json for the whole body)`;
|
|
304
|
+
}
|
|
305
|
+
async function payOrExplain(x402, input) {
|
|
306
|
+
try {
|
|
307
|
+
return await x402.pay(input);
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
throw explainPayFailure(error);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** Map the SDK's and the mandate's typed failures onto CLI exit codes. */
|
|
314
|
+
export function explainPayFailure(error) {
|
|
315
|
+
if (!(error instanceof Error))
|
|
316
|
+
return error;
|
|
317
|
+
switch (error.name) {
|
|
318
|
+
case "X402MandateDeniedError":
|
|
319
|
+
return new CliError(error.message, {
|
|
320
|
+
exitCode: 3,
|
|
321
|
+
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.",
|
|
322
|
+
cause: error,
|
|
323
|
+
});
|
|
324
|
+
case "X402PaymentRefusedError":
|
|
325
|
+
return new CliError(error.message, {
|
|
326
|
+
exitCode: 3,
|
|
327
|
+
hint: /exceeds maxAmount|exceeds maxRatePerSecond/.test(error.message)
|
|
328
|
+
? "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."
|
|
329
|
+
: "the quote failed one of the SDK's protections (wrong network or token, unknown factory, payTo != factory.predict(terms), not an opener payment, ...). Nothing was signed.",
|
|
330
|
+
cause: error,
|
|
331
|
+
});
|
|
332
|
+
case "X402PostSignatureError": {
|
|
333
|
+
// The signature was handed out: never say "nothing moved" unless the
|
|
334
|
+
// chain proves the authorization can never be used.
|
|
335
|
+
const post = error;
|
|
336
|
+
const recover = post.streamId === null
|
|
337
|
+
? ""
|
|
338
|
+
: ` Recover the unearned part: metrik refund ${post.streamId} --refund-url <the seller's relay> --close --reclaim (or metrik reclaim ${post.streamId}).`;
|
|
339
|
+
return new CliError(error.message, {
|
|
340
|
+
exitCode: 4,
|
|
341
|
+
hint: post.state === "used"
|
|
342
|
+
? `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}`
|
|
343
|
+
: post.state === "possibly-used"
|
|
344
|
+
? "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)."
|
|
345
|
+
: post.state === "unused-but-valid"
|
|
346
|
+
? "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."
|
|
347
|
+
: "the authorization was never used and has expired: nothing moved.",
|
|
348
|
+
cause: error,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
default:
|
|
352
|
+
return error;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=pay.js.map
|