oneie 5.7.6 → 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 (245) hide show
  1. package/README.md +19 -1
  2. package/dist/package.json +7 -8
  3. package/dist/src/age-yefbe8pe.js +1 -0
  4. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  5. package/dist/src/hl-run-tgrkrk69.js +1 -0
  6. package/dist/src/index-0rj9wdk9.js +4 -0
  7. package/dist/src/index-91y484c2.js +2052 -0
  8. package/dist/src/index-940y3rnv.js +12 -0
  9. package/dist/src/index.js +1047 -121
  10. package/dist/src/message-key-db1xjdkw.js +1 -0
  11. package/dist/src/message-lock-5vr8079x.js +5 -0
  12. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  13. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  14. package/package.json +7 -8
  15. package/dist/src/agent.d.ts +0 -75
  16. package/dist/src/agent.js +0 -1334
  17. package/dist/src/agentverse.d.ts +0 -26
  18. package/dist/src/agentverse.js +0 -171
  19. package/dist/src/args.d.ts +0 -9
  20. package/dist/src/args.js +0 -61
  21. package/dist/src/auth.d.ts +0 -6
  22. package/dist/src/auth.js +0 -121
  23. package/dist/src/balances.d.ts +0 -89
  24. package/dist/src/balances.js +0 -202
  25. package/dist/src/banner.d.ts +0 -1
  26. package/dist/src/banner.js +0 -17
  27. package/dist/src/broadcast.d.ts +0 -8
  28. package/dist/src/broadcast.js +0 -175
  29. package/dist/src/catalog.d.ts +0 -12
  30. package/dist/src/catalog.js +0 -76
  31. package/dist/src/chat.d.ts +0 -2
  32. package/dist/src/chat.js +0 -92
  33. package/dist/src/client.d.ts +0 -5
  34. package/dist/src/client.js +0 -157
  35. package/dist/src/compiler.d.ts +0 -36
  36. package/dist/src/compiler.js +0 -366
  37. package/dist/src/config.d.ts +0 -24
  38. package/dist/src/config.js +0 -70
  39. package/dist/src/connect.d.ts +0 -2
  40. package/dist/src/connect.js +0 -64
  41. package/dist/src/coordinate.d.ts +0 -3
  42. package/dist/src/coordinate.js +0 -58
  43. package/dist/src/create.d.ts +0 -2
  44. package/dist/src/create.js +0 -113
  45. package/dist/src/deploy.d.ts +0 -2
  46. package/dist/src/deploy.js +0 -19
  47. package/dist/src/dev.d.ts +0 -2
  48. package/dist/src/dev.js +0 -75
  49. package/dist/src/device-flow.d.ts +0 -57
  50. package/dist/src/device-flow.js +0 -173
  51. package/dist/src/doctor.d.ts +0 -26
  52. package/dist/src/doctor.js +0 -146
  53. package/dist/src/draw.d.ts +0 -18
  54. package/dist/src/draw.js +0 -156
  55. package/dist/src/endpoint.d.ts +0 -2
  56. package/dist/src/endpoint.js +0 -250
  57. package/dist/src/env.d.ts +0 -3
  58. package/dist/src/env.js +0 -37
  59. package/dist/src/eval.d.ts +0 -2
  60. package/dist/src/eval.js +0 -43
  61. package/dist/src/fn.d.ts +0 -2
  62. package/dist/src/fn.js +0 -70
  63. package/dist/src/group.d.ts +0 -2
  64. package/dist/src/group.js +0 -117
  65. package/dist/src/hl-run.d.ts +0 -119
  66. package/dist/src/hl-run.js +0 -480
  67. package/dist/src/hl.d.ts +0 -17
  68. package/dist/src/hl.js +0 -148
  69. package/dist/src/index.d.ts +0 -2
  70. package/dist/src/init.d.ts +0 -76
  71. package/dist/src/init.js +0 -278
  72. package/dist/src/join.d.ts +0 -11
  73. package/dist/src/join.js +0 -293
  74. package/dist/src/key-publish.d.ts +0 -40
  75. package/dist/src/key-publish.js +0 -232
  76. package/dist/src/key-seal.d.ts +0 -21
  77. package/dist/src/key-seal.js +0 -142
  78. package/dist/src/key-sweep.d.ts +0 -93
  79. package/dist/src/key-sweep.js +0 -263
  80. package/dist/src/key.d.ts +0 -26
  81. package/dist/src/key.js +0 -338
  82. package/dist/src/lib/age-plugin.d.ts +0 -51
  83. package/dist/src/lib/age-plugin.js +0 -130
  84. package/dist/src/lib/agent-env.d.ts +0 -12
  85. package/dist/src/lib/agent-env.js +0 -48
  86. package/dist/src/lib/api-path.d.ts +0 -2
  87. package/dist/src/lib/api-path.js +0 -40
  88. package/dist/src/lib/asker.d.ts +0 -34
  89. package/dist/src/lib/asker.js +0 -126
  90. package/dist/src/lib/client.d.ts +0 -20
  91. package/dist/src/lib/client.js +0 -71
  92. package/dist/src/lib/env-sealed.d.ts +0 -53
  93. package/dist/src/lib/env-sealed.js +0 -184
  94. package/dist/src/lib/flow-tag.d.ts +0 -86
  95. package/dist/src/lib/flow-tag.js +0 -230
  96. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  97. package/dist/src/lib/hl-core/actions.js +0 -69
  98. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  99. package/dist/src/lib/hl-core/eip712.js +0 -107
  100. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  101. package/dist/src/lib/hl-core/errors.js +0 -15
  102. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  103. package/dist/src/lib/hl-core/exchange.js +0 -47
  104. package/dist/src/lib/hl-core/index.d.ts +0 -13
  105. package/dist/src/lib/hl-core/index.js +0 -14
  106. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  107. package/dist/src/lib/hl-core/meta.js +0 -110
  108. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  109. package/dist/src/lib/hl-core/msgpack.js +0 -136
  110. package/dist/src/lib/hl-core/net.d.ts +0 -2
  111. package/dist/src/lib/hl-core/net.js +0 -7
  112. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  113. package/dist/src/lib/hl-core/signing.js +0 -295
  114. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  115. package/dist/src/lib/hl-core/wire.js +0 -81
  116. package/dist/src/lib/invoked-as.d.ts +0 -2
  117. package/dist/src/lib/invoked-as.js +0 -24
  118. package/dist/src/lib/journey-words.d.ts +0 -84
  119. package/dist/src/lib/journey-words.js +0 -360
  120. package/dist/src/lib/journey.d.ts +0 -148
  121. package/dist/src/lib/journey.js +0 -245
  122. package/dist/src/lib/key-receipt.d.ts +0 -48
  123. package/dist/src/lib/key-receipt.js +0 -116
  124. package/dist/src/lib/key-source.d.ts +0 -9
  125. package/dist/src/lib/key-source.js +0 -33
  126. package/dist/src/lib/keyfile.d.ts +0 -136
  127. package/dist/src/lib/keyfile.js +0 -397
  128. package/dist/src/lib/launch-claude.d.ts +0 -5
  129. package/dist/src/lib/launch-claude.js +0 -45
  130. package/dist/src/lib/lock-lookup.d.ts +0 -40
  131. package/dist/src/lib/lock-lookup.js +0 -92
  132. package/dist/src/lib/message-seal.d.ts +0 -63
  133. package/dist/src/lib/message-seal.js +0 -150
  134. package/dist/src/lib/network.d.ts +0 -15
  135. package/dist/src/lib/network.js +0 -41
  136. package/dist/src/lib/paths.d.ts +0 -41
  137. package/dist/src/lib/paths.js +0 -91
  138. package/dist/src/lib/plan-draw.d.ts +0 -56
  139. package/dist/src/lib/plan-draw.js +0 -219
  140. package/dist/src/lib/plan-live.d.ts +0 -20
  141. package/dist/src/lib/plan-live.js +0 -192
  142. package/dist/src/lib/qr.d.ts +0 -21
  143. package/dist/src/lib/qr.js +0 -402
  144. package/dist/src/lib/roster.d.ts +0 -20
  145. package/dist/src/lib/roster.js +0 -79
  146. package/dist/src/lib/sale-card.d.ts +0 -117
  147. package/dist/src/lib/sale-card.js +0 -261
  148. package/dist/src/lib/shop-init.d.ts +0 -62
  149. package/dist/src/lib/shop-init.js +0 -63
  150. package/dist/src/lib/sui-grpc-send.d.ts +0 -50
  151. package/dist/src/lib/sui-grpc-send.js +0 -89
  152. package/dist/src/lib/swap-core.d.ts +0 -163
  153. package/dist/src/lib/swap-core.js +0 -405
  154. package/dist/src/lib/tasks-digest.d.ts +0 -66
  155. package/dist/src/lib/tasks-digest.js +0 -200
  156. package/dist/src/lib/tasks-graph.d.ts +0 -79
  157. package/dist/src/lib/tasks-graph.js +0 -463
  158. package/dist/src/lib/tasks-lens.d.ts +0 -31
  159. package/dist/src/lib/tasks-lens.js +0 -47
  160. package/dist/src/lib/tasks-next.d.ts +0 -25
  161. package/dist/src/lib/tasks-next.js +0 -103
  162. package/dist/src/lib/tasks-prove.d.ts +0 -15
  163. package/dist/src/lib/tasks-prove.js +0 -68
  164. package/dist/src/lib/tasks-route.d.ts +0 -29
  165. package/dist/src/lib/tasks-route.js +0 -151
  166. package/dist/src/lib/tasks-score.d.ts +0 -36
  167. package/dist/src/lib/tasks-score.js +0 -152
  168. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  169. package/dist/src/lib/tasks-workspace.js +0 -73
  170. package/dist/src/lib/vault-read.d.ts +0 -24
  171. package/dist/src/lib/vault-read.js +0 -77
  172. package/dist/src/lib/vaultfile.d.ts +0 -88
  173. package/dist/src/lib/vaultfile.js +0 -222
  174. package/dist/src/lib/wallet-money.d.ts +0 -222
  175. package/dist/src/lib/wallet-money.js +0 -578
  176. package/dist/src/lib/wallet-request.d.ts +0 -50
  177. package/dist/src/lib/wallet-request.js +0 -86
  178. package/dist/src/links.d.ts +0 -5
  179. package/dist/src/links.js +0 -45
  180. package/dist/src/media.d.ts +0 -29
  181. package/dist/src/media.js +0 -487
  182. package/dist/src/message-receipt.d.ts +0 -25
  183. package/dist/src/message-receipt.js +0 -71
  184. package/dist/src/message.d.ts +0 -13
  185. package/dist/src/message.js +0 -92
  186. package/dist/src/onboard.d.ts +0 -16
  187. package/dist/src/onboard.js +0 -149
  188. package/dist/src/plugin.d.ts +0 -2
  189. package/dist/src/plugin.js +0 -193
  190. package/dist/src/push.d.ts +0 -2
  191. package/dist/src/push.js +0 -115
  192. package/dist/src/render.d.ts +0 -21
  193. package/dist/src/render.js +0 -32
  194. package/dist/src/secrets-device.d.ts +0 -32
  195. package/dist/src/secrets-device.js +0 -127
  196. package/dist/src/secrets-give.d.ts +0 -125
  197. package/dist/src/secrets-give.js +0 -236
  198. package/dist/src/secrets-list.d.ts +0 -27
  199. package/dist/src/secrets-list.js +0 -84
  200. package/dist/src/secrets-run.d.ts +0 -31
  201. package/dist/src/secrets-run.js +0 -182
  202. package/dist/src/secrets.d.ts +0 -33
  203. package/dist/src/secrets.js +0 -200
  204. package/dist/src/setup.d.ts +0 -6
  205. package/dist/src/setup.js +0 -127
  206. package/dist/src/ship.d.ts +0 -2
  207. package/dist/src/ship.js +0 -18
  208. package/dist/src/shop.d.ts +0 -10
  209. package/dist/src/shop.js +0 -110
  210. package/dist/src/skill-parser.d.ts +0 -14
  211. package/dist/src/skill-parser.js +0 -113
  212. package/dist/src/skill.d.ts +0 -2
  213. package/dist/src/skill.js +0 -493
  214. package/dist/src/slug.d.ts +0 -2
  215. package/dist/src/slug.js +0 -6
  216. package/dist/src/social.d.ts +0 -2
  217. package/dist/src/social.js +0 -106
  218. package/dist/src/staff.d.ts +0 -2
  219. package/dist/src/staff.js +0 -104
  220. package/dist/src/start.d.ts +0 -15
  221. package/dist/src/start.js +0 -203
  222. package/dist/src/status.d.ts +0 -2
  223. package/dist/src/status.js +0 -52
  224. package/dist/src/substrate.d.ts +0 -2
  225. package/dist/src/substrate.js +0 -258
  226. package/dist/src/swap.d.ts +0 -93
  227. package/dist/src/swap.js +0 -622
  228. package/dist/src/tasks.d.ts +0 -2
  229. package/dist/src/tasks.js +0 -743
  230. package/dist/src/templates.d.ts +0 -1
  231. package/dist/src/templates.js +0 -213
  232. package/dist/src/trade.d.ts +0 -2
  233. package/dist/src/trade.js +0 -91
  234. package/dist/src/trail.d.ts +0 -2
  235. package/dist/src/trail.js +0 -41
  236. package/dist/src/validate.d.ts +0 -13
  237. package/dist/src/validate.js +0 -35
  238. package/dist/src/wallet-money.d.ts +0 -152
  239. package/dist/src/wallet-money.js +0 -564
  240. package/dist/src/wallet.d.ts +0 -167
  241. package/dist/src/wallet.js +0 -855
  242. package/dist/src/workflow.d.ts +0 -2
  243. package/dist/src/workflow.js +0 -166
  244. package/dist/src/write.d.ts +0 -43
  245. package/dist/src/write.js +0 -180
