toolroll 0.9.105 → 0.9.106
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.
- package/CHANGELOG.md +25 -0
- package/README.md +5 -4
- package/dist/bin.js +38 -4
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +4 -4
- package/dist/demo.js +8 -3
- package/dist/easy-start.js +47 -4
- package/dist/flow-code.js +2 -1
- package/dist/guides.js +1 -1
- package/dist/invoke.js +4 -4
- package/dist/lead-voice.js +3 -3
- package/dist/operate.js +8 -1
- package/dist/sandbox-runtime.js +36 -2
- package/dist/store.js +4 -0
- package/dist/toolroll-update-cli.js +18 -1
- package/dist/tui.js +1 -1
- package/dist/work-index.js +81 -66
- package/package.json +2 -2
package/dist/work-index.js
CHANGED
|
@@ -97,32 +97,32 @@ const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
|
|
|
97
97
|
AND a.ref_id NOT IN (SELECT value FROM json_each($settledCustody)) custody_unresolved
|
|
98
98
|
FROM admitted a LEFT JOIN lineage l ON l.ref_id=a.ref_id
|
|
99
99
|
LEFT JOIN questions q ON q.task_ref=a.ref_id LEFT JOIN custody cu ON cu.task_ref=a.ref_id
|
|
100
|
-
), family_heads AS MATERIALIZED (
|
|
101
|
-
SELECT root_ref,COUNT(*) version_count,MAX(updated_at) family_updated,
|
|
102
|
-
CAST(substr(MAX((CASE WHEN ref_id=root_ref THEN '0' ELSE '1' END)||created_at||printf('%020d',ref_id)),-20) AS INTEGER) current_ref,
|
|
103
|
-
-- A put-away version (v145) is history: it never counts as an earlier active version or brings its question along.
|
|
104
|
-
SUM(NOT member_archived AND (state IN ('queued','running') OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved)) active_count,
|
|
105
|
-
MIN(CASE WHEN NOT member_archived AND (state IN ('queued','running') OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved) THEN ref_id END) first_active,
|
|
106
|
-
MAX(CASE WHEN NOT member_archived AND (state IN ('queued','running') OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved) THEN ref_id END) last_active,
|
|
107
|
-
MAX(live_lease IS NOT NULL) family_running,MIN(CASE WHEN NOT member_archived THEN decision_id END) question_id
|
|
108
|
-
FROM members GROUP BY root_ref
|
|
109
100
|
), ordered AS MATERIALIZED (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
-- Every version carries its family's facts (window functions over the family: see ONE_READ).
|
|
102
|
+
SELECT o.*,CASE WHEN o.ref_id=o.current_ref THEN 1 ELSE 2 END version_rank FROM (
|
|
103
|
+
SELECT m.*,COUNT(*) OVER family fam_version_count,MAX(updated_at) OVER family fam_updated,
|
|
104
|
+
CAST(substr(MAX((CASE WHEN ref_id=root_ref THEN '0' ELSE '1' END)||created_at||printf('%020d',ref_id)) OVER family,-20) AS INTEGER) current_ref,
|
|
105
|
+
-- A put-away version (v145) is history: it never counts as an earlier active version or brings its question along.
|
|
106
|
+
SUM(NOT member_archived AND (state IN ('queued','running') OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved)) OVER family fam_active_count,
|
|
107
|
+
MIN(CASE WHEN NOT member_archived AND (state IN ('queued','running') OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved) THEN ref_id END) OVER family fam_first_active,
|
|
108
|
+
MAX(CASE WHEN NOT member_archived AND (state IN ('queued','running') OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved) THEN ref_id END) OVER family fam_last_active,
|
|
109
|
+
MAX(live_lease IS NOT NULL) OVER family fam_running,MIN(CASE WHEN NOT member_archived THEN decision_id END) OVER family fam_question_id
|
|
110
|
+
FROM members m WINDOW family AS (PARTITION BY root_ref)) o
|
|
111
|
+
), versions AS MATERIALIZED (
|
|
112
|
+
-- Each family's versions as JSON lists, ordered by task_ref, built once per family (never on every version), for the
|
|
113
|
+
-- later reads that look across a family. Members' own family: admitted joined to its lineage, as members reads it.
|
|
114
|
+
SELECT COALESCE(l.root_ref,a.ref_id) root_ref,json_group_array(a.ref_id ORDER BY a.ref_id) fam_refs,json_group_array(a.id ORDER BY a.ref_id) fam_ids
|
|
115
|
+
FROM admitted a LEFT JOIN lineage l ON l.ref_id=a.ref_id GROUP BY COALESCE(l.root_ref,a.ref_id)
|
|
118
116
|
), workers AS MATERIALIZED (
|
|
119
117
|
SELECT r.name,r.capacity,r.heartbeat_at,j.value repo,
|
|
120
118
|
(SELECT COUNT(*) FROM claim c WHERE c.runner=r.name AND c.released_at IS NULL AND c.expires_at>$now
|
|
121
119
|
AND c.lease_generation=(SELECT MAX(newest.lease_generation) FROM claim newest WHERE newest.task_ref=c.task_ref)) occupied
|
|
122
120
|
FROM runner r,json_each(CASE WHEN json_valid(r.repos) THEN r.repos ELSE '[]' END) j WHERE r.retired_at IS NULL
|
|
123
121
|
), facts AS MATERIALIZED (
|
|
124
|
-
SELECT c.*,
|
|
125
|
-
|
|
122
|
+
SELECT c.*,c.fam_version_count version_count,c.fam_updated family_updated,
|
|
123
|
+
c.fam_active_count-(NOT c.member_archived AND (c.state IN ('queued','running') OR c.live_lease IS NOT NULL OR c.unfinished IS NOT NULL OR c.custody_unresolved)) earlier_active,
|
|
124
|
+
earlier.id earlier_id,c.fam_running family_running,COALESCE(c.decision_id,c.fam_question_id) question_id,
|
|
125
|
+
root.id root_id,root.title root_title,fam.fam_refs,fam.fam_ids,
|
|
126
126
|
result.role result_role,result.outcome result_outcome,result.head_revision,result.scope_digest,result.finished_at,
|
|
127
127
|
(SELECT id FROM run WHERE task_ref=c.ref_id AND lease_id=c.live_lease AND outcome IS NULL ORDER BY id DESC LIMIT 1) live_run,
|
|
128
128
|
h.owner_kind hold_kind,h.reason hold_reason,h.until hold_until,
|
|
@@ -181,7 +181,8 @@ const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
|
|
|
181
181
|
COALESCE((SELECT substr(actor,13) FROM action_ledger WHERE task_id=root.id AND action='assignment claimed' AND source='work' ORDER BY id DESC LIMIT 1),root.coordinator_cid) owner_id,
|
|
182
182
|
${HELD_FINDINGS} held_findings,
|
|
183
183
|
pub.pr_url publication_url
|
|
184
|
-
FROM ordered c JOIN
|
|
184
|
+
FROM ordered c JOIN admitted root ON root.ref_id=c.root_ref JOIN versions fam ON fam.root_ref=c.root_ref
|
|
185
|
+
LEFT JOIN admitted earlier ON earlier.ref_id=CASE WHEN c.fam_first_active=c.current_ref THEN c.fam_last_active ELSE c.fam_first_active END
|
|
185
186
|
LEFT JOIN run result INDEXED BY work_result ON result.task_ref=c.ref_id AND result.id=c.result_id
|
|
186
187
|
AND result.finished_at IS NOT NULL AND result.role IN ('builder','scout') LEFT JOIN hold h ON h.id=c.hold_id
|
|
187
188
|
LEFT JOIN task_scope sc ON sc.task_id=c.id LEFT JOIN publication pub ON pub.run=c.result_id
|
|
@@ -192,25 +193,26 @@ const PROJECTION = `WITH RECURSIVE admitted AS MATERIALIZED (
|
|
|
192
193
|
AND digest=scope_digest AND ((result_role='scout' AND result_outcome='built') OR
|
|
193
194
|
(result_role='builder' AND result_outcome IN ('built','no-change') AND length(head_revision)=40 AND head_revision NOT GLOB '*[^a-f0-9]*')) ready
|
|
194
195
|
FROM facts f
|
|
195
|
-
), completion_families AS MATERIALIZED (
|
|
196
|
-
SELECT root_ref FROM ready f WHERE f.ready AND EXISTS(SELECT 1 FROM action_ledger a
|
|
197
|
-
WHERE a.task_id=f.root_id AND a.run_id=f.result_id AND a.action='assignment handoff checked' AND a.source='work')
|
|
198
|
-
), completion_metadata AS MATERIALIZED (
|
|
199
|
-
SELECT m.root_ref,MAX((SELECT MAX(a.id) FROM action_ledger a WHERE a.task_id=m.id
|
|
200
|
-
AND a.action IN ('task state changed','scope approved','task placed','run started','run finished'))) changed_id,
|
|
201
|
-
MAX((SELECT MAX(ar.created_at) FROM run r JOIN artifact ar ON ar.run=r.id WHERE r.task_ref=m.ref_id)) artifact_at
|
|
202
|
-
FROM completion_families f JOIN ordered m ON m.root_ref=f.root_ref GROUP BY m.root_ref
|
|
203
196
|
), checked AS MATERIALIZED (
|
|
204
197
|
SELECT f.*,(SELECT a.id FROM action_ledger a WHERE f.ready AND a.task_id=f.root_id AND a.run_id=f.result_id
|
|
205
198
|
AND a.action='assignment handoff checked' AND a.source='work' AND a.repo IS f.repo
|
|
206
199
|
AND length(a.outcome)=64 AND a.outcome NOT GLOB '*[^a-f0-9]*'
|
|
207
200
|
AND a.at>=f.family_updated AND a.at>=f.finished_at AND a.at>=f.approved_at AND a.at>=f.proposed_at
|
|
208
201
|
AND (a.actor GLOB 'operator:?*' OR a.actor GLOB 'coordinator:?*' OR a.actor GLOB 'lead:?*' OR a.actor='${LANDED_ACTOR}')
|
|
209
|
-
AND (
|
|
202
|
+
AND (f.completion_changed IS NULL OR a.id>=f.completion_changed) AND (f.completion_artifact_at IS NULL OR a.at>=f.completion_artifact_at)
|
|
210
203
|
AND NOT EXISTS(SELECT 1 FROM proof_verdict p WHERE p.run=f.result_id AND p.decided_at>a.at)
|
|
211
204
|
AND NOT EXISTS(SELECT 1 FROM proof_acceptance p WHERE p.run=f.result_id AND p.accepted_at>a.at)
|
|
212
205
|
ORDER BY a.id DESC LIMIT 1) checked_id
|
|
213
|
-
FROM
|
|
206
|
+
FROM (
|
|
207
|
+
-- A ready family whose handoff was checked: the newest change and artifact of any of its versions, which a check must postdate.
|
|
208
|
+
SELECT f.*,CASE WHEN f.ready AND EXISTS(SELECT 1 FROM action_ledger a
|
|
209
|
+
WHERE a.task_id=f.root_id AND a.run_id=f.result_id AND a.action='assignment handoff checked' AND a.source='work')
|
|
210
|
+
THEN (SELECT MAX(a.id) FROM json_each(f.fam_ids) m JOIN action_ledger a ON a.task_id=m.value
|
|
211
|
+
AND a.action IN ('task state changed','scope approved','task placed','run started','run finished')) END completion_changed,
|
|
212
|
+
CASE WHEN f.ready AND EXISTS(SELECT 1 FROM action_ledger a
|
|
213
|
+
WHERE a.task_id=f.root_id AND a.run_id=f.result_id AND a.action='assignment handoff checked' AND a.source='work')
|
|
214
|
+
THEN (SELECT MAX(ar.created_at) FROM json_each(f.fam_refs) m JOIN run r ON r.task_ref=m.value JOIN artifact ar ON ar.run=r.id) END completion_artifact_at
|
|
215
|
+
FROM ready f) f
|
|
214
216
|
), classified AS MATERIALIZED (
|
|
215
217
|
SELECT f.*,CASE
|
|
216
218
|
WHEN broken THEN 'history-problem'
|
|
@@ -356,6 +358,19 @@ const GROUP_TOTALS = `COALESCE(SUM(rank=0 AND ask_rank=0 AND archived=0),0) deci
|
|
|
356
358
|
const ASK_TOTALS = WORK_ASK_GROUPS.map(group => `COALESCE(SUM(needs AND ask_group='${group}'),0) ask_${group}_count`).join(',')
|
|
357
359
|
+ `,COALESCE(SUM(code='complete' AND archived=0 AND $completedSince IS NOT NULL AND sort_at>=$completedSince),0) completed_since_count`
|
|
358
360
|
+ `,COALESCE(SUM(needs AND code IN ('no-worker-registered','no-worker-online')),0) builder_wait_count`;
|
|
361
|
+
function over(sums, window, prefix = '') {
|
|
362
|
+
const windowed = sums.replace(/\),0\) (\w+)/g, (_, name) => `) OVER (${window}),0) ${prefix}${name}`);
|
|
363
|
+
if (windowed.split(' OVER (').length !== sums.split('COALESCE(SUM(').length)
|
|
364
|
+
throw new Error('Every total must read COALESCE(SUM(...),0) <name>.');
|
|
365
|
+
return windowed;
|
|
366
|
+
}
|
|
367
|
+
const namesOf = (sums) => [...sums.matchAll(/\),0\) (\w+)/g)].map(match => match[1]);
|
|
368
|
+
const TOTAL_NAMES = namesOf(TOTALS);
|
|
369
|
+
const PAGE_TOTALS = over(`${TOTALS},${GROUP_TOTALS},${ASK_TOTALS}`, '');
|
|
370
|
+
const PAGE_TOTAL_NAMES = namesOf(`${TOTALS},${GROUP_TOTALS},${ASK_TOTALS}`);
|
|
371
|
+
const PROJECT_TOTALS = `${over(TOTALS, 'PARTITION BY repo', 'project_')},SUM(state='queued' AND family_running=0 AND archived=0) OVER (PARTITION BY repo) project_queued,
|
|
372
|
+
SUM(state='done' AND family_running=0 AND archived=0 AND updated_at>=$recent) OVER (PARTITION BY repo) project_done_recently`;
|
|
373
|
+
const PROJECT_TOTAL_NAMES = [...TOTAL_NAMES.map(name => `project_${name}`), 'project_queued', 'project_done_recently'];
|
|
359
374
|
function askCounts(row) {
|
|
360
375
|
return Object.fromEntries(WORK_ASK_GROUPS.map(group => [group, n(row, `ask_${group}_count`)]));
|
|
361
376
|
}
|
|
@@ -401,21 +416,22 @@ function readWorkIndexPage(store, now, access, options, taskId = null) {
|
|
|
401
416
|
const limit = Number.isFinite(options.limit) ? Math.max(1, Math.min(WORK_INDEX_MAX_LIMIT, Math.floor(options.limit))) : WORK_INDEX_PAGE_LIMIT;
|
|
402
417
|
const scope = cursorScope(access, options, view), cursor = readCursor(options.cursor, scope);
|
|
403
418
|
const filter = view === 'archived' ? 'archived=1' : view === 'needs-you' ? 'needs=1' : view === 'ready' ? READY : view === 'running' ? 'family_running=1 AND archived=0' : view === 'queued' ? QUEUED : view === 'completed' ? "code='complete' AND archived=0 AND ($completedSince IS NULL OR sort_at>=$completedSince)" : 'archived=0';
|
|
404
|
-
const rows = prepared(store, `${projection},
|
|
405
|
-
SELECT
|
|
406
|
-
|
|
407
|
-
ORDER BY ${ORDER},sort_at DESC,root_ref DESC
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
419
|
+
const rows = prepared(store, `${projection}, page AS (
|
|
420
|
+
SELECT p.*,p.in_page AND p.page_order<=$limit is_row,p.repo_order=1 is_project,
|
|
421
|
+
CASE WHEN p.in_page AND p.page_order<=$limit THEN COALESCE(p.result_id,(SELECT id FROM run WHERE task_ref=p.ref_id AND finished_at IS NOT NULL AND role IN ('builder','scout') ORDER BY id DESC LIMIT 1)) END page_result_id
|
|
422
|
+
FROM (SELECT s.*,ROW_NUMBER() OVER (PARTITION BY s.in_page ORDER BY ${ORDER},sort_at DESC,root_ref DESC) page_order,
|
|
423
|
+
ROW_NUMBER() OVER (PARTITION BY repo ORDER BY root_ref) repo_order,DENSE_RANK() OVER (ORDER BY repo) repo_rank
|
|
424
|
+
FROM (SELECT r.*,($taskId IS NOT NULL OR ${filter}) AND ($taskId IS NULL OR EXISTS(SELECT 1 FROM json_each(r.fam_ids) WHERE value=$taskId)) AND ($roots IS NULL OR root_id IN (SELECT value FROM json_each($roots))) AND ($cursorRoot=0 OR
|
|
425
|
+
${ORDER}>$cursorRank OR (${ORDER}=$cursorRank AND (sort_at<$cursorAt OR (sort_at=$cursorAt AND root_ref<$cursorRoot)))) in_page,
|
|
426
|
+
${PAGE_TOTALS},${PROJECT_TOTALS}
|
|
427
|
+
FROM ranked r) s) p
|
|
428
|
+
WHERE (p.in_page AND p.page_order<=$limit) OR p.repo_order=1
|
|
411
429
|
)
|
|
412
|
-
SELECT
|
|
413
|
-
'running_count',running_count,'queued_count',queued_count,'completed_count',completed_count,'archived_count',archived_count,'queued',queued,'done_recently',done_recently)) FROM project_totals) row_json FROM totals
|
|
414
|
-
UNION ALL SELECT 1,0,0,0,0,0,0,0,0,0,0,0,0,${WORK_ASK_GROUPS.map(() => '0,').join('')}0,0,json_object('archived',archived,'archived_by',(SELECT by FROM task_archive WHERE task_ref=page.ref_id),
|
|
430
|
+
SELECT is_row,is_project,repo_rank,repo,${PAGE_TOTAL_NAMES.join(',')},${PROJECT_TOTAL_NAMES.join(',')},CASE WHEN is_row THEN json_object('archived',archived,'archived_by',(SELECT by FROM task_archive WHERE task_ref=page.ref_id),
|
|
415
431
|
'archived_kind',(SELECT by_kind FROM task_archive WHERE task_ref=page.ref_id),'archived_reason',(SELECT reason FROM task_archive WHERE task_ref=page.ref_id),
|
|
416
432
|
'archived_at',(SELECT at FROM task_archive WHERE task_ref=page.ref_id),'root_ref',root_ref,'root_id',root_id,'id',id,'root_title',root_title,'repo',repo,
|
|
417
433
|
'state',state,'created_at',created_at,'family_updated',family_updated,'version_count',version_count,'earlier_active',earlier_active,
|
|
418
|
-
'earlier_id',earlier_id,'route_change',(SELECT rc.words FROM route_change rc JOIN task_scope rs ON rs.task_id=page.id AND rs.digest=rc.scope_digest AND rs.approved_digest IS NOT rs.digest WHERE rc.task_ref=page.ref_id),'retry_stopped',(SELECT stopped FROM retry_episode WHERE task_ref=page.ref_id),'retry_stopped_run',(SELECT stopped_run FROM retry_episode WHERE task_ref=page.ref_id),'broken',broken,'live_run',live_run,'result_id',page_result_id,'result_outcome',(SELECT outcome FROM run WHERE id=page_result_id),'attempt_reason',(SELECT substr(reason,1,1000) FROM run WHERE task_ref IN (SELECT
|
|
434
|
+
'earlier_id',earlier_id,'route_change',(SELECT rc.words FROM route_change rc JOIN task_scope rs ON rs.task_id=page.id AND rs.digest=rc.scope_digest AND rs.approved_digest IS NOT rs.digest WHERE rc.task_ref=page.ref_id),'retry_stopped',(SELECT stopped FROM retry_episode WHERE task_ref=page.ref_id),'retry_stopped_run',(SELECT stopped_run FROM retry_episode WHERE task_ref=page.ref_id),'broken',broken,'live_run',live_run,'result_id',page_result_id,'result_outcome',(SELECT outcome FROM run WHERE id=page_result_id),'attempt_reason',(SELECT substr(reason,1,1000) FROM run WHERE task_ref IN (SELECT value FROM json_each(page.fam_refs)) AND (finished_at IS NOT NULL OR outcome IS NOT NULL) AND role NOT IN ('planner','reviewer') ORDER BY id DESC LIMIT 1),
|
|
419
435
|
'publication_url',(SELECT pr_url FROM publication WHERE run=page_result_id),
|
|
420
436
|
'result_role',(SELECT role FROM run WHERE id=page_result_id),'result_head',(SELECT head_revision FROM run WHERE id=page_result_id),'live_role',(SELECT role FROM run WHERE id=page.live_run),
|
|
421
437
|
'check_status',(SELECT status FROM run_check WHERE run=page_result_id),
|
|
@@ -425,18 +441,20 @@ function readWorkIndexPage(store, now, access, options, taskId = null) {
|
|
|
425
441
|
'proof_verdict',(SELECT COALESCE(machine_verdict,verdict) FROM proof_verdict WHERE run=page_result_id),
|
|
426
442
|
'proof_failed_check',(SELECT verdict='refuted' AND reasons_json LIKE '%approved verification command exited%' FROM proof_verdict WHERE run=page_result_id),'code',code,'ask_group',ask_group,'needs',needs,'person_need',person_need,'lead_claim',lead_claim,'family_running',family_running,'rank',rank,'ask_rank',ask_rank,'list_order',${ORDER},'sort_at',sort_at,
|
|
427
443
|
'checked_actor',checked_actor,'checked_at',checked_at,'checked_digest',checked_digest,'checked_detail',checked_detail,'question_id',question_id,
|
|
428
|
-
'dependency_id',dependency_id,'dependency_state',dependency_state,'hold_until',hold_until,'attempt_run',(SELECT id FROM run WHERE task_ref IN (SELECT
|
|
444
|
+
'dependency_id',dependency_id,'dependency_state',dependency_state,'hold_until',hold_until,'attempt_run',(SELECT id FROM run WHERE task_ref IN (SELECT value FROM json_each(page.fam_refs)) AND (finished_at IS NOT NULL OR outcome IS NOT NULL) AND role NOT IN ('planner','reviewer') ORDER BY id DESC LIMIT 1),'custody_unresolved',custody_unresolved,'hold_kind',hold_kind,'hold_reason',substr(hold_reason,1,600),'hold_id',hold_id,'live_lease',live_lease IS NOT NULL,'approved',COALESCE(approved,0),
|
|
429
445
|
'plan_changed',scope_digest IS NOT NULL AND digest IS NOT scope_digest,'head_ok',length(head_revision)=40 AND head_revision NOT GLOB '*[^a-f0-9]*','stop_run',stop_run,'unfinished',unfinished,'signed_out',signed_out,'no_agent',no_agent,'models_cleared',models_cleared,
|
|
430
446
|
'question_run',(SELECT run FROM decision WHERE id=page.question_id),'agent_ask',page.agent_ask,
|
|
431
447
|
'agent_ask_run',(SELECT run FROM agent_question WHERE id=page.agent_ask),'agent_ask_text',(SELECT substr(question,1,300) FROM agent_question WHERE id=page.agent_ask),'replaced_by',(SELECT successor FROM task_replacement WHERE task_ref=page.ref_id),
|
|
432
448
|
'completed_by_lead',(SELECT lead FROM task_act WHERE task_ref=page.root_ref AND act='completed' ORDER BY id DESC LIMIT 1),'machine_check',COALESCE(machine_check,0),
|
|
433
|
-
'question_task',(SELECT r.external_id FROM decision d JOIN run ON run.id=d.run JOIN task_ref r ON r.id=run.task_ref WHERE d.id=page.question_id))
|
|
449
|
+
'question_task',(SELECT r.external_id FROM decision d JOIN run ON run.id=d.run JOIN task_ref r ON r.id=run.task_ref WHERE d.id=page.question_id)) END row_json
|
|
450
|
+
FROM page ORDER BY is_row DESC,page_order`)
|
|
434
451
|
.all({ ...parameters(store, now, access, options, custody), $taskId: taskId, $roots: options.roots === undefined ? null : JSON.stringify(options.roots), $cursorRoot: cursor?.root ?? 0, $cursorRank: cursor?.rank ?? 0, $cursorAt: cursor?.at ?? '', $limit: limit + 1, $completedSince: options.completedSince ?? null, $recent: new Date(now.getTime() - 86_400_000).toISOString() });
|
|
435
|
-
const selected = rows.
|
|
452
|
+
const selected = rows.filter(row => n(row, 'is_row') === 1).map(row => JSON.parse(String(row['row_json'])));
|
|
436
453
|
const page = selected.slice(0, limit), last = page.at(-1);
|
|
437
454
|
const nextCursor = selected.length > limit && last !== undefined ? Buffer.from(JSON.stringify({ version: 2, scope,
|
|
438
455
|
rank: n(last, 'list_order'), at: s(last, 'sort_at'), root: n(last, 'root_ref') })).toString('base64url') : null;
|
|
439
|
-
const projects =
|
|
456
|
+
const projects = rows.filter(row => n(row, 'is_project') === 1).sort((a, b) => n(a, 'repo_rank') - n(b, 'repo_rank')).map(row => ({ repo: s(row, 'repo'),
|
|
457
|
+
totals: counts(Object.fromEntries(TOTAL_NAMES.map(name => [name, row[`project_${name}`]]))), queued: n(row, 'project_queued'), doneRecently: n(row, 'project_done_recently') }));
|
|
440
458
|
const probe = (taskId) => {
|
|
441
459
|
const ref = store.lookupRef(taskId);
|
|
442
460
|
return ref === null ? null : custody.readings.get(ref.id) ?? null;
|
|
@@ -463,7 +481,7 @@ export function workStateRows(store, now, access) {
|
|
|
463
481
|
COALESCE((SELECT created_at FROM decision WHERE id=question_id),''),COALESCE((SELECT asked_at FROM agent_question WHERE id=agent_ask),''),
|
|
464
482
|
COALESCE((SELECT held_at FROM hold WHERE id=hold_id),''),COALESCE((SELECT requested_at FROM run_stop WHERE run=stop_run),'')),''),sort_at) ask_at,
|
|
465
483
|
COALESCE(live_run,(SELECT run FROM decision WHERE id=question_id),(SELECT run FROM agent_question WHERE id=agent_ask)) ask_run,
|
|
466
|
-
|
|
484
|
+
fam_refs members FROM ranked WHERE archived=0`)
|
|
467
485
|
.all(parameters(store, now, access, {}, custodyReadings(store)))
|
|
468
486
|
.map(row => ({ repo: s(row, 'repo'), rootId: String(row['root_id']), code: String(row['code']), needs: n(row, 'needs') === 1, personNeed: n(row, 'person_need') === 1,
|
|
469
487
|
leadClaim: n(row, 'lead_claim') === 1, liveRun: row['live_run'] == null ? null : n(row, 'live_run'), unfinished: row['unfinished'] == null ? null : n(row, 'unfinished'),
|
|
@@ -474,28 +492,26 @@ export function workOutcomeRows(store, now, access, project, since, limit) {
|
|
|
474
492
|
SELECT * FROM ranked WHERE archived=0 AND (code='ready-to-check' OR code='history-problem'
|
|
475
493
|
OR (code='complete' AND checked_at >= $since AND checked_at <= $now))
|
|
476
494
|
ORDER BY sort_at DESC,root_ref DESC LIMIT $outcomeLimit
|
|
477
|
-
), amounts AS (
|
|
478
|
-
-- reported-usage.ts runAmountOf, row for row: only evidenced billing on a run whose cost was reported is known;
|
|
479
|
-
-- an API run counts its priced spend as dollars (a safe integer), a subscription run its reported cost as usage,
|
|
480
|
-
-- never dollars. TOTAL sums as a float, so no family's sum can overflow.
|
|
481
|
-
SELECT m.root_ref,r.cost_usd,s.microusd,
|
|
482
|
-
CASE WHEN r.billing_basis IS NOT 'evidence' OR COALESCE(r.cost_unknown,1)<>0 THEN 'unknown'
|
|
483
|
-
WHEN s.billing='subscription' THEN 'subscription'
|
|
484
|
-
WHEN s.billing='api-key' AND typeof(s.microusd)='integer' AND s.microusd>=0 AND s.microusd<=9007199254740991 THEN 'api'
|
|
485
|
-
ELSE 'unknown' END amount
|
|
486
|
-
FROM selected f JOIN members m ON m.root_ref=f.root_ref JOIN run r ON r.task_ref=m.ref_id LEFT JOIN run_spend s ON s.run=r.id
|
|
487
|
-
), attempts AS (
|
|
488
|
-
SELECT root_ref,COUNT(*) runs,COUNT(CASE WHEN amount='api' THEN 1 END) api_runs,
|
|
489
|
-
TOTAL(CASE WHEN amount='api' THEN microusd END) api_microusd,
|
|
490
|
-
COUNT(CASE WHEN amount='subscription' THEN 1 END) subscription_runs,
|
|
491
|
-
SUM(CASE WHEN amount='subscription' AND typeof(cost_usd) IN ('integer','real') AND cost_usd>=0 THEN cost_usd END) subscription_usd
|
|
492
|
-
FROM amounts GROUP BY root_ref
|
|
493
495
|
) SELECT f.root_id,f.id task_id,f.root_title title,f.code,f.finished_at,f.result_id,f.result_role,
|
|
494
496
|
f.version_count,f.checked_at,f.checked_actor,f.checked_detail,
|
|
495
497
|
(SELECT lead FROM task_act WHERE task_ref=f.root_ref AND act='completed' AND at=f.checked_at ORDER BY id DESC LIMIT 1) completed_by_lead,
|
|
496
498
|
(SELECT status FROM run_check WHERE run=f.result_id) check_status,
|
|
497
|
-
|
|
498
|
-
|
|
499
|
+
COUNT(f.attempt) runs,COUNT(CASE WHEN amount='api' THEN 1 END) api_runs,
|
|
500
|
+
CASE WHEN COUNT(f.attempt)>0 THEN TOTAL(CASE WHEN amount='api' THEN microusd END) END api_microusd,
|
|
501
|
+
COUNT(CASE WHEN amount='subscription' THEN 1 END) subscription_runs,
|
|
502
|
+
SUM(CASE WHEN amount='subscription' AND typeof(cost_usd) IN ('integer','real') AND cost_usd>=0 THEN cost_usd END) subscription_usd
|
|
503
|
+
FROM (
|
|
504
|
+
-- Each family's runs, across its versions, with their amounts; one row with no run for a family that has none.
|
|
505
|
+
-- reported-usage.ts runAmountOf, row for row: only evidenced billing on a run whose cost was reported is known;
|
|
506
|
+
-- an API run counts its priced spend as dollars (a safe integer), a subscription run its reported cost as usage,
|
|
507
|
+
-- never dollars. TOTAL sums as a float, so no family's sum can overflow.
|
|
508
|
+
SELECT f.*,r.id attempt,r.cost_usd,s.microusd,
|
|
509
|
+
CASE WHEN r.billing_basis IS NOT 'evidence' OR COALESCE(r.cost_unknown,1)<>0 THEN 'unknown'
|
|
510
|
+
WHEN s.billing='subscription' THEN 'subscription'
|
|
511
|
+
WHEN s.billing='api-key' AND typeof(s.microusd)='integer' AND s.microusd>=0 AND s.microusd<=9007199254740991 THEN 'api'
|
|
512
|
+
ELSE 'unknown' END amount
|
|
513
|
+
FROM selected f LEFT JOIN json_each(f.fam_refs) m LEFT JOIN run r ON r.task_ref=m.value LEFT JOIN run_spend s ON s.run=r.id) f
|
|
514
|
+
GROUP BY f.root_ref ORDER BY f.sort_at DESC,f.root_ref DESC`)
|
|
499
515
|
.all({ ...parameters(store, now, access, { project }, custodyReadings(store)), $since: since, $outcomeLimit: limit + 1 });
|
|
500
516
|
}
|
|
501
517
|
export function workReadyForReview(store, now, access, limit = 5) {
|
|
@@ -719,8 +735,7 @@ export function workTidyRows(store, now, access) {
|
|
|
719
735
|
const projection = registerValidators(store);
|
|
720
736
|
return store.handle.prepare(`${projection} SELECT root_id,id,root_title,repo,state,code,archived,broken,family_updated,
|
|
721
737
|
(family_running OR live_lease IS NOT NULL OR unfinished IS NOT NULL OR custody_unresolved OR stop_run IS NOT NULL AND stop_settled IS NULL OR state='running') live,
|
|
722
|
-
|
|
723
|
-
(SELECT json_group_array(m.id) FROM members m WHERE m.root_ref=ranked.root_ref) member_ids FROM ranked`)
|
|
738
|
+
fam_refs members,fam_ids member_ids FROM ranked`)
|
|
724
739
|
.all(parameters(store, now, access, {}, custodyReadings(store)))
|
|
725
740
|
.map(row => ({ rootId: String(row['root_id']), currentId: String(row['id']), title: String(row['root_title']), repo: s(row, 'repo'),
|
|
726
741
|
state: String(row['state']), code: String(row['code']), live: n(row, 'live') === 1, archived: n(row, 'archived') === 1, broken: n(row, 'broken') === 1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolroll",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.106",
|
|
4
4
|
"description": "Your agents build. You decide. A control plane for coding agents — Claude Code, Codex, Gemini: approve the exact scope once, get results back Ready with the diff, the passing check and screenshots. Runs on your machine.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"doc": "docs"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"standing-orders": "dist/bin.js"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
|
-
"node": ">=22.
|
|
67
|
+
"node": ">=22.20.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@radix-ui/react-collapsible": "1.1.20",
|