@oneie/cli 5.8.0 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/package.json +7 -8
  2. package/dist/src/age-yefbe8pe.js +1 -0
  3. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  4. package/dist/src/hl-run-tgrkrk69.js +1 -0
  5. package/dist/src/index-0rj9wdk9.js +4 -0
  6. package/dist/src/index-91y484c2.js +2052 -0
  7. package/dist/src/index-940y3rnv.js +12 -0
  8. package/dist/src/index.js +1047 -134
  9. package/dist/src/message-key-db1xjdkw.js +1 -0
  10. package/dist/src/message-lock-5vr8079x.js +5 -0
  11. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  12. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  13. package/package.json +7 -8
  14. package/dist/src/agent.d.ts +0 -75
  15. package/dist/src/agent.js +0 -1334
  16. package/dist/src/agentverse.d.ts +0 -26
  17. package/dist/src/agentverse.js +0 -171
  18. package/dist/src/args.d.ts +0 -9
  19. package/dist/src/args.js +0 -61
  20. package/dist/src/auth.d.ts +0 -6
  21. package/dist/src/auth.js +0 -121
  22. package/dist/src/balances.d.ts +0 -89
  23. package/dist/src/balances.js +0 -202
  24. package/dist/src/banner.d.ts +0 -1
  25. package/dist/src/banner.js +0 -17
  26. package/dist/src/broadcast.d.ts +0 -8
  27. package/dist/src/broadcast.js +0 -175
  28. package/dist/src/catalog.d.ts +0 -12
  29. package/dist/src/catalog.js +0 -76
  30. package/dist/src/ceiling.d.ts +0 -36
  31. package/dist/src/ceiling.js +0 -189
  32. package/dist/src/chat.d.ts +0 -2
  33. package/dist/src/chat.js +0 -92
  34. package/dist/src/check.d.ts +0 -11
  35. package/dist/src/check.js +0 -53
  36. package/dist/src/client.d.ts +0 -5
  37. package/dist/src/client.js +0 -157
  38. package/dist/src/compiler.d.ts +0 -36
  39. package/dist/src/compiler.js +0 -366
  40. package/dist/src/config.d.ts +0 -24
  41. package/dist/src/config.js +0 -70
  42. package/dist/src/connect.d.ts +0 -2
  43. package/dist/src/connect.js +0 -64
  44. package/dist/src/coordinate.d.ts +0 -3
  45. package/dist/src/coordinate.js +0 -58
  46. package/dist/src/create.d.ts +0 -2
  47. package/dist/src/create.js +0 -113
  48. package/dist/src/credits.d.ts +0 -29
  49. package/dist/src/credits.js +0 -88
  50. package/dist/src/deploy.d.ts +0 -2
  51. package/dist/src/deploy.js +0 -19
  52. package/dist/src/dev.d.ts +0 -2
  53. package/dist/src/dev.js +0 -75
  54. package/dist/src/device-flow.d.ts +0 -57
  55. package/dist/src/device-flow.js +0 -173
  56. package/dist/src/doctor.d.ts +0 -26
  57. package/dist/src/doctor.js +0 -146
  58. package/dist/src/draw.d.ts +0 -18
  59. package/dist/src/draw.js +0 -156
  60. package/dist/src/endpoint.d.ts +0 -2
  61. package/dist/src/endpoint.js +0 -250
  62. package/dist/src/env.d.ts +0 -3
  63. package/dist/src/env.js +0 -37
  64. package/dist/src/eval.d.ts +0 -2
  65. package/dist/src/eval.js +0 -43
  66. package/dist/src/fn.d.ts +0 -2
  67. package/dist/src/fn.js +0 -70
  68. package/dist/src/group.d.ts +0 -2
  69. package/dist/src/group.js +0 -117
  70. package/dist/src/hl-run.d.ts +0 -119
  71. package/dist/src/hl-run.js +0 -480
  72. package/dist/src/hl.d.ts +0 -17
  73. package/dist/src/hl.js +0 -148
  74. package/dist/src/index.d.ts +0 -2
  75. package/dist/src/init.d.ts +0 -76
  76. package/dist/src/init.js +0 -278
  77. package/dist/src/join.d.ts +0 -11
  78. package/dist/src/join.js +0 -297
  79. package/dist/src/key-publish.d.ts +0 -40
  80. package/dist/src/key-publish.js +0 -232
  81. package/dist/src/key-seal.d.ts +0 -21
  82. package/dist/src/key-seal.js +0 -142
  83. package/dist/src/key-sweep.d.ts +0 -93
  84. package/dist/src/key-sweep.js +0 -270
  85. package/dist/src/key.d.ts +0 -26
  86. package/dist/src/key.js +0 -338
  87. package/dist/src/lib/age-plugin.d.ts +0 -51
  88. package/dist/src/lib/age-plugin.js +0 -130
  89. package/dist/src/lib/agent-env.d.ts +0 -12
  90. package/dist/src/lib/agent-env.js +0 -48
  91. package/dist/src/lib/api-path.d.ts +0 -2
  92. package/dist/src/lib/api-path.js +0 -40
  93. package/dist/src/lib/asker.d.ts +0 -34
  94. package/dist/src/lib/asker.js +0 -126
  95. package/dist/src/lib/check-words.d.ts +0 -57
  96. package/dist/src/lib/check-words.js +0 -144
  97. package/dist/src/lib/client.d.ts +0 -20
  98. package/dist/src/lib/client.js +0 -71
  99. package/dist/src/lib/env-sealed.d.ts +0 -53
  100. package/dist/src/lib/env-sealed.js +0 -184
  101. package/dist/src/lib/flow-tag.d.ts +0 -86
  102. package/dist/src/lib/flow-tag.js +0 -230
  103. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  104. package/dist/src/lib/hl-core/actions.js +0 -69
  105. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  106. package/dist/src/lib/hl-core/eip712.js +0 -107
  107. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  108. package/dist/src/lib/hl-core/errors.js +0 -15
  109. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  110. package/dist/src/lib/hl-core/exchange.js +0 -47
  111. package/dist/src/lib/hl-core/index.d.ts +0 -13
  112. package/dist/src/lib/hl-core/index.js +0 -14
  113. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  114. package/dist/src/lib/hl-core/meta.js +0 -110
  115. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  116. package/dist/src/lib/hl-core/msgpack.js +0 -136
  117. package/dist/src/lib/hl-core/net.d.ts +0 -2
  118. package/dist/src/lib/hl-core/net.js +0 -7
  119. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  120. package/dist/src/lib/hl-core/signing.js +0 -295
  121. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  122. package/dist/src/lib/hl-core/wire.js +0 -81
  123. package/dist/src/lib/invoked-as.d.ts +0 -2
  124. package/dist/src/lib/invoked-as.js +0 -24
  125. package/dist/src/lib/journey-words.d.ts +0 -84
  126. package/dist/src/lib/journey-words.js +0 -363
  127. package/dist/src/lib/journey.d.ts +0 -150
  128. package/dist/src/lib/journey.js +0 -264
  129. package/dist/src/lib/key-receipt.d.ts +0 -48
  130. package/dist/src/lib/key-receipt.js +0 -116
  131. package/dist/src/lib/key-source.d.ts +0 -9
  132. package/dist/src/lib/key-source.js +0 -33
  133. package/dist/src/lib/keyfile.d.ts +0 -136
  134. package/dist/src/lib/keyfile.js +0 -397
  135. package/dist/src/lib/launch-claude.d.ts +0 -5
  136. package/dist/src/lib/launch-claude.js +0 -45
  137. package/dist/src/lib/lock-lookup.d.ts +0 -40
  138. package/dist/src/lib/lock-lookup.js +0 -92
  139. package/dist/src/lib/message-seal.d.ts +0 -63
  140. package/dist/src/lib/message-seal.js +0 -150
  141. package/dist/src/lib/net-choice.d.ts +0 -28
  142. package/dist/src/lib/net-choice.js +0 -72
  143. package/dist/src/lib/network.d.ts +0 -22
  144. package/dist/src/lib/network.js +0 -50
  145. package/dist/src/lib/next-words.d.ts +0 -105
  146. package/dist/src/lib/next-words.js +0 -298
  147. package/dist/src/lib/paths.d.ts +0 -41
  148. package/dist/src/lib/paths.js +0 -91
  149. package/dist/src/lib/plan-draw.d.ts +0 -56
  150. package/dist/src/lib/plan-draw.js +0 -219
  151. package/dist/src/lib/plan-live.d.ts +0 -20
  152. package/dist/src/lib/plan-live.js +0 -192
  153. package/dist/src/lib/qr.d.ts +0 -21
  154. package/dist/src/lib/qr.js +0 -402
  155. package/dist/src/lib/roster.d.ts +0 -20
  156. package/dist/src/lib/roster.js +0 -79
  157. package/dist/src/lib/sale-card.d.ts +0 -117
  158. package/dist/src/lib/sale-card.js +0 -261
  159. package/dist/src/lib/shop-init.d.ts +0 -62
  160. package/dist/src/lib/shop-init.js +0 -63
  161. package/dist/src/lib/sui-grpc-send.d.ts +0 -90
  162. package/dist/src/lib/sui-grpc-send.js +0 -128
  163. package/dist/src/lib/swap-core.d.ts +0 -163
  164. package/dist/src/lib/swap-core.js +0 -405
  165. package/dist/src/lib/tasks-digest.d.ts +0 -66
  166. package/dist/src/lib/tasks-digest.js +0 -200
  167. package/dist/src/lib/tasks-graph.d.ts +0 -79
  168. package/dist/src/lib/tasks-graph.js +0 -463
  169. package/dist/src/lib/tasks-lens.d.ts +0 -31
  170. package/dist/src/lib/tasks-lens.js +0 -47
  171. package/dist/src/lib/tasks-next.d.ts +0 -25
  172. package/dist/src/lib/tasks-next.js +0 -103
  173. package/dist/src/lib/tasks-prove.d.ts +0 -15
  174. package/dist/src/lib/tasks-prove.js +0 -68
  175. package/dist/src/lib/tasks-route.d.ts +0 -29
  176. package/dist/src/lib/tasks-route.js +0 -151
  177. package/dist/src/lib/tasks-score.d.ts +0 -36
  178. package/dist/src/lib/tasks-score.js +0 -152
  179. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  180. package/dist/src/lib/tasks-workspace.js +0 -73
  181. package/dist/src/lib/timed-fetch.d.ts +0 -33
  182. package/dist/src/lib/timed-fetch.js +0 -59
  183. package/dist/src/lib/vault-read.d.ts +0 -24
  184. package/dist/src/lib/vault-read.js +0 -77
  185. package/dist/src/lib/vaultfile.d.ts +0 -103
  186. package/dist/src/lib/vaultfile.js +0 -249
  187. package/dist/src/lib/wallet-money.d.ts +0 -222
  188. package/dist/src/lib/wallet-money.js +0 -578
  189. package/dist/src/lib/wallet-request.d.ts +0 -50
  190. package/dist/src/lib/wallet-request.js +0 -86
  191. package/dist/src/links.d.ts +0 -5
  192. package/dist/src/links.js +0 -45
  193. package/dist/src/media.d.ts +0 -29
  194. package/dist/src/media.js +0 -487
  195. package/dist/src/message-receipt.d.ts +0 -25
  196. package/dist/src/message-receipt.js +0 -71
  197. package/dist/src/message.d.ts +0 -13
  198. package/dist/src/message.js +0 -92
  199. package/dist/src/move.d.ts +0 -36
  200. package/dist/src/move.js +0 -152
  201. package/dist/src/network-cmd.d.ts +0 -17
  202. package/dist/src/network-cmd.js +0 -74
  203. package/dist/src/next.d.ts +0 -12
  204. package/dist/src/next.js +0 -67
  205. package/dist/src/onboard.d.ts +0 -16
  206. package/dist/src/onboard.js +0 -149
  207. package/dist/src/plugin.d.ts +0 -2
  208. package/dist/src/plugin.js +0 -193
  209. package/dist/src/push.d.ts +0 -2
  210. package/dist/src/push.js +0 -115
  211. package/dist/src/render.d.ts +0 -21
  212. package/dist/src/render.js +0 -32
  213. package/dist/src/secrets-device.d.ts +0 -32
  214. package/dist/src/secrets-device.js +0 -127
  215. package/dist/src/secrets-give.d.ts +0 -125
  216. package/dist/src/secrets-give.js +0 -236
  217. package/dist/src/secrets-list.d.ts +0 -27
  218. package/dist/src/secrets-list.js +0 -84
  219. package/dist/src/secrets-run.d.ts +0 -31
  220. package/dist/src/secrets-run.js +0 -182
  221. package/dist/src/secrets.d.ts +0 -33
  222. package/dist/src/secrets.js +0 -200
  223. package/dist/src/setup.d.ts +0 -6
  224. package/dist/src/setup.js +0 -127
  225. package/dist/src/ship.d.ts +0 -2
  226. package/dist/src/ship.js +0 -18
  227. package/dist/src/shop-buy.d.ts +0 -16
  228. package/dist/src/shop-buy.js +0 -101
  229. package/dist/src/shop.d.ts +0 -10
  230. package/dist/src/shop.js +0 -112
  231. package/dist/src/skill-parser.d.ts +0 -14
  232. package/dist/src/skill-parser.js +0 -113
  233. package/dist/src/skill.d.ts +0 -2
  234. package/dist/src/skill.js +0 -493
  235. package/dist/src/slug.d.ts +0 -2
  236. package/dist/src/slug.js +0 -6
  237. package/dist/src/social.d.ts +0 -2
  238. package/dist/src/social.js +0 -106
  239. package/dist/src/staff.d.ts +0 -2
  240. package/dist/src/staff.js +0 -104
  241. package/dist/src/start.d.ts +0 -27
  242. package/dist/src/start.js +0 -225
  243. package/dist/src/status.d.ts +0 -2
  244. package/dist/src/status.js +0 -52
  245. package/dist/src/substrate.d.ts +0 -2
  246. package/dist/src/substrate.js +0 -258
  247. package/dist/src/swap.d.ts +0 -93
  248. package/dist/src/swap.js +0 -622
  249. package/dist/src/tasks.d.ts +0 -2
  250. package/dist/src/tasks.js +0 -743
  251. package/dist/src/templates.d.ts +0 -1
  252. package/dist/src/templates.js +0 -213
  253. package/dist/src/thread.d.ts +0 -2
  254. package/dist/src/thread.js +0 -52
  255. package/dist/src/trade.d.ts +0 -2
  256. package/dist/src/trade.js +0 -91
  257. package/dist/src/trail.d.ts +0 -2
  258. package/dist/src/trail.js +0 -41
  259. package/dist/src/validate.d.ts +0 -13
  260. package/dist/src/validate.js +0 -35
  261. package/dist/src/wallet-money.d.ts +0 -158
  262. package/dist/src/wallet-money.js +0 -664
  263. package/dist/src/wallet.d.ts +0 -169
  264. package/dist/src/wallet.js +0 -973
  265. package/dist/src/workflow.d.ts +0 -2
  266. package/dist/src/workflow.js +0 -169
  267. package/dist/src/write.d.ts +0 -43
  268. package/dist/src/write.js +0 -180
