@oneie/cli 5.8.0 → 5.9.0

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 (270) hide show
  1. package/README.md +114 -6
  2. package/dist/package.json +37 -11
  3. package/dist/src/age-1k8hs4ec.js +1 -0
  4. package/dist/src/client-n6fpnd9f.js +1 -0
  5. package/dist/src/evm-tx-cqhm9rtt.js +1 -0
  6. package/dist/src/hl-run-0pv1e0p2.js +1 -0
  7. package/dist/src/index-f5vhzspa.js +12 -0
  8. package/dist/src/index-h3nrt8bx.js +4 -0
  9. package/dist/src/index-st6k9vhc.js +2062 -0
  10. package/dist/src/index.js +1122 -134
  11. package/dist/src/message-key-yczrxszr.js +1 -0
  12. package/dist/src/message-lock-thr851d5.js +5 -0
  13. package/dist/src/sweep-order-jrq2hkye.js +1 -0
  14. package/dist/src/sweep-runner-jftw9em7.js +1 -0
  15. package/package.json +37 -11
  16. package/dist/src/agent.d.ts +0 -75
  17. package/dist/src/agent.js +0 -1334
  18. package/dist/src/agentverse.d.ts +0 -26
  19. package/dist/src/agentverse.js +0 -171
  20. package/dist/src/args.d.ts +0 -9
  21. package/dist/src/args.js +0 -61
  22. package/dist/src/auth.d.ts +0 -6
  23. package/dist/src/auth.js +0 -121
  24. package/dist/src/balances.d.ts +0 -89
  25. package/dist/src/balances.js +0 -202
  26. package/dist/src/banner.d.ts +0 -1
  27. package/dist/src/banner.js +0 -17
  28. package/dist/src/broadcast.d.ts +0 -8
  29. package/dist/src/broadcast.js +0 -175
  30. package/dist/src/catalog.d.ts +0 -12
  31. package/dist/src/catalog.js +0 -76
  32. package/dist/src/ceiling.d.ts +0 -36
  33. package/dist/src/ceiling.js +0 -189
  34. package/dist/src/chat.d.ts +0 -2
  35. package/dist/src/chat.js +0 -92
  36. package/dist/src/check.d.ts +0 -11
  37. package/dist/src/check.js +0 -53
  38. package/dist/src/client.d.ts +0 -5
  39. package/dist/src/client.js +0 -157
  40. package/dist/src/compiler.d.ts +0 -36
  41. package/dist/src/compiler.js +0 -366
  42. package/dist/src/config.d.ts +0 -24
  43. package/dist/src/config.js +0 -70
  44. package/dist/src/connect.d.ts +0 -2
  45. package/dist/src/connect.js +0 -64
  46. package/dist/src/coordinate.d.ts +0 -3
  47. package/dist/src/coordinate.js +0 -58
  48. package/dist/src/create.d.ts +0 -2
  49. package/dist/src/create.js +0 -113
  50. package/dist/src/credits.d.ts +0 -29
  51. package/dist/src/credits.js +0 -88
  52. package/dist/src/deploy.d.ts +0 -2
  53. package/dist/src/deploy.js +0 -19
  54. package/dist/src/dev.d.ts +0 -2
  55. package/dist/src/dev.js +0 -75
  56. package/dist/src/device-flow.d.ts +0 -57
  57. package/dist/src/device-flow.js +0 -173
  58. package/dist/src/doctor.d.ts +0 -26
  59. package/dist/src/doctor.js +0 -146
  60. package/dist/src/draw.d.ts +0 -18
  61. package/dist/src/draw.js +0 -156
  62. package/dist/src/endpoint.d.ts +0 -2
  63. package/dist/src/endpoint.js +0 -250
  64. package/dist/src/env.d.ts +0 -3
  65. package/dist/src/env.js +0 -37
  66. package/dist/src/eval.d.ts +0 -2
  67. package/dist/src/eval.js +0 -43
  68. package/dist/src/fn.d.ts +0 -2
  69. package/dist/src/fn.js +0 -70
  70. package/dist/src/group.d.ts +0 -2
  71. package/dist/src/group.js +0 -117
  72. package/dist/src/hl-run.d.ts +0 -119
  73. package/dist/src/hl-run.js +0 -480
  74. package/dist/src/hl.d.ts +0 -17
  75. package/dist/src/hl.js +0 -148
  76. package/dist/src/index.d.ts +0 -2
  77. package/dist/src/init.d.ts +0 -76
  78. package/dist/src/init.js +0 -278
  79. package/dist/src/join.d.ts +0 -11
  80. package/dist/src/join.js +0 -297
  81. package/dist/src/key-publish.d.ts +0 -40
  82. package/dist/src/key-publish.js +0 -232
  83. package/dist/src/key-seal.d.ts +0 -21
  84. package/dist/src/key-seal.js +0 -142
  85. package/dist/src/key-sweep.d.ts +0 -93
  86. package/dist/src/key-sweep.js +0 -270
  87. package/dist/src/key.d.ts +0 -26
  88. package/dist/src/key.js +0 -338
  89. package/dist/src/lib/age-plugin.d.ts +0 -51
  90. package/dist/src/lib/age-plugin.js +0 -130
  91. package/dist/src/lib/agent-env.d.ts +0 -12
  92. package/dist/src/lib/agent-env.js +0 -48
  93. package/dist/src/lib/api-path.d.ts +0 -2
  94. package/dist/src/lib/api-path.js +0 -40
  95. package/dist/src/lib/asker.d.ts +0 -34
  96. package/dist/src/lib/asker.js +0 -126
  97. package/dist/src/lib/check-words.d.ts +0 -57
  98. package/dist/src/lib/check-words.js +0 -144
  99. package/dist/src/lib/client.d.ts +0 -20
  100. package/dist/src/lib/client.js +0 -71
  101. package/dist/src/lib/env-sealed.d.ts +0 -53
  102. package/dist/src/lib/env-sealed.js +0 -184
  103. package/dist/src/lib/flow-tag.d.ts +0 -86
  104. package/dist/src/lib/flow-tag.js +0 -230
  105. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  106. package/dist/src/lib/hl-core/actions.js +0 -69
  107. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  108. package/dist/src/lib/hl-core/eip712.js +0 -107
  109. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  110. package/dist/src/lib/hl-core/errors.js +0 -15
  111. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  112. package/dist/src/lib/hl-core/exchange.js +0 -47
  113. package/dist/src/lib/hl-core/index.d.ts +0 -13
  114. package/dist/src/lib/hl-core/index.js +0 -14
  115. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  116. package/dist/src/lib/hl-core/meta.js +0 -110
  117. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  118. package/dist/src/lib/hl-core/msgpack.js +0 -136
  119. package/dist/src/lib/hl-core/net.d.ts +0 -2
  120. package/dist/src/lib/hl-core/net.js +0 -7
  121. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  122. package/dist/src/lib/hl-core/signing.js +0 -295
  123. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  124. package/dist/src/lib/hl-core/wire.js +0 -81
  125. package/dist/src/lib/invoked-as.d.ts +0 -2
  126. package/dist/src/lib/invoked-as.js +0 -24
  127. package/dist/src/lib/journey-words.d.ts +0 -84
  128. package/dist/src/lib/journey-words.js +0 -363
  129. package/dist/src/lib/journey.d.ts +0 -150
  130. package/dist/src/lib/journey.js +0 -264
  131. package/dist/src/lib/key-receipt.d.ts +0 -48
  132. package/dist/src/lib/key-receipt.js +0 -116
  133. package/dist/src/lib/key-source.d.ts +0 -9
  134. package/dist/src/lib/key-source.js +0 -33
  135. package/dist/src/lib/keyfile.d.ts +0 -136
  136. package/dist/src/lib/keyfile.js +0 -397
  137. package/dist/src/lib/launch-claude.d.ts +0 -5
  138. package/dist/src/lib/launch-claude.js +0 -45
  139. package/dist/src/lib/lock-lookup.d.ts +0 -40
  140. package/dist/src/lib/lock-lookup.js +0 -92
  141. package/dist/src/lib/message-seal.d.ts +0 -63
  142. package/dist/src/lib/message-seal.js +0 -150
  143. package/dist/src/lib/net-choice.d.ts +0 -28
  144. package/dist/src/lib/net-choice.js +0 -72
  145. package/dist/src/lib/network.d.ts +0 -22
  146. package/dist/src/lib/network.js +0 -50
  147. package/dist/src/lib/next-words.d.ts +0 -105
  148. package/dist/src/lib/next-words.js +0 -298
  149. package/dist/src/lib/paths.d.ts +0 -41
  150. package/dist/src/lib/paths.js +0 -91
  151. package/dist/src/lib/plan-draw.d.ts +0 -56
  152. package/dist/src/lib/plan-draw.js +0 -219
  153. package/dist/src/lib/plan-live.d.ts +0 -20
  154. package/dist/src/lib/plan-live.js +0 -192
  155. package/dist/src/lib/qr.d.ts +0 -21
  156. package/dist/src/lib/qr.js +0 -402
  157. package/dist/src/lib/roster.d.ts +0 -20
  158. package/dist/src/lib/roster.js +0 -79
  159. package/dist/src/lib/sale-card.d.ts +0 -117
  160. package/dist/src/lib/sale-card.js +0 -261
  161. package/dist/src/lib/shop-init.d.ts +0 -62
  162. package/dist/src/lib/shop-init.js +0 -63
  163. package/dist/src/lib/sui-grpc-send.d.ts +0 -90
  164. package/dist/src/lib/sui-grpc-send.js +0 -128
  165. package/dist/src/lib/swap-core.d.ts +0 -163
  166. package/dist/src/lib/swap-core.js +0 -405
  167. package/dist/src/lib/tasks-digest.d.ts +0 -66
  168. package/dist/src/lib/tasks-digest.js +0 -200
  169. package/dist/src/lib/tasks-graph.d.ts +0 -79
  170. package/dist/src/lib/tasks-graph.js +0 -463
  171. package/dist/src/lib/tasks-lens.d.ts +0 -31
  172. package/dist/src/lib/tasks-lens.js +0 -47
  173. package/dist/src/lib/tasks-next.d.ts +0 -25
  174. package/dist/src/lib/tasks-next.js +0 -103
  175. package/dist/src/lib/tasks-prove.d.ts +0 -15
  176. package/dist/src/lib/tasks-prove.js +0 -68
  177. package/dist/src/lib/tasks-route.d.ts +0 -29
  178. package/dist/src/lib/tasks-route.js +0 -151
  179. package/dist/src/lib/tasks-score.d.ts +0 -36
  180. package/dist/src/lib/tasks-score.js +0 -152
  181. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  182. package/dist/src/lib/tasks-workspace.js +0 -73
  183. package/dist/src/lib/timed-fetch.d.ts +0 -33
  184. package/dist/src/lib/timed-fetch.js +0 -59
  185. package/dist/src/lib/vault-read.d.ts +0 -24
  186. package/dist/src/lib/vault-read.js +0 -77
  187. package/dist/src/lib/vaultfile.d.ts +0 -103
  188. package/dist/src/lib/vaultfile.js +0 -249
  189. package/dist/src/lib/wallet-money.d.ts +0 -222
  190. package/dist/src/lib/wallet-money.js +0 -578
  191. package/dist/src/lib/wallet-request.d.ts +0 -50
  192. package/dist/src/lib/wallet-request.js +0 -86
  193. package/dist/src/links.d.ts +0 -5
  194. package/dist/src/links.js +0 -45
  195. package/dist/src/media.d.ts +0 -29
  196. package/dist/src/media.js +0 -487
  197. package/dist/src/message-receipt.d.ts +0 -25
  198. package/dist/src/message-receipt.js +0 -71
  199. package/dist/src/message.d.ts +0 -13
  200. package/dist/src/message.js +0 -92
  201. package/dist/src/move.d.ts +0 -36
  202. package/dist/src/move.js +0 -152
  203. package/dist/src/network-cmd.d.ts +0 -17
  204. package/dist/src/network-cmd.js +0 -74
  205. package/dist/src/next.d.ts +0 -12
  206. package/dist/src/next.js +0 -67
  207. package/dist/src/onboard.d.ts +0 -16
  208. package/dist/src/onboard.js +0 -149
  209. package/dist/src/plugin.d.ts +0 -2
  210. package/dist/src/plugin.js +0 -193
  211. package/dist/src/push.d.ts +0 -2
  212. package/dist/src/push.js +0 -115
  213. package/dist/src/render.d.ts +0 -21
  214. package/dist/src/render.js +0 -32
  215. package/dist/src/secrets-device.d.ts +0 -32
  216. package/dist/src/secrets-device.js +0 -127
  217. package/dist/src/secrets-give.d.ts +0 -125
  218. package/dist/src/secrets-give.js +0 -236
  219. package/dist/src/secrets-list.d.ts +0 -27
  220. package/dist/src/secrets-list.js +0 -84
  221. package/dist/src/secrets-run.d.ts +0 -31
  222. package/dist/src/secrets-run.js +0 -182
  223. package/dist/src/secrets.d.ts +0 -33
  224. package/dist/src/secrets.js +0 -200
  225. package/dist/src/setup.d.ts +0 -6
  226. package/dist/src/setup.js +0 -127
  227. package/dist/src/ship.d.ts +0 -2
  228. package/dist/src/ship.js +0 -18
  229. package/dist/src/shop-buy.d.ts +0 -16
  230. package/dist/src/shop-buy.js +0 -101
  231. package/dist/src/shop.d.ts +0 -10
  232. package/dist/src/shop.js +0 -112
  233. package/dist/src/skill-parser.d.ts +0 -14
  234. package/dist/src/skill-parser.js +0 -113
  235. package/dist/src/skill.d.ts +0 -2
  236. package/dist/src/skill.js +0 -493
  237. package/dist/src/slug.d.ts +0 -2
  238. package/dist/src/slug.js +0 -6
  239. package/dist/src/social.d.ts +0 -2
  240. package/dist/src/social.js +0 -106
  241. package/dist/src/staff.d.ts +0 -2
  242. package/dist/src/staff.js +0 -104
  243. package/dist/src/start.d.ts +0 -27
  244. package/dist/src/start.js +0 -225
  245. package/dist/src/status.d.ts +0 -2
  246. package/dist/src/status.js +0 -52
  247. package/dist/src/substrate.d.ts +0 -2
  248. package/dist/src/substrate.js +0 -258
  249. package/dist/src/swap.d.ts +0 -93
  250. package/dist/src/swap.js +0 -622
  251. package/dist/src/tasks.d.ts +0 -2
  252. package/dist/src/tasks.js +0 -743
  253. package/dist/src/templates.d.ts +0 -1
  254. package/dist/src/templates.js +0 -213
  255. package/dist/src/thread.d.ts +0 -2
  256. package/dist/src/thread.js +0 -52
  257. package/dist/src/trade.d.ts +0 -2
  258. package/dist/src/trade.js +0 -91
  259. package/dist/src/trail.d.ts +0 -2
  260. package/dist/src/trail.js +0 -41
  261. package/dist/src/validate.d.ts +0 -13
  262. package/dist/src/validate.js +0 -35
  263. package/dist/src/wallet-money.d.ts +0 -158
  264. package/dist/src/wallet-money.js +0 -664
  265. package/dist/src/wallet.d.ts +0 -169
  266. package/dist/src/wallet.js +0 -973
  267. package/dist/src/workflow.d.ts +0 -2
  268. package/dist/src/workflow.js +0 -169
  269. package/dist/src/write.d.ts +0 -43
  270. package/dist/src/write.js +0 -180
