@oneie/cli 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,245 +0,0 @@
1
- /**
2
- * The journey bare `npx oneie` walks: key → products → test sale → handover.
3
- *
4
- * Pure on purpose, like `shop-init.ts`: every round trip arrives through `deps`,
5
- * so the whole walk is exercised without a network, a key or a Keychain.
6
- * `src/start.ts` is the wiring and holds no logic of its own.
7
- *
8
- * RESUMABLE BY READ-BACK. Each step writes what it proved into the folder's
9
- * journey state before the next one starts, and a re-run skips every step whose
10
- * proof is already there. The test sale waits on a person paying in a browser,
11
- * so a run that ends at `pending` is the normal shape, not an error: pay, run it
12
- * again, and it picks up at the sale.
13
- *
14
- * THE WORDS NEVER REACH THIS PROCESS'S STDOUT. The key step mints the agent's
15
- * wallet and seals it (Keychain, or a passphrase typed at a terminal) through
16
- * `deps.wallet`; what comes back is addresses and a file path. Nothing here can
17
- * print what it never holds. The person who receives the shop makes their own
18
- * key in their own browser when they open the handover link.
19
- *
20
- * A SALE IS COUNTED, NEVER CLAIMED. A printed checkout link is not a sale. The
21
- * step is done only when `storefront:stats` reads back a purchase.
22
- */
23
- export const TEST_CARD = '4242 4242 4242 4242 · any future expiry · any CVC · any postcode';
24
- /**
25
- * Measured 2026-11-03 (text/agent-path.md § 6): Stripe's webhook counted a paid sale
26
- * 3.2 s after the receipt. A re-run straight after paying read 0 and stopped. 20 s at
27
- * 2 s a read covers that six times over without holding a run that will never sell.
28
- */
29
- export const RERUN_WAIT_S = 20;
30
- export const RERUN_POLL_MS = 2000;
31
- export const DEFAULT_PRODUCT = { name: 'Test product', amount: 100, currency: 'usd' };
32
- /** `"Name=9.99"` → a product in minor units. A spec that is not that shape is refused by name. */
33
- export function parseProductSpec(raw, currency = 'usd') {
34
- const at = raw.lastIndexOf('=');
35
- const name = at > 0 ? raw.slice(0, at).trim() : '';
36
- const price = at > 0 ? raw.slice(at + 1).trim() : '';
37
- if (!name || !/^\d+(\.\d{1,2})?$/.test(price)) {
38
- return { ok: false, error: `--product takes "Name=price" in major units, e.g. "Mug=12.50" (got "${raw}")` };
39
- }
40
- const amount = Math.round(Number(price) * 100);
41
- if (amount < 50)
42
- return { ok: false, error: `--product "${name}": the card rail cannot charge under 0.50` };
43
- return { ok: true, product: { name, amount, currency: currency.toLowerCase() } };
44
- }
45
- /** One reading of an `/api/ask` answer. A dissolve and a refusal both arrive as 200. */
46
- export function readAnswer(env, receiver) {
47
- if (env.outcome && env.outcome !== 'result')
48
- return { ok: false, error: `${receiver} ${env.outcome}${env.error ? `: ${env.error}` : ''}` };
49
- const result = env.result;
50
- if (!result)
51
- return { ok: false, error: env.error ?? `${receiver} returned no result` };
52
- if (result.ok === false || typeof result.error === 'string') {
53
- return { ok: false, error: `${receiver}: ${String(result.error ?? 'refused')}` };
54
- }
55
- return { ok: true, result };
56
- }
57
- const productUrl = (api, workspace, pid) => `${api}/u/${workspace}/shop/${pid}`;
58
- async function keyStep(deps, o, state) {
59
- let key = state ? deps.key() : null;
60
- let reused = Boolean(state && key);
61
- // Never mint over a key already in this folder: `writeKeyFolder` replaces it,
62
- // and the workspace it opened would be lost with it.
63
- const onDisk = deps.existingKey();
64
- if (state && !key) {
65
- return { report: { step: 'key', status: 'failed', detail: { workspace: state.workspace, error: `the journey here is for ${state.workspace}, but its key is missing or unreadable — move .one/ aside to start a new one` } }, state: null, key: null };
66
- }
67
- if (!state && onDisk !== null) {
68
- return { report: { step: 'key', status: 'failed', detail: { error: `this folder already holds a key${onDisk ? ` for ${onDisk}` : ''} that no journey made — run in a fresh folder, or move .one/ aside` } }, state: null, key: null };
69
- }
70
- if (!state) {
71
- // The owner invite is asked for at birth because it can only be minted there:
72
- // an agent key is walled off `manage_members` afterwards. With an email the
73
- // server sends it; without one it still returns the link to print.
74
- const body = { name: o.name, live: true, invite: { role: 'owner', ...(o.email ? { email: o.email } : {}) } };
75
- const res = await deps.provision(body);
76
- const j = res.json;
77
- if (!res.ok || typeof j.apiKey !== 'string' || typeof j.workspace !== 'string') {
78
- return { report: { step: 'key', status: 'failed', detail: { error: String(j.error ?? `provision refused (${res.status})`) } }, state: null, key: null };
79
- }
80
- const saved = deps.saveKey({
81
- apiKey: j.apiKey,
82
- regKey: typeof j.regKey === 'string' ? j.regKey : undefined,
83
- workspace: j.workspace,
84
- uid: typeof j.uid === 'string' ? j.uid : undefined,
85
- expiresAt: typeof j.expiresAt === 'number' ? j.expiresAt : undefined,
86
- });
87
- if (!saved.ok) {
88
- // The workspace exists but its key could not be kept — say so; a re-run mints another.
89
- return { report: { step: 'key', status: 'failed', detail: { workspace: j.workspace, error: saved.error ?? 'key folder not written' } }, state: null, key: null };
90
- }
91
- state = {
92
- v: 1,
93
- api: o.api,
94
- workspace: j.workspace,
95
- ...(typeof j.uid === 'string' ? { uid: j.uid } : {}),
96
- ...(typeof j.inviteUrl === 'string' ? { inviteUrl: j.inviteUrl } : {}),
97
- ...(o.email ? { email: o.email } : {}),
98
- };
99
- deps.save(state);
100
- key = (typeof j.regKey === 'string' && j.regKey) || j.apiKey;
101
- reused = false;
102
- }
103
- if (!state.wallet?.ok) {
104
- state.wallet = await deps.wallet({ key: key, workspace: state.workspace });
105
- deps.save(state);
106
- reused = false;
107
- }
108
- const w = state.wallet;
109
- const detail = { workspace: state.workspace };
110
- if (w.ok) {
111
- detail.wallet = w.file;
112
- detail.sealed = w.keychain ? 'Apple Keychain — Touch ID opens it' : 'passphrase';
113
- detail.addresses = w.addresses;
114
- detail.paper = 'run `npx oneie wallet paper` in your own terminal to write the 24 words down — they are never printed here';
115
- }
116
- else {
117
- detail.error = `wallet: ${w.error ?? 'not made'}`;
118
- }
119
- return { report: { step: 'key', status: w.ok ? 'done' : 'failed', reused, detail }, state, key };
120
- }
121
- async function productsStep(deps, o, state, key) {
122
- let wrote = false;
123
- if (!state.storefront) {
124
- const r = readAnswer(await deps.ask(key, 'storefront:enable', { slug: state.workspace, enabled: true, testMode: true }), 'storefront:enable');
125
- if (!r.ok)
126
- return { step: 'products', status: 'failed', detail: { error: r.error } };
127
- state.storefront = true;
128
- deps.save(state);
129
- wrote = true;
130
- }
131
- const have = state.products ?? [];
132
- // Resumed by name: a run that made one of two products and then failed makes
133
- // only the missing one next time, never a duplicate and never neither.
134
- const wanted = o.products.length > 0 ? o.products : have.length > 0 ? [] : [DEFAULT_PRODUCT];
135
- const specs = wanted.filter((p) => !have.some((h) => h.name === p.name));
136
- for (const p of specs) {
137
- const r = readAnswer(await deps.ask(key, 'products:create', {
138
- slug: state.workspace,
139
- name: p.name,
140
- status: 'active',
141
- prices: [{ unit_amount: p.amount, currency: p.currency, is_default: true }],
142
- }), 'products:create');
143
- if (!r.ok)
144
- return { step: 'products', status: 'failed', detail: { error: r.error, created: have.length } };
145
- const pid = String(r.result.pid ?? '');
146
- if (!pid)
147
- return { step: 'products', status: 'failed', detail: { error: 'products:create answered without a pid', created: have.length } };
148
- have.push({ ...p, pid, ...(r.result.ppid ? { ppid: String(r.result.ppid) } : {}), url: productUrl(state.api, state.workspace, pid) });
149
- state.products = have;
150
- deps.save(state);
151
- wrote = true;
152
- }
153
- return {
154
- step: 'products',
155
- status: 'done',
156
- reused: !wrote,
157
- detail: { mode: 'test money', products: have.map((p) => `${p.name} ${(p.amount / 100).toFixed(2)} ${p.currency.toUpperCase()} ${p.url}`) },
158
- };
159
- }
160
- async function saleStep(deps, o, state, key, rerun) {
161
- if (state.sale)
162
- return { step: 'sale', status: 'done', reused: true, detail: { purchases: state.sale.purchases } };
163
- // An explicit --wait wins; unset, only a re-run waits (and never NaN — an unset wait
164
- // once made the deadline NaN, and `now >= NaN` is never true).
165
- const asked = Number(o.waitSeconds);
166
- const waitS = o.waitSeconds !== undefined && Number.isFinite(asked) ? Math.max(0, asked) : rerun ? RERUN_WAIT_S : 0;
167
- const pollMs = o.pollMs ?? (o.waitSeconds === undefined ? RERUN_POLL_MS : 5000);
168
- const deadline = deps.now() + waitS * 1000;
169
- for (;;) {
170
- const r = readAnswer(await deps.ask(key, 'storefront:stats', { slug: state.workspace }), 'storefront:stats');
171
- if (!r.ok)
172
- return { step: 'sale', status: 'failed', detail: { error: r.error } };
173
- // An answer with no count is not zero purchases: an entitlement or credit gate
174
- // answers with its own shape, and reading that as 0 would keep the person paying
175
- // into a step that can never turn done.
176
- if (typeof r.result.purchases !== 'number') {
177
- return { step: 'sale', status: 'failed', detail: { error: `storefront:stats answered without a purchase count (keys: ${Object.keys(r.result).join(', ') || 'none'})` } };
178
- }
179
- const purchases = r.result.purchases;
180
- if (purchases >= 1) {
181
- state.sale = {
182
- purchases,
183
- ...(typeof r.result.revenue_cents === 'number' ? { revenueCents: r.result.revenue_cents } : {}),
184
- at: deps.now(),
185
- };
186
- deps.save(state);
187
- return { step: 'sale', status: 'done', detail: { purchases, read: 'storefront:stats' } };
188
- }
189
- if (deps.now() >= deadline)
190
- break;
191
- await deps.sleep(pollMs);
192
- }
193
- const first = state.products?.[0];
194
- return {
195
- step: 'sale',
196
- status: 'pending',
197
- detail: { pay: first?.url ?? `${state.api}/u/${state.workspace}/shop`, card: TEST_CARD, purchases: 0 },
198
- };
199
- }
200
- function handoverStep(state, saleDone) {
201
- if (!saleDone)
202
- return { step: 'handover', status: 'waiting', detail: { on: 'the test sale' } };
203
- if (!state.inviteUrl) {
204
- return {
205
- step: 'handover',
206
- status: 'failed',
207
- detail: {
208
- error: 'no owner link: the server minted none when this workspace was born, and an agent key cannot mint one afterwards',
209
- fix: 'run `npx oneie --email <owner>` in a fresh folder — the link is minted at birth',
210
- },
211
- };
212
- }
213
- return {
214
- step: 'handover',
215
- status: 'done',
216
- detail: {
217
- link: state.inviteUrl,
218
- ...(state.email ? { emailed: state.email } : {}),
219
- note: 'anyone holding this link can claim the owner seat — send it only to that person. It works once and lasts 7 days',
220
- },
221
- };
222
- }
223
- export async function runJourney(deps, o) {
224
- const steps = [];
225
- const k = await keyStep(deps, o, deps.load());
226
- steps.push(k.report);
227
- if (!k.state || !k.key)
228
- return { ok: false, steps, next: 'fix what stopped the key step above, then run `npx oneie` again' };
229
- const state = k.state;
230
- const products = await productsStep(deps, o, state, k.key);
231
- steps.push(products);
232
- if (products.status !== 'done') {
233
- return { ok: false, workspace: state.workspace, steps, next: 'fix what stopped the product step above, then run `npx oneie` again' };
234
- }
235
- // A re-run: the shop already had its products before this run, so someone was sent to pay.
236
- const sale = await saleStep(deps, o, state, k.key, products.reused === true);
237
- steps.push(sale);
238
- const handover = handoverStep(state, sale.status === 'done');
239
- steps.push(handover);
240
- const failed = steps.some((s) => s.status === 'failed');
241
- const next = sale.status === 'pending'
242
- ? `pay with the test card at the link above, then run \`npx oneie\` again. It waits up to ${RERUN_WAIT_S} seconds for the sale to land. Or run \`npx oneie --wait 30\` to wait here while you pay`
243
- : undefined;
244
- return { ok: !failed, workspace: state.workspace, steps, ...(next ? { next } : {}) };
245
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * key-receipt.ts — the agent's half of the key receipt (text/handover-course.md; the
3
- * person's half is one.ie/web/src/lib/key/draw-receipt.ts).
4
- *
5
- * `one key new` makes no network call. This measures that instead of saying it: from the
6
- * start of the key command to the moment the key exists, it counts every connection,
7
- * DNS lookup and datagram the process opens. The network is NOT switched off, and
8
- * nothing here needs it to be: the number is zero because nothing asks.
9
- *
10
- * What it can and cannot see. It counts inside THIS process. It cannot see another
11
- * process, and `npx` may download the CLI before the key command starts: that is the
12
- * package manager, not the key. So the receipt carries the check that does not trust
13
- * it, a command that makes the network unavailable and runs the same key command.
14
- *
15
- * Nothing secret is on it: no words, no key, no addresses, no hostname, no user name.
16
- */
17
- export interface KeyReceipt {
18
- lane: 'agent';
19
- madeAt: string;
20
- tookMs: number;
21
- /** Connections + DNS lookups + datagrams opened by this process while the key was made. */
22
- requests: number;
23
- counted: {
24
- connections: number;
25
- dnsLookups: number;
26
- datagrams: number;
27
- };
28
- computer: {
29
- chip: string | null;
30
- cores: number;
31
- memoryGb: number;
32
- platform: string;
33
- arch: string;
34
- node: string;
35
- };
36
- network: {
37
- online: boolean;
38
- interfaces: number;
39
- };
40
- check: string[];
41
- }
42
- /** The check that does not trust this file: the network made unavailable, same key command. */
43
- export declare const CHECKS: readonly string[];
44
- export declare function startKeyReceipt(): {
45
- seal: () => KeyReceipt;
46
- };
47
- /** The receipt as text: a box, 60 characters wide, no colour, safe in a log. */
48
- export declare function renderKeyReceipt(r: KeyReceipt): string;
@@ -1,116 +0,0 @@
1
- /**
2
- * key-receipt.ts — the agent's half of the key receipt (text/handover-course.md; the
3
- * person's half is one.ie/web/src/lib/key/draw-receipt.ts).
4
- *
5
- * `one key new` makes no network call. This measures that instead of saying it: from the
6
- * start of the key command to the moment the key exists, it counts every connection,
7
- * DNS lookup and datagram the process opens. The network is NOT switched off, and
8
- * nothing here needs it to be: the number is zero because nothing asks.
9
- *
10
- * What it can and cannot see. It counts inside THIS process. It cannot see another
11
- * process, and `npx` may download the CLI before the key command starts: that is the
12
- * package manager, not the key. So the receipt carries the check that does not trust
13
- * it, a command that makes the network unavailable and runs the same key command.
14
- *
15
- * Nothing secret is on it: no words, no key, no addresses, no hostname, no user name.
16
- */
17
- import dgram from 'node:dgram';
18
- import dns from 'node:dns';
19
- import net from 'node:net';
20
- import os from 'node:os';
21
- import { performance } from 'node:perf_hooks';
22
- /** The check that does not trust this file: the network made unavailable, same key command. */
23
- export const CHECKS = [
24
- 'macOS sandbox-exec -p \\',
25
- " '(version 1)(allow default)(deny network*)' \\",
26
- ' one key new --out k.json \\',
27
- ' --yes-i-accept-plaintext-file',
28
- 'Linux unshare -rn one key new --out k.json \\',
29
- ' --yes-i-accept-plaintext-file',
30
- ' (the Linux line is not yet measured)',
31
- ];
32
- export function startKeyReceipt() {
33
- const t0 = performance.now();
34
- const counted = { connections: 0, dnsLookups: 0, datagrams: 0 };
35
- const undo = [];
36
- // Each patch counts and passes through, so the measurement never changes what runs.
37
- const origConnect = net.Socket.prototype.connect;
38
- net.Socket.prototype.connect = function (...a) {
39
- counted.connections++;
40
- return origConnect.apply(this, a);
41
- };
42
- undo.push(() => { net.Socket.prototype.connect = origConnect; });
43
- const origSend = dgram.Socket.prototype.send;
44
- dgram.Socket.prototype.send = function (...a) {
45
- counted.datagrams++;
46
- return origSend.apply(this, a);
47
- };
48
- undo.push(() => { dgram.Socket.prototype.send = origSend; });
49
- const origLookup = dns.lookup;
50
- dns.lookup = function (...a) {
51
- counted.dnsLookups++;
52
- return origLookup.apply(dns, a);
53
- };
54
- undo.push(() => { dns.lookup = origLookup; });
55
- return {
56
- seal() {
57
- const tookMs = Math.round(performance.now() - t0);
58
- for (const u of undo.splice(0))
59
- u();
60
- const cpus = os.cpus();
61
- const interfaces = Object.values(os.networkInterfaces())
62
- .flat()
63
- .filter((i) => Boolean(i) && !i.internal).length;
64
- return {
65
- lane: 'agent',
66
- madeAt: new Date().toISOString(),
67
- tookMs,
68
- requests: counted.connections + counted.dnsLookups + counted.datagrams,
69
- counted,
70
- computer: {
71
- chip: cpus[0]?.model?.trim() || null,
72
- cores: cpus.length,
73
- memoryGb: Math.round(os.totalmem() / 2 ** 30),
74
- platform: os.platform(),
75
- arch: os.arch(),
76
- node: process.version,
77
- },
78
- network: { online: interfaces > 0, interfaces },
79
- check: [...CHECKS],
80
- };
81
- },
82
- };
83
- }
84
- const INNER = 56;
85
- function row(s = '') {
86
- const t = [...s].length > INNER ? [...s].slice(0, INNER).join('') : s;
87
- return `│ ${t}${' '.repeat(INNER - [...t].length)} │`;
88
- }
89
- /** The receipt as text: a box, 60 characters wide, no colour, safe in a log. */
90
- export function renderKeyReceipt(r) {
91
- const d = new Date(r.madeAt);
92
- const day = d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' });
93
- const time = d.toLocaleTimeString('en-GB', { hour12: false });
94
- const head = 'KEY RECEIPT';
95
- const gap = ' '.repeat(Math.max(1, INNER - head.length - day.length));
96
- const c = r.computer;
97
- const machine = [c.chip, `${c.cores} cores`, `${c.memoryGb} GB`, `${c.platform} ${c.arch}`].filter(Boolean).join(' · ');
98
- return [
99
- `╭${'─'.repeat(INNER + 2)}╮`,
100
- row(`${head}${gap}${day}`),
101
- row(),
102
- row(` ${r.requests} requests sent, from start to key`),
103
- row(),
104
- row(`made ${time} · took ${r.tookMs} ms`),
105
- row(`computer ${machine}`),
106
- row(`network ${r.network.online ? 'on' : 'off'} · ${r.network.interfaces} interface${r.network.interfaces === 1 ? '' : 's'}, none used`),
107
- row(`counted connections ${r.counted.connections} · DNS ${r.counted.dnsLookups} · datagrams ${r.counted.datagrams}`),
108
- row(),
109
- row('Measured inside this process. Check it without trusting'),
110
- row('this: make the network unavailable and run it again.'),
111
- row(),
112
- ...r.check.map((l) => row(l)),
113
- `╰${'─'.repeat(INNER + 2)}╯`,
114
- '',
115
- ].join('\n');
116
- }
@@ -1,9 +0,0 @@
1
- export interface KeySource {
2
- /** Human words: `--key`, `$ONE_API_KEY`, `~/.config/one/key`, `./.env.local` … — a place, never a value. */
3
- label: string;
4
- /** True when the key was found in the current folder (.env.local, .env, .one/key). */
5
- local: boolean;
6
- }
7
- export declare function keySourceOf(opts: {
8
- key?: string;
9
- }, cwd?: string, env?: NodeJS.ProcessEnv): KeySource;
@@ -1,33 +0,0 @@
1
- /**
2
- * key-source.ts — WHERE the key a money command acts with came from, never the key itself.
3
- *
4
- * The wallet commands resolve their key in this order (wallet.ts `resolveAuth`): --key, then
5
- * ONEIE_API_KEY / ONE_API_KEY from the shell, `<cwd>/.env.local`, `<cwd>/.env` (shell wins per
6
- * variable), then the folder's own `.one/key`, then the machine login. Four of the six are read
7
- * from the CURRENT FOLDER — so the same command can act as a different actor from a different
8
- * directory. That order is kept (`one init --write-env` writes `.env.local` on purpose); this file
9
- * only makes the choice visible: a label for the header, and whether it came from the folder.
10
- */
11
- import { homedir } from 'node:os';
12
- import { join } from 'node:path';
13
- import { readEnvFile } from '../env.js';
14
- import { readKeyFolder } from './keyfile.js';
15
- import { firstExisting, KEY_FILE, LEGACY_KEY_FILE } from './paths.js';
16
- const tilde = (p) => (p.startsWith(homedir()) ? `~${p.slice(homedir().length)}` : p);
17
- export function keySourceOf(opts, cwd = process.cwd(), env = process.env) {
18
- if (opts.key)
19
- return { label: '--key', local: false };
20
- const files = [join(cwd, '.env.local'), join(cwd, '.env')];
21
- const parsed = files.map((f) => ({ f, vars: readEnvFile(f) }));
22
- for (const name of ['ONEIE_API_KEY', 'ONE_API_KEY']) {
23
- if (env[name])
24
- return { label: `$${name}`, local: false };
25
- const hit = parsed.find((p) => p.vars[name]);
26
- if (hit)
27
- return { label: `./${hit.f.split('/').pop()}`, local: true };
28
- }
29
- if (readKeyFolder(cwd))
30
- return { label: './.one/key', local: true };
31
- const machine = firstExisting(KEY_FILE, LEGACY_KEY_FILE);
32
- return { label: machine ? tilde(machine) : 'no key', local: false };
33
- }
@@ -1,136 +0,0 @@
1
- /** The per-project directory holding the key, the vault and their metadata. */
2
- export declare const KEY_DIR_NAME = ".one";
3
- /**
4
- * The pre-rename project directory. READ-ONLY — a folder minted before the
5
- * rename keeps working; nothing is ever written here again. Same fallback shape
6
- * as `paths.ts` uses for ~/.config, and for the same reason: a rename must not
7
- * present as "my key stopped working".
8
- */
9
- export declare const LEGACY_KEY_DIR_NAME = ".oneie";
10
- /** `*.key` is already covered by the scaffold's root .gitignore. */
11
- export declare const KEY_FILE_NAME = "agent.key";
12
- export declare const META_FILE_NAME = "agent.json";
13
- export interface KeyFolderInput {
14
- /** Project root. The key lands at <dir>/.oneie/agent.key */
15
- dir: string;
16
- /** The workspace-scoped key — authenticates as the workspace actor. */
17
- apiKey: string;
18
- /** The uid-bound registration key. Distinct from apiKey; see the note below. */
19
- regKey?: string;
20
- workspace: string;
21
- uid?: string;
22
- api: string;
23
- /** Unix seconds at which the key stops verifying, when the server set one. */
24
- expiresAt?: number;
25
- /** The spend ceiling the server reports for this actor, in USD. */
26
- spendLimitUsd?: number;
27
- }
28
- export interface KeyFolderResult {
29
- ok: boolean;
30
- keyPath?: string;
31
- metaPath?: string;
32
- ignorePath?: string;
33
- /** Set when the ceremony refused — the key was NOT written. */
34
- error?: string;
35
- }
36
- /**
37
- * True when `.gitignore` already ignores the key directory.
38
- *
39
- * Deliberately a literal scan, not a `git check-ignore` shell-out: the folder
40
- * may not be a git repo yet (that is the common case — `npx oneie` runs before
41
- * `git init`), and a check that silently passes on "not a repo" would be the
42
- * false green this whole module exists to avoid.
43
- */
44
- export declare function ignoresKeyDir(ignoreText: string): boolean;
45
- /**
46
- * Ensure `<dir>/.gitignore` ignores the key directory. Returns the path on
47
- * success, or null when it could not be written — in which case the caller must
48
- * NOT write a key.
49
- */
50
- export declare function ensureIgnored(dir: string): string | null;
51
- /**
52
- * Canonical absolute path — symlinks resolved.
53
- *
54
- * `resolve()` alone is NOT enough for the path binding. On macOS `/tmp` is a
55
- * symlink to `/private/tmp` and `/var` to `/private/var`, so a key minted at the
56
- * path the user typed and read back after a `chdir` compares unequal and a
57
- * legitimate credential is refused. Home directories and network mounts are
58
- * symlinked on plenty of real machines too. Compare the REAL path on both sides
59
- * or the check fails open on attackers and closed on users — the worst pairing.
60
- *
61
- * Falls back to `resolve()` when the path does not exist yet (realpath throws).
62
- */
63
- export declare function canonicalDir(p: string): string;
64
- /**
65
- * A stable, secret-ish id for THIS machine.
66
- *
67
- * The path binding alone is not enough where the path is predictable. A repo
68
- * that ships `.oneie/agent.json` recording `dir:
69
- * "/home/runner/work/<repo>/<repo>"` matches that path on EVERY GitHub Actions
70
- * checkout of it — so the clone attack the binding closes for a laptop reopens
71
- * for CI, which is exactly where nobody is watching. The machine id is a value
72
- * the attacker cannot guess and cannot read from the victim's repo, so a key
73
- * must be BOTH at the right path AND on the right machine.
74
- *
75
- * Stored 0600 beside the machine-wide key. Not a secret in the cryptographic
76
- * sense — it authorises nothing on its own — so a read-only or unwritable home
77
- * degrades to path-only binding rather than refusing all work.
78
- */
79
- export declare function machineId(): string | null;
80
- /**
81
- * Write `data` to `path` at 0600, refusing to follow a symlink.
82
- *
83
- * `writeFileSync` FOLLOWS symlinks. An attacker who can pre-plant
84
- * `.oneie/agent.key.tmp` as a link to a file they control gets our chmod(0600)
85
- * and our credential written to their target — the classic pre-plant, and the
86
- * 0700 directory does not help because the link is created before we ever run.
87
- * `O_NOFOLLOW` makes the kernel refuse, and `O_EXCL` means we never write onto
88
- * an existing file at all.
89
- */
90
- export declare function writeSecret(path: string, data: string): void;
91
- /**
92
- * Write the key folder: ignore entry FIRST, then 0700 dir, then 0600 key via
93
- * tmp+rename so a reader never observes a partial or world-readable file.
94
- *
95
- * Refuses (and writes nothing) when the ignore entry cannot be established.
96
- */
97
- export declare function writeKeyFolder(input: KeyFolderInput): KeyFolderResult;
98
- /**
99
- * Read a folder key back, or null when the folder has none — or when the key
100
- * found there was minted for a DIFFERENT directory.
101
- *
102
- * THE PATH BINDING IS A SECURITY CONTROL, not bookkeeping. `resolveKey` consults
103
- * the current working directory, so without this check any directory you `cd`
104
- * into can supply your credentials: clone a repo that ships a `.oneie/agent.key`,
105
- * run one `one` command inside it, and you are authenticated as WHOEVER MINTED
106
- * THAT KEY. The damage is not that your key leaks — it is that your next
107
- * `one push` writes your agents and skills into THEIR workspace, and your next
108
- * `one trade` spends against their ledger. That is a credential-confusion
109
- * exfiltration, and the folder-key rung introduced it.
110
- *
111
- * `agent.json` records the absolute path the key was minted for, so a key that
112
- * travelled — by clone, copy, or archive — refuses rather than authenticates.
113
- * This is the same shape as git's `safe.directory`, decided per key instead of
114
- * per user.
115
- *
116
- * A key with NO recorded `dir` is pre-binding and also refused: the whole point
117
- * is that an unbound credential is the untrustworthy case, and treating a
118
- * missing field as permission is how the check gets bypassed by simply deleting
119
- * a line.
120
- */
121
- export declare function readKeyFolder(dir: string): {
122
- apiKey: string;
123
- meta: Record<string, unknown>;
124
- } | null;
125
- /**
126
- * Why a folder key present on disk was not used. Separate from `readKeyFolder`
127
- * so a refusal can be EXPLAINED without the reader having to hold a credential:
128
- * a silent null is right for `resolveKey` and useless for `doctor`.
129
- */
130
- export declare function keyFolderStatus(dir: string): 'none' | 'ok' | 'foreign' | 'unsafe' | 'unreadable';
131
- /**
132
- * Which workspace a command acts in: flag > AGENCY_SLUG > the workspace `npx oneie`
133
- * saved beside this folder's key. The journey already knows the agent's workspace;
134
- * asking for it again was a dead end (`wallet get`, `whoami`).
135
- */
136
- export declare function workspaceFor(explicit: string | undefined, dir: string, env: Record<string, string>): string | undefined;