@@ -1,270 +0,0 @@
1
- /**
2
- * key-sweep.ts — `one key sweep-rule | sweep | sweep-run`, the terminal halves of
3
- * text/key.md deliverable 8 under Tony's ruling (2026-10-06): "the sweep is
4
- * signed by the human who owns the agent; agents can be claimed by any owner."
5
- *
6
- * sweep-rule OWNER. Proves the owner's address (a signature over a fresh
7
- * wallet:challenge) and sets the agent's threshold + float.
8
- * sweep OWNER. Reads what is due, signs an ORDER with the owner's
9
- * address key, and submits it to wallet:sweep, which records it.
10
- * sweep-run AGENT. Reads its open orders, re-verifies each locally, performs
11
- * the transfer with the agent's own key and settles it
12
- * (@oneie/sdk/sweep-runner). Sui only; other chains are refused by
13
- * name, because no signer for them exists here.
14
- *
15
- * KEYS come from the folder's sealed vault (`.one/wallet.json`) through
16
- * wallet.ts `unlock` — Keychain or a passphrase typed at a terminal, never argv,
17
- * env or a pipe. Nothing here prints, logs or sends a private key or the words:
18
- * only addresses, signatures and the public order cross the wire, and every
19
- * receipt is built field by field.
20
- *
21
- * THE NEW SDK MODULES LOAD LAZILY. key.ts registers these commands, so a static
22
- * import of `@oneie/sdk/sweep-runner` would make every `one key` verb — `key new`
23
- * included — crash on an installed SDK that predates that export. Only the three
24
- * sweep actions reach for it, at the moment they run.
25
- */
26
- import { Command } from 'commander';
27
- import { addressProofMessage, signAddressProof } from '@oneie/sdk/address-proof';
28
- import { authHeaders, out, resolveBase } from './lib/client.js';
29
- import { askPath } from './lib/api-path.js';
30
- import { SUI_GRPC, SuiSendError, loadSpec, suiSendGrpc } from './lib/sui-grpc-send.js';
31
- import { SUI_NATIVE, parseNet } from './lib/wallet-money.js';
32
- import { unlock } from './wallet.js';
33
- import { resolveNet } from './lib/net-choice.js';
34
- /** The vault's chain spelling for each sweep chain. */
35
- const VAULT_CHAIN = { sui: 'sui', evm: 'evm', solana: 'sol', btc: 'btc' };
36
- const isSweepChain = (c) => Object.prototype.hasOwnProperty.call(VAULT_CHAIN, c);
37
- const digits = (v) => typeof v === 'string' && /^\d+$/.test(v);
38
- /** The order lives 10 minutes: inside the server's 15-minute cap, with room for the agent's 2-minute floor. */
39
- export const ORDER_LIFETIME_MS = 10 * 60 * 1000;
40
- const runnerModule = () => import('@oneie/sdk/sweep-runner');
41
- /** One receiver call through the ask door; answers the receiver's own result. */
42
- export function askVia(base, fetchImpl = fetch) {
43
- return async (receiver, data) => {
44
- try {
45
- const res = await fetchImpl(askPath(base.replace(/\/$/, ''), receiver), {
46
- method: 'POST', headers: authHeaders(), body: JSON.stringify({ data }),
47
- });
48
- const body = (await res.json().catch(() => ({})));
49
- if (body.outcome !== 'result')
50
- return { ok: false, error: String(body.error ?? body.outcome ?? `HTTP ${res.status}`) };
51
- return body.result ?? { ok: false, error: 'no result' };
52
- }
53
- catch (e) {
54
- return { ok: false, error: e instanceof Error ? e.message : String(e) };
55
- }
56
- };
57
- }
58
- /**
59
- * Sui balance in mist over gRPC — Sui JSON-RPC is switched off on every public fullnode.
60
- * `core.getBalance` answers `balance.balance` (coin + address balance), already base units.
61
- * `rpc` overrides the gRPC base URL; the default is Mysten's public fullnode for `net`.
62
- */
63
- export function suiBalanceReader(opts, load = loadSpec, deadlineMs = 15_000) {
64
- return async (address) => {
65
- let timer;
66
- try {
67
- const grpc = (await load('@mysten/sui/grpc'));
68
- const client = new grpc.SuiGrpcClient({ network: opts.net, baseUrl: (opts.rpc ?? SUI_GRPC[opts.net]).replace(/\/$/, '') });
69
- const deadline = new Promise((resolve) => { timer = setTimeout(() => resolve(null), deadlineMs); });
70
- const res = await Promise.race([client.core.getBalance({ owner: address, coinType: SUI_NATIVE }), deadline]);
71
- const v = res?.balance?.balance;
72
- return digits(v) ? v : null;
73
- }
74
- catch {
75
- return null;
76
- }
77
- finally {
78
- if (timer)
79
- clearTimeout(timer);
80
- }
81
- };
82
- }
83
- /** The sweep's Sui signer over gRPC: one SUI transfer through suiSendGrpc; resolves to the digest. */
84
- export function suiTransferGrpc(opts, send = (r) => suiSendGrpc(r)) {
85
- return async (t) => {
86
- if (t.chain !== 'sui')
87
- throw new Error(`no_signer:${t.chain}`);
88
- try {
89
- const done = await send({ asset: 'SUI', coinType: SUI_NATIVE, from: t.from, to: t.to, amountUnits: t.amountUnits, privateKeyHex: t.privateKeyHex, rpc: opts.rpc, net: opts.net });
90
- return done.digest;
91
- }
92
- catch (e) {
93
- // Keep the code and, when one exists, the digest of a transfer that may still land.
94
- if (e instanceof SuiSendError)
95
- throw new Error(`${e.code}: ${e.message}${e.digest ? ` (digest ${e.digest})` : ''}`);
96
- throw e;
97
- }
98
- };
99
- }
100
- /** --network wins; else an --rpc URL that names mainnet or testnet; else null. */
101
- export function sweepNet(network, rpc) {
102
- const n = parseNet(network);
103
- if (n)
104
- return n;
105
- if (network === undefined && rpc)
106
- return /mainnet/i.test(rpc) ? 'mainnet' : /testnet/i.test(rpc) ? 'testnet' : null;
107
- return null;
108
- }
109
- function keyFor(keys, chain, address) {
110
- const want = VAULT_CHAIN[chain];
111
- const k = keys.find((x) => x.chain === want && (address === undefined || x.address.toLowerCase() === address.toLowerCase()));
112
- return k ?? null;
113
- }
114
- // ── owner: prove the address, set the rule ─────────────────────────────────
115
- export async function ownerSweepRule(args, deps) {
116
- if (!digits(args.threshold) || !digits(args.float))
117
- return { ok: false, error: 'threshold and float are integer base units' };
118
- const opened = await deps.unlock();
119
- if ('error' in opened)
120
- return { ok: false, error: opened.error };
121
- const key = keyFor(opened.keys, args.chain);
122
- if (!key)
123
- return { ok: false, error: `the vault holds no ${args.chain} key` };
124
- // workspace = actor = the caller: the challenge binds to the owner itself.
125
- const ch = await deps.ask('wallet:challenge', {});
126
- if (ch['ok'] !== true || typeof ch['challenge'] !== 'string')
127
- return { ok: false, error: `wallet:challenge — ${String(ch['error'] ?? 'no challenge')}` };
128
- const message = addressProofMessage({
129
- challenge: ch['challenge'], workspace: String(ch['workspace']), actor: String(ch['actor']), chain: args.chain, address: key.address,
130
- });
131
- const proof = signAddressProof(args.chain, key.privateKeyHex, message);
132
- const res = await deps.ask('wallet:sweep-set', {
133
- workspace: args.workspace, actor: args.agent, chain: args.chain,
134
- threshold: args.threshold, float: args.float, address: key.address, challenge: ch['challenge'], proof,
135
- });
136
- if (res['ok'] !== true)
137
- return { ok: false, error: String(res['error'] ?? 'wallet:sweep-set refused') };
138
- return { ok: true, agent: args.agent, chain: args.chain, owner: res['owner'], ownerAddress: res['ownerAddress'], thresholdUnits: res['thresholdUnits'], floatUnits: res['floatUnits'] };
139
- }
140
- // ── owner: sign and submit an order ────────────────────────────────────────
141
- export async function ownerSweep(args, deps) {
142
- const now = deps.now ?? (() => Date.now());
143
- const base = { workspace: args.workspace, actor: args.agent, chain: args.chain };
144
- const pending = await deps.ask('wallet:sweep', { ...base, pending: true });
145
- if (pending['ok'] !== true)
146
- return { ok: false, error: String(pending['error'] ?? 'wallet:sweep refused') };
147
- const to = String(pending['to'] ?? '');
148
- const agentAddress = String(pending['agentAddress'] ?? '');
149
- let balance = args.balance;
150
- if (balance === undefined) {
151
- if (!deps.readBalance)
152
- return { ok: false, error: 'pass --balance <base units>, or --network mainnet|testnet to read it (sui only)' };
153
- const read = await deps.readBalance(agentAddress);
154
- if (read === null)
155
- return { ok: false, error: 'could not read the agent balance — pass --balance' };
156
- balance = read;
157
- }
158
- if (!digits(balance))
159
- return { ok: false, error: '--balance is integer base units' };
160
- const due = await deps.ask('wallet:sweep', { ...base, balance });
161
- if (due['ok'] !== true)
162
- return { ok: false, error: String(due['error'] ?? 'wallet:sweep refused') };
163
- if (due['due'] !== true)
164
- return { ok: true, due: false, balanceUnits: balance, thresholdUnits: due['thresholdUnits'], note: 'nothing to sweep — the balance is at or below the threshold' };
165
- const max = BigInt(String(due['maxUnits']));
166
- if (args.amount !== undefined && !digits(args.amount))
167
- return { ok: false, error: '--amount is integer base units' };
168
- const amount = args.amount !== undefined ? BigInt(args.amount) : max;
169
- if (amount <= 0n || amount > max)
170
- return { ok: false, error: `--amount must be in (0, ${max}] — balance minus float` };
171
- const opened = await deps.unlock();
172
- if ('error' in opened)
173
- return { ok: false, error: opened.error };
174
- const key = keyFor(opened.keys, args.chain, to);
175
- if (!key)
176
- return { ok: false, error: 'this vault does not hold the address you proved for sweeps — open the vault that does, or re-prove with `key sweep-rule`' };
177
- const { newOrderNonce, signSweepOrder } = await runnerModule();
178
- const { ORDER_MAX_TTL_MS } = await import('@oneie/sdk/sweep-order');
179
- if (ORDER_LIFETIME_MS > ORDER_MAX_TTL_MS)
180
- return { ok: false, error: 'order lifetime exceeds the server cap' };
181
- const order = { ...base, destination: to, amount, nonce: newOrderNonce(), expiresAt: now() + ORDER_LIFETIME_MS };
182
- const signature = signSweepOrder(key.privateKeyHex, order);
183
- const res = await deps.ask('wallet:sweep', {
184
- ...base, balance,
185
- order: { destination: order.destination, amount: order.amount.toString(), nonce: order.nonce, expiresAt: order.expiresAt },
186
- signature,
187
- });
188
- if (res['verified'] !== true)
189
- return { ok: false, error: String(res['error'] ?? 'order not verified') };
190
- return { ok: true, verified: true, agent: args.agent, chain: args.chain, to, amountUnits: order.amount.toString(), nonce: order.nonce, expiresAt: order.expiresAt, next: 'the agent runtime performs it: one key sweep-run' };
191
- }
192
- // ── agent: perform and settle ──────────────────────────────────────────────
193
- export async function agentSweepRun(args, deps) {
194
- const { runSweepOrders } = await runnerModule();
195
- const opened = await deps.unlock();
196
- if ('error' in opened)
197
- return { ok: false, error: opened.error };
198
- const key = keyFor(opened.keys, args.chain);
199
- if (!key)
200
- return { ok: false, error: `the vault holds no ${args.chain} key` };
201
- let transfer = deps.transfer;
202
- if (!transfer && args.chain === 'sui') {
203
- if (!args.network)
204
- return { ok: false, error: 'pass --network mainnet|testnet (--rpc <gRPC base URL> optionally overrides the public fullnode)' };
205
- transfer = { sui: suiTransferGrpc({ net: args.network, rpc: args.rpc }) };
206
- }
207
- const res = await runSweepOrders({ workspace: args.workspace, actor: args.agent, chain: args.chain, agentKey: { address: key.address, privateKeyHex: key.privateKeyHex }, ownerAddress: args.ownerAddress }, { ask: deps.ask, transfer, now: deps.now });
208
- return { ok: res.ok, ...(res.error ? { error: res.error } : {}), agent: args.agent, chain: args.chain, results: res.results };
209
- }
210
- function common(c) {
211
- return c
212
- .requiredOption('--agent <id>', "The agent's actor id")
213
- .option('--workspace <slug>', "The workspace that holds the agent's wallet (default: the agent id)")
214
- .option('--chain <chain>', 'sui | evm | solana | btc', 'sui')
215
- .option('--dir <path>', 'The folder whose sealed vault (.one/wallet.json) holds the key', '.')
216
- .option('--api <url>', 'API base URL (default https://one.ie)');
217
- }
218
- function depsFor(o) {
219
- return { ask: askVia(resolveBase({ api: o.api }, 'https://one.ie')), unlock: () => unlock(o.dir) };
220
- }
221
- export function keySweepCommands() {
222
- const rule = common(new Command('sweep-rule'))
223
- .description("OWNER — prove your address and set an agent's sweep threshold + float (base units)")
224
- .requiredOption('--threshold <units>', 'A sweep is due when the balance is above this')
225
- .requiredOption('--float <units>', 'What the agent keeps after a sweep')
226
- .action(async (o, c) => {
227
- if (!isSweepChain(o.chain))
228
- return out(c, { ok: false, error: '--chain must be sui, evm, solana or btc' });
229
- out(c, await ownerSweepRule({ agent: o.agent, workspace: o.workspace ?? o.agent, chain: o.chain, threshold: o.threshold, float: o.float }, depsFor(o)));
230
- });
231
- const sweep = common(new Command('sweep'))
232
- .description("OWNER — sign a sweep order for what is due and submit it; the agent's runtime performs it")
233
- .option('--amount <units>', 'Base units to sweep (default: everything above the float)')
234
- .option('--balance <units>', "The agent's balance in base units (else read from Sui over gRPC via --network, sui only)")
235
- .option('--network <n>', 'mainnet | testnet — the Sui network to read the balance on (default: ONE_NETWORK, `one network`, the deploy)')
236
- .option('--rpc <url>', 'Sui gRPC base URL override (default: the public fullnode for --network)')
237
- .action(async (o, c) => {
238
- if (!isSweepChain(o.chain))
239
- return out(c, { ok: false, error: '--chain must be sui, evm, solana or btc' });
240
- if (o.network !== undefined && !parseNet(o.network))
241
- return out(c, { ok: false, error: '--network must be mainnet or testnet' });
242
- const deps = depsFor(o);
243
- if (o.chain === 'sui' && o.balance === undefined) {
244
- // --network, or a network the --rpc URL names; else the one rule (ONE_NETWORK, `one network`, the deploy).
245
- const hinted = sweepNet(o.network, o.rpc);
246
- const nc = hinted ? { ok: true, net: hinted } : await resolveNet(undefined, o.api);
247
- if (!nc.ok)
248
- return out(c, nc);
249
- deps.readBalance = suiBalanceReader({ net: nc.net, rpc: o.rpc });
250
- }
251
- out(c, await ownerSweep({ agent: o.agent, workspace: o.workspace ?? o.agent, chain: o.chain, amount: o.amount, balance: o.balance }, deps));
252
- });
253
- const run = common(new Command('sweep-run'))
254
- .description("AGENT — perform and settle the owner's open sweep orders with this agent's own key (sui)")
255
- .option('--rpc <url>', 'Sui gRPC base URL override (default: the public fullnode for --network)')
256
- .option('--network <n>', 'mainnet | testnet — picks the Sui fullnode the transfer goes through (default: ONE_NETWORK, `one network`, the deploy)')
257
- .option('--owner-address <addr>', "Pin the owner's address; any other is refused")
258
- .action(async (o, c) => {
259
- if (!isSweepChain(o.chain))
260
- return out(c, { ok: false, error: '--chain must be sui, evm, solana or btc' });
261
- if (o.network !== undefined && o.network !== 'mainnet' && o.network !== 'testnet')
262
- return out(c, { ok: false, error: '--network must be mainnet or testnet' });
263
- const hinted = sweepNet(o.network, o.rpc);
264
- const nc = hinted ? { ok: true, net: hinted } : await resolveNet(undefined, o.api);
265
- if (!nc.ok)
266
- return out(c, nc);
267
- out(c, await agentSweepRun({ agent: o.agent, workspace: o.workspace ?? o.agent, chain: o.chain, rpc: o.rpc, network: nc.net, ownerAddress: o.ownerAddress }, depsFor(o)));
268
- });
269
- return [rule, sweep, run];
270
- }
package/dist/src/key.d.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * key.ts — `one key new | recover | public | verify`, the text/key.md door on a terminal.
3
- *
4
- * A VERB OVER WALLET KEYGEN, NOT A SECOND DERIVATION. Every address comes from
5
- * `@oneie/sdk/wallet` — the same core `one wallet keygen`, packages/recover and
6
- * the browser (by parity test) derive with. The public identity is the SDK's
7
- * `@oneie/sdk/key-identity`, byte-identical to one.ie/web's `deriveUserIdPub`.
8
- *
9
- * THE KEY NEVER LEAVES THIS MACHINE.
10
- * • new · recover · public make no network call at all.
11
- * • verify makes one kind of call — `fetchReferences(base, apiKey)` — and it is
12
- * structurally unable to send the key: its only inputs are a URL and the API
13
- * key. It reads the public identities the server holds and the comparison
14
- * happens HERE, so not even the public identity is transmitted.
15
- * • The words never come from argv (shell history, `ps`): env or stdin, or a
16
- * hidden prompt on a terminal. An argv token is never echoed — it may BE the
17
- * phrase.
18
- * • Under --json the words never reach stdout (an agent's stdout is a model
19
- * context and a session log). They reach disk only behind keygen's own
20
- * --yes-i-accept-plaintext-file, at 0600.
21
- * • Printed, the words go only to a terminal: a shell whose env names an agent
22
- * or CI is refused, and a non-TTY stdout needs --yes-print-to-pipe. That is
23
- * detection, not proof — a pty with no marker is not caught (text/key.md).
24
- */
25
- import { Command } from 'commander';
26
- export declare function keyCmd(): Command;
package/dist/src/key.js DELETED
@@ -1,338 +0,0 @@
1
- /**
2
- * key.ts — `one key new | recover | public | verify`, the text/key.md door on a terminal.
3
- *
4
- * A VERB OVER WALLET KEYGEN, NOT A SECOND DERIVATION. Every address comes from
5
- * `@oneie/sdk/wallet` — the same core `one wallet keygen`, packages/recover and
6
- * the browser (by parity test) derive with. The public identity is the SDK's
7
- * `@oneie/sdk/key-identity`, byte-identical to one.ie/web's `deriveUserIdPub`.
8
- *
9
- * THE KEY NEVER LEAVES THIS MACHINE.
10
- * • new · recover · public make no network call at all.
11
- * • verify makes one kind of call — `fetchReferences(base, apiKey)` — and it is
12
- * structurally unable to send the key: its only inputs are a URL and the API
13
- * key. It reads the public identities the server holds and the comparison
14
- * happens HERE, so not even the public identity is transmitted.
15
- * • The words never come from argv (shell history, `ps`): env or stdin, or a
16
- * hidden prompt on a terminal. An argv token is never echoed — it may BE the
17
- * phrase.
18
- * • Under --json the words never reach stdout (an agent's stdout is a model
19
- * context and a session log). They reach disk only behind keygen's own
20
- * --yes-i-accept-plaintext-file, at 0600.
21
- * • Printed, the words go only to a terminal: a shell whose env names an agent
22
- * or CI is refused, and a non-TTY stdout needs --yes-print-to-pipe. That is
23
- * detection, not proof — a pty with no marker is not caught (text/key.md).
24
- */
25
- import { Command } from 'commander';
26
- import { existsSync, readFileSync } from 'node:fs';
27
- import { generateWallet, recoverWallet } from '@oneie/sdk/wallet';
28
- import { userIdPubFromPhrase } from '@oneie/sdk/key-identity';
29
- import { jsonMode, resolveBase, resolveKey } from './lib/client.js';
30
- import { promptSecret, writeKeysFile } from './wallet.js';
31
- import { wordsStdoutRefusal } from './lib/agent-env.js';
32
- import { keySweepCommands } from './key-sweep.js';
33
- import { keySealCommands } from './key-seal.js';
34
- import { keyPublishCommands } from './key-publish.js';
35
- import { renderKeyReceipt, startKeyReceipt } from './lib/key-receipt.js';
36
- const REFUSE_ARGV_SECRET = 'A secret on the command line is refused on purpose: it is written to your shell history and is ' +
37
- 'visible in `ps` to every user on this machine. Set ONE_WALLET_MNEMONIC or pipe the words on stdin.';
38
- const REFUSE_ARGV = 'Unrecognised argument. It is not repeated here on purpose — it may BE your recovery phrase. ' +
39
- 'Words go on stdin or in ONE_WALLET_MNEMONIC, never on the command line. Run --help.';
40
- const INVALID_PHRASE = 'That is not a valid 24-word BIP-39 recovery phrase. Nothing was derived.';
41
- // text/key.md, verbatim in substance: the difference is silent and it costs money.
42
- const NOT_SUI = 'These 24 words are not a Sui wallet mnemonic under v1: ONE derives each chain by HKDF from their ' +
43
- '32 bytes of entropy, while a standard wallet derives by BIP-44/SLIP-0010 from the same phrase. ' +
44
- 'Both succeed; the standard one shows different, empty addresses. Recover them here, at /key, or with @oneie/recover.';
45
- const PAPER = 'Write these on paper. The paper is the only backup — ONE never holds this key and cannot recover it.';
46
- function labelFor(d) {
47
- return d === 'v2'
48
- ? 'v2 — standard paths (BIP-44 / SLIP-0010). Any BIP-39 wallet recovers these.'
49
- : 'v1 — original ONE derivation (HKDF labels). Only one.ie and @oneie/recover derive these.';
50
- }
51
- /** Field by field from the known chains — a private key has no route into the value.
52
- * `asi` exists only under v2; a v1 key gets no key for it, not an empty line. */
53
- function addressesOf(w) {
54
- const pick = (c) => w.keys.find((k) => k.chain === c)?.address ?? '';
55
- const asi = pick('asi');
56
- return { sui: pick('sui'), evm: pick('evm'), sol: pick('sol'), btc: pick('btc'), ...(asi ? { asi } : {}) };
57
- }
58
- function fail(cmd, error) {
59
- if (jsonMode(cmd))
60
- process.stdout.write(JSON.stringify({ ok: false, error }) + '\n');
61
- else
62
- process.stderr.write(`error ${error}\n`);
63
- process.exitCode = 1;
64
- }
65
- function done(cmd, data) {
66
- if (jsonMode(cmd)) {
67
- process.stdout.write(JSON.stringify(data) + '\n');
68
- return;
69
- }
70
- const lines = Object.entries(data)
71
- .filter(([k]) => k !== 'ok')
72
- .map(([k, v]) => ` ${k}: ${typeof v === 'string' ? v : JSON.stringify(v)}`);
73
- process.stdout.write(`ok\n${lines.join('\n')}\n`);
74
- }
75
- function readDerivationOpt(v) {
76
- if (v === undefined || v === 'v1')
77
- return 'v1';
78
- if (v === 'v2')
79
- return 'v2';
80
- return null;
81
- }
82
- /** Refuse a secret-bearing flag or any stray argv token, never echoing it. */
83
- function refuseArgv(cmd, opts, rest) {
84
- if (opts.phrase !== undefined || opts.mnemonic !== undefined) {
85
- fail(cmd, REFUSE_ARGV_SECRET);
86
- return true;
87
- }
88
- if (rest.length > 0) {
89
- fail(cmd, REFUSE_ARGV);
90
- return true;
91
- }
92
- return false;
93
- }
94
- /** The words: ONE_WALLET_MNEMONIC, else stdin when piped, else a hidden prompt. '' = none given. */
95
- async function readWords() {
96
- const fromEnv = process.env.ONE_WALLET_MNEMONIC?.trim();
97
- if (fromEnv)
98
- return fromEnv;
99
- if (!process.stdin.isTTY) {
100
- try {
101
- return readFileSync(0, 'utf8').trim();
102
- }
103
- catch {
104
- return '';
105
- }
106
- }
107
- return (await promptSecret('Your 24 words (hidden): ')).trim();
108
- }
109
- /** Adds the two refused secret flags and the argv catch-all every word-reading verb shares. */
110
- function wordsCommand(name, description) {
111
- return new Command(name)
112
- .description(description)
113
- .argument('[refused...]')
114
- .allowUnknownOption()
115
- .option('--phrase [words]', 'REFUSED — never put the words on the command line')
116
- .option('--mnemonic [words]', 'REFUSED — never put the words on the command line');
117
- }
118
- /**
119
- * The public identities the server holds for the caller: `vault_blob.user_id_pub`
120
- * and every `vault_passkey_hints.user_id_pub` (the same two sources /keys reads).
121
- * Its only inputs are a URL and the API key — nothing derived from the key can
122
- * reach the request, by signature.
123
- */
124
- async function fetchReferences(base, apiKey) {
125
- const out = [];
126
- for (const path of ['/api/vault/sync', '/api/vault/devices']) {
127
- try {
128
- const res = await fetch(base + path, { headers: { Authorization: `Bearer ${apiKey}` } });
129
- if (path === '/api/vault/sync' && res.status === 404) {
130
- out.push({ answered: true, ids: [] });
131
- continue;
132
- }
133
- if (!res.ok) {
134
- out.push({ answered: false, ids: [] });
135
- continue;
136
- }
137
- const body = (await res.json());
138
- const raw = path === '/api/vault/sync' ? [body.userIdPub] : (body.devices ?? []).map((d) => d?.userIdPub);
139
- out.push({ answered: true, ids: raw.filter((r) => typeof r === 'string' && r.length > 0) });
140
- }
141
- catch {
142
- out.push({ answered: false, ids: [] });
143
- }
144
- }
145
- return out;
146
- }
147
- function verdictOf(local, refs) {
148
- if (!local)
149
- return 'locked';
150
- if (refs.length === 0)
151
- return 'unregistered';
152
- return refs.includes(local) ? 'verified' : 'mismatch';
153
- }
154
- // ── the command ──────────────────────────────────────────────────────────────
155
- export function keyCmd() {
156
- const cmd = new Command('key').description('One key — new · recover · public · verify · lock · seal · open · identity · publish-lock · lock-of. Offline except verify, publish-lock, lock-of');
157
- cmd.command('new')
158
- .description('Mint a key on this machine: 24 words, printed ONCE, for paper. No network')
159
- .argument('[refused...]')
160
- .allowUnknownOption()
161
- .option('--phrase [words]', 'REFUSED — never put the words on the command line')
162
- .option('--mnemonic [words]', 'REFUSED — never put the words on the command line')
163
- .option('--derivation <v>', 'v2 (default — standard BIP-44 paths, what one.ie mints) or v1 (original ONE HKDF labels)', 'v2')
164
- .option('--out <file>', 'Write the words + keys to a file at mode 0600 instead of printing them')
165
- .option('--yes-i-accept-plaintext-file', 'Required with --out — acknowledge that unencrypted key material will be written to disk')
166
- .option('--yes-print-to-pipe', 'Print the words even though stdout is not a terminal — a printer, on purpose. An agent shell is refused regardless')
167
- .action(async (rest, opts, sub) => {
168
- if (refuseArgv(sub, opts, rest))
169
- return;
170
- const derivation = readDerivationOpt(opts.derivation);
171
- if (!derivation)
172
- return fail(sub, '--derivation must be v1 or v2');
173
- // Refuse BEFORE minting: words that exist only in a process about to exit are lost money.
174
- if (opts.out && !opts.yesIAcceptPlaintextFile) {
175
- return fail(sub, 'refusing to write plaintext key material to disk — pass --yes-i-accept-plaintext-file to override');
176
- }
177
- if (opts.out && existsSync(opts.out))
178
- return fail(sub, 'that file already exists — move it aside first; a key file is never overwritten');
179
- if (!opts.out && jsonMode(sub)) {
180
- return fail(sub, 'refusing to print the words under --json — stdout may be a log or a model context. Use --out <file> --yes-i-accept-plaintext-file');
181
- }
182
- if (!opts.out) {
183
- const why = wordsStdoutRefusal(process.env, Boolean(process.stdout.isTTY), Boolean(opts.yesPrintToPipe));
184
- if (why)
185
- return fail(sub, why);
186
- }
187
- // Counted, not claimed: every connection, lookup and datagram this process opens while the key is made.
188
- const measure = startKeyReceipt();
189
- const wallet = await generateWallet(derivation);
190
- const addresses = addressesOf(wallet);
191
- const userIdPub = await userIdPubFromPhrase(wallet.mnemonic);
192
- const receipt = measure.seal();
193
- if (opts.out) {
194
- const contents = JSON.stringify({ mnemonic: wallet.mnemonic, derivation, userIdPub, addresses, keys: wallet.keys }, null, 2) + '\n';
195
- writeKeysFile(opts.out, contents, true);
196
- const data = { ok: true, out: opts.out, derivation, label: labelFor(derivation), addresses, userIdPub };
197
- if (jsonMode(sub))
198
- return done(sub, { ...data, receipt });
199
- done(sub, data);
200
- return void process.stdout.write(`\n${renderKeyReceipt(receipt)}`);
201
- }
202
- // Straight to stdout, never through a JSON receipt (refused above).
203
- const words = wallet.mnemonic.split(' ');
204
- const sheet = words.map((w, i) => `${String(i + 1).padStart(4)}. ${w}`).join('\n');
205
- process.stdout.write(`\n${PAPER}\n\n${sheet}\n\n${NOT_SUI}\n\n` +
206
- `derivation ${labelFor(derivation)}\n` +
207
- Object.entries(addresses).map(([c, a]) => `${c.padEnd(11)} ${a}`).join('\n') +
208
- `\nidentity ${userIdPub}\n\nThis is the only time the words are shown. Close the terminal when they are on paper.\n\n` +
209
- renderKeyReceipt(receipt));
210
- });
211
- cmd.addCommand(wordsCommand('recover', 'Rebuild a key from its 24 words (stdin or ONE_WALLET_MNEMONIC) — both address sets, no network')
212
- .option('--derivation <v>', 'which set --out writes: v1 (default) or v2', 'v1')
213
- .option('--out <file>', 'Write the words + keys to a file at mode 0600')
214
- .option('--yes-i-accept-plaintext-file', 'Required with --out')
215
- .action(async (rest, opts, sub) => {
216
- if (refuseArgv(sub, opts, rest))
217
- return;
218
- const derivation = readDerivationOpt(opts.derivation);
219
- if (!derivation)
220
- return fail(sub, '--derivation must be v1 or v2');
221
- if (opts.out && !opts.yesIAcceptPlaintextFile) {
222
- return fail(sub, 'refusing to write plaintext key material to disk — pass --yes-i-accept-plaintext-file to override');
223
- }
224
- const words = await readWords();
225
- let v1, v2, userIdPub;
226
- try {
227
- v1 = await recoverWallet(words, 'v1');
228
- v2 = await recoverWallet(words, 'v2');
229
- userIdPub = await userIdPubFromPhrase(words);
230
- }
231
- catch {
232
- return fail(sub, INVALID_PHRASE);
233
- }
234
- if (opts.out) {
235
- if (existsSync(opts.out))
236
- return fail(sub, 'that file already exists — move it aside first; a key file is never overwritten');
237
- const w = derivation === 'v2' ? v2 : v1;
238
- writeKeysFile(opts.out, JSON.stringify({ mnemonic: w.mnemonic, derivation, userIdPub, addresses: addressesOf(w), keys: w.keys }, null, 2) + '\n', true);
239
- }
240
- done(sub, {
241
- ok: true,
242
- userIdPub,
243
- v1: { label: labelFor('v1'), addresses: addressesOf(v1) },
244
- v2: { label: labelFor('v2'), addresses: addressesOf(v2) },
245
- ...(opts.out ? { out: opts.out, wrote: derivation } : {}),
246
- });
247
- }));
248
- cmd.addCommand(wordsCommand('public', 'The public identity + the five chain addresses for your words (four for a v1 key) — nothing secret, no network')
249
- .option('--derivation <v>', 'v1 or v2 — omit it and both sets print, because the words carry no marker')
250
- .action(async (rest, opts, sub) => {
251
- if (refuseArgv(sub, opts, rest))
252
- return;
253
- const derivation = readDerivationOpt(opts.derivation);
254
- if (!derivation)
255
- return fail(sub, '--derivation must be v1 or v2');
256
- const words = await readWords();
257
- // No --derivation: the words say nothing about which set they were minted
258
- // under, and `key new` mints v2 while every older key is v1. Picking one
259
- // here is the silent divergence task:01a0c33a93bbebfc8e2ebba0 closed — so
260
- // both sets print, the way `key recover` already does.
261
- if (opts.derivation === undefined) {
262
- let v1, v2, userIdPub;
263
- try {
264
- v1 = await recoverWallet(words, 'v1');
265
- v2 = await recoverWallet(words, 'v2');
266
- userIdPub = await userIdPubFromPhrase(words);
267
- }
268
- catch {
269
- return fail(sub, INVALID_PHRASE);
270
- }
271
- return done(sub, {
272
- ok: true,
273
- userIdPub,
274
- v1: { label: labelFor('v1'), addresses: addressesOf(v1) },
275
- v2: { label: labelFor('v2'), addresses: addressesOf(v2) },
276
- });
277
- }
278
- let wallet, userIdPub;
279
- try {
280
- wallet = await recoverWallet(words, derivation);
281
- userIdPub = await userIdPubFromPhrase(words);
282
- }
283
- catch {
284
- return fail(sub, INVALID_PHRASE);
285
- }
286
- done(sub, { ok: true, derivation, label: labelFor(derivation), addresses: addressesOf(wallet), userIdPub });
287
- }));
288
- cmd.addCommand(wordsCommand('verify', "Compare this key's public identity with what the server holds — locked | verified | mismatch | unregistered")
289
- .option('--api <url>', 'API base URL (default https://one.ie)')
290
- .action(async (rest, opts, sub) => {
291
- if (refuseArgv(sub, opts, rest))
292
- return;
293
- const words = await readWords();
294
- if (!words) {
295
- done(sub, { ok: true, verdict: 'locked', note: 'no words given — nothing to compare, and no request was made' });
296
- process.exitCode = 1;
297
- return;
298
- }
299
- let local;
300
- try {
301
- local = await userIdPubFromPhrase(words);
302
- }
303
- catch {
304
- return fail(sub, INVALID_PHRASE);
305
- }
306
- const apiKey = resolveKey();
307
- if (!apiKey)
308
- return fail(sub, 'no API key — set ONE_API_KEY or run: one login');
309
- const refs = await fetchReferences(resolveBase({ api: opts.api }, 'https://one.ie'), apiKey);
310
- const verdict = verdictOf(local, refs.flatMap((r) => r.ids));
311
- // `unregistered` is a claim about ABSENCE: believable only when every source
312
- // answered. A refused or failed probe is inconclusive, never "not registered".
313
- if (verdict === 'unregistered' && refs.some((r) => !r.answered)) {
314
- return fail(sub, 'inconclusive — the server did not answer (auth refused or unreachable), so absence cannot be claimed. A key that is not a person\'s own login also reads as nothing here');
315
- }
316
- done(sub, { ok: true, verdict, userIdPub: local });
317
- if (verdict === 'mismatch')
318
- process.exitCode = 1;
319
- }));
320
- // sweep-rule · sweep · sweep-run — the owner's and the agent's halves of the
321
- // sweep (key-sweep.ts). Keys come from the folder's sealed vault, never argv.
322
- for (const sub of keySweepCommands())
323
- cmd.addCommand(sub);
324
- // lock · seal · open · identity — sealed notes from a terminal (key-seal.ts). Offline.
325
- // publish-lock · lock-of — put a lock under a name / read one back, checked (key-publish.ts).
326
- for (const sub of keySealCommands())
327
- cmd.addCommand(sub);
328
- for (const sub of keyPublishCommands())
329
- cmd.addCommand(sub);
330
- // `one key <token>`: commander would print "unknown command '<token>'" — and the
331
- // token may BE the first word of a phrase. Refuse it here without repeating it.
332
- cmd.argument('[refused...]').allowUnknownOption().action((rest, _opts, c) => {
333
- if (rest.length === 0)
334
- return c.help({ error: true });
335
- fail(c, REFUSE_ARGV);
336
- });
337
- return cmd;
338
- }