@oneie/cli 5.7.6 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +19 -1
  2. package/dist/package.json +7 -8
  3. package/dist/src/age-yefbe8pe.js +1 -0
  4. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  5. package/dist/src/hl-run-tgrkrk69.js +1 -0
  6. package/dist/src/index-0rj9wdk9.js +4 -0
  7. package/dist/src/index-91y484c2.js +2052 -0
  8. package/dist/src/index-940y3rnv.js +12 -0
  9. package/dist/src/index.js +1047 -121
  10. package/dist/src/message-key-db1xjdkw.js +1 -0
  11. package/dist/src/message-lock-5vr8079x.js +5 -0
  12. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  13. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  14. package/package.json +7 -8
  15. package/dist/src/agent.d.ts +0 -75
  16. package/dist/src/agent.js +0 -1334
  17. package/dist/src/agentverse.d.ts +0 -26
  18. package/dist/src/agentverse.js +0 -171
  19. package/dist/src/args.d.ts +0 -9
  20. package/dist/src/args.js +0 -61
  21. package/dist/src/auth.d.ts +0 -6
  22. package/dist/src/auth.js +0 -121
  23. package/dist/src/balances.d.ts +0 -89
  24. package/dist/src/balances.js +0 -202
  25. package/dist/src/banner.d.ts +0 -1
  26. package/dist/src/banner.js +0 -17
  27. package/dist/src/broadcast.d.ts +0 -8
  28. package/dist/src/broadcast.js +0 -175
  29. package/dist/src/catalog.d.ts +0 -12
  30. package/dist/src/catalog.js +0 -76
  31. package/dist/src/chat.d.ts +0 -2
  32. package/dist/src/chat.js +0 -92
  33. package/dist/src/client.d.ts +0 -5
  34. package/dist/src/client.js +0 -157
  35. package/dist/src/compiler.d.ts +0 -36
  36. package/dist/src/compiler.js +0 -366
  37. package/dist/src/config.d.ts +0 -24
  38. package/dist/src/config.js +0 -70
  39. package/dist/src/connect.d.ts +0 -2
  40. package/dist/src/connect.js +0 -64
  41. package/dist/src/coordinate.d.ts +0 -3
  42. package/dist/src/coordinate.js +0 -58
  43. package/dist/src/create.d.ts +0 -2
  44. package/dist/src/create.js +0 -113
  45. package/dist/src/deploy.d.ts +0 -2
  46. package/dist/src/deploy.js +0 -19
  47. package/dist/src/dev.d.ts +0 -2
  48. package/dist/src/dev.js +0 -75
  49. package/dist/src/device-flow.d.ts +0 -57
  50. package/dist/src/device-flow.js +0 -173
  51. package/dist/src/doctor.d.ts +0 -26
  52. package/dist/src/doctor.js +0 -146
  53. package/dist/src/draw.d.ts +0 -18
  54. package/dist/src/draw.js +0 -156
  55. package/dist/src/endpoint.d.ts +0 -2
  56. package/dist/src/endpoint.js +0 -250
  57. package/dist/src/env.d.ts +0 -3
  58. package/dist/src/env.js +0 -37
  59. package/dist/src/eval.d.ts +0 -2
  60. package/dist/src/eval.js +0 -43
  61. package/dist/src/fn.d.ts +0 -2
  62. package/dist/src/fn.js +0 -70
  63. package/dist/src/group.d.ts +0 -2
  64. package/dist/src/group.js +0 -117
  65. package/dist/src/hl-run.d.ts +0 -119
  66. package/dist/src/hl-run.js +0 -480
  67. package/dist/src/hl.d.ts +0 -17
  68. package/dist/src/hl.js +0 -148
  69. package/dist/src/index.d.ts +0 -2
  70. package/dist/src/init.d.ts +0 -76
  71. package/dist/src/init.js +0 -278
  72. package/dist/src/join.d.ts +0 -11
  73. package/dist/src/join.js +0 -293
  74. package/dist/src/key-publish.d.ts +0 -40
  75. package/dist/src/key-publish.js +0 -232
  76. package/dist/src/key-seal.d.ts +0 -21
  77. package/dist/src/key-seal.js +0 -142
  78. package/dist/src/key-sweep.d.ts +0 -93
  79. package/dist/src/key-sweep.js +0 -263
  80. package/dist/src/key.d.ts +0 -26
  81. package/dist/src/key.js +0 -338
  82. package/dist/src/lib/age-plugin.d.ts +0 -51
  83. package/dist/src/lib/age-plugin.js +0 -130
  84. package/dist/src/lib/agent-env.d.ts +0 -12
  85. package/dist/src/lib/agent-env.js +0 -48
  86. package/dist/src/lib/api-path.d.ts +0 -2
  87. package/dist/src/lib/api-path.js +0 -40
  88. package/dist/src/lib/asker.d.ts +0 -34
  89. package/dist/src/lib/asker.js +0 -126
  90. package/dist/src/lib/client.d.ts +0 -20
  91. package/dist/src/lib/client.js +0 -71
  92. package/dist/src/lib/env-sealed.d.ts +0 -53
  93. package/dist/src/lib/env-sealed.js +0 -184
  94. package/dist/src/lib/flow-tag.d.ts +0 -86
  95. package/dist/src/lib/flow-tag.js +0 -230
  96. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  97. package/dist/src/lib/hl-core/actions.js +0 -69
  98. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  99. package/dist/src/lib/hl-core/eip712.js +0 -107
  100. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  101. package/dist/src/lib/hl-core/errors.js +0 -15
  102. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  103. package/dist/src/lib/hl-core/exchange.js +0 -47
  104. package/dist/src/lib/hl-core/index.d.ts +0 -13
  105. package/dist/src/lib/hl-core/index.js +0 -14
  106. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  107. package/dist/src/lib/hl-core/meta.js +0 -110
  108. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  109. package/dist/src/lib/hl-core/msgpack.js +0 -136
  110. package/dist/src/lib/hl-core/net.d.ts +0 -2
  111. package/dist/src/lib/hl-core/net.js +0 -7
  112. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  113. package/dist/src/lib/hl-core/signing.js +0 -295
  114. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  115. package/dist/src/lib/hl-core/wire.js +0 -81
  116. package/dist/src/lib/invoked-as.d.ts +0 -2
  117. package/dist/src/lib/invoked-as.js +0 -24
  118. package/dist/src/lib/journey-words.d.ts +0 -84
  119. package/dist/src/lib/journey-words.js +0 -360
  120. package/dist/src/lib/journey.d.ts +0 -148
  121. package/dist/src/lib/journey.js +0 -245
  122. package/dist/src/lib/key-receipt.d.ts +0 -48
  123. package/dist/src/lib/key-receipt.js +0 -116
  124. package/dist/src/lib/key-source.d.ts +0 -9
  125. package/dist/src/lib/key-source.js +0 -33
  126. package/dist/src/lib/keyfile.d.ts +0 -136
  127. package/dist/src/lib/keyfile.js +0 -397
  128. package/dist/src/lib/launch-claude.d.ts +0 -5
  129. package/dist/src/lib/launch-claude.js +0 -45
  130. package/dist/src/lib/lock-lookup.d.ts +0 -40
  131. package/dist/src/lib/lock-lookup.js +0 -92
  132. package/dist/src/lib/message-seal.d.ts +0 -63
  133. package/dist/src/lib/message-seal.js +0 -150
  134. package/dist/src/lib/network.d.ts +0 -15
  135. package/dist/src/lib/network.js +0 -41
  136. package/dist/src/lib/paths.d.ts +0 -41
  137. package/dist/src/lib/paths.js +0 -91
  138. package/dist/src/lib/plan-draw.d.ts +0 -56
  139. package/dist/src/lib/plan-draw.js +0 -219
  140. package/dist/src/lib/plan-live.d.ts +0 -20
  141. package/dist/src/lib/plan-live.js +0 -192
  142. package/dist/src/lib/qr.d.ts +0 -21
  143. package/dist/src/lib/qr.js +0 -402
  144. package/dist/src/lib/roster.d.ts +0 -20
  145. package/dist/src/lib/roster.js +0 -79
  146. package/dist/src/lib/sale-card.d.ts +0 -117
  147. package/dist/src/lib/sale-card.js +0 -261
  148. package/dist/src/lib/shop-init.d.ts +0 -62
  149. package/dist/src/lib/shop-init.js +0 -63
  150. package/dist/src/lib/sui-grpc-send.d.ts +0 -50
  151. package/dist/src/lib/sui-grpc-send.js +0 -89
  152. package/dist/src/lib/swap-core.d.ts +0 -163
  153. package/dist/src/lib/swap-core.js +0 -405
  154. package/dist/src/lib/tasks-digest.d.ts +0 -66
  155. package/dist/src/lib/tasks-digest.js +0 -200
  156. package/dist/src/lib/tasks-graph.d.ts +0 -79
  157. package/dist/src/lib/tasks-graph.js +0 -463
  158. package/dist/src/lib/tasks-lens.d.ts +0 -31
  159. package/dist/src/lib/tasks-lens.js +0 -47
  160. package/dist/src/lib/tasks-next.d.ts +0 -25
  161. package/dist/src/lib/tasks-next.js +0 -103
  162. package/dist/src/lib/tasks-prove.d.ts +0 -15
  163. package/dist/src/lib/tasks-prove.js +0 -68
  164. package/dist/src/lib/tasks-route.d.ts +0 -29
  165. package/dist/src/lib/tasks-route.js +0 -151
  166. package/dist/src/lib/tasks-score.d.ts +0 -36
  167. package/dist/src/lib/tasks-score.js +0 -152
  168. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  169. package/dist/src/lib/tasks-workspace.js +0 -73
  170. package/dist/src/lib/vault-read.d.ts +0 -24
  171. package/dist/src/lib/vault-read.js +0 -77
  172. package/dist/src/lib/vaultfile.d.ts +0 -88
  173. package/dist/src/lib/vaultfile.js +0 -222
  174. package/dist/src/lib/wallet-money.d.ts +0 -222
  175. package/dist/src/lib/wallet-money.js +0 -578
  176. package/dist/src/lib/wallet-request.d.ts +0 -50
  177. package/dist/src/lib/wallet-request.js +0 -86
  178. package/dist/src/links.d.ts +0 -5
  179. package/dist/src/links.js +0 -45
  180. package/dist/src/media.d.ts +0 -29
  181. package/dist/src/media.js +0 -487
  182. package/dist/src/message-receipt.d.ts +0 -25
  183. package/dist/src/message-receipt.js +0 -71
  184. package/dist/src/message.d.ts +0 -13
  185. package/dist/src/message.js +0 -92
  186. package/dist/src/onboard.d.ts +0 -16
  187. package/dist/src/onboard.js +0 -149
  188. package/dist/src/plugin.d.ts +0 -2
  189. package/dist/src/plugin.js +0 -193
  190. package/dist/src/push.d.ts +0 -2
  191. package/dist/src/push.js +0 -115
  192. package/dist/src/render.d.ts +0 -21
  193. package/dist/src/render.js +0 -32
  194. package/dist/src/secrets-device.d.ts +0 -32
  195. package/dist/src/secrets-device.js +0 -127
  196. package/dist/src/secrets-give.d.ts +0 -125
  197. package/dist/src/secrets-give.js +0 -236
  198. package/dist/src/secrets-list.d.ts +0 -27
  199. package/dist/src/secrets-list.js +0 -84
  200. package/dist/src/secrets-run.d.ts +0 -31
  201. package/dist/src/secrets-run.js +0 -182
  202. package/dist/src/secrets.d.ts +0 -33
  203. package/dist/src/secrets.js +0 -200
  204. package/dist/src/setup.d.ts +0 -6
  205. package/dist/src/setup.js +0 -127
  206. package/dist/src/ship.d.ts +0 -2
  207. package/dist/src/ship.js +0 -18
  208. package/dist/src/shop.d.ts +0 -10
  209. package/dist/src/shop.js +0 -110
  210. package/dist/src/skill-parser.d.ts +0 -14
  211. package/dist/src/skill-parser.js +0 -113
  212. package/dist/src/skill.d.ts +0 -2
  213. package/dist/src/skill.js +0 -493
  214. package/dist/src/slug.d.ts +0 -2
  215. package/dist/src/slug.js +0 -6
  216. package/dist/src/social.d.ts +0 -2
  217. package/dist/src/social.js +0 -106
  218. package/dist/src/staff.d.ts +0 -2
  219. package/dist/src/staff.js +0 -104
  220. package/dist/src/start.d.ts +0 -15
  221. package/dist/src/start.js +0 -203
  222. package/dist/src/status.d.ts +0 -2
  223. package/dist/src/status.js +0 -52
  224. package/dist/src/substrate.d.ts +0 -2
  225. package/dist/src/substrate.js +0 -258
  226. package/dist/src/swap.d.ts +0 -93
  227. package/dist/src/swap.js +0 -622
  228. package/dist/src/tasks.d.ts +0 -2
  229. package/dist/src/tasks.js +0 -743
  230. package/dist/src/templates.d.ts +0 -1
  231. package/dist/src/templates.js +0 -213
  232. package/dist/src/trade.d.ts +0 -2
  233. package/dist/src/trade.js +0 -91
  234. package/dist/src/trail.d.ts +0 -2
  235. package/dist/src/trail.js +0 -41
  236. package/dist/src/validate.d.ts +0 -13
  237. package/dist/src/validate.js +0 -35
  238. package/dist/src/wallet-money.d.ts +0 -152
  239. package/dist/src/wallet-money.js +0 -564
  240. package/dist/src/wallet.d.ts +0 -167
  241. package/dist/src/wallet.js +0 -855
  242. package/dist/src/workflow.d.ts +0 -2
  243. package/dist/src/workflow.js +0 -166
  244. package/dist/src/write.d.ts +0 -43
  245. package/dist/src/write.js +0 -180
