@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
package/dist/src/push.js DELETED
@@ -1,115 +0,0 @@
1
- import { Command } from 'commander';
2
- import { compileNode } from './compiler.js';
3
- import { mergeEnv } from './env.js';
4
- import { askPath } from './lib/api-path.js';
5
- const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
6
- function apiKey(env) {
7
- return env.ONEIE_API_KEY ?? env.ONE_API_KEY ?? process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY ?? '';
8
- }
9
- async function ask(base, headers, receiver, data) {
10
- try {
11
- const res = await fetch(askPath(base, receiver), {
12
- method: 'POST', headers, body: JSON.stringify({ data }),
13
- });
14
- if (!res.ok)
15
- return { ok: false, result: {} };
16
- const json = (await res.json().catch(() => ({})));
17
- return { ok: true, result: json.result ?? {} };
18
- }
19
- catch {
20
- return { ok: false, result: {} };
21
- }
22
- }
23
- /** workflow:create resolves the target from requireSlug(ctx), so child workflows need that
24
- * workspace's own owner key. The configured (possibly parent) key can mint it via the walk. */
25
- async function mintOwnerKey(base, headers, slug) {
26
- const r = await ask(base, headers, 'world:mint-owner-key', { slug, label: 'push' });
27
- const k = r.result.key ?? r.result.ownerKey ?? r.result.scopedKey;
28
- return typeof k === 'string' && k ? k : null;
29
- }
30
- export function pushCmd() {
31
- return new Command('push')
32
- .description('Compile ai/ + data/ folders and push to substrate')
33
- .argument('[path]', 'Node root directory (default: cwd)')
34
- .option('--client <slug>', 'Apply client override from clients/<slug>/')
35
- .option('--dry-run', 'Validate and print plan without making substrate calls')
36
- .option('--api <url>', 'API base URL', DEFAULT_API)
37
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
38
- .action(async (path, opts) => {
39
- const dir = path ?? process.cwd();
40
- const env = mergeEnv(dir);
41
- const agencySlug = env.AGENCY_SLUG;
42
- if (!agencySlug) {
43
- process.stderr.write('AGENCY_SLUG missing — run `one setup` first\n');
44
- process.exit(1);
45
- }
46
- const { compiled, errors } = await compileNode(dir, agencySlug, { clientSlug: opts.client, dryRun: opts.dryRun });
47
- if (errors.length) {
48
- for (const e of errors)
49
- process.stderr.write(` error: ${e.path}: ${e.message}\n`);
50
- process.exit(1);
51
- }
52
- if (opts.dryRun) {
53
- process.stdout.write(`[dry-run] ${compiled.length} item(s) would push:\n`);
54
- for (const item of compiled) {
55
- const steps = item.applyDiff ? ` (+${item.applyDiff.add.length} steps)` : '';
56
- process.stdout.write(` ${item.receiver} ${item.path}${steps}\n`);
57
- }
58
- return;
59
- }
60
- const base = (opts.api ?? DEFAULT_API).replace(/\/$/, '');
61
- const key = opts.key ?? apiKey(env);
62
- const authHeaders = { 'Content-Type': 'application/json' };
63
- if (key)
64
- authHeaders['Authorization'] = `Bearer ${key}`;
65
- const isWorkflow = (i) => i.receiver === 'workflow:create';
66
- let ok = 0;
67
- // Standard items (agents, skills, context, lifecycles, types …) — explicit-slug receivers
68
- // authorize via the ownership walk, so the configured key covers owned child workspaces.
69
- for (const item of compiled.filter((i) => !isWorkflow(i))) {
70
- const res = await fetch(askPath(base, item.receiver), {
71
- method: 'POST', headers: authHeaders, body: JSON.stringify({ data: item.payload }),
72
- });
73
- if (res.ok)
74
- ok++;
75
- else
76
- process.stderr.write(` failed: ${item.receiver} ${res.status}\n`);
77
- }
78
- // Workflows — two-phase (create → apply-diff) under a workspace-owner key, idempotent by name.
79
- const wfItems = compiled.filter(isWorkflow);
80
- if (wfItems.length) {
81
- const wfKey = (await mintOwnerKey(base, authHeaders, agencySlug)) ?? key;
82
- const wfHeaders = { 'Content-Type': 'application/json', Authorization: `Bearer ${wfKey}` };
83
- // Existing workflows by name → delete a same-name match before recreating (clean re-push).
84
- const list = await ask(base, wfHeaders, 'workflow:list', {});
85
- const rows = (Array.isArray(list.result) ? list.result : (list.result.workflows ?? list.result.items ?? []));
86
- const byName = new Map();
87
- for (const w of rows) {
88
- const n = String(w.name ?? '');
89
- const id = String(w.id ?? w.workflowId ?? '');
90
- if (n && id)
91
- byName.set(n, [...(byName.get(n) ?? []), id]);
92
- }
93
- for (const item of wfItems) {
94
- const name = String(item.payload.name ?? '');
95
- for (const id of byName.get(name) ?? [])
96
- await ask(base, wfHeaders, 'workflow:delete', { workflowId: id });
97
- const created = await ask(base, wfHeaders, 'workflow:create', item.payload);
98
- const wid = created.result.workflowId ?? created.result.id;
99
- if (!created.ok || typeof wid !== 'string') {
100
- process.stderr.write(` failed: workflow:create ${name}\n`);
101
- continue;
102
- }
103
- if (item.applyDiff) {
104
- const applied = await ask(base, wfHeaders, 'workflow:apply-diff', { workflowId: wid, diff: item.applyDiff });
105
- if (!applied.ok || applied.result.ok === false) {
106
- process.stderr.write(` failed: workflow:apply-diff ${name}\n`);
107
- continue;
108
- }
109
- }
110
- ok++;
111
- }
112
- }
113
- process.stdout.write(`Pushed ${ok}/${compiled.length} item(s).\n`);
114
- });
115
- }
@@ -1,21 +0,0 @@
1
- export interface AgencyPL {
2
- slug: string;
3
- name: string | null;
4
- plan: string;
5
- markup_pct: number;
6
- pool: number;
7
- }
8
- export interface ClientPL {
9
- slug: string;
10
- name: string | null;
11
- plan: string;
12
- funded: number;
13
- burned: number;
14
- margin: number;
15
- balance: number;
16
- cap: number | null;
17
- }
18
- /** The CLIENT/PLAN/FUNDED/… table — shared by `status` (with the agency P&L
19
- * header) and `client list` (bare, no header). */
20
- export declare function renderClientTable(clients: ClientPL[], markupPct: number): string;
21
- export declare function renderStatus(agency: AgencyPL, clients: ClientPL[]): string;
@@ -1,32 +0,0 @@
1
- const fmt = (n) => n.toLocaleString('en-US');
2
- const capFmt = (n) => (n == null ? '—' : fmt(n));
3
- function pad(cells, widths) {
4
- return cells.map((c, i) => c.padEnd(widths[i])).join(' ').replace(/\s+$/, '');
5
- }
6
- /** The CLIENT/PLAN/FUNDED/… table — shared by `status` (with the agency P&L
7
- * header) and `client list` (bare, no header). */
8
- export function renderClientTable(clients, markupPct) {
9
- const header = ['CLIENT', 'PLAN', 'FUNDED', 'BURNED', `MARGIN(${markupPct}%)`, 'BALANCE', 'CAP'];
10
- const rows = clients.map((c) => [
11
- c.slug, c.plan, fmt(c.funded), fmt(c.burned), fmt(c.margin), fmt(c.balance), capFmt(c.cap),
12
- ]);
13
- const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length), 0));
14
- const totalBurned = clients.reduce((s, c) => s + c.burned, 0);
15
- const totalMargin = clients.reduce((s, c) => s + c.margin, 0);
16
- const out = [];
17
- out.push(pad(header, widths));
18
- for (const r of rows)
19
- out.push(pad(r, widths));
20
- if (clients.length === 0)
21
- out.push(' (no clients yet — `one client add <slug>`)');
22
- else
23
- out.push(`\n total burned ${fmt(totalBurned)} · margin ${fmt(totalMargin)} ← your margin this period`);
24
- return out.join('\n');
25
- }
26
- export function renderStatus(agency, clients) {
27
- const out = [];
28
- out.push(`Agency: ${agency.name ?? agency.slug} (${agency.slug}) plan=${agency.plan} markup=${agency.markup_pct}% pool=${fmt(agency.pool)} cr`);
29
- out.push('');
30
- out.push(renderClientTable(clients, agency.markup_pct));
31
- return out.join('\n');
32
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * secrets-device.ts — `one secrets add-device`: make this Mac a reader of your sealed files
3
- * (text/secrets.md deliverable 3; text/secrets-todo.md § C3).
4
- *
5
- * Runs `age-plugin-se keygen --access-control current-biometry -o <identity>`: a key born
6
- * in the Mac's Secure Enclave that never leaves the chip. The identity file is only a
7
- * handle to that key (the chip holds the secret), written mode 600 and never overwritten
8
- * without --replace. The `age1se1…` lock is then appended to ~/.one/secrets-readers.json,
9
- * where C1's `seal` finds it.
10
- *
11
- * The access control is NOT a flag. Real use is always `current-biometry`; the test seam
12
- * below is a module value the command line cannot reach.
13
- *
14
- * Nothing the identity holds is read or printed here: the lock comes from
15
- * `age-plugin-se recipients -i`, and age-plugin-se's own output is discarded.
16
- */
17
- import type { Command } from 'commander';
18
- /** The Secure Enclave identity file. ONE_SECRETS_DEVICE moves it (tests). */
19
- export declare function deviceIdentityFile(): string;
20
- /**
21
- * Test seam. Only a test module can set it; there is no flag and no env var for it, so a
22
- * person at a terminal always gets the finger rule. A key made with `none` opens without Touch ID.
23
- */
24
- export declare const deviceSeam: {
25
- accessControl: 'current-biometry' | 'none';
26
- };
27
- interface AddDeviceOpts {
28
- name?: string;
29
- replace?: boolean;
30
- }
31
- export declare function addDeviceAction(o: AddDeviceOpts, c: Command): Promise<void>;
32
- export {};
@@ -1,127 +0,0 @@
1
- /**
2
- * secrets-device.ts — `one secrets add-device`: make this Mac a reader of your sealed files
3
- * (text/secrets.md deliverable 3; text/secrets-todo.md § C3).
4
- *
5
- * Runs `age-plugin-se keygen --access-control current-biometry -o <identity>`: a key born
6
- * in the Mac's Secure Enclave that never leaves the chip. The identity file is only a
7
- * handle to that key (the chip holds the secret), written mode 600 and never overwritten
8
- * without --replace. The `age1se1…` lock is then appended to ~/.one/secrets-readers.json,
9
- * where C1's `seal` finds it.
10
- *
11
- * The access control is NOT a flag. Real use is always `current-biometry`; the test seam
12
- * below is a module value the command line cannot reach.
13
- *
14
- * Nothing the identity holds is read or printed here: the lock comes from
15
- * `age-plugin-se recipients -i`, and age-plugin-se's own output is discarded.
16
- */
17
- import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
18
- import { homedir, hostname } from 'node:os';
19
- import { dirname, join } from 'node:path';
20
- import { jsonMode } from './lib/client.js';
21
- import { keygen, PLUGIN_LOCK_RE, recipientOf, requireAge } from './lib/age-plugin.js';
22
- import { fail, readersFile } from './secrets.js';
23
- /** The Secure Enclave identity file. ONE_SECRETS_DEVICE moves it (tests). */
24
- export function deviceIdentityFile() {
25
- return process.env.ONE_SECRETS_DEVICE?.trim() || join(homedir(), '.one', 'secrets-device.txt');
26
- }
27
- /**
28
- * Test seam. Only a test module can set it; there is no flag and no env var for it, so a
29
- * person at a terminal always gets the finger rule. A key made with `none` opens without Touch ID.
30
- */
31
- export const deviceSeam = { accessControl: 'current-biometry' };
32
- const badReaders = (path) => ({ ok: false, error: `${path} is not a list of age1… locks`, code: 'bad_readers_file' });
33
- function lockOf(e) {
34
- const l = typeof e === 'string' ? e : e?.lock;
35
- return typeof l === 'string' ? l.trim() : undefined;
36
- }
37
- /** Both file shapes C1 reads: a JSON array, or `{ "readers": [...] }`. No file is a new list. */
38
- function readReaders(path) {
39
- if (!existsSync(path))
40
- return { shape: 'new', items: [] };
41
- let parsed;
42
- try {
43
- parsed = JSON.parse(readFileSync(path, 'utf8'));
44
- }
45
- catch {
46
- return badReaders(path);
47
- }
48
- if (Array.isArray(parsed))
49
- return { shape: 'list', items: parsed };
50
- const list = parsed?.readers;
51
- if (Array.isArray(list))
52
- return { shape: 'object', items: list };
53
- return badReaders(path);
54
- }
55
- function writeReaders(path, doc, original) {
56
- const body = doc.shape === 'object' ? { ...original, readers: doc.items } : doc.items;
57
- mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
58
- const tmp = `${path}.tmp-${process.pid}`;
59
- writeFileSync(tmp, JSON.stringify(body, null, 2) + '\n', { mode: 0o600 });
60
- renameSync(tmp, path);
61
- }
62
- export async function addDeviceAction(o, c) {
63
- const identity = deviceIdentityFile();
64
- const readersPath = readersFile();
65
- const bins = requireAge();
66
- if (typeof bins === 'string') {
67
- return fail(c, { ok: false, error: bins === 'no_plugin' ? 'the `age-plugin-se` program is not installed — brew install age-plugin-se' : 'the `age` program is not installed — brew install age', code: bins });
68
- }
69
- const doc = readReaders(readersPath);
70
- if ('ok' in doc)
71
- return fail(c, doc);
72
- let oldLock = null;
73
- try {
74
- lstatSync(identity);
75
- if (!o.replace)
76
- return fail(c, { ok: false, error: `${identity} already exists — this Mac is already a reader (pass --replace to make a new key)`, code: 'device_exists' });
77
- oldLock = recipientOf(identity);
78
- }
79
- catch (e) {
80
- if (e.code !== 'ENOENT')
81
- return fail(c, { ok: false, error: `cannot check ${identity}`, code: 'failed' });
82
- }
83
- const tmp = `${identity}.tmp-${process.pid}`;
84
- try {
85
- mkdirSync(dirname(identity), { recursive: true, mode: 0o700 });
86
- const made = keygen(tmp, deviceSeam.accessControl);
87
- if (made !== true) {
88
- // No Secure Enclave (or no biometry) on this machine: a fixed message, exit 3.
89
- fail(c, { ok: false, error: 'this Mac could not make a Secure Enclave key — it has no Secure Enclave, or no Touch ID set up', code: 'no_secure_enclave' });
90
- process.exitCode = 3;
91
- return;
92
- }
93
- chmodSync(tmp, 0o600);
94
- if ((statSync(tmp).mode & 0o777) !== 0o600)
95
- return fail(c, { ok: false, error: `${identity} could not be made private (mode 600)`, code: 'bad_mode' });
96
- const lock = recipientOf(tmp);
97
- if (!lock || !PLUGIN_LOCK_RE.test(lock))
98
- return fail(c, { ok: false, error: 'could not read the lock of the new key', code: 'failed' });
99
- renameSync(tmp, identity);
100
- // Re-reading after the keygen: the file may have changed under a long Touch ID wait.
101
- const fresh = readReaders(readersPath);
102
- if ('ok' in fresh)
103
- return fail(c, fresh);
104
- const original = existsSync(readersPath) ? JSON.parse(readFileSync(readersPath, 'utf8')) : undefined;
105
- const name = o.name?.trim() || hostname();
106
- const items = fresh.items.filter((e) => {
107
- const l = lockOf(e);
108
- return l !== lock && !(oldLock && l === oldLock);
109
- });
110
- items.push({ lock, name, added: new Date().toISOString() });
111
- writeReaders(readersPath, { shape: fresh.shape, items }, original);
112
- if (jsonMode(c))
113
- process.stdout.write(JSON.stringify({ ok: true, lock, name, identity, replaced: Boolean(oldLock) }) + '\n');
114
- else {
115
- process.stdout.write(`device ${lock}\n`);
116
- process.stdout.write(`name ${name}\nidentity ${identity} (a handle — the key stays in the chip)\n`);
117
- process.stdout.write('re-seal your .env to add this Mac as a reader\n');
118
- }
119
- }
120
- catch (e) {
121
- fail(c, { ok: false, error: `could not add this Mac: ${e.code ?? 'failed'}`, code: 'failed' });
122
- }
123
- finally {
124
- if (existsSync(tmp))
125
- unlinkSync(tmp);
126
- }
127
- }
@@ -1,125 +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 { Command } from 'commander';
39
- /** The part of `@oneie/sdk/secrets-give` this command uses, typed here so a typecheck does not need that SDK built. */
40
- export interface OneVaultReader {
41
- (): Promise<{
42
- readers: string[];
43
- sealedHash: string | null;
44
- }>;
45
- }
46
- export interface GiveSdk {
47
- readOneLock(reader: OneVaultReader): Promise<{
48
- ok: true;
49
- lock: string;
50
- } | {
51
- ok: false;
52
- error: 'no_one_lock';
53
- detail: string;
54
- }>;
55
- sealForOne(value: string, bind: {
56
- vault: string;
57
- name: string;
58
- provider: string;
59
- }, reader: OneVaultReader, lock?: string): Promise<{
60
- ok: true;
61
- sealed: string;
62
- } | {
63
- ok: false;
64
- error: 'no_one_lock' | 'lock_mismatch';
65
- detail: string;
66
- }>;
67
- giveData(input: {
68
- vault: string;
69
- name: string;
70
- provider: string;
71
- sealed: string;
72
- mode?: 'give' | 'check';
73
- allowFlagged?: boolean;
74
- replaces?: string | null;
75
- subject: string;
76
- }, secret: Uint8Array): {
77
- signer: {
78
- kind: 'agent';
79
- sig: string;
80
- signer: string;
81
- };
82
- payload: {
83
- type: 'give';
84
- vault: string;
85
- body: Record<string, unknown>;
86
- };
87
- };
88
- decodeSignerKey(text: string): Uint8Array | null;
89
- fixtureReader(f?: {
90
- oneLock: string | null;
91
- sealPageHash: string | null;
92
- }): OneVaultReader;
93
- }
94
- /**
95
- * Swappable in tests (the message-seal.ts `loaders` shape): the cli resolves `@oneie/sdk` through
96
- * its own node_modules, which can be a published or main-tree SDK older than `./secrets-give`;
97
- * a test serves the source. `oneVault` is the reader of ONE's vault and the ONLY source of ONE's
98
- * lock — C14 reached testnet 2026-11-08: the fixture is the SDK's mirror of ONE's testnet vault
99
- * (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
100
- * test injects a reader by assigning this field. `fetch` is the one network call.
101
- */
102
- export declare const giveLoaders: {
103
- sdk: () => Promise<GiveSdk>;
104
- oneVault: (sdk: GiveSdk) => Promise<OneVaultReader>;
105
- fetch: (input: string, init: RequestInit) => Promise<Response>;
106
- };
107
- interface GiveOpts {
108
- provider?: string;
109
- vault?: string;
110
- file: string;
111
- stdin?: boolean;
112
- key?: string;
113
- signer: string;
114
- signerKey?: string;
115
- lock?: string;
116
- check?: boolean;
117
- allowFlagged?: boolean;
118
- replaces?: string;
119
- as?: string;
120
- api?: string;
121
- }
122
- export declare function giveAction(name: string, extra: string[], o: GiveOpts, c: Command): Promise<void>;
123
- /** The `give` subcommand, fresh per call (a Command has one parent). */
124
- export declare function buildGive(): Command;
125
- export {};