oneie 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,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function workflowCmd(): Command;
@@ -1,169 +0,0 @@
1
- import { Command } from 'commander';
2
- import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
3
- import { homedir } from 'node:os';
4
- import { resolve } from 'node:path';
5
- import { askPath } from './lib/api-path.js';
6
- const DEFAULT_API = 'https://api.one.ie';
7
- const KEY_FILE = resolve(homedir(), '.config', 'oneie', 'key');
8
- function readApiKey() {
9
- // ONE_API_KEY is canonical, ONEIE_API_KEY legacy — same order lib/client.ts uses.
10
- if (process.env.ONE_API_KEY)
11
- return process.env.ONE_API_KEY;
12
- if (process.env.ONEIE_API_KEY)
13
- return process.env.ONEIE_API_KEY;
14
- if (existsSync(KEY_FILE))
15
- return readFileSync(KEY_FILE, 'utf8').trim() || null;
16
- return null;
17
- }
18
- // Every workspace op hits an EXISTING workflow:* receiver via the ask door — no new
19
- // HTTP route (cli/CLAUDE.md no-new-endpoints). pull writes the workflow:get graph
20
- // verbatim as <name>/workflow.json; push takes a diff-JSON file and applies it
21
- // (simulate by default, --commit persists). Mirrors the agent group's file round-trip.
22
- export function workflowCmd() {
23
- const cmd = new Command('workflow').description('List, pull, push (diff), and run workflows');
24
- const call = async (api, slug, receiver, data) => {
25
- const key = readApiKey();
26
- if (!key)
27
- return { ok: false, error: 'no API key — run `oneie auth login --key <key>` or set ONEIE_API_KEY' };
28
- const url = askPath(api.replace(/\/$/, ''), receiver);
29
- const res = await fetch(url, {
30
- method: 'POST',
31
- // Bearer <key> — NOT `<slug>:<key>`. The world key carries its own ownerSlug;
32
- // prefixing the slug made the gateway read the whole string as an unknown key
33
- // and every workflow subcommand 403'd with "authentication required".
34
- headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` },
35
- body: JSON.stringify({ data }),
36
- });
37
- const text = await res.text();
38
- if (!text)
39
- return {};
40
- const body = JSON.parse(text);
41
- // The ask door answers with an ENVELOPE — { outcome, result, signalId }. Every
42
- // subcommand below reads the receiver's own fields (r.id, r.ok, r.runId), so
43
- // unwrap here. Reading them off the envelope made `pull` report not_found for
44
- // a workflow that exists, and `push` report ok=false on a successful apply.
45
- if (body && typeof body === 'object' && 'outcome' in body) {
46
- const inner = (body.result ?? {});
47
- if (body.outcome === 'failure')
48
- return { error: inner.error ?? 'failure', ...inner };
49
- return { ...inner, ...(body.simulated ? { simulated: true } : {}) };
50
- }
51
- return body;
52
- };
53
- cmd.command('list')
54
- .description('List workflows in a workspace')
55
- .requiredOption('--slug <slug>', 'Workspace slug')
56
- .option('--api <url>', 'API base URL', DEFAULT_API)
57
- .action(async (opts) => {
58
- // The receiver lists `data.slug` when the key controls it, else the KEY's own
59
- // workspace. Sending {} dropped --slug, so a key minted for another workspace
60
- // printed 0 for `--slug one` while workflow:list answered 22 for one.
61
- const r = await call(opts.api, opts.slug, 'workflow:list', { slug: opts.slug });
62
- out(cmd, { ok: !r.error, ...r });
63
- });
64
- cmd.command('pull <id>')
65
- .description('Download a workflow graph to <name>/workflow.json')
66
- .requiredOption('--slug <slug>', 'Workspace slug')
67
- .option('--out <dir>', 'Output directory (defaults to the workflow name)')
68
- .option('--api <url>', 'API base URL', DEFAULT_API)
69
- .action(async (id, opts) => {
70
- const r = await call(opts.api, opts.slug, 'workflow:get', { workflowId: id });
71
- if (r.error || !r.id) {
72
- out(cmd, { ok: false, error: r.error ?? 'not_found' });
73
- return;
74
- }
75
- const dir = opts.out ?? String(r.name ?? id).toLowerCase().replace(/[^a-z0-9]+/g, '-');
76
- mkdirSync(dir, { recursive: true });
77
- const path = `${dir}/workflow.json`;
78
- writeFileSync(path, JSON.stringify(r, null, 2));
79
- out(cmd, { ok: true, path, steps: (r.steps ?? []).length });
80
- });
81
- cmd.command('push <id> <file>')
82
- .description('Apply a diff-JSON file to a workflow (simulate by default)')
83
- .requiredOption('--slug <slug>', 'Workspace slug')
84
- .option('--commit', 'Persist the diff (default simulates)')
85
- .option('--api <url>', 'API base URL', DEFAULT_API)
86
- .action(async (id, file, opts) => {
87
- if (!existsSync(file)) {
88
- out(cmd, { ok: false, error: `not found: ${file}` });
89
- return;
90
- }
91
- const diff = JSON.parse(readFileSync(file, 'utf8'));
92
- const r = await call(opts.api, opts.slug, 'workflow:apply-diff', { workflowId: id, diff, simulate: opts.commit !== true });
93
- out(cmd, { ok: !!r.ok, simulated: opts.commit !== true, ...r });
94
- });
95
- cmd.command('run <id>')
96
- .description('Start a run of a workflow')
97
- .requiredOption('--slug <slug>', 'Workspace slug')
98
- .option('--api <url>', 'API base URL', DEFAULT_API)
99
- .action(async (id, opts) => {
100
- const r = await call(opts.api, opts.slug, 'workflow:run', { workflowId: id });
101
- out(cmd, { ok: !!r.runId, ...r });
102
- });
103
- // publish takes the workflow ID, like every sibling above — `loadOwned` looks
104
- // up by id deliberately ("not name, to prevent name-guessing"), and `workflow
105
- // list` is the door from a name to an id. The seller is NOT passed: the
106
- // receiver derives it from the key's own attested workspace, so --slug here
107
- // only picks the API host's workspace context, exactly as the siblings use it.
108
- cmd.command('publish <id>')
109
- .description('List a workflow you own on the marketplace at a price (credits; 0 = free)')
110
- .requiredOption('--slug <slug>', 'Workspace slug')
111
- .option('--price <n>', 'Price in credits', (v) => Number(v))
112
- .option('--name <name>', "Listing title (defaults to the workflow's own name)")
113
- .option('--tags <csv>', 'Comma-separated tags (workflow is always added)')
114
- .option('--api <url>', 'API base URL', DEFAULT_API)
115
- .action(async (id, opts) => {
116
- const tags = opts.tags ? opts.tags.split(',').map((t) => t.trim()).filter(Boolean) : undefined;
117
- const r = await call(opts.api, opts.slug, 'workflow:publish', {
118
- workflowId: id,
119
- ...(opts.price !== undefined ? { price: opts.price } : {}),
120
- ...(opts.name ? { name: opts.name } : {}),
121
- ...(tags ? { tags } : {}),
122
- });
123
- out(cmd, { ok: !!r.ok, ...r });
124
- });
125
- cmd.command('validate <id> <file>')
126
- .description('Validate a diff-JSON file against a workflow (§9 gate, never persists)')
127
- .requiredOption('--slug <slug>', 'Workspace slug')
128
- .option('--api <url>', 'API base URL', DEFAULT_API)
129
- .action(async (id, file, opts) => {
130
- if (!existsSync(file)) {
131
- out(cmd, { ok: false, error: `not found: ${file}` });
132
- return;
133
- }
134
- const diff = JSON.parse(readFileSync(file, 'utf8'));
135
- const r = await call(opts.api, opts.slug, 'workflow:validate', { workflowId: id, diff });
136
- out(cmd, { ok: !!r.ok, ...r });
137
- });
138
- cmd.command('resolve <runId> <stepId>')
139
- .description('Resolve a suspended human step in a run (--decision approved|rejected)')
140
- .requiredOption('--slug <slug>', 'Workspace slug')
141
- .option('--decision <d>', 'approved | rejected')
142
- .option('--api <url>', 'API base URL', DEFAULT_API)
143
- .action(async (runId, stepId, opts) => {
144
- const r = await call(opts.api, opts.slug, 'human:resolve', { runId, stepId, ...(opts.decision ? { decision: opts.decision } : {}) });
145
- out(cmd, { ok: !!r.ok, ...r });
146
- });
147
- cmd.command('logs <id>')
148
- .description("List recent runs of a workflow; --run <runId> for one run's step-event timeline")
149
- .requiredOption('--slug <slug>', 'Workspace slug')
150
- .option('--run <runId>', "Return this run's event timeline")
151
- .option('--limit <n>', 'Max runs to list', (v) => parseInt(v, 10))
152
- .option('--api <url>', 'API base URL', DEFAULT_API)
153
- .action(async (id, opts) => {
154
- const r = await call(opts.api, opts.slug, 'workflow:runs', { workflowId: id, ...(opts.run ? { runId: opts.run } : {}), ...(opts.limit ? { limit: opts.limit } : {}) });
155
- out(cmd, { ok: !r.error, ...r });
156
- });
157
- return cmd;
158
- }
159
- // out() mirrors agent.ts — human `✓ k=v` or --json. W3: reuse the shared helper if
160
- // one is exported; otherwise copy agent.ts's local out().
161
- function out(cmd, data) {
162
- const json = cmd.parent?.opts()?.json ?? false;
163
- if (json) {
164
- process.stdout.write(JSON.stringify(data) + '\n');
165
- return;
166
- }
167
- const line = Object.entries(data).map(([k, v]) => `${k}=${typeof v === 'object' ? JSON.stringify(v) : v}`).join(' ');
168
- process.stdout.write((data.ok ? '✓ ' : '✗ ') + line + '\n');
169
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * write.ts — `one write <slug> --to age1… [file|-]`: seal a note HERE, on this machine,
3
- * and drop the ciphertext in a holder's inbox through the door already live on one.ie.
4
- *
5
- * POST <web base>/api/write { ws, sealed, from? }
6
- *
7
- * THE PLAINTEXT NEVER LEAVES THIS PROCESS. The note is sealed to the `--to` lock(s)
8
- * before any request is built, and the request body is built from the armored block and
9
- * the slug alone — `sealNote` takes the plaintext, `postSealed` takes only what is
10
- * already sealed, and a test pins that the posted body does not contain the note.
11
- * The door itself refuses anything that is not one armored age block.
12
- *
13
- * `/api/write` is a WEB route (one.ie), not a gateway receiver, so this does not go
14
- * through `askPath`. An env base that points at the gateway (api.one.ie) would 404, so
15
- * unless `--api` names a host explicitly, that base is replaced with https://one.ie.
16
- *
17
- * `--to` is the literal `age1…` the holder gave you, used as given — no lookup, no check.
18
- * Leave `--to` off and the name's PUBLISHED lock is looked up and verified here first
19
- * (lib/lock-lookup.ts: GET /api/lock/<slug>, the Sui signature re-checked locally). An
20
- * unpublished name, a lookup that is not live or unreachable, or a lock that does not
21
- * verify stops the note before anything is sealed or posted — it never falls back to a
22
- * lock nobody checked.
23
- */
24
- import { Command } from 'commander';
25
- import { type Fail } from './lib/message-seal.js';
26
- /** The door's own limits (one.ie/web pages/api/write.ts + lib/key/sealed-post.ts). */
27
- export declare const SEALED_MAX_CHARS = 8000;
28
- export declare function writeBase(explicit?: string, env?: NodeJS.ProcessEnv): string;
29
- /** Plaintext in, armored block out — or a plain refusal. Nothing here touches the network. */
30
- export declare function sealNote(note: Uint8Array, locks: string[]): Promise<{
31
- ok: true;
32
- sealed: string;
33
- } | Fail>;
34
- export interface PostResult {
35
- ok: true;
36
- workspace: string;
37
- threadId: string | null;
38
- messageId: string | null;
39
- sealedChars: number;
40
- }
41
- /** Post an ALREADY SEALED block. Its inputs carry no plaintext, by signature. */
42
- export declare function postSealed(base: string, ws: string, sealed: string, from: string | undefined, fetchImpl?: typeof fetch): Promise<PostResult | Fail>;
43
- export declare function writeCmd(): Command;
package/dist/src/write.js DELETED
@@ -1,180 +0,0 @@
1
- /**
2
- * write.ts — `one write <slug> --to age1… [file|-]`: seal a note HERE, on this machine,
3
- * and drop the ciphertext in a holder's inbox through the door already live on one.ie.
4
- *
5
- * POST <web base>/api/write { ws, sealed, from? }
6
- *
7
- * THE PLAINTEXT NEVER LEAVES THIS PROCESS. The note is sealed to the `--to` lock(s)
8
- * before any request is built, and the request body is built from the armored block and
9
- * the slug alone — `sealNote` takes the plaintext, `postSealed` takes only what is
10
- * already sealed, and a test pins that the posted body does not contain the note.
11
- * The door itself refuses anything that is not one armored age block.
12
- *
13
- * `/api/write` is a WEB route (one.ie), not a gateway receiver, so this does not go
14
- * through `askPath`. An env base that points at the gateway (api.one.ie) would 404, so
15
- * unless `--api` names a host explicitly, that base is replaced with https://one.ie.
16
- *
17
- * `--to` is the literal `age1…` the holder gave you, used as given — no lookup, no check.
18
- * Leave `--to` off and the name's PUBLISHED lock is looked up and verified here first
19
- * (lib/lock-lookup.ts: GET /api/lock/<slug>, the Sui signature re-checked locally). An
20
- * unpublished name, a lookup that is not live or unreachable, or a lock that does not
21
- * verify stops the note before anything is sealed or posted — it never falls back to a
22
- * lock nobody checked.
23
- */
24
- import { Command } from 'commander';
25
- import { jsonMode } from './lib/client.js';
26
- import { exitFor, lookupLock } from './lib/lock-lookup.js';
27
- import { ageModule, readNote } from './lib/message-seal.js';
28
- /** The door's own limits (one.ie/web pages/api/write.ts + lib/key/sealed-post.ts). */
29
- export const SEALED_MAX_CHARS = 8000;
30
- const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;
31
- const AGENT_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
32
- const FROM_MAX = 60;
33
- const DEADLINE_MS = 15_000;
34
- const WEB = 'https://one.ie';
35
- export function writeBase(explicit, env = process.env) {
36
- const pick = explicit ?? env.ONE_API_URL ?? env.ONEIE_BASE_URL ?? WEB;
37
- const base = pick.replace(/\/$/, '');
38
- if (!explicit) {
39
- try {
40
- if (new URL(base).hostname === 'api.one.ie')
41
- return WEB;
42
- }
43
- catch {
44
- /* an unparseable env base falls through and fails at fetch with a plain sentence */
45
- }
46
- }
47
- return base;
48
- }
49
- const collect = (v, prev = []) => [...prev, v];
50
- /** Plaintext in, armored block out — or a plain refusal. Nothing here touches the network. */
51
- export async function sealNote(note, locks) {
52
- if (locks.length === 0)
53
- return { ok: false, error: 'seal it to someone — pass --to age1…', code: 'no_recipient' };
54
- const age = await ageModule();
55
- for (const l of locks) {
56
- try {
57
- age.decodeRecipient(l);
58
- }
59
- catch {
60
- return { ok: false, error: `${l} is not an age lock — it starts age1…`, code: 'bad_key' };
61
- }
62
- }
63
- return { ok: true, sealed: age.armor(age.encrypt(note, [...new Set(locks.map((l) => l.trim()))])) };
64
- }
65
- /** Post an ALREADY SEALED block. Its inputs carry no plaintext, by signature. */
66
- export async function postSealed(base, ws, sealed, from, fetchImpl = fetch) {
67
- // The door reads `name` (writerLabel → "Sam (not verified)") and ignores `from`; sending
68
- // `from` made every CLI note arrive as "Someone with your lock".
69
- const body = { ws, sealed };
70
- if (from)
71
- body.name = from;
72
- const ctl = new AbortController();
73
- const timer = setTimeout(() => ctl.abort(), DEADLINE_MS);
74
- let res;
75
- try {
76
- res = await fetchImpl(`${base}/api/write`, {
77
- method: 'POST',
78
- headers: { 'content-type': 'application/json' },
79
- body: JSON.stringify(body),
80
- signal: ctl.signal,
81
- });
82
- }
83
- catch {
84
- return { ok: false, error: `could not reach ${base} — the note was sealed but not sent`, code: 'unreachable' };
85
- }
86
- finally {
87
- clearTimeout(timer);
88
- }
89
- let j = {};
90
- try {
91
- j = (await res.json());
92
- }
93
- catch {
94
- /* a non-JSON body is reported by status below */
95
- }
96
- if (res.status === 429 && j.error === 'inbox_busy')
97
- return { ok: false, error: 'this inbox is busy — it has taken its 60 notes for these ten minutes; wait a minute and try again', code: 'inbox_busy' };
98
- if (res.status === 429)
99
- return { ok: false, error: 'too many notes from this address — the door takes ten a minute; wait and try again', code: 'rate_limited' };
100
- if (res.ok && j.ok)
101
- return { ok: true, workspace: ws, threadId: j.threadId ?? null, messageId: j.messageId ?? null, sealedChars: sealed.length };
102
- switch (j.error) {
103
- case 'bad_workspace':
104
- return { ok: false, error: `"${ws}" is not a workspace name`, code: 'bad_workspace' };
105
- case 'unknown_workspace':
106
- return { ok: false, error: `there is no workspace called "${ws}" on ${base}`, code: 'unknown_workspace' };
107
- case 'too_large':
108
- return { ok: false, error: 'the door refused it — the sealed note is over its size cap', code: 'too_large' };
109
- case 'not_sealed':
110
- return { ok: false, error: 'the door refused it — it is not one armored age block', code: 'not_sealed' };
111
- default:
112
- return { ok: false, error: `the door answered ${res.status}${j.error ? ` (${j.error})` : ''} — nothing was delivered`, code: j.error ?? 'failed' };
113
- }
114
- }
115
- export function writeCmd() {
116
- return new Command('write')
117
- .description("Seal a note on this machine to someone's age1… lock and drop it in their inbox on one.ie (/api/write). Plaintext never leaves")
118
- .argument('<slug>', "The holder's workspace name, or <workspace>/<agent-id> for an agent's own lock (the note still lands in the workspace's sealed notes)")
119
- .argument('[file]', 'The note to send; omit or "-" to read stdin')
120
- .option('--to <lock>', 'The holder\'s age1… lock (repeat to seal to several). Omit it to use the lock <slug> has PUBLISHED, checked here first', collect)
121
- .option('--from <name>', `A display name for you, up to ${FROM_MAX} characters — a label, never proof of who you are`)
122
- .option('--api <url>', 'Web base (default https://one.ie; /api/write is a web route, not on the gateway)')
123
- .action(async (nameArg, file, o, c) => {
124
- const refuse = (f) => {
125
- if (jsonMode(c))
126
- process.stdout.write(JSON.stringify(f) + '\n');
127
- else
128
- process.stderr.write(`error ${f.error}\n`);
129
- process.exitCode = 1;
130
- };
131
- // `sam` or `sam/scout`: the workspace half is where the note lands; the whole name
132
- // is what gets looked up, so an agent's lock is checked against ITS name, never sam's.
133
- const name = nameArg.trim();
134
- const ws = name.split('/')[0].toLowerCase();
135
- if (!SLUG_RE.test(ws))
136
- return refuse({ ok: false, error: `"${nameArg}" is not a workspace name — lowercase letters, digits and dashes`, code: 'bad_workspace' });
137
- const agentPart = name.includes('/') ? name.slice(name.indexOf('/') + 1) : undefined;
138
- if (agentPart !== undefined && !AGENT_NAME_RE.test(agentPart)) {
139
- return refuse({ ok: false, error: `"${nameArg}" is not an agent name — <workspace>/<agent-id>`, code: 'bad_agent' });
140
- }
141
- const from = o.from?.trim();
142
- if (from && from.length > FROM_MAX)
143
- return refuse({ ok: false, error: `--from is ${from.length} characters; the door keeps ${FROM_MAX}`, code: 'from_too_long' });
144
- // No --to: seal to the name's published lock, but only one that verifies HERE.
145
- let locks = o.to ?? [];
146
- let checked;
147
- if (locks.length === 0) {
148
- const found = await lookupLock(writeBase(o.api), agentPart === undefined ? ws : `${ws}/${agentPart}`);
149
- if (!found.ok) {
150
- refuse(found);
151
- process.exitCode = exitFor(found.code);
152
- return;
153
- }
154
- checked = found;
155
- locks = [found.lock];
156
- }
157
- const note = await readNote(file);
158
- if ('ok' in note)
159
- return refuse(note);
160
- const sealed = await sealNote(note, locks);
161
- if (!sealed.ok)
162
- return refuse(sealed);
163
- if (sealed.sealed.length > SEALED_MAX_CHARS) {
164
- return refuse({
165
- ok: false,
166
- error: `sealed, this note is ${sealed.sealed.length} characters and the door takes ${SEALED_MAX_CHARS} — send a shorter note, or fewer locks. Nothing was sent`,
167
- code: 'too_long',
168
- });
169
- }
170
- const r = await postSealed(writeBase(o.api), ws, sealed.sealed, from);
171
- if (!r.ok)
172
- return refuse(r);
173
- if (jsonMode(c))
174
- process.stdout.write(JSON.stringify(checked ? { ...r, name: checked.name, lock: checked.lock, suiAddress: checked.suiAddress, lockChecked: true } : r) + '\n');
175
- else if (checked)
176
- process.stdout.write(`sent sealed to ${checked.name}'s published lock (signature checked, signed by Sui address ${checked.suiAddress}), ${r.sealedChars} characters, into ${ws}'s sealed notes\n`);
177
- else
178
- process.stdout.write(`sent sealed to ${new Set(o.to).size} lock(s), ${r.sealedChars} characters, into ${ws}'s sealed notes\n`);
179
- });
180
- }