@mu-crew/mu 4.1.1 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import {
6
6
  logItem,
7
7
  openHumanNeeds,
8
8
  parseOpKey
9
- } from "./chunk-DEYBQDTO.js";
9
+ } from "./chunk-FVRIKUBR.js";
10
10
  import {
11
11
  UNKNOWN_REASON,
12
12
  WorkstreamNotFoundError,
@@ -16,16 +16,16 @@ import {
16
16
  listLogs,
17
17
  listTasks,
18
18
  readLiveAgents,
19
+ shellWord,
19
20
  tallyCalls,
20
21
  tryResolveLiveWorkstreamId
21
- } from "./chunk-L7I3BLXP.js";
22
+ } from "./chunk-4ZWBLTZK.js";
22
23
 
23
24
  // src/dashboard-data.ts
24
25
  var DEFAULT_STATUS = ["OPEN", "IN_PROGRESS"];
25
26
  var DEFAULT_LOG_LIMIT = 100;
26
27
  var STALLED_TOOL_MS = 15 * 6e4;
27
28
  var FINISHED_CALL = ["done", "failed", "cancelled"];
28
- var FAILED_CALL_MS = 24 * 60 * 6e4;
29
29
  var WAVE_MAX = 5;
30
30
  var callOf = (c) => ({
31
31
  call_id: c.callId,
@@ -146,22 +146,28 @@ var ATTENTION_ORDER = [
146
146
  "sync"
147
147
  ];
148
148
  function agentAttention(a, now) {
149
- const item = (kind, text) => ({
149
+ const item = (kind, text, fix) => ({
150
150
  key: `${kind}:${a.key}`,
151
151
  workstream: a.workstream,
152
152
  kind,
153
153
  text: `${a.name} ${text}`,
154
- target: a.key
154
+ target: a.key,
155
+ ...fix !== void 0 ? { fix } : {}
155
156
  });
156
157
  const since = a.since == null ? Number.NaN : Date.parse(a.since);
157
158
  const waited = Number.isFinite(since) ? ` ${formatElapsed(now - since)}` : "";
158
159
  const out = [];
159
- if (isDead(a)) out.push(item("dead", "dead"));
160
+ if (isDead(a))
161
+ out.push(
162
+ item("dead", "dead", `mu agent close ${shellWord(a.name)} -w ${shellWord(a.workstream)}`)
163
+ );
160
164
  if (a.state === "needs_permission") out.push(item("permission", `permission${waited}`));
161
165
  if (a.idle === true) out.push(item("input", `input${waited}`));
162
- const ran = a.tool?.elapsed_ms;
166
+ const quiet = a.tool?.quiet_ms;
167
+ const ran = quiet ?? a.tool?.elapsed_ms;
163
168
  if (a.tool != null && ran !== void 0 && ran >= STALLED_TOOL_MS) {
164
- out.push(item("stalled", `${a.tool.name} ${formatElapsed(ran)}`));
169
+ const how = quiet !== void 0 ? "quiet " : "";
170
+ out.push(item("stalled", `${a.tool.name} ${how}${formatElapsed(ran)}`));
165
171
  }
166
172
  return out;
167
173
  }
@@ -293,23 +299,18 @@ async function loadDashboard(db, opts) {
293
299
  })) : [];
294
300
  const attention = everyAgent.flatMap((a) => agentAttention(a, now));
295
301
  const liveNames = new Set(live.map((w) => w.name));
296
- const troubled = [
297
- ...listDelegates(db, void 0, void 0, { states: ["refused"] }),
298
- ...listDelegates(db, void 0, void 0, {
299
- states: ["failed"],
300
- updatedAfter: new Date(now - FAILED_CALL_MS).toISOString()
301
- })
302
- ];
303
- troubled.sort((a, b) => keyOf(a.workstream, a.task).localeCompare(keyOf(b.workstream, b.task)));
304
- for (const c of troubled) {
302
+ const refused = listDelegates(db, void 0, void 0, { states: ["refused"] }).sort(
303
+ (a, b) => keyOf(a.workstream, a.task).localeCompare(keyOf(b.workstream, b.task))
304
+ );
305
+ for (const c of refused) {
305
306
  if (!liveNames.has(c.workstream)) continue;
306
- const how = c.state === "refused" ? " (reissue or cancel it from pi)" : "";
307
307
  attention.push({
308
308
  key: `delegate:${keyOf(c.workstream, c.task)}`,
309
309
  workstream: c.workstream,
310
310
  kind: "delegate",
311
- text: `delegate ${c.state}: ${c.request.label ?? c.task}${how}`,
312
- target: keyOf(c.workstream, c.task)
311
+ text: `delegate refused: ${c.request.label ?? c.task} (reissue from pi, or y copies the cancel)`,
312
+ target: keyOf(c.workstream, c.task),
313
+ fix: `mu delegates finish ${shellWord(c.callId)} --outcome cancelled --no-record --author "$USER"`
313
314
  });
314
315
  }
315
316
  for (const t of db.prepare(
@@ -321,8 +322,10 @@ async function loadDashboard(db, opts) {
321
322
  key: `human:${keyOf(t.ws, t.id)}`,
322
323
  workstream: t.ws,
323
324
  kind: "human",
324
- text: t.title,
325
- target: keyOf(t.ws, t.id)
325
+ // The strip labels it `human: ` already; drop recordHumanNeeded's `human needed: ` title prefix.
326
+ text: t.title.replace(/^human needed:\s*/i, ""),
327
+ target: keyOf(t.ws, t.id),
328
+ fix: `mu task close ${shellWord(t.id)} -w ${shellWord(t.ws)} --evidence '<what you decided>'`
326
329
  });
327
330
  }
328
331
  if (next.source === "unavailable") {
@@ -372,4 +375,4 @@ export {
372
375
  matches,
373
376
  loadDashboard
374
377
  };
375
- //# sourceMappingURL=chunk-LBBZAG5C.js.map
378
+ //# sourceMappingURL=chunk-U2QLTREB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dashboard-data.ts"],"sourcesContent":["// SDK seam for the dashboard: ONE read-only projection of everything its tabs\n// show (workstreams, tasks with a delegate task's `call`, frontier, agents, log,\n// human needs, the caller's delegates, delegate `waves`, attention).\n//\n// READ-ONLY by construction: it never reconciles, reaps, ingests or writes, and\n// runs on a `readonly: true` connection. The only I/O beyond SQL is the\n// best-effort ctl probe `readLiveAgents` does (a socket read). It composes the\n// merged readers (`listTasks`, `loadOpenTaskFrontier`, `readLiveAgents`,\n// `listLogs`/`logItem`, `openHumanNeeds`, `listDelegates`, `tallyCalls`) rather than\n// re-deriving them, so a dashboard row equals the CLI's. `stateSnapshot` is NOT\n// the source of the task list: it omits OPEN/parked rows and caps closed ones.\n//\n// `next` is `computeNext` (the CLI's one rule set) with no outcome: it only reads.\n// A failed computation stays `next_source: \"unavailable\"` (never \"no authorised\n// work\"). An agent's `tool` comes from the ctl status the agent read already did:\n// an object while a tool runs, null when none, absent for an extension that\n// predates the field (unknown). Elapsed is `now - since`, calculated at read.\n//\n// Two delegate reads, on purpose: `delegates` is the caller's own unfinished calls\n// (caller-scoped like `human_needs`, empty for a human shell), while a task's\n// `call`, `waves` and the `delegate` attention items read every caller's, because\n// they describe tasks and waves anyone can see. Each delegate read is bounded in\n// SQL (shown task statuses, the newest waves, refused calls only), so a tick\n// does not grow with the delegate history in `scratch`.\n\nimport { type AgentOutput, liveAgentToOutput } from \"./agent-output.js\";\nimport type { StateReading } from \"./agent-state.js\";\nimport { UNKNOWN_REASON } from \"./agent-state.js\";\nimport { readLiveAgents } from \"./agents.js\";\nimport { type LogItem, logItem } from \"./cli/log-records.js\";\nimport type { CtlTool } from \"./ctl/protocol.js\";\nimport { loadOpenTaskFrontier } from \"./dag.js\";\nimport { type Db, tryResolveLiveWorkstreamId, WorkstreamNotFoundError } from \"./db.js\";\nimport { type DelegateRow, listDelegates, tallyCalls } from \"./delegates.js\";\nimport { openHumanNeeds } from \"./human-needed.js\";\nimport { parseOpKey } from \"./log-render.js\";\nimport { latestSeq, listLogs } from \"./logs.js\";\nimport { computeNext } from \"./next-hints.js\";\nimport type { NextPlan } from \"./output-contract.js\";\nimport { shellWord } from \"./shell-quote.js\";\nimport type { TaskStatus } from \"./tasks/status.js\";\nimport { listTasks, type TaskRow } from \"./tasks.js\";\nimport { isScratchWorkstream } from \"./workstream.js\";\n\n/** A running tool of a pi agent (from the ctl status). */\nexport interface AgentTool {\n name: string;\n /** Epoch ms the tool started. */\n since: number;\n /** Calculated at read time (`now - since`), when known. */\n elapsed_ms?: number;\n /** How long since the tool last reported output, by the agent's clock; absent from older extensions. */\n quiet_ms?: number;\n}\n\nexport interface DashboardWorkstream {\n name: string;\n scratch: boolean;\n /** Newest visible op seq in the workstream; 0 when it has none, or when `activity: false` skipped the read. */\n latest_seq: number;\n}\n\n/** One task, SQL column names, `key` = `<workstream>/<id>` (unique across workstreams). */\nexport interface DashboardTask {\n key: string;\n workstream: string;\n id: string;\n title: string;\n status: string;\n substate: string;\n impact: number;\n effort_days: number;\n /** Owner's name; only while IN_PROGRESS. */\n owner: string | null;\n /** The owner's registry id (`tasks.owner_id`; the identity: names repeat across workstreams). */\n owner_id: number | null;\n /** The owner's OWN workstream, which can differ from the task's; null when unowned. */\n owner_workstream: string | null;\n kind: string;\n wave: string | null;\n created_at: string;\n updated_at: string;\n /** `MAX(ops.seq)` over the task's own ops, its notes' and its edges' (raw log, db/sql writes included); 0 when none. */\n activity_seq: number;\n /** The call behind a `kind=delegate` task, whoever made it; absent for any other task. */\n call?: DashboardCall;\n}\n\n/** A delegate call as a task row shows it: machine-wide, never narrowed to a caller. */\nexport interface DashboardCall {\n call_id: string;\n state: string;\n /** The parsed label of a done answer; null otherwise. */\n verdict: string | null;\n /** `<workstream>/<task>` the call judges; null with no record target. */\n judges: string | null;\n wave: string | null;\n}\n\n/**\n * One wave of delegate calls in a workstream, tallied as `verdictTally` counts it\n * (one result per call), over every caller. `pending` includes `refused`.\n */\nexport interface DashboardWave {\n /** `<workstream>/<wave>`. */\n key: string;\n workstream: string;\n wave: string;\n calls: number;\n confirmed: number;\n refuted: number;\n unverified: number;\n pending: number;\n refused: number;\n /** The newest `updated_at` of its calls. */\n updated_at: string;\n}\n\n/** One line of the open DAG (`loadOpenTaskFrontier`, preorder, per workstream). */\nexport interface DashboardEdge {\n key: string;\n workstream: string;\n id: string;\n title: string;\n status: string;\n substate: string;\n depth: number;\n /** Qualified key of the entry it is listed under; null for a root. */\n parent: string | null;\n /** Already listed above (a diamond): not expanded again. */\n again: boolean;\n /** Open neighbours not listed under this entry. */\n kids: number;\n /** CLOSED neighbours collapsed into this count. */\n closed: number;\n cap_cut: number;\n}\n\n/** What the frontier cap left out of one workstream's DAG (per-entry `cap_cut` cannot say it). */\nexport interface DashboardFrontierCut {\n workstream: string;\n /** Open start tasks the node cap left out: open work absent from `edges`. */\n roots_cut: number;\n /** Recurrence (diamond) lines the cap left out; each such task is listed elsewhere. */\n again_cut: number;\n}\n\n/** A registry agent with its computed state; unknown stays unknown. */\nexport interface DashboardAgent extends AgentOutput {\n /** `<workstream>/<name>`. */\n key: string;\n /** Qualified keys of the IN_PROGRESS tasks it owns (empty when none). */\n tasks: string[];\n /** The first of `tasks`; null when none. */\n task: string | null;\n /** The running tool; null = none running; absent = unknown (old extension, no ctl): never read as \"none\". */\n tool?: AgentTool | null;\n}\n\n/** An op of the canonical log, rendered by the one formatter (`logItem`), plus its workstream. */\nexport interface DashboardLogItem extends LogItem {\n /** The workstream the op belongs to; null for a machine-wide op. */\n scope: string | null;\n}\n\n/** An OPEN `human` task of the caller. */\nexport interface DashboardHumanNeed {\n key: string;\n workstream: string;\n id: string;\n reason: string;\n}\n\n/** An unfinished delegate call of the caller. */\nexport interface DashboardDelegate {\n call_id: string;\n workstream: string;\n /** The delegate task's local id. */\n task: string;\n state: string;\n wave: string | null;\n judges: string | null;\n agent: string | null;\n verdict: string | null;\n error: string | null;\n updated_at: string;\n}\n\n/**\n * Something a human has to look at. Read over EVERY live workstream and blind\n * to the status/text filters and the workstream scope, so each surface (the\n * strip under the tabs, the Overview card) agrees.\n *\n * - `dead`: the agent's pane (or gate process) is gone.\n * - `permission`: `needs_permission`; `text` carries how long.\n * - `stalled`: one tool has been quiet (no output) for `STALLED_TOOL_MS`; an\n * older extension that cannot say counts from the tool's start.\n * - `input`: `needs_input` past the idle threshold on an agent that owns work\n * (the registry's `idle` flag; `MU_IDLE_THRESHOLD_MS`, 0 disables).\n * - `delegate`: a delegate call that is `refused` (parked until its pi session\n * reissues it), whoever made it. A failed call is not one: it is final, its\n * caller had the settle, and its task row shows it.\n * - `human`: an OPEN `kind=human` task, whoever recorded it (`human_needs`\n * is caller-scoped and empty for a human shell).\n * - `next_unavailable`: `computeNext` failed.\n * - `sync`: a warning the caller passed as `syncWarnings`.\n */\nexport type AttentionKind =\n | \"dead\"\n | \"permission\"\n | \"input\"\n | \"stalled\"\n | \"delegate\"\n | \"human\"\n | \"next_unavailable\"\n | \"sync\";\n\nexport interface DashboardAttention {\n /** Unique within a snapshot (`<kind>:<target>`). */\n key: string;\n /** The workstream it belongs to; null for a machine-wide item (`next_unavailable`, `sync`). */\n workstream: string | null;\n kind: AttentionKind;\n /** One short line, age at read (\"worker-3 permission 20m\"; a human task: its title); bare names, the UI qualifies. */\n text: string;\n /** Qualified key to drill into: the agent (dead/permission/input/stalled) or the task (delegate, human); null otherwise. */\n target: string | null;\n /** The `mu` command that clears it, for `y` to copy (absent: attach or read instead). */\n fix?: string;\n}\n\nexport interface DashboardSnapshot {\n /** The identity the caller-scoped panels were read for; null = a human shell. */\n caller: string | null;\n /** `none`: no identity, so `human_needs` and `delegates` are empty BY DESIGN (never another caller's); `call`, `waves` and attention are every caller's. */\n caller_scope: \"caller\" | \"none\";\n /** Every live workstream, scratch included; never narrowed by a filter (it is the switcher). */\n workstreams: DashboardWorkstream[];\n tasks: DashboardTask[];\n edges: DashboardEdge[];\n /** One per in-scope workstream: the frontier's root/recurrence cuts, passed through. */\n frontier: DashboardFrontierCut[];\n agents: DashboardAgent[];\n /** The newest ops, oldest first. */\n log: DashboardLogItem[];\n /** `computeNext` for the caller set and the workstream filter; null when `next_source` is `unavailable`, or computed and nothing is authorised. */\n next: NextPlan;\n /** `unavailable`: the computation failed; the UI must not read null as \"no work\". */\n next_source: \"unavailable\" | \"computed\";\n human_needs: DashboardHumanNeed[];\n delegates: DashboardDelegate[];\n /** Per read workstream (tasks scope), its `WAVE_MAX` most recently updated waves, newest first, any caller. */\n waves: DashboardWave[];\n /** Trouble across every workstream, filters ignored, most urgent first (see `AttentionKind`). */\n attention: DashboardAttention[];\n}\n\nexport interface DashboardOptions {\n /** Narrow tasks, frontier, agents, log and caller panels to one live workstream. */\n workstream?: string;\n /**\n * Read tasks, edges and frontier of this workstream ONLY (a name that is not live,\n * or null: none), leaving agents, log, caller panels and attention machine-wide:\n * the dashboard shows one workstream, and reading every other one's tasks and DAG\n * each tick is what made it costly. Absent: every live workstream. `workstream`, when\n * set, wins.\n */\n scopeWorkstream?: string | null;\n /** Statuses to list; default OPEN + IN_PROGRESS (CLOSED is hidden). */\n status?: readonly TaskStatus[];\n /** Case-insensitive substring over a task's key/title/owner/substate and an agent's key/name/state/task keys. */\n text?: string;\n /** `spawnerFromEnv()`; null = a human shell (caller-scoped panels stay empty). */\n caller: string | null;\n /** Who `next` is computed for (`currentCallers()`); default: `caller` alone, none for a human shell. */\n callers?: readonly string[];\n /** Log tail size (default 100). */\n logLimit?: number;\n /** Read the log tail of this workstream only, leaving every other panel unscoped (not checked: a name that is not live reads an empty log). */\n logWorkstream?: string;\n /**\n * Read each workstream's `latest_seq` (default true). It only ranks the starting\n * pick and costs one log scan per workstream, so the dashboard's poll passes false\n * once the set of live workstreams is known (every `latest_seq` is then 0).\n */\n activity?: boolean;\n /** Sync warnings the caller holds (`ambientIngest`); each becomes a `sync` attention item. */\n syncWarnings?: readonly string[];\n /**\n * The agent-state cache (the dashboard's slow tier, see `readLiveAgents`): with\n * `probe: false` the read is SQL only for every cached agent. Absent: probe all.\n */\n agentStates?: { cache: Map<string, StateReading>; probe: boolean };\n}\n\nconst DEFAULT_STATUS: readonly TaskStatus[] = [\"OPEN\", \"IN_PROGRESS\"];\nconst DEFAULT_LOG_LIMIT = 100;\n/** A tool quiet this long (no output; run time from an older extension) counts as stalled. */\nexport const STALLED_TOOL_MS = 15 * 60_000;\nconst FINISHED_CALL: readonly string[] = [\"done\", \"failed\", \"cancelled\"];\n/** Waves kept per workstream. */\nexport const WAVE_MAX = 5;\n\nconst callOf = (c: DelegateRow): DashboardCall => ({\n call_id: c.callId,\n state: c.state,\n verdict: c.verdict,\n judges: c.record ? `${c.record.workstream}/${c.record.task}` : null,\n wave: c.wave,\n});\n\n/** The `WAVE_MAX` most recently updated waves of `calls` (one workstream's), newest first. */\nfunction wavesOf(db: Db, workstream: string): DashboardWave[] {\n // The newest waves by name first (no request parse), then only their calls.\n const names = (\n db\n .prepare(\n `SELECT t.wave AS wave, MAX(d.updated_at) AS at FROM delegate_calls d\n JOIN tasks t ON t.id = d.task_id JOIN workstreams w ON w.id = t.workstream_id\n WHERE w.name = ? AND t.wave IS NOT NULL\n GROUP BY t.wave ORDER BY at DESC, t.wave LIMIT ?`,\n )\n .all(workstream, WAVE_MAX) as { wave: string }[]\n ).map((r) => r.wave);\n return names.map((wave): DashboardWave => {\n const rows = listDelegates(db, undefined, workstream, { wave });\n const t = tallyCalls(rows);\n const sum = (k: \"confirmed\" | \"refuted\" | \"unverified\" | \"pending\"): number =>\n t.findings.reduce((n, f) => n + f[k], 0);\n return {\n key: keyOf(workstream, wave),\n workstream,\n wave,\n calls: rows.length,\n confirmed: sum(\"confirmed\"),\n refuted: sum(\"refuted\"),\n unverified: sum(\"unverified\"),\n pending: sum(\"pending\"),\n refused: t.refused.length,\n updated_at: rows.reduce((m, r) => (r.updatedAt > m ? r.updatedAt : m), \"\"),\n };\n });\n}\n\n/** `MAX(ops.seq)` per task id of one workstream over its task, note and edge ops. */\nfunction taskActivity(db: Db, workstream: string): Map<string, number> {\n const prefix = `${workstream}/`;\n const rows = db\n .prepare(\n `SELECT entity, key, MAX(seq) AS seq FROM ops\n WHERE entity IN ('task', 'note', 'edge') AND key >= ? AND key < ?\n GROUP BY entity, key`,\n )\n .all(prefix, `${workstream}0`) as { entity: string; key: string; seq: number }[];\n const out = new Map<string, number>();\n const bump = (id: string | undefined, seq: number): void => {\n if (id !== undefined && seq > (out.get(id) ?? 0)) out.set(id, seq);\n };\n for (const r of rows) {\n if (r.entity === \"task\") bump(r.key.slice(prefix.length), r.seq);\n else if (r.entity === \"note\") bump(r.key.slice(prefix.length).split(\"#\")[0], r.seq);\n else {\n const parsed = parseOpKey(r.key);\n bump(parsed.local, r.seq);\n bump(parsed.to, r.seq);\n }\n }\n return out;\n}\n\nfunction nextOf(\n db: Db,\n callers: readonly string[],\n workstream: string | undefined,\n): { plan: NextPlan; source: DashboardSnapshot[\"next_source\"] } {\n try {\n const plan = computeNext(db, { callers, ...(workstream !== undefined ? { workstream } : {}) });\n return { plan, source: \"computed\" };\n } catch {\n return { plan: null, source: \"unavailable\" };\n }\n}\n\n/** The tool as the dashboard shows it, `elapsed_ms` calculated now; unknown stays absent. */\nfunction toolOf(tool: CtlTool | null | undefined, now: number): { tool?: AgentTool | null } {\n if (tool === undefined) return {};\n return { tool: tool === null ? null : { ...tool, elapsed_ms: Math.max(0, now - tool.since) } };\n}\n\nconst keyOf = (workstream: string, id: string): string => `${workstream}/${id}`;\n\ninterface AgentIdentity {\n name: string;\n workstream: string;\n}\n\nfunction dashboardTask(\n row: TaskRow,\n activity: ReadonlyMap<string, number>,\n agentsById: ReadonlyMap<number, AgentIdentity>,\n calls: ReadonlyMap<string, DelegateRow>,\n): DashboardTask {\n const call = row.kind === \"delegate\" ? calls.get(row.name) : undefined;\n const inProgress = row.status === \"IN_PROGRESS\";\n const owner = inProgress && row.ownerId !== null ? agentsById.get(row.ownerId) : undefined;\n return {\n key: keyOf(row.workstreamName, row.name),\n workstream: row.workstreamName,\n id: row.name,\n title: row.title,\n status: row.status,\n substate: row.substate,\n impact: row.impact,\n effort_days: row.effortDays,\n owner: inProgress ? row.ownerName : null,\n owner_id: inProgress ? row.ownerId : null,\n owner_workstream: owner?.workstream ?? null,\n kind: row.kind,\n wave: row.wave,\n created_at: row.createdAt,\n updated_at: row.updatedAt,\n activity_seq: activity.get(row.name) ?? 0,\n ...(call ? { call: callOf(call) } : {}),\n };\n}\n\n/** Newest activity first; no ops (capture suppressed) falls back to `updated_at`, then key. */\nfunction byActivityDesc(a: DashboardTask, b: DashboardTask): number {\n if (a.activity_seq !== b.activity_seq) return b.activity_seq - a.activity_seq;\n if (a.updated_at !== b.updated_at) return a.updated_at < b.updated_at ? 1 : -1;\n return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;\n}\n\n/** `45s`, `1m05s`, `1h05m`: the ONE duration format of the dashboard (strip and tool column). */\nexport function formatElapsed(ms: number): string {\n const s = Math.max(0, Math.floor(ms / 1000));\n if (s < 60) return `${s}s`;\n const m = Math.floor(s / 60);\n if (m < 60) return `${m}m${String(s % 60).padStart(2, \"0\")}s`;\n return `${Math.floor(m / 60)}h${String(m % 60).padStart(2, \"0\")}m`;\n}\n\n/** The pane (or a gate's process) is gone, as opposed to a state source that merely cannot say. */\nfunction isDead(a: DashboardAgent): boolean {\n if (a.state !== \"unknown\") return false;\n if (a.reason === UNKNOWN_REASON.paneGone) return true;\n return a.gate_token !== null && /^(exited \\d+|killed by signal)/.test(a.reason ?? \"\");\n}\n\nconst ATTENTION_ORDER: readonly AttentionKind[] = [\n \"dead\",\n \"permission\",\n \"stalled\",\n \"input\",\n \"delegate\",\n \"human\",\n \"next_unavailable\",\n \"sync\",\n];\n\nfunction agentAttention(a: DashboardAgent, now: number): DashboardAttention[] {\n const item = (kind: AttentionKind, text: string, fix?: string): DashboardAttention => ({\n key: `${kind}:${a.key}`,\n workstream: a.workstream,\n kind,\n text: `${a.name} ${text}`,\n target: a.key,\n ...(fix !== undefined ? { fix } : {}),\n });\n const since = a.since == null ? Number.NaN : Date.parse(a.since);\n const waited = Number.isFinite(since) ? ` ${formatElapsed(now - since)}` : \"\";\n const out: DashboardAttention[] = [];\n // `agent close` previews first; its `--if` is the human's second step.\n if (isDead(a))\n out.push(\n item(\"dead\", \"dead\", `mu agent close ${shellWord(a.name)} -w ${shellWord(a.workstream)}`),\n );\n if (a.state === \"needs_permission\") out.push(item(\"permission\", `permission${waited}`));\n if (a.idle === true) out.push(item(\"input\", `input${waited}`));\n const quiet = a.tool?.quiet_ms;\n const ran = quiet ?? a.tool?.elapsed_ms;\n if (a.tool != null && ran !== undefined && ran >= STALLED_TOOL_MS) {\n const how = quiet !== undefined ? \"quiet \" : \"\";\n out.push(item(\"stalled\", `${a.tool.name} ${how}${formatElapsed(ran)}`));\n }\n return out;\n}\n\nexport function matches(\n text: string | undefined,\n ...fields: (string | null | undefined)[]\n): boolean {\n if (text === undefined || text === \"\") return true;\n const needle = text.toLowerCase();\n return fields.some((f) => f?.toLowerCase().includes(needle) === true);\n}\n\n/**\n * Load the dashboard's whole read model in one pass. Read-only (see the file\n * header); async only for the ctl probes. Throws `WorkstreamNotFoundError` for\n * a `workstream` filter that is not a live workstream.\n */\nexport async function loadDashboard(db: Db, opts: DashboardOptions): Promise<DashboardSnapshot> {\n const live = (\n db\n .prepare(\"SELECT name, id FROM workstreams WHERE torn_down_at IS NULL ORDER BY name\")\n .all() as { name: string; id: number }[]\n ).map((w) => ({ ...w, scratch: isScratchWorkstream(w.name) }));\n if (opts.workstream !== undefined && tryResolveLiveWorkstreamId(db, opts.workstream) === null) {\n throw new WorkstreamNotFoundError(opts.workstream);\n }\n const scoped = live.filter((w) => opts.workstream === undefined || w.name === opts.workstream);\n // Whose tasks, edges and frontier are read (`scopeWorkstream`; `workstream` wins).\n const readFrom =\n opts.workstream !== undefined || opts.scopeWorkstream === undefined\n ? scoped\n : live.filter((w) => w.name === opts.scopeWorkstream);\n const statuses =\n opts.status === undefined || opts.status.length === 0 ? DEFAULT_STATUS : opts.status;\n\n const agentsById = new Map<number, AgentIdentity>(\n (\n db\n .prepare(\n \"SELECT a.id, a.name, w.name AS workstream FROM agents a JOIN workstreams w ON w.id = a.workstream_id\",\n )\n .all() as { id: number; name: string; workstream: string }[]\n ).map((a) => [a.id, { name: a.name, workstream: a.workstream }]),\n );\n // IN_PROGRESS tasks by owner registry id, over EVERY live workstream: a task can be\n // claimed by an agent of another workstream, and a filtered read must still show it.\n const owned = new Map<number, string[]>();\n for (const t of db\n .prepare(\n `SELECT ws.name AS ws, t.local_id AS id, t.owner_id AS owner FROM tasks t\n JOIN workstreams ws ON ws.id = t.workstream_id AND ws.torn_down_at IS NULL\n WHERE t.status = 'IN_PROGRESS' AND t.owner_id IS NOT NULL ORDER BY ws.name, t.local_id`,\n )\n .all() as { ws: string; id: string; owner: number }[]) {\n owned.set(t.owner, [...(owned.get(t.owner) ?? []), keyOf(t.ws, t.id)]);\n }\n\n const tasks: DashboardTask[] = [];\n const edges: DashboardEdge[] = [];\n const frontier: DashboardFrontierCut[] = [];\n const agents: DashboardAgent[] = [];\n const waves: DashboardWave[] = [];\n const now = Date.now();\n for (const ws of readFrom) {\n const activity = taskActivity(db, ws.name);\n const calls = listDelegates(db, undefined, ws.name, { taskStatuses: statuses });\n const callByTask = new Map(calls.map((c) => [c.task, c]));\n waves.push(...wavesOf(db, ws.name));\n tasks.push(\n ...listTasks(db, ws.name, { status: statuses })\n .map((r) => dashboardTask(r, activity, agentsById, callByTask))\n .filter((t) =>\n matches(\n opts.text,\n t.key,\n t.title,\n t.owner,\n t.substate,\n t.call?.state,\n t.call?.verdict,\n t.call?.judges,\n ),\n ),\n );\n const front = loadOpenTaskFrontier(db, ws.name);\n frontier.push({\n workstream: ws.name,\n roots_cut: front.rootsCut,\n again_cut: front.againCut,\n });\n for (const e of front.entries) {\n edges.push({\n key: keyOf(ws.name, e.task.name),\n workstream: ws.name,\n id: e.task.name,\n title: e.task.title,\n status: e.task.status,\n substate: e.task.substate,\n depth: e.depth,\n parent: e.parent === null ? null : keyOf(ws.name, e.parent),\n again: e.again,\n kids: e.kids,\n closed: e.closed,\n cap_cut: e.capCut,\n });\n }\n }\n tasks.sort(byActivityDesc);\n\n // Every live workstream's agents, whatever the scope or text: Attention reads them all.\n const everyAgent: DashboardAgent[] = [];\n for (const ws of live) {\n for (const a of await readLiveAgents(db, ws.name, undefined, opts.agentStates)) {\n const mine = owned.get(a.incarnation) ?? [];\n everyAgent.push({\n ...liveAgentToOutput(a, ws.id),\n key: keyOf(ws.name, a.name),\n tasks: mine,\n task: mine[0] ?? null,\n ...toolOf(a.tool, now),\n });\n }\n }\n const inScope = new Set(scoped.map((w) => w.name));\n agents.push(\n ...everyAgent.filter(\n (a) => inScope.has(a.workstream) && matches(opts.text, a.key, a.state ?? null, ...a.tasks),\n ),\n );\n\n const next = nextOf(\n db,\n opts.callers ?? (opts.caller === null ? [] : [opts.caller]),\n opts.workstream,\n );\n const logWs = opts.logWorkstream ?? opts.workstream;\n const log = listLogs(db, {\n ...(logWs !== undefined ? { workstream: logWs } : {}),\n limit: opts.logLimit ?? DEFAULT_LOG_LIMIT,\n }).map((row) => ({\n ...logItem(row, true).item,\n scope: parseOpKey(row.workstreamName).workstream ?? null,\n }));\n\n const callerOwn = opts.caller !== null;\n const human_needs = callerOwn\n ? openHumanNeeds(db, opts.caller as string)\n .filter((h) => inScope.has(h.workstream))\n .map((h) => ({\n key: keyOf(h.workstream, h.id),\n workstream: h.workstream,\n id: h.id,\n reason: h.reason,\n }))\n : [];\n const delegates = callerOwn\n ? listDelegates(db, opts.caller as string)\n .filter((c) => inScope.has(c.workstream) && !FINISHED_CALL.includes(c.state))\n .map((c) => ({\n call_id: c.callId,\n workstream: c.workstream,\n task: c.task,\n state: c.state,\n wave: c.wave,\n judges: c.record ? `${c.record.workstream}/${c.record.task}` : null,\n agent: c.agent,\n verdict: c.verdict,\n error: c.error,\n updated_at: c.updatedAt,\n }))\n : [];\n\n const attention: DashboardAttention[] = everyAgent.flatMap((a) => agentAttention(a, now));\n const liveNames = new Set(live.map((w) => w.name));\n // Workstream, then task id, like the human items (listDelegates orders by task row id).\n const refused = listDelegates(db, undefined, undefined, { states: [\"refused\"] }).sort((a, b) =>\n keyOf(a.workstream, a.task).localeCompare(keyOf(b.workstream, b.task)),\n );\n for (const c of refused) {\n if (!liveNames.has(c.workstream)) continue;\n // A refused call has no expiry, and its pi session may be gone: the fix cancels it\n // from a shell (it never ran, so the judged task is left alone).\n attention.push({\n key: `delegate:${keyOf(c.workstream, c.task)}`,\n workstream: c.workstream,\n kind: \"delegate\",\n text: `delegate refused: ${c.request.label ?? c.task} (reissue from pi, or y copies the cancel)`,\n target: keyOf(c.workstream, c.task),\n fix: `mu delegates finish ${shellWord(c.callId)} --outcome cancelled --no-record --author \"$USER\"`,\n });\n }\n for (const t of db\n .prepare(\n `SELECT ws.name AS ws, t.local_id AS id, t.title AS title FROM tasks t\n JOIN workstreams ws ON ws.id = t.workstream_id AND ws.torn_down_at IS NULL\n WHERE t.status = 'OPEN' AND t.kind = 'human' ORDER BY ws.name, t.local_id`,\n )\n .all() as { ws: string; id: string; title: string }[]) {\n attention.push({\n key: `human:${keyOf(t.ws, t.id)}`,\n workstream: t.ws,\n kind: \"human\",\n // The strip labels it `human: ` already; drop recordHumanNeeded's `human needed: ` title prefix.\n text: t.title.replace(/^human needed:\\s*/i, \"\"),\n target: keyOf(t.ws, t.id),\n fix: `mu task close ${shellWord(t.id)} -w ${shellWord(t.ws)} --evidence '<what you decided>'`,\n });\n }\n if (next.source === \"unavailable\") {\n attention.push({\n key: \"next_unavailable\",\n workstream: null,\n kind: \"next_unavailable\",\n text: \"next unavailable\",\n target: null,\n });\n }\n (opts.syncWarnings ?? []).forEach((w, i) => {\n attention.push({\n key: `sync:${i}`,\n workstream: null,\n kind: \"sync\",\n text: `sync: ${w}`,\n target: null,\n });\n });\n // Most urgent kind first; within a kind the order read holds (agents, delegate and\n // human items: workstream, then name).\n attention.sort((a, b) => ATTENTION_ORDER.indexOf(a.kind) - ATTENTION_ORDER.indexOf(b.kind));\n\n return {\n caller: opts.caller,\n caller_scope: callerOwn ? \"caller\" : \"none\",\n workstreams: live.map((w) => ({\n name: w.name,\n scratch: w.scratch,\n latest_seq: opts.activity === false ? 0 : latestSeq(db, w.name),\n })),\n tasks,\n edges,\n frontier,\n agents,\n log,\n next: next.plan,\n next_source: next.source,\n human_needs,\n delegates,\n waves,\n attention,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuSA,IAAM,iBAAwC,CAAC,QAAQ,aAAa;AACpE,IAAM,oBAAoB;AAEnB,IAAM,kBAAkB,KAAK;AACpC,IAAM,gBAAmC,CAAC,QAAQ,UAAU,WAAW;AAEhE,IAAM,WAAW;AAExB,IAAM,SAAS,CAAC,OAAmC;AAAA,EACjD,SAAS,EAAE;AAAA,EACX,OAAO,EAAE;AAAA,EACT,SAAS,EAAE;AAAA,EACX,QAAQ,EAAE,SAAS,GAAG,EAAE,OAAO,UAAU,IAAI,EAAE,OAAO,IAAI,KAAK;AAAA,EAC/D,MAAM,EAAE;AACV;AAGA,SAAS,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