@north-light/crouter 0.3.262 → 0.3.269

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 (150) hide show
  1. package/dist/api/client.d.ts +5 -1
  2. package/dist/api/client.js +6 -0
  3. package/dist/api/dto/canvas.d.ts +53 -2
  4. package/dist/api/dto/health.d.ts +2 -0
  5. package/dist/api/dto/nodes.d.ts +6 -2
  6. package/dist/api/routes.d.ts +1 -0
  7. package/dist/api/routes.js +1 -0
  8. package/dist/builtin-memory/05-kinds/advisor/advice-contract.md +2 -2
  9. package/dist/builtin-memory/internal/memory-loading.md +3 -3
  10. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/integration/provider-rotation.test.ts +50 -0
  11. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +46 -6
  12. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +10 -5
  13. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +12 -5
  14. package/dist/clients/attach/input/controller.d.ts +4 -0
  15. package/dist/clients/attach/input/controller.js +8 -0
  16. package/dist/clients/attach/session/bindings.d.ts +3 -0
  17. package/dist/clients/attach/session/bindings.js +7 -0
  18. package/dist/clients/attach/session/keys.d.ts +2 -0
  19. package/dist/clients/attach/session/keys.js +3 -3
  20. package/dist/clients/attach/session/whip-achievements.d.ts +4 -0
  21. package/dist/clients/attach/session/whip-achievements.js +145 -0
  22. package/dist/clients/attach/slash/dispatch.js +5 -3
  23. package/dist/clients/attach/viewer.js +668 -667
  24. package/dist/commands/canvas-history/grep.js +3 -22
  25. package/dist/commands/canvas-history/read.js +5 -3
  26. package/dist/commands/canvas-history/search.js +3 -22
  27. package/dist/commands/canvas-history/shared.d.ts +8 -0
  28. package/dist/commands/canvas-history/shared.js +64 -1
  29. package/dist/commands/canvas-history/stats.d.ts +1 -0
  30. package/dist/commands/canvas-history/stats.js +68 -0
  31. package/dist/commands/canvas-history.js +4 -3
  32. package/dist/commands/memory/read.js +15 -38
  33. package/dist/commands/memory/shared.d.ts +1 -1
  34. package/dist/commands/memory/shared.js +1 -1
  35. package/dist/commands/node/create.js +2 -2
  36. package/dist/commands/sys/config.js +19 -2
  37. package/dist/commands/sys/context/admin/docs-panel.d.ts +3 -3
  38. package/dist/commands/sys/context/admin/model.d.ts +7 -2
  39. package/dist/commands/sys/context/admin/model.js +7 -1
  40. package/dist/commands/sys/context/admin/read-view.d.ts +5 -5
  41. package/dist/commands/sys/context/admin/read-view.js +9 -4
  42. package/dist/commands/sys/context/resolve.d.ts +32 -3
  43. package/dist/commands/sys/context/resolve.js +74 -25
  44. package/dist/commands/sys/panels/models-panel.d.ts +28 -5
  45. package/dist/commands/sys/panels/models-panel.js +560 -75
  46. package/dist/core/__tests__/integration/broker-sdk-wiring.test.js +1 -1
  47. package/dist/core/__tests__/integration/revive.test.js +4 -2
  48. package/dist/core/__tests__/model-pin-durability.test.js +25 -1
  49. package/dist/core/__tests__/model-routes-config.test.d.ts +1 -0
  50. package/dist/core/__tests__/model-routes-config.test.js +142 -0
  51. package/dist/core/__tests__/on-read-nested-store.test.js +8 -0
  52. package/dist/core/__tests__/profile-project-memory-delivery.test.js +264 -1
  53. package/dist/core/__tests__/relaunch-root.test.js +17 -0
  54. package/dist/core/__tests__/seam/broker-provider-retry.test.js +21 -6
  55. package/dist/core/__tests__/seam/memory-slash-node-relative-inventory.test.js +19 -2
  56. package/dist/core/broker-client/__tests__/transport-relay.test.js +3 -1
  57. package/dist/core/broker-client/transport-relay.js +5 -1
  58. package/dist/core/canvas/__tests__/history-transcript.test.d.ts +1 -0
  59. package/dist/core/canvas/__tests__/history-transcript.test.js +102 -0
  60. package/dist/core/canvas/browse/app.d.ts +1 -1
  61. package/dist/core/canvas/browse/app.js +13 -10
  62. package/dist/core/canvas/browse/model.js +16 -1
  63. package/dist/core/canvas/browse/render.d.ts +23 -3
  64. package/dist/core/canvas/browse/render.js +429 -64
  65. package/dist/core/canvas/canvas.js +12 -8
  66. package/dist/core/canvas/extensions.d.ts +1 -1
  67. package/dist/core/canvas/extensions.js +7 -1
  68. package/dist/core/canvas/history.d.ts +36 -1
  69. package/dist/core/canvas/history.js +328 -7
  70. package/dist/core/canvas/labels.d.ts +2 -2
  71. package/dist/core/canvas/migrations.js +32 -0
  72. package/dist/core/canvas/node-recap.d.ts +23 -0
  73. package/dist/core/canvas/node-recap.js +67 -0
  74. package/dist/core/canvas/render-source.d.ts +34 -2
  75. package/dist/core/canvas/render-source.js +83 -24
  76. package/dist/core/canvas/types.d.ts +9 -0
  77. package/dist/core/config.d.ts +19 -2
  78. package/dist/core/config.js +174 -51
  79. package/dist/core/keybindings/catalog.d.ts +2 -2
  80. package/dist/core/keybindings/catalog.js +11 -8
  81. package/dist/core/model-routes.js +11 -4
  82. package/dist/core/runtime/broker/auth-reload.js +4 -1
  83. package/dist/core/runtime/broker/fault-retry.js +7 -2
  84. package/dist/core/runtime/broker/frame-client.js +4 -0
  85. package/dist/core/runtime/broker/frame-dispatch.js +7 -0
  86. package/dist/core/runtime/broker/inbox.d.ts +12 -2
  87. package/dist/core/runtime/broker/inbox.js +68 -38
  88. package/dist/core/runtime/broker-protocol.d.ts +6 -0
  89. package/dist/core/runtime/broker.js +14 -0
  90. package/dist/core/runtime/canvas-extensions.d.ts +1 -0
  91. package/dist/core/runtime/canvas-extensions.js +2 -0
  92. package/dist/core/runtime/interactive-deliver.d.ts +8 -2
  93. package/dist/core/runtime/interactive-deliver.js +12 -3
  94. package/dist/core/runtime/launch-target.js +1 -1
  95. package/dist/core/runtime/launch.d.ts +12 -6
  96. package/dist/core/runtime/launch.js +19 -17
  97. package/dist/core/runtime/model-swap.d.ts +5 -4
  98. package/dist/core/runtime/model-swap.js +7 -5
  99. package/dist/core/runtime/promote.js +2 -1
  100. package/dist/core/runtime/reset.js +4 -2
  101. package/dist/core/runtime/revive.js +22 -0
  102. package/dist/core/runtime/spawn.d.ts +3 -3
  103. package/dist/core/runtime/spawn.js +20 -3
  104. package/dist/core/runtime/stamp/channel.d.ts +18 -0
  105. package/dist/core/runtime/stamp/channel.js +74 -0
  106. package/dist/core/runtime/stamp/protocol.d.ts +86 -0
  107. package/dist/core/runtime/stamp/protocol.js +113 -0
  108. package/dist/core/runtime/tmux-driver.d.ts +11 -1
  109. package/dist/core/runtime/tmux-driver.js +27 -11
  110. package/dist/core/self-update.js +2 -5
  111. package/dist/core/substrate/listings.d.ts +1 -1
  112. package/dist/core/substrate/listings.js +6 -2
  113. package/dist/core/substrate/on-read.d.ts +61 -5
  114. package/dist/core/substrate/on-read.js +129 -22
  115. package/dist/core/substrate/render.d.ts +3 -2
  116. package/dist/core/substrate/render.js +133 -38
  117. package/dist/core/tui/draw.d.ts +1 -0
  118. package/dist/core/tui/draw.js +5 -1
  119. package/dist/core/tui/markdown.d.ts +17 -0
  120. package/dist/core/tui/markdown.js +407 -0
  121. package/dist/core/user-settings.d.ts +4 -0
  122. package/dist/core/user-settings.js +1 -0
  123. package/dist/daemon/api/__tests__/node-model-validation.test.js +21 -0
  124. package/dist/daemon/api/__tests__/seam/api-server.test.js +34 -0
  125. package/dist/daemon/api/bridge.d.ts +3 -2
  126. package/dist/daemon/api/bridge.js +34 -9
  127. package/dist/daemon/api/handlers/canvas.js +80 -18
  128. package/dist/daemon/api/handlers/health.js +17 -12
  129. package/dist/daemon/api/handlers/messages.js +12 -1
  130. package/dist/daemon/api/handlers/nodes.js +10 -3
  131. package/dist/daemon/api/map.js +2 -0
  132. package/dist/daemon/messaging/node-message.js +15 -1
  133. package/dist/daemon/reconcilers/broker-supervision.js +26 -9
  134. package/dist/daemon/reconcilers/live-obligation.d.ts +8 -1
  135. package/dist/daemon/reconcilers/live-obligation.js +17 -0
  136. package/dist/pi-extensions/__tests__/pre-command-gate.test.js +2 -2
  137. package/dist/pi-extensions/canvas-inbox-watcher.js +27 -2
  138. package/dist/pi-extensions/canvas-recap.js +4 -0
  139. package/dist/pi-extensions/canvas-stamp.d.ts +14 -0
  140. package/dist/pi-extensions/canvas-stamp.js +77 -0
  141. package/dist/pi-extensions/canvas-stophook.js +3 -0
  142. package/dist/shared/__tests__/env-boundary.test.js +4 -2
  143. package/dist/shared/crtr-version.d.ts +2 -0
  144. package/dist/shared/crtr-version.js +18 -0
  145. package/dist/shared/env.d.ts +10 -0
  146. package/dist/shared/env.js +19 -4
  147. package/dist/types.d.ts +14 -2
  148. package/dist/types.js +4 -0
  149. package/package.json +1 -1
  150. package/runtime.lock.json +2 -2
