@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,150 +0,0 @@
1
- /**
2
- * message-seal.ts — the shared parts of `one key lock | seal | open | identity` and
3
- * `one write`: where the key comes from, where the note comes from, and what an age
4
- * failure is called in plain words.
5
- *
6
- * THE KEY NEVER COMES FROM STDIN OR A PROMPT. `seal` and `open` read the NOTE on stdin,
7
- * so the 24 words cannot also arrive there, and an agent runs these with nothing to
8
- * prompt. The words come from a key file (`--key`, the file `one key new --out` writes)
9
- * or from ONE_WALLET_MNEMONIC. No key is an error with a plain sentence, never a hang.
10
- *
11
- * THE SDK MODULES LOAD LAZILY, same reason as key-sweep.ts: key.ts registers these
12
- * commands, so a static import of `@oneie/sdk/age` would crash every `one key` verb —
13
- * `key new` included — on an installed SDK that predates the export.
14
- *
15
- * Derivation and format live in `@oneie/sdk/{age,message-key}`, which are copies of
16
- * one.ie/web's lib/key/{age,message-key}.ts; the SDK test fails if either drifts.
17
- */
18
- import { readFileSync } from 'node:fs';
19
- /** The most a note or a file may be read as — a ceiling on a caller-controlled read. */
20
- export const MAX_INPUT_BYTES = 8 * 1024 * 1024;
21
- export const ageModule = () => import('@oneie/sdk/age');
22
- export const messageKeyModule = () => import('@oneie/sdk/message-key');
23
- const SECRETS_KEY_SPEC = '@oneie/sdk/secrets-key'; // a variable, so a bundler/vite does not resolve it at build time
24
- /**
25
- * Swappable in tests: the cli resolves `@oneie/sdk` through its own node_modules, which can be a
26
- * published or main-tree SDK older than `./secrets-key` (C4). A test serves the source instead.
27
- */
28
- export const loaders = { secretsKey: () => import(/* @vite-ignore */ SECRETS_KEY_SPEC) };
29
- export const secretsKeyModule = () => loaders.secretsKey();
30
- /** Swappable in tests; the defaults are the process's real stdin. */
31
- export const io = {
32
- stdinIsTTY: () => Boolean(process.stdin.isTTY),
33
- async readStdin() {
34
- const chunks = [];
35
- let n = 0;
36
- for await (const c of process.stdin) {
37
- const b = Buffer.isBuffer(c) ? c : Buffer.from(c);
38
- n += b.length;
39
- if (n > MAX_INPUT_BYTES)
40
- throw new Error(`that is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB — too big to seal or open here`);
41
- chunks.push(b);
42
- }
43
- return new Uint8Array(Buffer.concat(chunks));
44
- },
45
- };
46
- /** The 24 words from a key file. JSON with a `mnemonic` field, or a bare phrase. */
47
- export function wordsFromKeyFile(path) {
48
- let raw;
49
- try {
50
- raw = readFileSync(path, 'utf8');
51
- }
52
- catch {
53
- return { ok: false, error: `cannot read the key file ${path} — make one with: one key new --out ${path} --yes-i-accept-plaintext-file`, code: 'no_key' };
54
- }
55
- const t = raw.trim();
56
- if (t.startsWith('{')) {
57
- try {
58
- const m = JSON.parse(t).mnemonic;
59
- if (typeof m === 'string' && m.trim())
60
- return m;
61
- }
62
- catch {
63
- /* fall through to the plain sentence */
64
- }
65
- return { ok: false, error: `${path} is not a key file — it has no "mnemonic" field`, code: 'no_key' };
66
- }
67
- return t;
68
- }
69
- /** The key's words: --key file, else ONE_WALLET_MNEMONIC. Never stdin, never a prompt. */
70
- export function keyWords(keyPath) {
71
- if (keyPath)
72
- return wordsFromKeyFile(keyPath);
73
- const env = process.env.ONE_WALLET_MNEMONIC?.trim();
74
- if (env)
75
- return env;
76
- return { ok: false, error: 'no key — pass --key key.json (made by: one key new --out key.json) or set ONE_WALLET_MNEMONIC', code: 'no_key' };
77
- }
78
- /** The message key for the given key source, or a plain failure. The caller zeroes `.secret`. */
79
- export async function loadMessageKey(keyPath) {
80
- const words = keyWords(keyPath);
81
- if (typeof words !== 'string')
82
- return words;
83
- const { messageKeyFromPhrase } = await messageKeyModule();
84
- try {
85
- return messageKeyFromPhrase(words);
86
- }
87
- catch (e) {
88
- // The SDK's message never repeats the phrase; this one stays in this sentence too.
89
- return { ok: false, error: e.message, code: 'bad_key' };
90
- }
91
- }
92
- /** The paper (secrets) key for the given key source, or a plain failure. The caller zeroes `.secret`. */
93
- export async function loadSecretsKey(keyPath) {
94
- const words = keyWords(keyPath);
95
- if (typeof words !== 'string')
96
- return words;
97
- let mod;
98
- try {
99
- mod = await secretsKeyModule();
100
- }
101
- catch {
102
- return { ok: false, error: 'this @oneie/sdk is too old for the paper key — update it: npm i -g oneie@latest', code: 'sdk_too_old' };
103
- }
104
- try {
105
- return mod.secretsKeyFromPhrase(words);
106
- }
107
- catch (e) {
108
- return { ok: false, error: e.message, code: 'bad_key' };
109
- }
110
- }
111
- /** A note from a file path, or stdin for `-` / no argument. Refuses a terminal rather than hang. */
112
- export async function readNote(arg) {
113
- if (arg && arg !== '-') {
114
- try {
115
- const b = readFileSync(arg);
116
- if (b.length > MAX_INPUT_BYTES)
117
- return { ok: false, error: `${arg} is more than ${MAX_INPUT_BYTES / (1024 * 1024)} MiB — too big to seal or open here`, code: 'too_big' };
118
- return new Uint8Array(b);
119
- }
120
- catch {
121
- return { ok: false, error: `cannot read ${arg}`, code: 'no_input' };
122
- }
123
- }
124
- if (io.stdinIsTTY())
125
- return { ok: false, error: 'nothing to read — pass a file, or pipe the note in (echo "hi" | one key seal --to age1…)', code: 'no_input' };
126
- try {
127
- return await io.readStdin();
128
- }
129
- catch (e) {
130
- return { ok: false, error: e.message, code: 'too_big' };
131
- }
132
- }
133
- /** Plain-word sentences for every way an age note can refuse to open. */
134
- export function ageFailure(e) {
135
- const code = e?.code;
136
- switch (code) {
137
- case 'no_identity':
138
- return { ok: false, error: 'this note is not for your key — it was sealed to a different lock', code };
139
- case 'tampered':
140
- return { ok: false, error: 'this note was changed after it was sealed, or it is damaged — it cannot be trusted', code };
141
- case 'unsupported':
142
- return { ok: false, error: 'this note is locked with a passphrase or an ssh key, which ONE does not open — use the age tool', code };
143
- case 'malformed':
144
- return { ok: false, error: 'this is not an age note, or it is cut short', code };
145
- case 'bad_key':
146
- return { ok: false, error: e.message, code };
147
- default:
148
- return { ok: false, error: 'could not open this note', code: 'failed' };
149
- }
150
- }
@@ -1,28 +0,0 @@
1
- import { type Net } from './network.js';
2
- export type NetFrom = 'flag' | 'env' | 'saved' | 'deploy';
3
- export type NetChoice = {
4
- ok: true;
5
- net: Net;
6
- from: NetFrom;
7
- } | {
8
- ok: false;
9
- error: 'bad_net' | 'network_unknown';
10
- message: string;
11
- };
12
- export declare const NET_FILE: string;
13
- export declare function savedNet(path?: string): Net | null;
14
- /** Save a choice, or clear it with null (`one network auto`). */
15
- export declare function saveNet(net: Net | null, path?: string): void;
16
- /** The page that carries the deploy's meta tag: the web host, never the gateway (api.one.ie serves no page). */
17
- export declare function webBase(api?: string): string;
18
- export interface NetDeps {
19
- env: Record<string, string | undefined>;
20
- saved: () => Net | null;
21
- deploy: (base: string) => Promise<Net | null>;
22
- }
23
- export declare function resolveNet(flag: string | undefined, api?: string, deps?: NetDeps): Promise<NetChoice>;
24
- /** The one line every money command prints: the network, and where the choice came from. */
25
- export declare function netLine(c: {
26
- net: Net;
27
- from: NetFrom;
28
- }): string;
@@ -1,72 +0,0 @@
1
- /**
2
- * net-choice.ts — which network a chain command acts on. ONE rule for every command that touches a chain:
3
- *
4
- * 1. --net <mainnet|testnet> this one command
5
- * 2. ONE_NETWORK=<mainnet|testnet> this shell
6
- * 3. `one network mainnet|testnet` saved in ~/.config/one/network, until `one network auto`
7
- * 4. the deploy what one.ie says it runs (<meta name="one:network">)
8
- *
9
- * The answer always says where it came from. When nothing above names a network and the deploy cannot be read,
10
- * the answer is a refusal (`network_unknown`), never a guess — a command that moves money must not assume testnet.
11
- * Words (a first run's "test money" line) keep their own testnet fallback in lib/network.ts learnNetwork.
12
- */
13
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
14
- import { dirname, join } from 'node:path';
15
- import { CONFIG_DIR } from './paths.js';
16
- import { readDeployNetwork } from './network.js';
17
- export const NET_FILE = join(CONFIG_DIR, 'network');
18
- const isNet = (v) => v === 'mainnet' || v === 'testnet';
19
- export function savedNet(path = NET_FILE) {
20
- try {
21
- const v = readFileSync(path, 'utf8').trim();
22
- return isNet(v) ? v : null;
23
- }
24
- catch {
25
- return null;
26
- }
27
- }
28
- /** Save a choice, or clear it with null (`one network auto`). */
29
- export function saveNet(net, path = NET_FILE) {
30
- if (net === null) {
31
- if (existsSync(path))
32
- rmSync(path);
33
- return;
34
- }
35
- mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
36
- writeFileSync(path, net + '\n', { mode: 0o600 });
37
- }
38
- /** The page that carries the deploy's meta tag: the web host, never the gateway (api.one.ie serves no page). */
39
- export function webBase(api) {
40
- const raw = (api ?? process.env.ONE_API_URL ?? process.env.ONEIE_BASE_URL ?? 'https://one.ie').replace(/\/$/, '');
41
- try {
42
- const u = new URL(raw);
43
- if (u.hostname.startsWith('api.'))
44
- u.hostname = u.hostname.slice(4);
45
- return u.origin;
46
- }
47
- catch {
48
- return 'https://one.ie';
49
- }
50
- }
51
- const defaultDeps = () => ({ env: process.env, saved: () => savedNet(), deploy: (b) => readDeployNetwork(b) });
52
- export async function resolveNet(flag, api, deps = defaultDeps()) {
53
- if (flag !== undefined) {
54
- return isNet(flag) ? { ok: true, net: flag, from: 'flag' } : { ok: false, error: 'bad_net', message: `--net must be mainnet or testnet, not '${flag}'` };
55
- }
56
- const env = deps.env.ONE_NETWORK?.trim();
57
- if (env)
58
- return isNet(env) ? { ok: true, net: env, from: 'env' } : { ok: false, error: 'bad_net', message: `ONE_NETWORK must be mainnet or testnet, not '${env}'` };
59
- const saved = deps.saved();
60
- if (saved)
61
- return { ok: true, net: saved, from: 'saved' };
62
- const base = webBase(api);
63
- const deployed = await deps.deploy(base);
64
- if (deployed)
65
- return { ok: true, net: deployed, from: 'deploy' };
66
- return { ok: false, error: 'network_unknown', message: `could not read which network ${base} runs, and nothing names one — pass --net mainnet|testnet, set ONE_NETWORK, or run \`one network mainnet|testnet\`` };
67
- }
68
- /** The one line every money command prints: the network, and where the choice came from. */
69
- export function netLine(c) {
70
- const why = { flag: '--net', env: 'ONE_NETWORK', saved: '`one network`', deploy: 'the deploy' }[c.from];
71
- return c.net === 'mainnet' ? `network MAINNET — real money (from ${why})` : `network testnet — test money (from ${why})`;
72
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Which Sui network is the API this CLI is talking to on? One's answer is the deploy's own: Layout.astro
3
- * writes `<meta name="one:network" content="testnet|mainnet">` into every page from the worker's `NETWORK`
4
- * (one.ie/web/src/lib/sui-network.ts `DEPLOY_NET_META_NAME`), so the CLI asks the home page — the one door
5
- * that carries it today. There is no status route for it.
6
- *
7
- * It only ever shapes the WORDS of a first run (the faucet line, "test money"), never a command's
8
- * behaviour, and it must never block or fail a run: a slow, failing or unreadable answer is `testnet`
9
- * (the display rule: show the network where a mistake costs nothing). The home page is large, so the
10
- * body is read only until the meta tag or `</head>` appears, then dropped.
11
- */
12
- export type Net = 'testnet' | 'mainnet';
13
- /** Parse the meta tag out of the start of a page. Null when it is not there (yet). */
14
- export declare function netFromHtml(html: string): Net | null;
15
- /**
16
- * The deploy's network, or NULL when it cannot be read (slow, down, no tag). The strict read: a command that
17
- * moves money refuses on null rather than guessing (lib/net-choice.ts). learnNetwork below is the words-only
18
- * reading of the same answer, where null becomes `testnet`.
19
- */
20
- export declare function readDeployNetwork(api: string, f?: typeof fetch, timeoutMs?: number): Promise<Net | null>;
21
- /** Words only: the deploy's network, `testnet` when it cannot be read (show the network where a mistake costs nothing). */
22
- export declare function learnNetwork(api: string, f?: typeof fetch, timeoutMs?: number): Promise<Net>;
@@ -1,50 +0,0 @@
1
- /** Parse the meta tag out of the start of a page. Null when it is not there (yet). */
2
- export function netFromHtml(html) {
3
- const tag = /<meta\b[^>]*\bname=["']one:network["'][^>]*>/i.exec(html)?.[0];
4
- const content = tag ? /\bcontent=["']([^"']*)["']/i.exec(tag)?.[1] : undefined;
5
- if (content === 'mainnet' || content === 'testnet')
6
- return content;
7
- return null;
8
- }
9
- /**
10
- * The deploy's network, or NULL when it cannot be read (slow, down, no tag). The strict read: a command that
11
- * moves money refuses on null rather than guessing (lib/net-choice.ts). learnNetwork below is the words-only
12
- * reading of the same answer, where null becomes `testnet`.
13
- */
14
- export async function readDeployNetwork(api, f = fetch, timeoutMs = 3000) {
15
- const ctl = new AbortController();
16
- const timer = setTimeout(() => ctl.abort(), timeoutMs);
17
- try {
18
- const res = await f(`${api.replace(/\/$/, '')}/`, { signal: ctl.signal, headers: { accept: 'text/html' } });
19
- if (!res.ok || !res.body)
20
- return null;
21
- const reader = res.body.getReader();
22
- const dec = new TextDecoder();
23
- let seen = '';
24
- while (seen.length < 131_072) {
25
- const { done, value } = await reader.read();
26
- if (done)
27
- break;
28
- seen += dec.decode(value, { stream: true });
29
- const net = netFromHtml(seen);
30
- if (net) {
31
- void reader.cancel().catch(() => { });
32
- return net;
33
- }
34
- if (seen.includes('</head>'))
35
- break;
36
- }
37
- void reader.cancel().catch(() => { });
38
- return null;
39
- }
40
- catch {
41
- return null;
42
- }
43
- finally {
44
- clearTimeout(timer);
45
- }
46
- }
47
- /** Words only: the deploy's network, `testnet` when it cannot be read (show the network where a mistake costs nothing). */
48
- export async function learnNetwork(api, f = fetch, timeoutMs = 3000) {
49
- return (await readDeployNetwork(api, f, timeoutMs)) ?? 'testnet';
50
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * `one next` and `one learn [topic]`: where an agent is, and the one thing to do now.
3
- *
4
- * Two readers, one set of facts. BRIAN is a young person starting out: plain words,
5
- * one step, the wins he already has. A YOUNG AGENT has just been born with `npx oneie`:
6
- * it needs to know who it is, its keys, its wallets, its limit, how to sell, how to be
7
- * paid, how to ask its person for more, what it must never do, and where to learn next.
8
- *
9
- * PURE and LOCAL. Every fact comes from the folder (`.one/journey.json`, the key and
10
- * vault files' presence) through `NextFacts`; nothing here touches the network, so the
11
- * "what now" door answers instantly and cannot hang.
12
- *
13
- * NEVER PRINTED: the owner link (a bearer credential, kept in journey.json), any key,
14
- * the 24 words. This file never receives them, except the state object, from which it
15
- * reads only workspace, addresses, products and the sale count.
16
- *
17
- * Claims follow text/one.md § Words we keep true: "We take nothing from a card sale;
18
- * the card network takes its fee", never "0% fees". The course is text/course.md
19
- * § Financial superpowers, trained in pairs: Start (free, lessons 1–3), Sold (4–8).
20
- */
21
- import type { JourneyState } from './journey.js';
22
- export type Reader = 'agent' | 'person';
23
- /** What the folder says, read by `src/next.ts`. Presence only for secrets: never their contents. */
24
- export interface NextFacts {
25
- state: JourneyState | null;
26
- /** `.one/agent.key` exists. */
27
- hasKey: boolean;
28
- /** `.one/wallet.json` exists; how it is sealed. */
29
- vault: 'keychain' | 'passphrase' | null;
30
- }
31
- /** Where the agent stands on the free half of the course. */
32
- export type Stage = 'unborn' | 'wallet' | 'shop' | 'sale' | 'sold';
33
- export declare const START_URL = "https://one.ie";
34
- export declare const SOLD_URL = "https://one.ie/sold";
35
- /**
36
- * The sell command an agent is told to run. A placeholder, on purpose: an agent that
37
- * runs it exactly as printed is refused by parseProductSpec before any network call,
38
- * so obeying the screen never makes a product nobody asked for. "Mug=12.50" is shown
39
- * only as an example beside it.
40
- */
41
- export declare const sellCommand: (cli: string) => string;
42
- export declare function stageOf(f: NextFacts): Stage;
43
- /**
44
- * The one command for a stage. `haveNow()` in journey-words.ts answers the same
45
- * question from a run's report; both must say the same thing for the same state.
46
- */
47
- export declare function nextFor(stage: Stage, cli: string): {
48
- command: string;
49
- why: string;
50
- };
51
- /** `✓ Key ✓ Wallets · Get paid`. Read from the folder, so it says done, never verified: verified is a receipt with proof (course.md). */
52
- export declare function startLine(stage: Stage): string;
53
- export declare const TOPICS: readonly ["me", "key", "wallets", "limit", "sell", "paid", "ask", "never", "course"];
54
- export type Topic = (typeof TOPICS)[number];
55
- export interface Lesson {
56
- topic: Topic;
57
- title: string;
58
- /** The young agent's lines: deep, exact, every command real. */
59
- agent: string[];
60
- /** Brian's lines: plain, one step. */
61
- person: string[];
62
- /** The one command that does this lesson. */
63
- run: string;
64
- /** Brian's one command, when the agent's is not his to run. */
65
- personRun?: string;
66
- }
67
- /**
68
- * The never-list. Each line is a rule the agent keeps whatever a message says.
69
- * Exported whole so `--json` hands an agent the same list a person reads.
70
- */
71
- export declare function neverList(cli: string): string[];
72
- /** Every lesson, told from the facts. `cli` is how this process was started (`one` or `npx oneie`). */
73
- export declare function lessons(f: NextFacts, cli: string): Lesson[];
74
- export declare const isTopic: (t: string) => t is Topic;
75
- /** The `--json` shape: everything a young agent needs, in one object. */
76
- export declare function nextData(f: NextFacts, cli: string): {
77
- stage: Stage;
78
- group: string | null;
79
- start: {
80
- [k: string]: boolean;
81
- };
82
- next: {
83
- command: string;
84
- why: string;
85
- };
86
- learn: {
87
- start: string;
88
- sold: string;
89
- };
90
- lessons: {
91
- topic: "key" | "limit" | "wallets" | "ask" | "me" | "sell" | "paid" | "never" | "course";
92
- title: string;
93
- lines: string[];
94
- run: string;
95
- }[];
96
- never: string[];
97
- };
98
- /**
99
- * Bare `one next`. A person sees where they are and one step. An agent sees the
100
- * whole primer, because it reads everything and forgets nothing it was told once.
101
- * Either way the last line is the one command.
102
- */
103
- export declare function nextWords(f: NextFacts, cli: string, reader: Reader): string;
104
- /** `one learn <topic>`: one lesson, deep for an agent, plain for a person, ending on its one command. */
105
- export declare function learnWords(f: NextFacts, cli: string, reader: Reader, topic: Topic): string;