@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
|
@@ -14,9 +14,11 @@ import type { CliReadClient } from "./deps.js";
|
|
|
14
14
|
* — and `escapeGraceSeconds` is a public immutable on the escrow, so readiness
|
|
15
15
|
* is fully computable before a single wei of gas is spent.
|
|
16
16
|
*
|
|
17
|
-
* Note which timestamp the escrow uses
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Note which timestamp the escrow uses, which depends on its GENERATION (the
|
|
18
|
+
* SDK registry's `escrow.generation`; see `../escrow-generation.ts`): V2 uses
|
|
19
|
+
* `expiresAt`, NEVER `closedAt` — closing early does not bring the hatch
|
|
20
|
+
* forward, and the CLI must not imply that it does. V3 opens it at
|
|
21
|
+
* `min(expiresAt, closedAt) + escapeGraceSeconds`.
|
|
20
22
|
*/
|
|
21
23
|
export interface EscapeHatchWindow {
|
|
22
24
|
/** `escapeGraceSeconds` as read from the escrow. */
|
|
@@ -27,7 +29,7 @@ export interface EscapeHatchWindow {
|
|
|
27
29
|
/** Seconds left until `readyAt`; `0` once the window is open. */
|
|
28
30
|
readonly secondsRemaining: number;
|
|
29
31
|
}
|
|
30
|
-
export declare function escapeHatchWindow(stream: Pick<StreamV2, "expiresAt"
|
|
32
|
+
export declare function escapeHatchWindow(stream: Pick<StreamV2, "expiresAt"> & Partial<Pick<StreamV2, "closedAt">>, graceSeconds: number, nowSeconds: number, generation?: string): EscapeHatchWindow;
|
|
31
33
|
/** `2026-09-17T09:15:00.000Z (1789…)`, or `-` for an unset timestamp. */
|
|
32
34
|
export declare function formatTimestamp(seconds: number): string;
|
|
33
35
|
/** One line describing where the escape hatch stands, for humans. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape-hatch.d.ts","sourceRoot":"","sources":["../../src/cli/escape-hatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"escape-hatch.d.ts","sourceRoot":"","sources":["../../src/cli/escape-hatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,EACzE,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,SAAO,GAChB,iBAAiB,CAkBnB;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAMrE;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,sBAAsB,CAAC,EACjD,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,QAAQ,CAAC,CAUnB"}
|
package/dist/cli/escape-hatch.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { escapeHatchReadyAtFormula } from "../escrow-generation.js";
|
|
1
2
|
import { formatDuration } from "./amounts.js";
|
|
2
|
-
export function escapeHatchWindow(stream, graceSeconds, nowSeconds) {
|
|
3
|
-
const readyAt =
|
|
3
|
+
export function escapeHatchWindow(stream, graceSeconds, nowSeconds, generation = "v2") {
|
|
4
|
+
const readyAt = Number(escapeHatchReadyAtFormula(generation, {
|
|
5
|
+
expiresAt: BigInt(stream.expiresAt),
|
|
6
|
+
closedAt: BigInt(stream.closedAt ?? 0),
|
|
7
|
+
}, BigInt(graceSeconds)));
|
|
4
8
|
const secondsRemaining = readyAt - nowSeconds;
|
|
5
9
|
return {
|
|
6
10
|
graceSeconds,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape-hatch.js","sourceRoot":"","sources":["../../src/cli/escape-hatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"escape-hatch.js","sourceRoot":"","sources":["../../src/cli/escape-hatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAiC9C,MAAM,UAAU,iBAAiB,CAC/B,MAAyE,EACzE,YAAoB,EACpB,UAAkB,EAClB,UAAU,GAAG,IAAI;IAEjB,MAAM,OAAO,GAAG,MAAM,CACpB,yBAAyB,CACvB,UAAU,EACV;QACE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;KACvC,EACD,MAAM,CAAC,YAAY,CAAC,CACrB,CACF,CAAC;IACF,MAAM,gBAAgB,GAAG,OAAO,GAAG,UAAU,CAAC;IAC9C,OAAO;QACL,YAAY;QACZ,OAAO;QACP,KAAK,EAAE,gBAAgB,IAAI,CAAC;QAC5B,gBAAgB,EAAE,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC;IAC7B,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,GAAG,CAAC;AAClE,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,mBAAmB,CAAC,MAAyB;IAC3D,OAAO,MAAM,CAAC,KAAK;QACjB,CAAC,CAAC,cAAc,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QACjD,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,cAAc,CAC7D,MAAM,CAAC,gBAAgB,CACxB,EAAE,CAAC;AACV,CAAC;AAQD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAiD,EACjD,eAAuB;IAEvB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClD,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qCAAqC;IACvC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/cli/listings.d.ts
CHANGED
|
@@ -12,4 +12,22 @@ import type { ServiceListing } from "./deps.js";
|
|
|
12
12
|
export declare function resolveListing(context: CommandContext, serviceRef: `0x${string}`, options: {
|
|
13
13
|
readonly required: boolean;
|
|
14
14
|
}): Promise<ServiceListing | null>;
|
|
15
|
+
/**
|
|
16
|
+
* What {@link resolveListing} found, including the verified signed record of a
|
|
17
|
+
* matching row even when that row is not usable as a listing (no signed
|
|
18
|
+
* invocation URL) — `open` still has to read the operator-signed rate band off
|
|
19
|
+
* it — and whether the registry was unreachable (the only case in which a
|
|
20
|
+
* signed band may exist and be unknown).
|
|
21
|
+
*/
|
|
22
|
+
export interface ListingRecordResolution {
|
|
23
|
+
readonly listing: ServiceListing | null;
|
|
24
|
+
readonly record: {
|
|
25
|
+
readonly serviceRef: string;
|
|
26
|
+
readonly signed: ServiceListing["signed"];
|
|
27
|
+
} | null;
|
|
28
|
+
readonly registryUnreachable: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function resolveListingRecord(context: CommandContext, serviceRef: `0x${string}`, options: {
|
|
31
|
+
readonly required: boolean;
|
|
32
|
+
}): Promise<ListingRecordResolution>;
|
|
15
33
|
//# sourceMappingURL=listings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listings.d.ts","sourceRoot":"","sources":["../../src/cli/listings.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,KAAK,MAAM,EAAE,EACzB,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACtC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"listings.d.ts","sourceRoot":"","sources":["../../src/cli/listings.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,KAAK,MAAM,EAAE,EACzB,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACtC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAEhC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;KAC3C,GAAG,IAAI,CAAC;IACT,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;CACvC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,KAAK,MAAM,EAAE,EACzB,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACtC,OAAO,CAAC,uBAAuB,CAAC,CAkElC"}
|
package/dist/cli/listings.js
CHANGED
|
@@ -10,6 +10,9 @@ import { CliError } from "./errors.js";
|
|
|
10
10
|
* discovery instead of taking a `--url`.
|
|
11
11
|
*/
|
|
12
12
|
export async function resolveListing(context, serviceRef, options) {
|
|
13
|
+
return (await resolveListingRecord(context, serviceRef, options)).listing;
|
|
14
|
+
}
|
|
15
|
+
export async function resolveListingRecord(context, serviceRef, options) {
|
|
13
16
|
const { config, out, deps } = context;
|
|
14
17
|
let services;
|
|
15
18
|
try {
|
|
@@ -21,36 +24,43 @@ export async function resolveListing(context, serviceRef, options) {
|
|
|
21
24
|
catch (error) {
|
|
22
25
|
if (error instanceof RegistryUnavailableError && !options.required) {
|
|
23
26
|
out.note(`warning: the registry at ${config.registryUrl} is unreachable; continuing without a verified listing.`);
|
|
24
|
-
return null;
|
|
27
|
+
return { listing: null, record: null, registryUnreachable: true };
|
|
25
28
|
}
|
|
26
29
|
throw new CliError(`the service registry at ${config.registryUrl} could not be read`, { exitCode: 4, cause: error });
|
|
27
30
|
}
|
|
28
31
|
const wanted = serviceRef.toLowerCase();
|
|
29
32
|
const match = services.find((service) => service.serviceRef.toLowerCase() === wanted);
|
|
30
33
|
if (match === undefined) {
|
|
31
|
-
if (!options.required)
|
|
32
|
-
return null;
|
|
34
|
+
if (!options.required) {
|
|
35
|
+
return { listing: null, record: null, registryUnreachable: false };
|
|
36
|
+
}
|
|
33
37
|
throw new CliError(`no verified listing in the registry matches serviceRef ${serviceRef}`, {
|
|
34
38
|
exitCode: 4,
|
|
35
39
|
hint: "run `metrik discover` to see what is listed. A listing that fails signature verification is dropped, so it will not appear here.",
|
|
36
40
|
});
|
|
37
41
|
}
|
|
42
|
+
const record = { serviceRef: match.serviceRef, signed: match.signed };
|
|
38
43
|
if (match.accessUrl === null) {
|
|
39
|
-
if (!options.required)
|
|
40
|
-
return null;
|
|
44
|
+
if (!options.required) {
|
|
45
|
+
return { listing: null, record, registryUnreachable: false };
|
|
46
|
+
}
|
|
41
47
|
throw new CliError(`listing ${serviceRef} carries no signed invocation URL`, {
|
|
42
48
|
exitCode: 4,
|
|
43
49
|
hint: "the CLI refuses to call an origin that the operator did not sign.",
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
listing: {
|
|
54
|
+
serviceRef: match.serviceRef,
|
|
55
|
+
operator: match.operator,
|
|
56
|
+
publicUrl: match.publicUrl,
|
|
57
|
+
access: match.access,
|
|
58
|
+
accessUrl: match.accessUrl,
|
|
59
|
+
signed: match.signed,
|
|
60
|
+
category: match.category,
|
|
61
|
+
},
|
|
62
|
+
record,
|
|
63
|
+
registryUnreachable: false,
|
|
54
64
|
};
|
|
55
65
|
}
|
|
56
66
|
//# sourceMappingURL=listings.js.map
|
package/dist/cli/listings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listings.js","sourceRoot":"","sources":["../../src/cli/listings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,E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E,KAAK,EAAE,CAAC;QACrE,CAAC;QACD,MAAM,IAAI,QAAQ,CAChB,0DAA0D,UAAU,EAAE,EACtE;YACE,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,kIAAkI;SACzI,CACF,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IACtE,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACtB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;QAC/D,CAAC;QACD,MAAM,IAAI,QAAQ,CAChB,WAAW,UAAU,mCAAmC,EACxD;YACE,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,mEAAmE;SAC1E,CACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB;QACD,MAAM;QACN,mBAAmB,EAAE,KAAK;KAC3B,CAAC;AACJ,CAAC"}
|
package/dist/cli/preflight.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import type { MetrikNetwork } from "@absol-labs/sdk";
|
|
1
2
|
import type { CliReadClient } from "./deps.js";
|
|
2
|
-
/** Where a Base Sepolia test wallet gets its gas. */
|
|
3
|
-
export declare const BASE_SEPOLIA_FAUCET_URL = "https://www.alchemy.com/faucets/base-sepolia";
|
|
4
|
-
/** Where a Base Sepolia test wallet gets the USDC it escrows. */
|
|
5
|
-
export declare const CIRCLE_USDC_FAUCET_URL = "https://faucet.circle.com";
|
|
6
3
|
/**
|
|
7
4
|
* Refuse to broadcast from a wallet that cannot pay for gas.
|
|
8
5
|
*
|
|
@@ -10,23 +7,32 @@ export declare const CIRCLE_USDC_FAUCET_URL = "https://faucet.circle.com";
|
|
|
10
7
|
* phrasing — `USDC approve transaction failed: Execution reverted with reason:
|
|
11
8
|
* gas required exceeds allowance (0)` — which reads like a USDC allowance
|
|
12
9
|
* problem and sends the reader looking at approvals. The actual fact is "this
|
|
13
|
-
* address holds no
|
|
10
|
+
* address holds no gas", and it is knowable with one read before anything is
|
|
14
11
|
* signed.
|
|
15
12
|
*
|
|
13
|
+
* The gas token is read from the network's registry metadata, never assumed to
|
|
14
|
+
* be ETH. Where gas IS the settlement token (`gasToken.isSettlementToken`),
|
|
15
|
+
* there is only one balance: the USDC balance is the gas balance, so that is
|
|
16
|
+
* the one read.
|
|
17
|
+
*
|
|
16
18
|
* Deliberately only a ZERO check, not an estimate: predicting the gas a hire
|
|
17
|
-
* will cost means simulating it, and a wallet with a little
|
|
19
|
+
* will cost means simulating it, and a wallet with a little gas that still runs
|
|
18
20
|
* short should get the real revert rather than a guess from this CLI.
|
|
19
21
|
*/
|
|
20
|
-
export declare function assertCanPayGas(read: CliReadClient, address: `0x${string}
|
|
22
|
+
export declare function assertCanPayGas(read: CliReadClient, address: `0x${string}`, network: MetrikNetwork): Promise<void>;
|
|
21
23
|
/**
|
|
22
24
|
* Refuse to broadcast a hire the wallet cannot fund.
|
|
23
25
|
*
|
|
24
|
-
* The sibling of `assertCanPayGas`, for the OTHER balance.
|
|
25
|
-
*
|
|
26
|
-
* that passes the gas check can still hold no USDC at all.
|
|
27
|
-
* `open` path sends the USDC approval FIRST — which succeeds,
|
|
28
|
-
* an amount you do not hold is legal — and then reverts
|
|
29
|
-
* having already spent gas to learn something that was
|
|
26
|
+
* The sibling of `assertCanPayGas`, for the OTHER balance. On a network whose
|
|
27
|
+
* gas token is not USDC, gas and deposit are separate balances on separate
|
|
28
|
+
* tokens, so a wallet that passes the gas check can still hold no USDC at all.
|
|
29
|
+
* Without this the `open` path sends the USDC approval FIRST — which succeeds,
|
|
30
|
+
* because approving an amount you do not hold is legal — and then reverts
|
|
31
|
+
* inside `transferFrom`, having already spent gas to learn something that was
|
|
32
|
+
* one `balanceOf` away.
|
|
33
|
+
*
|
|
34
|
+
* Where gas IS USDC there is one balance, and it must cover the deposit AND
|
|
35
|
+
* leave something for gas, so the check is strict (`balance > budget`).
|
|
30
36
|
*
|
|
31
37
|
* Deliberately NOT an allowance check. The CLI's own open path grants the
|
|
32
38
|
* bounded approval it needs (`approveTxHash` in the result), so a missing
|
|
@@ -34,5 +40,5 @@ export declare function assertCanPayGas(read: CliReadClient, address: `0x${strin
|
|
|
34
40
|
* would refuse a hire that was about to work. Balance is the fact the CLI
|
|
35
41
|
* cannot fix for you.
|
|
36
42
|
*/
|
|
37
|
-
export declare function assertCanFundStream(read: CliReadClient, address: `0x${string}`, budgetUsdc: bigint): Promise<void>;
|
|
43
|
+
export declare function assertCanFundStream(read: CliReadClient, address: `0x${string}`, budgetUsdc: bigint, network: MetrikNetwork): Promise<void>;
|
|
38
44
|
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/cli/preflight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/cli/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,KAAK,MAAM,EAAE,EACtB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,KAAK,MAAM,EAAE,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
package/dist/cli/preflight.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { gasFundingHint, usdcFundingHint } from "../network.js";
|
|
1
2
|
import { formatUsdc } from "./amounts.js";
|
|
2
3
|
import { CliError } from "./errors.js";
|
|
3
|
-
/** Where a Base Sepolia test wallet gets its gas. */
|
|
4
|
-
export const BASE_SEPOLIA_FAUCET_URL = "https://www.alchemy.com/faucets/base-sepolia";
|
|
5
|
-
/** Where a Base Sepolia test wallet gets the USDC it escrows. */
|
|
6
|
-
export const CIRCLE_USDC_FAUCET_URL = "https://faucet.circle.com";
|
|
7
4
|
/**
|
|
8
5
|
* Refuse to broadcast from a wallet that cannot pay for gas.
|
|
9
6
|
*
|
|
@@ -11,17 +8,25 @@ export const CIRCLE_USDC_FAUCET_URL = "https://faucet.circle.com";
|
|
|
11
8
|
* phrasing — `USDC approve transaction failed: Execution reverted with reason:
|
|
12
9
|
* gas required exceeds allowance (0)` — which reads like a USDC allowance
|
|
13
10
|
* problem and sends the reader looking at approvals. The actual fact is "this
|
|
14
|
-
* address holds no
|
|
11
|
+
* address holds no gas", and it is knowable with one read before anything is
|
|
15
12
|
* signed.
|
|
16
13
|
*
|
|
14
|
+
* The gas token is read from the network's registry metadata, never assumed to
|
|
15
|
+
* be ETH. Where gas IS the settlement token (`gasToken.isSettlementToken`),
|
|
16
|
+
* there is only one balance: the USDC balance is the gas balance, so that is
|
|
17
|
+
* the one read.
|
|
18
|
+
*
|
|
17
19
|
* Deliberately only a ZERO check, not an estimate: predicting the gas a hire
|
|
18
|
-
* will cost means simulating it, and a wallet with a little
|
|
20
|
+
* will cost means simulating it, and a wallet with a little gas that still runs
|
|
19
21
|
* short should get the real revert rather than a guess from this CLI.
|
|
20
22
|
*/
|
|
21
|
-
export async function assertCanPayGas(read, address) {
|
|
23
|
+
export async function assertCanPayGas(read, address, network) {
|
|
24
|
+
const gasIsUsdc = network.gasToken.isSettlementToken;
|
|
22
25
|
let balance;
|
|
23
26
|
try {
|
|
24
|
-
balance =
|
|
27
|
+
balance = gasIsUsdc
|
|
28
|
+
? await read.usdcBalance(address)
|
|
29
|
+
: await read.nativeBalance(address);
|
|
25
30
|
}
|
|
26
31
|
catch {
|
|
27
32
|
// A balance read is a courtesy, not a gate. If the RPC will not answer it,
|
|
@@ -30,20 +35,26 @@ export async function assertCanPayGas(read, address) {
|
|
|
30
35
|
}
|
|
31
36
|
if (balance > 0n)
|
|
32
37
|
return;
|
|
33
|
-
throw new CliError(`wallet ${address} has 0
|
|
38
|
+
throw new CliError(`wallet ${address} has 0 ${network.gasToken.symbol} on ${network.name}, so it cannot pay for gas`, {
|
|
34
39
|
exitCode: 3,
|
|
35
|
-
hint:
|
|
40
|
+
hint: gasIsUsdc
|
|
41
|
+
? `${gasFundingHint(network)}, then re-run. (On ${network.name} gas is paid in USDC, the same balance a stream is escrowed from.)`
|
|
42
|
+
: `${gasFundingHint(network)}, then re-run. (Gas is ${network.gasToken.symbol}; the stream itself is escrowed in USDC, which is a separate balance.)`,
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Refuse to broadcast a hire the wallet cannot fund.
|
|
40
47
|
*
|
|
41
|
-
* The sibling of `assertCanPayGas`, for the OTHER balance.
|
|
42
|
-
*
|
|
43
|
-
* that passes the gas check can still hold no USDC at all.
|
|
44
|
-
* `open` path sends the USDC approval FIRST — which succeeds,
|
|
45
|
-
* an amount you do not hold is legal — and then reverts
|
|
46
|
-
* having already spent gas to learn something that was
|
|
48
|
+
* The sibling of `assertCanPayGas`, for the OTHER balance. On a network whose
|
|
49
|
+
* gas token is not USDC, gas and deposit are separate balances on separate
|
|
50
|
+
* tokens, so a wallet that passes the gas check can still hold no USDC at all.
|
|
51
|
+
* Without this the `open` path sends the USDC approval FIRST — which succeeds,
|
|
52
|
+
* because approving an amount you do not hold is legal — and then reverts
|
|
53
|
+
* inside `transferFrom`, having already spent gas to learn something that was
|
|
54
|
+
* one `balanceOf` away.
|
|
55
|
+
*
|
|
56
|
+
* Where gas IS USDC there is one balance, and it must cover the deposit AND
|
|
57
|
+
* leave something for gas, so the check is strict (`balance > budget`).
|
|
47
58
|
*
|
|
48
59
|
* Deliberately NOT an allowance check. The CLI's own open path grants the
|
|
49
60
|
* bounded approval it needs (`approveTxHash` in the result), so a missing
|
|
@@ -51,7 +62,8 @@ export async function assertCanPayGas(read, address) {
|
|
|
51
62
|
* would refuse a hire that was about to work. Balance is the fact the CLI
|
|
52
63
|
* cannot fix for you.
|
|
53
64
|
*/
|
|
54
|
-
export async function assertCanFundStream(read, address, budgetUsdc) {
|
|
65
|
+
export async function assertCanFundStream(read, address, budgetUsdc, network) {
|
|
66
|
+
const gasIsUsdc = network.gasToken.isSettlementToken;
|
|
55
67
|
let balance;
|
|
56
68
|
try {
|
|
57
69
|
balance = await read.usdcBalance(address);
|
|
@@ -62,11 +74,13 @@ export async function assertCanFundStream(read, address, budgetUsdc) {
|
|
|
62
74
|
// the real error surface.
|
|
63
75
|
return;
|
|
64
76
|
}
|
|
65
|
-
if (balance >= budgetUsdc)
|
|
77
|
+
if (gasIsUsdc ? balance > budgetUsdc : balance >= budgetUsdc)
|
|
66
78
|
return;
|
|
67
|
-
throw new CliError(`wallet ${address} holds ${formatUsdc(balance)} but --budget is ${formatUsdc(budgetUsdc)}`, {
|
|
79
|
+
throw new CliError(`wallet ${address} holds ${formatUsdc(balance)} but --budget is ${formatUsdc(budgetUsdc)}${gasIsUsdc ? " (plus gas, which is also USDC here)" : ""}`, {
|
|
68
80
|
exitCode: 3,
|
|
69
|
-
hint:
|
|
81
|
+
hint: gasIsUsdc
|
|
82
|
+
? `the deposit and the gas are both USDC on ${network.name} — ${usdcFundingHint(network)}, then re-run.`
|
|
83
|
+
: `the deposit is escrowed in USDC — ${usdcFundingHint(network)}, then re-run. (Gas is a separate ${network.gasToken.symbol} balance.)`,
|
|
70
84
|
});
|
|
71
85
|
}
|
|
72
86
|
//# sourceMappingURL=preflight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/cli/preflight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/cli/preflight.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAmB,EACnB,OAAsB,EACtB,OAAsB;IAEtB,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACrD,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,SAAS;YACjB,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YACjC,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,wDAAwD;QACxD,OAAO;IACT,CAAC;IACD,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO;IAEzB,MAAM,IAAI,QAAQ,CAChB,UAAU,OAAO,UAAU,OAAO,CAAC,QAAQ,CAAC,MAAM,OAAO,OAAO,CAAC,IAAI,4BAA4B,EACjG;QACE,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,SAA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entialStore } from "../wallet/autonomous-wallet.js";
|
|
3
|
+
/**
|
|
4
|
+
* The CLI's two Privy wallet shapes.
|
|
5
|
+
*
|
|
6
|
+
* Privy differs from the private-key and CDP paths in ONE structural way: the
|
|
7
|
+
* account it yields has no local `signTransaction`. It signs and broadcasts by
|
|
8
|
+
* sending `eth_sendTransaction` / `eth_signTypedData_v4` to a provider, so the
|
|
9
|
+
* viem wallet client's TRANSPORT must be that provider rather than a plain HTTP
|
|
10
|
+
* RPC. That is the whole difference, and it is what `transport` below carries.
|
|
11
|
+
*
|
|
12
|
+
* Neither shape puts a wallet key on this machine. The signing key lives at
|
|
13
|
+
* Privy; the broker holds the Privy authorization key. What the CLI holds is
|
|
14
|
+
* either a short-lived session token (`session`) or a P-256 authorization key
|
|
15
|
+
* in the host credential store (`autonomous`) — a key that authorizes a
|
|
16
|
+
* policy-bounded request, not a key that can move funds by itself.
|
|
17
|
+
*/
|
|
18
|
+
export type PrivyCliWalletSource = "privy-autonomous" | "privy-session";
|
|
19
|
+
/** The store key naming the agent-owned wallet in the host credential store. */
|
|
20
|
+
export declare const PRIVY_WALLET_KEY_ENV = "METRIK_AGENT_PRIVY_WALLET_KEY";
|
|
21
|
+
/** Broker base URL. Optional for `autonomous`, REQUIRED for `session`. */
|
|
22
|
+
export declare const PRIVY_BROKER_URL_ENV = "METRIK_AGENT_PRIVY_BROKER_URL";
|
|
23
|
+
/** A scoped session token minted by the broker's `POST /v1/sessions`. */
|
|
24
|
+
export declare const PRIVY_SESSION_TOKEN_ENV = "METRIK_AGENT_PRIVY_SESSION_TOKEN";
|
|
25
|
+
/** The embedded wallet address the session is bound to. */
|
|
26
|
+
export declare const PRIVY_ADDRESS_ENV = "METRIK_AGENT_PRIVY_ADDRESS";
|
|
27
|
+
/** The PUBLIC Privy app id. Not a secret — the broker serves it at `/v1/config`. */
|
|
28
|
+
export declare const PRIVY_APP_ID_ENV = "METRIK_AGENT_PRIVY_APP_ID";
|
|
29
|
+
/** Every variable either Privy shape reads. Named in errors, never printed. */
|
|
30
|
+
export declare const PRIVY_ENV_VARS: readonly ["METRIK_AGENT_PRIVY_WALLET_KEY", "METRIK_AGENT_PRIVY_BROKER_URL", "METRIK_AGENT_PRIVY_SESSION_TOKEN", "METRIK_AGENT_PRIVY_ADDRESS", "METRIK_AGENT_PRIVY_APP_ID"];
|
|
31
|
+
/** The variables the user-owned session shape needs, all of them. */
|
|
32
|
+
export declare const PRIVY_SESSION_ENV_VARS: readonly ["METRIK_AGENT_PRIVY_BROKER_URL", "METRIK_AGENT_PRIVY_SESSION_TOKEN", "METRIK_AGENT_PRIVY_ADDRESS", "METRIK_AGENT_PRIVY_APP_ID"];
|
|
33
|
+
/**
|
|
34
|
+
* The spend ceiling a broker enforces server-side, read from `GET /v1/config`.
|
|
35
|
+
*
|
|
36
|
+
* These are the SAME numbers the broker checks `openStream` against
|
|
37
|
+
* (`deposit <= maxTotalUsdc`, `ratePerSecond <= maxRatePerSecondUsdc`,
|
|
38
|
+
* `duration <= maxDurationSeconds`), which is why the CLI can use them to
|
|
39
|
+
* refuse an over-ceiling hire locally instead of paying gas to learn a knowable
|
|
40
|
+
* fact. It reads them rather than hardcoding them: the ceiling belongs to the
|
|
41
|
+
* broker, and a copy in this file would be a second source of truth that goes
|
|
42
|
+
* stale silently.
|
|
43
|
+
*/
|
|
44
|
+
export interface PrivySpendPolicy {
|
|
45
|
+
readonly brokerUrl: string;
|
|
46
|
+
readonly chainId: number;
|
|
47
|
+
readonly maxTotalUsdc: bigint;
|
|
48
|
+
readonly maxRatePerSecondUsdc: bigint;
|
|
49
|
+
readonly maxDurationSeconds: number;
|
|
50
|
+
}
|
|
51
|
+
/** Reads a broker's public policy. No credential is sent; nothing secret is served. */
|
|
52
|
+
export declare function fetchPrivySpendPolicy(brokerUrl: string, fetchImpl?: typeof fetch): Promise<PrivySpendPolicy>;
|
|
53
|
+
export interface ResolvedPrivyCliWallet {
|
|
54
|
+
readonly source: PrivyCliWalletSource;
|
|
55
|
+
/** A JSON-RPC account: `signTypedData` works, `signTransaction` does not exist. */
|
|
56
|
+
readonly account: Account;
|
|
57
|
+
/** The provider-as-transport. Without this every write goes to a plain RPC and fails. */
|
|
58
|
+
readonly transport: Transport;
|
|
59
|
+
/** One line naming the wallet's origin. Safe to print: no credential in it. */
|
|
60
|
+
readonly description: string;
|
|
61
|
+
/** Reads the broker ceiling this wallet is capped at. Bound to its broker URL. */
|
|
62
|
+
readonly readSpendPolicy: () => Promise<PrivySpendPolicy>;
|
|
63
|
+
}
|
|
64
|
+
export interface ResolvePrivyCliWalletOptions {
|
|
65
|
+
/** `--rpc-url`, so a Privy wallet's READS use the same endpoint as everything else. */
|
|
66
|
+
readonly rpcUrl?: string;
|
|
67
|
+
readonly note?: (line: string) => void;
|
|
68
|
+
/** Test seam. Defaults to the real credential store selected from `env`. */
|
|
69
|
+
readonly store?: AutonomousWalletCredentialStore;
|
|
70
|
+
/** Test seam for the broker HTTP contract. */
|
|
71
|
+
readonly fetchImpl?: typeof fetch;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Resolves a Privy wallet from the environment, or `null` when no Privy
|
|
75
|
+
* variable is set at all.
|
|
76
|
+
*
|
|
77
|
+
* A PARTIALLY configured Privy setup is an error, not a `null` — "you set the
|
|
78
|
+
* session token but not the address" and "you configured no Privy wallet" are
|
|
79
|
+
* different facts, and rendering the first as the second sends the reader
|
|
80
|
+
* looking in the wrong place. This mirrors the CDP path exactly.
|
|
81
|
+
*/
|
|
82
|
+
export declare function resolvePrivyCliWallet(env: NodeJS.ProcessEnv, options?: ResolvePrivyCliWalletOptions): Promise<ResolvedPrivyCliWallet | null>;
|
|
83
|
+
//# sourceMappingURL=privy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privy.d.ts","sourceRoot":"","sources":["../../src/cli/privy.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,SAAS,EACf,MAAM,MAAM,CAAC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