@@ -1,236 +0,0 @@
1
- /**
2
- * secrets-give.ts — `one secrets give NAME`: give a key to ONE from the terminal
3
- * (text/secrets.md deliverable 6; text/secrets-todo.md § C8).
4
- *
5
- * In order, all on this machine until the last step:
6
- *
7
- * 1 ONE's lock, read from ONE's vault (the single entry of its `readers`, plan D5) through
8
- * `@oneie/sdk/secrets-give` `readOneLock`. No answer is `no_one_lock`; a `--lock` that
9
- * differs is `lock_mismatch`. There is no constant to fall back to, ever.
10
- * 2 the value — from `.env.sealed` (opened in memory with your paper key, the C2 way) or
11
- * from piped stdin with `--stdin`. NEVER from argv: a word after NAME refuses exit 2,
12
- * unread, so a key never sits in shell history or `ps`
13
- * 3 sealed to ONE's lock alone (`sealForOne`, which reads ONE's vault itself and seals only to
14
- * what it names — a `--lock` that differs is `lock_mismatch` there too), over the canonical
15
- * plaintext naming this vault, NAME and --provider, so the blob is no other vault's, name's or
16
- * provider's key; the value dropped
17
- * 4 signed by an AGENT's own ed25519 key (`--signer-key <file>`, `giveData`) over
18
- * `canonicalSigned(payload)`. Your master key never signs a give: `--key` opens the
19
- * sealed file and does nothing else, and `--signer person` exits 2 — a person's touch is
20
- * on the seal page (C9)
21
- * 5 `secrets:give` through ask(), under your API key: the web side adds who you are and
22
- * forwards to the opener. The answer names the last four characters and nothing more.
23
- *
24
- * The body names who gives: `--as <actor>` — the actor your API key is, which the web side attests;
25
- * the opener refuses `subject_mismatch` for any other, so a captured give resent under another
26
- * session is never theirs.
27
- *
28
- * ONE's lock has one source: the reader of ONE's vault. Until C14 publishes it, the shipped reader
29
- * answers no lock and this command refuses `no_one_lock` — there is no environment or file
30
- * override (a test injects a reader through `giveLoaders.oneVault`, in code).
31
- *
32
- * A rotate names what it replaces: `--replaces <sigHash>` (the `sigHash` of the last give, or the
33
- * hash a `stale` refusal prints), signed into the body; a first give sends null. A captured give
34
- * re-sent after a rotate is therefore stale at the opener, never a rollback.
35
- *
36
- * Exits 0 given (or checked) · 1 refused · 2 usage. Prints no value, no line of the file, no key.
37
- */
38
- import { readFileSync } from 'node:fs';
39
- import { resolve } from 'node:path';
40
- import { Command } from 'commander';
41
- import { askPath } from './lib/api-path.js';
42
- import { authHeaders, jsonMode, resolveBase } from './lib/client.js';
43
- import { parseSealed } from './lib/env-sealed.js';
44
- import { ageModule, io, loadSecretsKey, MAX_INPUT_BYTES } from './lib/message-seal.js';
45
- const GIVE_SPEC = '@oneie/sdk/secrets-give'; // a variable, so a bundler/vite does not resolve it at build time
46
- /**
47
- * Swappable in tests (the message-seal.ts `loaders` shape): the cli resolves `@oneie/sdk` through
48
- * its own node_modules, which can be a published or main-tree SDK older than `./secrets-give`;
49
- * a test serves the source. `oneVault` is the reader of ONE's vault and the ONLY source of ONE's
50
- * lock — C14 reached testnet 2026-11-08: the fixture is the SDK's mirror of ONE's testnet vault
51
- * (ONE_VAULT_ID), pinned equal to the chain by one-vault-chain.test.ts. Nothing in the environment or on disk can name another lock (C8 repair 3); a
52
- * test injects a reader by assigning this field. `fetch` is the one network call.
53
- */
54
- export const giveLoaders = {
55
- sdk: () => import(/* @vite-ignore */ GIVE_SPEC),
56
- oneVault: async (sdk) => sdk.fixtureReader(),
57
- fetch: (input, init) => fetch(input, init),
58
- };
59
- const NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
60
- const VAULT_RE = /^0x[0-9a-fA-F]{64}$/;
61
- const HASH_RE = /^[0-9a-f]{64}$/;
62
- const MAX_VALUE = 64 * 1024;
63
- function fail(cmd, f, exit = 1) {
64
- if (jsonMode(cmd))
65
- process.stdout.write(JSON.stringify(f) + '\n');
66
- else
67
- process.stderr.write(`error ${f.error}\n`);
68
- process.exitCode = exit;
69
- }
70
- export async function giveAction(name, extra, o, c) {
71
- // the value is never an argument — refused before anything is read, and the word is never echoed
72
- if (extra.length > 0) {
73
- return fail(c, { ok: false, error: 'a key is never an argument (it would sit in your shell history) — pipe it with --stdin, or keep it in .env.sealed', code: 'value_in_argv' }, 2);
74
- }
75
- if (o.signer === 'person')
76
- return fail(c, { ok: false, error: 'the touch is on the seal page (C9)', code: 'person_signs_on_seal_page' }, 2);
77
- if (o.signer !== 'agent')
78
- return fail(c, { ok: false, error: '--signer is agent (your agent’s own key) — a person signs on the seal page (C9)', code: 'usage' }, 2);
79
- if (!NAME_RE.test(name))
80
- return fail(c, { ok: false, error: 'NAME is a .env name: letters, digits and _', code: 'usage' }, 2);
81
- if (!o.provider)
82
- return fail(c, { ok: false, error: '--provider is required (openai · anthropic · stripe · github · dataforseo)', code: 'usage' }, 2);
83
- if (!o.as || o.as.trim().length === 0 || o.as.length > 256) {
84
- return fail(c, { ok: false, error: 'name who gives: --as <actor> — the actor your API key is (ONE refuses any other as subject_mismatch)', code: 'usage' }, 2);
85
- }
86
- if (o.replaces !== undefined && !HASH_RE.test(o.replaces))
87
- return fail(c, { ok: false, error: '--replaces is the sigHash of the record ONE holds: 64 lower-case hex', code: 'usage' }, 2);
88
- // only an agent's own ed25519 key signs; the master (--key / ONE_WALLET_MNEMONIC) opens the file and nothing else
89
- if (!o.signerKey) {
90
- return fail(c, { ok: false, error: 'only an agent’s own ed25519 key signs a give (--signer-key <file>); your master key never does', code: 'no_signer' });
91
- }
92
- const sdk = await giveLoaders.sdk();
93
- let signerText;
94
- try {
95
- signerText = readFileSync(resolve(o.signerKey), 'utf8');
96
- }
97
- catch {
98
- return fail(c, { ok: false, error: `cannot read ${o.signerKey}`, code: 'bad_signer_key' });
99
- }
100
- const secret = sdk.decodeSignerKey(signerText);
101
- signerText = '';
102
- if (!secret)
103
- return fail(c, { ok: false, error: `${o.signerKey} is not an ed25519 key (suiprivkey1… or 64 hex) — a mnemonic or a key file never signs here`, code: 'bad_signer_key' });
104
- try {
105
- // 1 — ONE's lock, from ONE's vault; never a constant, never the flag alone (checked here before
106
- // anything is opened, and again by sealForOne, which seals to nothing else)
107
- const reader = await giveLoaders.oneVault(sdk);
108
- const one = await sdk.readOneLock(reader);
109
- if (!one.ok)
110
- return fail(c, { ok: false, error: `${one.detail} — nothing was sealed`, code: 'no_one_lock' });
111
- if (o.lock !== undefined && o.lock.trim() !== one.lock) {
112
- return fail(c, { ok: false, error: 'that is not the lock ONE’s vault names — nothing was sealed', code: 'lock_mismatch' });
113
- }
114
- // the vault: --vault, else the sealed file's header
115
- let vault = o.vault;
116
- let sealedText = null;
117
- if (!o.stdin || !vault) {
118
- try {
119
- const b = readFileSync(resolve(o.file));
120
- if (b.length > MAX_INPUT_BYTES)
121
- return fail(c, { ok: false, error: `${o.file} is too big`, code: 'too_big' });
122
- sealedText = b.toString('utf8');
123
- }
124
- catch {
125
- if (!o.stdin)
126
- return fail(c, { ok: false, error: `cannot read ${o.file}`, code: 'no_input' });
127
- }
128
- }
129
- const parsed = sealedText !== null ? parseSealed(sealedText) : null;
130
- if (parsed && 'ok' in parsed && !o.stdin)
131
- return fail(c, parsed);
132
- if (!vault && parsed && !('ok' in parsed))
133
- vault = parsed.vault;
134
- if (!vault || !VAULT_RE.test(vault))
135
- return fail(c, { ok: false, error: 'name your vault: --vault 0x… (64 hex), or a # vault line in the sealed file', code: 'bad_vault' });
136
- vault = vault.toLowerCase();
137
- // 2 — the value, in memory only
138
- let value;
139
- if (o.stdin) {
140
- const bytes = await io.readStdin();
141
- if (bytes.length > MAX_VALUE)
142
- return fail(c, { ok: false, error: 'stdin is too long to be a key', code: 'too_big' });
143
- value = new TextDecoder().decode(bytes).replace(/\r?\n$/, '');
144
- bytes.fill(0);
145
- }
146
- else {
147
- if (!parsed || 'ok' in parsed)
148
- return fail(c, { ok: false, error: `cannot read ${o.file}`, code: 'no_input' });
149
- const entry = parsed.entries.find((e) => e.name === name);
150
- if (!entry)
151
- return fail(c, { ok: false, error: `${name} is not in ${o.file}`, code: 'no_such_name' });
152
- const k = await loadSecretsKey(o.key);
153
- if ('ok' in k)
154
- return fail(c, k);
155
- try {
156
- const age = await ageModule();
157
- let plain;
158
- try {
159
- plain = age.decrypt(entry.file, [k.secret]);
160
- }
161
- catch {
162
- return fail(c, { ok: false, error: `${name} does not open with this key`, code: 'no_identity' });
163
- }
164
- value = new TextDecoder().decode(plain);
165
- plain.fill(0);
166
- }
167
- finally {
168
- k.secret.fill(0);
169
- }
170
- }
171
- if (value.length === 0)
172
- return fail(c, { ok: false, error: 'the value is empty', code: 'bad_key' });
173
- // 3 + 4 — bound to this vault and NAME, sealed to the lock ONE's vault names alone, then signed by the agent's key
174
- const s = await sdk.sealForOne(value, { vault, name, provider: o.provider }, reader, o.lock?.trim() ?? one.lock);
175
- value = '';
176
- if (!s.ok)
177
- return fail(c, { ok: false, error: `${s.detail} — nothing was sealed`, code: s.error });
178
- const data = sdk.giveData({ vault, name, provider: o.provider, sealed: s.sealed, mode: o.check ? 'check' : 'give', allowFlagged: o.allowFlagged === true, replaces: o.replaces ?? null, subject: o.as.trim() }, secret);
179
- // 5 — secrets:give through ask(); the web side adds who you are
180
- const base = resolveBase({ api: o.api });
181
- let res;
182
- try {
183
- res = await giveLoaders.fetch(askPath(base, 'secrets:give'), { method: 'POST', headers: authHeaders(), body: JSON.stringify({ data }) });
184
- }
185
- catch {
186
- return fail(c, { ok: false, error: `could not reach ${base}`, code: 'unreachable' });
187
- }
188
- let json = {};
189
- try {
190
- json = (await res.json());
191
- }
192
- catch {
193
- /* the status speaks */
194
- }
195
- const r = json['result'] ?? json;
196
- if (!res.ok || r['ok'] !== true) {
197
- const code = String(r['refused'] ?? r['error'] ?? `http_${res.status}`);
198
- const detail = typeof r['detail'] === 'string' ? ` (${r['detail']})` : '';
199
- // stale: ONE holds another record for this name — its sigHash is what a rotate signs as --replaces
200
- const hint = code === 'stale' && typeof r['detail'] === 'string' && HASH_RE.test(r['detail']) ? ` — to replace it, run again with --replaces ${r['detail']}` : '';
201
- return fail(c, { ok: false, error: `ONE did not take ${name}: ${code}${detail}${hint}`, code });
202
- }
203
- const given = (r['given'] ?? {});
204
- const stored = r['stored'] === true;
205
- if (jsonMode(c))
206
- process.stdout.write(JSON.stringify({ ok: true, stored, given }) + '\n');
207
- else {
208
- const tail = given.last4 ? `…${given.last4}` : '';
209
- process.stdout.write(`${stored ? 'given' : 'checked'} ${name} ${tail} ${given.provider ?? o.provider} check ${given.check?.status ?? '?'}${given.flagged ? ` flagged: ${given.flagged}` : ''}${stored && given.sigHash ? ` sigHash ${given.sigHash}` : ''}\n`);
210
- }
211
- }
212
- finally {
213
- secret.fill(0);
214
- }
215
- }
216
- /** The `give` subcommand, fresh per call (a Command has one parent). */
217
- export function buildGive() {
218
- return new Command('give')
219
- .description('Give a key to ONE — sealed here to the lock ONE’s vault names, signed by your agent’s key; afterwards only its last four characters show')
220
- .argument('<name>', 'The .env name of the key, e.g. OPENAI_API_KEY')
221
- .argument('[extra...]')
222
- .requiredOption('--provider <name>', 'openai · anthropic · stripe · github · dataforseo')
223
- .option('--vault <id>', 'Your vault (0x…); default: the # vault line of the sealed file')
224
- .option('--file <file>', 'The sealed file the value is read from', '.env.sealed')
225
- .option('--stdin', 'Read the value from piped stdin instead of the sealed file')
226
- .option('--key <file>', 'Key file that opens the sealed file (else ONE_WALLET_MNEMONIC). It never signs')
227
- .option('--signer <kind>', 'agent (the only signer here); a person signs on the seal page (C9)', 'agent')
228
- .option('--signer-key <file>', 'Your agent’s own ed25519 key: suiprivkey1… or 64 hex')
229
- .option('--lock <age1…>', 'The lock you expect ONE to have; refused unless ONE’s vault names the same')
230
- .option('--check', 'Check the key works and what it can do; store nothing')
231
- .option('--allow-flagged', 'Store a key Check it flags: one that can make other keys (an admin key, a full Stripe secret key, a GitHub admin: or key-making scope) or a GitHub token whose scopes cannot be read (scopes_unknown)')
232
- .option('--as <actor>', 'Who gives: the actor your API key is — signed into the body and checked against the caller ONE attests')
233
- .option('--replaces <sigHash>', 'Rotate: the sigHash of the record ONE holds for NAME (printed by the last give, or by a stale refusal)')
234
- .option('--api <url>', 'API base (default: ONE_API_URL or https://one.ie)')
235
- .action((name, extra, o, c) => giveAction(name, extra ?? [], o, c));
236
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * secrets-list.ts — `one secrets list`: your secrets desk from the terminal (text/secrets.md
3
- * § What an agent sees; the `secrets:list` receiver, C15).
4
- *
5
- * Read only. One POST to secrets:list through ask(); the web side reads WHO from the session or
6
- * the API key and D1 — this command sends nothing about the caller. Names and meters only: the
7
- * receiver never returns a value, and this prints only what it returned.
8
- *
9
- * Lending and Stop are not here. A person signs a grant or a Stop with a passkey on the seal
10
- * page, in a window of its own (plan D11, § Signatures); an agent may sign with its own ed25519
11
- * key, but no vault holds a grant-signer list until the D37 package is published (D46), so an
12
- * agent-signed grant has nothing to verify against yet.
13
- */
14
- import { Command } from 'commander';
15
- /** Swappable in tests. `fetch` is the one network call. */
16
- export declare const listLoaders: {
17
- fetch: (input: string, init: RequestInit) => Promise<Response>;
18
- };
19
- type Rec = Record<string, unknown>;
20
- /** The desk in a few human lines — never a value, never a full id where a short one reads. */
21
- export declare function deskLines(r: Rec): string[];
22
- export declare function listAction(o: {
23
- api?: string;
24
- }, c: Command): Promise<void>;
25
- /** The `list` subcommand, fresh per call (a Command has one parent). */
26
- export declare function buildList(): Command;
27
- export {};
@@ -1,84 +0,0 @@
1
- /**
2
- * secrets-list.ts — `one secrets list`: your secrets desk from the terminal (text/secrets.md
3
- * § What an agent sees; the `secrets:list` receiver, C15).
4
- *
5
- * Read only. One POST to secrets:list through ask(); the web side reads WHO from the session or
6
- * the API key and D1 — this command sends nothing about the caller. Names and meters only: the
7
- * receiver never returns a value, and this prints only what it returned.
8
- *
9
- * Lending and Stop are not here. A person signs a grant or a Stop with a passkey on the seal
10
- * page, in a window of its own (plan D11, § Signatures); an agent may sign with its own ed25519
11
- * key, but no vault holds a grant-signer list until the D37 package is published (D46), so an
12
- * agent-signed grant has nothing to verify against yet.
13
- */
14
- import { Command } from 'commander';
15
- import { askPath } from './lib/api-path.js';
16
- import { authHeaders, jsonMode, out, resolveBase } from './lib/client.js';
17
- /** Swappable in tests. `fetch` is the one network call. */
18
- export const listLoaders = {
19
- fetch: (input, init) => fetch(input, init),
20
- };
21
- /** D51: an "unlimited" lend signs this ceiling (UNLIMITED_PER_DAY in @oneie/sdk/secrets; kept here so the CLI runs on a published SDK that predates it). */
22
- const UNLIMITED_PER_DAY = 1_000_000;
23
- const leftLine = (l) => {
24
- const per = Number(l['perDay']);
25
- if (per === UNLIMITED_PER_DAY)
26
- return `${per - Number(l['left_today'] ?? per)} today · no daily limit (ceiling 1,000,000)`;
27
- return `${String(l['left_today'] ?? '?')}/${String(l['perDay'] ?? '?')} left today`;
28
- };
29
- const arr = (v) => (Array.isArray(v) ? v : []);
30
- /** The desk in a few human lines — never a value, never a full id where a short one reads. */
31
- export function deskLines(r) {
32
- const lines = [];
33
- const keys = arr(r['keys']);
34
- const lent = arr(r['lentToMe']);
35
- lines.push(`ok keys=${keys.length} lent_to_me=${lent.length} vaults=${arr(r['vaults']).length}${r['capped'] === true ? ' capped=true' : ''}`);
36
- for (const k of keys) {
37
- const grants = arr(k['grants']);
38
- const live = grants.filter((g) => g['stopped'] !== true).length;
39
- lines.push(`key ${String(k['name'] ?? '?')} ${String(k['provider'] ?? '?')} …${String(k['last4'] ?? '')} grants=${live} live/${grants.length}${k['flagged'] ? ` flagged=${String(k['flagged'])}` : ''}`);
40
- }
41
- for (const l of lent) {
42
- lines.push(`lent ${String(l['name'] ?? '?')} ${String(l['provider'] ?? '?')} from ${String(l['from'] ?? '?')} ${leftLine(l)} until ${String(l['until'] ?? '?')}${l['stopped'] === true ? ' STOPPED' : l['accepted'] === true ? '' : ' not accepted'}`);
43
- }
44
- for (const c of arr(r['composio'])) {
45
- if (!c['requireGrants'])
46
- lines.push(`composio ${String(c['group'] ?? '?')} running without a grant today=${String(c['noGrantToday'] ?? 0)}`);
47
- }
48
- return lines;
49
- }
50
- export async function listAction(o, c) {
51
- const base = resolveBase({ api: o.api });
52
- let res;
53
- try {
54
- res = await listLoaders.fetch(askPath(base, 'secrets:list'), { method: 'POST', headers: authHeaders(), body: JSON.stringify({ data: {} }) });
55
- }
56
- catch {
57
- return out(c, { ok: false, error: `could not reach ${base}`, code: 'unreachable' });
58
- }
59
- let json = {};
60
- try {
61
- json = (await res.json());
62
- }
63
- catch {
64
- /* the status speaks */
65
- }
66
- const r = json['result'] ?? json;
67
- if (!res.ok || r['ok'] !== true) {
68
- const code = String(r['refused'] ?? r['error'] ?? `http_${res.status}`);
69
- const why = code === 'opener_unbound' ? ' — the opener is not live on this host yet; nothing was read' : '';
70
- return out(c, { ok: false, error: `secrets:list refused: ${code}${why}`, code });
71
- }
72
- if (jsonMode(c)) {
73
- process.stdout.write(JSON.stringify(r) + '\n');
74
- return;
75
- }
76
- process.stdout.write(deskLines(r).join('\n') + '\n');
77
- }
78
- /** The `list` subcommand, fresh per call (a Command has one parent). */
79
- export function buildList() {
80
- return new Command('list')
81
- .description('Your secrets desk — the keys you gave ONE, who uses them, keys lent to you. Names and meters, never values')
82
- .option('--api <url>', 'API base (default: ONE_API_URL or https://one.ie)')
83
- .action(listAction);
84
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * secrets-run.ts — `one run -- <cmd…>` and `one secrets run -- <cmd…>`; `one secrets hash`.
3
- * (text/secrets.md deliverable 2; text/secrets-todo.md § C2.)
4
- *
5
- * Opens `.env.sealed` once, hands the values to ONE child process through its environment,
6
- * and writes nothing anywhere. The order is the point:
7
- *
8
- * 1. read the file's exact bytes, parse the header (no key yet)
9
- * 2. sha256 of those bytes must equal the `sealed_hash` of the vault named by `# vault`
10
- * — a file the vault does not know opens NOTHING (the key is not even loaded)
11
- * 3. open every value with the owner's paper identity, in memory
12
- * 4. spawn the child with `{ ...process.env, ...values }`, stdio inherited
13
- * 5. zero the decrypted buffers; exit with the child's exit code
14
- *
15
- * There is no flag that skips step 2. `process.env` of this process is never changed, no
16
- * value is printed, and an error names a variable or a line number, never a value or the key.
17
- */
18
- import { Command } from 'commander';
19
- interface RunOpts {
20
- file: string;
21
- key?: string;
22
- }
23
- export declare function runAction(cmdArgs: string[], o: RunOpts, c: Command): Promise<void>;
24
- /** The `run` subcommand, fresh per call (a Command has one parent). */
25
- export declare function buildRun(): Command;
26
- /** The top-level `one run`. */
27
- export declare const runCmd: () => Command;
28
- /** `one secrets hash [file]` — the sha256 an owner sets on their vault. Names no value, needs no key. */
29
- export declare function hashAction(file: string, _o: unknown, c: Command): Promise<void>;
30
- export declare function buildHash(): Command;
31
- export {};
@@ -1,182 +0,0 @@
1
- /**
2
- * secrets-run.ts — `one run -- <cmd…>` and `one secrets run -- <cmd…>`; `one secrets hash`.
3
- * (text/secrets.md deliverable 2; text/secrets-todo.md § C2.)
4
- *
5
- * Opens `.env.sealed` once, hands the values to ONE child process through its environment,
6
- * and writes nothing anywhere. The order is the point:
7
- *
8
- * 1. read the file's exact bytes, parse the header (no key yet)
9
- * 2. sha256 of those bytes must equal the `sealed_hash` of the vault named by `# vault`
10
- * — a file the vault does not know opens NOTHING (the key is not even loaded)
11
- * 3. open every value with the owner's paper identity, in memory
12
- * 4. spawn the child with `{ ...process.env, ...values }`, stdio inherited
13
- * 5. zero the decrypted buffers; exit with the child's exit code
14
- *
15
- * There is no flag that skips step 2. `process.env` of this process is never changed, no
16
- * value is printed, and an error names a variable or a line number, never a value or the key.
17
- */
18
- import { spawn } from 'node:child_process';
19
- import { createHash } from 'node:crypto';
20
- import { readFileSync } from 'node:fs';
21
- import { constants as osConstants } from 'node:os';
22
- import { resolve } from 'node:path';
23
- import { Command } from 'commander';
24
- import { jsonMode } from './lib/client.js';
25
- import { parseSealed } from './lib/env-sealed.js';
26
- import { ageModule, loadSecretsKey, MAX_INPUT_BYTES } from './lib/message-seal.js';
27
- import { readVault } from './lib/vault-read.js';
28
- function fail(cmd, f, exit = 1) {
29
- if (jsonMode(cmd))
30
- process.stdout.write(JSON.stringify(f) + '\n');
31
- else
32
- process.stderr.write(`error ${f.error}\n`);
33
- process.exitCode = exit;
34
- }
35
- const sha256 = (b) => createHash('sha256').update(b).digest('hex');
36
- function readSealedBytes(file) {
37
- try {
38
- const b = readFileSync(resolve(file));
39
- if (b.length > MAX_INPUT_BYTES)
40
- return { ok: false, error: `${file} is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB`, code: 'too_big' };
41
- return b;
42
- }
43
- catch {
44
- return { ok: false, error: `cannot read ${file}`, code: 'no_input' };
45
- }
46
- }
47
- /**
48
- * Was `--` the word that ended this command's own flags? Commander strips the `--`, so look
49
- * at the raw argv: between the command's name and the first `--` there may be only flags
50
- * (and the values of --file / --key). Any other word there means `one run bun dev`, where
51
- * `bun` would be taken for the command without the person ever saying where it starts.
52
- */
53
- function dashDashStartsCommand(c) {
54
- let root = c;
55
- while (root.parent)
56
- root = root.parent;
57
- // commander sets rawArgs on the root; its typings do not declare it
58
- const raw = (root.rawArgs ?? []).slice(2);
59
- const at = raw.indexOf(c.name());
60
- if (at < 0)
61
- return false;
62
- const rest = raw.slice(at + 1);
63
- const end = rest.indexOf('--');
64
- if (end < 0)
65
- return false;
66
- for (let i = 0; i < end; i++) {
67
- const t = rest[i];
68
- if (t === '--file' || t === '--key')
69
- i++;
70
- else if (!t.startsWith('-'))
71
- return false;
72
- }
73
- return true;
74
- }
75
- export async function runAction(cmdArgs, o, c) {
76
- if (cmdArgs.length === 0 || !dashDashStartsCommand(c)) {
77
- return fail(c, { ok: false, error: 'usage: one run [--file .env.sealed] [--key <file>] -- <command> [args…] (the -- is required)', code: 'usage' }, 2);
78
- }
79
- const bytes = readSealedBytes(o.file);
80
- if (!Buffer.isBuffer(bytes))
81
- return fail(c, bytes);
82
- const sealed = parseSealed(bytes.toString('utf8'));
83
- if ('ok' in sealed)
84
- return fail(c, sealed);
85
- // The check comes first and has no way around it.
86
- if (!sealed.vault) {
87
- return fail(c, { ok: false, error: `${o.file} names no vault (# vault <id>) — there is nothing to check it against, so it is not run`, code: 'unknown_file' });
88
- }
89
- const vault = await readVault(sealed.vault);
90
- if ('ok' in vault)
91
- return fail(c, { ok: false, error: vault.error, code: 'cannot_verify' });
92
- if (!vault.sealedHash) {
93
- return fail(c, { ok: false, error: 'the vault has no sealed hash for this file — set one with: one secrets hash, then set_sealed_hash', code: 'unknown_file' });
94
- }
95
- if (vault.sealedHash.toLowerCase() !== sha256(bytes)) {
96
- return fail(c, { ok: false, error: `${o.file} is not the file your vault knows — its hash differs, so nothing was opened`, code: 'unknown_file' });
97
- }
98
- const k = await loadSecretsKey(o.key);
99
- if ('ok' in k)
100
- return fail(c, k);
101
- const opened = [];
102
- try {
103
- const age = await ageModule();
104
- const dec = new TextDecoder();
105
- const values = {};
106
- for (const e of sealed.entries) {
107
- let plain;
108
- try {
109
- plain = age.decrypt(e.file, [k.secret]);
110
- }
111
- catch {
112
- return fail(c, { ok: false, error: `${e.name} does not open with this key`, code: 'no_identity' });
113
- }
114
- opened.push(plain);
115
- values[e.name] = dec.decode(plain);
116
- }
117
- const [bin, ...args] = cmdArgs;
118
- const code = await new Promise((done) => {
119
- const child = spawn(bin, args, { stdio: 'inherit', env: { ...process.env, ...values } });
120
- // spawn has copied the environment; nothing in this process needs a value any more.
121
- for (const p of opened)
122
- p.fill(0);
123
- for (const n of Object.keys(values))
124
- delete values[n];
125
- const forward = (sig) => () => {
126
- child.kill(sig);
127
- };
128
- const onInt = forward('SIGINT');
129
- const onTerm = forward('SIGTERM');
130
- process.on('SIGINT', onInt);
131
- process.on('SIGTERM', onTerm);
132
- const finish = (n) => {
133
- process.off('SIGINT', onInt);
134
- process.off('SIGTERM', onTerm);
135
- done(n);
136
- };
137
- child.on('error', (err) => {
138
- process.stderr.write(`error cannot start ${bin}: ${err.code ?? 'failed'}\n`);
139
- finish(127);
140
- });
141
- child.on('exit', (status, signal) => finish(status ?? 128 + (signal ? (osConstants.signals[signal] ?? 0) : 0)));
142
- });
143
- process.exitCode = code;
144
- }
145
- finally {
146
- for (const p of opened)
147
- p.fill(0);
148
- k.secret.fill(0);
149
- }
150
- }
151
- /** The `run` subcommand, fresh per call (a Command has one parent). */
152
- export function buildRun() {
153
- return new Command('run')
154
- .description('Run a command with the sealed values in its environment only — nothing is written to disk')
155
- .argument('[command...]', 'The command and its arguments, after --')
156
- .option('--file <file>', 'The sealed file', '.env.sealed')
157
- .option('--key <file>', 'Key file made by `one key new --out` (else ONE_WALLET_MNEMONIC). Never read from stdin')
158
- .allowUnknownOption() // a stray flag must reach the usage check (exit 2), not commander's own error
159
- .action((cmdArgs, o, c) => runAction(cmdArgs, o, c));
160
- }
161
- /** The top-level `one run`. */
162
- export const runCmd = () => buildRun();
163
- /** `one secrets hash [file]` — the sha256 an owner sets on their vault. Names no value, needs no key. */
164
- export async function hashAction(file, _o, c) {
165
- const bytes = readSealedBytes(file);
166
- if (!Buffer.isBuffer(bytes))
167
- return fail(c, bytes);
168
- const sealed = parseSealed(bytes.toString('utf8'));
169
- if ('ok' in sealed)
170
- return fail(c, sealed);
171
- const hash = sha256(bytes);
172
- if (jsonMode(c))
173
- process.stdout.write(JSON.stringify({ ok: true, file: resolve(file), sealedHash: hash }) + '\n');
174
- else
175
- process.stdout.write(hash + '\n');
176
- }
177
- export function buildHash() {
178
- return new Command('hash')
179
- .description("Print the sha256 of a sealed file — the value to set on your vault with set_sealed_hash")
180
- .argument('[file]', 'The sealed file', '.env.sealed')
181
- .action(hashAction);
182
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * secrets.ts — `one secrets seal | run | add-device | give | list`: the sealed .env.
3
- * (text/secrets.md deliverables 1 and 5; text/secrets-todo.md § C1.)
4
- *
5
- * `seal` is the one verb built here. It turns a plaintext .env into `.env.sealed` v1 —
6
- * names readable, one age file per value — and the readers of every value are ONLY the
7
- * owner's: the paper lock (the 24 words, HKDF `secrets-x25519-v1`) and the device locks
8
- * the owner listed in ~/.one/secrets-readers.json (`add-device`, C3, writes it). A lock
9
- * that is in neither is refused `not_your_reader`: no other person and no agent ever
10
- * holds a key.
11
- *
12
- * Like key-seal.ts it is offline, never prompts, answers `--json`, and exits 0 done /
13
- * 1 refused. It never prints a value, a line of the .env, or the key words; an error
14
- * names a variable or a line number. The key is a key file (`--key`) or
15
- * ONE_WALLET_MNEMONIC — never stdin.
16
- *
17
- * `run` and `hash` live in secrets-run.ts (C2). `add-device` (secrets-device.ts, C3) makes this
18
- * Mac a reader; a Secure Enclave lock among the readers seals through the `age` program
19
- * (lib/age-plugin.ts). `give` (secrets-give.ts, C8) hands a key to ONE, sealed to the lock ONE's
20
- * vault names and signed by an agent's own key. `list` (secrets-list.ts, C15) reads the desk —
21
- * secrets:list, names and meters, never values.
22
- */
23
- import { Command } from 'commander';
24
- import { type Fail } from './lib/message-seal.js';
25
- export declare function fail(cmd: Command, f: Fail): void;
26
- /** The owner's device-lock list. ONE_SECRETS_READERS moves it (tests); `add-device` (C3) writes it. */
27
- export declare function readersFile(): string;
28
- /**
29
- * The owner's device locks: a JSON array of locks, or `{ "readers": [...] }`, each entry a
30
- * lock string or `{ "lock": "…" }`. No file is no devices — the paper lock is then the only reader.
31
- */
32
- export declare function deviceLocks(path?: string): string[] | Fail;
33
- export declare function secretsCmd(): Command;