@draht/coding-agent 2026.10.16 → 2026.10.19
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 +39 -0
- package/README.md +1 -0
- package/dist/bundle/chunks/{chunk-OWGSPJPZ.js → chunk-7TYCZN4Z.js} +4 -4
- package/dist/bundle/chunks/{chunk-TJ3AW62W.js → chunk-KEUN2Y6B.js} +1 -1
- package/dist/bundle/chunks/{chunk-JFDPOIUH.js → chunk-MO3SCGBN.js} +1 -1
- package/dist/bundle/chunks/{chunk-6APPDDHH.js → chunk-N2QZNJT6.js} +3 -3
- package/dist/bundle/chunks/{chunk-MIUVNYYW.js → chunk-VOODMGI3.js} +103 -91
- package/dist/bundle/chunks/{chunk-NHTOADU6.js → chunk-ZA4QNPJY.js} +1 -1
- package/dist/bundle/chunks/{cli-U7Y4VNNI.js → cli-PYJB6AQ3.js} +1 -1
- package/dist/bundle/chunks/{execute-ZWB4PIQQ.js → execute-6N7T7VLY.js} +1 -1
- package/dist/bundle/chunks/{runtime-PXJK4L7Y.js → runtime-D3KV73AE.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-BEJ4ZJ3D.js → virtual-modules-GSNL3MCU.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +4 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/builtins/duet.d.ts +7 -1
- package/dist/core/builtins/duet.d.ts.map +1 -1
- package/dist/core/builtins/duet.js +83 -14
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/builtins/polyphase.d.ts.map +1 -1
- package/dist/core/builtins/polyphase.js +21 -2
- package/dist/core/builtins/polyphase.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts +59 -2
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +258 -62
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +23 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +2 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +12 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts +18 -6
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +867 -59
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/polyphase/approval.d.ts +6 -2
- package/dist/core/polyphase/approval.d.ts.map +1 -1
- package/dist/core/polyphase/approval.js +23 -35
- package/dist/core/polyphase/approval.js.map +1 -1
- package/dist/core/polyphase/child-events.js +1 -1
- package/dist/core/polyphase/child-events.js.map +1 -1
- package/dist/core/polyphase/child-process.d.ts.map +1 -1
- package/dist/core/polyphase/child-process.js +65 -7
- package/dist/core/polyphase/child-process.js.map +1 -1
- package/dist/core/polyphase/commands.d.ts.map +1 -1
- package/dist/core/polyphase/commands.js +46 -5
- package/dist/core/polyphase/commands.js.map +1 -1
- package/dist/core/polyphase/details.d.ts.map +1 -1
- package/dist/core/polyphase/details.js +5 -0
- package/dist/core/polyphase/details.js.map +1 -1
- package/dist/core/polyphase/permission-bridge.d.ts +128 -0
- package/dist/core/polyphase/permission-bridge.d.ts.map +1 -0
- package/dist/core/polyphase/permission-bridge.js +357 -0
- package/dist/core/polyphase/permission-bridge.js.map +1 -0
- package/dist/core/polyphase/render/run-block.d.ts.map +1 -1
- package/dist/core/polyphase/render/run-block.js +13 -4
- package/dist/core/polyphase/render/run-block.js.map +1 -1
- package/dist/core/polyphase/render/snapshot.d.ts +4 -0
- package/dist/core/polyphase/render/snapshot.d.ts.map +1 -1
- package/dist/core/polyphase/render/snapshot.js +4 -0
- package/dist/core/polyphase/render/snapshot.js.map +1 -1
- package/dist/core/polyphase/result-text.d.ts.map +1 -1
- package/dist/core/polyphase/result-text.js +23 -3
- package/dist/core/polyphase/result-text.js.map +1 -1
- package/dist/core/polyphase/session.d.ts +15 -1
- package/dist/core/polyphase/session.d.ts.map +1 -1
- package/dist/core/polyphase/session.js +36 -1
- package/dist/core/polyphase/session.js.map +1 -1
- package/dist/core/polyphase/settings.d.ts +1 -0
- package/dist/core/polyphase/settings.d.ts.map +1 -1
- package/dist/core/polyphase/settings.js +1 -1
- package/dist/core/polyphase/settings.js.map +1 -1
- package/dist/core/polyphase/store.d.ts +18 -0
- package/dist/core/polyphase/store.d.ts.map +1 -1
- package/dist/core/polyphase/store.js +38 -0
- package/dist/core/polyphase/store.js.map +1 -1
- package/dist/core/polyphase/types.d.ts +60 -3
- package/dist/core/polyphase/types.d.ts.map +1 -1
- package/dist/core/polyphase/types.js.map +1 -1
- package/dist/core/polyphase/ui/inspector.js +1 -1
- package/dist/core/polyphase/ui/inspector.js.map +1 -1
- package/dist/core/polyphase/workflow/agent-host.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/agent-host.js +17 -3
- package/dist/core/polyphase/workflow/agent-host.js.map +1 -1
- package/dist/core/polyphase/workflow/guidance.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/guidance.js +16 -5
- package/dist/core/polyphase/workflow/guidance.js.map +1 -1
- package/dist/core/polyphase/workflow/launch.d.ts +2 -1
- package/dist/core/polyphase/workflow/launch.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/launch.js +22 -3
- package/dist/core/polyphase/workflow/launch.js.map +1 -1
- package/dist/core/polyphase/workflow/limits.d.ts +80 -0
- package/dist/core/polyphase/workflow/limits.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/limits.js +234 -0
- package/dist/core/polyphase/workflow/limits.js.map +1 -0
- package/dist/core/polyphase/workflow/runtime.d.ts +1 -1
- package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/runtime.js.map +1 -1
- package/dist/core/polyphase/workflow/tool.d.ts +1 -0
- package/dist/core/polyphase/workflow/tool.d.ts.map +1 -1
- package/dist/core/polyphase/workflow/tool.js +23 -2
- package/dist/core/polyphase/workflow/tool.js.map +1 -1
- package/dist/core/usage-totals.d.ts +5 -0
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +16 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +2 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +3 -0
- package/dist/utils/shell.js.map +1 -1
- package/docs/duet.md +1 -1
- package/docs/environment-variables.md +3 -1
- package/docs/extensions.md +2 -1
- package/docs/keybindings.md +1 -0
- package/docs/polyphase.md +97 -33
- package/docs/settings.md +2 -2
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/polyphase/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D,iGAAiG;AACjG,MAAM,CAAC,MAAM,qBAAqB,GAAG,uCAAuC,CAAC;AAE7E,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAErH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,eAAqC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5F,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,qBAAqB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACzE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;IACpE,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AA4JD,MAAM,CAAC,MAAM,0BAA0B,GAAqB;IAC3D,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,OAAO;IACjB,YAAY,EAAE,MAAM;IACpB,iBAAiB,EAAE,OAAO;IAC1B,cAAc,EAAE,MAAM;IACtB,gBAAgB,EAAE,MAAM;CACxB,CAAC","sourcesContent":["/**\n * Shared types and constants for polyphase: subagent/workflow orchestration, the child\n * event stream, and the persisted/live views consumed by rendering and the inspector.\n *\n * This module owns the vocabulary. Other polyphase modules import from here instead of\n * redeclaring these shapes.\n */\n\nimport type { ThinkingLevel } from \"@draht/agent-core\";\nimport type { JsonObject, JsonValue, StopReason, Usage } from \"@draht/ai\";\nimport type { MergeResult } from \"../multi-agent/index.ts\";\nimport type { ChildEventReducer } from \"./child-events.ts\";\n\n// ── Names and limits ───────────────────────────────────────────────────────\n\nexport const POLYPHASE_DEPTH_ENV = \"DRAHT_POLYPHASE_DEPTH\";\nexport const POLYPHASE_SCHEMA_FILE_ENV = \"DRAHT_POLYPHASE_SCHEMA_FILE\";\nexport const SUBAGENT_TOOL_NAME = \"subagent\";\nexport const WORKFLOW_TOOL_NAME = \"workflow\";\nexport const DUET_DELEGATE_TOOL_NAME = \"duet_delegate\";\nexport const POLYPHASE_RESULT_TOOL_NAME = \"polyphase_result\";\n\n/** Suffix of the permission gate's block reason when no UI can answer (builtins/subagent.ts). */\nexport const NO_UI_APPROVAL_SUFFIX = \"(no UI available to request approval)\";\n\nexport const FINAL_DETAILS_MAX_BYTES = 16_384;\nexport const PARTIAL_DETAILS_MAX_BYTES = 8_192;\n\nexport const THINKING_LEVELS: readonly ThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function isThinkingLevel(value: unknown): value is ThinkingLevel {\n\treturn typeof value === \"string\" && (THINKING_LEVELS as readonly string[]).includes(value);\n}\n\n/** Nesting depth of this process: 0 for the user's session, n for a child spawned at depth n-1. */\nexport function currentPolyphaseDepth(env: NodeJS.ProcessEnv = process.env): number {\n\tconst parsed = Number.parseInt(env[POLYPHASE_DEPTH_ENV] ?? \"0\", 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : 0;\n}\n\n// ── Agent definitions and the runner seam (moved from builtins/subagent.ts) ──\n\nexport interface AgentConfig {\n\tname: string;\n\tdescription: string;\n\ttools?: string[];\n\tmodel?: string;\n\t/** Disable user and project extensions in the child process. Core builtins still load. */\n\tdisableExtensions?: boolean;\n\tsystemPrompt: string;\n\tsource: \"user\" | \"project\";\n}\n\nexport interface ModelRef {\n\tprovider: string;\n\tid: string;\n}\n\nexport interface RunResult {\n\tagent: string;\n\ttask: string;\n\texitCode: number;\n\toutput: string;\n\tstderr: string;\n\tusage?: Usage;\n\tstep?: number;\n\tmerge?: MergeResult;\n\t/** Confirmed from the child's first assistant message_start. */\n\tmodel?: ModelRef;\n\t/** Confirmed from the child's assistant message_end. */\n\tthinkingLevel?: ThinkingLevel;\n\tstopReason?: StopReason;\n\tturns?: number;\n\ttoolCalls?: number;\n\tblockedToolCalls?: number;\n\t/** Validated polyphase_result arguments when a schema was requested. */\n\tstructured?: { value: JsonValue };\n\tcancelled?: boolean;\n\tdurationMs?: number;\n}\n\nexport type ProgressFn = (activity: string) => void;\nexport type ChildStateChange = \"none\" | \"fine\" | \"coarse\";\n\n/** Per-run options threaded from orchestrators to the process runner. All optional. */\nexport interface AgentRunContext {\n\t/** `--model` value. Overrides agent.model when set. */\n\tmodel?: string;\n\t/** `--thinking` value. */\n\tthinking?: ThinkingLevel;\n\t/** Model display info used when the runner creates its own reducer. */\n\tmodelInfo?: AgentModelInfo;\n\t/** Retry once without --model/--thinking when the child cannot resolve the inherited model (§7.3). */\n\tfallbackToChildDefaultModel?: boolean;\n\t/** Added to the runner's fixed exclusions (workflow, duet_delegate). */\n\texcludeTools?: readonly string[];\n\t/** Appended to `--tools` only when the agent has a tools allowlist. */\n\textraTools?: readonly string[];\n\t/** Appended to the agent system prompt in the same temp file. */\n\textraSystemPrompt?: string;\n\t/** Extra environment for the child. */\n\tenv?: Readonly<Record<string, string>>;\n\t/** Object JSON Schema for polyphase_result. The runner writes it to a 0600 temp file. */\n\tschema?: JsonObject;\n\t/** Live state sink. When absent the runner uses a private reducer. */\n\treducer?: ChildEventReducer;\n\tonQueued?: () => void;\n\tonStart?: (info: { pid: number | undefined; argv: readonly string[] }) => void;\n\tonChange?: (change: \"fine\" | \"coarse\") => void;\n\t/** Called once by runAgentWithLifecycle with the final result (after merge-back). */\n\tonFinish?: (result: RunResult) => void;\n}\n\nexport type AgentRunner = (\n\tcwd: string,\n\tagent: AgentConfig,\n\ttask: string,\n\tsignal?: AbortSignal,\n\tstep?: number,\n\tonProgress?: ProgressFn,\n\trun?: AgentRunContext,\n) => Promise<RunResult>;\n\n// ── Child state ─────────────────────────────────────────────────────────────\n\nexport type AgentStatus =\n\t| \"pending\" // created, not yet asked to run (later chain step)\n\t| \"queued\" // waiting for a limiter slot\n\t| \"starting\" // process spawned, no agent_start yet\n\t| \"running\"\n\t| \"done\"\n\t| \"failed\"\n\t| \"cancelled\"\n\t| \"skipped\"; // never started because its run ended (e.g. chain stopped)\nexport type AgentActivity = \"idle\" | \"waiting\" | \"thinking\" | \"writing\" | \"tool\" | \"retrying\" | \"compacting\";\nexport type ModelSource = \"override\" | \"phase\" | \"frontmatter\" | \"inherited\" | \"child-default\";\nexport type CancelReason = \"user\" | \"budget\" | \"run\" | \"parent\" | \"shutdown\";\n\nexport interface AgentModelInfo {\n\tsource: ModelSource;\n\t/** Value passed with --model (or the frontmatter pattern). */\n\trequested?: string;\n\trequestedThinking?: ThinkingLevel;\n\t/** Pre-resolved in the parent, then confirmed by the child's assistant message_start. */\n\tprovider?: string;\n\tid?: string;\n\t/** Confirmed at message_end, or by thinking_level_changed. */\n\tthinkingLevel?: ThinkingLevel;\n\tconfirmed: boolean;\n}\n\nexport type ToolItemStatus = \"pending\" | \"running\" | \"ok\" | \"error\" | \"blocked\";\n\n/** `rev` increments on every mutation of the item (cache key for wrapped lines). */\nexport type TranscriptItem =\n\t| {\n\t\t\tkind: \"thinking\";\n\t\t\tseq: number;\n\t\t\trev: number;\n\t\t\ttext: string;\n\t\t\tdroppedChars: number;\n\t\t\tdone: boolean;\n\t\t\tredacted: boolean;\n\t }\n\t| { kind: \"text\"; seq: number; rev: number; text: string; droppedChars: number; done: boolean }\n\t| {\n\t\t\tkind: \"tool\";\n\t\t\tseq: number;\n\t\t\trev: number;\n\t\t\ttoolCallId: string;\n\t\t\tname: string;\n\t\t\tsummary: string;\n\t\t\tstatus: ToolItemStatus;\n\t\t\tstartedAt?: number;\n\t\t\tendedAt?: number;\n\t\t\tresultPreview?: string;\n\t\t\tblockedReason?: string;\n\t }\n\t| { kind: \"notice\"; seq: number; rev: number; level: \"info\" | \"warning\" | \"error\"; text: string; at: number };\n\nexport interface BlockedToolCall {\n\ttoolName: string;\n\tsummary: string;\n\treason: string;\n}\n\nexport interface ChildStateLimits {\n\tmaxItems: number; // 400\n\tmaxChars: number; // 256_000 transcript chars while running\n\tmaxItemChars: number; // 32_000 per thinking/text item (tail kept)\n\tmaxFinalTextChars: number; // 200_000\n\tmaxStderrChars: number; // 16_384 (tail kept)\n\tfinishedMaxChars: number; // 32_000 after the run finished\n}\nexport const DEFAULT_CHILD_STATE_LIMITS: ChildStateLimits = {\n\tmaxItems: 400,\n\tmaxChars: 256_000,\n\tmaxItemChars: 32_000,\n\tmaxFinalTextChars: 200_000,\n\tmaxStderrChars: 16_384,\n\tfinishedMaxChars: 32_000,\n};\n\nexport interface ChildAgentState {\n\tlifecycle: \"pending\" | \"queued\" | \"spawning\" | \"running\" | \"settled\" | \"exited\";\n\tactivity: AgentActivity;\n\tsessionId?: string;\n\tmodel: AgentModelInfo;\n\tturns: number;\n\ttoolCalls: number;\n\ttoolErrors: number;\n\ttoolCounts: Record<string, number>;\n\t/** Newest last, at most 20 kept. */\n\tblocked: BlockedToolCall[];\n\tblockedCount: number;\n\tcurrentTool?: { toolCallId: string; name: string; summary: string; startedAt: number };\n\t/** Sum of finished assistant message usage (combineUsage). */\n\tusage?: Usage;\n\t/** Cumulative usage of the in-flight assistant message. */\n\tliveUsage?: Usage;\n\ttranscript: TranscriptItem[];\n\ttranscriptChars: number;\n\tdroppedItems: number;\n\tnextSeq: number;\n\t/** One line, ≤ 160 chars: what the agent is doing right now. */\n\tnowLine: string;\n\t/** First text part of the last assistant message that had text, capped. */\n\tfinalText: string;\n\tstopReason?: StopReason;\n\terrorMessage?: string;\n\t/** Arguments of the last successful polyphase_result call (validated later by the runner). */\n\tstructured?: { value: JsonValue };\n\tretry?: { attempt: number; maxAttempts: number; delayMs: number; errorMessage: string };\n\tstderrTail: string;\n\tmalformedLines: number;\n\tdroppedLines: number;\n\trecordsSeen: number;\n\tqueuedAt?: number;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tlastEventAt?: number;\n\t/** ++ on every fine or coarse change. */\n\tversion: number;\n\t/** ++ on every coarse change. */\n\tcoarseVersion: number;\n}\n\n// ── Runs: read-only views implemented by store.ts, consumed by details/text/render/inspector ──\n\nexport type RunKind = \"subagent\" | \"workflow\" | \"duet\";\nexport type RunOrigin = \"tool\" | \"command\";\nexport type SubagentMode = \"single\" | \"parallel\" | \"chain\";\nexport type RunStatus = \"running\" | \"done\" | \"failed\" | \"cancelled\";\nexport type WorkflowSource = \"inline\" | \"project\" | \"user\";\n\nexport interface PhaseInfo {\n\ttitle: string;\n\tdetail?: string;\n\tmodel?: string;\n\t/** True for phases created by phase()/agent({phase}) that meta did not declare. */\n\tdynamic: boolean;\n}\n\nexport interface WorkflowRunInfo {\n\tname: string;\n\tdescription: string;\n\tsource: WorkflowSource;\n\tpath?: string;\n\targs: string;\n}\n\nexport interface LogLine {\n\tat: number;\n\tlevel: \"info\" | \"warning\";\n\ttext: string;\n\tphase?: number;\n}\n\nexport interface AgentView {\n\t/** `${runId}#${index}` */\n\treadonly key: string;\n\treadonly index: number;\n\treadonly label: string;\n\treadonly agentType: string;\n\treadonly task: string;\n\treadonly phase?: number;\n\t/** 1-based chain step. */\n\treadonly step?: number;\n\treadonly status: AgentStatus;\n\treadonly cancelReason?: CancelReason;\n\treadonly state: Readonly<ChildAgentState>;\n\treadonly result?: Readonly<RunResult>;\n\treadonly createdAt: number;\n}\n\nexport interface RunView {\n\treadonly id: string;\n\treadonly kind: RunKind;\n\treadonly origin: RunOrigin;\n\treadonly mode?: SubagentMode;\n\treadonly title: string;\n\treadonly workflow?: Readonly<WorkflowRunInfo>;\n\treadonly phases: readonly PhaseInfo[];\n\treadonly currentPhase?: number;\n\treadonly status: RunStatus;\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly agents: readonly AgentView[];\n\treadonly log: readonly LogLine[];\n\treadonly logDropped: number;\n\treadonly budget: Readonly<{ totalTokens: number | null; spentTokens: number; exhausted: boolean }>;\n\treadonly resultPreview?: string;\n\treadonly error?: string;\n\treadonly version: number;\n\treadonly coarseVersion: number;\n}\n\n// ── Persisted, bounded, JSON-compatible tool-result details (D2) ────────────\n\nexport interface PolyphaseDetails {\n\tv: 1;\n\trunId: string;\n\tkind: RunKind;\n\torigin: RunOrigin;\n\tmode?: SubagentMode;\n\ttitle: string;\n\t/** \"running\" in partial details. */\n\tstatus: RunStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tworkflow?: { name: string; description: string; source: WorkflowSource; path?: string; args?: string };\n\tphases?: PhaseDetails[];\n\tcurrentPhase?: number;\n\tagents: AgentDetails[];\n\tagentsOmitted?: { count: number; byStatus: Partial<Record<AgentStatus, number>> };\n\tlog?: string[];\n\tlogOmitted?: number;\n\ttotals: {\n\t\tagents: number;\n\t\t/** Billable tokens: input + output + cacheWrite. */\n\t\ttokens: number;\n\t\t/** USD. */\n\t\tcost: number;\n\t\tbyStatus: Partial<Record<AgentStatus, number>>;\n\t\tblockedToolCalls: number;\n\t};\n\tbudget?: { totalTokens: number; spentTokens: number; exhausted: boolean };\n\tresultPreview?: string;\n\terror?: string;\n\t/** Degradation level applied to fit the byte cap (§9.2). */\n\tdegraded?: 0 | 1 | 2 | 3 | 4;\n}\n\nexport interface PhaseDetails {\n\ttitle: string;\n\tdetail?: string;\n\tmodel?: string;\n\tdynamic?: boolean;\n}\n\nexport interface AgentDetails {\n\ti: number;\n\tlabel: string;\n\tagent: string;\n\tphase?: number;\n\tstep?: number;\n\tstatus: AgentStatus;\n\tcancelReason?: CancelReason;\n\t/** \"provider/id\" when known, else the requested pattern. */\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n\tmodelSource?: ModelSource;\n\tmodelConfirmed?: boolean;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tturns?: number;\n\ttoolCalls?: number;\n\ttools?: Record<string, number>;\n\ttokens?: number;\n\tcost?: number;\n\tblocked?: number;\n\t/** e.g. \"bash: npm test -- auth\". */\n\tblockedSample?: string;\n\ttask: string;\n\t/** Partial details only. */\n\tnow?: string;\n\t/** Last `STATUS: ...` line of the output. */\n\tstatusLine?: string;\n\t/** Head+tail preview of the final output. */\n\toutput?: string;\n\terror?: string;\n\tmerge?: \"ok\" | \"failed\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/polyphase/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAE7D,iGAAiG;AACjG,MAAM,CAAC,MAAM,qBAAqB,GAAG,uCAAuC,CAAC;AAqC7E,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAErH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,eAAqC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5F,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,qBAAqB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACzE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;IACpE,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAqKD,MAAM,CAAC,MAAM,0BAA0B,GAAqB;IAC3D,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,OAAO;IACjB,YAAY,EAAE,MAAM;IACpB,iBAAiB,EAAE,OAAO;IAC1B,cAAc,EAAE,MAAM;IACtB,gBAAgB,EAAE,MAAM;CACxB,CAAC","sourcesContent":["/**\n * Shared types and constants for polyphase: subagent/workflow orchestration, the child\n * event stream, and the persisted/live views consumed by rendering and the inspector.\n *\n * This module owns the vocabulary. Other polyphase modules import from here instead of\n * redeclaring these shapes.\n */\n\nimport type { ThinkingLevel } from \"@draht/agent-core\";\nimport type { JsonObject, JsonValue, StopReason, Usage } from \"@draht/ai\";\nimport type { MergeResult } from \"../multi-agent/index.ts\";\nimport type { ChildEventReducer } from \"./child-events.ts\";\n\n// ── Names and limits ───────────────────────────────────────────────────────\n\nexport const POLYPHASE_DEPTH_ENV = \"DRAHT_POLYPHASE_DEPTH\";\nexport const POLYPHASE_SCHEMA_FILE_ENV = \"DRAHT_POLYPHASE_SCHEMA_FILE\";\nexport const SUBAGENT_TOOL_NAME = \"subagent\";\nexport const WORKFLOW_TOOL_NAME = \"workflow\";\nexport const DUET_DELEGATE_TOOL_NAME = \"duet_delegate\";\nexport const POLYPHASE_RESULT_TOOL_NAME = \"polyphase_result\";\n\n/** Suffix of the permission gate's block reason when no UI can answer (builtins/subagent.ts). */\nexport const NO_UI_APPROVAL_SUFFIX = \"(no UI available to request approval)\";\n\n// ── Permission asks a child forwards to its parent (permission-bridge.ts) ──────\n\n/** One argument of a tool call as it crosses to the parent: scalars only. */\nexport type ChildPermissionValue = string | number | boolean | null;\n\n/** A tool call's arguments as the parent receives them: the gate's own keys (`command`, `path`,\n * `file_path`) verbatim, everything else reduced to a bounded scalar that only feeds the dialog. */\nexport type ChildPermissionInput = Record<string, ChildPermissionValue>;\n\n/** A permission ask a child's own gate could not answer, as its parent receives it. */\nexport interface ChildPermissionRequest {\n\ttoolName: string;\n\ttoolCallId: string;\n\tinput: ChildPermissionInput;\n\t/** Labels of the agents the ask came up through below the parent's direct child, outermost\n\t * first. Empty when the direct child raised it. */\n\tvia: readonly string[];\n\t/** Where the child was spawned. Supplied by the parent's own runner, never by the child. */\n\tcwd: string;\n}\n\nexport type ChildPermissionVerdict =\n\t| { kind: \"approved\" }\n\t| { kind: \"denied\"; reason: string }\n\t/** Nobody could be asked: the child blocks the call exactly as it did before asks were forwarded. */\n\t| { kind: \"unavailable\" }\n\t/** The ask ended unanswered: the child's turn was aborted, or the child went away. */\n\t| { kind: \"cancelled\" };\n\n/** Decides a child's permission ask in the parent. Must settle once `signal` aborts. */\nexport type ChildPermissionAsker = (\n\trequest: ChildPermissionRequest,\n\tsignal: AbortSignal,\n) => Promise<ChildPermissionVerdict>;\n\nexport const FINAL_DETAILS_MAX_BYTES = 16_384;\nexport const PARTIAL_DETAILS_MAX_BYTES = 8_192;\n\nexport const THINKING_LEVELS: readonly ThinkingLevel[] = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"];\n\nexport function isThinkingLevel(value: unknown): value is ThinkingLevel {\n\treturn typeof value === \"string\" && (THINKING_LEVELS as readonly string[]).includes(value);\n}\n\n/** Nesting depth of this process: 0 for the user's session, n for a child spawned at depth n-1. */\nexport function currentPolyphaseDepth(env: NodeJS.ProcessEnv = process.env): number {\n\tconst parsed = Number.parseInt(env[POLYPHASE_DEPTH_ENV] ?? \"0\", 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : 0;\n}\n\n// ── Agent definitions and the runner seam (moved from builtins/subagent.ts) ──\n\nexport interface AgentConfig {\n\tname: string;\n\tdescription: string;\n\ttools?: string[];\n\tmodel?: string;\n\t/** Disable user and project extensions in the child process. Core builtins still load. */\n\tdisableExtensions?: boolean;\n\tsystemPrompt: string;\n\tsource: \"user\" | \"project\";\n}\n\nexport interface ModelRef {\n\tprovider: string;\n\tid: string;\n}\n\nexport interface RunResult {\n\tagent: string;\n\ttask: string;\n\texitCode: number;\n\toutput: string;\n\tstderr: string;\n\tusage?: Usage;\n\tstep?: number;\n\tmerge?: MergeResult;\n\t/** Confirmed from the child's first assistant message_start. */\n\tmodel?: ModelRef;\n\t/** Confirmed from the child's assistant message_end. */\n\tthinkingLevel?: ThinkingLevel;\n\tstopReason?: StopReason;\n\tturns?: number;\n\ttoolCalls?: number;\n\tblockedToolCalls?: number;\n\t/** Validated polyphase_result arguments when a schema was requested. */\n\tstructured?: { value: JsonValue };\n\tcancelled?: boolean;\n\tdurationMs?: number;\n}\n\nexport type ProgressFn = (activity: string) => void;\nexport type ChildStateChange = \"none\" | \"fine\" | \"coarse\";\n\n/** Per-run options threaded from orchestrators to the process runner. All optional. */\nexport interface AgentRunContext {\n\t/** `--model` value. Overrides agent.model when set. */\n\tmodel?: string;\n\t/** `--thinking` value. */\n\tthinking?: ThinkingLevel;\n\t/** Model display info used when the runner creates its own reducer. */\n\tmodelInfo?: AgentModelInfo;\n\t/** Retry once without --model/--thinking when the child cannot resolve the inherited model (§7.3). */\n\tfallbackToChildDefaultModel?: boolean;\n\t/** Added to the runner's fixed exclusions (workflow, duet_delegate). */\n\texcludeTools?: readonly string[];\n\t/** Appended to `--tools` only when the agent has a tools allowlist. */\n\textraTools?: readonly string[];\n\t/** Appended to the agent system prompt in the same temp file. */\n\textraSystemPrompt?: string;\n\t/** Extra environment for the child. A thunk is resolved once, at actual spawn time\n\t * (`child-process.ts`'s `buildChildInvocation`), not when the caller builds this context. */\n\tenv?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);\n\t/** Answers the permission asks the child's own gate cannot (it has no UI). When set, the child\n\t * is spawned with an IPC channel and `DRAHT_POLYPHASE_PERMISSION_BRIDGE=1`; when absent, the\n\t * child blocks such calls as before. */\n\tonPermissionAsk?: ChildPermissionAsker;\n\t/** Object JSON Schema for polyphase_result. The runner writes it to a 0600 temp file. */\n\tschema?: JsonObject;\n\t/** Live state sink. When absent the runner uses a private reducer. */\n\treducer?: ChildEventReducer;\n\tonQueued?: () => void;\n\tonStart?: (info: { pid: number | undefined; argv: readonly string[] }) => void;\n\tonChange?: (change: \"fine\" | \"coarse\") => void;\n\t/** Called once by runAgentWithLifecycle with the final result (after merge-back). */\n\tonFinish?: (result: RunResult) => void;\n}\n\nexport type AgentRunner = (\n\tcwd: string,\n\tagent: AgentConfig,\n\ttask: string,\n\tsignal?: AbortSignal,\n\tstep?: number,\n\tonProgress?: ProgressFn,\n\trun?: AgentRunContext,\n) => Promise<RunResult>;\n\n// ── Child state ─────────────────────────────────────────────────────────────\n\nexport type AgentStatus =\n\t| \"pending\" // created, not yet asked to run (later chain step)\n\t| \"queued\" // waiting for a limiter slot\n\t| \"starting\" // process spawned, no agent_start yet\n\t| \"running\"\n\t| \"done\"\n\t| \"failed\"\n\t| \"cancelled\"\n\t| \"skipped\"; // never started because its run ended (e.g. chain stopped)\nexport type AgentActivity = \"idle\" | \"waiting\" | \"thinking\" | \"writing\" | \"tool\" | \"retrying\" | \"compacting\";\nexport type ModelSource = \"override\" | \"phase\" | \"frontmatter\" | \"inherited\" | \"child-default\";\nexport type CancelReason = \"user\" | \"budget\" | \"time\" | \"run\" | \"parent\" | \"shutdown\";\n\n/** Where a resolved workflow limit (token budget or time limit) came from: the user's own prompt,\n * a tool/command parameter the model or user set, config, or nowhere (\"none\"). */\nexport type LimitSource = \"prompt\" | \"tool\" | \"config\" | \"none\";\n\nexport interface AgentModelInfo {\n\tsource: ModelSource;\n\t/** Value passed with --model (or the frontmatter pattern). */\n\trequested?: string;\n\trequestedThinking?: ThinkingLevel;\n\t/** Pre-resolved in the parent, then confirmed by the child's assistant message_start. */\n\tprovider?: string;\n\tid?: string;\n\t/** Confirmed at message_end, or by thinking_level_changed. */\n\tthinkingLevel?: ThinkingLevel;\n\tconfirmed: boolean;\n}\n\nexport type ToolItemStatus = \"pending\" | \"running\" | \"ok\" | \"error\" | \"blocked\";\n\n/** `rev` increments on every mutation of the item (cache key for wrapped lines). */\nexport type TranscriptItem =\n\t| {\n\t\t\tkind: \"thinking\";\n\t\t\tseq: number;\n\t\t\trev: number;\n\t\t\ttext: string;\n\t\t\tdroppedChars: number;\n\t\t\tdone: boolean;\n\t\t\tredacted: boolean;\n\t }\n\t| { kind: \"text\"; seq: number; rev: number; text: string; droppedChars: number; done: boolean }\n\t| {\n\t\t\tkind: \"tool\";\n\t\t\tseq: number;\n\t\t\trev: number;\n\t\t\ttoolCallId: string;\n\t\t\tname: string;\n\t\t\tsummary: string;\n\t\t\tstatus: ToolItemStatus;\n\t\t\tstartedAt?: number;\n\t\t\tendedAt?: number;\n\t\t\tresultPreview?: string;\n\t\t\tblockedReason?: string;\n\t }\n\t| { kind: \"notice\"; seq: number; rev: number; level: \"info\" | \"warning\" | \"error\"; text: string; at: number };\n\nexport interface BlockedToolCall {\n\ttoolName: string;\n\tsummary: string;\n\treason: string;\n}\n\nexport interface ChildStateLimits {\n\tmaxItems: number; // 400\n\tmaxChars: number; // 256_000 transcript chars while running\n\tmaxItemChars: number; // 32_000 per thinking/text item (tail kept)\n\tmaxFinalTextChars: number; // 200_000\n\tmaxStderrChars: number; // 16_384 (tail kept)\n\tfinishedMaxChars: number; // 32_000 after the run finished\n}\nexport const DEFAULT_CHILD_STATE_LIMITS: ChildStateLimits = {\n\tmaxItems: 400,\n\tmaxChars: 256_000,\n\tmaxItemChars: 32_000,\n\tmaxFinalTextChars: 200_000,\n\tmaxStderrChars: 16_384,\n\tfinishedMaxChars: 32_000,\n};\n\nexport interface ChildAgentState {\n\tlifecycle: \"pending\" | \"queued\" | \"spawning\" | \"running\" | \"settled\" | \"exited\";\n\tactivity: AgentActivity;\n\tsessionId?: string;\n\tmodel: AgentModelInfo;\n\tturns: number;\n\ttoolCalls: number;\n\ttoolErrors: number;\n\ttoolCounts: Record<string, number>;\n\t/** Newest last, at most 20 kept. */\n\tblocked: BlockedToolCall[];\n\tblockedCount: number;\n\tcurrentTool?: { toolCallId: string; name: string; summary: string; startedAt: number };\n\t/** Sum of finished assistant message usage (combineUsage). */\n\tusage?: Usage;\n\t/** Cumulative usage of the in-flight assistant message. */\n\tliveUsage?: Usage;\n\ttranscript: TranscriptItem[];\n\ttranscriptChars: number;\n\tdroppedItems: number;\n\tnextSeq: number;\n\t/** One line, ≤ 160 chars: what the agent is doing right now. */\n\tnowLine: string;\n\t/** First text part of the last assistant message that had text, capped. */\n\tfinalText: string;\n\tstopReason?: StopReason;\n\terrorMessage?: string;\n\t/** Arguments of the last successful polyphase_result call (validated later by the runner). */\n\tstructured?: { value: JsonValue };\n\tretry?: { attempt: number; maxAttempts: number; delayMs: number; errorMessage: string };\n\tstderrTail: string;\n\tmalformedLines: number;\n\tdroppedLines: number;\n\trecordsSeen: number;\n\tqueuedAt?: number;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tlastEventAt?: number;\n\t/** ++ on every fine or coarse change. */\n\tversion: number;\n\t/** ++ on every coarse change. */\n\tcoarseVersion: number;\n}\n\n// ── Runs: read-only views implemented by store.ts, consumed by details/text/render/inspector ──\n\nexport type RunKind = \"subagent\" | \"workflow\" | \"duet\";\nexport type RunOrigin = \"tool\" | \"command\";\nexport type SubagentMode = \"single\" | \"parallel\" | \"chain\";\nexport type RunStatus = \"running\" | \"done\" | \"failed\" | \"cancelled\";\nexport type WorkflowSource = \"inline\" | \"project\" | \"user\";\n\nexport interface PhaseInfo {\n\ttitle: string;\n\tdetail?: string;\n\tmodel?: string;\n\t/** True for phases created by phase()/agent({phase}) that meta did not declare. */\n\tdynamic: boolean;\n}\n\nexport interface WorkflowRunInfo {\n\tname: string;\n\tdescription: string;\n\tsource: WorkflowSource;\n\tpath?: string;\n\targs: string;\n\t/** Where the run's token budget and time limit came from (D-B precedence: prompt > tool >\n\t * config > none). Absent (treated as \"none\") only for a `RunView`/`PolyphaseDetails` built\n\t * before this field existed. */\n\tbudgetSource?: LimitSource;\n\ttimeLimitSource?: LimitSource;\n}\n\nexport interface LogLine {\n\tat: number;\n\tlevel: \"info\" | \"warning\";\n\ttext: string;\n\tphase?: number;\n}\n\nexport interface AgentView {\n\t/** `${runId}#${index}` */\n\treadonly key: string;\n\treadonly index: number;\n\treadonly label: string;\n\treadonly agentType: string;\n\treadonly task: string;\n\treadonly phase?: number;\n\t/** 1-based chain step. */\n\treadonly step?: number;\n\treadonly status: AgentStatus;\n\treadonly cancelReason?: CancelReason;\n\treadonly state: Readonly<ChildAgentState>;\n\treadonly result?: Readonly<RunResult>;\n\treadonly createdAt: number;\n}\n\nexport interface RunView {\n\treadonly id: string;\n\treadonly kind: RunKind;\n\treadonly origin: RunOrigin;\n\treadonly mode?: SubagentMode;\n\treadonly title: string;\n\treadonly workflow?: Readonly<WorkflowRunInfo>;\n\treadonly phases: readonly PhaseInfo[];\n\treadonly currentPhase?: number;\n\treadonly status: RunStatus;\n\treadonly startedAt: number;\n\treadonly endedAt?: number;\n\treadonly agents: readonly AgentView[];\n\treadonly log: readonly LogLine[];\n\treadonly logDropped: number;\n\treadonly budget: Readonly<{ totalTokens: number | null; spentTokens: number; exhausted: boolean }>;\n\t/** Absent (treated as \"no time limit, not reached\") for a fixture/snapshot built before this\n\t * field existed. */\n\treadonly timeLimit?: Readonly<{ totalMs: number | null; reached: boolean }>;\n\treadonly resultPreview?: string;\n\treadonly error?: string;\n\treadonly version: number;\n\treadonly coarseVersion: number;\n}\n\n// ── Persisted, bounded, JSON-compatible tool-result details (D2) ────────────\n\nexport interface PolyphaseDetails {\n\tv: 1;\n\trunId: string;\n\tkind: RunKind;\n\torigin: RunOrigin;\n\tmode?: SubagentMode;\n\ttitle: string;\n\t/** \"running\" in partial details. */\n\tstatus: RunStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tworkflow?: {\n\t\tname: string;\n\t\tdescription: string;\n\t\tsource: WorkflowSource;\n\t\tpath?: string;\n\t\targs?: string;\n\t\tbudgetSource?: LimitSource;\n\t\ttimeLimitSource?: LimitSource;\n\t};\n\tphases?: PhaseDetails[];\n\tcurrentPhase?: number;\n\tagents: AgentDetails[];\n\tagentsOmitted?: { count: number; byStatus: Partial<Record<AgentStatus, number>> };\n\tlog?: string[];\n\tlogOmitted?: number;\n\ttotals: {\n\t\tagents: number;\n\t\t/** Billable tokens: input + output + cacheWrite. */\n\t\ttokens: number;\n\t\t/** USD. */\n\t\tcost: number;\n\t\tbyStatus: Partial<Record<AgentStatus, number>>;\n\t\tblockedToolCalls: number;\n\t};\n\tbudget?: { totalTokens: number; spentTokens: number; exhausted: boolean };\n\ttimeLimit?: { totalMs: number; reached: boolean };\n\tresultPreview?: string;\n\terror?: string;\n\t/** Degradation level applied to fit the byte cap (§9.2). */\n\tdegraded?: 0 | 1 | 2 | 3 | 4;\n}\n\nexport interface PhaseDetails {\n\ttitle: string;\n\tdetail?: string;\n\tmodel?: string;\n\tdynamic?: boolean;\n}\n\nexport interface AgentDetails {\n\ti: number;\n\tlabel: string;\n\tagent: string;\n\tphase?: number;\n\tstep?: number;\n\tstatus: AgentStatus;\n\tcancelReason?: CancelReason;\n\t/** \"provider/id\" when known, else the requested pattern. */\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n\tmodelSource?: ModelSource;\n\tmodelConfirmed?: boolean;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tturns?: number;\n\ttoolCalls?: number;\n\ttools?: Record<string, number>;\n\ttokens?: number;\n\tcost?: number;\n\tblocked?: number;\n\t/** e.g. \"bash: npm test -- auth\". */\n\tblockedSample?: string;\n\ttask: string;\n\t/** Partial details only. */\n\tnow?: string;\n\t/** Last `STATUS: ...` line of the output. */\n\tstatusLine?: string;\n\t/** Head+tail preview of the final output. */\n\toutput?: string;\n\terror?: string;\n\tmerge?: \"ok\" | \"failed\";\n}\n"]}
|
|
@@ -188,7 +188,7 @@ function agentRowRightText(row, showThinking) {
|
|
|
188
188
|
case "skipped":
|
|
189
189
|
return "not run";
|
|
190
190
|
case "cancelled":
|
|
191
|
-
return "cancelled";
|
|
191
|
+
return row.cancelReason === "time" ? "cancelled (time limit)" : "cancelled";
|
|
192
192
|
case "done":
|
|
193
193
|
// A finished agent with no `now` and no `STATUS:` line still has output worth showing
|
|
194
194
|
// (§11.3's tool-row fallback does the same): the first line beats a blank column.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../../../src/core/polyphase/ui/inspector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC;AAGrG,OAAO,EAEN,OAAO,EACP,OAAO,EACP,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAA2C,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAItH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EAEnB,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAqBhC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAkB5B,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;+FAG+F;AAC/F,SAA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AC;IACd,CAAC;IAEO,WAAW;QAClB,OAAO;YACN,eAAe,CAAC,CAAC,eAAe,EAAE,iBAAiB,CAAC,EAAE,QAAQ,CAAC;YAC/D,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC;YACvC,OAAO,CAAC,2BAA2B,EAAE,cAAc,CAAC;YACpD,OAAO,CAAC,yBAAyB,EAAE,YAAY,CAAC;YAChD,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,aAAa,CAAC,MAAoB;QACzC,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACvE,OAAO;YACN,OAAO,CAAC,yBAAyB,EAAE,YAAY,CAAC;YAChD,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;YAChE,OAAO,CAAC,qBAAqB,EAAE,UAAU,CAAC;YAC1C,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACD","sourcesContent":["/**\n * `PolyphaseInspector`: the `alt+a` popup overlay listing runs and following an agent's live\n * transcript. See DESIGN.md §12.1-12.6, §12.8.\n */\n\nimport type { Component, Focusable, KeybindingsManager, TUI } from \"@draht/tui\";\nimport { visibleWidth, wrapTextWithAnsi } from \"@draht/tui\";\nimport { combinedKeyHint, keyHint } from \"../../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport type { ArchivedRun } from \"../details.ts\";\nimport {\n\ttype ColumnCell,\n\tcolumns,\n\tfitLine,\n\tformatCost,\n\tformatDuration,\n\tformatModelLabel,\n\tformatTokens,\n\toneLine,\n\tpadToWidth,\n\tstatusGlyph,\n} from \"../render/format.ts\";\nimport { sanitizeChildText, sanitizeSnapshot } from \"../render/run-block.ts\";\nimport { type AgentSnapshotRow, type RunSnapshot, snapshotFromDetails, snapshotFromRun } from \"../render/snapshot.ts\";\nimport type { PolyphaseSession } from \"../session.ts\";\nimport type { AgentStatus, TranscriptItem } from \"../types.ts\";\nimport type { SavedWorkflowSummary } from \"../workflow/saved.ts\";\nimport {\n\tsanitizeForDisplay,\n\tTranscriptLineCache,\n\ttype TranscriptLineRange,\n\ttailWindowOf,\n} from \"./transcript-layout.ts\";\n\nexport type InspectorInitialView =\n\t| { view: \"auto\" }\n\t| { view: \"runs\" }\n\t| { view: \"run\"; runId: string }\n\t| { view: \"agent\"; runId: string; agentIndex: number };\n\nexport interface InspectorDeps {\n\tsession: PolyphaseSession;\n\ttui: TUI;\n\ttheme: Theme;\n\tkeybindings: KeybindingsManager;\n\tgetArchivedRuns(): readonly ArchivedRun[];\n\tgetSavedWorkflows(): readonly SavedWorkflowSummary[];\n\tinitial: InspectorInitialView;\n\tshowThinking: boolean;\n\tclose(): void;\n\tinsertCommand(text: string): void;\n}\n\nconst PAGE_SIZE = 10;\nconst SPLIT_MIN_WIDTH = 120;\nconst SPLIT_LEFT_WIDTH = 40;\n\ntype ViewMode = \"runs\" | \"run\" | \"agent\";\n\ninterface RunsRow {\n\tkind: \"live\" | \"earlier\" | \"saved\";\n\trunId?: string;\n\tsnapshot?: RunSnapshot;\n\tsaved?: SavedWorkflowSummary;\n}\n\ninterface CancelTarget {\n\trunId: string;\n\tagentIndex?: number;\n\tlabel: string;\n\tfinished: boolean;\n}\n\nfunction clamp(n: number, min: number, max: number): number {\n\treturn Math.min(max, Math.max(min, n));\n}\n\n/** Slices `lines` to `height` rows centred on `pivot`, replacing the first/last visible row with\n * a muted \"N more\" marker when the window hides rows above/below. The window is always centred on\n * `pivot` (clamped only at the list's edges), so `pivot` lands on an edge row of the window only\n * when that edge has nothing hidden past it — the marker never overwrites the selected row. */\nfunction windowAround(lines: readonly string[], height: number, pivot: number, theme: Theme): readonly string[] {\n\tif (lines.length <= height) return lines;\n\tconst start = Math.max(0, Math.min(pivot - Math.floor(height / 2), lines.length - height));\n\tconst end = start + height;\n\tconst windowed = lines.slice(start, end);\n\tif (height < 2) return windowed;\n\tconst pivotOffset = pivot - start;\n\tconst marked = windowed.slice();\n\tif (start > 0 && pivotOffset !== 0) {\n\t\tmarked[0] = theme.fg(\"muted\", `↑ ${start} more`);\n\t}\n\tif (end < lines.length && pivotOffset !== marked.length - 1) {\n\t\tmarked[marked.length - 1] = theme.fg(\"muted\", `↓ ${lines.length - end} more`);\n\t}\n\treturn marked;\n}\n\nfunction padLines(lines: readonly string[], height: number): string[] {\n\tif (lines.length >= height) return lines.slice(0, height);\n\treturn [...lines, ...Array.from({ length: height - lines.length }, () => \"\")];\n}\n\ninterface PauseAnchor {\n\tseq: number;\n\tlineInItem: number;\n}\n\n/** Resolves a pause anchor back to an absolute window-end line (exclusive), against the item line\n * ranges from the most recent render. If the anchored item was evicted, clamps to just past the\n * first still-kept item instead of drifting the view forward by the wrong amount. */\nfunction resolvePauseEndLine(anchor: PauseAnchor, ranges: readonly TranscriptLineRange[], totalLines: number): number {\n\tconst range = ranges.find((r) => r.seq === anchor.seq);\n\tif (range) return clamp(range.start + anchor.lineInItem + 1, 0, totalLines);\n\tconst first = ranges[0];\n\treturn first ? clamp(first.start + 1, 0, totalLines) : 0;\n}\n\n/** Converts an absolute window-end line (exclusive) into a pause anchor on whichever item renders\n * that line, so the anchor survives evictions that shift line numbers. */\nfunction anchorAtEndLine(endLine: number, ranges: readonly TranscriptLineRange[]): PauseAnchor | undefined {\n\tconst lastVisibleLine = endLine - 1;\n\tfor (const range of ranges) {\n\t\tif (lastVisibleLine >= range.start && lastVisibleLine < range.end) {\n\t\t\treturn { seq: range.seq, lineInItem: lastVisibleLine - range.start };\n\t\t}\n\t}\n\tconst last = ranges[ranges.length - 1];\n\treturn last ? { seq: last.seq, lineInItem: Math.max(0, last.end - last.start - 1) } : undefined;\n}\n\n/** Truncates the title (never the right segment or the closing corner) so the border always stays\n * closed, instead of handing the whole assembled string to `fitLine` and letting it cut off\n * whichever happens to sit at the end. */\nfunction borderTop(title: string, right: string, width: number): string {\n\tconst inner = Math.max(0, width - 2);\n\tlet rightSeg = right ? ` ${right} ` : \"\";\n\tlet rightWidth = visibleWidth(rightSeg);\n\tif (rightWidth > inner) {\n\t\trightSeg = \"\";\n\t\trightWidth = 0;\n\t}\n\tconst minDashes = 1;\n\tconst titleBudget = Math.max(0, inner - rightWidth - minDashes);\n\tconst titleSeg = fitLine(` ${title} `, titleBudget);\n\tconst dashes = Math.max(0, inner - visibleWidth(titleSeg) - rightWidth);\n\treturn `┌${titleSeg}${\"─\".repeat(dashes)}${rightSeg}┐`;\n}\n\nfunction borderBottom(width: number): string {\n\treturn fitLine(`└${\"─\".repeat(Math.max(0, width - 2))}┘`, width);\n}\n\nfunction sideLine(content: string, width: number): string {\n\tconst inner = Math.max(0, width - 4);\n\treturn fitLine(`│ ${padToWidth(content, inner)} │`, width);\n}\n\nfunction runsRowKey(row: RunsRow): string {\n\tif (row.kind === \"saved\") return `saved:${row.saved?.name ?? \"\"}`;\n\treturn `run:${row.runId ?? \"\"}`;\n}\n\nfunction groupLabel(kind: RunsRow[\"kind\"]): string {\n\tswitch (kind) {\n\t\tcase \"live\":\n\t\t\treturn \"Live\";\n\t\tcase \"earlier\":\n\t\t\treturn \"Earlier in this session\";\n\t\tcase \"saved\":\n\t\t\treturn \"Saved workflows\";\n\t}\n}\n\n/** Drops a trailing agent-count suffix (e.g. \"subagent parallel · 2 agents\"): `runSubtitleText`\n * is the single place that shows the count, so the title must not repeat it. */\nconst TRAILING_AGENT_COUNT = / · \\d+ agents?$/;\n\n/** The phase marker is only meaningful while the run is still progressing through phases; a\n * finished or cancelled run has no \"current\" phase left, so showing one would misread as still\n * running. */\nfunction isCurrentlyPhased(status: RunSnapshot[\"status\"]): boolean {\n\treturn status === \"running\";\n}\n\nfunction runTitleText(snapshot: RunSnapshot): string {\n\tif (snapshot.kind === \"workflow\") return `workflow ${snapshot.workflow?.name ?? snapshot.title}`;\n\tif (snapshot.kind === \"duet\") return `duet · ${snapshot.title}`;\n\treturn snapshot.title.replace(TRAILING_AGENT_COUNT, \"\");\n}\n\nfunction runSubtitleText(snapshot: RunSnapshot): string {\n\tif (snapshot.kind === \"workflow\") {\n\t\tconst phase =\n\t\t\tisCurrentlyPhased(snapshot.status) && snapshot.currentPhase !== undefined\n\t\t\t\t? snapshot.phases[snapshot.currentPhase]\n\t\t\t\t: undefined;\n\t\tif (phase) return `▸ ${phase.title}`;\n\t\tconst n = snapshot.phases.length;\n\t\treturn n > 0 ? `${n} phase${n === 1 ? \"\" : \"s\"}` : \"\";\n\t}\n\tconst n = snapshot.agents.length;\n\treturn `${n} agent${n === 1 ? \"\" : \"s\"}`;\n}\n\n/** `› ` (or ` `) + glyph, always a fixed-width cell outside the title's flex cell: the cursor and\n * status glyph must stay visible even when nothing else does. `columns()`'s own 1-column gap\n * supplies the separator space before the title, matching `› ● label` elsewhere in this file. */\nconst RUNS_ROW_CURSOR_WIDTH = 3;\n\nfunction savedWorkflowSourceLabel(source: SavedWorkflowSummary[\"source\"]): string {\n\treturn source === \"project\" ? \"proj\" : \"user\";\n}\n\n/** Drops or shrinks the runs-view row's optional columns as `width` decreases, in order of least\n * useful first (tokens, then cost, then the subtitle, then counts and duration), so the title (the\n * flex cell) keeps a usable share of the row instead of being squeezed to nothing by fixed columns\n * that no longer fit. */\nfunction runsRowOptionalWidths(width: number): {\n\tsubtitle: number;\n\tcounts: number;\n\tduration: number;\n\ttokens: number;\n\tcost: number;\n} {\n\treturn {\n\t\tsubtitle: width >= 80 ? 16 : width >= 60 ? 10 : 0,\n\t\tcounts: width >= 56 ? 10 : 0,\n\t\tduration: width >= 50 ? 7 : 0,\n\t\ttokens: width >= 70 ? 6 : 0,\n\t\tcost: width >= 60 ? 7 : 0,\n\t};\n}\n\n/** The agent detail header's right side (§12.2: `◐ thinking 0:41`) shows only the current activity\n * keyword, not `row.now`'s full content: `row.now` for a thinking/writing agent is `\"thinking · <the\n * actual text>\"`, and showing that verbatim in the border would leak hidden-thinking content past the\n * `app.thinking.toggle` gate that otherwise hides it in the transcript below. */\nfunction headerActivityText(row: AgentSnapshotRow): string {\n\tconst now = row.now ? oneLine(sanitizeForDisplay(row.now)) : undefined;\n\tif (!now) return row.status;\n\tconst separator = now.indexOf(\" · \");\n\treturn separator === -1 ? now : now.slice(0, separator);\n}\n\n/** Mirrors `headerActivityText`'s thinking-keyword cut: the run view's agent list and the split\n * view's left pane must not leak hidden thinking content into the \"now\" column either (§12.2 shows\n * just `thinking` there), even though the same column shows the activity in full once thinking is\n * visible. */\nfunction agentRowRightText(row: AgentSnapshotRow, showThinking: boolean): string {\n\tif (row.now) {\n\t\tconst now = oneLine(sanitizeForDisplay(row.now));\n\t\t// \"thinking\" is the only `computeNowLine()` activity word that can be followed by child-written\n\t\t// text; checking the prefix (not the full `\"thinking · \"` separator) also catches the edge case\n\t\t// where the thinking block is still empty and `oneLine()` has trimmed the trailing separator.\n\t\tif (!showThinking && now.startsWith(\"thinking\")) return \"thinking\";\n\t\treturn now;\n\t}\n\tif (row.statusLine) return oneLine(sanitizeForDisplay(row.statusLine));\n\tif (row.error) return oneLine(sanitizeForDisplay(row.error));\n\tswitch (row.status) {\n\t\tcase \"queued\":\n\t\t\treturn \"queued\";\n\t\tcase \"pending\":\n\t\t\treturn row.step !== undefined && row.step > 1 ? `waits for step ${row.step - 1}` : \"not run\";\n\t\tcase \"skipped\":\n\t\t\treturn \"not run\";\n\t\tcase \"cancelled\":\n\t\t\treturn \"cancelled\";\n\t\tcase \"done\":\n\t\t\t// A finished agent with no `now` and no `STATUS:` line still has output worth showing\n\t\t\t// (§11.3's tool-row fallback does the same): the first line beats a blank column.\n\t\t\treturn row.output ? oneLine(sanitizeForDisplay(row.output)) : \"\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nconst COUNT_ORDER: readonly AgentStatus[] = [\"running\", \"done\", \"failed\", \"cancelled\", \"queued\", \"pending\", \"skipped\"];\n\nfunction formatCounts(theme: Theme, now: number, counts: Record<AgentStatus, number>): string {\n\tconst parts: string[] = [];\n\tfor (const status of COUNT_ORDER) {\n\t\tconst n = counts[status];\n\t\tif (n > 0) parts.push(`${statusGlyph(status, theme, { now, animate: false })}${n}`);\n\t}\n\treturn parts.join(\" \");\n}\n\nfunction isFinishedAgentStatus(status: AgentStatus): boolean {\n\treturn status === \"done\" || status === \"failed\" || status === \"cancelled\" || status === \"skipped\";\n}\n\n/**\n * The `alt+a` popup. `render()` recomputes the live runs-view list, the current run's agent list\n * and the selected agent's transcript window on every call, since those come straight from the\n * live store; nothing here owns a timer. Dirtiness (when to re-render at all) is the caller's job,\n * driven by `session.store`'s flush notifications.\n */\nexport class PolyphaseInspector implements Component, Focusable {\n\tfocused = false;\n\n\tprivate readonly deps: InspectorDeps;\n\tprivate readonly transcriptCache: TranscriptLineCache;\n\tprivate readonly unsubscribe: () => void;\n\n\tprivate mode: ViewMode = \"runs\";\n\tprivate currentRunId: string | undefined;\n\tprivate currentAgentIndex: number | undefined;\n\tprivate runsRows: RunsRow[] = [];\n\tprivate runsSelection = 0;\n\tprivate runsSelectionKey: string | undefined;\n\tprivate runSelection = 0;\n\tprivate following = true;\n\t/** Anchors the paused window to an item (`seq`) and a line within it, not an absolute line index:\n\t * the transcript keeps at most `maxItems`, so a paused run that keeps producing output evicts\n\t * older items and shifts every absolute line index after them. Resolved back to an absolute line\n\t * on each render via `resolvePauseEndLine`. See `renderAgentDetailBody`. */\n\tprivate pauseAnchor: PauseAnchor | undefined;\n\tprivate lastTranscriptTotalLines: number | undefined;\n\tprivate lastTranscriptRanges: readonly TranscriptLineRange[] = [];\n\tprivate lastDetailBodyHeight: number | undefined;\n\tprivate lastRenderWidth = 0;\n\tprivate showThinking: boolean;\n\tprivate showToolPreviews = false;\n\tprivate armed: { action: \"cancelAgent\" | \"cancelRun\"; runId: string; agentIndex?: number } | undefined;\n\tprivate footerNotice: string | undefined;\n\n\tconstructor(deps: InspectorDeps) {\n\t\tthis.deps = deps;\n\t\tthis.showThinking = deps.showThinking;\n\t\tthis.transcriptCache = new TranscriptLineCache(deps.theme);\n\t\tthis.resolveInitialView();\n\t\tthis.unsubscribe = deps.session.store.subscribe((change) => {\n\t\t\tif (change.type === \"disposed\") {\n\t\t\t\tthis.deps.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.deps.tui.requestRender();\n\t\t});\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tthis.runsRows = this.buildRunsRows();\n\t\t\tthis.runsSelection = this.resolveRunsSelectionIndex(this.runsRows);\n\t\t}\n\t\tconst kb = this.deps.keybindings;\n\n\t\tif (kb.matches(data, \"app.polyphase.inspector\")) {\n\t\t\tthis.deps.close();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"app.polyphase.cancelAgent\")) {\n\t\t\tthis.handleCancelKey(\"cancelAgent\");\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"app.polyphase.cancelRun\")) {\n\t\t\tthis.handleCancelKey(\"cancelRun\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.armed = undefined;\n\t\tthis.footerNotice = undefined;\n\n\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.goBack();\n\t\t} else if (kb.matches(data, \"app.thinking.toggle\")) {\n\t\t\tthis.showThinking = !this.showThinking;\n\t\t} else if (kb.matches(data, \"app.tools.expand\")) {\n\t\t\tthis.showToolPreviews = !this.showToolPreviews;\n\t\t} else if (kb.matches(data, \"app.polyphase.follow\")) {\n\t\t\tthis.toggleFollow();\n\t\t} else if (kb.matches(data, \"app.polyphase.nextAgent\")) {\n\t\t\tthis.cycleAgent(1);\n\t\t} else if (kb.matches(data, \"app.polyphase.previousAgent\")) {\n\t\t\tthis.cycleAgent(-1);\n\t\t} else if (kb.matches(data, \"tui.select.up\")) {\n\t\t\tthis.moveSelection(-1);\n\t\t} else if (kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.moveSelection(1);\n\t\t} else if (kb.matches(data, \"tui.select.pageUp\")) {\n\t\t\tthis.handlePage(-1);\n\t\t} else if (kb.matches(data, \"tui.select.pageDown\")) {\n\t\t\tthis.handlePage(1);\n\t\t} else if (kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tthis.confirmSelection();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tthis.lastRenderWidth = width;\n\t\tconst terminal = this.deps.tui.terminal;\n\t\tif (width < 40 || terminal.rows < 10) {\n\t\t\treturn [fitLine(\"terminal too small for the agent inspector\", width)];\n\t\t}\n\t\tconst height = Math.max(8, terminal.rows - 2);\n\t\tconst bodyHeight = Math.max(1, height - 2);\n\t\tconst innerWidth = Math.max(1, width - 4);\n\n\t\tlet topTitle: string;\n\t\tlet topRight: string;\n\t\tlet bodyLines: string[];\n\n\t\tif (this.mode === \"runs\") {\n\t\t\tthis.runsRows = this.buildRunsRows();\n\t\t\tthis.runsSelection = this.resolveRunsSelectionIndex(this.runsRows);\n\t\t\t// Tracks the selection by identity from the very first render, not only once the user has\n\t\t\t// pressed an arrow key, so a live run inserted above the selection between renders cannot\n\t\t\t// change what a subsequent `enter` opens.\n\t\t\tif (this.runsSelectionKey === undefined) {\n\t\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\t\tthis.runsSelectionKey = row ? runsRowKey(row) : undefined;\n\t\t\t}\n\t\t\tconst liveCount = this.runsRows.filter((row) => row.kind === \"live\").length;\n\t\t\tconst earlierCount = this.runsRows.filter((row) => row.kind === \"earlier\").length;\n\t\t\tconst limiter = this.deps.session.limiter.stats();\n\t\t\ttopTitle = `polyphase · ${liveCount} live · ${earlierCount} earlier · slots ${limiter.active}/${limiter.capacity}`;\n\t\t\ttopRight = keyHint(\"app.polyphase.inspector\", \"close\");\n\t\t\tbodyLines = this.renderRunsBody(innerWidth, bodyHeight);\n\t\t} else if (this.mode === \"run\") {\n\t\t\t// Built once here and threaded through, instead of each of the header and the body methods\n\t\t\t// calling `currentRunSnapshot()`/`currentRunAgents()` again: `snapshotFromRun` runs a regex\n\t\t\t// over every agent's output and hashes the whole details object, so repeating it several\n\t\t\t// times per render on every pump flush is wasted work.\n\t\t\tconst snapshot = this.currentRunSnapshot();\n\t\t\tconst rows = this.sortedAgentsOf(snapshot);\n\t\t\ttopTitle = snapshot ? this.runTitleForHeader(snapshot) : \"run\";\n\t\t\ttopRight = snapshot ? this.runHeaderRight(snapshot) : \"\";\n\t\t\tbodyLines =\n\t\t\t\twidth >= SPLIT_MIN_WIDTH\n\t\t\t\t\t? this.renderSplitBody(innerWidth, bodyHeight, rows)\n\t\t\t\t\t: this.renderRunBody(innerWidth, bodyHeight, snapshot, rows);\n\t\t} else {\n\t\t\tconst snapshot = this.currentRunSnapshot();\n\t\t\tconst rows = this.sortedAgentsOf(snapshot);\n\t\t\tconst row = rows.find((r) => r.i === this.currentAgentIndex);\n\t\t\tconst phaseTitle = row?.phase !== undefined ? snapshot?.phases[row.phase]?.title : undefined;\n\t\t\ttopTitle = row ? `${row.label} · ${row.agentType}${phaseTitle ? ` · ${phaseTitle}` : \"\"}` : \"agent\";\n\t\t\ttopRight = row\n\t\t\t\t? `${statusGlyph(row.status, this.deps.theme, { now: this.now(), animate: false })} ${headerActivityText(row)}${\n\t\t\t\t\t\trow.elapsedMs === undefined ? \"\" : ` ${formatDuration(row.elapsedMs)}`\n\t\t\t\t\t}`\n\t\t\t\t: \"\";\n\t\t\tbodyLines = this.renderAgentDetailBody(this.currentAgentIndex, innerWidth, bodyHeight, rows);\n\t\t}\n\n\t\tconst padded = padLines(bodyLines, bodyHeight);\n\t\treturn [\n\t\t\tborderTop(topTitle, topRight, width),\n\t\t\t...padded.map((line) => sideLine(line, width)),\n\t\t\tborderBottom(width),\n\t\t];\n\t}\n\n\tinvalidate(): void {}\n\n\tdispose(): void {\n\t\tthis.unsubscribe();\n\t}\n\n\tprivate now(): number {\n\t\treturn Date.now();\n\t}\n\n\t// ── Navigation ──────────────────────────────────────────────────────────\n\n\tprivate resolveInitialView(): void {\n\t\tconst initial = this.deps.initial;\n\t\tif (initial.view === \"runs\") {\n\t\t\tthis.mode = \"runs\";\n\t\t\treturn;\n\t\t}\n\t\tif (initial.view === \"run\") {\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.currentRunId = initial.runId;\n\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t\treturn;\n\t\t}\n\t\tif (initial.view === \"agent\") {\n\t\t\tthis.mode = \"agent\";\n\t\t\tthis.currentRunId = initial.runId;\n\t\t\tthis.currentAgentIndex = initial.agentIndex;\n\t\t\treturn;\n\t\t}\n\t\tconst liveRuns = this.deps.session.store.runs().filter((run) => run.status === \"running\");\n\t\tif (liveRuns.length === 1) {\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.currentRunId = liveRuns[0]?.id;\n\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t} else {\n\t\t\tthis.mode = \"runs\";\n\t\t}\n\t}\n\n\tprivate selectFirstActiveAgentForCurrentRun(): void {\n\t\tconst rows = this.currentRunAgents();\n\t\tconst idx = rows.findIndex((row) => row.status === \"running\" || row.status === \"starting\");\n\t\tthis.runSelection = idx === -1 ? 0 : idx;\n\t}\n\n\t/** Resolves the runs-view selection by the identity of the previously selected row (its runId or\n\t * saved-workflow name), not its index, so a live update that reorders rows between a render and the\n\t * next key press does not silently select a different run. Falls back to a clamped index when the\n\t * previous row is gone (e.g. an archived run was pruned). */\n\tprivate resolveRunsSelectionIndex(rows: readonly RunsRow[]): number {\n\t\tif (this.runsSelectionKey !== undefined) {\n\t\t\tconst idx = rows.findIndex((row) => runsRowKey(row) === this.runsSelectionKey);\n\t\t\tif (idx !== -1) return idx;\n\t\t}\n\t\treturn clamp(this.runsSelection, 0, Math.max(0, rows.length - 1));\n\t}\n\n\tprivate resetFollowing(): void {\n\t\tthis.following = true;\n\t\tthis.pauseAnchor = undefined;\n\t}\n\n\tprivate isSplitActive(): boolean {\n\t\treturn this.lastRenderWidth >= SPLIT_MIN_WIDTH;\n\t}\n\n\tprivate goBack(): void {\n\t\tif (this.mode === \"agent\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tconst idx = rows.findIndex((row) => row.i === this.currentAgentIndex);\n\t\t\tif (idx !== -1) this.runSelection = idx;\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.resetFollowing();\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\t// Reselects the run the user came from, so the runs view does not fall back to the index it\n\t\t\t// had before drilling in (which may now point at a different row).\n\t\t\tif (this.currentRunId) this.runsSelectionKey = `run:${this.currentRunId}`;\n\t\t\tthis.mode = \"runs\";\n\t\t\tthis.currentRunId = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.deps.close();\n\t}\n\n\tprivate confirmSelection(): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tif (!row) return;\n\t\t\tif (row.kind === \"saved\") {\n\t\t\t\tconst saved = row.saved;\n\t\t\t\tif (!saved) return;\n\t\t\t\tif (!saved.valid) {\n\t\t\t\t\tthis.footerNotice = `/${saved.name} is invalid`;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst command = saved.command ? `/${saved.command.replace(/^\\//, \"\")} ` : `/workflow ${saved.name} `;\n\t\t\t\tthis.deps.insertCommand(command);\n\t\t\t\tthis.deps.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (row.runId) {\n\t\t\t\tthis.currentRunId = row.runId;\n\t\t\t\tthis.mode = \"run\";\n\t\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tconst row = rows[this.runSelection];\n\t\t\tif (!row) return;\n\t\t\tthis.currentAgentIndex = row.i;\n\t\t\tthis.mode = \"agent\";\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\tprivate moveSelection(delta: number): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tif (this.runsRows.length === 0) return;\n\t\t\tthis.runsSelection = clamp(this.runsSelection + delta, 0, this.runsRows.length - 1);\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tthis.runsSelectionKey = row ? runsRowKey(row) : undefined;\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tconst next = clamp(this.runSelection + delta, 0, rows.length - 1);\n\t\t\tif (next !== this.runSelection) {\n\t\t\t\tthis.runSelection = next;\n\t\t\t\tthis.resetFollowing();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis.scrollTranscript(delta);\n\t}\n\n\t/** Shared by the agent detail view and, in split view, by page keys on the run view: both drive\n\t * the same `following`/`pauseAnchor` pair against whichever agent is currently shown on the\n\t * right. */\n\tprivate scrollTranscript(delta: number): void {\n\t\tconst total = this.lastTranscriptTotalLines ?? 0;\n\t\tconst ranges = this.lastTranscriptRanges;\n\t\tconst visible = Math.max(1, this.lastDetailBodyHeight ?? 1);\n\t\tconst currentEnd = this.pauseAnchor ? resolvePauseEndLine(this.pauseAnchor, ranges, total) : total;\n\t\tif (delta < 0) {\n\t\t\tif (total <= visible) return;\n\t\t\tconst minEnd = Math.min(total, visible);\n\t\t\tthis.pauseAnchor = anchorAtEndLine(Math.max(minEnd, currentEnd + delta), ranges);\n\t\t\tthis.following = false;\n\t\t} else if (delta > 0 && this.pauseAnchor !== undefined) {\n\t\t\tconst next = Math.min(total, currentEnd + delta);\n\t\t\tif (next >= total) {\n\t\t\t\tthis.pauseAnchor = undefined;\n\t\t\t\tthis.following = true;\n\t\t\t} else {\n\t\t\t\tthis.pauseAnchor = anchorAtEndLine(next, ranges);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Page keys scroll the right pane in split view (§12.2) instead of moving the left selection by\n\t * a page. Up/down always move the left selection; only page keys are redirected. */\n\tprivate handlePage(direction: 1 | -1): void {\n\t\tif (this.mode === \"run\" && this.isSplitActive()) {\n\t\t\tthis.scrollTranscript(direction * PAGE_SIZE);\n\t\t\treturn;\n\t\t}\n\t\tthis.moveSelection(direction * PAGE_SIZE);\n\t}\n\n\tprivate cycleAgent(direction: 1 | -1): void {\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tthis.runSelection = (this.runSelection + direction + rows.length) % rows.length;\n\t\t\tthis.resetFollowing();\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"agent\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tconst curIdx = rows.findIndex((row) => row.i === this.currentAgentIndex);\n\t\t\tconst nextIdx = ((curIdx === -1 ? 0 : curIdx) + direction + rows.length) % rows.length;\n\t\t\tthis.currentAgentIndex = rows[nextIdx]?.i;\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\tprivate toggleFollow(): void {\n\t\tif (this.mode !== \"agent\" && !(this.mode === \"run\" && this.isSplitActive())) return;\n\t\tif (this.following) {\n\t\t\tconst anchor = anchorAtEndLine(this.lastTranscriptTotalLines ?? 0, this.lastTranscriptRanges);\n\t\t\t// An empty transcript (no ranges yet, or the archived/retention-dropped summary body, which\n\t\t\t// never sets any ranges) has nothing to anchor a pause to. Pressing `f` must stay a no-op\n\t\t\t// then, not flip into a paused state the view can never escape: `scrollTranscript` only\n\t\t\t// resumes following once `pauseAnchor` advances to the end, which it can never do without an\n\t\t\t// anchor.\n\t\t\tif (anchor === undefined) return;\n\t\t\tthis.pauseAnchor = anchor;\n\t\t\tthis.following = false;\n\t\t} else {\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\t// ── Two-press cancel (§12.4) ────────────────────────────────────────────\n\n\tprivate handleCancelKey(action: \"cancelAgent\" | \"cancelRun\"): void {\n\t\tconst target = this.cancelTarget(action);\n\t\tif (!target) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst sameTarget =\n\t\t\tthis.armed?.action === action &&\n\t\t\tthis.armed.runId === target.runId &&\n\t\t\tthis.armed.agentIndex === target.agentIndex;\n\t\tif (sameTarget) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = undefined;\n\t\t\tif (action === \"cancelAgent\" && target.agentIndex !== undefined) {\n\t\t\t\tthis.deps.session.store.cancelAgent(target.runId, target.agentIndex);\n\t\t\t} else {\n\t\t\t\tthis.deps.session.store.cancelRun(target.runId);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (target.finished) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = \"already finished\";\n\t\t\treturn;\n\t\t}\n\t\tthis.armed = { action, runId: target.runId, agentIndex: target.agentIndex };\n\t\tthis.footerNotice =\n\t\t\taction === \"cancelAgent\" ? `press x again to cancel ${target.label}` : \"press X again to cancel the run\";\n\t}\n\n\tprivate cancelTarget(action: \"cancelAgent\" | \"cancelRun\"): CancelTarget | undefined {\n\t\tif (action === \"cancelAgent\") {\n\t\t\tif (this.mode === \"run\") {\n\t\t\t\tconst row = this.currentRunAgents()[this.runSelection];\n\t\t\t\tif (!row || !this.currentRunId) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\trunId: this.currentRunId,\n\t\t\t\t\tagentIndex: row.i,\n\t\t\t\t\tlabel: row.label,\n\t\t\t\t\tfinished: isFinishedAgentStatus(row.status),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (this.mode === \"agent\") {\n\t\t\t\tconst row = this.currentAgentRow();\n\t\t\t\tif (!row || !this.currentRunId) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\trunId: this.currentRunId,\n\t\t\t\t\tagentIndex: row.i,\n\t\t\t\t\tlabel: row.label,\n\t\t\t\t\tfinished: isFinishedAgentStatus(row.status),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\tif (this.mode === \"runs\") {\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tif (!row || row.kind === \"saved\" || !row.runId || !row.snapshot) return undefined;\n\t\t\treturn { runId: row.runId, label: row.snapshot.title, finished: row.snapshot.status !== \"running\" };\n\t\t}\n\t\tconst snapshot = this.currentRunSnapshot();\n\t\tif (!snapshot || !this.currentRunId) return undefined;\n\t\treturn { runId: this.currentRunId, label: snapshot.title, finished: snapshot.status !== \"running\" };\n\t}\n\n\t// ── Data access ─────────────────────────────────────────────────────────\n\n\tprivate buildRunsRows(): RunsRow[] {\n\t\tconst store = this.deps.session.store;\n\t\tconst allRuns = store.runs();\n\t\tconst liveRuns = allRuns.filter((run) => run.status === \"running\");\n\t\tconst finishedLive = allRuns.filter((run) => run.status !== \"running\");\n\t\tconst knownIds = new Set([...liveRuns, ...finishedLive].map((run) => run.id));\n\t\tconst archived = this.deps.getArchivedRuns().filter((entry) => !knownIds.has(entry.runId));\n\n\t\tconst rows: RunsRow[] = [];\n\t\tfor (const run of liveRuns) {\n\t\t\trows.push({\n\t\t\t\tkind: \"live\",\n\t\t\t\trunId: run.id,\n\t\t\t\tsnapshot: sanitizeSnapshot(\n\t\t\t\t\tsnapshotFromRun(run, { now: this.now(), tailItems: 0, limiter: this.deps.session.limiter.stats() }),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\tfor (const run of finishedLive) {\n\t\t\trows.push({\n\t\t\t\tkind: \"earlier\",\n\t\t\t\trunId: run.id,\n\t\t\t\tsnapshot: sanitizeSnapshot(snapshotFromRun(run, { now: this.now(), tailItems: 0 })),\n\t\t\t});\n\t\t}\n\t\tfor (const entry of archived) {\n\t\t\trows.push({\n\t\t\t\tkind: \"earlier\",\n\t\t\t\trunId: entry.runId,\n\t\t\t\tsnapshot: sanitizeSnapshot(snapshotFromDetails(entry.details, { now: this.now() })),\n\t\t\t});\n\t\t}\n\t\tfor (const saved of this.deps.getSavedWorkflows()) {\n\t\t\trows.push({ kind: \"saved\", saved });\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate currentRunSnapshot(): RunSnapshot | undefined {\n\t\tif (!this.currentRunId) return undefined;\n\t\tconst liveRun = this.deps.session.store.getRun(this.currentRunId);\n\t\tif (liveRun) {\n\t\t\treturn sanitizeSnapshot(\n\t\t\t\tsnapshotFromRun(liveRun, { now: this.now(), tailItems: 0, limiter: this.deps.session.limiter.stats() }),\n\t\t\t);\n\t\t}\n\t\tconst archived = this.deps.getArchivedRuns().find((entry) => entry.runId === this.currentRunId);\n\t\treturn archived ? sanitizeSnapshot(snapshotFromDetails(archived.details, { now: this.now() })) : undefined;\n\t}\n\n\tprivate sortedAgentsOf(snapshot: RunSnapshot | undefined): AgentSnapshotRow[] {\n\t\tif (!snapshot) return [];\n\t\treturn [...snapshot.agents].sort((a, b) => a.i - b.i);\n\t}\n\n\tprivate currentRunAgents(): AgentSnapshotRow[] {\n\t\treturn this.sortedAgentsOf(this.currentRunSnapshot());\n\t}\n\n\tprivate currentAgentRow(): AgentSnapshotRow | undefined {\n\t\tif (this.currentAgentIndex === undefined) return undefined;\n\t\treturn this.currentRunAgents().find((row) => row.i === this.currentAgentIndex);\n\t}\n\n\tprivate currentAgentTranscriptFor(\n\t\tagentIndex: number,\n\t): { items: readonly TranscriptItem[]; dropped: number } | undefined {\n\t\tif (!this.currentRunId) return undefined;\n\t\tconst run = this.deps.session.store.getRun(this.currentRunId);\n\t\tconst agent = run?.agents[agentIndex];\n\t\t// Retention drops every agent's transcript on a finished run once it falls past\n\t\t// `keepTranscriptRuns`; `undefined` here sends the caller to the archived-style summary body\n\t\t// (status, output, error, the \"only kept while in memory\" note) instead of an empty transcript.\n\t\tif (!run || !agent || run.transcriptsDropped) return undefined;\n\t\treturn { items: agent.state.transcript, dropped: agent.state.droppedItems };\n\t}\n\n\t// ── Rendering ───────────────────────────────────────────────────────────\n\n\tprivate formatRunsRow(row: RunsRow, width: number, selected: boolean): string {\n\t\tconst cursor = selected ? \"› \" : \" \";\n\t\tif (row.kind === \"saved\" && row.saved) {\n\t\t\tconst saved = row.saved;\n\t\t\t// `name`/`description` come from the saved script's own meta block (`workflow/meta.ts`), the\n\t\t\t// same kind of script-supplied text `sanitizeSnapshot` cleans for live/archived runs.\n\t\t\tconst nameText = `${cursor}/${sanitizeChildText(saved.name)}`;\n\t\t\treturn columns(\n\t\t\t\t[\n\t\t\t\t\t{ text: saved.valid ? nameText : this.deps.theme.fg(\"error\", `${nameText} invalid`), width: 18 },\n\t\t\t\t\t{ text: sanitizeChildText(saved.description), width: \"flex\" },\n\t\t\t\t\t{ text: savedWorkflowSourceLabel(saved.source), width: 4, align: \"right\" },\n\t\t\t\t],\n\t\t\t\twidth,\n\t\t\t);\n\t\t}\n\t\tconst snapshot = row.snapshot;\n\t\tif (!snapshot) return fitLine(`${cursor}?`, width);\n\t\tconst glyph = statusGlyph(snapshot.status, this.deps.theme, { now: this.now(), animate: false });\n\t\tconst optional = runsRowOptionalWidths(width);\n\t\t// The cursor, glyph and title are fixed/flex cells ahead of every optional column, so they\n\t\t// always render, even at widths where every optional column below has been dropped.\n\t\tconst cells: ColumnCell[] = [\n\t\t\t{ text: `${cursor}${glyph}`, width: RUNS_ROW_CURSOR_WIDTH },\n\t\t\t{ text: runTitleText(snapshot), width: \"flex\" },\n\t\t];\n\t\tif (optional.subtitle > 0) cells.push({ text: runSubtitleText(snapshot), width: optional.subtitle });\n\t\tif (optional.counts > 0) {\n\t\t\tcells.push({ text: formatCounts(this.deps.theme, this.now(), snapshot.counts), width: optional.counts });\n\t\t}\n\t\tif (optional.duration > 0) {\n\t\t\tcells.push({ text: formatDuration(snapshot.elapsedMs), width: optional.duration, align: \"right\" });\n\t\t}\n\t\tif (optional.tokens > 0) {\n\t\t\tcells.push({\n\t\t\t\ttext: snapshot.tokens > 0 ? formatTokens(snapshot.tokens) : \"\",\n\t\t\t\twidth: optional.tokens,\n\t\t\t\talign: \"right\",\n\t\t\t});\n\t\t}\n\t\tif (optional.cost > 0) cells.push({ text: formatCost(snapshot.cost), width: optional.cost, align: \"right\" });\n\t\treturn columns(cells, width);\n\t}\n\n\tprivate renderRunsBody(width: number, height: number): string[] {\n\t\tconst rows = this.runsRows;\n\t\tconst lines: string[] = [];\n\t\tconst lineForRow: number[] = [];\n\t\tlet lastKind: RunsRow[\"kind\"] | undefined;\n\t\trows.forEach((row, idx) => {\n\t\t\tif (row.kind !== lastKind) {\n\t\t\t\tlines.push(this.deps.theme.bold(groupLabel(row.kind)));\n\t\t\t\tlastKind = row.kind;\n\t\t\t}\n\t\t\tlineForRow[idx] = lines.length;\n\t\t\tlines.push(this.formatRunsRow(row, width, idx === this.runsSelection));\n\t\t});\n\t\tif (rows.length === 0) {\n\t\t\tlines.push('No agents yet. Put \"polyphase\" in a prompt or run /workflow <name>.');\n\t\t}\n\t\tconst pivot = lineForRow[this.runsSelection] ?? 0;\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tconst windowed = padLines(windowAround(lines, contentHeight, pivot, this.deps.theme), contentHeight);\n\t\treturn [...windowed, this.footerLine(this.runsHintLine(), width)];\n\t}\n\n\tprivate formatAgentRow(row: AgentSnapshotRow, width: number, selected: boolean): string {\n\t\tconst cursor = selected ? \"› \" : \" \";\n\t\tconst glyph = statusGlyph(row.status, this.deps.theme, { now: this.now(), animate: false });\n\t\tconst model = formatModelLabel(row, { withProvider: false });\n\t\tconst cells: ColumnCell[] = [\n\t\t\t{ text: `${cursor}${glyph} ${row.label}`, width: 18 },\n\t\t\t{ text: model, width: 20 },\n\t\t];\n\t\t// Dropped below 60 columns, the same threshold `layoutRun` uses for its elapsed column: at\n\t\t// the 40-column split-pane width there is no room for a 5th fixed cell ahead of the flex one.\n\t\tif (width >= 60) {\n\t\t\tcells.push({\n\t\t\t\ttext: row.elapsedMs === undefined ? \"\" : formatDuration(row.elapsedMs),\n\t\t\t\twidth: 5,\n\t\t\t\talign: \"right\",\n\t\t\t});\n\t\t}\n\t\tcells.push({ text: agentRowRightText(row, this.showThinking), width: \"flex\" });\n\t\treturn columns(cells, width);\n\t}\n\n\tprivate runTitleForHeader(snapshot: RunSnapshot): string {\n\t\tconst base = runTitleText(snapshot);\n\t\tif (snapshot.kind === \"workflow\" && isCurrentlyPhased(snapshot.status) && snapshot.currentPhase !== undefined) {\n\t\t\tconst phase = snapshot.phases[snapshot.currentPhase];\n\t\t\tif (phase) return `${base} ▸ ${phase.title}`;\n\t\t}\n\t\treturn base;\n\t}\n\n\tprivate runHeaderRight(snapshot: RunSnapshot): string {\n\t\tconst parts = [formatCounts(this.deps.theme, this.now(), snapshot.counts), formatDuration(snapshot.elapsedMs)];\n\t\tif (snapshot.tokens > 0) parts.push(formatTokens(snapshot.tokens));\n\t\tconst cost = formatCost(snapshot.cost);\n\t\tif (cost) parts.push(cost);\n\t\treturn parts.filter((part) => part.length > 0).join(\" \");\n\t}\n\n\tprivate renderRunBody(\n\t\twidth: number,\n\t\theight: number,\n\t\tsnapshot: RunSnapshot | undefined,\n\t\trows: AgentSnapshotRow[],\n\t): string[] {\n\t\tif (!snapshot) return [this.deps.theme.fg(\"muted\", \"run not found\")];\n\t\tthis.runSelection = clamp(this.runSelection, 0, Math.max(0, rows.length - 1));\n\n\t\tconst lines: string[] = [];\n\t\tconst lineForAgent: number[] = [];\n\t\tif (snapshot.phases.length > 0) {\n\t\t\t// Agents spawned before any phase()/agent({phase}) call (§13.3) carry no phase index; they\n\t\t\t// are still selectable, so they get an ungrouped block ahead of the phase list instead of\n\t\t\t// being silently dropped from the view.\n\t\t\trows.forEach((row, idx) => {\n\t\t\t\tif (row.phase !== undefined) return;\n\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\tlines.push(this.formatAgentRow(row, width, idx === this.runSelection));\n\t\t\t});\n\t\t\tfor (const phase of snapshot.phases) {\n\t\t\t\tlines.push(\n\t\t\t\t\tcolumns(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttext: `${statusGlyph(phase.status, this.deps.theme, { now: this.now(), animate: false })} ${phase.index + 1} ${phase.title}`,\n\t\t\t\t\t\t\t\twidth: \"flex\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ text: `${phase.done}/${phase.total}`, width: 7, align: \"right\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttext: phase.elapsedMs === undefined ? \"\" : formatDuration(phase.elapsedMs),\n\t\t\t\t\t\t\t\twidth: 7,\n\t\t\t\t\t\t\t\talign: \"right\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\trows.forEach((row, idx) => {\n\t\t\t\t\tif (row.phase !== phase.index) return;\n\t\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\t\tlines.push(` ${this.formatAgentRow(row, Math.max(1, width - 4), idx === this.runSelection)}`);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\trows.forEach((row, idx) => {\n\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\tconst prefix = row.step !== undefined ? `${row.step} ` : \"\";\n\t\t\t\tlines.push(\n\t\t\t\t\t`${prefix}${this.formatAgentRow(row, Math.max(1, width - prefix.length), idx === this.runSelection)}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tif (snapshot.log.length > 0) {\n\t\t\tlines.push(`» ${oneLine(sanitizeForDisplay(snapshot.log[snapshot.log.length - 1] ?? \"\"))}`);\n\t\t} else if (snapshot.resultPreview && snapshot.status !== \"running\") {\n\t\t\tlines.push(`→ ${oneLine(sanitizeForDisplay(snapshot.resultPreview))}`);\n\t\t}\n\n\t\tconst pivot = lineForAgent[this.runSelection] ?? 0;\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tconst windowed = padLines(windowAround(lines, contentHeight, pivot, this.deps.theme), contentHeight);\n\t\treturn [...windowed, this.footerLine(this.runHintLine(), width)];\n\t}\n\n\tprivate renderSplitBody(width: number, height: number, rows: AgentSnapshotRow[]): string[] {\n\t\tconst rightWidth = Math.max(1, width - SPLIT_LEFT_WIDTH - 1);\n\t\tthis.runSelection = clamp(this.runSelection, 0, Math.max(0, rows.length - 1));\n\t\tconst leftLines = rows.map((row, idx) =>\n\t\t\tfitLine(this.formatAgentRow(row, SPLIT_LEFT_WIDTH, idx === this.runSelection), SPLIT_LEFT_WIDTH),\n\t\t);\n\t\tconst selectedAgentIndex = rows[this.runSelection]?.i;\n\t\tconst rightLines = this.renderAgentDetailBody(selectedAgentIndex, rightWidth, height, rows);\n\t\t// Windowed the same way `renderRunBody` windows the flat agent list, so a run with more agents\n\t\t// than the pane has rows keeps the `›` cursor on screen instead of scrolling it off the top.\n\t\tconst paddedLeft = padLines(windowAround(leftLines, height, this.runSelection, this.deps.theme), height);\n\t\tconst paddedRight = padLines(rightLines, height);\n\t\treturn paddedLeft.map((line, idx) => `${padToWidth(line, SPLIT_LEFT_WIDTH)}│${paddedRight[idx] ?? \"\"}`);\n\t}\n\n\tprivate renderAgentDetailBody(\n\t\tagentIndex: number | undefined,\n\t\twidth: number,\n\t\theight: number,\n\t\trows: AgentSnapshotRow[],\n\t): string[] {\n\t\tconst footerFallback = this.agentHintLine();\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tif (agentIndex === undefined) {\n\t\t\treturn [\n\t\t\t\t...padLines([this.deps.theme.fg(\"muted\", \"no agent selected\")], contentHeight),\n\t\t\t\tthis.footerLine(footerFallback, width),\n\t\t\t];\n\t\t}\n\t\tconst row = rows.find((r) => r.i === agentIndex);\n\t\tif (!row) {\n\t\t\treturn [\n\t\t\t\t...padLines([this.deps.theme.fg(\"muted\", \"agent not found\")], contentHeight),\n\t\t\t\tthis.footerLine(footerFallback, width),\n\t\t\t];\n\t\t}\n\n\t\tconst header: string[] = [];\n\t\tconst modelLabel = formatModelLabel(row, { withProvider: true, withSource: true });\n\t\tconst confirmText = row.modelConfirmed ? \"confirmed\" : \"unconfirmed\";\n\t\tconst tokensText = row.tokens > 0 ? ` · ${formatTokens(row.tokens)} tok` : \"\";\n\t\tconst costText = row.cost > 0 ? ` · ${formatCost(row.cost)}` : \"\";\n\t\tconst turnsText = `${row.turns} turn${row.turns === 1 ? \"\" : \"s\"}`;\n\t\tconst toolsText = `${row.toolCalls} tool${row.toolCalls === 1 ? \"\" : \"s\"}`;\n\t\theader.push(oneLine(`${modelLabel} · ${confirmText} · ${turnsText} · ${toolsText}${tokensText}${costText}`));\n\t\theader.push(`task ${oneLine(row.task)}`);\n\t\theader.push(\"─\".repeat(Math.max(0, width)));\n\n\t\tconst footer = this.footerLine(this.agentHintLine(row.status), width);\n\t\tconst transcript = this.currentAgentTranscriptFor(agentIndex);\n\t\tif (!transcript) {\n\t\t\tconst OUTPUT_PREVIEW_MAX_LINES = 8;\n\t\t\tlet statusLines = row.statusLine ? 1 : 0;\n\t\t\tlet errorLines = row.error ? 1 : 0;\n\t\t\tconst noteLines = 1;\n\t\t\t// The note explains why the transcript is gone, so it must survive trimming even at the\n\t\t\t// smallest supported height: reserve header + note first, then drop error, then status,\n\t\t\t// before giving any remaining budget to the output preview. `padLines` below only pads or\n\t\t\t// truncates from the end, so whatever we build here must already fit `contentHeight`.\n\t\t\tif (header.length + statusLines + errorLines + noteLines > contentHeight && errorLines > 0) {\n\t\t\t\terrorLines = 0;\n\t\t\t}\n\t\t\tif (header.length + statusLines + errorLines + noteLines > contentHeight && statusLines > 0) {\n\t\t\t\tstatusLines = 0;\n\t\t\t}\n\t\t\tconst outputBudget = row.output\n\t\t\t\t? Math.max(0, contentHeight - header.length - statusLines - errorLines - noteLines - 1)\n\t\t\t\t: 0;\n\t\t\tconst body = [...header];\n\t\t\tif (statusLines > 0 && row.statusLine) {\n\t\t\t\tbody.push(fitLine(`status ${oneLine(sanitizeForDisplay(row.statusLine))}`, width));\n\t\t\t}\n\t\t\tif (row.output && outputBudget > 0) {\n\t\t\t\tbody.push(\"output\");\n\t\t\t\tbody.push(\n\t\t\t\t\t...wrapTextWithAnsi(sanitizeForDisplay(row.output), Math.max(1, width - 2))\n\t\t\t\t\t\t.slice(0, Math.min(OUTPUT_PREVIEW_MAX_LINES, outputBudget))\n\t\t\t\t\t\t.map((line) => fitLine(` ${line}`, width)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (errorLines > 0 && row.error) body.push(fitLine(`error ${oneLine(sanitizeForDisplay(row.error))}`, width));\n\t\t\tbody.push(this.deps.theme.fg(\"muted\", \"Live transcript is only kept while the run is in memory.\"));\n\t\t\tthis.lastTranscriptTotalLines = undefined;\n\t\t\tthis.lastTranscriptRanges = [];\n\t\t\tthis.lastDetailBodyHeight = undefined;\n\t\t\treturn [...padLines(body, contentHeight), footer];\n\t\t}\n\n\t\tconst owner = `${this.currentRunId}:${agentIndex}`;\n\t\tconst transcriptLines = this.transcriptCache.linesFor(owner, transcript.items, transcript.dropped, {\n\t\t\twidth,\n\t\t\tshowThinking: this.showThinking,\n\t\t\tshowToolPreviews: this.showToolPreviews,\n\t\t\tnow: this.now(),\n\t\t});\n\t\tconst tail = tailWindowOf(transcriptLines);\n\t\tthis.lastTranscriptTotalLines = tail.totalLines;\n\t\tthis.lastTranscriptRanges = this.transcriptCache.lineRanges();\n\t\t// A finished or cancelled agent has nothing left to follow or pause: the indicator row only\n\t\t// makes sense while the agent could still produce more output.\n\t\tconst showFollowLine = !isFinishedAgentStatus(row.status);\n\t\tconst transcriptRows = Math.max(1, contentHeight - header.length - (showFollowLine ? 1 : 0));\n\t\tthis.lastDetailBodyHeight = transcriptRows;\n\t\tconst pinnedEndLine = this.pauseAnchor\n\t\t\t? resolvePauseEndLine(this.pauseAnchor, this.lastTranscriptRanges, tail.totalLines)\n\t\t\t: undefined;\n\t\tconst offsetFromEnd = this.following ? 0 : Math.max(0, tail.totalLines - (pinnedEndLine ?? tail.totalLines));\n\t\tconst windowLines = padLines(tail.window(transcriptRows, offsetFromEnd), transcriptRows);\n\t\tconst followLine = showFollowLine\n\t\t\t? [fitLine(this.following ? \"◆ following\" : \"‖ paused · f to follow\", width)]\n\t\t\t: [];\n\t\tconst body = [...header, ...windowLines, ...followLine];\n\t\treturn [...padLines(body, contentHeight), footer];\n\t}\n\n\t/** `width` is the same inner width the caller laid its body out to, so a hint line that does not\n\t * fit is ellipsised like every other row instead of being hard-cut by `sideLine`'s padding,\n\t * which carries no ellipsis of its own. */\n\tprivate footerLine(hint: string, width: number): string {\n\t\treturn fitLine(this.footerNotice ? this.deps.theme.fg(\"warning\", this.footerNotice) : hint, width);\n\t}\n\n\tprivate runsHintLine(): string {\n\t\treturn [\n\t\t\tcombinedKeyHint([\"tui.select.up\", \"tui.select.down\"], \"select\"),\n\t\t\tkeyHint(\"tui.select.confirm\", \"open\"),\n\t\t\tkeyHint(\"app.polyphase.cancelRun\", \"cancel run\"),\n\t\t\tkeyHint(\"tui.select.cancel\", \"close\"),\n\t\t].join(\" \");\n\t}\n\n\tprivate runHintLine(): string {\n\t\treturn [\n\t\t\tcombinedKeyHint([\"tui.select.up\", \"tui.select.down\"], \"select\"),\n\t\t\tkeyHint(\"tui.select.confirm\", \"follow\"),\n\t\t\tkeyHint(\"app.polyphase.cancelAgent\", \"cancel agent\"),\n\t\t\tkeyHint(\"app.polyphase.cancelRun\", \"cancel run\"),\n\t\t\tkeyHint(\"tui.select.cancel\", \"back\"),\n\t\t].join(\" \");\n\t}\n\n\tprivate agentHintLine(status?: AgentStatus): string {\n\t\tconst finished = status !== undefined && isFinishedAgentStatus(status);\n\t\treturn [\n\t\t\tkeyHint(\"app.polyphase.nextAgent\", \"next agent\"),\n\t\t\t...(finished ? [] : [keyHint(\"app.polyphase.follow\", \"follow\")]),\n\t\t\tkeyHint(\"app.thinking.toggle\", \"thinking\"),\n\t\t\t...(finished ? [] : [keyHint(\"app.polyphase.cancelAgent\", \"cancel\")]),\n\t\t\tkeyHint(\"tui.select.cancel\", \"back\"),\n\t\t].join(\" \");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../../../src/core/polyphase/ui/inspector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC;AAGrG,OAAO,EAEN,OAAO,EACP,OAAO,EACP,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAA2C,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAItH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EAEnB,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAqBhC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAkB5B,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;+FAG+F;AAC/F,SAAS,YAAY,CAAC,KAAwB,EAAE,MAAc,EAAE,KAAa,EAAE,KAAY;IAC1F,IAAI,KAAK,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,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AC;YAC/D,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC;YACvC,OAAO,CAAC,2BAA2B,EAAE,cAAc,CAAC;YACpD,OAAO,CAAC,yBAAyB,EAAE,YAAY,CAAC;YAChD,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,aAAa,CAAC,MAAoB;QACzC,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACvE,OAAO;YACN,OAAO,CAAC,yBAAyB,EAAE,YAAY,CAAC;YAChD,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;YAChE,OAAO,CAAC,qBAAqB,EAAE,UAAU,CAAC;YAC1C,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACD","sourcesContent":["/**\n * `PolyphaseInspector`: the `alt+a` popup overlay listing runs and following an agent's live\n * transcript. See DESIGN.md §12.1-12.6, §12.8.\n */\n\nimport type { Component, Focusable, KeybindingsManager, TUI } from \"@draht/tui\";\nimport { visibleWidth, wrapTextWithAnsi } from \"@draht/tui\";\nimport { combinedKeyHint, keyHint } from \"../../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport type { ArchivedRun } from \"../details.ts\";\nimport {\n\ttype ColumnCell,\n\tcolumns,\n\tfitLine,\n\tformatCost,\n\tformatDuration,\n\tformatModelLabel,\n\tformatTokens,\n\toneLine,\n\tpadToWidth,\n\tstatusGlyph,\n} from \"../render/format.ts\";\nimport { sanitizeChildText, sanitizeSnapshot } from \"../render/run-block.ts\";\nimport { type AgentSnapshotRow, type RunSnapshot, snapshotFromDetails, snapshotFromRun } from \"../render/snapshot.ts\";\nimport type { PolyphaseSession } from \"../session.ts\";\nimport type { AgentStatus, TranscriptItem } from \"../types.ts\";\nimport type { SavedWorkflowSummary } from \"../workflow/saved.ts\";\nimport {\n\tsanitizeForDisplay,\n\tTranscriptLineCache,\n\ttype TranscriptLineRange,\n\ttailWindowOf,\n} from \"./transcript-layout.ts\";\n\nexport type InspectorInitialView =\n\t| { view: \"auto\" }\n\t| { view: \"runs\" }\n\t| { view: \"run\"; runId: string }\n\t| { view: \"agent\"; runId: string; agentIndex: number };\n\nexport interface InspectorDeps {\n\tsession: PolyphaseSession;\n\ttui: TUI;\n\ttheme: Theme;\n\tkeybindings: KeybindingsManager;\n\tgetArchivedRuns(): readonly ArchivedRun[];\n\tgetSavedWorkflows(): readonly SavedWorkflowSummary[];\n\tinitial: InspectorInitialView;\n\tshowThinking: boolean;\n\tclose(): void;\n\tinsertCommand(text: string): void;\n}\n\nconst PAGE_SIZE = 10;\nconst SPLIT_MIN_WIDTH = 120;\nconst SPLIT_LEFT_WIDTH = 40;\n\ntype ViewMode = \"runs\" | \"run\" | \"agent\";\n\ninterface RunsRow {\n\tkind: \"live\" | \"earlier\" | \"saved\";\n\trunId?: string;\n\tsnapshot?: RunSnapshot;\n\tsaved?: SavedWorkflowSummary;\n}\n\ninterface CancelTarget {\n\trunId: string;\n\tagentIndex?: number;\n\tlabel: string;\n\tfinished: boolean;\n}\n\nfunction clamp(n: number, min: number, max: number): number {\n\treturn Math.min(max, Math.max(min, n));\n}\n\n/** Slices `lines` to `height` rows centred on `pivot`, replacing the first/last visible row with\n * a muted \"N more\" marker when the window hides rows above/below. The window is always centred on\n * `pivot` (clamped only at the list's edges), so `pivot` lands on an edge row of the window only\n * when that edge has nothing hidden past it — the marker never overwrites the selected row. */\nfunction windowAround(lines: readonly string[], height: number, pivot: number, theme: Theme): readonly string[] {\n\tif (lines.length <= height) return lines;\n\tconst start = Math.max(0, Math.min(pivot - Math.floor(height / 2), lines.length - height));\n\tconst end = start + height;\n\tconst windowed = lines.slice(start, end);\n\tif (height < 2) return windowed;\n\tconst pivotOffset = pivot - start;\n\tconst marked = windowed.slice();\n\tif (start > 0 && pivotOffset !== 0) {\n\t\tmarked[0] = theme.fg(\"muted\", `↑ ${start} more`);\n\t}\n\tif (end < lines.length && pivotOffset !== marked.length - 1) {\n\t\tmarked[marked.length - 1] = theme.fg(\"muted\", `↓ ${lines.length - end} more`);\n\t}\n\treturn marked;\n}\n\nfunction padLines(lines: readonly string[], height: number): string[] {\n\tif (lines.length >= height) return lines.slice(0, height);\n\treturn [...lines, ...Array.from({ length: height - lines.length }, () => \"\")];\n}\n\ninterface PauseAnchor {\n\tseq: number;\n\tlineInItem: number;\n}\n\n/** Resolves a pause anchor back to an absolute window-end line (exclusive), against the item line\n * ranges from the most recent render. If the anchored item was evicted, clamps to just past the\n * first still-kept item instead of drifting the view forward by the wrong amount. */\nfunction resolvePauseEndLine(anchor: PauseAnchor, ranges: readonly TranscriptLineRange[], totalLines: number): number {\n\tconst range = ranges.find((r) => r.seq === anchor.seq);\n\tif (range) return clamp(range.start + anchor.lineInItem + 1, 0, totalLines);\n\tconst first = ranges[0];\n\treturn first ? clamp(first.start + 1, 0, totalLines) : 0;\n}\n\n/** Converts an absolute window-end line (exclusive) into a pause anchor on whichever item renders\n * that line, so the anchor survives evictions that shift line numbers. */\nfunction anchorAtEndLine(endLine: number, ranges: readonly TranscriptLineRange[]): PauseAnchor | undefined {\n\tconst lastVisibleLine = endLine - 1;\n\tfor (const range of ranges) {\n\t\tif (lastVisibleLine >= range.start && lastVisibleLine < range.end) {\n\t\t\treturn { seq: range.seq, lineInItem: lastVisibleLine - range.start };\n\t\t}\n\t}\n\tconst last = ranges[ranges.length - 1];\n\treturn last ? { seq: last.seq, lineInItem: Math.max(0, last.end - last.start - 1) } : undefined;\n}\n\n/** Truncates the title (never the right segment or the closing corner) so the border always stays\n * closed, instead of handing the whole assembled string to `fitLine` and letting it cut off\n * whichever happens to sit at the end. */\nfunction borderTop(title: string, right: string, width: number): string {\n\tconst inner = Math.max(0, width - 2);\n\tlet rightSeg = right ? ` ${right} ` : \"\";\n\tlet rightWidth = visibleWidth(rightSeg);\n\tif (rightWidth > inner) {\n\t\trightSeg = \"\";\n\t\trightWidth = 0;\n\t}\n\tconst minDashes = 1;\n\tconst titleBudget = Math.max(0, inner - rightWidth - minDashes);\n\tconst titleSeg = fitLine(` ${title} `, titleBudget);\n\tconst dashes = Math.max(0, inner - visibleWidth(titleSeg) - rightWidth);\n\treturn `┌${titleSeg}${\"─\".repeat(dashes)}${rightSeg}┐`;\n}\n\nfunction borderBottom(width: number): string {\n\treturn fitLine(`└${\"─\".repeat(Math.max(0, width - 2))}┘`, width);\n}\n\nfunction sideLine(content: string, width: number): string {\n\tconst inner = Math.max(0, width - 4);\n\treturn fitLine(`│ ${padToWidth(content, inner)} │`, width);\n}\n\nfunction runsRowKey(row: RunsRow): string {\n\tif (row.kind === \"saved\") return `saved:${row.saved?.name ?? \"\"}`;\n\treturn `run:${row.runId ?? \"\"}`;\n}\n\nfunction groupLabel(kind: RunsRow[\"kind\"]): string {\n\tswitch (kind) {\n\t\tcase \"live\":\n\t\t\treturn \"Live\";\n\t\tcase \"earlier\":\n\t\t\treturn \"Earlier in this session\";\n\t\tcase \"saved\":\n\t\t\treturn \"Saved workflows\";\n\t}\n}\n\n/** Drops a trailing agent-count suffix (e.g. \"subagent parallel · 2 agents\"): `runSubtitleText`\n * is the single place that shows the count, so the title must not repeat it. */\nconst TRAILING_AGENT_COUNT = / · \\d+ agents?$/;\n\n/** The phase marker is only meaningful while the run is still progressing through phases; a\n * finished or cancelled run has no \"current\" phase left, so showing one would misread as still\n * running. */\nfunction isCurrentlyPhased(status: RunSnapshot[\"status\"]): boolean {\n\treturn status === \"running\";\n}\n\nfunction runTitleText(snapshot: RunSnapshot): string {\n\tif (snapshot.kind === \"workflow\") return `workflow ${snapshot.workflow?.name ?? snapshot.title}`;\n\tif (snapshot.kind === \"duet\") return `duet · ${snapshot.title}`;\n\treturn snapshot.title.replace(TRAILING_AGENT_COUNT, \"\");\n}\n\nfunction runSubtitleText(snapshot: RunSnapshot): string {\n\tif (snapshot.kind === \"workflow\") {\n\t\tconst phase =\n\t\t\tisCurrentlyPhased(snapshot.status) && snapshot.currentPhase !== undefined\n\t\t\t\t? snapshot.phases[snapshot.currentPhase]\n\t\t\t\t: undefined;\n\t\tif (phase) return `▸ ${phase.title}`;\n\t\tconst n = snapshot.phases.length;\n\t\treturn n > 0 ? `${n} phase${n === 1 ? \"\" : \"s\"}` : \"\";\n\t}\n\tconst n = snapshot.agents.length;\n\treturn `${n} agent${n === 1 ? \"\" : \"s\"}`;\n}\n\n/** `› ` (or ` `) + glyph, always a fixed-width cell outside the title's flex cell: the cursor and\n * status glyph must stay visible even when nothing else does. `columns()`'s own 1-column gap\n * supplies the separator space before the title, matching `› ● label` elsewhere in this file. */\nconst RUNS_ROW_CURSOR_WIDTH = 3;\n\nfunction savedWorkflowSourceLabel(source: SavedWorkflowSummary[\"source\"]): string {\n\treturn source === \"project\" ? \"proj\" : \"user\";\n}\n\n/** Drops or shrinks the runs-view row's optional columns as `width` decreases, in order of least\n * useful first (tokens, then cost, then the subtitle, then counts and duration), so the title (the\n * flex cell) keeps a usable share of the row instead of being squeezed to nothing by fixed columns\n * that no longer fit. */\nfunction runsRowOptionalWidths(width: number): {\n\tsubtitle: number;\n\tcounts: number;\n\tduration: number;\n\ttokens: number;\n\tcost: number;\n} {\n\treturn {\n\t\tsubtitle: width >= 80 ? 16 : width >= 60 ? 10 : 0,\n\t\tcounts: width >= 56 ? 10 : 0,\n\t\tduration: width >= 50 ? 7 : 0,\n\t\ttokens: width >= 70 ? 6 : 0,\n\t\tcost: width >= 60 ? 7 : 0,\n\t};\n}\n\n/** The agent detail header's right side (§12.2: `◐ thinking 0:41`) shows only the current activity\n * keyword, not `row.now`'s full content: `row.now` for a thinking/writing agent is `\"thinking · <the\n * actual text>\"`, and showing that verbatim in the border would leak hidden-thinking content past the\n * `app.thinking.toggle` gate that otherwise hides it in the transcript below. */\nfunction headerActivityText(row: AgentSnapshotRow): string {\n\tconst now = row.now ? oneLine(sanitizeForDisplay(row.now)) : undefined;\n\tif (!now) return row.status;\n\tconst separator = now.indexOf(\" · \");\n\treturn separator === -1 ? now : now.slice(0, separator);\n}\n\n/** Mirrors `headerActivityText`'s thinking-keyword cut: the run view's agent list and the split\n * view's left pane must not leak hidden thinking content into the \"now\" column either (§12.2 shows\n * just `thinking` there), even though the same column shows the activity in full once thinking is\n * visible. */\nfunction agentRowRightText(row: AgentSnapshotRow, showThinking: boolean): string {\n\tif (row.now) {\n\t\tconst now = oneLine(sanitizeForDisplay(row.now));\n\t\t// \"thinking\" is the only `computeNowLine()` activity word that can be followed by child-written\n\t\t// text; checking the prefix (not the full `\"thinking · \"` separator) also catches the edge case\n\t\t// where the thinking block is still empty and `oneLine()` has trimmed the trailing separator.\n\t\tif (!showThinking && now.startsWith(\"thinking\")) return \"thinking\";\n\t\treturn now;\n\t}\n\tif (row.statusLine) return oneLine(sanitizeForDisplay(row.statusLine));\n\tif (row.error) return oneLine(sanitizeForDisplay(row.error));\n\tswitch (row.status) {\n\t\tcase \"queued\":\n\t\t\treturn \"queued\";\n\t\tcase \"pending\":\n\t\t\treturn row.step !== undefined && row.step > 1 ? `waits for step ${row.step - 1}` : \"not run\";\n\t\tcase \"skipped\":\n\t\t\treturn \"not run\";\n\t\tcase \"cancelled\":\n\t\t\treturn row.cancelReason === \"time\" ? \"cancelled (time limit)\" : \"cancelled\";\n\t\tcase \"done\":\n\t\t\t// A finished agent with no `now` and no `STATUS:` line still has output worth showing\n\t\t\t// (§11.3's tool-row fallback does the same): the first line beats a blank column.\n\t\t\treturn row.output ? oneLine(sanitizeForDisplay(row.output)) : \"\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nconst COUNT_ORDER: readonly AgentStatus[] = [\"running\", \"done\", \"failed\", \"cancelled\", \"queued\", \"pending\", \"skipped\"];\n\nfunction formatCounts(theme: Theme, now: number, counts: Record<AgentStatus, number>): string {\n\tconst parts: string[] = [];\n\tfor (const status of COUNT_ORDER) {\n\t\tconst n = counts[status];\n\t\tif (n > 0) parts.push(`${statusGlyph(status, theme, { now, animate: false })}${n}`);\n\t}\n\treturn parts.join(\" \");\n}\n\nfunction isFinishedAgentStatus(status: AgentStatus): boolean {\n\treturn status === \"done\" || status === \"failed\" || status === \"cancelled\" || status === \"skipped\";\n}\n\n/**\n * The `alt+a` popup. `render()` recomputes the live runs-view list, the current run's agent list\n * and the selected agent's transcript window on every call, since those come straight from the\n * live store; nothing here owns a timer. Dirtiness (when to re-render at all) is the caller's job,\n * driven by `session.store`'s flush notifications.\n */\nexport class PolyphaseInspector implements Component, Focusable {\n\tfocused = false;\n\n\tprivate readonly deps: InspectorDeps;\n\tprivate readonly transcriptCache: TranscriptLineCache;\n\tprivate readonly unsubscribe: () => void;\n\n\tprivate mode: ViewMode = \"runs\";\n\tprivate currentRunId: string | undefined;\n\tprivate currentAgentIndex: number | undefined;\n\tprivate runsRows: RunsRow[] = [];\n\tprivate runsSelection = 0;\n\tprivate runsSelectionKey: string | undefined;\n\tprivate runSelection = 0;\n\tprivate following = true;\n\t/** Anchors the paused window to an item (`seq`) and a line within it, not an absolute line index:\n\t * the transcript keeps at most `maxItems`, so a paused run that keeps producing output evicts\n\t * older items and shifts every absolute line index after them. Resolved back to an absolute line\n\t * on each render via `resolvePauseEndLine`. See `renderAgentDetailBody`. */\n\tprivate pauseAnchor: PauseAnchor | undefined;\n\tprivate lastTranscriptTotalLines: number | undefined;\n\tprivate lastTranscriptRanges: readonly TranscriptLineRange[] = [];\n\tprivate lastDetailBodyHeight: number | undefined;\n\tprivate lastRenderWidth = 0;\n\tprivate showThinking: boolean;\n\tprivate showToolPreviews = false;\n\tprivate armed: { action: \"cancelAgent\" | \"cancelRun\"; runId: string; agentIndex?: number } | undefined;\n\tprivate footerNotice: string | undefined;\n\n\tconstructor(deps: InspectorDeps) {\n\t\tthis.deps = deps;\n\t\tthis.showThinking = deps.showThinking;\n\t\tthis.transcriptCache = new TranscriptLineCache(deps.theme);\n\t\tthis.resolveInitialView();\n\t\tthis.unsubscribe = deps.session.store.subscribe((change) => {\n\t\t\tif (change.type === \"disposed\") {\n\t\t\t\tthis.deps.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.deps.tui.requestRender();\n\t\t});\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tthis.runsRows = this.buildRunsRows();\n\t\t\tthis.runsSelection = this.resolveRunsSelectionIndex(this.runsRows);\n\t\t}\n\t\tconst kb = this.deps.keybindings;\n\n\t\tif (kb.matches(data, \"app.polyphase.inspector\")) {\n\t\t\tthis.deps.close();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"app.polyphase.cancelAgent\")) {\n\t\t\tthis.handleCancelKey(\"cancelAgent\");\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"app.polyphase.cancelRun\")) {\n\t\t\tthis.handleCancelKey(\"cancelRun\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.armed = undefined;\n\t\tthis.footerNotice = undefined;\n\n\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.goBack();\n\t\t} else if (kb.matches(data, \"app.thinking.toggle\")) {\n\t\t\tthis.showThinking = !this.showThinking;\n\t\t} else if (kb.matches(data, \"app.tools.expand\")) {\n\t\t\tthis.showToolPreviews = !this.showToolPreviews;\n\t\t} else if (kb.matches(data, \"app.polyphase.follow\")) {\n\t\t\tthis.toggleFollow();\n\t\t} else if (kb.matches(data, \"app.polyphase.nextAgent\")) {\n\t\t\tthis.cycleAgent(1);\n\t\t} else if (kb.matches(data, \"app.polyphase.previousAgent\")) {\n\t\t\tthis.cycleAgent(-1);\n\t\t} else if (kb.matches(data, \"tui.select.up\")) {\n\t\t\tthis.moveSelection(-1);\n\t\t} else if (kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.moveSelection(1);\n\t\t} else if (kb.matches(data, \"tui.select.pageUp\")) {\n\t\t\tthis.handlePage(-1);\n\t\t} else if (kb.matches(data, \"tui.select.pageDown\")) {\n\t\t\tthis.handlePage(1);\n\t\t} else if (kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tthis.confirmSelection();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tthis.lastRenderWidth = width;\n\t\tconst terminal = this.deps.tui.terminal;\n\t\tif (width < 40 || terminal.rows < 10) {\n\t\t\treturn [fitLine(\"terminal too small for the agent inspector\", width)];\n\t\t}\n\t\tconst height = Math.max(8, terminal.rows - 2);\n\t\tconst bodyHeight = Math.max(1, height - 2);\n\t\tconst innerWidth = Math.max(1, width - 4);\n\n\t\tlet topTitle: string;\n\t\tlet topRight: string;\n\t\tlet bodyLines: string[];\n\n\t\tif (this.mode === \"runs\") {\n\t\t\tthis.runsRows = this.buildRunsRows();\n\t\t\tthis.runsSelection = this.resolveRunsSelectionIndex(this.runsRows);\n\t\t\t// Tracks the selection by identity from the very first render, not only once the user has\n\t\t\t// pressed an arrow key, so a live run inserted above the selection between renders cannot\n\t\t\t// change what a subsequent `enter` opens.\n\t\t\tif (this.runsSelectionKey === undefined) {\n\t\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\t\tthis.runsSelectionKey = row ? runsRowKey(row) : undefined;\n\t\t\t}\n\t\t\tconst liveCount = this.runsRows.filter((row) => row.kind === \"live\").length;\n\t\t\tconst earlierCount = this.runsRows.filter((row) => row.kind === \"earlier\").length;\n\t\t\tconst limiter = this.deps.session.limiter.stats();\n\t\t\ttopTitle = `polyphase · ${liveCount} live · ${earlierCount} earlier · slots ${limiter.active}/${limiter.capacity}`;\n\t\t\ttopRight = keyHint(\"app.polyphase.inspector\", \"close\");\n\t\t\tbodyLines = this.renderRunsBody(innerWidth, bodyHeight);\n\t\t} else if (this.mode === \"run\") {\n\t\t\t// Built once here and threaded through, instead of each of the header and the body methods\n\t\t\t// calling `currentRunSnapshot()`/`currentRunAgents()` again: `snapshotFromRun` runs a regex\n\t\t\t// over every agent's output and hashes the whole details object, so repeating it several\n\t\t\t// times per render on every pump flush is wasted work.\n\t\t\tconst snapshot = this.currentRunSnapshot();\n\t\t\tconst rows = this.sortedAgentsOf(snapshot);\n\t\t\ttopTitle = snapshot ? this.runTitleForHeader(snapshot) : \"run\";\n\t\t\ttopRight = snapshot ? this.runHeaderRight(snapshot) : \"\";\n\t\t\tbodyLines =\n\t\t\t\twidth >= SPLIT_MIN_WIDTH\n\t\t\t\t\t? this.renderSplitBody(innerWidth, bodyHeight, rows)\n\t\t\t\t\t: this.renderRunBody(innerWidth, bodyHeight, snapshot, rows);\n\t\t} else {\n\t\t\tconst snapshot = this.currentRunSnapshot();\n\t\t\tconst rows = this.sortedAgentsOf(snapshot);\n\t\t\tconst row = rows.find((r) => r.i === this.currentAgentIndex);\n\t\t\tconst phaseTitle = row?.phase !== undefined ? snapshot?.phases[row.phase]?.title : undefined;\n\t\t\ttopTitle = row ? `${row.label} · ${row.agentType}${phaseTitle ? ` · ${phaseTitle}` : \"\"}` : \"agent\";\n\t\t\ttopRight = row\n\t\t\t\t? `${statusGlyph(row.status, this.deps.theme, { now: this.now(), animate: false })} ${headerActivityText(row)}${\n\t\t\t\t\t\trow.elapsedMs === undefined ? \"\" : ` ${formatDuration(row.elapsedMs)}`\n\t\t\t\t\t}`\n\t\t\t\t: \"\";\n\t\t\tbodyLines = this.renderAgentDetailBody(this.currentAgentIndex, innerWidth, bodyHeight, rows);\n\t\t}\n\n\t\tconst padded = padLines(bodyLines, bodyHeight);\n\t\treturn [\n\t\t\tborderTop(topTitle, topRight, width),\n\t\t\t...padded.map((line) => sideLine(line, width)),\n\t\t\tborderBottom(width),\n\t\t];\n\t}\n\n\tinvalidate(): void {}\n\n\tdispose(): void {\n\t\tthis.unsubscribe();\n\t}\n\n\tprivate now(): number {\n\t\treturn Date.now();\n\t}\n\n\t// ── Navigation ──────────────────────────────────────────────────────────\n\n\tprivate resolveInitialView(): void {\n\t\tconst initial = this.deps.initial;\n\t\tif (initial.view === \"runs\") {\n\t\t\tthis.mode = \"runs\";\n\t\t\treturn;\n\t\t}\n\t\tif (initial.view === \"run\") {\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.currentRunId = initial.runId;\n\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t\treturn;\n\t\t}\n\t\tif (initial.view === \"agent\") {\n\t\t\tthis.mode = \"agent\";\n\t\t\tthis.currentRunId = initial.runId;\n\t\t\tthis.currentAgentIndex = initial.agentIndex;\n\t\t\treturn;\n\t\t}\n\t\tconst liveRuns = this.deps.session.store.runs().filter((run) => run.status === \"running\");\n\t\tif (liveRuns.length === 1) {\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.currentRunId = liveRuns[0]?.id;\n\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t} else {\n\t\t\tthis.mode = \"runs\";\n\t\t}\n\t}\n\n\tprivate selectFirstActiveAgentForCurrentRun(): void {\n\t\tconst rows = this.currentRunAgents();\n\t\tconst idx = rows.findIndex((row) => row.status === \"running\" || row.status === \"starting\");\n\t\tthis.runSelection = idx === -1 ? 0 : idx;\n\t}\n\n\t/** Resolves the runs-view selection by the identity of the previously selected row (its runId or\n\t * saved-workflow name), not its index, so a live update that reorders rows between a render and the\n\t * next key press does not silently select a different run. Falls back to a clamped index when the\n\t * previous row is gone (e.g. an archived run was pruned). */\n\tprivate resolveRunsSelectionIndex(rows: readonly RunsRow[]): number {\n\t\tif (this.runsSelectionKey !== undefined) {\n\t\t\tconst idx = rows.findIndex((row) => runsRowKey(row) === this.runsSelectionKey);\n\t\t\tif (idx !== -1) return idx;\n\t\t}\n\t\treturn clamp(this.runsSelection, 0, Math.max(0, rows.length - 1));\n\t}\n\n\tprivate resetFollowing(): void {\n\t\tthis.following = true;\n\t\tthis.pauseAnchor = undefined;\n\t}\n\n\tprivate isSplitActive(): boolean {\n\t\treturn this.lastRenderWidth >= SPLIT_MIN_WIDTH;\n\t}\n\n\tprivate goBack(): void {\n\t\tif (this.mode === \"agent\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tconst idx = rows.findIndex((row) => row.i === this.currentAgentIndex);\n\t\t\tif (idx !== -1) this.runSelection = idx;\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.resetFollowing();\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\t// Reselects the run the user came from, so the runs view does not fall back to the index it\n\t\t\t// had before drilling in (which may now point at a different row).\n\t\t\tif (this.currentRunId) this.runsSelectionKey = `run:${this.currentRunId}`;\n\t\t\tthis.mode = \"runs\";\n\t\t\tthis.currentRunId = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.deps.close();\n\t}\n\n\tprivate confirmSelection(): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tif (!row) return;\n\t\t\tif (row.kind === \"saved\") {\n\t\t\t\tconst saved = row.saved;\n\t\t\t\tif (!saved) return;\n\t\t\t\tif (!saved.valid) {\n\t\t\t\t\tthis.footerNotice = `/${saved.name} is invalid`;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst command = saved.command ? `/${saved.command.replace(/^\\//, \"\")} ` : `/workflow ${saved.name} `;\n\t\t\t\tthis.deps.insertCommand(command);\n\t\t\t\tthis.deps.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (row.runId) {\n\t\t\t\tthis.currentRunId = row.runId;\n\t\t\t\tthis.mode = \"run\";\n\t\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tconst row = rows[this.runSelection];\n\t\t\tif (!row) return;\n\t\t\tthis.currentAgentIndex = row.i;\n\t\t\tthis.mode = \"agent\";\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\tprivate moveSelection(delta: number): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tif (this.runsRows.length === 0) return;\n\t\t\tthis.runsSelection = clamp(this.runsSelection + delta, 0, this.runsRows.length - 1);\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tthis.runsSelectionKey = row ? runsRowKey(row) : undefined;\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tconst next = clamp(this.runSelection + delta, 0, rows.length - 1);\n\t\t\tif (next !== this.runSelection) {\n\t\t\t\tthis.runSelection = next;\n\t\t\t\tthis.resetFollowing();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis.scrollTranscript(delta);\n\t}\n\n\t/** Shared by the agent detail view and, in split view, by page keys on the run view: both drive\n\t * the same `following`/`pauseAnchor` pair against whichever agent is currently shown on the\n\t * right. */\n\tprivate scrollTranscript(delta: number): void {\n\t\tconst total = this.lastTranscriptTotalLines ?? 0;\n\t\tconst ranges = this.lastTranscriptRanges;\n\t\tconst visible = Math.max(1, this.lastDetailBodyHeight ?? 1);\n\t\tconst currentEnd = this.pauseAnchor ? resolvePauseEndLine(this.pauseAnchor, ranges, total) : total;\n\t\tif (delta < 0) {\n\t\t\tif (total <= visible) return;\n\t\t\tconst minEnd = Math.min(total, visible);\n\t\t\tthis.pauseAnchor = anchorAtEndLine(Math.max(minEnd, currentEnd + delta), ranges);\n\t\t\tthis.following = false;\n\t\t} else if (delta > 0 && this.pauseAnchor !== undefined) {\n\t\t\tconst next = Math.min(total, currentEnd + delta);\n\t\t\tif (next >= total) {\n\t\t\t\tthis.pauseAnchor = undefined;\n\t\t\t\tthis.following = true;\n\t\t\t} else {\n\t\t\t\tthis.pauseAnchor = anchorAtEndLine(next, ranges);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Page keys scroll the right pane in split view (§12.2) instead of moving the left selection by\n\t * a page. Up/down always move the left selection; only page keys are redirected. */\n\tprivate handlePage(direction: 1 | -1): void {\n\t\tif (this.mode === \"run\" && this.isSplitActive()) {\n\t\t\tthis.scrollTranscript(direction * PAGE_SIZE);\n\t\t\treturn;\n\t\t}\n\t\tthis.moveSelection(direction * PAGE_SIZE);\n\t}\n\n\tprivate cycleAgent(direction: 1 | -1): void {\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tthis.runSelection = (this.runSelection + direction + rows.length) % rows.length;\n\t\t\tthis.resetFollowing();\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"agent\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tconst curIdx = rows.findIndex((row) => row.i === this.currentAgentIndex);\n\t\t\tconst nextIdx = ((curIdx === -1 ? 0 : curIdx) + direction + rows.length) % rows.length;\n\t\t\tthis.currentAgentIndex = rows[nextIdx]?.i;\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\tprivate toggleFollow(): void {\n\t\tif (this.mode !== \"agent\" && !(this.mode === \"run\" && this.isSplitActive())) return;\n\t\tif (this.following) {\n\t\t\tconst anchor = anchorAtEndLine(this.lastTranscriptTotalLines ?? 0, this.lastTranscriptRanges);\n\t\t\t// An empty transcript (no ranges yet, or the archived/retention-dropped summary body, which\n\t\t\t// never sets any ranges) has nothing to anchor a pause to. Pressing `f` must stay a no-op\n\t\t\t// then, not flip into a paused state the view can never escape: `scrollTranscript` only\n\t\t\t// resumes following once `pauseAnchor` advances to the end, which it can never do without an\n\t\t\t// anchor.\n\t\t\tif (anchor === undefined) return;\n\t\t\tthis.pauseAnchor = anchor;\n\t\t\tthis.following = false;\n\t\t} else {\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\t// ── Two-press cancel (§12.4) ────────────────────────────────────────────\n\n\tprivate handleCancelKey(action: \"cancelAgent\" | \"cancelRun\"): void {\n\t\tconst target = this.cancelTarget(action);\n\t\tif (!target) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst sameTarget =\n\t\t\tthis.armed?.action === action &&\n\t\t\tthis.armed.runId === target.runId &&\n\t\t\tthis.armed.agentIndex === target.agentIndex;\n\t\tif (sameTarget) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = undefined;\n\t\t\tif (action === \"cancelAgent\" && target.agentIndex !== undefined) {\n\t\t\t\tthis.deps.session.store.cancelAgent(target.runId, target.agentIndex);\n\t\t\t} else {\n\t\t\t\tthis.deps.session.store.cancelRun(target.runId);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (target.finished) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = \"already finished\";\n\t\t\treturn;\n\t\t}\n\t\tthis.armed = { action, runId: target.runId, agentIndex: target.agentIndex };\n\t\tthis.footerNotice =\n\t\t\taction === \"cancelAgent\" ? `press x again to cancel ${target.label}` : \"press X again to cancel the run\";\n\t}\n\n\tprivate cancelTarget(action: \"cancelAgent\" | \"cancelRun\"): CancelTarget | undefined {\n\t\tif (action === \"cancelAgent\") {\n\t\t\tif (this.mode === \"run\") {\n\t\t\t\tconst row = this.currentRunAgents()[this.runSelection];\n\t\t\t\tif (!row || !this.currentRunId) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\trunId: this.currentRunId,\n\t\t\t\t\tagentIndex: row.i,\n\t\t\t\t\tlabel: row.label,\n\t\t\t\t\tfinished: isFinishedAgentStatus(row.status),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (this.mode === \"agent\") {\n\t\t\t\tconst row = this.currentAgentRow();\n\t\t\t\tif (!row || !this.currentRunId) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\trunId: this.currentRunId,\n\t\t\t\t\tagentIndex: row.i,\n\t\t\t\t\tlabel: row.label,\n\t\t\t\t\tfinished: isFinishedAgentStatus(row.status),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\tif (this.mode === \"runs\") {\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tif (!row || row.kind === \"saved\" || !row.runId || !row.snapshot) return undefined;\n\t\t\treturn { runId: row.runId, label: row.snapshot.title, finished: row.snapshot.status !== \"running\" };\n\t\t}\n\t\tconst snapshot = this.currentRunSnapshot();\n\t\tif (!snapshot || !this.currentRunId) return undefined;\n\t\treturn { runId: this.currentRunId, label: snapshot.title, finished: snapshot.status !== \"running\" };\n\t}\n\n\t// ── Data access ─────────────────────────────────────────────────────────\n\n\tprivate buildRunsRows(): RunsRow[] {\n\t\tconst store = this.deps.session.store;\n\t\tconst allRuns = store.runs();\n\t\tconst liveRuns = allRuns.filter((run) => run.status === \"running\");\n\t\tconst finishedLive = allRuns.filter((run) => run.status !== \"running\");\n\t\tconst knownIds = new Set([...liveRuns, ...finishedLive].map((run) => run.id));\n\t\tconst archived = this.deps.getArchivedRuns().filter((entry) => !knownIds.has(entry.runId));\n\n\t\tconst rows: RunsRow[] = [];\n\t\tfor (const run of liveRuns) {\n\t\t\trows.push({\n\t\t\t\tkind: \"live\",\n\t\t\t\trunId: run.id,\n\t\t\t\tsnapshot: sanitizeSnapshot(\n\t\t\t\t\tsnapshotFromRun(run, { now: this.now(), tailItems: 0, limiter: this.deps.session.limiter.stats() }),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\tfor (const run of finishedLive) {\n\t\t\trows.push({\n\t\t\t\tkind: \"earlier\",\n\t\t\t\trunId: run.id,\n\t\t\t\tsnapshot: sanitizeSnapshot(snapshotFromRun(run, { now: this.now(), tailItems: 0 })),\n\t\t\t});\n\t\t}\n\t\tfor (const entry of archived) {\n\t\t\trows.push({\n\t\t\t\tkind: \"earlier\",\n\t\t\t\trunId: entry.runId,\n\t\t\t\tsnapshot: sanitizeSnapshot(snapshotFromDetails(entry.details, { now: this.now() })),\n\t\t\t});\n\t\t}\n\t\tfor (const saved of this.deps.getSavedWorkflows()) {\n\t\t\trows.push({ kind: \"saved\", saved });\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate currentRunSnapshot(): RunSnapshot | undefined {\n\t\tif (!this.currentRunId) return undefined;\n\t\tconst liveRun = this.deps.session.store.getRun(this.currentRunId);\n\t\tif (liveRun) {\n\t\t\treturn sanitizeSnapshot(\n\t\t\t\tsnapshotFromRun(liveRun, { now: this.now(), tailItems: 0, limiter: this.deps.session.limiter.stats() }),\n\t\t\t);\n\t\t}\n\t\tconst archived = this.deps.getArchivedRuns().find((entry) => entry.runId === this.currentRunId);\n\t\treturn archived ? sanitizeSnapshot(snapshotFromDetails(archived.details, { now: this.now() })) : undefined;\n\t}\n\n\tprivate sortedAgentsOf(snapshot: RunSnapshot | undefined): AgentSnapshotRow[] {\n\t\tif (!snapshot) return [];\n\t\treturn [...snapshot.agents].sort((a, b) => a.i - b.i);\n\t}\n\n\tprivate currentRunAgents(): AgentSnapshotRow[] {\n\t\treturn this.sortedAgentsOf(this.currentRunSnapshot());\n\t}\n\n\tprivate currentAgentRow(): AgentSnapshotRow | undefined {\n\t\tif (this.currentAgentIndex === undefined) return undefined;\n\t\treturn this.currentRunAgents().find((row) => row.i === this.currentAgentIndex);\n\t}\n\n\tprivate currentAgentTranscriptFor(\n\t\tagentIndex: number,\n\t): { items: readonly TranscriptItem[]; dropped: number } | undefined {\n\t\tif (!this.currentRunId) return undefined;\n\t\tconst run = this.deps.session.store.getRun(this.currentRunId);\n\t\tconst agent = run?.agents[agentIndex];\n\t\t// Retention drops every agent's transcript on a finished run once it falls past\n\t\t// `keepTranscriptRuns`; `undefined` here sends the caller to the archived-style summary body\n\t\t// (status, output, error, the \"only kept while in memory\" note) instead of an empty transcript.\n\t\tif (!run || !agent || run.transcriptsDropped) return undefined;\n\t\treturn { items: agent.state.transcript, dropped: agent.state.droppedItems };\n\t}\n\n\t// ── Rendering ───────────────────────────────────────────────────────────\n\n\tprivate formatRunsRow(row: RunsRow, width: number, selected: boolean): string {\n\t\tconst cursor = selected ? \"› \" : \" \";\n\t\tif (row.kind === \"saved\" && row.saved) {\n\t\t\tconst saved = row.saved;\n\t\t\t// `name`/`description` come from the saved script's own meta block (`workflow/meta.ts`), the\n\t\t\t// same kind of script-supplied text `sanitizeSnapshot` cleans for live/archived runs.\n\t\t\tconst nameText = `${cursor}/${sanitizeChildText(saved.name)}`;\n\t\t\treturn columns(\n\t\t\t\t[\n\t\t\t\t\t{ text: saved.valid ? nameText : this.deps.theme.fg(\"error\", `${nameText} invalid`), width: 18 },\n\t\t\t\t\t{ text: sanitizeChildText(saved.description), width: \"flex\" },\n\t\t\t\t\t{ text: savedWorkflowSourceLabel(saved.source), width: 4, align: \"right\" },\n\t\t\t\t],\n\t\t\t\twidth,\n\t\t\t);\n\t\t}\n\t\tconst snapshot = row.snapshot;\n\t\tif (!snapshot) return fitLine(`${cursor}?`, width);\n\t\tconst glyph = statusGlyph(snapshot.status, this.deps.theme, { now: this.now(), animate: false });\n\t\tconst optional = runsRowOptionalWidths(width);\n\t\t// The cursor, glyph and title are fixed/flex cells ahead of every optional column, so they\n\t\t// always render, even at widths where every optional column below has been dropped.\n\t\tconst cells: ColumnCell[] = [\n\t\t\t{ text: `${cursor}${glyph}`, width: RUNS_ROW_CURSOR_WIDTH },\n\t\t\t{ text: runTitleText(snapshot), width: \"flex\" },\n\t\t];\n\t\tif (optional.subtitle > 0) cells.push({ text: runSubtitleText(snapshot), width: optional.subtitle });\n\t\tif (optional.counts > 0) {\n\t\t\tcells.push({ text: formatCounts(this.deps.theme, this.now(), snapshot.counts), width: optional.counts });\n\t\t}\n\t\tif (optional.duration > 0) {\n\t\t\tcells.push({ text: formatDuration(snapshot.elapsedMs), width: optional.duration, align: \"right\" });\n\t\t}\n\t\tif (optional.tokens > 0) {\n\t\t\tcells.push({\n\t\t\t\ttext: snapshot.tokens > 0 ? formatTokens(snapshot.tokens) : \"\",\n\t\t\t\twidth: optional.tokens,\n\t\t\t\talign: \"right\",\n\t\t\t});\n\t\t}\n\t\tif (optional.cost > 0) cells.push({ text: formatCost(snapshot.cost), width: optional.cost, align: \"right\" });\n\t\treturn columns(cells, width);\n\t}\n\n\tprivate renderRunsBody(width: number, height: number): string[] {\n\t\tconst rows = this.runsRows;\n\t\tconst lines: string[] = [];\n\t\tconst lineForRow: number[] = [];\n\t\tlet lastKind: RunsRow[\"kind\"] | undefined;\n\t\trows.forEach((row, idx) => {\n\t\t\tif (row.kind !== lastKind) {\n\t\t\t\tlines.push(this.deps.theme.bold(groupLabel(row.kind)));\n\t\t\t\tlastKind = row.kind;\n\t\t\t}\n\t\t\tlineForRow[idx] = lines.length;\n\t\t\tlines.push(this.formatRunsRow(row, width, idx === this.runsSelection));\n\t\t});\n\t\tif (rows.length === 0) {\n\t\t\tlines.push('No agents yet. Put \"polyphase\" in a prompt or run /workflow <name>.');\n\t\t}\n\t\tconst pivot = lineForRow[this.runsSelection] ?? 0;\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tconst windowed = padLines(windowAround(lines, contentHeight, pivot, this.deps.theme), contentHeight);\n\t\treturn [...windowed, this.footerLine(this.runsHintLine(), width)];\n\t}\n\n\tprivate formatAgentRow(row: AgentSnapshotRow, width: number, selected: boolean): string {\n\t\tconst cursor = selected ? \"› \" : \" \";\n\t\tconst glyph = statusGlyph(row.status, this.deps.theme, { now: this.now(), animate: false });\n\t\tconst model = formatModelLabel(row, { withProvider: false });\n\t\tconst cells: ColumnCell[] = [\n\t\t\t{ text: `${cursor}${glyph} ${row.label}`, width: 18 },\n\t\t\t{ text: model, width: 20 },\n\t\t];\n\t\t// Dropped below 60 columns, the same threshold `layoutRun` uses for its elapsed column: at\n\t\t// the 40-column split-pane width there is no room for a 5th fixed cell ahead of the flex one.\n\t\tif (width >= 60) {\n\t\t\tcells.push({\n\t\t\t\ttext: row.elapsedMs === undefined ? \"\" : formatDuration(row.elapsedMs),\n\t\t\t\twidth: 5,\n\t\t\t\talign: \"right\",\n\t\t\t});\n\t\t}\n\t\tcells.push({ text: agentRowRightText(row, this.showThinking), width: \"flex\" });\n\t\treturn columns(cells, width);\n\t}\n\n\tprivate runTitleForHeader(snapshot: RunSnapshot): string {\n\t\tconst base = runTitleText(snapshot);\n\t\tif (snapshot.kind === \"workflow\" && isCurrentlyPhased(snapshot.status) && snapshot.currentPhase !== undefined) {\n\t\t\tconst phase = snapshot.phases[snapshot.currentPhase];\n\t\t\tif (phase) return `${base} ▸ ${phase.title}`;\n\t\t}\n\t\treturn base;\n\t}\n\n\tprivate runHeaderRight(snapshot: RunSnapshot): string {\n\t\tconst parts = [formatCounts(this.deps.theme, this.now(), snapshot.counts), formatDuration(snapshot.elapsedMs)];\n\t\tif (snapshot.tokens > 0) parts.push(formatTokens(snapshot.tokens));\n\t\tconst cost = formatCost(snapshot.cost);\n\t\tif (cost) parts.push(cost);\n\t\treturn parts.filter((part) => part.length > 0).join(\" \");\n\t}\n\n\tprivate renderRunBody(\n\t\twidth: number,\n\t\theight: number,\n\t\tsnapshot: RunSnapshot | undefined,\n\t\trows: AgentSnapshotRow[],\n\t): string[] {\n\t\tif (!snapshot) return [this.deps.theme.fg(\"muted\", \"run not found\")];\n\t\tthis.runSelection = clamp(this.runSelection, 0, Math.max(0, rows.length - 1));\n\n\t\tconst lines: string[] = [];\n\t\tconst lineForAgent: number[] = [];\n\t\tif (snapshot.phases.length > 0) {\n\t\t\t// Agents spawned before any phase()/agent({phase}) call (§13.3) carry no phase index; they\n\t\t\t// are still selectable, so they get an ungrouped block ahead of the phase list instead of\n\t\t\t// being silently dropped from the view.\n\t\t\trows.forEach((row, idx) => {\n\t\t\t\tif (row.phase !== undefined) return;\n\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\tlines.push(this.formatAgentRow(row, width, idx === this.runSelection));\n\t\t\t});\n\t\t\tfor (const phase of snapshot.phases) {\n\t\t\t\tlines.push(\n\t\t\t\t\tcolumns(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttext: `${statusGlyph(phase.status, this.deps.theme, { now: this.now(), animate: false })} ${phase.index + 1} ${phase.title}`,\n\t\t\t\t\t\t\t\twidth: \"flex\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ text: `${phase.done}/${phase.total}`, width: 7, align: \"right\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttext: phase.elapsedMs === undefined ? \"\" : formatDuration(phase.elapsedMs),\n\t\t\t\t\t\t\t\twidth: 7,\n\t\t\t\t\t\t\t\talign: \"right\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\trows.forEach((row, idx) => {\n\t\t\t\t\tif (row.phase !== phase.index) return;\n\t\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\t\tlines.push(` ${this.formatAgentRow(row, Math.max(1, width - 4), idx === this.runSelection)}`);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\trows.forEach((row, idx) => {\n\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\tconst prefix = row.step !== undefined ? `${row.step} ` : \"\";\n\t\t\t\tlines.push(\n\t\t\t\t\t`${prefix}${this.formatAgentRow(row, Math.max(1, width - prefix.length), idx === this.runSelection)}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tif (snapshot.log.length > 0) {\n\t\t\tlines.push(`» ${oneLine(sanitizeForDisplay(snapshot.log[snapshot.log.length - 1] ?? \"\"))}`);\n\t\t} else if (snapshot.resultPreview && snapshot.status !== \"running\") {\n\t\t\tlines.push(`→ ${oneLine(sanitizeForDisplay(snapshot.resultPreview))}`);\n\t\t}\n\n\t\tconst pivot = lineForAgent[this.runSelection] ?? 0;\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tconst windowed = padLines(windowAround(lines, contentHeight, pivot, this.deps.theme), contentHeight);\n\t\treturn [...windowed, this.footerLine(this.runHintLine(), width)];\n\t}\n\n\tprivate renderSplitBody(width: number, height: number, rows: AgentSnapshotRow[]): string[] {\n\t\tconst rightWidth = Math.max(1, width - SPLIT_LEFT_WIDTH - 1);\n\t\tthis.runSelection = clamp(this.runSelection, 0, Math.max(0, rows.length - 1));\n\t\tconst leftLines = rows.map((row, idx) =>\n\t\t\tfitLine(this.formatAgentRow(row, SPLIT_LEFT_WIDTH, idx === this.runSelection), SPLIT_LEFT_WIDTH),\n\t\t);\n\t\tconst selectedAgentIndex = rows[this.runSelection]?.i;\n\t\tconst rightLines = this.renderAgentDetailBody(selectedAgentIndex, rightWidth, height, rows);\n\t\t// Windowed the same way `renderRunBody` windows the flat agent list, so a run with more agents\n\t\t// than the pane has rows keeps the `›` cursor on screen instead of scrolling it off the top.\n\t\tconst paddedLeft = padLines(windowAround(leftLines, height, this.runSelection, this.deps.theme), height);\n\t\tconst paddedRight = padLines(rightLines, height);\n\t\treturn paddedLeft.map((line, idx) => `${padToWidth(line, SPLIT_LEFT_WIDTH)}│${paddedRight[idx] ?? \"\"}`);\n\t}\n\n\tprivate renderAgentDetailBody(\n\t\tagentIndex: number | undefined,\n\t\twidth: number,\n\t\theight: number,\n\t\trows: AgentSnapshotRow[],\n\t): string[] {\n\t\tconst footerFallback = this.agentHintLine();\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tif (agentIndex === undefined) {\n\t\t\treturn [\n\t\t\t\t...padLines([this.deps.theme.fg(\"muted\", \"no agent selected\")], contentHeight),\n\t\t\t\tthis.footerLine(footerFallback, width),\n\t\t\t];\n\t\t}\n\t\tconst row = rows.find((r) => r.i === agentIndex);\n\t\tif (!row) {\n\t\t\treturn [\n\t\t\t\t...padLines([this.deps.theme.fg(\"muted\", \"agent not found\")], contentHeight),\n\t\t\t\tthis.footerLine(footerFallback, width),\n\t\t\t];\n\t\t}\n\n\t\tconst header: string[] = [];\n\t\tconst modelLabel = formatModelLabel(row, { withProvider: true, withSource: true });\n\t\tconst confirmText = row.modelConfirmed ? \"confirmed\" : \"unconfirmed\";\n\t\tconst tokensText = row.tokens > 0 ? ` · ${formatTokens(row.tokens)} tok` : \"\";\n\t\tconst costText = row.cost > 0 ? ` · ${formatCost(row.cost)}` : \"\";\n\t\tconst turnsText = `${row.turns} turn${row.turns === 1 ? \"\" : \"s\"}`;\n\t\tconst toolsText = `${row.toolCalls} tool${row.toolCalls === 1 ? \"\" : \"s\"}`;\n\t\theader.push(oneLine(`${modelLabel} · ${confirmText} · ${turnsText} · ${toolsText}${tokensText}${costText}`));\n\t\theader.push(`task ${oneLine(row.task)}`);\n\t\theader.push(\"─\".repeat(Math.max(0, width)));\n\n\t\tconst footer = this.footerLine(this.agentHintLine(row.status), width);\n\t\tconst transcript = this.currentAgentTranscriptFor(agentIndex);\n\t\tif (!transcript) {\n\t\t\tconst OUTPUT_PREVIEW_MAX_LINES = 8;\n\t\t\tlet statusLines = row.statusLine ? 1 : 0;\n\t\t\tlet errorLines = row.error ? 1 : 0;\n\t\t\tconst noteLines = 1;\n\t\t\t// The note explains why the transcript is gone, so it must survive trimming even at the\n\t\t\t// smallest supported height: reserve header + note first, then drop error, then status,\n\t\t\t// before giving any remaining budget to the output preview. `padLines` below only pads or\n\t\t\t// truncates from the end, so whatever we build here must already fit `contentHeight`.\n\t\t\tif (header.length + statusLines + errorLines + noteLines > contentHeight && errorLines > 0) {\n\t\t\t\terrorLines = 0;\n\t\t\t}\n\t\t\tif (header.length + statusLines + errorLines + noteLines > contentHeight && statusLines > 0) {\n\t\t\t\tstatusLines = 0;\n\t\t\t}\n\t\t\tconst outputBudget = row.output\n\t\t\t\t? Math.max(0, contentHeight - header.length - statusLines - errorLines - noteLines - 1)\n\t\t\t\t: 0;\n\t\t\tconst body = [...header];\n\t\t\tif (statusLines > 0 && row.statusLine) {\n\t\t\t\tbody.push(fitLine(`status ${oneLine(sanitizeForDisplay(row.statusLine))}`, width));\n\t\t\t}\n\t\t\tif (row.output && outputBudget > 0) {\n\t\t\t\tbody.push(\"output\");\n\t\t\t\tbody.push(\n\t\t\t\t\t...wrapTextWithAnsi(sanitizeForDisplay(row.output), Math.max(1, width - 2))\n\t\t\t\t\t\t.slice(0, Math.min(OUTPUT_PREVIEW_MAX_LINES, outputBudget))\n\t\t\t\t\t\t.map((line) => fitLine(` ${line}`, width)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (errorLines > 0 && row.error) body.push(fitLine(`error ${oneLine(sanitizeForDisplay(row.error))}`, width));\n\t\t\tbody.push(this.deps.theme.fg(\"muted\", \"Live transcript is only kept while the run is in memory.\"));\n\t\t\tthis.lastTranscriptTotalLines = undefined;\n\t\t\tthis.lastTranscriptRanges = [];\n\t\t\tthis.lastDetailBodyHeight = undefined;\n\t\t\treturn [...padLines(body, contentHeight), footer];\n\t\t}\n\n\t\tconst owner = `${this.currentRunId}:${agentIndex}`;\n\t\tconst transcriptLines = this.transcriptCache.linesFor(owner, transcript.items, transcript.dropped, {\n\t\t\twidth,\n\t\t\tshowThinking: this.showThinking,\n\t\t\tshowToolPreviews: this.showToolPreviews,\n\t\t\tnow: this.now(),\n\t\t});\n\t\tconst tail = tailWindowOf(transcriptLines);\n\t\tthis.lastTranscriptTotalLines = tail.totalLines;\n\t\tthis.lastTranscriptRanges = this.transcriptCache.lineRanges();\n\t\t// A finished or cancelled agent has nothing left to follow or pause: the indicator row only\n\t\t// makes sense while the agent could still produce more output.\n\t\tconst showFollowLine = !isFinishedAgentStatus(row.status);\n\t\tconst transcriptRows = Math.max(1, contentHeight - header.length - (showFollowLine ? 1 : 0));\n\t\tthis.lastDetailBodyHeight = transcriptRows;\n\t\tconst pinnedEndLine = this.pauseAnchor\n\t\t\t? resolvePauseEndLine(this.pauseAnchor, this.lastTranscriptRanges, tail.totalLines)\n\t\t\t: undefined;\n\t\tconst offsetFromEnd = this.following ? 0 : Math.max(0, tail.totalLines - (pinnedEndLine ?? tail.totalLines));\n\t\tconst windowLines = padLines(tail.window(transcriptRows, offsetFromEnd), transcriptRows);\n\t\tconst followLine = showFollowLine\n\t\t\t? [fitLine(this.following ? \"◆ following\" : \"‖ paused · f to follow\", width)]\n\t\t\t: [];\n\t\tconst body = [...header, ...windowLines, ...followLine];\n\t\treturn [...padLines(body, contentHeight), footer];\n\t}\n\n\t/** `width` is the same inner width the caller laid its body out to, so a hint line that does not\n\t * fit is ellipsised like every other row instead of being hard-cut by `sideLine`'s padding,\n\t * which carries no ellipsis of its own. */\n\tprivate footerLine(hint: string, width: number): string {\n\t\treturn fitLine(this.footerNotice ? this.deps.theme.fg(\"warning\", this.footerNotice) : hint, width);\n\t}\n\n\tprivate runsHintLine(): string {\n\t\treturn [\n\t\t\tcombinedKeyHint([\"tui.select.up\", \"tui.select.down\"], \"select\"),\n\t\t\tkeyHint(\"tui.select.confirm\", \"open\"),\n\t\t\tkeyHint(\"app.polyphase.cancelRun\", \"cancel run\"),\n\t\t\tkeyHint(\"tui.select.cancel\", \"close\"),\n\t\t].join(\" \");\n\t}\n\n\tprivate runHintLine(): string {\n\t\treturn [\n\t\t\tcombinedKeyHint([\"tui.select.up\", \"tui.select.down\"], \"select\"),\n\t\t\tkeyHint(\"tui.select.confirm\", \"follow\"),\n\t\t\tkeyHint(\"app.polyphase.cancelAgent\", \"cancel agent\"),\n\t\t\tkeyHint(\"app.polyphase.cancelRun\", \"cancel run\"),\n\t\t\tkeyHint(\"tui.select.cancel\", \"back\"),\n\t\t].join(\" \");\n\t}\n\n\tprivate agentHintLine(status?: AgentStatus): string {\n\t\tconst finished = status !== undefined && isFinishedAgentStatus(status);\n\t\treturn [\n\t\t\tkeyHint(\"app.polyphase.nextAgent\", \"next agent\"),\n\t\t\t...(finished ? [] : [keyHint(\"app.polyphase.follow\", \"follow\")]),\n\t\t\tkeyHint(\"app.thinking.toggle\", \"thinking\"),\n\t\t\t...(finished ? [] : [keyHint(\"app.polyphase.cancelAgent\", \"cancel\")]),\n\t\t\tkeyHint(\"tui.select.cancel\", \"back\"),\n\t\t].join(\" \");\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-host.d.ts","sourceRoot":"","sources":["../../../../src/core/polyphase/workflow/agent-host.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAEN,KAAK,WAAW,EAKhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAA4C,YAAY,EAAE,MAAM,cAAc,CAAC;AAG3F,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,gBAAgB,CAAC;IACtB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,GAAG,EAAE,YAAY,CAAC;IAClB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"agent-host.d.ts","sourceRoot":"","sources":["../../../../src/core/polyphase/workflow/agent-host.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAEN,KAAK,WAAW,EAKhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAA4C,YAAY,EAAE,MAAM,cAAc,CAAC;AAG3F,MAA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