@@ -0,0 +1,67 @@
1
+ // node-recap.ts — the node's last Goal/State briefing, persisted.
2
+ //
3
+ // The recap itself is generated in the broker (`pi-extensions/canvas-recap.ts`)
4
+ // and painted above the editor as throwaway chrome. That widget lives in broker
5
+ // memory, so the moment a node goes dormant its briefing is gone — which is
6
+ // exactly when a developer scanning `crtr canvas browse` needs it most ("what was
7
+ // this one for, and where did it stop?"). Persisting the two lines the viewer
8
+ // already produced makes them readable without a broker and without a model call.
9
+ //
10
+ // Stored beside telemetry in `job/` because it is machine-generated runtime
11
+ // state, not a document the node authored: safe to delete, rebuilt on the node's
12
+ // next idle recap. `context/` stays the agent's own document space.
13
+ import { join } from 'node:path';
14
+ import { mkdirSync } from 'node:fs';
15
+ import { jobDir } from './paths.js';
16
+ import { readJsonIfExists, atomicWriteJson } from '../fs-utils.js';
17
+ function recapPath(nodeId) {
18
+ return join(jobDir(nodeId), 'recap.json');
19
+ }
20
+ /** Strip one leading `Goal:` / `State:` label from a briefing line. */
21
+ function stripLabel(line) {
22
+ return line.replace(/^\s*(goal|state)\s*:\s*/i, '').trim();
23
+ }
24
+ /** Split the model's two-line briefing into its labelled halves. Returns null for
25
+ * anything that doesn't yield at least one non-empty line — a garbled recap is
26
+ * worse than none, so it is never stored. Missing labels fall back to line order
27
+ * (the prompt asks for Goal first, State second). */
28
+ export function parseRecapBriefing(briefing) {
29
+ const lines = briefing.split('\n').map((l) => l.trim()).filter((l) => l !== '');
30
+ if (lines.length === 0)
31
+ return null;
32
+ const labelled = (prefix) => lines.find((l) => new RegExp(`^${prefix}\\s*:`, 'i').test(l));
33
+ const goalLine = labelled('goal') ?? lines[0];
34
+ const stateLine = labelled('state') ?? (lines[1] !== goalLine ? lines[1] : undefined);
35
+ const goal = goalLine === undefined ? '' : stripLabel(goalLine);
36
+ const state = stateLine === undefined ? '' : stripLabel(stateLine);
37
+ if (goal === '' && state === '')
38
+ return null;
39
+ return { goal, state };
40
+ }
41
+ /** Persist a freshly generated briefing. Best-effort — a write failure only costs
42
+ * the browse preview one stale panel, so it must never disturb the broker. */
43
+ export function writeNodeRecap(nodeId, briefing) {
44
+ const parsed = parseRecapBriefing(briefing);
45
+ if (parsed === null)
46
+ return;
47
+ try {
48
+ mkdirSync(jobDir(nodeId), { recursive: true });
49
+ atomicWriteJson(recapPath(nodeId), { ...parsed, at: new Date().toISOString() });
50
+ }
51
+ catch {
52
+ /* best-effort: the recap is regenerated on the node's next idle window */
53
+ }
54
+ }
55
+ /** The node's stored briefing, or undefined when it never generated one (a node
56
+ * that finished before its first idle window, or one last run before this file
57
+ * existed). Never throws. */
58
+ export function readNodeRecap(nodeId) {
59
+ const raw = readJsonIfExists(recapPath(nodeId));
60
+ if (raw === null || typeof raw !== 'object')
61
+ return undefined;
62
+ const goal = typeof raw.goal === 'string' ? raw.goal : '';
63
+ const state = typeof raw.state === 'string' ? raw.state : '';
64
+ if (goal === '' && state === '')
65
+ return undefined;
66
+ return { goal, state, at: typeof raw.at === 'string' ? raw.at : '' };
67
+ }
@@ -1,4 +1,5 @@
1
1
  import type { CanvasSource } from './source.js';
