@temporalabs/treasury 0.1.0 → 0.1.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.
Files changed (75) hide show
  1. package/NOTICE +4 -2
  2. package/README.md +108 -111
  3. package/THIRD_PARTY_NOTICES.connect-page.md +7420 -0
  4. package/THIRD_PARTY_NOTICES.md +4 -196
  5. package/dist/cli.d.ts +6 -0
  6. package/dist/cli.js +220 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client.d.ts +224 -239
  9. package/dist/client.js +147 -25
  10. package/dist/client.js.map +1 -1
  11. package/dist/config/earn.d.ts +33 -12
  12. package/dist/config/earn.js +33 -12
  13. package/dist/config/earn.js.map +1 -1
  14. package/dist/connect/ack.d.ts +59 -0
  15. package/dist/connect/ack.js +111 -0
  16. package/dist/connect/ack.js.map +1 -0
  17. package/dist/connect/commands.d.ts +78 -0
  18. package/dist/connect/commands.js +411 -0
  19. package/dist/connect/commands.js.map +1 -0
  20. package/dist/connect/config.d.ts +22 -0
  21. package/dist/connect/config.js +33 -0
  22. package/dist/connect/config.js.map +1 -0
  23. package/dist/connect/gate.d.ts +37 -0
  24. package/dist/connect/gate.js +115 -0
  25. package/dist/connect/gate.js.map +1 -0
  26. package/dist/connect/http.d.ts +54 -0
  27. package/dist/connect/http.js +205 -0
  28. package/dist/connect/http.js.map +1 -0
  29. package/dist/connect/open.d.ts +2 -0
  30. package/dist/connect/open.js +35 -0
  31. package/dist/connect/open.js.map +1 -0
  32. package/dist/connect/page.d.ts +5 -0
  33. package/dist/connect/page.js +69 -0
  34. package/dist/connect/page.js.map +1 -0
  35. package/dist/connect/session.d.ts +16 -0
  36. package/dist/connect/session.js +73 -0
  37. package/dist/connect/session.js.map +1 -0
  38. package/dist/connect/verify.d.ts +37 -0
  39. package/dist/connect/verify.js +89 -0
  40. package/dist/connect/verify.js.map +1 -0
  41. package/dist/connect-page.js +5141 -0
  42. package/dist/disclosures.d.ts +21 -6
  43. package/dist/disclosures.js +32 -7
  44. package/dist/disclosures.js.map +1 -1
  45. package/dist/earn/commands.d.ts +46 -0
  46. package/dist/earn/commands.js +483 -0
  47. package/dist/earn/commands.js.map +1 -0
  48. package/dist/links.d.ts +2 -0
  49. package/dist/links.js +38 -14
  50. package/dist/links.js.map +1 -1
  51. package/dist/position.d.ts +7 -5
  52. package/dist/position.js +35 -18
  53. package/dist/position.js.map +1 -1
  54. package/dist/preflight.d.ts +9 -0
  55. package/dist/preflight.js +14 -3
  56. package/dist/preflight.js.map +1 -1
  57. package/dist/quote.js +24 -7
  58. package/dist/quote.js.map +1 -1
  59. package/dist/redact.d.ts +3 -3
  60. package/dist/redact.js +3 -3
  61. package/dist/redact.js.map +1 -1
  62. package/dist/registry-schema.d.ts +5 -5
  63. package/dist/registry-schema.js +30 -16
  64. package/dist/registry-schema.js.map +1 -1
  65. package/dist/registry.d.ts +29 -6
  66. package/dist/registry.js +80 -16
  67. package/dist/registry.js.map +1 -1
  68. package/dist/{mcp-server.mjs → treasury.mjs} +29289 -44702
  69. package/dist/version.js +6 -3
  70. package/dist/version.js.map +1 -1
  71. package/package.json +9 -7
  72. package/registry/vaults.json +105 -4
  73. package/dist/mcp/server.d.ts +0 -33
  74. package/dist/mcp/server.js +0 -346
  75. package/dist/mcp/server.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/mcp-server.mjs` is a single file that includes the third-party components below. Each
3
+ `dist/treasury.mjs` is a single file that includes the third-party components below. Each
4
4
  component remains under its own licence, reproduced here in full for the exact version included.
5
- Tempora Labs' Apache License 2.0 (`LICENSE`) applies to Tempora's own code, not to these
5
+ Tempora Labs' Apache License 2.0 (`LICENSE`) applies to Tempora Labs' own code, not to these
6
6
  components.
7
7
 
8
8
  This file is generated by `scripts/third-party-notices.ts` from the bundle itself. Do not edit it
@@ -10,45 +10,12 @@ by hand.
10
10
 
11
11
  | Component | Version | Licence |
12
12
  |---|---|---|
13
- | `@modelcontextprotocol/sdk` | 1.30.0 | MIT |
14
13
  | `@noble/curves` | 1.9.1 | MIT |
15
14
  | `@noble/hashes` | 1.8.0 | MIT |
16
15
  | `abitype` | 1.2.3 | MIT |
17
- | `ajv` | 8.20.0 | MIT |
18
- | `ajv-formats` | 3.0.1 | MIT |
19
- | `fast-deep-equal` | 3.1.3 | MIT |
20
- | `fast-uri` | 3.1.8 | BSD-3-Clause |
21
- | `json-schema-traverse` | 1.0.0 | MIT |
22
16
  | `ox` | 0.14.45 | MIT |
23
- | `viem` | 2.56.7 | MIT |
17
+ | `viem` | 2.57.2 | MIT |
24
18
  | `zod` | 4.6.5 | MIT |
25
- | `zod-to-json-schema` | 3.25.2 | ISC |
26
-
27
- ## @modelcontextprotocol/sdk 1.30.0 (MIT)
28
-
29
- ```text
30
- MIT License
31
-
32
- Copyright (c) 2024 Anthropic, PBC
33
-
34
- Permission is hereby granted, free of charge, to any person obtaining a copy
35
- of this software and associated documentation files (the "Software"), to deal
36
- in the Software without restriction, including without limitation the rights
37
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38
- copies of the Software, and to permit persons to whom the Software is
39
- furnished to do so, subject to the following conditions:
40
-
41
- The above copyright notice and this permission notice shall be included in all
42
- copies or substantial portions of the Software.
43
-
44
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50
- SOFTWARE.
51
- ```
52
19
 
53
20
  ## @noble/curves 1.9.1 (MIT)
54
21
 
@@ -128,145 +95,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
128
95
  SOFTWARE.
129
96
  ```
