@volter/supercode-orchestrator 0.4.31 → 0.4.32
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/board/dispatch.mjs +15 -1
- package/package.json +1 -1
package/board/dispatch.mjs
CHANGED
|
@@ -411,6 +411,17 @@ export async function startCard(board, id, { roles = ['manager'], lanes, setting
|
|
|
411
411
|
* The heartbeat, observed: a running pane session whose last message is a whole tick old is sent `session_idle` with
|
|
412
412
|
* how many times it has been asked this run and whether it worked since the last ask; the workflow decides the rest.
|
|
413
413
|
*/
|
|
414
|
+
/** Panes whose close was asked by their own session's command (see sessionEffect), closed now. */
|
|
415
|
+
function closeRequested(board, report) {
|
|
416
|
+
const rows = board.db.prepare(`SELECT id, task_id, metadata FROM task_runs WHERE metadata LIKE '%"close_requested"%' AND metadata NOT LIKE '%"closed_at"%'`).all();
|
|
417
|
+
for (const row of rows) {
|
|
418
|
+
const session = json(row.metadata, {})?.supercode;
|
|
419
|
+
if (!session?.pane) continue;
|
|
420
|
+
try { stopSession(session); } catch (error) { report.undelivered.push([row.task_id, session.address, `closing it: ${String(error.message).slice(-200)}`]); continue; }
|
|
421
|
+
tx(board, (db) => setRunSession(db, row.id, { ...session, closed_at: now() }));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
414
425
|
function observeIdle(board, fleet, settings, report, entry, effects) {
|
|
415
426
|
if (!fleet.ok) return;
|
|
416
427
|
for (const { id } of board.db.prepare("SELECT id FROM tasks WHERE status = 'running'").all()) {
|
|
@@ -457,6 +468,9 @@ export async function sessionEffect(board, e) {
|
|
|
457
468
|
for (const row of rows) {
|
|
458
469
|
const session = json(row.metadata, {})?.supercode;
|
|
459
470
|
if ((session?.slot ?? 'worker') !== e.slot || !session?.pane || session.closed_at) continue;
|
|
471
|
+
// the session that sent the event is not closed under its own command: the dispatcher closes it next tick
|
|
472
|
+
const caller = process.env.CLAUDE_CODE_SESSION_ID || process.env.CODEX_THREAD_ID;
|
|
473
|
+
if (caller && caller === session.session_id) { tx(board, (db) => setRunSession(db, row.id, { ...session, close_requested: now() })); return; }
|
|
460
474
|
stopSession(session);
|
|
461
475
|
tx(board, (db) => setRunSession(db, row.id, { ...session, closed_at: now() }));
|
|
462
476
|
return;
|
|
@@ -1080,7 +1094,7 @@ export async function tick({ root, lanes, settings, only = null, slugs = null, d
|
|
|
1080
1094
|
const phase = (name) => { const t = Date.now(); report.ms[name] = t - mark; mark = t; };
|
|
1081
1095
|
readMailbox(board, boardAddress(board.label), report); phase('mailbox');
|
|
1082
1096
|
const effects = [];
|
|
1083
|
-
supervise(board, fleet, settings, report, entry, effects); phase('supervise');
|
|
1097
|
+
supervise(board, fleet, settings, report, entry, effects); closeRequested(board, report); phase('supervise');
|
|
1084
1098
|
report.promoted = recomputeReady(board);
|
|
1085
1099
|
const before = report.started.length;
|
|
1086
1100
|
if (dispatch) startCards(board, fleet, lanes, settings, report, entry, effects, { only, hostRunning });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-orchestrator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
|
|
6
6
|
"exports": {
|