oneie 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,463 +0,0 @@
1
- // CLOSED = satisfied. A closed row is never scheduled into a wave and every
2
- // edge pointing AT one is dropped before the graph is built.
3
- export const CLOSED = new Set(['done', 'verified', 'dissolved', 'failed']);
4
- const HINT_LINE = /^\s*(model|effort|touches|accept)\s*:\s*(.*)$/i;
5
- // Splits a Touches value on , · ; only at parenthesis depth 0, then per-piece
6
- // strips backticks, trailing parenthetical /\\s*\\([^)]*\\)\\s*$/, and trims.
7
- function splitTouches(value) {
8
- const pieces = [];
9
- let depth = 0;
10
- let start = 0;
11
- for (let i = 0; i < value.length; i++) {
12
- const ch = value[i];
13
- if (ch === '(')
14
- depth++;
15
- else if (ch === ')')
16
- depth--;
17
- else if (depth === 0 && /[,·;]/.test(ch)) {
18
- pieces.push(value.slice(start, i));
19
- start = i + 1;
20
- }
21
- }
22
- pieces.push(value.slice(start));
23
- return pieces
24
- .map((s) => s
25
- .replace(/`/g, '')
26
- .replace(/\s*\([^)]*\)\s*$/, '')
27
- .trim())
28
- .filter(Boolean);
29
- }
30
- // Dispatch hints live in a row's notes as labelled lines, one per line,
31
- // case-insensitive key, anywhere in the prose.
32
- export function parseHints(notes) {
33
- const hints = { touches: [] };
34
- if (!notes)
35
- return hints;
36
- for (const line of notes.split('\n')) {
37
- const m = HINT_LINE.exec(line);
38
- if (!m)
39
- continue;
40
- const key = m[1].toLowerCase();
41
- const value = m[2].trim();
42
- if (!value)
43
- continue;
44
- if (key === 'model')
45
- hints.model = value;
46
- else if (key === 'effort')
47
- hints.effort = value;
48
- else if (key === 'accept')
49
- hints.accept = value;
50
- else if (key === 'touches')
51
- hints.touches = splitTouches(value);
52
- }
53
- return hints;
54
- }
55
- // Root + all descendants via `parent`, root included; [] if root absent.
56
- export function subtree(rows, rootTid) {
57
- const byTid = new Map(rows.map((r) => [r.tid, r]));
58
- if (!byTid.has(rootTid))
59
- return [];
60
- const children = new Map();
61
- for (const r of rows) {
62
- if (r.parent) {
63
- const arr = children.get(r.parent) ?? [];
64
- arr.push(r);
65
- children.set(r.parent, arr);
66
- }
67
- }
68
- const out = [];
69
- const seen = new Set();
70
- const queue = [rootTid];
71
- while (queue.length > 0) {
72
- const tid = queue.shift();
73
- if (seen.has(tid))
74
- continue;
75
- seen.add(tid);
76
- const r = byTid.get(tid);
77
- if (!r)
78
- continue;
79
- out.push(r);
80
- for (const c of children.get(tid) ?? [])
81
- queue.push(c.tid);
82
- }
83
- return out;
84
- }
85
- export function sameFile(a, b) {
86
- if (a === b)
87
- return true;
88
- if (a.length >= b.length) {
89
- if (a.endsWith('/' + b))
90
- return true;
91
- }
92
- else {
93
- if (b.endsWith('/' + a))
94
- return true;
95
- }
96
- return false;
97
- }
98
- export function planWaves(rows) {
99
- const fullMap = new Map();
100
- for (const r of rows)
101
- fullMap.set(r.tid, r);
102
- const closed = [];
103
- const nodeIds = [];
104
- for (const r of rows) {
105
- if (CLOSED.has(r.status))
106
- closed.push(r.tid);
107
- else
108
- nodeIds.push(r.tid);
109
- }
110
- const nodeSet = new Set(nodeIds);
111
- const missing = [];
112
- const outsideMarked = new Set();
113
- const outside = [];
114
- const ownerless = [];
115
- const implied = [];
116
- const preds = new Map();
117
- const succs = new Map();
118
- for (const tid of nodeIds) {
119
- preds.set(tid, new Set());
120
- succs.set(tid, new Set());
121
- }
122
- const addEdge = (prereq, waiter) => {
123
- preds.get(waiter)?.add(prereq);
124
- succs.get(prereq)?.add(waiter);
125
- };
126
- // blockedBy edges + missing/outside accounting
127
- for (const tid of nodeIds) {
128
- const r = fullMap.get(tid);
129
- if (!r.assignee)
130
- ownerless.push(tid);
131
- const blockedByArr = r.blockedBy ?? [];
132
- const absent = [];
133
- let inSetOpen = 0;
134
- for (const b of blockedByArr) {
135
- const br = fullMap.get(b);
136
- if (!br) {
137
- absent.push(b);
138
- continue;
139
- }
140
- if (CLOSED.has(br.status))
141
- continue;
142
- inSetOpen += 1;
143
- if (nodeSet.has(b))
144
- addEdge(b, tid);
145
- }
146
- // A blocker absent from the rows is ambiguous: the board read is usually
147
- // ACTIVE rows only, so a CLOSED blocker is absent too, and so is an open one
148
- // outside this goal's subtree. The server's openBlockers settles it — never
149
- // the raw blockedBy (a closed blocker once read as "absent", which is the
150
- // defect this module exists to stop repeating). Only when the server gave no
151
- // count is an absent blocker unknowable, and only then is it `missing`.
152
- if (r.openBlockers === undefined) {
153
- for (const b of absent)
154
- missing.push({ tid, blockedBy: b });
155
- }
156
- else if (r.openBlockers > inSetOpen) {
157
- outsideMarked.add(tid);
158
- outside.push({ tid, open: r.openBlockers - inSetOpen });
159
- }
160
- }
161
- // containment: a parent waits for every non-closed child present in the set.
162
- for (const tid of nodeIds) {
163
- const r = fullMap.get(tid);
164
- if (r.parent && nodeSet.has(r.parent)) {
165
- addEdge(tid, r.parent);
166
- implied.push({ tid: r.parent, waitsFor: tid, reason: 'containment' });
167
- }
168
- }
169
- const priorityOf = (tid) => fullMap.get(tid)?.priority ?? 0;
170
- const runKahn = () => {
171
- const inDeg = new Map();
172
- for (const tid of nodeIds)
173
- inDeg.set(tid, preds.get(tid)?.size ?? 0);
174
- const scheduled = new Set();
175
- const waves = [];
176
- let current = nodeIds.filter((t) => inDeg.get(t) === 0 && !outsideMarked.has(t));
177
- while (current.length > 0) {
178
- for (const t of current)
179
- scheduled.add(t);
180
- waves.push(current);
181
- const nextCandidates = new Set();
182
- for (const t of current) {
183
- for (const s of succs.get(t) ?? []) {
184
- const d = (inDeg.get(s) ?? 0) - 1;
185
- inDeg.set(s, d);
186
- if (d === 0)
187
- nextCandidates.add(s);
188
- }
189
- }
190
- current = [...nextCandidates].filter((t) => !outsideMarked.has(t) && !scheduled.has(t));
191
- }
192
- return { waves, scheduled };
193
- };
194
- // Fixpoint: run Kahn's algorithm, look for same-wave `touches:` collisions,
195
- // add the implied serialising edge, and recompute until stable.
196
- let kahn = runKahn();
197
- const seenTouchesEdge = new Set();
198
- const maxIters = nodeIds.length + 5;
199
- for (let iter = 0; iter < maxIters; iter++) {
200
- let added = false;
201
- for (const wave of kahn.waves) {
202
- if (wave.length < 2)
203
- continue;
204
- const touchesOf = new Map();
205
- for (const tid of wave)
206
- touchesOf.set(tid, parseHints(fullMap.get(tid)?.notes).touches);
207
- for (let i = 0; i < wave.length; i++) {
208
- for (let j = i + 1; j < wave.length; j++) {
209
- const a = wave[i];
210
- const b = wave[j];
211
- const aTouches = touchesOf.get(a) ?? [];
212
- const bTouches = touchesOf.get(b) ?? [];
213
- const shared = aTouches.find((p) => bTouches.some((q) => sameFile(p, q)));
214
- if (!shared)
215
- continue;
216
- if (preds.get(a)?.has(b) || preds.get(b)?.has(a))
217
- continue;
218
- const pa = priorityOf(a);
219
- const pb = priorityOf(b);
220
- let winner;
221
- let loser;
222
- if (pa !== pb) {
223
- winner = pa > pb ? a : b;
224
- loser = pa > pb ? b : a;
225
- }
226
- else {
227
- // tie -> lexically larger tid waits
228
- winner = a < b ? a : b;
229
- loser = a < b ? b : a;
230
- }
231
- const key = `${loser}->${winner}`;
232
- if (seenTouchesEdge.has(key))
233
- continue;
234
- seenTouchesEdge.add(key);
235
- addEdge(winner, loser);
236
- implied.push({ tid: loser, waitsFor: winner, reason: 'touches', path: shared });
237
- added = true;
238
- }
239
- }
240
- }
241
- if (!added)
242
- break;
243
- kahn = runKahn();
244
- }
245
- // Leftover = never scheduled and not already explicitly marked outside.
246
- const leftover = nodeIds.filter((t) => !kahn.scheduled.has(t) && !outsideMarked.has(t));
247
- const leftoverSet = new Set(leftover);
248
- const cycles = [];
249
- {
250
- let index = 0;
251
- const indices = new Map();
252
- const lowlink = new Map();
253
- const onStack = new Set();
254
- const stack = [];
255
- const sccs = [];
256
- const strongconnect = (v) => {
257
- indices.set(v, index);
258
- lowlink.set(v, index);
259
- index += 1;
260
- stack.push(v);
261
- onStack.add(v);
262
- for (const w of preds.get(v) ?? []) {
263
- if (!leftoverSet.has(w))
264
- continue;
265
- if (!indices.has(w)) {
266
- strongconnect(w);
267
- lowlink.set(v, Math.min(lowlink.get(v), lowlink.get(w)));
268
- }
269
- else if (onStack.has(w)) {
270
- lowlink.set(v, Math.min(lowlink.get(v), indices.get(w)));
271
- }
272
- }
273
- if (lowlink.get(v) === indices.get(v)) {
274
- const comp = [];
275
- let w;
276
- do {
277
- w = stack.pop();
278
- onStack.delete(w);
279
- comp.push(w);
280
- } while (w !== v);
281
- sccs.push(comp);
282
- }
283
- };
284
- for (const v of leftover) {
285
- if (!indices.has(v))
286
- strongconnect(v);
287
- }
288
- const cycleMembers = new Set();
289
- for (const comp of sccs) {
290
- const isCycle = comp.length > 1 || preds.get(comp[0])?.has(comp[0]);
291
- if (isCycle) {
292
- cycles.push(comp.slice().sort());
293
- for (const t of comp)
294
- cycleMembers.add(t);
295
- }
296
- }
297
- // Downstream of a cycle (or of an outside-marked node) but not in a
298
- // cycle itself: still excluded from waves, reported as `outside`.
299
- for (const t of leftover) {
300
- if (cycleMembers.has(t))
301
- continue;
302
- const unresolved = [...(preds.get(t) ?? [])].filter((p) => !kahn.scheduled.has(p)).length;
303
- outside.push({ tid: t, open: unresolved });
304
- }
305
- }
306
- // Longest path (by node count) over the final DAG, in execution order.
307
- const longest = new Map();
308
- const pathParent = new Map();
309
- for (const wave of kahn.waves) {
310
- for (const t of wave) {
311
- let best = 1;
312
- let bestParent;
313
- for (const p of preds.get(t) ?? []) {
314
- if (!kahn.scheduled.has(p))
315
- continue;
316
- const val = (longest.get(p) ?? 1) + 1;
317
- if (val > best) {
318
- best = val;
319
- bestParent = p;
320
- }
321
- }
322
- longest.set(t, best);
323
- pathParent.set(t, bestParent);
324
- }
325
- }
326
- let bestTid;
327
- let bestLen = 0;
328
- for (const t of kahn.waves.flat()) {
329
- const l = longest.get(t) ?? 1;
330
- if (l > bestLen) {
331
- bestLen = l;
332
- bestTid = t;
333
- }
334
- }
335
- const pathTids = [];
336
- let cur = bestTid;
337
- while (cur !== undefined) {
338
- pathTids.unshift(cur);
339
- cur = pathParent.get(cur);
340
- }
341
- const criticalPath = { hops: Math.max(pathTids.length - 1, 0), tids: pathTids };
342
- const waves = kahn.waves.map((tids, i) => ({
343
- n: i + 1,
344
- tids: tids.slice().sort((a, b) => priorityOf(b) - priorityOf(a)),
345
- }));
346
- const seenOutside = new Set();
347
- const outsideDeduped = [];
348
- for (const o of outside) {
349
- if (seenOutside.has(o.tid))
350
- continue;
351
- seenOutside.add(o.tid);
352
- outsideDeduped.push(o);
353
- }
354
- return {
355
- waves,
356
- criticalPath,
357
- cycles,
358
- missing,
359
- outside: outsideDeduped,
360
- ownerless,
361
- implied,
362
- closed,
363
- };
364
- }
365
- export function toDispatch(res, rows, meta) {
366
- const byTid = new Map(rows.map((r) => [r.tid, r]));
367
- const waves = res.waves.map((w) => ({
368
- n: w.n,
369
- rows: w.tids.map((tid) => {
370
- const r = byTid.get(tid);
371
- const hints = parseHints(r?.notes);
372
- return {
373
- tid,
374
- name: r?.name ?? '',
375
- assignee: r?.assignee,
376
- model: hints.model,
377
- effort: hints.effort,
378
- touches: hints.touches,
379
- accept: hints.accept,
380
- };
381
- }),
382
- }));
383
- const warnings = [];
384
- for (const c of res.cycles)
385
- warnings.push(`cycle: ${c.join(', ')}`);
386
- for (const m of res.missing)
387
- warnings.push(`${m.tid} blocked by missing ${m.blockedBy}`);
388
- for (const o of res.outside)
389
- warnings.push(`${o.tid} waits outside plan (open=${o.open})`);
390
- if (res.ownerless.length > 0)
391
- warnings.push(`${res.ownerless.length} rows ownerless`);
392
- return {
393
- goal: meta.goal,
394
- asOf: meta.asOf,
395
- truncated: meta.truncated,
396
- waves,
397
- criticalPath: res.criticalPath,
398
- warnings,
399
- };
400
- }
401
- // Chains tids in order: edits[i] = { tid: tids[i+1], addBlockedBy: [tids[i]] }.
402
- export function sequenceEdits(tids) {
403
- if (tids.length < 2)
404
- return { ok: false, error: 'need at least two tids' };
405
- const seen = new Set();
406
- for (const t of tids) {
407
- if (seen.has(t))
408
- return { ok: false, error: `duplicate tid ${t}` };
409
- seen.add(t);
410
- }
411
- const edits = [];
412
- for (let i = 0; i < tids.length - 1; i++) {
413
- edits.push({ tid: tids[i + 1], addBlockedBy: [tids[i]] });
414
- }
415
- return { ok: true, edits };
416
- }
417
- export function renderPlan(res, rows, opts) {
418
- const byTid = new Map(rows.map((r) => [r.tid, r]));
419
- const cpSet = new Set(res.criticalPath.tids);
420
- const lines = [];
421
- const goal = opts?.goal ?? '';
422
- lines.push(`plan ${goal} — ${res.waves.length} waves · critical path ${res.criticalPath.hops} hops · ${rows.length} rows (${res.closed.length} closed skipped)`);
423
- for (const wave of res.waves) {
424
- lines.push(`wave ${wave.n}`);
425
- for (const tid of wave.tids) {
426
- const r = byTid.get(tid);
427
- const name = (r?.name ?? '').slice(0, 60);
428
- const assignee = r?.assignee ?? '-';
429
- const priority = r?.priority ?? 0;
430
- const marker = cpSet.has(tid) ? ' *' : '';
431
- lines.push(` ${tid} p${priority} @${assignee} ${name}${marker}`);
432
- }
433
- }
434
- if (res.cycles.length > 0) {
435
- lines.push('cycles');
436
- for (const c of res.cycles)
437
- lines.push(` ${c.join(', ')}`);
438
- }
439
- if (res.missing.length > 0) {
440
- lines.push('missing blockers');
441
- for (const m of res.missing)
442
- lines.push(` ${m.tid} → ${m.blockedBy}`);
443
- }
444
- if (res.outside.length > 0) {
445
- lines.push('waits outside plan');
446
- for (const o of res.outside)
447
- lines.push(` ${o.tid} (open=${o.open})`);
448
- }
449
- if (res.ownerless.length > 0) {
450
- lines.push('ownerless');
451
- for (const tid of res.ownerless)
452
- lines.push(` ${tid}`);
453
- }
454
- if (res.implied.length > 0) {
455
- lines.push('implied order');
456
- for (const i of res.implied) {
457
- const suffix = i.reason === 'touches' && i.path ? `: ${i.path}` : '';
458
- lines.push(` ${i.tid} waits for ${i.waitsFor} (${i.reason}${suffix})`);
459
- }
460
- }
461
- lines.push(`critical path: ${res.criticalPath.tids.length > 0 ? res.criticalPath.tids.join(' → ') : '(none)'}`);
462
- return lines.join('\n');
463
- }
@@ -1,31 +0,0 @@
1
- import type { Row } from './tasks-digest.js';
2
- /** One seat from the org roster: its id, tier, who it reports to, and its staked (subscribed) bare tags. */
3
- export interface Seat {
4
- id: string;
5
- tier?: string;
6
- reportsTo: string | null;
7
- subscribes: string[];
8
- }
9
- /** A seat's lens: its bare tags (sorted, never '*'), itself + every seat below it (sorted), and all=true when it staked '*'. */
10
- export interface Lens {
11
- seat: string;
12
- tags: string[];
13
- seats: string[];
14
- all: boolean;
15
- }
16
- export type LensResult = {
17
- ok: true;
18
- lens: Lens;
19
- } | {
20
- ok: false;
21
- error: string;
22
- };
23
- /**
24
- * BUILD LENS — A director owns a stake, not just its own assignments.
25
- * Walks the reporting tree downward to find every direct/indirect report.
26
- */
27
- export declare function buildLens(roster: Seat[], seat: string): LensResult;
28
- /**
29
- * LENS ROWS — Keep rows that match the lens (tag stake or assignee descended from the seat).
30
- */
31
- export declare function lensRows(rows: Row[], lens: Lens): Row[];
@@ -1,47 +0,0 @@
1
- /**
2
- * BUILD LENS — A director owns a stake, not just its own assignments.
3
- * Walks the reporting tree downward to find every direct/indirect report.
4
- */
5
- export function buildLens(roster, seat) {
6
- const entry = roster.find((s) => s.id === seat);
7
- if (!entry)
8
- return { ok: false, error: `unknown seat '${seat}' — not in the roster (${roster.length} seats)` };
9
- const rawTags = entry.subscribes.filter((t) => t !== '*');
10
- const tags = [...new Set(rawTags)].sort();
11
- const all = entry.subscribes.includes('*');
12
- // Breadth-first descent from the seat; visited guards cycles.
13
- const seats = [seat];
14
- const visited = new Set([seat]);
15
- const queue = [seat];
16
- while (queue.length) {
17
- const current = queue.shift();
18
- for (const s of roster) {
19
- if (s.reportsTo === current && !visited.has(s.id)) {
20
- visited.add(s.id);
21
- seats.push(s.id);
22
- queue.push(s.id);
23
- }
24
- }
25
- }
26
- seats.sort();
27
- // Reject an empty lens: no tags, not all, no reports but itself.
28
- if (tags.length === 0 && !all && seats.length === 1)
29
- return { ok: false, error: `seat '${seat}' stakes no tags and has no reports — its lens would be empty` };
30
- return { ok: true, lens: { seat, tags, seats, all } };
31
- }
32
- /**
33
- * LENS ROWS — Keep rows that match the lens (tag stake or assignee descended from the seat).
34
- */
35
- export function lensRows(rows, lens) {
36
- if (lens.all)
37
- return rows;
38
- const tagSet = new Set(lens.tags);
39
- const seatSet = new Set(lens.seats);
40
- return rows.filter((row) => {
41
- if ((row.tags ?? []).some((t) => tagSet.has(t)))
42
- return true;
43
- if (row.assignee && seatSet.has(row.assignee))
44
- return true;
45
- return false;
46
- });
47
- }
@@ -1,25 +0,0 @@
1
- import type { Asker } from '@oneie/sdk/tasks-bulk';
2
- import { type Row } from './tasks-digest.js';
3
- import { type Lens } from './tasks-lens.js';
4
- export declare function nextCandidates(rows: Row[], lens: Lens): {
5
- candidates: Row[];
6
- refusal?: string;
7
- };
8
- export type ClaimNextResult = {
9
- ok: true;
10
- row: Row;
11
- claimed: boolean;
12
- claimant?: string;
13
- reassigned?: boolean;
14
- } | {
15
- ok: false;
16
- error: string;
17
- tried: {
18
- tid: string;
19
- reason: string;
20
- }[];
21
- };
22
- export declare function claimNext(ask: Asker, candidates: Row[], seat: string, opts?: {
23
- peek?: boolean;
24
- tries?: number;
25
- }): Promise<ClaimNextResult>;
@@ -1,103 +0,0 @@
1
- import { CLOSED, kindOf } from './tasks-digest.js';
2
- import { lensRows } from './tasks-lens.js';
3
- export function nextCandidates(rows, lens) {
4
- const inLens = lensRows(rows, lens).filter(r => kindOf(r) === 'work');
5
- const candidates = inLens
6
- .filter(r => r.status === 'open' && r.ready === true && (!r.assignee || r.assignee === lens.seat))
7
- .sort((a, b) => b.priority - a.priority || a.tid.localeCompare(b.tid));
8
- if (candidates.length > 0) {
9
- return { candidates };
10
- }
11
- // No ready candidates – build a refusal message.
12
- const waiting = inLens
13
- .filter(r => (r.status === 'open' || r.status === 'blocked') && r.ready !== true)
14
- .sort((a, b) => b.priority - a.priority);
15
- if (waiting.length > 0) {
16
- const w = waiting[0];
17
- const byId = new Map(rows.map(r => [r.tid, r]));
18
- const open = (w.blockedBy ?? [])
19
- .map(tid => byId.get(tid))
20
- .filter((b) => b !== undefined && !CLOSED.has(b.status));
21
- if (open.length > 0) {
22
- return {
23
- candidates: [],
24
- refusal: `nothing ready in ${lens.seat}'s lens — highest waiting ${w.tid} "${w.name}" is blocked by ${open.map(b => `${b.tid} "${b.name}" (${b.status})`).join(', ')}`
25
- };
26
- }
27
- else {
28
- return {
29
- candidates: [],
30
- refusal: `nothing ready in ${lens.seat}'s lens — highest waiting ${w.tid} "${w.name}" has ${w.openBlockers ?? 0} open blocker(s) outside this read`
31
- };
32
- }
33
- }
34
- // No waiting rows – check if other seats hold ready rows in the lens.
35
- const heldByOther = inLens.filter(r => r.status === 'open' && r.ready === true && r.assignee && r.assignee !== lens.seat);
36
- if (heldByOther.length > 0) {
37
- return {
38
- candidates: [],
39
- refusal: `nothing ready in ${lens.seat}'s lens — ${heldByOther.length} ready row(s) are held by other seats`
40
- };
41
- }
42
- // Nothing open at all.
43
- return {
44
- candidates: [],
45
- refusal: `nothing open in ${lens.seat}'s lens (${inLens.length} rows read, none open and ready)`
46
- };
47
- }
48
- export async function claimNext(ask, candidates, seat, opts = {}) {
49
- if (candidates.length === 0) {
50
- return { ok: false, error: 'no candidates', tried: [] };
51
- }
52
- // --- peek mode: just return the first candidate without calling ask
53
- if (opts.peek) {
54
- return { ok: true, row: candidates[0], claimed: false };
55
- }
56
- const tries = opts.tries ?? 5;
57
- const tried = [];
58
- for (let i = 0; i < Math.min(candidates.length, tries); i++) {
59
- const c = candidates[i];
60
- // --- step 1: claim
61
- let claimRes;
62
- try {
63
- claimRes = (await ask('tasks:claim', { tid: c.tid, workspace: c.workspace }));
64
- }
65
- catch (e) {
66
- tried.push({ tid: c.tid, reason: e instanceof Error ? e.message : String(e) });
67
- continue;
68
- }
69
- const r = claimRes;
70
- if (r.ok !== true) {
71
- tried.push({ tid: c.tid, reason: r.error ?? 'refused' });
72
- continue;
73
- }
74
- // --- successfully claimed by someone
75
- if (r.claimant === seat) {
76
- return { ok: true, row: c, claimed: true, claimant: seat };
77
- }
78
- // --- claimed by shared key, need to reassign to `seat`
79
- let reassignRes;
80
- try {
81
- reassignRes = (await ask('tasks:reassign', { tid: c.tid, assignee: seat, workspace: c.workspace }));
82
- }
83
- catch (e) {
84
- return stranded(c.tid, r.claimant, seat, e instanceof Error ? e.message : String(e), tried);
85
- }
86
- const a = reassignRes;
87
- if (a.ok === true && a.unchanged !== true && a.previous !== seat) {
88
- return { ok: true, row: c, claimed: true, claimant: r.claimant, reassigned: true };
89
- }
90
- // A refused reassign leaves the row picked under the shared claimant: stop here
91
- // rather than strand more rows the same way.
92
- if (a.ok !== true)
93
- return stranded(c.tid, r.claimant, seat, a.error ?? 'reassign refused', tried);
94
- tried.push({ tid: c.tid, reason: `taken by another ${seat} between claim and reassign` });
95
- }
96
- // --- exhausted tries
97
- const error = `no row claimed after ${tried.length} tries: ` + tried.map(t => `${t.tid} ${t.reason}`).join('; ');
98
- return { ok: false, error, tried };
99
- }
100
- function stranded(tid, claimant, seat, reason, tried) {
101
- tried.push({ tid, reason: `reassign failed: ${reason}` });
102
- return { ok: false, error: `claimed ${tid} as @${claimant ?? '?'} but could not hand it to @${seat} (${reason}) — row stranded picked; reassign it by hand`, tried };
103
- }
@@ -1,15 +0,0 @@
1
- import type { Row } from './tasks-digest.js';
2
- export declare function acceptOf(notes: string): string | null;
3
- export declare function isHermetic(accept: string): boolean;
4
- export declare function proveRows(rows: {
5
- tid: string;
6
- notes?: string;
7
- }[], run: (accept: string) => number): {
8
- tid: string;
9
- verdict: 'proof-green — close?' | 'red' | 'unproven';
10
- }[];
11
- export declare function renderProve(results: {
12
- tid: string;
13
- verdict: string;
14
- }[]): string;
15
- export declare function proveBoard(rows: Row[]): Promise<void>;