130
97
 
131
- ## ajv 8.20.0 (MIT)
132
-
133
- ```text
134
- The MIT License (MIT)
135
-
136
- Copyright (c) 2015-2021 Evgeny Poberezkin
137
-
138
- Permission is hereby granted, free of charge, to any person obtaining a copy
139
- of this software and associated documentation files (the "Software"), to deal
140
- in the Software without restriction, including without limitation the rights
141
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
142
- copies of the Software, and to permit persons to whom the Software is
143
- furnished to do so, subject to the following conditions:
144
-
145
- The above copyright notice and this permission notice shall be included in all
146
- copies or substantial portions of the Software.
147
-
148
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
149
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
150
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
151
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
152
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
153
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
154
- SOFTWARE.
155
- ```
156
-
157
- ## ajv-formats 3.0.1 (MIT)
158
-
159
- ```text
160
- MIT License
161
-
162
- Copyright (c) 2020 Evgeny Poberezkin
163
-
164
- Permission is hereby granted, free of charge, to any person obtaining a copy
165
- of this software and associated documentation files (the "Software"), to deal
166
- in the Software without restriction, including without limitation the rights
167
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
168
- copies of the Software, and to permit persons to whom the Software is
169
- furnished to do so, subject to the following conditions:
170
-
171
- The above copyright notice and this permission notice shall be included in all
172
- copies or substantial portions of the Software.
173
-
174
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
176
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
177
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
178
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
179
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
180
- SOFTWARE.
181
- ```
182
-
183
- ## fast-deep-equal 3.1.3 (MIT)
184
-
185
- ```text
186
- MIT License
187
-
188
- Copyright (c) 2017 Evgeny Poberezkin
189
-
190
- Permission is hereby granted, free of charge, to any person obtaining a copy
191
- of this software and associated documentation files (the "Software"), to deal
192
- in the Software without restriction, including without limitation the rights
193
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
194
- copies of the Software, and to permit persons to whom the Software is
195
- furnished to do so, subject to the following conditions:
196
-
197
- The above copyright notice and this permission notice shall be included in all
198
- copies or substantial portions of the Software.
199
-
200
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
201
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
202
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
203
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
204
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
205
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
206
- SOFTWARE.
207
- ```
208
-
209
- ## fast-uri 3.1.8 (BSD-3-Clause)
210
-
211
- ```text
212
- Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
213
- Copyright (c) 2021-present The Fastify team <https://github.com/fastify/fastify#team>
214
- All rights reserved.
215
-
216
- Redistribution and use in source and binary forms, with or without
217
- modification, are permitted provided that the following conditions are met:
218
- * Redistributions of source code must retain the above copyright
219
- notice, this list of conditions and the following disclaimer.
220
- * Redistributions in binary form must reproduce the above copyright
221
- notice, this list of conditions and the following disclaimer in the
222
- documentation and/or other materials provided with the distribution.
223
- * The names of any contributors may not be used to endorse or promote
224
- products derived from this software without specific prior written
225
- permission.
226
-
227
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
228
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
229
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
230
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
231
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
232
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
233
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
234
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
235
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
236
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
237
-
238
- * * *
239
-
240
- The complete list of contributors can be found at:
241
- - https://github.com/garycourt/uri-js/graphs/contributors
242
- ```
243
-
244
- ## json-schema-traverse 1.0.0 (MIT)
245
-
246
- ```text
247
- MIT License
248
-
249
- Copyright (c) 2017 Evgeny Poberezkin
250
-
251
- Permission is hereby granted, free of charge, to any person obtaining a copy
252
- of this software and associated documentation files (the "Software"), to deal
253
- in the Software without restriction, including without limitation the rights
254
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
255
- copies of the Software, and to permit persons to whom the Software is
256
- furnished to do so, subject to the following conditions:
257
-
258
- The above copyright notice and this permission notice shall be included in all
259
- copies or substantial portions of the Software.
260
-
261
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
262
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
263
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
264
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
265
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
266
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
267
- SOFTWARE.
268
- ```
269
-
270
98
  ## ox 0.14.45 (MIT)