@@ -1,20 +0,0 @@
1
- import type { Command } from 'commander';
2
- /** --api flag > ONE_API_URL (canonical) > ONEIE_BASE_URL (legacy) > fallback. ONE_BASE_URL is retired. */
3
- export declare function resolveBase(opts?: {
4
- api?: string;
5
- }, fallback?: string): string;
6
- /** ONE_API_KEY (canonical) > ONEIE_API_KEY (legacy) > ~/.config/oneie/key. */
7
- export declare function resolveKey(opts?: {
8
- key?: string;
9
- }): string;
10
- export declare function authHeaders(opts?: {
11
- key?: string;
12
- }): Record<string, string>;
13
- /** Walks cmd.parent all the way to root — never a fixed depth. ONEIE_JSON env is retired. */
14
- export declare function jsonMode(cmd: Command): boolean;
15
- /**
16
- * ok/error human line (`ok k=v k=v`), or the same data as one JSON line under --json.
17
- * `ok: false` exits 1 in BOTH modes — the JSON line is for the pipeline, the exit
18
- * code for `$?`; 5.5.0 skipped it under --json and a refusal read as success.
19
- */
20
- export declare function out(cmd: Command, data: Record<string, unknown>): void;
@@ -1,71 +0,0 @@
1
- import { readKeyFolder } from './keyfile.js';
2
- import { readMachineKey } from './paths.js';
3
- // Every command resolves base URL, key, and --json the same way — this module
4
- // is the one place that knows the env contract. Composes askPath() from
5
- // ./api-path.js for the gateway-vs-web path split; does not replace it.
6
- // Path canon lives in lib/paths.ts — six modules used to each carry their own.
7
- /** --api flag > ONE_API_URL (canonical) > ONEIE_BASE_URL (legacy) > fallback. ONE_BASE_URL is retired. */
8
- export function resolveBase(opts = {}, fallback = 'https://one.ie') {
9
- const base = opts.api ?? process.env.ONE_API_URL ?? process.env.ONEIE_BASE_URL ?? fallback;
10
- return base.replace(/\/$/, '');
11
- }
12
- /** ONE_API_KEY (canonical) > ONEIE_API_KEY (legacy) > ~/.config/oneie/key. */
13
- export function resolveKey(opts = {}) {
14
- if (opts.key)
15
- return opts.key;
16
- if (process.env.ONE_API_KEY)
17
- return process.env.ONE_API_KEY;
18
- if (process.env.ONEIE_API_KEY)
19
- return process.env.ONEIE_API_KEY;
20
- // The PROJECT's key outranks the machine's. A folder that carries its own
21
- // credential is saying "use mine", and `one init --dir .` wrote it there to
22
- // narrow the blast radius — falling through to ~/.config/oneie/key would hand
23
- // the command the machine-wide key instead and quietly undo that.
24
- //
25
- // Below the env vars on purpose: an explicit ONE_API_KEY in the shell is a
26
- // deliberate override, and CI sets it that way.
27
- const folder = readKeyFolder(process.cwd());
28
- if (folder)
29
- return folder.apiKey;
30
- // readMachineKey tries ~/.config/one/key then the pre-rename ~/.config/oneie/key,
31
- // so an upgrade does not silently log anyone out.
32
- return readMachineKey();
33
- }
34
- export function authHeaders(opts = {}) {
35
- const h = { 'Content-Type': 'application/json' };
36
- const k = resolveKey(opts);
37
- if (k)
38
- h['Authorization'] = `Bearer ${k}`;
39
- return h;
40
- }
41
- /** Walks cmd.parent all the way to root — never a fixed depth. ONEIE_JSON env is retired. */
42
- export function jsonMode(cmd) {
43
- let c = cmd;
44
- while (c) {
45
- if (c.opts().json)
46
- return true;
47
- c = c.parent ?? undefined;
48
- }
49
- return false;
50
- }
51
- /**
52
- * ok/error human line (`ok k=v k=v`), or the same data as one JSON line under --json.
53
- * `ok: false` exits 1 in BOTH modes — the JSON line is for the pipeline, the exit
54
- * code for `$?`; 5.5.0 skipped it under --json and a refusal read as success.
55
- */
56
- export function out(cmd, data) {
57
- if (data.ok === false)
58
- process.exitCode = 1;
59
- if (jsonMode(cmd)) {
60
- process.stdout.write(JSON.stringify(data) + '\n');
61
- return;
62
- }
63
- if (data.ok === false) {
64
- process.stderr.write(`error ${data.error ?? 'unknown'}\n`);
65
- return;
66
- }
67
- const pairs = Object.entries(data)
68
- .filter(([k]) => k !== 'ok')
69
- .map(([k, v]) => `${k}=${JSON.stringify(v)}`);
70
- process.stdout.write(`ok ${pairs.join(' ')}\n`);
71
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * env-sealed.ts — parse a plaintext .env, and write and read `.env.sealed` v1
3
- * (text/secrets-plan.md § Data shape).
4
- *
5
- * # one-secrets v1
6
- * # readers age1… age1…
7
- * # vault <id> (only when one is known)
8
- * NAME=age:<base64 of one binary age file>
9
- *
10
- * One age file per value, in the .env's own order; comments and blank lines are dropped.
11
- * Names stay readable, values do not. Nothing here prints, logs or writes a value: every
12
- * error names a line NUMBER, never a line, because a line of a .env is a secret.
13
- *
14
- * The age module loads lazily (same reason as message-seal.ts): `one secrets` is
15
- * registered from index.ts, and a static `@oneie/sdk/age` import would crash every verb
16
- * on an installed SDK that predates the export.
17
- */
18
- import type { Fail } from './message-seal.js';
19
- export declare const SEALED_HEADER = "# one-secrets v1";
20
- export interface EnvEntry {
21
- name: string;
22
- value: string;
23
- }
24
- export interface SealedEntry {
25
- name: string;
26
- /** One binary age file. */
27
- file: Uint8Array;
28
- }
29
- export interface SealedFile {
30
- readers: string[];
31
- vault?: string;
32
- entries: SealedEntry[];
33
- }
34
- export declare const isVaultId: (v: string) => boolean;
35
- /**
36
- * Parse a .env the way dotenv reads it: `NAME=value`, an optional `export `, "double"
37
- * quotes (with \n \r \t \" \\ escapes, may span lines), 'single' quotes (literal, may
38
- * span lines), and unquoted values that end at whitespace-then-#. A value may hold `=`
39
- * and `#`. Duplicate names are refused, never merged.
40
- */
41
- export declare function parseEnv(text: string): EnvEntry[] | Fail;
42
- /** The `.env.sealed` v1 text. */
43
- export declare function renderSealed(f: SealedFile): string;
44
- /** Read `.env.sealed` v1 back. Refuses anything that is not exactly the format. */
45
- export declare function parseSealed(text: string): SealedFile | Fail;
46
- /** Seal every value to every lock: one binary age file per value. */
47
- export declare function sealEntries(entries: EnvEntry[], locks: string[]): Promise<SealedEntry[]>;
48
- /**
49
- * Open the sealed file's values with one identity and compare them to `expected` byte for
50
- * byte — same names, same order, same count, every reader on every value. Returns null
51
- * when it all holds, else a plain failure that names a variable, never a value.
52
- */
53
- export declare function verifySealed(sealed: SealedFile, expected: EnvEntry[], secret: Uint8Array): Promise<Fail | null>;
@@ -1,184 +0,0 @@
1
- /**
2
- * env-sealed.ts — parse a plaintext .env, and write and read `.env.sealed` v1
3
- * (text/secrets-plan.md § Data shape).
4
- *
5
- * # one-secrets v1
6
- * # readers age1… age1…
7
- * # vault <id> (only when one is known)
8
- * NAME=age:<base64 of one binary age file>
9
- *
10
- * One age file per value, in the .env's own order; comments and blank lines are dropped.
11
- * Names stay readable, values do not. Nothing here prints, logs or writes a value: every
12
- * error names a line NUMBER, never a line, because a line of a .env is a secret.
13
- *
14
- * The age module loads lazily (same reason as message-seal.ts): `one secrets` is
15
- * registered from index.ts, and a static `@oneie/sdk/age` import would crash every verb
16
- * on an installed SDK that predates the export.
17
- */
18
- import { ageModule } from './message-seal.js';
19
- import { isPluginLock, sealWithAge } from './age-plugin.js';
20
- export const SEALED_HEADER = '# one-secrets v1';
21
- const bad = (error, code = 'bad_env') => ({ ok: false, error, code });
22
- const NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
23
- const VAULT_RE = /^[A-Za-z0-9_.:-]{1,128}$/;
24
- const B64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
25
- export const isVaultId = (v) => VAULT_RE.test(v);
26
- /** The tail of a line after a closing quote may only be blank or a comment. */
27
- function tailOk(tail) {
28
- const t = tail.trim();
29
- return t === '' || t.startsWith('#');
30
- }
31
- /**
32
- * Parse a .env the way dotenv reads it: `NAME=value`, an optional `export `, "double"
33
- * quotes (with \n \r \t \" \\ escapes, may span lines), 'single' quotes (literal, may
34
- * span lines), and unquoted values that end at whitespace-then-#. A value may hold `=`
35
- * and `#`. Duplicate names are refused, never merged.
36
- */
37
- export function parseEnv(text) {
38
- const lines = text.replace(/^/, '').split(/\r?\n/);
39
- const out = [];
40
- const seen = new Set();
41
- for (let i = 0; i < lines.length; i++) {
42
- const line = lines[i].trimStart();
43
- if (line === '' || line.startsWith('#'))
44
- continue;
45
- const m = /^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)$/.exec(line);
46
- if (!m)
47
- return bad(`line ${i + 1} of the .env is not NAME=value`);
48
- const name = m[1];
49
- const rest = m[2];
50
- const startLine = i + 1;
51
- let value;
52
- const q = rest[0];
53
- if (q === '"' || q === "'") {
54
- // Find the closing quote, pulling in the following lines while it is open.
55
- let body = '';
56
- let buf = rest.slice(1);
57
- let closed = false;
58
- let tail = '';
59
- for (;;) {
60
- let j = 0;
61
- for (; j < buf.length; j++) {
62
- const c = buf[j];
63
- if (q === '"' && c === '\\' && j + 1 < buf.length) {
64
- const n = buf[j + 1];
65
- body += n === 'n' ? '\n' : n === 'r' ? '\r' : n === 't' ? '\t' : n === '"' ? '"' : n === '\\' ? '\\' : '\\' + n;
66
- j++;
67
- continue;
68
- }
69
- if (c === q) {
70
- closed = true;
71
- tail = buf.slice(j + 1);
72
- break;
73
- }
74
- body += c;
75
- }
76
- if (closed)
77
- break;
78
- if (++i >= lines.length)
79
- return bad(`line ${startLine} of the .env opens a quote that never closes`);
80
- body += '\n';
81
- buf = lines[i];
82
- }
83
- if (!tailOk(tail))
84
- return bad(`line ${i + 1} of the .env has text after the closing quote`);
85
- value = body;
86
- }
87
- else {
88
- value = rest.replace(/(^|[ \t])#.*$/, '').trimEnd();
89
- }
90
- if (seen.has(name))
91
- return bad(`${name} is set twice in the .env — keep one`, 'duplicate_name');
92
- seen.add(name);
93
- out.push({ name, value });
94
- }
95
- return out;
96
- }
97
- /** The `.env.sealed` v1 text. */
98
- export function renderSealed(f) {
99
- const lines = [SEALED_HEADER, `# readers ${f.readers.join(' ')}`];
100
- if (f.vault)
101
- lines.push(`# vault ${f.vault}`);
102
- for (const e of f.entries)
103
- lines.push(`${e.name}=age:${Buffer.from(e.file).toString('base64')}`);
104
- return lines.join('\n') + '\n';
105
- }
106
- /** Read `.env.sealed` v1 back. Refuses anything that is not exactly the format. */
107
- export function parseSealed(text) {
108
- const lines = text.split(/\r?\n/);
109
- if (lines[0] !== SEALED_HEADER)
110
- return bad('this is not a one-secrets v1 file', 'not_sealed');
111
- let readers;
112
- let vault;
113
- const entries = [];
114
- const seen = new Set();
115
- for (let i = 1; i < lines.length; i++) {
116
- const l = lines[i];
117
- if (l === '')
118
- continue;
119
- if (l.startsWith('# ')) {
120
- if (entries.length)
121
- return bad(`line ${i + 1}: the header comes before the values`, 'not_sealed');
122
- if (l.startsWith('# readers ') && !readers)
123
- readers = l.slice('# readers '.length).split(' ').filter(Boolean);
124
- else if (l.startsWith('# vault ') && vault === undefined && isVaultId(l.slice('# vault '.length)))
125
- vault = l.slice('# vault '.length);
126
- else
127
- return bad(`line ${i + 1}: unknown header line`, 'not_sealed');
128
- continue;
129
- }
130
- const m = /^([A-Za-z_][A-Za-z0-9_]*)=age:(.*)$/.exec(l);
131
- if (!m || !B64_RE.test(m[2]) || m[2] === '' || !NAME_RE.test(m[1]))
132
- return bad(`line ${i + 1}: not NAME=age:<base64>`, 'not_sealed');
133
- if (seen.has(m[1]))
134
- return bad(`${m[1]} appears twice`, 'not_sealed');
135
- seen.add(m[1]);
136
- entries.push({ name: m[1], file: new Uint8Array(Buffer.from(m[2], 'base64')) });
137
- }
138
- if (!readers || readers.length === 0)
139
- return bad('the file lists no readers', 'not_sealed');
140
- return { readers, vault, entries };
141
- }
142
- /** Seal every value to every lock: one binary age file per value. */
143
- export async function sealEntries(entries, locks) {
144
- const enc = new TextEncoder();
145
- // A Secure Enclave reader means the `age` program seals the file (every reader on one command line);
146
- // with none, the SDK's own age does exactly what it always did.
147
- if (locks.some(isPluginLock))
148
- return entries.map((e) => ({ name: e.name, file: sealWithAge(enc.encode(e.value), locks) }));
149
- const age = await ageModule();
150
- return entries.map((e) => ({ name: e.name, file: age.encrypt(enc.encode(e.value), locks) }));
151
- }
152
- /**
153
- * Open the sealed file's values with one identity and compare them to `expected` byte for
154
- * byte — same names, same order, same count, every reader on every value. Returns null
155
- * when it all holds, else a plain failure that names a variable, never a value.
156
- */
157
- export async function verifySealed(sealed, expected, secret) {
158
- const age = await ageModule();
159
- const enc = new TextEncoder();
160
- const fail = (error) => ({ ok: false, error, code: 'readback_failed' });
161
- if (sealed.entries.length !== expected.length)
162
- return fail('the sealed file has a different number of variables than the .env');
163
- for (let i = 0; i < expected.length; i++) {
164
- const got = sealed.entries[i];
165
- const want = expected[i];
166
- if (got.name !== want.name)
167
- return fail(`variable ${i + 1} reads back under a different name`);
168
- let stanzas;
169
- let plain;
170
- try {
171
- stanzas = age.parseHeader(got.file).stanzas.length;
172
- plain = age.decrypt(got.file, [secret]);
173
- }
174
- catch {
175
- return fail(`${want.name} does not open with the paper key`);
176
- }
177
- if (stanzas !== sealed.readers.length)
178
- return fail(`${want.name} is not sealed to every reader`);
179
- const w = enc.encode(want.value);
180
- if (plain.length !== w.length || !plain.every((b, k) => b === w[k]))
181
- return fail(`${want.name} does not read back byte for byte`);
182
- }
183
- return null;
184
- }
@@ -1,86 +0,0 @@
1
- import { type Asker, type BoardRes, type BulkRes } from '@oneie/sdk/tasks-bulk';
2
- /** All valid Flow IDs */
3
- export declare const FLOWS: readonly ["card", "page", "write", "secure", "decide", "operate", "recon", "rollup"];
4
- export type FlowId = (typeof FLOWS)[number];
5
- /** Row metadata used to derive a flow */
6
- export interface FlowRow {
7
- role?: string | null;
8
- family?: string | null;
9
- rung?: string | null;
10
- }
11
- /** Valid role values (labels and signals) */
12
- export declare const ROLES: readonly ["leaf", "epic", "operate", "decision", "recon", "settle", "dupe"];
13
- /** Valid rung values */
14
- export declare const RUNGS: readonly ["trivial", "contained", "shaped", "irreversible"];
15
- /** Valid family values */
16
- export declare const FAMILIES: readonly ["copy", "doc", "chain", "security", "schema", "astro-page", "puck-block", "ts-lib", "react-component", "react-hook", "receiver", "interface", "worker", "d1", "workflow", "eval", "test-gate", "perf"];
17
- /** Compute the FlowId from a FlowRow (exact spec port) */
18
- export declare function flowOf(row: FlowRow): FlowId | null;
19
- /** Format a flow line for notes */
20
- export declare function flowNote(flow: FlowId): string;
21
- /** Check if notes already contain a Flow: line */
22
- export declare function hasFlowLine(notes: string | null | undefined): boolean;
23
- /** Append a flow line to notes (never modify existing text) */
24
- export declare function appendFlowNote(notes: string | null | undefined, flow: FlowId): string;
25
- export type SignalSource = 'notes' | 'tags' | 'classified';
26
- export interface BoardRowIn {
27
- tid: string;
28
- name?: string;
29
- status?: string;
30
- notes?: string | null;
31
- tags?: string[];
32
- }
33
- export interface ClassifiedRow {
34
- tid: string;
35
- role?: string | null;
36
- family?: string | null;
37
- rung?: string | null;
38
- flow?: string | null;
39
- }
40
- /** Read signals from notes, tags, and classified data in priority order */
41
- export declare function readSignals(row: BoardRowIn, classified?: ClassifiedRow): {
42
- signals: FlowRow;
43
- sources: SignalSource[];
44
- };
45
- export interface FlowPlanEdit {
46
- tid: string;
47
- notes: string;
48
- addTags: string[];
49
- }
50
- export interface FlowPlan {
51
- counts: Record<FlowId, number>;
52
- placed: number;
53
- unplaced: string[];
54
- alreadyTagged: string[];
55
- mismatches: {
56
- tid: string;
57
- computed: FlowId | null;
58
- file: string;
59
- }[];
60
- bySource: Record<SignalSource, number>;
61
- edits: FlowPlanEdit[];
62
- }
63
- /** Build a plan for applying flow tags to board rows */
64
- export declare function planFlowTags(rows: BoardRowIn[], classified?: ClassifiedRow[]): FlowPlan;
65
- export interface RunFlowOpts {
66
- workspace?: string;
67
- tree?: boolean;
68
- status?: string;
69
- apply?: boolean;
70
- maxAgeSec?: number;
71
- now?: number;
72
- board?: BoardRes;
73
- fresh?: boolean;
74
- }
75
- export interface RunFlowResult {
76
- ok: boolean;
77
- dryRun: boolean;
78
- plan?: FlowPlan;
79
- total?: number;
80
- asOf?: string;
81
- truncated?: unknown;
82
- applied?: BulkRes;
83
- error?: string;
84
- }
85
- /** Orchestrate the flow tag operation: plan and optionally apply */
86
- export declare function runFlow(ask: Asker, classified: ClassifiedRow[], opts: RunFlowOpts): Promise<RunFlowResult>;
@@ -1,230 +0,0 @@
1
- import { boardAllWith, bulkAllWith, } from '@oneie/sdk/tasks-bulk';
2
- // ── Constants ──────────────────────────────────────────────────────────
3
- /** All valid Flow IDs */
4
- export const FLOWS = ['card', 'page', 'write', 'secure', 'decide', 'operate', 'recon', 'rollup'];
5
- /** Valid role values (labels and signals) */
6
- export const ROLES = ['leaf', 'epic', 'operate', 'decision', 'recon', 'settle', 'dupe'];
7
- /** Valid rung values */
8
- export const RUNGS = ['trivial', 'contained', 'shaped', 'irreversible'];
9
- /** Valid family values */
10
- export const FAMILIES = [
11
- 'copy', 'doc', 'chain', 'security', 'schema', 'astro-page', 'puck-block',
12
- 'ts-lib', 'react-component', 'react-hook', 'receiver', 'interface', 'worker',
13
- 'd1', 'workflow', 'eval', 'test-gate', 'perf',
14
- ];
15
- // ── Derivation helpers ─────────────────────────────────────────────────
16
- /** Compute the FlowId from a FlowRow (exact spec port) */
17
- export function flowOf(row) {
18
- const { role, rung, family } = row;
19
- if (role === 'decision')
20
- return 'decide';
21
- if (role === 'operate')
22
- return 'operate';
23
- if (role === 'recon')
24
- return 'recon';
25
- if (role === 'epic' || role === 'dupe' || role === 'settle')
26
- return 'rollup';
27
- if (role !== 'leaf')
28
- return null;
29
- if (!rung || !RUNGS.includes(rung))
30
- return null;
31
- if (family == null)
32
- return null;
33
- if (['copy', 'doc'].includes(family))
34
- return 'write';
35
- if (rung === 'irreversible' || ['chain', 'security', 'schema'].includes(family))
36
- return 'secure';
37
- if (['astro-page', 'puck-block'].includes(family))
38
- return 'page';
39
- if (['ts-lib', 'react-component', 'react-hook', 'receiver', 'interface', 'worker', 'd1', 'workflow', 'eval', 'test-gate', 'perf'].includes(family)) {
40
- return rung === 'shaped' ? 'secure' : 'card';
41
- }
42
- return null;
43
- }
44
- /** Format a flow line for notes */
45
- export function flowNote(flow) {
46
- return `Flow: ${flow}`;
47
- }
48
- /** Check if notes already contain a Flow: line */
49
- export function hasFlowLine(notes) {
50
- return /^[ \t]*flow[ \t]*:/im.test(notes ?? '');
51
- }
52
- /** Append a flow line to notes (never modify existing text) */
53
- export function appendFlowNote(notes, flow) {
54
- const line = flowNote(flow);
55
- if (!notes)
56
- return line;
57
- return notes.endsWith('\n') ? notes + line : notes + '\n' + line;
58
- }
59
- /** Read signals from notes, tags, and classified data in priority order */
60
- export function readSignals(row, classified) {
61
- const signals = {};
62
- const fieldSources = {};
63
- // Helper: try to extract a value from a notes line
64
- function getNotesValue(label, valid) {
65
- const re = new RegExp(`^[ \\t]*${label}[ \\t]*:[ \\t]*([a-z0-9-]+)[ \\t\\r]*$`, 'im');
66
- const m = re.exec(row.notes ?? '');
67
- if (m) {
68
- const val = m[1].toLowerCase();
69
- if (valid.includes(val))
70
- return val;
71
- }
72
- return undefined;
73
- }
74
- // Helper: try to extract a value from tags
75
- function getTagValue(prefix, valid) {
76
- if (!row.tags)
77
- return undefined;
78
- for (const tag of row.tags) {
79
- const re = new RegExp(`^${prefix}-([a-z0-9-]+)$`, 'i');
80
- const m = re.exec(tag);
81
- if (m) {
82
- const val = m[1].toLowerCase();
83
- if (valid.includes(val))
84
- return val;
85
- }
86
- }
87
- return undefined;
88
- }
89
- // Role
90
- const roleFromNotes = getNotesValue('role', ROLES);
91
- const roleFromTags = getTagValue('role', ROLES);
92
- const roleFromClassified = classified && ROLES.includes(classified.role ?? '') ? classified.role : undefined;
93
- const role = roleFromNotes ?? roleFromTags ?? roleFromClassified;
94
- if (role !== undefined) {
95
- signals.role = role;
96
- if (roleFromNotes !== undefined)
97
- fieldSources['role'] = 'notes';
98
- else if (roleFromTags !== undefined)
99
- fieldSources['role'] = 'tags';
100
- else if (roleFromClassified !== undefined)
101
- fieldSources['role'] = 'classified';
102
- }
103
- // Family
104
- const familyFromNotes = getNotesValue('family', FAMILIES);
105
- const familyFromTags = getTagValue('family', FAMILIES);
106
- const familyFromClassified = classified && FAMILIES.includes(classified.family ?? '') ? classified.family : undefined;
107
- const family = familyFromNotes ?? familyFromTags ?? familyFromClassified;
108
- if (family !== undefined) {
109
- signals.family = family;
110
- if (familyFromNotes !== undefined)
111
- fieldSources['family'] = 'notes';
112
- else if (familyFromTags !== undefined)
113
- fieldSources['family'] = 'tags';
114
- else if (familyFromClassified !== undefined)
115
- fieldSources['family'] = 'classified';
116
- }
117
- // Rung
118
- const rungFromNotes = getNotesValue('rung', RUNGS);
119
- const rungFromTags = getTagValue('rung', RUNGS);
120
- const rungFromClassified = classified && RUNGS.includes(classified.rung ?? '') ? classified.rung : undefined;
121
- const rung = rungFromNotes ?? rungFromTags ?? rungFromClassified;
122
- if (rung !== undefined) {
123
- signals.rung = rung;
124
- if (rungFromNotes !== undefined)
125
- fieldSources['rung'] = 'notes';
126
- else if (rungFromTags !== undefined)
127
- fieldSources['rung'] = 'tags';
128
- else if (rungFromClassified !== undefined)
129
- fieldSources['rung'] = 'classified';
130
- }
131
- // Build sources list preserving priority order and only those that contributed at least one field
132
- const sources = [];
133
- const usedSources = new Set(Object.values(fieldSources));
134
- if (usedSources.has('notes'))
135
- sources.push('notes');
136
- if (usedSources.has('tags'))
137
- sources.push('tags');
138
- if (usedSources.has('classified'))
139
- sources.push('classified');
140
- return { signals, sources };
141
- }
142
- /** Build a plan for applying flow tags to board rows */
143
- export function planFlowTags(rows, classified = []) {
144
- const classifiedByTid = new Map();
145
- for (const c of classified) {
146
- if (!classifiedByTid.has(c.tid))
147
- classifiedByTid.set(c.tid, c);
148
- }
149
- const seen = new Set();
150
- const counts = { card: 0, page: 0, write: 0, secure: 0, decide: 0, operate: 0, recon: 0, rollup: 0 };
151
- const unplaced = [];
152
- const alreadyTagged = [];
153
- const mismatches = [];
154
- const bySource = { notes: 0, tags: 0, classified: 0 };
155
- const edits = [];
156
- let placed = 0;
157
- for (const row of rows) {
158
- if (seen.has(row.tid))
159
- continue;
160
- seen.add(row.tid);
161
- if (hasFlowLine(row.notes)) {
162
- alreadyTagged.push(row.tid);
163
- continue;
164
- }
165
- const cls = classifiedByTid.get(row.tid);
166
- const { signals, sources } = readSignals(row, cls);
167
- const computed = flowOf(signals);
168
- // Mismatch? Only when cls.flow is a non-empty string and differs from computed
169
- if (cls?.flow && cls.flow !== computed) {
170
- mismatches.push({ tid: row.tid, computed, file: cls.flow });
171
- // continue removed – fall through to normal placement logic
172
- }
173
- if (computed === null) {
174
- unplaced.push(row.tid);
175
- continue;
176
- }
177
- for (const s of sources)
178
- bySource[s]++;
179
- const newNotes = appendFlowNote(row.notes, computed);
180
- counts[computed]++;
181
- placed++;
182
- edits.push({ tid: row.tid, notes: newNotes, addTags: [`flow-${computed}`] });
183
- }
184
- return { counts, placed, unplaced, alreadyTagged, mismatches, bySource, edits };
185
- }
186
- /** Orchestrate the flow tag operation: plan and optionally apply */
187
- export async function runFlow(ask, classified, opts) {
188
- const board = opts.board ??
189
- (await boardAllWith(ask, {
190
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
191
- scope: opts.tree ? 'tree' : undefined,
192
- status: opts.status ?? 'active',
193
- include: ['notes'],
194
- limit: 2000,
195
- ...(opts.fresh ? { fresh: true } : {}),
196
- }));
197
- if (board.ok === false) {
198
- return { ok: false, dryRun: !opts.apply, error: board.error ?? 'tasks:board failed' };
199
- }
200
- const plan = planFlowTags(board.tasks ?? [], classified);
201
- if (!opts.apply) {
202
- return { ok: true, dryRun: true, plan, total: board.total, asOf: board.asOf, truncated: board.truncated };
203
- }
204
- // Apply refusals
205
- if (opts.board) {
206
- return { ok: false, dryRun: false, plan, error: 'apply_needs_live_read' };
207
- }
208
- if (board.truncated?.rows !== undefined) {
209
- return { ok: false, dryRun: false, plan, error: 'apply_refused_truncated' };
210
- }
211
- const maxAge = opts.maxAgeSec ?? 120;
212
- if (!Number.isFinite(maxAge) || maxAge < 0) {
213
- return { ok: false, dryRun: false, plan, error: 'apply_refused_bad_max_age' };
214
- }
215
- const asOf = board.asOf;
216
- const t = asOf ? Date.parse(asOf) : NaN;
217
- const age = (opts.now ?? Date.now()) - t;
218
- if (!Number.isFinite(age) || age > maxAge * 1000) {
219
- return { ok: false, dryRun: false, plan, error: 'apply_refused_stale' };
220
- }
221
- if (plan.edits.length === 0) {
222
- return { ok: true, dryRun: false, plan, applied: undefined };
223
- }
224
- const applied = await bulkAllWith(ask, {
225
- ...(opts.workspace ? { workspace: opts.workspace } : {}),
226
- edits: plan.edits,
227
- });
228
- const ok = applied.ok !== false && (applied.failed ?? 0) === 0;
229
- return { ok, dryRun: false, plan, total: board.total, asOf, truncated: board.truncated, applied };
230
- }