2
+ import { type NodeRecap } from './node-recap.js';
2
3
  import { type Fault } from '../runtime/fault.js';
3
4
  import type { NodeStatus, Lifecycle, NodeMeta, NodeRow, TerminalReason } from './types.js';
4
5
  export declare function activeFaultForDisplay<T extends {
@@ -69,6 +70,15 @@ export interface DashboardRow {
69
70
  * by loadPreview (same single session read as `prompts`); undefined for a node whose
70
71
  * session has no assistant reply yet. Shown in the preview's reply block. */
71
72
  lastAssistant?: string;
73
+ /** The node's last persisted Goal/State briefing (`job/recap.json`, written by the
74
+ * broker's recap extension). Populated LAZILY by loadPreview; undefined for a node
75
+ * that never generated one. The preview's fastest "what is this / where is it" line. */
76
+ recap?: NodeRecap;
77
+ /** The newest report the node pushed (`reports/<ts>-<id>-<kind>.md`). Populated
78
+ * LAZILY by loadPreview; undefined when the node has pushed nothing. Residents push
79
+ * updates as they work, so this is the last thing the node deliberately DELIVERED —
80
+ * usually crisper than its last assistant message. */
81
+ report?: NodeReportPreview;
72
82
  /** True when the node is GENUINELY mid-turn right now — its `busy` marker exists
73
83
  * AND its broker pid is alive (not merely an `active`, between-turns node). The
74
84
  * live "is it generating?" cue. Computed on the cheap boot path for LIVE nodes
@@ -93,8 +103,30 @@ export interface DashboardRow {
93
103
  /** Lazy-enrichment guard (internal): true once loadPreview has read goal + the
94
104
  * session (prompts + lastAssistant). Idempotency marker for the selected row. */
95
105
  previewLoaded?: boolean;
106
+ /** The source `NodeRow` this row was built from (dashboardRowFromNodeRow only).
107
+ * Carries every column listNodes already fetched — the runtime fields
108
+ * (host_kind/parent/waiting_for/final_report/finalized_at/pi_pid) plus the
109
+ * mirrored identity fields (description/cycles) — so the snapshot handler
110
+ * reads them here instead of opening meta.json.
111
+ * Undefined for rows built by other paths (dashboardRowsFromSource). */
112
+ srcRow?: NodeRow;
96
113
  }
97
114
  export declare function readGoalText(nodeId: string): string | undefined;
115
+ /** The newest pushed report, reduced to what a preview panel can use. */
116
+ export interface NodeReportPreview {
117
+ /** final | update | urgent (frontmatter, else the filename suffix). */
118
+ kind: string;
119
+ /** ISO 8601 push time (frontmatter, else the filename stamp). */
120
+ ts: string;
121
+ /** The report's first markdown heading, or its first non-empty line. */
122
+ heading: string;
123
+ /** The body after that heading, whitespace-normalized + capped. */
124
+ body: string;
125
+ }
126
+ /** The node's newest report, read straight off disk. Report filenames lead with a
127
+ * compact timestamp, so the lexicographic maximum is the latest one — no stat of
128
+ * the whole directory. Never throws; undefined when the node pushed nothing. */
129
+ export declare function readNewestReport(nodeId: string): NodeReportPreview | undefined;
98
130
  interface SessionParts {
99
131
  prompts?: string;
100
132
  lastAssistant?: string;
@@ -137,8 +169,8 @@ export declare function dashboardRowsFromSource(source: CanvasSource, rootId: st
137
169
  * the node ids from one `listFocuses()` query so `viewed` remains visible without
138
170
  * coupling the canvas source to local viewer state. Remote sources ignore that
139
171
  * set. Local disk telemetry/fault/streaming are likewise suppressed remotely. */
140
- export declare function dashboardRowsAllFromSource(source: CanvasSource, localFocusedNodeIds?: ReadonlySet<string>): Promise<DashboardRow[]>;
141
- export declare function enrichRowsFromSource(source: CanvasSource, rows: DashboardRow[], asks?: Record<string, number>): Promise<void>;
172
+ export declare function dashboardRowsAllFromSource(source: CanvasSource, localFocusedNodeIds?: ReadonlySet<string>, liveOnly?: boolean): Promise<DashboardRow[]>;
173
+ export declare function enrichRowsFromSource(_source: CanvasSource, rows: DashboardRow[], asks?: Record<string, number>): Promise<void>;
142
174
  /** goal (initial-prompt.md) and session parts are local disk reads — suppressed
143
175
  * to undefined for a remote source. */
144
176
  export declare function loadPreviewFromSource(source: CanvasSource, row: DashboardRow): Promise<DashboardRow>;
@@ -9,14 +9,16 @@
9
9
  // migrated onto these `*FromSource` variants directly.
10
10
  //
11
11
  // ALLOWED imports (verified openDb-free): node:fs/path, ./pid.js, ./labels.js,
12
- // ./status-glyph.js, ../runtime/fault.js, ./paths.js, ./remote-canvas-source.js,
13
- // and TYPE-ONLY ./source.js + ./types.js. Do NOT import ./canvas.js, ./attention.js,
12
+ // ./status-glyph.js, ./node-recap.js, ../runtime/fault.js, ../frontmatter.js,
13
+ // ./paths.js, ./remote-canvas-source.js, and TYPE-ONLY ./source.js + ./types.js. Do NOT import ./canvas.js, ./attention.js,
14
14
  // ./focuses.js, or ./db.js here — that is the whole point of the split.
15
- import { existsSync, readFileSync, statSync } from 'node:fs';
15
+ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
16
16
  import { join } from 'node:path';
17
17
  import { RemoteCanvasSource } from './remote-canvas-source.js';
18
18
  import { fullName } from './labels.js';
19
- import { jobDir, contextDir } from './paths.js';
19
+ import { jobDir, contextDir, reportsDir } from './paths.js';
20
+ import { readNodeRecap } from './node-recap.js';
21
+ import { parseFrontmatterGeneric } from '../frontmatter.js';
20
22
  import { isPidAlive } from './pid.js';
21
23
  import { isFrozenRow, resolveNodeVisual, faultSummary } from './status-glyph.js';
22
24
  import { readFault } from '../runtime/fault.js';
@@ -168,6 +170,63 @@ export function readGoalText(nodeId) {
168
170
  return undefined;
169
171
  }
170
172
  }
173
+ const REPORT_BODY_CAP = 1024;
174
+ /** Compact report stamp `20260810T190533286` → an ISO 8601 instant. */
175
+ function reportStampToIso(stamp) {
176
+ const m = stamp.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})?$/);
177
+ if (m === null)
178
+ return undefined;
179
+ return `${m[1]}-${m[2]}-${m[3]}T${m[4]}:${m[5]}:${m[6]}.${m[7] ?? '000'}Z`;
180
+ }
181
+ /** The node's newest report, read straight off disk. Report filenames lead with a
182
+ * compact timestamp, so the lexicographic maximum is the latest one — no stat of
183
+ * the whole directory. Never throws; undefined when the node pushed nothing. */
184
+ export function readNewestReport(nodeId) {
185
+ let newest;
186
+ try {
187
+ for (const f of readdirSync(reportsDir(nodeId))) {
188
+ if (!f.endsWith('.md'))
189
+ continue;
190
+ if (newest === undefined || f > newest)
191
+ newest = f;
192
+ }
193
+ }
194
+ catch {
195
+ return undefined; // no reports dir
196
+ }
197
+ if (newest === undefined)
198
+ return undefined;
199
+ let raw;
200
+ try {
201
+ raw = readFileSync(join(reportsDir(nodeId), newest), 'utf8');
202
+ }
203
+ catch {
204
+ return undefined;
205
+ }
206
+ const { data, body } = parseFrontmatterGeneric(raw);
207
+ const name = newest.replace(/\.md$/, '');
208
+ const kind = typeof data?.['kind'] === 'string'
209
+ ? data['kind']
210
+ : (name.split('-').pop() ?? 'report');
211
+ const ts = typeof data?.['ts'] === 'string'
212
+ ? data['ts']
213
+ : (reportStampToIso(name.split('-')[0] ?? '') ?? '');
214
+ // The heading is the report's own headline; everything after it is the detail the
215
+ // preview shows next, so a panel never repeats the heading twice.
216
+ const lines = body.split('\n');
217
+ let heading = '';
218
+ let rest = body;
219
+ for (let i = 0; i < lines.length; i++) {
220
+ const t = (lines[i] ?? '').trim();
221
+ if (t === '')
222
+ continue;
223
+ heading = t.startsWith('#') ? t.replace(/^#+\s*/, '').trim() : t;
224
+ rest = lines.slice(i + 1).join('\n');
225
+ break;
226
+ }
227
+ const text = rest.replace(/\s+/g, ' ').trim();
228
+ return { kind, ts, heading, body: text.length > REPORT_BODY_CAP ? text.slice(0, REPORT_BODY_CAP) : text };
229
+ }
171
230
  /** The node's session-derived preview text in ONE file read (today's two reads,
172
231
  * folded): EVERY user prompt across the pi session (`prompts` — the whole
173
232
  * conversation, not just the spawn prompt) AND the LAST assistant message text
@@ -385,8 +444,9 @@ export function dashboardRowFromNodeRow(row, focusedNodeIds, remote) {
385
444
  const hanging = remote ? null : activeFaultForDisplay(row, readFault(row.node_id));
386
445
  return {
387
446
  node_id: row.node_id,
388
- name: row.name, // handle only; enrichRow upgrades to fullName (meta.description)
447
+ name: fullName(row), // description is a row column (v38) — no meta read needed
389
448
  handle: row.name,
449
+ description: row.description,
390
450
  status: row.status,
391
451
  frozen_at: row.frozen_at ?? null,
392
452
  terminal_reason: row.terminal_reason ?? null,
@@ -403,6 +463,7 @@ export function dashboardRowFromNodeRow(row, focusedNodeIds, remote) {
403
463
  streaming: !remote && hanging === null && live ? isStreaming(row.node_id, row.pi_pid) : false,
404
464
  hanging,
405
465
  viewed: remote ? false : focusedNodeIds.has(row.node_id) || hasLiveBrokerViewer(row),
466
+ srcRow: row,
406
467
  };
407
468
  }
408
469
  /** One row per node visible in the sub-DAG of `rootId` (including root), read
@@ -443,33 +504,29 @@ export async function dashboardRowsFromSource(source, rootId) {
443
504
  * the node ids from one `listFocuses()` query so `viewed` remains visible without
444
505
  * coupling the canvas source to local viewer state. Remote sources ignore that
445
506
  * set. Local disk telemetry/fault/streaming are likewise suppressed remotely. */
446
- export async function dashboardRowsAllFromSource(source, localFocusedNodeIds = new Set()) {
507
+ export async function dashboardRowsAllFromSource(source, localFocusedNodeIds = new Set(), liveOnly = false) {
447
508
  const remote = source instanceof RemoteCanvasSource;
448
509
  const focusedNodeIds = remote ? new Set() : localFocusedNodeIds;
449
- return (await source.listNodes()).map((row) => dashboardRowFromNodeRow(row, focusedNodeIds, remote));
510
+ const rows = await source.listNodes(liveOnly ? { status: ['active', 'idle'] } : undefined);
511
+ return rows.map((row) => dashboardRowFromNodeRow(row, focusedNodeIds, remote));
450
512
  }
451
- // Lazy enrichment (source-driven) — fold expensive per-node reads into rows on
452
- // demand. Ask counts are supplied by the caller (`asks` — a pre-fetched
453
- // `ticketCountsForView` map merged across the visible roots), NOT scanned here
454
- // (`ticketCountsForNodes` reaches openDb). Telemetry (ctx tokens) + goal/session
455
- // are LOCAL disk reads, suppressed for a `RemoteCanvasSource`.
456
- export async function enrichRowsFromSource(source, rows, asks) {
513
+ // Lazy enrichment (source-driven) — fold the per-node reads the cheap boot skips
514
+ // into rows on demand. Ask counts are supplied by the caller (`asks` — a
515
+ // pre-fetched `ticketCountsForView` map merged across the visible roots), NOT
516
+ // scanned here (`ticketCountsForNodes` reaches openDb). Telemetry (ctx tokens) is
517
+ // a LOCAL disk read, suppressed for a `RemoteCanvasSource`.
518
+ //
519
+ // This does NO source read. The label fields it used to re-fetch per node
520
+ // (name/handle/description) are set by the row builders: `description` became a
521
+ // nodes-table column in v38, so both builders already hold the full label and a
522
+ // per-node getNode here would re-read what the caller's single listNodes returned.
523
+ export async function enrichRowsFromSource(_source, rows, asks) {
457
524
  const todo = rows.filter((r) => r.enriched !== true);
458
525
  if (todo.length === 0)
459
526
  return;
460
- const remote = source instanceof RemoteCanvasSource;
527
+ const remote = _source instanceof RemoteCanvasSource;
461
528
  const askMap = asks ?? {};
462
- // A full dashboard may contain thousands of rows. Keep source reads serial:
463
- // ApiCanvasSource turns each into a unix-socket request, and an unbounded
464
- // Promise.all can overflow crtrd's accept backlog then spuriously trigger
465
- // the client's cold-daemon path even though the daemon is still running.
466
529
  for (const row of todo) {
467
- const meta = await source.getNode(row.node_id);
468
- if (meta !== null) {
469
- row.name = fullName(meta);
470
- row.handle = meta.name;
471
- row.description = meta.description;
472
- }
473
530
  row.ctx_tokens = remote ? 0 : (readNodeTelemetry(row.node_id).tokens_in ?? 0);
474
531
  row.asks = askMap[row.node_id] ?? 0;
475
532
  row.enriched = true;
@@ -487,6 +544,8 @@ export async function loadPreviewFromSource(source, row) {
487
544
  const { prompts, lastAssistant } = readSessionParts(meta?.pi_session_file);
488
545
  row.prompts = prompts;
489
546
  row.lastAssistant = lastAssistant;
547
+ row.recap = readNodeRecap(row.node_id);
548
+ row.report = readNewestReport(row.node_id);
490
549
  }
491
550
  row.previewLoaded = true;
492
551
  return row;
@@ -292,6 +292,15 @@ export type NodeMeta = NodeIdentity & NodeRuntime;
292
292
  export interface NodeRow {
293
293
  node_id: string;
294
294
  name: string;
295
+ /** The pi-generated first-task description; see NodeIdentity.description.
296
+ * Durable IDENTITY mirrored to the row (like `cwd`/`host_kind`) so a roster
297
+ * read can build the full display label without opening meta.json. Absent for
298
+ * a node not yet named — the column's NULL is mapped to undefined at `rowFrom`
299
+ * so identity, row, and DTO all spell "unnamed" the same way. */
300
+ description?: string;
301
+ /** Relaunch count; see NodeIdentity.cycles. Mirrored to the row for the same
302
+ * reason as `description`; absent on a row written before this column. */
303
+ cycles?: number;
295
304
  kind: string;
296
305
  mode: Mode;
297
306
  lifecycle: Lifecycle;
@@ -2,12 +2,12 @@ import type { PageComponentRegistration, Scope, ScopeConfig, ScopeState, HumanAc
2
2
  import { type BindingId } from './keybindings/catalog.js';
3
3
  export declare function configPath(scope: Scope): string | null;
4
4
  export declare function statePath(scope: Scope): string | null;
5
- export declare function readConfig(scope: Scope): ScopeConfig;
5
+ export declare function readConfig(scope: Scope): ResolvedScopeConfig;
6
6
  /** Read the config that lives at an EXACT scope-root dir, rather than the
7
7
  * resolved nearest root for a scope. Lets a caller iterate each visible
8
8
  * project root's own config when several are in scope (nested `.crouter` dirs
9
9
  * or a profile-widened stack), instead of collapsing them onto the nearest. */
10
- export declare function readConfigAtRoot(root: string): ScopeConfig;
10
+ export declare function readConfigAtRoot(root: string): ResolvedScopeConfig;
11
11
  export declare function readState(scope: Scope): ScopeState;
12
12
  type RawConfig = Record<string, unknown>;
13
13
  export declare function updateRawConfigAtomically(scope: Scope, mutate: (latest: RawConfig) => RawConfig): RawConfig;
@@ -26,6 +26,14 @@ export declare function ensureScopeInitialized(scope: Scope, root: string): void
26
26
  /** Normalize the user-owned list of attach actions allowed to bridge through an
27
27
  * occupied tmux root binding. Unknown and non-attach ids have no effect. */
28
28
  export declare function normalizeTmuxPassthrough(raw: unknown): BindingId[];
29
+ type LegacyModelRouteConfig = Omit<ModelRouteConfig, 'models'> & {
30
+ models: Partial<Record<ModelStrength, string>>;
31
+ };
32
+ /** Read configuration exposes legacy sparse routes separately during the
33
+ * one-release cutover; launch code only treats `modelRoutes` as complete. */
34
+ export type ResolvedScopeConfig = ScopeConfig & {
35
+ legacyModelRoutes?: Record<string, LegacyModelRouteConfig>;
36
+ };
29
37
  /** One malformed `bin` declaration. The read path retains these as doctor
30
38
  * findings rather than letting malformed config break a node launch. */
31
39
  export interface BinDeclarationIssue {
@@ -103,7 +111,11 @@ export declare function readRawScopeConfig(scope: Scope): Partial<ScopeConfig> |
103
111
  export interface MergedLaunchConfig {
104
112
  kinds: Record<string, KindConfig>;
105
113
  modelLadders: ModelLaddersConfig;
114
+ /** Complete declared routes. Every route here has all four strengths. */
106
115
  modelRoutes?: Record<string, ModelRouteConfig>;
116
+ /** Read-only compatibility view for sparse routes written before complete
117
+ * routes were required. New route persistence never produces this shape. */
118
+ legacyModelRoutes?: Record<string, LegacyModelRouteConfig>;
107
119
  modelRouting?: ModelRoutingConfig;
108
120
  /** The merged `spawnEnv.allow` set (project stack > profile > user >
109
121
  * builtin, additive) — read by `buildOperationalEnvBase`
@@ -185,6 +197,11 @@ export declare function persistModelLadders(root: string, patch: {
185
197
  anthropic?: Partial<Record<ModelStrength, string>>;
186
198
  openai?: Partial<Record<ModelStrength, string>>;
187
199
  }): void;
200
+ /** Persist one complete route at one exact config root. The route is the only
201
+ * raw route entry touched; unrelated routes and local ladder defaults remain
202
+ * absent. Pass `undefined` to remove this scope's entry, which resumes lower
203
+ * scope inheritance rather than introducing a tombstone. */
204
+ export declare function persistModelRoute(root: string, routeId: string, route: ModelRouteConfig | undefined): void;
188
205
  /** Mutate one exact config root. Setup uses this for profile and explicit
189
206
  * project targets that cannot be represented by the user/project Scope enum. */
190
207
  export declare function updateConfigAtRoot(root: string, mutate: (cfg: ScopeConfig) => void): ScopeConfig;