271
99
 
272
100
  ```text
@@ -293,7 +121,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
293
121
  SOFTWARE.
294
122
  ```
295
123
 
296
- ## viem 2.56.7 (MIT)
124
+ ## viem 2.57.2 (MIT)
297
125
 
298
126
  ```text
299
127
  MIT License
@@ -344,23 +172,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
344
172
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
345
173
  SOFTWARE.
346
174
  ```
347
-
348
- ## zod-to-json-schema 3.25.2 (ISC)
349
-
350
- ```text
351
- ISC License
352
-
353
- Copyright (c) 2020, Stefan Terdell
354
-
355
- Permission to use, copy, modify, and/or distribute this software for any
356
- purpose with or without fee is hereby granted, provided that the above
357
- copyright notice and this permission notice appear in all copies.
358
-
359
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
360
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
361
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
362
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
363
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
364
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
365
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
366
- ```
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /** Runs one invocation. Returns what to print and the exit status; never calls `process.exit` itself, so tests can drive it. */
2
+ export declare function run(argv: string[]): Promise<{
3
+ stdout?: string;
4
+ stderr?: string;
5
+ code: 0 | 1;
6
+ }>;
package/dist/cli.js ADDED
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Agent Treasury — the command line. `treasury <earn|connect> <command> [--flag value …]`; every command prints
3
+ * one JSON document on stdout (`--version` prints the bare version).
4
+ *
5
+ * Headless on purpose: an agent with a shell runs this with `node` and reads the JSON, and nothing
6
+ * stays running between calls. The commands themselves live in `earn/commands.ts` and `connect/commands.ts`; this file only
7
+ * turns argv into their arguments, validates them against each command's own schema, and prints.
8
+ *
9
+ * treasury earn --help every command, its flags and its description, as JSON
10
+ * treasury earn quote --direction deposit --account 0x… --amount_usdc 25 --chain base
11
+ * treasury --version
12
+ *
13
+ * Flags are the command's argument names. `--amount-usdc` is accepted for `--amount_usdc`, and
14
+ * `prepare-deposit` for `prepare_deposit`, because both spellings get typed.
15
+ *
16
+ * Exit status: 0 with the result on stdout; 1 with `{ "error": … }` on stderr when the command could not
17
+ * run as asked (a vault on another chain, an unknown or repeated flag, a malformed address, an
18
+ * unreachable RPC on a read that needs it) — never a result, so a caller cannot read it as an answer. A
19
+ * VERDICT is a result: `earn status` reporting `WHITELIST_GATED` or `rpc: "wrong_chain"` exits 0, and
20
+ * its fields say what it found. A switch (`--all`) takes no value.
21
+ */
22
+ import { realpathSync } from "node:fs";
23
+ import { fileURLToPath } from "node:url";
24
+ import { parseArgs } from "node:util";
25
+ import { z } from "zod";
26
+ import { buildCommands } from "./earn/commands.js";
27
+ import { buildConnectCommands } from "./connect/commands.js";
28
+ import { resolvedRpcSecrets } from "./client.js";
29
+ import { redactEndpoints, registerSecretSource } from "./redact.js";
30
+ import { PACKAGE_VERSION } from "./version.js";
31
+ /**
32
+ * The skills this CLI carries: a word on the command line, and the commands it opens. A command's name
33
+ * starts with its skill's word (`earn_quote`), and only that skill's builder is ever consulted for it.
34
+ */
35
+ const SKILLS = { earn: buildCommands, connect: () => buildConnectCommands() };
36
+ /** The JSON type a flag's schema finally checks, looking through `optional`, `default` and refine/transform pipes. */
37
+ function kindOf(schema) {
38
+ let s = schema;
39
+ for (;;) {
40
+ const def = s.def;
41
+ if ((def.type === "optional" || def.type === "default" || def.type === "nullable") && def.innerType)
42
+ s = def.innerType;
43
+ else if (def.type === "pipe" && def.in)
44
+ s = def.in;
45
+ else
46
+ return def.type === "number" ? "number" : def.type === "boolean" ? "boolean" : "string";
47
+ }
48
+ }
49
+ const isOptional = (schema) => schema.safeParse(undefined).success;
50
+ /** The constraints `--help` repeats from each flag's JSON Schema, so a caller sees what the schema will refuse. */
51
+ const SCHEMA_KEYS = ["description", "enum", "pattern", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum"];
52
+ /** What `--help` prints for one command. */
53
+ function describe(skill, name, c) {
54
+ // The JSON Schema carries what the zod objects hide behind wrappers: a description set before
55
+ // `.optional()`, an enum, a pattern, a range. Read in INPUT mode, so a transform describes what it accepts.
56
+ // `unrepresentable: "any"`: a type JSON Schema cannot express must not take `--help` down with it.
57
+ const props = (z.toJSONSchema(c.inputSchema, { io: "input", unrepresentable: "any" }).properties ?? {});
58
+ return {
59
+ command: `${skill} ${name.slice(skill.length + 1)}`,
60
+ tool: name,
61
+ title: c.title,
62
+ description: c.description,
63
+ flags: Object.entries(c.inputSchema.shape).map(([flag, schema]) => {
64
+ const kind = kindOf(schema);
65
+ const js = props[flag] ?? {};
66
+ return {
67
+ flag: `--${flag}`,
68
+ type: kind,
69
+ required: !isOptional(schema),
70
+ ...(kind === "boolean" ? { takesValue: false } : {}),
71
+ ...Object.fromEntries(SCHEMA_KEYS.filter((k) => js[k] !== undefined).map((k) => [k, js[k]])),
72
+ };
73
+ }),
74
+ };
75
+ }
76
+ class UsageError extends Error {
77
+ }
78
+ /** argv after the command word → the command's arguments, checked against its own schema. */
79
+ function parseFlags(c, argv) {
80
+ const shape = c.inputSchema.shape;
81
+ const options = {};
82
+ const canonical = {};
83
+ for (const [name, schema] of Object.entries(shape)) {
84
+ const type = kindOf(schema) === "boolean" ? "boolean" : "string";
85
+ for (const spelling of new Set([name, name.replaceAll("_", "-")])) {
86
+ options[spelling] = { type };
87
+ canonical[spelling] = name;
88
+ }
89
+ }
90
+ const switches = Object.keys(shape).filter((n) => kindOf(shape[n]) === "boolean");
91
+ let parsed;
92
+ try {
93
+ parsed = parseArgs({ args: argv, options, strict: true, allowPositionals: false, tokens: true });
94
+ }
95
+ catch (e) {
96
+ const why = (e instanceof Error ? e.message : String(e)).replace(/\.+$/, "");
97
+ const hint = switches.length ? ` ${switches.map((n) => `--${n}`).join(", ")} ${switches.length === 1 ? "is a switch" : "are switches"}: give it for true, leave it out for false.` : "";
98
+ const help = argv.includes("--help") || argv.includes("-h") ? " For help, put --help right after the command." : "";
99
+ throw new UsageError(`${why}. Flags for this command: ${Object.keys(shape).map((f) => `--${f}`).join(", ") || "none"}.${hint}${help}`);
100
+ }
101
+ // 🔴 Repeats are read from the TOKENS, not from `values`. `parseArgs` keeps only the LAST value of a
102
+ // repeated option and keys `values` by spelling, so `--receiver A --receiver B` would otherwise
103
+ // arrive as `receiver: B` with nothing to say A was ever typed — a different call than the one read.
104
+ const seen = new Set();
105
+ for (const t of parsed.tokens ?? []) {
106
+ if (t.kind !== "option")
107
+ continue;
108
+ const name = canonical[t.name];
109
+ if (seen.has(name))
110
+ throw new UsageError(`--${name} was given twice`);
111
+ seen.add(name);
112
+ }
113
+ const args = {};
114
+ for (const [spelling, raw] of Object.entries(parsed.values)) {
115
+ if (raw === undefined)
116
+ continue;
117
+ const name = canonical[spelling];
118
+ const kind = kindOf(shape[name]);
119
+ if (kind === "number") {
120
+ if (typeof raw !== "string" || !/^\d+$/.test(raw))
121
+ throw new UsageError(`--${name} takes a whole number, got ${JSON.stringify(raw)}`);
122
+ args[name] = Number(raw);
123
+ }
124
+ else {
125
+ args[name] = raw;
126
+ }
127
+ }
128
+ const checked = c.inputSchema.strict().safeParse(args);
129
+ if (!checked.success) {
130
+ throw new UsageError(checked.error.issues.map((i) => `--${i.path.join(".") || "?"}: ${i.message}`).join("; "));
131
+ }
132
+ return checked.data;
133
+ }
134
+ /** Runs one invocation. Returns what to print and the exit status; never calls `process.exit` itself, so tests can drive it. */
135
+ export async function run(argv) {
136
+ // Registered before anything can be printed: a usage error echoes what was typed, and what was typed
137
+ // can be a keyed RPC URL. Every error below goes through `redactEndpoints`, so none can print it.
138
+ registerSecretSource(resolvedRpcSecrets);
139
+ const fail = (message) => ({ stderr: JSON.stringify({ error: redactEndpoints(message) }, null, 2), code: 1 });
140
+ const [first, second, ...rest] = argv;
141
+ if (first === "--version" || first === "-v")
142
+ return { stdout: PACKAGE_VERSION, code: 0 };
143
+ if (first === undefined || first === "--help" || first === "-h") {
144
+ return { stdout: JSON.stringify({ usage: "treasury <skill> <command> [--flag value …]", version: PACKAGE_VERSION, skills: Object.keys(SKILLS) }, null, 2), code: 0 };
145
+ }
146
+ const build = Object.hasOwn(SKILLS, first) ? SKILLS[first] : undefined;
147
+ if (!build)
148
+ return fail(`unknown skill ${JSON.stringify(first)}; this CLI carries: ${Object.keys(SKILLS).join(", ")}`);
149
+ const skill = first;
150
+ let commands;
151
+ try {
152
+ commands = build();
153
+ }
154
+ catch (e) {
155
+ return fail(e instanceof Error ? e.message : String(e));
156
+ }
157
+ const mine = Object.entries(commands).filter(([name]) => name.startsWith(`${skill}_`));
158
+ if (second === undefined || second === "--help" || second === "-h") {
159
+ return { stdout: JSON.stringify({ usage: `treasury ${skill} <command> [--flag value …]`, version: PACKAGE_VERSION, commands: mine.map(([n, c]) => describe(skill, n, c)) }, null, 2), code: 0 };
160
+ }
161
+ const name = `${skill}_${second.replaceAll("-", "_")}`;
162
+ // Own keys only: `commands` is a plain object, so `earn constructor` must not reach anything inherited.
163
+ const command = Object.hasOwn(commands, name) ? commands[name] : undefined;
164
+ if (!command) {
165
+ return fail(`unknown command ${JSON.stringify(`${skill} ${second}`)}; commands: ${mine.map(([n]) => n.slice(skill.length + 1)).join(", ")}`);
166
+ }
167
+ // Help only when asked for in place of the flags — `--receiver --help` is a missing value, not a request for help.
168
+ if (rest[0] === "--help" || rest[0] === "-h")
169
+ return { stdout: JSON.stringify(describe(skill, name, command), null, 2), code: 0 };
170
+ let args;
171
+ try {
172
+ args = parseFlags(command, rest);
173
+ }
174
+ catch (e) {
175
+ return fail(e instanceof Error ? e.message : String(e));
176
+ }
177
+ try {
178
+ return { stdout: await command.handler(args), code: 0 };
179
+ }
180
+ catch (e) {
181
+ // The handlers already mask endpoints (`guarded`); `fail` masks again so nothing printed by this
182
+ // file can carry a keyed RPC URL, whatever a future handler forgets.
183
+ return fail(e instanceof Error ? e.message : String(e));
184
+ }
185
+ }
186
+ /**
187
+ * True only when THIS module is the file Node was asked to run. The comparison is by resolved path,
188
+ * not by name: an earlier guard tested `process.argv[1]` against a filename pattern, which is the
189
+ * basename of whatever was invoked — so the published bin (a symlink npm makes) never matched and
190
+ * exited silently (#22), while any unrelated script with a matching name that merely imported this
191
+ * module matched and ran. Node resolves the main module's symlink before evaluating it, so
192
+ * `import.meta.url` is already the real path and the two sides agree for a bin. Anything
193
+ * unresolvable is treated as "not the entry point": the module loads and does nothing.
194
+ */
195
+ function isEntryPoint() {
196
+ const invoked = process.argv[1];
197
+ if (!invoked)
198
+ return false;
199
+ try {
200
+ return realpathSync(invoked) === realpathSync(fileURLToPath(import.meta.url));
201
+ }
202
+ catch {
203
+ return false;
204
+ }
205
+ }
206
+ if (isEntryPoint()) {
207
+ run(process.argv.slice(2)).then(({ stdout, stderr, code }) => {
208
+ // Exit as soon as the answer is written. A read that lost a race (the chain-id probe beside a
209
+ // slow endpoint) can leave a request timer running for seconds after the answer exists, and
210
+ // the agent's shell call would wait it out. The callbacks wait for each stream to flush first.
211
+ const out = stdout === undefined ? Promise.resolve() : new Promise((done) => process.stdout.write(`${stdout}\n`, () => done()));
212
+ const err = stderr === undefined ? Promise.resolve() : new Promise((done) => process.stderr.write(`${stderr}\n`, () => done()));
213
+ void Promise.all([out, err]).then(() => process.exit(code));
214
+ }, (e) => {
215
+ // Defence-in-depth: `run` catches everything it calls, so this is reached only by a defect in
216
+ // `run` itself. Masked anyway, so that stays true if `run` ever grows.
217
+ process.stderr.write(`${JSON.stringify({ error: redactEndpoints(String(e)) })}\n`, () => process.exit(1));
218
+ });
219
+ }
220
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAgB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OA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