@absol-labs/agent 0.11.0 → 0.12.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -51
- package/dist/capability/invocation-capability.d.ts +2 -2
- package/dist/capability/probe-capability.d.ts +225 -0
- package/dist/capability/probe-capability.d.ts.map +1 -0
- package/dist/capability/probe-capability.js +248 -0
- package/dist/capability/probe-capability.js.map +1 -0
- package/dist/cli/args.d.ts +11 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +23 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/claim.d.ts +32 -0
- package/dist/cli/commands/claim.d.ts.map +1 -1
- package/dist/cli/commands/claim.js +116 -28
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.d.ts.map +1 -1
- package/dist/cli/commands/close.js +35 -3
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/invoke.d.ts +2 -0
- package/dist/cli/commands/invoke.d.ts.map +1 -1
- package/dist/cli/commands/invoke.js +2 -2
- package/dist/cli/commands/invoke.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +15 -2
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/open.d.ts.map +1 -1
- package/dist/cli/commands/open.js +58 -4
- package/dist/cli/commands/open.js.map +1 -1
- package/dist/cli/commands/pay.d.ts +34 -0
- package/dist/cli/commands/pay.d.ts.map +1 -0
- package/dist/cli/commands/pay.js +479 -0
- package/dist/cli/commands/pay.js.map +1 -0
- package/dist/cli/commands/reclaim-unverified.d.ts.map +1 -1
- package/dist/cli/commands/reclaim-unverified.js +3 -2
- package/dist/cli/commands/reclaim-unverified.js.map +1 -1
- package/dist/cli/commands/reclaim.d.ts +23 -2
- package/dist/cli/commands/reclaim.d.ts.map +1 -1
- package/dist/cli/commands/reclaim.js +204 -20
- package/dist/cli/commands/reclaim.js.map +1 -1
- package/dist/cli/commands/refund.d.ts +31 -0
- package/dist/cli/commands/refund.d.ts.map +1 -0
- package/dist/cli/commands/refund.js +397 -0
- package/dist/cli/commands/refund.js.map +1 -0
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +21 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/streams.js +8 -12
- package/dist/cli/commands/streams.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +4 -1
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/config.d.ts +44 -26
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +88 -38
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/context.d.ts +19 -0
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/deps.d.ts +53 -0
- package/dist/cli/deps.d.ts.map +1 -1
- package/dist/cli/deps.js +51 -1
- package/dist/cli/deps.js.map +1 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +21 -1
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/escape-hatch.d.ts +6 -4
- package/dist/cli/escape-hatch.d.ts.map +1 -1
- package/dist/cli/escape-hatch.js +6 -2
- package/dist/cli/escape-hatch.js.map +1 -1
- package/dist/cli/listings.d.ts +18 -0
- package/dist/cli/listings.d.ts.map +1 -1
- package/dist/cli/listings.js +22 -12
- package/dist/cli/listings.js.map +1 -1
- package/dist/cli/preflight.d.ts +20 -14
- package/dist/cli/preflight.d.ts.map +1 -1
- package/dist/cli/preflight.js +34 -20
- package/dist/cli/preflight.js.map +1 -1
- package/dist/cli/privy.d.ts.map +1 -1
- package/dist/cli/privy.js +4 -2
- package/dist/cli/privy.js.map +1 -1
- package/dist/cli/progress.d.ts +13 -1
- package/dist/cli/progress.d.ts.map +1 -1
- package/dist/cli/progress.js +7 -1
- package/dist/cli/progress.js.map +1 -1
- package/dist/cli/reclaimability.d.ts +82 -0
- package/dist/cli/reclaimability.d.ts.map +1 -0
- package/dist/cli/reclaimability.js +80 -0
- package/dist/cli/reclaimability.js.map +1 -0
- package/dist/cli/run.d.ts +2 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +62 -21
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/scan-range.d.ts +2 -2
- package/dist/cli/scan-range.js +2 -2
- package/dist/cli/status.d.ts +106 -1
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +325 -44
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/wallet.d.ts +2 -2
- package/dist/cli/wallet.d.ts.map +1 -1
- package/dist/cli/wallet.js +29 -5
- package/dist/cli/wallet.js.map +1 -1
- package/dist/discovery/rate-band.d.ts +74 -0
- package/dist/discovery/rate-band.d.ts.map +1 -0
- package/dist/discovery/rate-band.js +114 -0
- package/dist/discovery/rate-band.js.map +1 -0
- package/dist/escrow-generation.d.ts +81 -0
- package/dist/escrow-generation.d.ts.map +1 -0
- package/dist/escrow-generation.js +76 -0
- package/dist/escrow-generation.js.map +1 -0
- package/dist/frameworks/agentkit.d.ts +8 -4
- package/dist/frameworks/agentkit.d.ts.map +1 -1
- package/dist/frameworks/agentkit.js +27 -10
- package/dist/frameworks/agentkit.js.map +1 -1
- package/dist/frameworks/eliza.d.ts +3 -3
- package/dist/frameworks/eliza.d.ts.map +1 -1
- package/dist/frameworks/eliza.js +15 -6
- package/dist/frameworks/eliza.js.map +1 -1
- package/dist/frameworks/langchain.d.ts.map +1 -1
- package/dist/frameworks/langchain.js +8 -0
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/gateway/caller-auth-gateway.d.ts +83 -31
- package/dist/gateway/caller-auth-gateway.d.ts.map +1 -1
- package/dist/gateway/caller-auth-gateway.js +180 -27
- package/dist/gateway/caller-auth-gateway.js.map +1 -1
- package/dist/gateway/http-server.d.ts +128 -44
- package/dist/gateway/http-server.d.ts.map +1 -1
- package/dist/gateway/http-server.js +506 -155
- package/dist/gateway/http-server.js.map +1 -1
- package/dist/gateway/probe-auth.d.ts +112 -0
- package/dist/gateway/probe-auth.d.ts.map +1 -0
- package/dist/gateway/probe-auth.js +127 -0
- package/dist/gateway/probe-auth.js.map +1 -0
- package/dist/gateway/signed-rate-bounds.d.ts +51 -0
- package/dist/gateway/signed-rate-bounds.d.ts.map +1 -0
- package/dist/gateway/signed-rate-bounds.js +94 -0
- package/dist/gateway/signed-rate-bounds.js.map +1 -0
- package/dist/gateway/x402-opener-mode.d.ts +252 -0
- package/dist/gateway/x402-opener-mode.d.ts.map +1 -0
- package/dist/gateway/x402-opener-mode.js +772 -0
- package/dist/gateway/x402-opener-mode.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +64 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +247 -37
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/x402-tools.d.ts +109 -0
- package/dist/mcp/x402-tools.d.ts.map +1 -0
- package/dist/mcp/x402-tools.js +554 -0
- package/dist/mcp/x402-tools.js.map +1 -0
- package/dist/network.d.ts +119 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +199 -0
- package/dist/network.js.map +1 -0
- package/dist/sdk/client.d.ts +13 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/client.js +15 -0
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/invoke.d.ts +4 -0
- package/dist/sdk/invoke.d.ts.map +1 -1
- package/dist/sdk/invoke.js +2 -5
- package/dist/sdk/invoke.js.map +1 -1
- package/dist/wallet/autonomous-wallet-broker.d.ts +3 -0
- package/dist/wallet/autonomous-wallet-broker.d.ts.map +1 -1
- package/dist/wallet/autonomous-wallet-broker.js +27 -23
- package/dist/wallet/autonomous-wallet-broker.js.map +1 -1
- package/dist/wallet/autonomous-wallet-protocol.d.ts +8 -2
- package/dist/wallet/autonomous-wallet-protocol.d.ts.map +1 -1
- package/dist/wallet/autonomous-wallet-protocol.js +9 -2
- package/dist/wallet/autonomous-wallet-protocol.js.map +1 -1
- package/dist/wallet/autonomous-wallet.d.ts.map +1 -1
- package/dist/wallet/autonomous-wallet.js +3 -2
- package/dist/wallet/autonomous-wallet.js.map +1 -1
- package/dist/wallet/broker-escrows.d.ts +222 -0
- package/dist/wallet/broker-escrows.d.ts.map +1 -0
- package/dist/wallet/broker-escrows.js +36 -0
- package/dist/wallet/broker-escrows.js.map +1 -0
- package/dist/wallet/lifecycle.d.ts +21 -5
- package/dist/wallet/lifecycle.d.ts.map +1 -1
- package/dist/wallet/lifecycle.js +32 -12
- package/dist/wallet/lifecycle.js.map +1 -1
- package/dist/wallet/privy-broker-server.d.ts.map +1 -1
- package/dist/wallet/privy-broker-server.js +31 -26
- package/dist/wallet/privy-broker-server.js.map +1 -1
- package/dist/wallet/privy-session-broker.d.ts +14 -5
- package/dist/wallet/privy-session-broker.d.ts.map +1 -1
- package/dist/wallet/privy-session-broker.js +29 -17
- package/dist/wallet/privy-session-broker.js.map +1 -1
- package/dist/wallet/privy-session-provider.d.ts +3 -1
- package/dist/wallet/privy-session-provider.d.ts.map +1 -1
- package/dist/wallet/privy-session-provider.js +5 -3
- package/dist/wallet/privy-session-provider.js.map +1 -1
- package/dist/wallet/provider.d.ts.map +1 -1
- package/dist/wallet/provider.js +15 -8
- package/dist/wallet/provider.js.map +1 -1
- package/dist/x402/facilitator.d.ts +3 -30
- package/dist/x402/facilitator.d.ts.map +1 -1
- package/dist/x402/facilitator.js +0 -27
- package/dist/x402/facilitator.js.map +1 -1
- package/dist/x402-buyer/guarded-fetch.d.ts +51 -0
- package/dist/x402-buyer/guarded-fetch.d.ts.map +1 -0
- package/dist/x402-buyer/guarded-fetch.js +147 -0
- package/dist/x402-buyer/guarded-fetch.js.map +1 -0
- package/dist/x402-buyer/index.d.ts +10 -0
- package/dist/x402-buyer/index.d.ts.map +1 -0
- package/dist/x402-buyer/index.js +10 -0
- package/dist/x402-buyer/index.js.map +1 -0
- package/dist/x402-buyer/pay.d.ts +157 -0
- package/dist/x402-buyer/pay.d.ts.map +1 -0
- package/dist/x402-buyer/pay.js +366 -0
- package/dist/x402-buyer/pay.js.map +1 -0
- package/dist/x402-opener/abi.d.ts +684 -0
- package/dist/x402-opener/abi.d.ts.map +1 -0
- package/dist/x402-opener/abi.js +880 -0
- package/dist/x402-opener/abi.js.map +1 -0
- package/dist/x402-opener/facilitator-entry.d.ts +3 -0
- package/dist/x402-opener/facilitator-entry.d.ts.map +1 -0
- package/dist/x402-opener/facilitator-entry.js +40 -0
- package/dist/x402-opener/facilitator-entry.js.map +1 -0
- package/dist/x402-opener/facilitator-server.d.ts +209 -0
- package/dist/x402-opener/facilitator-server.d.ts.map +1 -0
- package/dist/x402-opener/facilitator-server.js +762 -0
- package/dist/x402-opener/facilitator-server.js.map +1 -0
- package/dist/x402-opener/index.d.ts +14 -0
- package/dist/x402-opener/index.d.ts.map +1 -0
- package/dist/x402-opener/index.js +14 -0
- package/dist/x402-opener/index.js.map +1 -0
- package/dist/x402-opener/listing-resolver.d.ts +55 -0
- package/dist/x402-opener/listing-resolver.d.ts.map +1 -0
- package/dist/x402-opener/listing-resolver.js +125 -0
- package/dist/x402-opener/listing-resolver.js.map +1 -0
- package/dist/x402-opener/refund-relay.d.ts +266 -0
- package/dist/x402-opener/refund-relay.d.ts.map +1 -0
- package/dist/x402-opener/refund-relay.js +1341 -0
- package/dist/x402-opener/refund-relay.js.map +1 -0
- package/dist/x402-opener/relayer-queue.d.ts +14 -0
- package/dist/x402-opener/relayer-queue.d.ts.map +1 -0
- package/dist/x402-opener/relayer-queue.js +18 -0
- package/dist/x402-opener/relayer-queue.js.map +1 -0
- package/dist/x402-opener/scheme.d.ts +296 -0
- package/dist/x402-opener/scheme.d.ts.map +1 -0
- package/dist/x402-opener/scheme.js +1035 -0
- package/dist/x402-opener/scheme.js.map +1 -0
- package/dist/x402-opener/terms.d.ts +165 -0
- package/dist/x402-opener/terms.d.ts.map +1 -0
- package/dist/x402-opener/terms.js +304 -0
- package/dist/x402-opener/terms.js.map +1 -0
- package/dist/zktls/reclaim.d.ts +2 -2
- package/dist/zktls/t2-delivery-proof.d.ts +6 -6
- package/docs/agent-layer.md +3 -2
- package/docs/autonomous-privy-wallet.md +188 -0
- package/docs/cli.md +265 -34
- package/docs/langchain.md +5 -0
- package/docs/mcp-reference.md +91 -5
- package/docs/probe-capability.md +191 -0
- package/docs/quickstart.md +39 -4
- package/docs/threat-model.md +20 -0
- package/docs/x402.md +766 -593
- package/package.json +19 -17
- package/src/capability/probe-capability.ts +355 -0
- package/src/cli/args.ts +29 -0
- package/src/cli/commands/claim.ts +168 -33
- package/src/cli/commands/close.ts +36 -3
- package/src/cli/commands/invoke.ts +5 -2
- package/src/cli/commands/mcp.ts +18 -2
- package/src/cli/commands/open.ts +75 -4
- package/src/cli/commands/pay.ts +584 -0
- package/src/cli/commands/reclaim-unverified.ts +8 -2
- package/src/cli/commands/reclaim.ts +277 -19
- package/src/cli/commands/refund.ts +475 -0
- package/src/cli/commands/status.ts +28 -2
- package/src/cli/commands/streams.ts +10 -14
- package/src/cli/commands/watch.ts +11 -1
- package/src/cli/config.ts +139 -52
- package/src/cli/context.ts +16 -0
- package/src/cli/deps.ts +111 -1
- package/src/cli/errors.ts +24 -1
- package/src/cli/escape-hatch.ts +19 -5
- package/src/cli/listings.ts +43 -10
- package/src/cli/preflight.ts +36 -21
- package/src/cli/privy.ts +4 -2
- package/src/cli/progress.ts +21 -2
- package/src/cli/reclaimability.ts +154 -0
- package/src/cli/run.ts +77 -21
- package/src/cli/scan-range.ts +2 -2
- package/src/cli/status.ts +454 -44
- package/src/cli/wallet.ts +45 -8
- package/src/discovery/rate-band.ts +172 -0
- package/src/escrow-generation.ts +135 -0
- package/src/frameworks/agentkit.ts +45 -11
- package/src/frameworks/eliza.ts +27 -5
- package/src/frameworks/langchain.ts +14 -0
- package/src/gateway/caller-auth-gateway.ts +320 -68
- package/src/gateway/http-server.ts +717 -220
- package/src/gateway/probe-auth.ts +191 -0
- package/src/gateway/signed-rate-bounds.ts +164 -0
- package/src/gateway/x402-opener-mode.ts +1171 -0
- package/src/index.ts +82 -19
- package/src/mcp/server.ts +351 -42
- package/src/mcp/x402-tools.ts +785 -0
- package/src/network.ts +302 -0
- package/src/sdk/client.ts +25 -0
- package/src/sdk/invoke.ts +6 -5
- package/src/wallet/autonomous-wallet-broker.ts +46 -20
- package/src/wallet/autonomous-wallet-protocol.ts +11 -2
- package/src/wallet/autonomous-wallet.ts +4 -2
- package/src/wallet/broker-escrows.ts +66 -0
- package/src/wallet/lifecycle.ts +53 -18
- package/src/wallet/privy-broker-server.ts +35 -25
- package/src/wallet/privy-session-broker.ts +58 -25
- package/src/wallet/privy-session-provider.ts +7 -3
- package/src/wallet/provider.ts +20 -15
- package/src/x402/facilitator.ts +3 -43
- package/src/x402-buyer/guarded-fetch.ts +213 -0
- package/src/x402-buyer/index.ts +9 -0
- package/src/x402-buyer/pay.ts +555 -0
- package/src/x402-opener/abi.ts +881 -0
- package/src/x402-opener/facilitator-entry.ts +48 -0
- package/src/x402-opener/facilitator-server.ts +1114 -0
- package/src/x402-opener/index.ts +13 -0
- package/src/x402-opener/listing-resolver.ts +202 -0
- package/src/x402-opener/refund-relay.ts +1873 -0
- package/src/x402-opener/relayer-queue.ts +18 -0
- package/src/x402-opener/scheme.ts +1551 -0
- package/src/x402-opener/terms.ts +453 -0
- package/dist/gateway/x402-mode.d.ts +0 -123
- package/dist/gateway/x402-mode.d.ts.map +0 -1
- package/dist/gateway/x402-mode.js +0 -212
- package/dist/gateway/x402-mode.js.map +0 -1
- package/dist/x402/delivery-oracle.d.ts +0 -108
- package/dist/x402/delivery-oracle.d.ts.map +0 -1
- package/dist/x402/delivery-oracle.js +0 -174
- package/dist/x402/delivery-oracle.js.map +0 -1
- package/dist/x402/facilitator-server-entry.d.ts +0 -3
- package/dist/x402/facilitator-server-entry.d.ts.map +0 -1
- package/dist/x402/facilitator-server-entry.js +0 -27
- package/dist/x402/facilitator-server-entry.js.map +0 -1
- package/dist/x402/facilitator-server.d.ts +0 -73
- package/dist/x402/facilitator-server.d.ts.map +0 -1
- package/dist/x402/facilitator-server.js +0 -305
- package/dist/x402/facilitator-server.js.map +0 -1
- package/dist/x402/payment-requirements.d.ts +0 -106
- package/dist/x402/payment-requirements.d.ts.map +0 -1
- package/dist/x402/payment-requirements.js +0 -138
- package/dist/x402/payment-requirements.js.map +0 -1
- package/dist/x402/relayer.d.ts +0 -41
- package/dist/x402/relayer.d.ts.map +0 -1
- package/dist/x402/relayer.js +0 -64
- package/dist/x402/relayer.js.map +0 -1
- package/dist/x402/resource-index.d.ts +0 -75
- package/dist/x402/resource-index.d.ts.map +0 -1
- package/dist/x402/resource-index.js +0 -126
- package/dist/x402/resource-index.js.map +0 -1
- package/dist/x402/verified-delivery-facilitator.d.ts +0 -285
- package/dist/x402/verified-delivery-facilitator.d.ts.map +0 -1
- package/dist/x402/verified-delivery-facilitator.js +0 -423
- package/dist/x402/verified-delivery-facilitator.js.map +0 -1
- package/src/gateway/x402-mode.ts +0 -350
- package/src/x402/delivery-oracle.ts +0 -285
- package/src/x402/facilitator-server-entry.ts +0 -35
- package/src/x402/facilitator-server.ts +0 -445
- package/src/x402/payment-requirements.ts +0 -231
- package/src/x402/relayer.ts +0 -122
- package/src/x402/resource-index.ts +0 -228
- package/src/x402/verified-delivery-facilitator.ts +0 -744
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { StreamV2 } from "@absol-labs/sdk";
|
|
2
|
+
import type { CliReadClient } from "./deps.js";
|
|
3
|
+
/**
|
|
4
|
+
* Why a proof-based reclaim cannot go through right now, read from chain state
|
|
5
|
+
* rather than decoded out of a revert.
|
|
6
|
+
*
|
|
7
|
+
* `metrik reclaim` used to learn this only by sending the simulation and
|
|
8
|
+
* reading what came back. That works exactly as well as the endpoint's revert
|
|
9
|
+
* data does, and on the public Base Sepolia RPC it frequently does not work at
|
|
10
|
+
* all: an already-reclaimed stream, a stream that is still running, and a
|
|
11
|
+
* stream whose stop time is not checkpointed yet ALL came back as
|
|
12
|
+
*
|
|
13
|
+
* reclaim simulation failed: Execution reverted for an unknown reason.
|
|
14
|
+
*
|
|
15
|
+
* Three different situations, three completely different next actions — you
|
|
16
|
+
* already have the money / close it first / wait ~20 seconds — and one message
|
|
17
|
+
* that distinguishes none of them. Worse, the retry loop keys off the same
|
|
18
|
+
* undecoded revert, so the wait that this command advertises never engaged.
|
|
19
|
+
*
|
|
20
|
+
* Every one of these conditions is a pure function of state the CLI already
|
|
21
|
+
* reads elsewhere (`getStreamV2`, `latestCheckpointCheckedAt`, the chain clock,
|
|
22
|
+
* and {@link settlementCoverage}, which `metrik status` has always used to
|
|
23
|
+
* decide the same question). So the condition is named from that state, before
|
|
24
|
+
* a transaction is built, the way `reclaim-unverified` has always named
|
|
25
|
+
* "already reclaimed". No revert data required.
|
|
26
|
+
*/
|
|
27
|
+
export type ReclaimBlocker =
|
|
28
|
+
/** `AlreadyReclaimed()` / `NothingToReclaim()`: the money is already back. */
|
|
29
|
+
{
|
|
30
|
+
readonly kind: "reclaimed";
|
|
31
|
+
}
|
|
32
|
+
/** `StreamNotReclaimable()`: neither closed nor expired, so the clock runs. */
|
|
33
|
+
| {
|
|
34
|
+
readonly kind: "running";
|
|
35
|
+
readonly expiresAt: number;
|
|
36
|
+
readonly secondsRemaining: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* `SettlementWindowOpen()`: the stream has stopped but no checkpoint reaches
|
|
40
|
+
* its stop time yet. The ONLY one of the three that is a wait rather than a
|
|
41
|
+
* refusal — the oracle publishes roughly every 15-22s.
|
|
42
|
+
*/
|
|
43
|
+
| {
|
|
44
|
+
readonly kind: "awaiting-checkpoint";
|
|
45
|
+
readonly stopAt: number;
|
|
46
|
+
readonly coveredUpTo: number | null;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The blocker implied by this state, or `null` when nothing in the state blocks
|
|
50
|
+
* a reclaim. Pure, so every branch is testable without an RPC — the same reason
|
|
51
|
+
* {@link settlementCoverage} is.
|
|
52
|
+
*
|
|
53
|
+
* Order matters and follows the escrow: a reclaimed stream is terminal, a
|
|
54
|
+
* running stream cannot be reclaimed at any settlement state, and only then
|
|
55
|
+
* does checkpoint coverage decide.
|
|
56
|
+
*/
|
|
57
|
+
export declare function classifyReclaimBlocker(stream: Pick<StreamV2, "status" | "closedAt" | "expiresAt" | "reclaimed">, latestCheckpointCheckedAt: number | null, nowSeconds: number): ReclaimBlocker | null;
|
|
58
|
+
/**
|
|
59
|
+
* Read the state the classifier needs and name the blocker.
|
|
60
|
+
*
|
|
61
|
+
* **Fails open.** A read that does not answer returns `null` — "nothing known
|
|
62
|
+
* to block this" — never a refusal. Refusing to return a buyer's money because
|
|
63
|
+
* a load-balanced endpoint would not answer a view call is the one outcome this
|
|
64
|
+
* command must never produce; the transaction itself remains the authority.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readReclaimBlocker(read: Pick<CliReadClient, "getStreamV2" | "latestCheckpointCheckedAt" | "latestBlockTimestamp">, streamId: `0x${string}`, fallbackNowSeconds: number): Promise<ReclaimBlocker | null>;
|
|
67
|
+
/**
|
|
68
|
+
* The refusal for a blocker that will not clear on its own, as message + hint.
|
|
69
|
+
*
|
|
70
|
+
* `awaiting-checkpoint` has no entry here on purpose: it clears by itself, so
|
|
71
|
+
* it is narrated by {@link describeAwaitingCheckpoint} and waited out, never
|
|
72
|
+
* raised as an error.
|
|
73
|
+
*/
|
|
74
|
+
export declare function describeTerminalBlocker(blocker: ReclaimBlocker, streamId: `0x${string}`): {
|
|
75
|
+
readonly message: string;
|
|
76
|
+
readonly hint: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/** The wait, named: what stopped, how far the oracle has published. */
|
|
79
|
+
export declare function describeAwaitingCheckpoint(blocker: Extract<ReclaimBlocker, {
|
|
80
|
+
kind: "awaiting-checkpoint";
|
|
81
|
+
}>): string;
|
|
82
|
+
//# sourceMappingURL=reclaimability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reclaimability.d.ts","sourceRoot":"","sources":["../../src/cli/reclaimability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,cAAc;AACxB,8EAA8E;AAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE;AAChC,+EAA+E;GAC7E;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AACH;;;;GAIG;GACD;IACE,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAEN;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC,EACzE,yBAAyB,EAAE,MAAM,GAAG,IAAI,EACxC,UAAU,EAAE,MAAM,GACjB,cAAc,GAAG,IAAI,CAsBvB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,CACR,aAAa,EACb,aAAa,GAAG,2BAA2B,GAAG,sBAAsB,CACrE,EACD,QAAQ,EAAE,KAAK,MAAM,EAAE,EACvB,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQhC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,KAAK,MAAM,EAAE,GACtB;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiB5D;AAED,uEAAuE;AACvE,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC,GAChE,MAAM,CAQR"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { formatDuration } from "./amounts.js";
|
|
2
|
+
import { formatTimestamp, readChainNow } from "./escape-hatch.js";
|
|
3
|
+
import { settlementCoverage } from "./status.js";
|
|
4
|
+
/**
|
|
5
|
+
* The blocker implied by this state, or `null` when nothing in the state blocks
|
|
6
|
+
* a reclaim. Pure, so every branch is testable without an RPC — the same reason
|
|
7
|
+
* {@link settlementCoverage} is.
|
|
8
|
+
*
|
|
9
|
+
* Order matters and follows the escrow: a reclaimed stream is terminal, a
|
|
10
|
+
* running stream cannot be reclaimed at any settlement state, and only then
|
|
11
|
+
* does checkpoint coverage decide.
|
|
12
|
+
*/
|
|
13
|
+
export function classifyReclaimBlocker(stream, latestCheckpointCheckedAt, nowSeconds) {
|
|
14
|
+
if (stream.reclaimed)
|
|
15
|
+
return { kind: "reclaimed" };
|
|
16
|
+
if (stream.status !== "closed" && nowSeconds < stream.expiresAt) {
|
|
17
|
+
return {
|
|
18
|
+
kind: "running",
|
|
19
|
+
expiresAt: stream.expiresAt,
|
|
20
|
+
secondsRemaining: stream.expiresAt - nowSeconds,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const coverage = settlementCoverage(stream, latestCheckpointCheckedAt, nowSeconds);
|
|
24
|
+
if (coverage.pending && coverage.stopAt !== null) {
|
|
25
|
+
return {
|
|
26
|
+
kind: "awaiting-checkpoint",
|
|
27
|
+
stopAt: coverage.stopAt,
|
|
28
|
+
coveredUpTo: coverage.coveredUpTo,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Read the state the classifier needs and name the blocker.
|
|
35
|
+
*
|
|
36
|
+
* **Fails open.** A read that does not answer returns `null` — "nothing known
|
|
37
|
+
* to block this" — never a refusal. Refusing to return a buyer's money because
|
|
38
|
+
* a load-balanced endpoint would not answer a view call is the one outcome this
|
|
39
|
+
* command must never produce; the transaction itself remains the authority.
|
|
40
|
+
*/
|
|
41
|
+
export async function readReclaimBlocker(read, streamId, fallbackNowSeconds) {
|
|
42
|
+
const stream = await read.getStreamV2(streamId).catch(() => null);
|
|
43
|
+
if (stream === null)
|
|
44
|
+
return null;
|
|
45
|
+
const now = await readChainNow(read, fallbackNowSeconds);
|
|
46
|
+
const latestCheckpointCheckedAt = await read
|
|
47
|
+
.latestCheckpointCheckedAt()
|
|
48
|
+
.catch(() => null);
|
|
49
|
+
return classifyReclaimBlocker(stream, latestCheckpointCheckedAt, now.seconds);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The refusal for a blocker that will not clear on its own, as message + hint.
|
|
53
|
+
*
|
|
54
|
+
* `awaiting-checkpoint` has no entry here on purpose: it clears by itself, so
|
|
55
|
+
* it is narrated by {@link describeAwaitingCheckpoint} and waited out, never
|
|
56
|
+
* raised as an error.
|
|
57
|
+
*/
|
|
58
|
+
export function describeTerminalBlocker(blocker, streamId) {
|
|
59
|
+
if (blocker.kind === "reclaimed") {
|
|
60
|
+
return {
|
|
61
|
+
message: "this stream has already been reclaimed — there is nothing left to take back",
|
|
62
|
+
hint: `check where it went: metrik status ${streamId}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (blocker.kind === "running") {
|
|
66
|
+
return {
|
|
67
|
+
message: `the stream is still running, so there is nothing to reclaim yet — the meter stops at ${formatTimestamp(blocker.expiresAt)}, in ${formatDuration(blocker.secondsRemaining)}`,
|
|
68
|
+
hint: `stop the clock first — \`metrik close ${streamId}\`, or re-run this command with --close-first — or wait for it to expire. (If you closed it moments ago, the RPC endpoint may not have caught up yet: re-run this command.)`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/** The wait, named: what stopped, how far the oracle has published. */
|
|
74
|
+
export function describeAwaitingCheckpoint(blocker) {
|
|
75
|
+
const covered = blocker.coveredUpTo === null
|
|
76
|
+
? "how far the oracle has published could not be read"
|
|
77
|
+
: `the oracle has published only to ${formatTimestamp(blocker.coveredUpTo)}`;
|
|
78
|
+
return `the stream stopped at ${formatTimestamp(blocker.stopAt)} and ${covered}. Reclaim reverts until a checkpoint reaches the stop time — the oracle publishes roughly every 15-22s, so this waits.`;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=reclaimability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reclaimability.js","sourceRoot":"","sources":["../../src/cli/reclaimability.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA+CjD;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyE,EACzE,yBAAwC,EACxC,UAAkB;IAElB,IAAI,MAAM,CAAC,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,UAAU,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;QAChE,OAAO;YACL,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,gBAAgB,EAAE,MAAM,CAAC,SAAS,GAAG,UAAU;SAChD,CAAC;IACJ,CAAC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S,CAClB,QAAQ,cAAc,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;YACnD,IAAI,EAAE,yCAAyC,QAAQ,6KAA6K;SACrO,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,0BAA0B,CACxC,OAAiE;IAEjE,MAAM,OAAO,GACX,OAAO,CAAC,WAAW,KAAK,IAAI;QAC1B,CAAC,CAAC,oDAAoD;QACtD,CAAC,CAAC,oCAAoC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;IACjF,OAAO,yBAAyB,eAAe,CAC7C,OAAO,CAAC,MAAM,CACf,QAAQ,OAAO,wHAAwH,CAAC;AAC3I,CAAC"}
|
package/dist/cli/run.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { type CliDependencies } from "./deps.js";
|
|
|
3
3
|
import type { CommandSpec } from "./context.js";
|
|
4
4
|
/**
|
|
5
5
|
* The command surface, in the order the product loop runs:
|
|
6
|
-
* discover -> open -> invoke -> watch/status -> close ->
|
|
6
|
+
* discover -> open (or pay, over x402) -> invoke -> watch/status -> close ->
|
|
7
|
+
* reclaim (or refund, through an x402 seller's gasless relay), then the
|
|
7
8
|
* operator's own redemption (`claim`) and the buyer's last-resort exit
|
|
8
9
|
* (`reclaim-unverified`). `streams` (which of them are mine?) sits inside that
|
|
9
10
|
* loop; `mcp` (run the same loop from an MCP host) sits after it.
|
package/dist/cli/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAeA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAQzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAqChD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,WAAW,EAc1C,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAwEpE;AAqBD,wBAAgB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAyEvD"}
|
package/dist/cli/run.js
CHANGED
|
@@ -1,25 +1,46 @@
|
|
|
1
|
-
import { assertKnownFlags, booleanFlag, parseArgs } from "./args.js";
|
|
2
|
-
import { CONFIG_FLAGS, GLOBAL_FLAGS,
|
|
1
|
+
import { JSON_BODY_COMMANDS, assertKnownFlags, booleanFlag, jsonOutputRequested, parseArgs, } from "./args.js";
|
|
2
|
+
import { CONFIG_FLAGS, GLOBAL_FLAGS, CLI_NETWORK_POLICY, resolveConfig, } from "./config.js";
|
|
3
|
+
import { describeAllowedNetworks } from "../network.js";
|
|
3
4
|
import { CliError, describeError, usageError } from "./errors.js";
|
|
4
5
|
import { createPrinter } from "./output.js";
|
|
5
6
|
import { startHeartbeat } from "./progress.js";
|
|
6
7
|
import { defaultCliDependencies } from "./deps.js";
|
|
7
8
|
import { packageVersion } from "./version.js";
|
|
8
|
-
import { CDP_ENV_VARS, PRIVATE_KEY_ENV } from "./wallet.js";
|
|
9
|
+
import { CDP_ENV_VARS, PRIVATE_KEY_ENV, PRIVY_SESSION_ENV_VARS, PRIVY_WALLET_KEY_ENV, } from "./wallet.js";
|
|
9
10
|
import { claimCommand } from "./commands/claim.js";
|
|
10
11
|
import { closeCommand } from "./commands/close.js";
|
|
11
12
|
import { discoverCommand } from "./commands/discover.js";
|
|
12
13
|
import { invokeCommand } from "./commands/invoke.js";
|
|
13
14
|
import { mcpCommand } from "./commands/mcp.js";
|
|
14
15
|
import { openCommand } from "./commands/open.js";
|
|
16
|
+
import { payCommand } from "./commands/pay.js";
|
|
15
17
|
import { reclaimCommand } from "./commands/reclaim.js";
|
|
18
|
+
import { refundCommand } from "./commands/refund.js";
|
|
16
19
|
import { reclaimUnverifiedCommand } from "./commands/reclaim-unverified.js";
|
|
17
20
|
import { statusCommand } from "./commands/status.js";
|
|
18
21
|
import { streamsCommand } from "./commands/streams.js";
|
|
19
22
|
import { watchCommand } from "./commands/watch.js";
|
|
23
|
+
/**
|
|
24
|
+
* Every wallet source, named in the order they are resolved. Privy shipped in
|
|
25
|
+
* 0.11.0 as resolution step 3 and worked, but appeared in no user-facing text
|
|
26
|
+
* at all — so the only way to learn the CLI could use it was to read the
|
|
27
|
+
* source or the docs. An external reviewer running the published package
|
|
28
|
+
* concluded it did not exist.
|
|
29
|
+
*/
|
|
30
|
+
const WALLET_SOURCES = `${PRIVATE_KEY_ENV}, ${CDP_ENV_VARS.join(" + ")}, ` +
|
|
31
|
+
`or ${PRIVY_WALLET_KEY_ENV} (Privy; or a broker session via ${PRIVY_SESSION_ENV_VARS.join(" + ")}).`;
|
|
32
|
+
/**
|
|
33
|
+
* Said in the help, not only discovered at runtime. `claim` is the OPERATOR's
|
|
34
|
+
* side and a Privy broker policy allowlists BUYER actions only, so a Privy
|
|
35
|
+
* wallet cannot sign one — the broker refuses, and the client cannot raise its
|
|
36
|
+
* own ceiling. The command already warns when it runs; someone choosing a
|
|
37
|
+
* wallet needs it before that.
|
|
38
|
+
*/
|
|
39
|
+
const PRIVY_CLAIM_NOTE = "`metrik claim` does NOT work on a Privy wallet: the broker's transaction allowlist is buyer-only. Claim with the operator's own key.";
|
|
20
40
|
/**
|
|
21
41
|
* The command surface, in the order the product loop runs:
|
|
22
|
-
* discover -> open -> invoke -> watch/status -> close ->
|
|
42
|
+
* discover -> open (or pay, over x402) -> invoke -> watch/status -> close ->
|
|
43
|
+
* reclaim (or refund, through an x402 seller's gasless relay), then the
|
|
23
44
|
* operator's own redemption (`claim`) and the buyer's last-resort exit
|
|
24
45
|
* (`reclaim-unverified`). `streams` (which of them are mine?) sits inside that
|
|
25
46
|
* loop; `mcp` (run the same loop from an MCP host) sits after it.
|
|
@@ -27,12 +48,14 @@ import { watchCommand } from "./commands/watch.js";
|
|
|
27
48
|
export const COMMANDS = [
|
|
28
49
|
discoverCommand,
|
|
29
50
|
openCommand,
|
|
51
|
+
payCommand,
|
|
30
52
|
statusCommand,
|
|
31
53
|
streamsCommand,
|
|
32
54
|
watchCommand,
|
|
33
55
|
invokeCommand,
|
|
34
56
|
closeCommand,
|
|
35
57
|
reclaimCommand,
|
|
58
|
+
refundCommand,
|
|
36
59
|
reclaimUnverifiedCommand,
|
|
37
60
|
claimCommand,
|
|
38
61
|
mcpCommand,
|
|
@@ -52,7 +75,7 @@ export async function runCli(options) {
|
|
|
52
75
|
let json = false;
|
|
53
76
|
try {
|
|
54
77
|
const args = parseArgs(options.argv);
|
|
55
|
-
json =
|
|
78
|
+
json = jsonOutputRequested(args);
|
|
56
79
|
const out = createPrinter(streams, json);
|
|
57
80
|
// `--version` is checked before the bare-invocation help branch: `metrik
|
|
58
81
|
// --version` parses to no command at all.
|
|
@@ -87,7 +110,14 @@ export async function runCli(options) {
|
|
|
87
110
|
// exception is a rule someone forgets to apply to the next command.
|
|
88
111
|
const heartbeat = startHeartbeat(out.note, `metrik ${command.name}`);
|
|
89
112
|
try {
|
|
90
|
-
await command.run({
|
|
113
|
+
await command.run({
|
|
114
|
+
args,
|
|
115
|
+
config,
|
|
116
|
+
env,
|
|
117
|
+
out,
|
|
118
|
+
deps,
|
|
119
|
+
progress: heartbeat,
|
|
120
|
+
});
|
|
91
121
|
}
|
|
92
122
|
finally {
|
|
93
123
|
heartbeat.stop();
|
|
@@ -124,20 +154,25 @@ export function renderHelp(commandName) {
|
|
|
124
154
|
"",
|
|
125
155
|
command.flags.length === 0
|
|
126
156
|
? "Command flags: (none)"
|
|
127
|
-
: `Command flags: ${command.flags.map((flag) => `--${flag}`).join(" ")}`,
|
|
157
|
+
: `Command flags: ${command.flags.map((flag) => command.flagHelp?.[flag] ?? `--${flag}`).join(" ")}`,
|
|
128
158
|
`Settlement flags: ${CONFIG_FLAGS.map((flag) => `--${flag}`).join(" ")}`,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
: command.requiresKey === true
|
|
159
|
+
JSON_BODY_COMMANDS.has(command.name)
|
|
160
|
+
? "Output flags: --json (bare, with no body; combinable with --json <body>)"
|
|
161
|
+
: "Output flags: --json",
|
|
162
|
+
...(command.walletHelp !== undefined
|
|
163
|
+
? ["", command.walletHelp.text]
|
|
164
|
+
: command.signs
|
|
136
165
|
? [
|
|
137
166
|
"",
|
|
138
|
-
`Broadcasts
|
|
167
|
+
`Broadcasts a transaction. Requires a wallet in the environment: ${WALLET_SOURCES}`,
|
|
168
|
+
...(command.name === "claim" ? [PRIVY_CLAIM_NOTE] : []),
|
|
139
169
|
]
|
|
140
|
-
:
|
|
170
|
+
: command.requiresKey === true
|
|
171
|
+
? [
|
|
172
|
+
"",
|
|
173
|
+
`Broadcasts nothing, but signs an off-chain EIP-712 capability, so it requires a wallet in the environment: ${WALLET_SOURCES}`,
|
|
174
|
+
]
|
|
175
|
+
: []),
|
|
141
176
|
].join("\n");
|
|
142
177
|
}
|
|
143
178
|
const width = COMMANDS.reduce((max, spec) => Math.max(max, spec.name.length), 0);
|
|
@@ -151,22 +186,28 @@ export function renderHelp(commandName) {
|
|
|
151
186
|
"Usage: metrik <command> [options]",
|
|
152
187
|
"",
|
|
153
188
|
"Commands:",
|
|
154
|
-
...COMMANDS.map((spec) => ` ${spec.name.padEnd(width)} ${spec.summary}${spec.signs ? " [broadcasts a tx]" : spec.requiresKey === true ? " [needs a key]" : ""}`),
|
|
189
|
+
...COMMANDS.map((spec) => ` ${spec.name.padEnd(width)} ${spec.summary}${spec.walletHelp !== undefined ? ` ${spec.walletHelp.tag}` : spec.signs ? " [broadcasts a tx]" : spec.requiresKey === true ? " [needs a key]" : ""}`),
|
|
155
190
|
"",
|
|
156
191
|
"Global flags:",
|
|
157
192
|
" --json machine-readable output on stdout",
|
|
158
193
|
" --help this text, or `metrik <command> --help`",
|
|
159
194
|
"",
|
|
160
|
-
"Settlement flags (all default to
|
|
161
|
-
" --chain-id --rpc-url --escrow --usdc --oracle-url --registry-url",
|
|
195
|
+
"Settlement flags (all default to the selected network's registry entry):",
|
|
196
|
+
" --network --chain-id --rpc-url --escrow --usdc --oracle-url --registry-url",
|
|
197
|
+
" --network takes a registry id, chain id or CAIP-2 id (env METRIK_NETWORK).",
|
|
162
198
|
"",
|
|
163
199
|
"Wallet (read from the environment only; never accepted as a flag):",
|
|
164
|
-
` ${PRIVATE_KEY_ENV} a
|
|
200
|
+
` ${PRIVATE_KEY_ENV} a testnet key. Checked first.`,
|
|
165
201
|
` ${CDP_ENV_VARS.join(", ")}`,
|
|
166
202
|
" a Coinbase CDP Server Wallet v2 account. Used when no private key is set.",
|
|
203
|
+
` ${PRIVY_WALLET_KEY_ENV}`,
|
|
204
|
+
" a Privy wallet you provisioned, reached through a broker. Checked third.",
|
|
205
|
+
` A broker session instead: ${PRIVY_SESSION_ENV_VARS.join(", ")}.`,
|
|
206
|
+
` ${PRIVY_CLAIM_NOTE}`,
|
|
207
|
+
" Nor do `metrik pay` (the broker does not sign EIP-3009) or `metrik refund --close` (nor the opener's Close).",
|
|
167
208
|
" A credential on the command line lands in shell history; these never are.",
|
|
168
209
|
"",
|
|
169
|
-
`TESTNET ONLY: this CLI refuses any chain outside ${
|
|
210
|
+
`TESTNET ONLY: this CLI refuses any chain outside the registered testnets: ${describeAllowedNetworks(CLI_NETWORK_POLICY)},`,
|
|
170
211
|
"and re-checks the chain id the RPC actually serves before signing. There is no override.",
|
|
171
212
|
].join("\n");
|
|
172
213
|
}
|
package/dist/cli/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAwB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,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I,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CACzM;QACD,EAAE;QACF,eAAe;QACf,qDAAqD;QACrD,2DAA2D;QAC3D,EAAE;QACF,0EAA0E;QAC1E,oFAAoF;QACpF,8EAA8E;QAC9E,EAAE;QACF,oEAAoE;QACpE,KAAK,eAAe,iCAAiC;QACrD,KAAK,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9B,+EAA+E;QAC/E,KAAK,oBAAoB,EAAE;QAC3B,8EAA8E;QAC9E,iCAAiC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACrE,OAAO,gBAAgB,EAAE;QACzB,kHAAkH;QAClH,6EAA6E;QAC7E,EAAE;QACF,6EAA6E,uBAAuB,CAAC,kBAAkB,CAAC,GAAG;QAC3H,0FAA0F;KAC3F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/cli/scan-range.d.ts
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
* `buyer` and `operator` are INDEXED on `StreamOpened`, so a per-wallet scan is
|
|
20
20
|
* a server-side topic filter whose response is tiny regardless of range. What
|
|
21
21
|
* public RPCs cap is the per-call BLOCK RANGE, and a topic filter does not lift
|
|
22
|
-
* it:
|
|
22
|
+
* it: the public RPC answers a wider range with `-32614 "eth_getLogs is
|
|
23
23
|
* limited to a 10,000 range"`. So the page size is the cap, not a guess below
|
|
24
24
|
* it.
|
|
25
25
|
*/
|
|
26
26
|
/**
|
|
27
27
|
* getLogs page size. The window is `chunk + 1` blocks (bounds inclusive), so
|
|
28
|
-
* 9 999 is the largest page
|
|
28
|
+
* 9 999 is the largest page the public RPC accepts.
|
|
29
29
|
*/
|
|
30
30
|
export declare const LOG_SCAN_CHUNK = 9999n;
|
|
31
31
|
/**
|
package/dist/cli/scan-range.js
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
* `buyer` and `operator` are INDEXED on `StreamOpened`, so a per-wallet scan is
|
|
20
20
|
* a server-side topic filter whose response is tiny regardless of range. What
|
|
21
21
|
* public RPCs cap is the per-call BLOCK RANGE, and a topic filter does not lift
|
|
22
|
-
* it:
|
|
22
|
+
* it: the public RPC answers a wider range with `-32614 "eth_getLogs is
|
|
23
23
|
* limited to a 10,000 range"`. So the page size is the cap, not a guess below
|
|
24
24
|
* it.
|
|
25
25
|
*/
|
|
26
26
|
/**
|
|
27
27
|
* getLogs page size. The window is `chunk + 1` blocks (bounds inclusive), so
|
|
28
|
-
* 9 999 is the largest page
|
|
28
|
+
* 9 999 is the largest page the public RPC accepts.
|
|
29
29
|
*/
|
|
30
30
|
export const LOG_SCAN_CHUNK = 9999n;
|
|
31
31
|
/**
|
package/dist/cli/status.d.ts
CHANGED
|
@@ -38,6 +38,87 @@ export interface SettlementCoverage {
|
|
|
38
38
|
* is to withhold a number we cannot stand behind, never to print one we cannot.
|
|
39
39
|
*/
|
|
40
40
|
export declare function settlementCoverage(stream: Pick<StreamV2, "closedAt" | "expiresAt">, latestCheckpointCheckedAt: number | null, nowSeconds: number): SettlementCoverage;
|
|
41
|
+
/**
|
|
42
|
+
* How much of the operator's verified, unclaimed accrual the buyer's no-proof
|
|
43
|
+
* escape hatch (`reclaimUnverified`) could take. All amounts are GROSS
|
|
44
|
+
* cumulative USDC base units (before the protocol fee), the unit the escrow
|
|
45
|
+
* settles in; the operator receives a claimed amount net of the fee.
|
|
46
|
+
*
|
|
47
|
+
* The rule depends on the escrow's generation:
|
|
48
|
+
*
|
|
49
|
+
* - **V2**: the hatch settles the operator at `claimedCumulative`, so every
|
|
50
|
+
* verified-but-unclaimed unit is exposed.
|
|
51
|
+
* - **V3**: the hatch settles the operator at
|
|
52
|
+
* `max(claimedCumulative, provenCumulative)` — the on-chain proven high-water
|
|
53
|
+
* the oracle's `recordProven` keeper (or any claim / reclaim with a proof)
|
|
54
|
+
* writes, and which the operator can redeem with `claimProven`. Only verified
|
|
55
|
+
* value NOBODY has proven on-chain is exposed.
|
|
56
|
+
*/
|
|
57
|
+
export interface OperatorHatchExposure {
|
|
58
|
+
/** Verified cumulative from the oracle proof, capped at the deposit (gross). */
|
|
59
|
+
readonly verifiedCumulative: bigint;
|
|
60
|
+
/** What the hatch would still settle to the operator (gross). */
|
|
61
|
+
readonly protectedCumulative: bigint;
|
|
62
|
+
/** `max(0, verifiedCumulative − protectedCumulative)` (gross). */
|
|
63
|
+
readonly atRiskCumulative: bigint;
|
|
64
|
+
/**
|
|
65
|
+
* V3 only: whether `provenCumulative` was read. `false` means it was assumed
|
|
66
|
+
* to be zero (worst case for the operator), never assumed to be protective.
|
|
67
|
+
* Always `true` on V2, which has no such view.
|
|
68
|
+
*/
|
|
69
|
+
readonly provenCumulativeKnown: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The exposure for a stream that has NOT been reclaimed and has a verified
|
|
73
|
+
* proof. Pure, so the per-generation rule is testable without an RPC. Returns
|
|
74
|
+
* `null` when there is nothing to reason about (no proof, or already reclaimed:
|
|
75
|
+
* a reclaimed stream has no hatch left to open).
|
|
76
|
+
*/
|
|
77
|
+
export declare function operatorHatchExposure(stream: Pick<StreamV2, "deposit" | "claimedCumulative" | "reclaimed">, verifiedCumulative: bigint | null, generation: string, provenCumulative: bigint | null): OperatorHatchExposure | null;
|
|
78
|
+
/**
|
|
79
|
+
* A stream whose buyer side is over, read from chain state. All amounts gross.
|
|
80
|
+
*
|
|
81
|
+
* Two ways to get here:
|
|
82
|
+
*
|
|
83
|
+
* - `reclaimed`: the buyer reclaimed. Read from the stream tuple, which reclaim
|
|
84
|
+
* WRITES, unlike during the stream's active life. The buyer's refund is
|
|
85
|
+
* deliberately absent: reclaim overwrites `deposit` with the operator's
|
|
86
|
+
* entitlement, so `deposit − settled` is NOT the refund, and the true figure
|
|
87
|
+
* lives only in the reclaim's `BuyerReclaimed` event, which this screen does
|
|
88
|
+
* not scan for (the reclaim block is unknown, so the lookup is not bounded).
|
|
89
|
+
* - `deposit-exhausted`: the stream has stopped (closed, or past expiry) and the
|
|
90
|
+
* operator's floor already covers the whole deposit, so there is nothing to
|
|
91
|
+
* reclaim and the buyer never will. Both buyer exits settle the operator at no
|
|
92
|
+
* less than `max(claimedCumulative, provenCumulative)` (V2:
|
|
93
|
+
* `claimedCumulative`) and revert `NothingToReclaim` when `deposit − floor` is
|
|
94
|
+
* zero, so `reclaimed` stays `false` forever on such a stream.
|
|
95
|
+
*/
|
|
96
|
+
export interface FinalSettlement {
|
|
97
|
+
readonly finishedBy: "reclaimed" | "deposit-exhausted";
|
|
98
|
+
/**
|
|
99
|
+
* The operator's entitlement: `settledCumulative` (fixed at reclaim), or the
|
|
100
|
+
* whole `deposit` when it was exhausted.
|
|
101
|
+
*/
|
|
102
|
+
readonly settledToOperator: bigint;
|
|
103
|
+
/** `claimedCumulative`: what the operator has redeemed so far. */
|
|
104
|
+
readonly operatorClaimed: bigint;
|
|
105
|
+
/** `settledToOperator − operatorClaimed`, still escrowed for the operator. */
|
|
106
|
+
readonly operatorUnclaimed: bigint;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Whether the buyer side of a stream is finished, and what the operator holds.
|
|
110
|
+
* Pure, so the rule is testable without an RPC.
|
|
111
|
+
*
|
|
112
|
+
* `stopped` is the escrow's own reclaim gate (closed, or `now >= expiresAt`).
|
|
113
|
+
* `provenCumulative` counts only on V3, and only when it was READ: an
|
|
114
|
+
* unreadable high-water is treated as zero, so it can never make a stream look
|
|
115
|
+
* finished that is not.
|
|
116
|
+
*/
|
|
117
|
+
export declare function finalSettlement(stream: Pick<StreamV2, "reclaimed" | "settledCumulative" | "claimedCumulative" | "deposit">, exhaustion?: {
|
|
118
|
+
readonly stopped: boolean;
|
|
119
|
+
readonly generation: string;
|
|
120
|
+
readonly provenCumulative: bigint | null;
|
|
121
|
+
}): FinalSettlement | null;
|
|
41
122
|
/**
|
|
42
123
|
* A stream as the CLI reports it.
|
|
43
124
|
*
|
|
@@ -55,6 +136,12 @@ export interface StreamReport {
|
|
|
55
136
|
/** Why there is no proof yet, when applicable. */
|
|
56
137
|
readonly proofUnavailable: string | null;
|
|
57
138
|
readonly claimable: bigint | null;
|
|
139
|
+
/**
|
|
140
|
+
* What {@link claimable} was computed against: the oracle's current proof,
|
|
141
|
+
* or — V3, when the latest checkpoint no longer contains the stream — the
|
|
142
|
+
* on-chain proven high-water, which `claimProven` redeems without a proof.
|
|
143
|
+
*/
|
|
144
|
+
readonly claimableSource: "checkpoint-proof" | "proven-on-chain" | null;
|
|
58
145
|
readonly reclaimable: bigint | null;
|
|
59
146
|
readonly protocolFeeBps: number | null;
|
|
60
147
|
/**
|
|
@@ -83,8 +170,26 @@ export interface StreamReport {
|
|
|
83
170
|
* "no overlap".
|
|
84
171
|
*/
|
|
85
172
|
readonly attesters: AttesterSet;
|
|
173
|
+
/** The escrow generation this report was read against (`v2` / `v3`). */
|
|
174
|
+
readonly escrowGeneration: string;
|
|
175
|
+
/**
|
|
176
|
+
* V3 only: the on-chain proven high-water (`provenCumulativeOf`). `null` on
|
|
177
|
+
* V2, or when the read failed — see {@link provenUnavailable}.
|
|
178
|
+
*/
|
|
179
|
+
readonly provenCumulative: bigint | null;
|
|
180
|
+
/** Why a V3 proven high-water could not be read, when applicable. */
|
|
181
|
+
readonly provenUnavailable: string | null;
|
|
182
|
+
/** See {@link operatorHatchExposure}. `null` when not applicable. */
|
|
183
|
+
readonly operatorExposure: OperatorHatchExposure | null;
|
|
184
|
+
/**
|
|
185
|
+
* See {@link finalSettlement}. Non-null exactly when the buyer side is over:
|
|
186
|
+
* reclaimed, or stopped with the whole deposit already the operator's.
|
|
187
|
+
*/
|
|
188
|
+
readonly finalSettlement: FinalSettlement | null;
|
|
86
189
|
}
|
|
87
|
-
export declare function readStreamReport(read: CliReadClient, streamId: `0x${string}`, nowSeconds: number
|
|
190
|
+
export declare function readStreamReport(read: CliReadClient, streamId: `0x${string}`, nowSeconds: number,
|
|
191
|
+
/** The escrow's generation (decides the escape-hatch rule). Default `v2`. */
|
|
192
|
+
escrowGeneration?: string): Promise<StreamReport>;
|
|
88
193
|
export declare function streamReportJson(report: StreamReport): unknown;
|
|
89
194
|
export declare function streamReportRows(report: StreamReport): (readonly [string, string])[];
|
|
90
195
|
//# sourceMappingURL=status.d.ts.map
|
package/dist/cli/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/cli/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC,EAChD,yBAAyB,EAAE,MAAM,GAAG,IAAI,EACxC,UAAU,EAAE,MAAM,GACjB,kBAAkB,CAgBpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC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