@absol-labs/agent 0.9.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -26
- package/dist/capability/invocation-capability.d.ts +18 -6
- package/dist/capability/invocation-capability.d.ts.map +1 -1
- package/dist/capability/invocation-capability.js.map +1 -1
- package/dist/cli/amounts.d.ts +26 -0
- package/dist/cli/amounts.d.ts.map +1 -0
- package/dist/cli/amounts.js +71 -0
- package/dist/cli/amounts.js.map +1 -0
- package/dist/cli/args.d.ts +32 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +119 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/attesters.d.ts +51 -0
- package/dist/cli/attesters.d.ts.map +1 -0
- package/dist/cli/attesters.js +58 -0
- package/dist/cli/attesters.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +5 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/claim.d.ts +13 -0
- package/dist/cli/commands/claim.d.ts.map +1 -0
- package/dist/cli/commands/claim.js +102 -0
- package/dist/cli/commands/claim.js.map +1 -0
- package/dist/cli/commands/close.d.ts +3 -0
- package/dist/cli/commands/close.d.ts.map +1 -0
- package/dist/cli/commands/close.js +55 -0
- package/dist/cli/commands/close.js.map +1 -0
- package/dist/cli/commands/discover.d.ts +3 -0
- package/dist/cli/commands/discover.d.ts.map +1 -0
- package/dist/cli/commands/discover.js +183 -0
- package/dist/cli/commands/discover.js.map +1 -0
- package/dist/cli/commands/invoke.d.ts +3 -0
- package/dist/cli/commands/invoke.d.ts.map +1 -0
- package/dist/cli/commands/invoke.js +142 -0
- package/dist/cli/commands/invoke.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +3 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +113 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/open.d.ts +3 -0
- package/dist/cli/commands/open.d.ts.map +1 -0
- package/dist/cli/commands/open.js +331 -0
- package/dist/cli/commands/open.js.map +1 -0
- package/dist/cli/commands/reclaim-unverified.d.ts +3 -0
- package/dist/cli/commands/reclaim-unverified.d.ts.map +1 -0
- package/dist/cli/commands/reclaim-unverified.js +172 -0
- package/dist/cli/commands/reclaim-unverified.js.map +1 -0
- package/dist/cli/commands/reclaim.d.ts +33 -0
- package/dist/cli/commands/reclaim.d.ts.map +1 -0
- package/dist/cli/commands/reclaim.js +308 -0
- package/dist/cli/commands/reclaim.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +43 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/streams.d.ts +3 -0
- package/dist/cli/commands/streams.d.ts.map +1 -0
- package/dist/cli/commands/streams.js +257 -0
- package/dist/cli/commands/streams.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +3 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +55 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/config.d.ts +61 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +140 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/context.d.ts +29 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/context.js +2 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/deps.d.ts +191 -0
- package/dist/cli/deps.d.ts.map +1 -0
- package/dist/cli/deps.js +277 -0
- package/dist/cli/deps.js.map +1 -0
- package/dist/cli/descriptor.d.ts +61 -0
- package/dist/cli/descriptor.d.ts.map +1 -0
- package/dist/cli/descriptor.js +78 -0
- package/dist/cli/descriptor.js.map +1 -0
- package/dist/cli/errors.d.ts +48 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +129 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/escape-hatch.d.ts +50 -0
- package/dist/cli/escape-hatch.d.ts.map +1 -0
- package/dist/cli/escape-hatch.js +45 -0
- package/dist/cli/escape-hatch.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +7 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/listings.d.ts +15 -0
- package/dist/cli/listings.d.ts.map +1 -0
- package/dist/cli/listings.js +56 -0
- package/dist/cli/listings.js.map +1 -0
- package/dist/cli/mandate.d.ts +66 -0
- package/dist/cli/mandate.d.ts.map +1 -0
- package/dist/cli/mandate.js +61 -0
- package/dist/cli/mandate.js.map +1 -0
- package/dist/cli/output.d.ts +33 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +34 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/preflight.d.ts +38 -0
- package/dist/cli/preflight.d.ts.map +1 -0
- package/dist/cli/preflight.js +72 -0
- package/dist/cli/preflight.js.map +1 -0
- package/dist/cli/privy.d.ts +83 -0
- package/dist/cli/privy.d.ts.map +1 -0
- package/dist/cli/privy.js +230 -0
- package/dist/cli/privy.js.map +1 -0
- package/dist/cli/progress.d.ts +36 -0
- package/dist/cli/progress.d.ts.map +1 -0
- package/dist/cli/progress.js +40 -0
- package/dist/cli/progress.js.map +1 -0
- package/dist/cli/run.d.ts +25 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +173 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/scan-range.d.ts +55 -0
- package/dist/cli/scan-range.d.ts.map +1 -0
- package/dist/cli/scan-range.js +57 -0
- package/dist/cli/scan-range.js.map +1 -0
- 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 +90 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +252 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/timeout.d.ts +30 -0
- package/dist/cli/timeout.d.ts.map +1 -0
- package/dist/cli/timeout.js +55 -0
- package/dist/cli/timeout.js.map +1 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +22 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/wallet.d.ts +164 -0
- package/dist/cli/wallet.d.ts.map +1 -0
- package/dist/cli/wallet.js +234 -0
- package/dist/cli/wallet.js.map +1 -0
- package/dist/frameworks/crewai.d.ts +10 -0
- package/dist/frameworks/crewai.d.ts.map +1 -1
- package/dist/frameworks/crewai.js +12 -2
- package/dist/frameworks/crewai.js.map +1 -1
- package/dist/gateway/caller-auth-gateway.d.ts +38 -3
- package/dist/gateway/caller-auth-gateway.d.ts.map +1 -1
- package/dist/gateway/caller-auth-gateway.js +25 -1
- package/dist/gateway/caller-auth-gateway.js.map +1 -1
- package/dist/gateway/http-server.d.ts +53 -0
- package/dist/gateway/http-server.d.ts.map +1 -1
- package/dist/gateway/http-server.js +189 -4
- package/dist/gateway/http-server.js.map +1 -1
- package/dist/gateway/server-entry.d.ts +1 -0
- package/dist/gateway/server-entry.js +1 -0
- package/dist/gateway/server-entry.js.map +1 -1
- package/dist/gateway/x402-mode.d.ts +123 -0
- package/dist/gateway/x402-mode.d.ts.map +1 -0
- package/dist/gateway/x402-mode.js +212 -0
- package/dist/gateway/x402-mode.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- 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/http-server.d.ts +1 -0
- package/dist/mcp/http-server.js +1 -0
- package/dist/mcp/http-server.js.map +1 -1
- package/dist/mcp/server.d.ts +49 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +533 -25
- 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/stdio.d.ts +1 -0
- package/dist/mcp/stdio.js +1 -0
- package/dist/mcp/stdio.js.map +1 -1
- package/dist/sdk/client.d.ts +25 -1
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/client.js +20 -1
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/invoke.d.ts +19 -4
- package/dist/sdk/invoke.d.ts.map +1 -1
- package/dist/sdk/invoke.js +69 -5
- package/dist/sdk/invoke.js.map +1 -1
- package/dist/x402/delivery-oracle.d.ts +108 -0
- package/dist/x402/delivery-oracle.d.ts.map +1 -0
- package/dist/x402/delivery-oracle.js +174 -0
- package/dist/x402/delivery-oracle.js.map +1 -0
- package/dist/x402/facilitator-server-entry.d.ts +3 -0
- package/dist/x402/facilitator-server-entry.d.ts.map +1 -0
- package/dist/x402/facilitator-server-entry.js +27 -0
- package/dist/x402/facilitator-server-entry.js.map +1 -0
- package/dist/x402/facilitator-server.d.ts +73 -0
- package/dist/x402/facilitator-server.d.ts.map +1 -0
- package/dist/x402/facilitator-server.js +305 -0
- package/dist/x402/facilitator-server.js.map +1 -0
- package/dist/x402/facilitator.d.ts +69 -17
- package/dist/x402/facilitator.d.ts.map +1 -1
- package/dist/x402/facilitator.js +76 -33
- package/dist/x402/facilitator.js.map +1 -1
- package/dist/x402/payment-requirements.d.ts +106 -0
- package/dist/x402/payment-requirements.d.ts.map +1 -0
- package/dist/x402/payment-requirements.js +138 -0
- package/dist/x402/payment-requirements.js.map +1 -0
- package/dist/x402/relayer.d.ts +41 -0
- package/dist/x402/relayer.d.ts.map +1 -0
- package/dist/x402/relayer.js +64 -0
- package/dist/x402/relayer.js.map +1 -0
- package/dist/x402/resource-index.d.ts +75 -0
- package/dist/x402/resource-index.d.ts.map +1 -0
- package/dist/x402/resource-index.js +126 -0
- package/dist/x402/resource-index.js.map +1 -0
- package/dist/x402/verified-delivery-facilitator.d.ts +285 -0
- package/dist/x402/verified-delivery-facilitator.d.ts.map +1 -0
- package/dist/x402/verified-delivery-facilitator.js +423 -0
- package/dist/x402/verified-delivery-facilitator.js.map +1 -0
- package/dist/zktls/t2-delivery-proof.d.ts +6 -6
- package/docs/agent-layer.md +14 -9
- package/docs/cli.md +705 -0
- package/docs/crewai.md +6 -2
- package/docs/eliza.md +6 -1
- package/docs/mcp-hosted.md +7 -5
- package/docs/mcp-reference.md +175 -0
- package/docs/quickstart.md +36 -9
- package/docs/threat-model.md +4 -3
- package/docs/x402.md +648 -0
- package/package.json +33 -10
- package/src/capability/invocation-capability.ts +17 -1
- package/src/cli/amounts.ts +102 -0
- package/src/cli/args.ts +150 -0
- package/src/cli/attesters.ts +86 -0
- package/src/cli/bin.ts +5 -0
- package/src/cli/commands/claim.ts +126 -0
- package/src/cli/commands/close.ts +69 -0
- package/src/cli/commands/discover.ts +228 -0
- package/src/cli/commands/invoke.ts +178 -0
- package/src/cli/commands/mcp.ts +135 -0
- package/src/cli/commands/open.ts +397 -0
- package/src/cli/commands/reclaim-unverified.ts +218 -0
- package/src/cli/commands/reclaim.ts +377 -0
- package/src/cli/commands/status.ts +56 -0
- package/src/cli/commands/streams.ts +344 -0
- package/src/cli/commands/watch.ts +70 -0
- package/src/cli/config.ts +208 -0
- package/src/cli/context.ts +30 -0
- package/src/cli/deps.ts +528 -0
- package/src/cli/descriptor.ts +133 -0
- package/src/cli/errors.ts +162 -0
- package/src/cli/escape-hatch.ts +92 -0
- package/src/cli/index.ts +27 -0
- package/src/cli/listings.ts +77 -0
- package/src/cli/mandate.ts +126 -0
- package/src/cli/output.ts +63 -0
- package/src/cli/preflight.ts +88 -0
- package/src/cli/privy.ts +396 -0
- package/src/cli/progress.ts +75 -0
- package/src/cli/run.ts +209 -0
- package/src/cli/scan-range.ts +76 -0
- package/src/cli/spend-policy.ts +139 -0
- package/src/cli/status.ts +381 -0
- package/src/cli/timeout.ts +64 -0
- package/src/cli/version.ts +21 -0
- package/src/cli/wallet.ts +372 -0
- package/src/frameworks/crewai.ts +13 -2
- package/src/gateway/caller-auth-gateway.ts +77 -6
- package/src/gateway/http-server.ts +280 -6
- package/src/gateway/server-entry.ts +1 -0
- package/src/gateway/x402-mode.ts +350 -0
- package/src/index.ts +40 -5
- package/src/mandates/env.ts +3 -2
- package/src/mcp/http-server.ts +1 -0
- package/src/mcp/server.ts +706 -30
- package/src/mcp/service-invoker.ts +285 -0
- package/src/mcp/stdio.ts +1 -0
- package/src/sdk/client.ts +33 -1
- package/src/sdk/invoke.ts +90 -12
- package/src/x402/delivery-oracle.ts +285 -0
- package/src/x402/facilitator-server-entry.ts +35 -0
- package/src/x402/facilitator-server.ts +445 -0
- package/src/x402/facilitator.ts +125 -46
- package/src/x402/payment-requirements.ts +231 -0
- package/src/x402/relayer.ts +122 -0
- package/src/x402/resource-index.ts +228 -0
- package/src/x402/verified-delivery-facilitator.ts +744 -0
package/dist/cli/args.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { usageError } from "./errors.js";
|
|
2
|
+
export function parseArgs(argv) {
|
|
3
|
+
const positionals = [];
|
|
4
|
+
const flags = new Map();
|
|
5
|
+
const push = (name, value) => {
|
|
6
|
+
const existing = flags.get(name);
|
|
7
|
+
if (existing === undefined)
|
|
8
|
+
flags.set(name, [value]);
|
|
9
|
+
else
|
|
10
|
+
existing.push(value);
|
|
11
|
+
};
|
|
12
|
+
let passthrough = false;
|
|
13
|
+
for (let index = 0; index < argv.length; index++) {
|
|
14
|
+
const token = argv[index];
|
|
15
|
+
if (token === undefined)
|
|
16
|
+
continue;
|
|
17
|
+
if (passthrough || !token.startsWith("--")) {
|
|
18
|
+
positionals.push(token);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (token === "--") {
|
|
22
|
+
passthrough = true;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const body = token.slice(2);
|
|
26
|
+
const equals = body.indexOf("=");
|
|
27
|
+
if (equals !== -1) {
|
|
28
|
+
const name = body.slice(0, equals);
|
|
29
|
+
assertFlagName(name, token);
|
|
30
|
+
push(name, body.slice(equals + 1));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
assertFlagName(body, token);
|
|
34
|
+
if (body.startsWith("no-")) {
|
|
35
|
+
push(body.slice(3), false);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const next = argv[index + 1];
|
|
39
|
+
if (next === undefined || next.startsWith("--")) {
|
|
40
|
+
push(body, true);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
push(body, next);
|
|
44
|
+
index++;
|
|
45
|
+
}
|
|
46
|
+
const [command = null, ...rest] = positionals;
|
|
47
|
+
return { command, positionals: rest, flags };
|
|
48
|
+
}
|
|
49
|
+
function assertFlagName(name, token) {
|
|
50
|
+
if (name.length === 0) {
|
|
51
|
+
throw usageError(`not a valid flag: ${token}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Reads a flag that must carry a string value. */
|
|
55
|
+
export function stringFlag(args, name) {
|
|
56
|
+
const values = args.flags.get(name);
|
|
57
|
+
if (values === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
const value = values[values.length - 1];
|
|
60
|
+
if (typeof value !== "string") {
|
|
61
|
+
throw usageError(`--${name} requires a value`);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
/** Every occurrence of a repeatable string flag (e.g. `--header`). */
|
|
66
|
+
export function stringFlags(args, name) {
|
|
67
|
+
const values = args.flags.get(name) ?? [];
|
|
68
|
+
return values.map((value) => {
|
|
69
|
+
if (typeof value !== "string") {
|
|
70
|
+
throw usageError(`--${name} requires a value`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function requiredStringFlag(args, name) {
|
|
76
|
+
const value = stringFlag(args, name);
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
throw usageError(`--${name} is required`);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
export function booleanFlag(args, name) {
|
|
83
|
+
const values = args.flags.get(name);
|
|
84
|
+
if (values === undefined)
|
|
85
|
+
return false;
|
|
86
|
+
const value = values[values.length - 1];
|
|
87
|
+
if (value === undefined)
|
|
88
|
+
return false;
|
|
89
|
+
if (typeof value === "boolean")
|
|
90
|
+
return value;
|
|
91
|
+
if (value === "true")
|
|
92
|
+
return true;
|
|
93
|
+
if (value === "false")
|
|
94
|
+
return false;
|
|
95
|
+
throw usageError(`--${name} takes no value (got "${value}")`);
|
|
96
|
+
}
|
|
97
|
+
export function integerFlag(args, name) {
|
|
98
|
+
const raw = stringFlag(args, name);
|
|
99
|
+
if (raw === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
if (!/^\d+$/.test(raw)) {
|
|
102
|
+
throw usageError(`--${name} must be a non-negative integer (got "${raw}")`);
|
|
103
|
+
}
|
|
104
|
+
return Number(raw);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Rejects flags the command does not understand. A silently ignored `--budgt`
|
|
108
|
+
* on a fund-moving command is how someone spends more than they meant to.
|
|
109
|
+
*/
|
|
110
|
+
export function assertKnownFlags(args, known) {
|
|
111
|
+
const allowed = new Set(known);
|
|
112
|
+
const unknown = [...args.flags.keys()].filter((name) => !allowed.has(name));
|
|
113
|
+
if (unknown.length > 0) {
|
|
114
|
+
throw usageError(`unknown flag${unknown.length > 1 ? "s" : ""}: ${unknown
|
|
115
|
+
.map((name) => `--${name}`)
|
|
116
|
+
.join(", ")}`, `known flags: ${known.map((name) => `--${name}`).join(", ")}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
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1B,IAAI,CAAC,IAAI,CAAC,EAAE,EACf,gBAAgB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CliReadClient } from "./deps.js";
|
|
2
|
+
/**
|
|
3
|
+
* Who attests, read off the escrow.
|
|
4
|
+
*
|
|
5
|
+
* Metrik's whole claim is that money moves only for delivery that a NEUTRAL
|
|
6
|
+
* verifier checked. On the live Base Sepolia deployment that neutrality is
|
|
7
|
+
* partial: `getOracleSigners()` returns three addresses, and one of them is the
|
|
8
|
+
* operator of the listings a buyer is being offered. A tool that prints
|
|
9
|
+
* "cryptographically verified" and "tier 2" without saying so is letting the
|
|
10
|
+
* buyer assume something the deployment does not provide.
|
|
11
|
+
*
|
|
12
|
+
* This is DISCLOSURE, not enforcement. The CLI does not refuse such a listing
|
|
13
|
+
* and does not score it — it states the fact and leaves the judgement to the
|
|
14
|
+
* buyer. Fixing the deployment is a deployment decision, not a CLI one.
|
|
15
|
+
*/
|
|
16
|
+
export interface AttesterSet {
|
|
17
|
+
/** The signer set, lowercased. `null` when the escrow would not answer. */
|
|
18
|
+
readonly signers: readonly string[] | null;
|
|
19
|
+
/** Why the set could not be read, when applicable. */
|
|
20
|
+
readonly unavailable: string | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read the signer set, failing SOFT.
|
|
24
|
+
*
|
|
25
|
+
* An unreadable set must never render as "no overlap": "we checked and the
|
|
26
|
+
* operator does not attest" and "we could not check" are different facts, and
|
|
27
|
+
* conflating them would turn an outage into a false assurance. `signers: null`
|
|
28
|
+
* is carried through to every caller and printed as UNKNOWN.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readAttesterSet(read: Pick<CliReadClient, "oracleSigners">): Promise<AttesterSet>;
|
|
31
|
+
/**
|
|
32
|
+
* Is this operator also one of the escrow's attesters?
|
|
33
|
+
*
|
|
34
|
+
* `null` means unknown (the set could not be read) and must be rendered as
|
|
35
|
+
* unknown, never as `false`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function operatorAttestsOwnDelivery(set: AttesterSet, operator: string): boolean | null;
|
|
38
|
+
/**
|
|
39
|
+
* One factual stderr line, or `null` when there is nothing to disclose.
|
|
40
|
+
*
|
|
41
|
+
* Deliberately not alarming and deliberately not a verdict: it reports a
|
|
42
|
+
* configuration fact and what that fact means, and stops there.
|
|
43
|
+
*/
|
|
44
|
+
export declare function attesterDisclosure(set: AttesterSet, operator: string): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The one warning that belongs to the ESCROW rather than to any one listing:
|
|
47
|
+
* the signer set could not be read at all. Printed once per command, not once
|
|
48
|
+
* per row, and never as "no overlap".
|
|
49
|
+
*/
|
|
50
|
+
export declare function attesterSetUnavailableWarning(set: AttesterSet): string | null;
|
|
51
|
+
//# sourceMappingURL=attesters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attesters.d.ts","sourceRoot":"","sources":["../../src/cli/attesters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,GACzC,OAAO,CAAC,WAAW,CAAC,CAUtB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,GAAG,IAAI,CAGhB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAMf;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAG7E"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describeError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read the signer set, failing SOFT.
|
|
4
|
+
*
|
|
5
|
+
* An unreadable set must never render as "no overlap": "we checked and the
|
|
6
|
+
* operator does not attest" and "we could not check" are different facts, and
|
|
7
|
+
* conflating them would turn an outage into a false assurance. `signers: null`
|
|
8
|
+
* is carried through to every caller and printed as UNKNOWN.
|
|
9
|
+
*/
|
|
10
|
+
export async function readAttesterSet(read) {
|
|
11
|
+
try {
|
|
12
|
+
const signers = await read.oracleSigners();
|
|
13
|
+
return {
|
|
14
|
+
signers: signers.map((signer) => signer.toLowerCase()),
|
|
15
|
+
unavailable: null,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return { signers: null, unavailable: describeError(error) };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Is this operator also one of the escrow's attesters?
|
|
24
|
+
*
|
|
25
|
+
* `null` means unknown (the set could not be read) and must be rendered as
|
|
26
|
+
* unknown, never as `false`.
|
|
27
|
+
*/
|
|
28
|
+
export function operatorAttestsOwnDelivery(set, operator) {
|
|
29
|
+
if (set.signers === null)
|
|
30
|
+
return null;
|
|
31
|
+
return set.signers.includes(operator.toLowerCase());
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* One factual stderr line, or `null` when there is nothing to disclose.
|
|
35
|
+
*
|
|
36
|
+
* Deliberately not alarming and deliberately not a verdict: it reports a
|
|
37
|
+
* configuration fact and what that fact means, and stops there.
|
|
38
|
+
*/
|
|
39
|
+
export function attesterDisclosure(set, operator) {
|
|
40
|
+
const overlap = operatorAttestsOwnDelivery(set, operator);
|
|
41
|
+
if (overlap === null)
|
|
42
|
+
return attesterSetUnavailableWarning(set);
|
|
43
|
+
if (!overlap)
|
|
44
|
+
return null;
|
|
45
|
+
const total = set.signers?.length ?? 0;
|
|
46
|
+
return `warning: operator ${operator} is also one of the ${total} oracle signer${total === 1 ? "" : "s"} configured on this escrow. The party being paid is among the parties attesting that delivery happened. Verification here is not independent of the seller.`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The one warning that belongs to the ESCROW rather than to any one listing:
|
|
50
|
+
* the signer set could not be read at all. Printed once per command, not once
|
|
51
|
+
* per row, and never as "no overlap".
|
|
52
|
+
*/
|
|
53
|
+
export function attesterSetUnavailableWarning(set) {
|
|
54
|
+
if (set.signers !== null)
|
|
55
|
+
return null;
|
|
56
|
+
return `warning: the escrow's oracle signer set could not be read (${set.unavailable ?? "no reason given"}) — whether the operator being paid is also one of the parties attesting to its own delivery is UNKNOWN, not "no overlap".`;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=attesters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attesters.js","sourceRoot":"","sources":["../../src/cli/attesters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwB5C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAA0C;IAE1C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3C,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACtD,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAgB,EAChB,QAAgB;IAEhB,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAgB,EAChB,QAAgB;IAEhB,MAAM,OAAO,GAAG,0BAA0B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,6BAA6B,CAAC,GAAG,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC;IACvC,OAAO,qBAAqB,QAAQ,uBAAuB,KAAK,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,6JAA6J,CAAC;AACvQ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAAC,GAAgB;IAC5D,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,8DAA8D,GAAG,CAAC,WAAW,IAAI,iBAAiB,4HAA4H,CAAC;AACxO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":""}
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/D,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommandSpec } from "../context.js";
|
|
2
|
+
/**
|
|
3
|
+
* The seller's side of the loop.
|
|
4
|
+
*
|
|
5
|
+
* `status` has always computed and printed an `operator claimable` row — a
|
|
6
|
+
* redeemable balance the CLI could see and could not act on. `claimWithProof` is
|
|
7
|
+
* operator-gated on-chain, so this command refuses a wallet that is not the
|
|
8
|
+
* stream's operator BEFORE it broadcasts: an address mismatch is knowable with
|
|
9
|
+
* one read, and letting it become a raw `NotOperator()` revert would cost gas to
|
|
10
|
+
* learn a fact that was already available.
|
|
11
|
+
*/
|
|
12
|
+
export declare const claimCommand: CommandSpec;
|
|
13
|
+
//# sourceMappingURL=claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/claim.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,WAsG1B,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { formatUsdc } from "../amounts.js";
|
|
2
|
+
import { assertTestnetRpc, parseBytes32 } from "../config.js";
|
|
3
|
+
import { CliError, describeError, usageError } from "../errors.js";
|
|
4
|
+
import { signClaimMandate } from "../mandate.js";
|
|
5
|
+
import { assertCanPayGas } from "../preflight.js";
|
|
6
|
+
import { writeClientOptions } from "../deps.js";
|
|
7
|
+
import { isPolicyEnforced, PRIVATE_KEY_ENV, resolveCliWallet, } from "../wallet.js";
|
|
8
|
+
/**
|
|
9
|
+
* The seller's side of the loop.
|
|
10
|
+
*
|
|
11
|
+
* `status` has always computed and printed an `operator claimable` row — a
|
|
12
|
+
* redeemable balance the CLI could see and could not act on. `claimWithProof` is
|
|
13
|
+
* operator-gated on-chain, so this command refuses a wallet that is not the
|
|
14
|
+
* stream's operator BEFORE it broadcasts: an address mismatch is knowable with
|
|
15
|
+
* one read, and letting it become a raw `NotOperator()` revert would cost gas to
|
|
16
|
+
* learn a fact that was already available.
|
|
17
|
+
*/
|
|
18
|
+
export const claimCommand = {
|
|
19
|
+
name: "claim",
|
|
20
|
+
summary: "Operator: redeem what this stream has verifiably earned",
|
|
21
|
+
usage: "metrik claim <streamId>",
|
|
22
|
+
flags: [],
|
|
23
|
+
signs: true,
|
|
24
|
+
async run(context) {
|
|
25
|
+
const { args, config, env, out, deps } = context;
|
|
26
|
+
const [streamIdArg] = args.positionals;
|
|
27
|
+
if (streamIdArg === undefined) {
|
|
28
|
+
throw usageError("metrik claim requires a <streamId>");
|
|
29
|
+
}
|
|
30
|
+
const streamId = parseBytes32(streamIdArg, "<streamId>");
|
|
31
|
+
const wallet = await resolveCliWallet(env, {
|
|
32
|
+
note: out.note,
|
|
33
|
+
rpcUrl: config.rpcUrl,
|
|
34
|
+
});
|
|
35
|
+
const { account } = wallet;
|
|
36
|
+
if (isPolicyEnforced(wallet)) {
|
|
37
|
+
// Said plainly rather than discovered mid-command. `claim` is the
|
|
38
|
+
// OPERATOR's side, and a Privy broker policy allowlists the BUYER
|
|
39
|
+
// actions only (openStream, close, reclaim, reclaimUnverified, and a
|
|
40
|
+
// bounded USDC approval). That is a property of an operator using a
|
|
41
|
+
// buyer-scoped wallet, not a defect in this command.
|
|
42
|
+
out.note("warning: this wallet's broker policy allowlists buyer actions only, so it will refuse to sign an operator claim. Claim with the operator's own key.");
|
|
43
|
+
}
|
|
44
|
+
const read = deps.createReadClient(config);
|
|
45
|
+
await assertTestnetRpc(config, () => read.getChainId());
|
|
46
|
+
await assertCanPayGas(read, account.address);
|
|
47
|
+
const stream = await read.getStreamV2(streamId);
|
|
48
|
+
if (stream.operator.toLowerCase() !== account.address.toLowerCase()) {
|
|
49
|
+
throw new CliError(`wallet ${account.address} is not the operator of this stream`, {
|
|
50
|
+
exitCode: 3,
|
|
51
|
+
hint: `only ${stream.operator} can claim it — the escrow enforces this, so no other wallet can. Set ${PRIVATE_KEY_ENV} to the operator's key. (The buyer's side of this stream is \`metrik reclaim ${streamId}\`.)`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// Accrual lives in the oracle's checkpoint proof, never in the stream tuple.
|
|
55
|
+
// No proof means no claim is possible yet, and saying that is better than
|
|
56
|
+
// paying gas for a `NothingToClaim()` revert.
|
|
57
|
+
let cumulativeAmount;
|
|
58
|
+
try {
|
|
59
|
+
cumulativeAmount = (await read.checkpointProof(streamId))
|
|
60
|
+
.cumulativeAmount;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
throw new CliError("no checkpoint covers this stream yet, so there is nothing provable to claim", {
|
|
64
|
+
exitCode: 4,
|
|
65
|
+
hint: `the oracle publishes roughly every 15-22s and pays only for intervals that verified; ${describeError(error)}`,
|
|
66
|
+
cause: error,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const claimable = await read.claimableForV2(streamId, cumulativeAmount);
|
|
70
|
+
if (claimable === 0n) {
|
|
71
|
+
throw new CliError("this stream has nothing claimable right now", {
|
|
72
|
+
exitCode: 4,
|
|
73
|
+
hint: `everything checkpointed so far has already been claimed. See where it stands: metrik status ${streamId}`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const write = deps.createWriteClient(config, account, writeClientOptions(wallet));
|
|
77
|
+
const result = await write.claimStream({
|
|
78
|
+
streamId,
|
|
79
|
+
// `null` for a policy-enforced wallet — see `../spend-policy.ts`.
|
|
80
|
+
signedMandate: isPolicyEnforced(wallet)
|
|
81
|
+
? null
|
|
82
|
+
: await signClaimMandate(account, config.chainId),
|
|
83
|
+
spentSoFarUsdc: 0n,
|
|
84
|
+
nowSeconds: deps.nowSeconds(),
|
|
85
|
+
});
|
|
86
|
+
out.result({
|
|
87
|
+
streamId,
|
|
88
|
+
txHash: result.txHash,
|
|
89
|
+
operator: stream.operator,
|
|
90
|
+
claimed: claimable,
|
|
91
|
+
verifiedCumulative: cumulativeAmount,
|
|
92
|
+
});
|
|
93
|
+
out.print("Claimed.");
|
|
94
|
+
out.table([
|
|
95
|
+
["streamId", streamId],
|
|
96
|
+
["tx", result.txHash],
|
|
97
|
+
["operator", stream.operator],
|
|
98
|
+
["claimed", `${formatUsdc(claimable)} (net of protocol fee)`],
|
|
99
|
+
]);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../../src/cli/commands/claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,yDAAyD;IAClE,KAAK,EAAE,yBAAyB;IAChC,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,IAAI;IACX,KAAK,CAAC,GAAG,CA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Q;YACR,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,SAAS;YAClB,kBAAkB,EAAE,gBAAgB;SACrC,CAAC,CAAC;QACH,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACtB,GAAG,CAAC,KAAK,CAAC;YACR,CAAC,UAAU,EAAE,QAAQ,CAAC;YACtB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;YACrB,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC;YAC7B,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC,wBAAwB,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/close.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,YAAY,EAAE,WA4D1B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { assertTestnetRpc, parseBytes32 } from "../config.js";
|
|
2
|
+
import { usageError } from "../errors.js";
|
|
3
|
+
import { signRecoveryMandate } from "../mandate.js";
|
|
4
|
+
import { assertCanPayGas } from "../preflight.js";
|
|
5
|
+
import { writeClientOptions } from "../deps.js";
|
|
6
|
+
import { isPolicyEnforced, resolveCliWallet } from "../wallet.js";
|
|
7
|
+
export const closeCommand = {
|
|
8
|
+
name: "close",
|
|
9
|
+
summary: "Stop the clock on a stream so the unspent budget can be reclaimed",
|
|
10
|
+
usage: "metrik close <streamId>",
|
|
11
|
+
flags: [],
|
|
12
|
+
signs: true,
|
|
13
|
+
async run(context) {
|
|
14
|
+
const { args, config, env, out, deps } = context;
|
|
15
|
+
const [streamIdArg] = args.positionals;
|
|
16
|
+
if (streamIdArg === undefined) {
|
|
17
|
+
throw usageError("metrik close requires a <streamId>");
|
|
18
|
+
}
|
|
19
|
+
const streamId = parseBytes32(streamIdArg, "<streamId>");
|
|
20
|
+
const wallet = await resolveCliWallet(env, {
|
|
21
|
+
note: out.note,
|
|
22
|
+
rpcUrl: config.rpcUrl,
|
|
23
|
+
});
|
|
24
|
+
const { account } = wallet;
|
|
25
|
+
const read = deps.createReadClient(config);
|
|
26
|
+
await assertTestnetRpc(config, () => read.getChainId());
|
|
27
|
+
await assertCanPayGas(read, account.address);
|
|
28
|
+
// A policy-enforced wallet signs no mandate of its own: this is a
|
|
29
|
+
// buyer-recovery action, the escrow gates it on the buyer address and the
|
|
30
|
+
// broker gates it again on `stream.buyer == wallet`. A locally self-signed
|
|
31
|
+
// placeholder would add nothing and the broker would refuse to sign it.
|
|
32
|
+
// See `../spend-policy.ts`.
|
|
33
|
+
const signedMandate = isPolicyEnforced(wallet)
|
|
34
|
+
? null
|
|
35
|
+
: await signRecoveryMandate(account, config.chainId);
|
|
36
|
+
const write = deps.createWriteClient(config, account, writeClientOptions(wallet));
|
|
37
|
+
const result = await write.closeStream({
|
|
38
|
+
streamId,
|
|
39
|
+
signedMandate,
|
|
40
|
+
spentSoFarUsdc: 0n,
|
|
41
|
+
nowSeconds: deps.nowSeconds(),
|
|
42
|
+
});
|
|
43
|
+
out.result({ streamId, txHash: result.txHash, closed: true });
|
|
44
|
+
out.print("Stream closed.");
|
|
45
|
+
out.table([
|
|
46
|
+
["streamId", streamId],
|
|
47
|
+
["tx", result.txHash],
|
|
48
|
+
]);
|
|
49
|
+
out.print("");
|
|
50
|
+
out.print(`Nothing pushes money back. Reclaim what was never earned: metrik reclaim ${streamId}`);
|
|
51
|
+
out.print("That reclaim reverts until the oracle publishes a checkpoint covering the stop time, so it waits and retries for you — leave it running.");
|
|
52
|
+
out.print(`Next time: metrik reclaim <streamId> --close-first does this close and that reclaim in one command.`);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=close.js.map
|
|
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