@@ -1,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
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * hyperliquid/actions — builders for the four actions ONE prepares (text/hyperliquid-plan.md H2):
3
- *
4
- * L1 (msgpack-hashed, phantom-agent signed) order · cancel
5
- * user-signed (own EIP-712 domain) usdClassTransfer · withdraw3
6
- *
7
- * KEY ORDER IS PART OF THE HASH for L1 actions: msgpack keeps insertion order, so each literal
8
- * below is written in exactly the python SDK's order (`order_request_to_order_wire`,
9
- * `order_wires_to_order_action`, `bulk_cancel`). Do not "tidy" them.
10
- *
11
- * Every builder validates against the asset's tick rules and throws `HlRefusal` before an action
12
- * exists. Nothing here reads the network or the clock: nonce and mid come in as arguments.
13
- */
14
- import { type AssetInfo } from './meta.js';
15
- export type Tif = 'Gtc' | 'Ioc' | 'Alo';
16
- export interface OrderWire {
17
- a: number;
18
- b: boolean;
19
- p: string;
20
- s: string;
21
- r: boolean;
22
- t: {
23
- limit: {
24
- tif: Tif;
25
- };
26
- };
27
- c?: string;
28
- }
29
- export interface OrderAction {
30
- type: 'order';
31
- orders: OrderWire[];
32
- grouping: 'na';
33
- }
34
- export interface CancelAction {
35
- type: 'cancel';
36
- cancels: Array<{
37
- a: number;
38
- o: number;
39
- }>;
40
- }
41
- export interface UsdClassTransferAction {
42
- type: 'usdClassTransfer';
43
- amount: string;
44
- toPerp: boolean;
45
- nonce: number;
46
- }
47
- export interface Withdraw3Action {
48
- type: 'withdraw3';
49
- destination: string;
50
- amount: string;
51
- time: number;
52
- }
53
- export type L1Action = OrderAction | CancelAction;
54
- export type UserAction = UsdClassTransferAction | Withdraw3Action;
55
- export type HlAction = L1Action | UserAction;
56
- export interface LimitOrderInput {
57
- asset: AssetInfo;
58
- isBuy: boolean;
59
- /** Decimal string, in the asset's units. */
60
- sz: string;
61
- /** Decimal string. */
62
- px: string;
63
- tif?: Tif;
64
- reduceOnly?: boolean;
65
- /** 16-byte client order id, 0x + 32 hex. */
66
- cloid?: string;
67
- }
68
- export declare function orderWire(o: LimitOrderInput): OrderWire;
69
- export declare function buildOrder(o: LimitOrderInput): OrderAction;
70
- export interface MarketOrderInput {
71
- asset: AssetInfo;
72
- isBuy: boolean;
73
- sz: string;
74
- /** The mid the caller read (allMids). The core never fetches it. */
75
- mid: string;
76
- /** Default 0.05, the python SDK's DEFAULT_SLIPPAGE. */
77
- slippage?: number;
78
- reduceOnly?: boolean;
79
- cloid?: string;
80
- }
81
- /** A market order is an aggressive IOC limit (python `market_open` / `market_close`). */
82
- export declare function buildMarketOrder(o: MarketOrderInput): OrderAction;
83
- /** A cancel needs only the asset INDEX; pass the AssetInfo from the table when you have it. */
84
- export declare function buildCancel(o: {
85
- asset: Pick<AssetInfo, 'asset'>;
86
- oid: number;
87
- }): CancelAction;
88
- /** Move USDC between the spot and perps balances of the SAME account (toPerp: spot → perps). */
89
- export declare function buildUsdClassTransfer(o: {
90
- amount: string;
91
- toPerp: boolean;
92
- nonce: number;
93
- }): UsdClassTransferAction;
94
- /** Withdraw USDC from the PERPS balance to an address on Arbitrum. */
95
- export declare function buildWithdraw3(o: {
96
- destination: string;
97
- amount: string;
98
- time: number;
99
- }): Withdraw3Action;
@@ -1,69 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/actions.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/actions — builders for the four actions ONE prepares (text/hyperliquid-plan.md H2):
4
- *
5
- * L1 (msgpack-hashed, phantom-agent signed) order · cancel
6
- * user-signed (own EIP-712 domain) usdClassTransfer · withdraw3
7
- *
8
- * KEY ORDER IS PART OF THE HASH for L1 actions: msgpack keeps insertion order, so each literal
9
- * below is written in exactly the python SDK's order (`order_request_to_order_wire`,
10
- * `order_wires_to_order_action`, `bulk_cancel`). Do not "tidy" them.
11
- *
12
- * Every builder validates against the asset's tick rules and throws `HlRefusal` before an action
13
- * exists. Nothing here reads the network or the clock: nonce and mid come in as arguments.
14
- */
15
- import { HlRefusal } from './errors.js';
16
- import { BUILDER_DEX_OFFSET } from './meta.js';
17
- import { checkPrice, checkSize, checkUsd, marketPrice } from './wire.js';
18
- const TIFS = ['Gtc', 'Ioc', 'Alo'];
19
- const CLOID = /^0x[0-9a-fA-F]{32}$/;
20
- const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
21
- export function orderWire(o) {
22
- const tif = o.tif ?? 'Gtc';
23
- if (!TIFS.includes(tif))
24
- throw new HlRefusal('bad_tif', String(tif));
25
- if (o.asset.delisted)
26
- throw new HlRefusal('asset_delisted', o.asset.coin);
27
- const s = checkSize(o.sz, o.asset.szDecimals);
28
- const p = checkPrice(o.px, o.asset.szDecimals, o.asset.kind);
29
- if (o.cloid !== undefined && !CLOID.test(o.cloid))
30
- throw new HlRefusal('bad_cloid', o.cloid);
31
- const w = { a: o.asset.asset, b: o.isBuy, p, s, r: o.reduceOnly ?? false, t: { limit: { tif } } };
32
- if (o.cloid !== undefined)
33
- w.c = o.cloid.toLowerCase();
34
- return w;
35
- }
36
- export function buildOrder(o) {
37
- return { type: 'order', orders: [orderWire(o)], grouping: 'na' };
38
- }
39
- /** A market order is an aggressive IOC limit (python `market_open` / `market_close`). */
40
- export function buildMarketOrder(o) {
41
- const px = marketPrice(o.mid, o.isBuy, o.slippage ?? 0.05, o.asset.szDecimals, o.asset.kind);
42
- return buildOrder({ asset: o.asset, isBuy: o.isBuy, sz: o.sz, px, tif: 'Ioc', reduceOnly: o.reduceOnly, cloid: o.cloid });
43
- }
44
- /** A cancel needs only the asset INDEX; pass the AssetInfo from the table when you have it. */
45
- export function buildCancel(o) {
46
- const a = o.asset.asset;
47
- if (!Number.isSafeInteger(a) || a < 0)
48
- throw new HlRefusal('unknown_asset', String(a));
49
- if (a >= BUILDER_DEX_OFFSET)
50
- throw new HlRefusal('builder_dex_unsupported', String(a));
51
- if (!Number.isSafeInteger(o.oid) || o.oid < 0)
52
- throw new HlRefusal('bad_oid', String(o.oid));
53
- return { type: 'cancel', cancels: [{ a, o: o.oid }] };
54
- }
55
- function checkNonce(n) {
56
- if (!Number.isSafeInteger(n) || n <= 0)
57
- throw new HlRefusal('nonce_required', String(n));
58
- return n;
59
- }
60
- /** Move USDC between the spot and perps balances of the SAME account (toPerp: spot → perps). */
61
- export function buildUsdClassTransfer(o) {
62
- return { type: 'usdClassTransfer', amount: checkUsd(o.amount), toPerp: o.toPerp, nonce: checkNonce(o.nonce) };
63
- }
64
- /** Withdraw USDC from the PERPS balance to an address on Arbitrum. */
65
- export function buildWithdraw3(o) {
66
- if (!ADDRESS.test(o.destination))
67
- throw new HlRefusal('bad_address', o.destination);
68
- return { type: 'withdraw3', destination: o.destination.toLowerCase(), amount: checkUsd(o.amount), time: checkNonce(o.time) };
69
- }