@draht/coding-agent 2026.10.4 → 2026.10.8-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +32 -6
- package/dist/bundle/chunks/{anthropic-messages-GAKYXF65.js → anthropic-messages-E2P6C3P7.js} +1 -1
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-ZIXMK6JO.js → azure-openai-responses-JZMSTDIM.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +20 -20
- package/dist/bundle/chunks/chunk-2JZLKNZ4.js +3 -0
- package/dist/bundle/chunks/chunk-5QJFWTKA.js +4 -0
- package/dist/bundle/chunks/{chunk-XKDTJ4YR.js → chunk-6QIFWMDF.js} +1 -1
- package/dist/bundle/chunks/{chunk-5VZWYVZB.js → chunk-AHGUOQPH.js} +2 -2
- package/dist/bundle/chunks/{chunk-H6FT43VC.js → chunk-BOGY4QVF.js} +4 -4
- package/dist/bundle/chunks/{chunk-RZKPFWMH.js → chunk-D3HO453P.js} +2 -2
- package/dist/bundle/chunks/{chunk-KVH4HR57.js → chunk-FHX2S5IG.js} +1 -1
- package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
- package/dist/bundle/chunks/chunk-GD2WVXWT.js +65 -0
- package/dist/bundle/chunks/{chunk-Z2INEV2J.js → chunk-KJJJSTND.js} +307 -168
- package/dist/bundle/chunks/{chunk-BXSHCX3G.js → chunk-KY2BG6BC.js} +1 -1
- package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
- package/dist/bundle/chunks/chunk-PGJAHC3R.js +107 -0
- package/dist/bundle/chunks/chunk-QVFELZW2.js +312 -0
- package/dist/bundle/chunks/{chunk-COF5JT7R.js → chunk-QVTLBSTH.js} +1 -1
- package/dist/bundle/chunks/{chunk-DPE4ALPU.js → chunk-U6LDZZGM.js} +10 -10
- package/dist/bundle/chunks/{chunk-D6TMD5Q2.js → chunk-UTRX2VHB.js} +8 -8
- package/dist/bundle/chunks/{chunk-LDAOC5RB.js → chunk-VQOV5VFH.js} +1 -1
- package/dist/bundle/chunks/chunk-VXUJMEMO.js +2 -0
- package/dist/bundle/chunks/{cli-SR5QBZH4.js → cli-O6OWCY7N.js} +1 -1
- package/dist/bundle/chunks/execute-4JU5WQXP.js +18 -0
- package/dist/bundle/chunks/google-antigravity.js +1 -1
- package/dist/bundle/chunks/google-gemini-cli.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-RPUPQ6PM.js → google-generative-ai-HPNDIAZD.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-EZES5QVQ.js → google-vertex-KPAWJ4SP.js} +1 -1
- package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.js +13 -0
- package/dist/bundle/chunks/lib-ULKZYRGD.js +9 -0
- package/dist/bundle/chunks/{mistral-conversations-AOYGU43Y.js → mistral-conversations-FMSPWQ7A.js} +1 -1
- package/dist/bundle/chunks/{multipart-parser-AZP5BX2W.js → multipart-parser-HMCXZ4BD.js} +1 -1
- package/dist/bundle/chunks/{node-LQ52KV6B.js → node-4JNG6XQO.js} +1 -1
- package/dist/bundle/chunks/{node-C2JGH2OB.js → node-6IIDYB3K.js} +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-M2Y77JEQ.js → openai-codex-responses-TU7NGPXE.js} +1 -1
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/{openai-completions-A4OKYOYV.js → openai-completions-GANCQQO5.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-6IXV53T3.js → openai-responses-ASDPAX3E.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-LYV4NKFM.js → openrouter-images-NROSQXMZ.js} +1 -1
- package/dist/bundle/chunks/openrouter.js +1 -1
- package/dist/bundle/chunks/{pi-messages-KKMEUT3Z.js → pi-messages-2QEJYOAO.js} +1 -1
- package/dist/bundle/chunks/radius.js +1 -1
- package/dist/bundle/chunks/{runtime-6YJPGSP7.js → runtime-FIGQHW75.js} +1 -1
- package/dist/bundle/chunks/runtime-TJ3EAMJK.js +3 -0
- package/dist/bundle/chunks/{settings-manager-D2EG7WDO.js → settings-manager-HC5RR36T.js} +1 -1
- package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
- package/dist/bundle/chunks/virtual-modules-UIGTRGHQ.js +2 -0
- package/dist/bundle/chunks/xai.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/cli/args.js +3 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/core/builtins/duet.d.ts +5 -2
- package/dist/core/builtins/duet.d.ts.map +1 -1
- package/dist/core/builtins/duet.js +65 -27
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +2 -0
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/builtins/polyphase.d.ts +15 -0
- package/dist/core/builtins/polyphase.d.ts.map +1 -0
- package/dist/core/builtins/polyphase.js +196 -0
- package/dist/core/builtins/polyphase.js.map +1 -0
- package/dist/core/builtins/subagent.d.ts +44 -34
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +827 -560
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/extensions/types.d.ts +17 -2
- 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 +30 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-resolver.js +4 -4
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +4 -1
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/polyphase/approval.d.ts +35 -0
- package/dist/core/polyphase/approval.d.ts.map +1 -0
- package/dist/core/polyphase/approval.js +184 -0
- package/dist/core/polyphase/approval.js.map +1 -0
- package/dist/core/polyphase/child-events.d.ts +107 -0
- package/dist/core/polyphase/child-events.d.ts.map +1 -0
- package/dist/core/polyphase/child-events.js +862 -0
- package/dist/core/polyphase/child-events.js.map +1 -0
- package/dist/core/polyphase/child-process.d.ts +65 -0
- package/dist/core/polyphase/child-process.d.ts.map +1 -0
- package/dist/core/polyphase/child-process.js +361 -0
- package/dist/core/polyphase/child-process.js.map +1 -0
- package/dist/core/polyphase/commands.d.ts +44 -0
- package/dist/core/polyphase/commands.d.ts.map +1 -0
- package/dist/core/polyphase/commands.js +244 -0
- package/dist/core/polyphase/commands.js.map +1 -0
- package/dist/core/polyphase/details.d.ts +40 -0
- package/dist/core/polyphase/details.d.ts.map +1 -0
- package/dist/core/polyphase/details.js +538 -0
- package/dist/core/polyphase/details.js.map +1 -0
- package/dist/core/polyphase/emitter.d.ts +20 -0
- package/dist/core/polyphase/emitter.d.ts.map +1 -0
- package/dist/core/polyphase/emitter.js +90 -0
- package/dist/core/polyphase/emitter.js.map +1 -0
- package/dist/core/polyphase/jsonl-reader.d.ts +31 -0
- package/dist/core/polyphase/jsonl-reader.d.ts.map +1 -0
- package/dist/core/polyphase/jsonl-reader.js +161 -0
- package/dist/core/polyphase/jsonl-reader.js.map +1 -0
- package/dist/core/polyphase/keyword.d.ts +27 -0
- package/dist/core/polyphase/keyword.d.ts.map +1 -0
- package/dist/core/polyphase/keyword.js +97 -0
- package/dist/core/polyphase/keyword.js.map +1 -0
- package/dist/core/polyphase/limiter.d.ts +38 -0
- package/dist/core/polyphase/limiter.d.ts.map +1 -0
- package/dist/core/polyphase/limiter.js +129 -0
- package/dist/core/polyphase/limiter.js.map +1 -0
- package/dist/core/polyphase/model-selection.d.ts +35 -0
- package/dist/core/polyphase/model-selection.d.ts.map +1 -0
- package/dist/core/polyphase/model-selection.js +72 -0
- package/dist/core/polyphase/model-selection.js.map +1 -0
- package/dist/core/polyphase/render/format.d.ts +52 -0
- package/dist/core/polyphase/render/format.d.ts.map +1 -0
- package/dist/core/polyphase/render/format.js +169 -0
- package/dist/core/polyphase/render/format.js.map +1 -0
- package/dist/core/polyphase/render/renderers.d.ts +63 -0
- package/dist/core/polyphase/render/renderers.d.ts.map +1 -0
- package/dist/core/polyphase/render/renderers.js +277 -0
- package/dist/core/polyphase/render/renderers.js.map +1 -0
- package/dist/core/polyphase/render/run-block.d.ts +45 -0
- package/dist/core/polyphase/render/run-block.d.ts.map +1 -0
- package/dist/core/polyphase/render/run-block.js +843 -0
- package/dist/core/polyphase/render/run-block.js.map +1 -0
- package/dist/core/polyphase/render/snapshot.d.ts +106 -0
- package/dist/core/polyphase/render/snapshot.d.ts.map +1 -0
- package/dist/core/polyphase/render/snapshot.js +292 -0
- package/dist/core/polyphase/render/snapshot.js.map +1 -0
- package/dist/core/polyphase/result-text.d.ts +41 -0
- package/dist/core/polyphase/result-text.d.ts.map +1 -0
- package/dist/core/polyphase/result-text.js +326 -0
- package/dist/core/polyphase/result-text.js.map +1 -0
- package/dist/core/polyphase/session.d.ts +33 -0
- package/dist/core/polyphase/session.d.ts.map +1 -0
- package/dist/core/polyphase/session.js +106 -0
- package/dist/core/polyphase/session.js.map +1 -0
- package/dist/core/polyphase/settings.d.ts +18 -0
- package/dist/core/polyphase/settings.d.ts.map +1 -0
- package/dist/core/polyphase/settings.js +93 -0
- package/dist/core/polyphase/settings.js.map +1 -0
- package/dist/core/polyphase/store.d.ts +197 -0
- package/dist/core/polyphase/store.d.ts.map +1 -0
- package/dist/core/polyphase/store.js +558 -0
- package/dist/core/polyphase/store.js.map +1 -0
- package/dist/core/polyphase/types.d.ts +371 -0
- package/dist/core/polyphase/types.d.ts.map +1 -0
- package/dist/core/polyphase/types.js +36 -0
- package/dist/core/polyphase/types.js.map +1 -0
- package/dist/core/polyphase/ui/controller.d.ts +28 -0
- package/dist/core/polyphase/ui/controller.d.ts.map +1 -0
- package/dist/core/polyphase/ui/controller.js +150 -0
- package/dist/core/polyphase/ui/controller.js.map +1 -0
- package/dist/core/polyphase/ui/dock.d.ts +27 -0
- package/dist/core/polyphase/ui/dock.d.ts.map +1 -0
- package/dist/core/polyphase/ui/dock.js +121 -0
- package/dist/core/polyphase/ui/dock.js.map +1 -0
- package/dist/core/polyphase/ui/inspector.d.ts +117 -0
- package/dist/core/polyphase/ui/inspector.d.ts.map +1 -0
- package/dist/core/polyphase/ui/inspector.js +1016 -0
- package/dist/core/polyphase/ui/inspector.js.map +1 -0
- package/dist/core/polyphase/ui/transcript-layout.d.ts +55 -0
- package/dist/core/polyphase/ui/transcript-layout.d.ts.map +1 -0
- package/dist/core/polyphase/ui/transcript-layout.js +210 -0
- package/dist/core/polyphase/ui/transcript-layout.js.map +1 -0
- package/dist/core/polyphase/update-pump.d.ts +18 -0
- package/dist/core/polyphase/update-pump.d.ts.map +1 -0
- package/dist/core/polyphase/update-pump.js +132 -0
- package/dist/core/polyphase/update-pump.js.map +1 -0
- package/dist/core/polyphase/workflow/agent-host.d.ts +26 -0
- package/dist/core/polyphase/workflow/agent-host.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/agent-host.js +187 -0
- package/dist/core/polyphase/workflow/agent-host.js.map +1 -0
- package/dist/core/polyphase/workflow/guidance.d.ts +19 -0
- package/dist/core/polyphase/workflow/guidance.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/guidance.js +119 -0
- package/dist/core/polyphase/workflow/guidance.js.map +1 -0
- package/dist/core/polyphase/workflow/launch.d.ts +41 -0
- package/dist/core/polyphase/workflow/launch.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/launch.js +173 -0
- package/dist/core/polyphase/workflow/launch.js.map +1 -0
- package/dist/core/polyphase/workflow/meta.d.ts +43 -0
- package/dist/core/polyphase/workflow/meta.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/meta.js +529 -0
- package/dist/core/polyphase/workflow/meta.js.map +1 -0
- package/dist/core/polyphase/workflow/prelude.d.ts +24 -0
- package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/prelude.js +93 -0
- package/dist/core/polyphase/workflow/prelude.js.map +1 -0
- package/dist/core/polyphase/workflow/runtime.d.ts +79 -0
- package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/runtime.js +217 -0
- package/dist/core/polyphase/workflow/runtime.js.map +1 -0
- package/dist/core/polyphase/workflow/runtime.lazy.d.ts +3 -0
- package/dist/core/polyphase/workflow/runtime.lazy.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/runtime.lazy.js +3 -0
- package/dist/core/polyphase/workflow/runtime.lazy.js.map +1 -0
- package/dist/core/polyphase/workflow/saved.d.ts +55 -0
- package/dist/core/polyphase/workflow/saved.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/saved.js +299 -0
- package/dist/core/polyphase/workflow/saved.js.map +1 -0
- package/dist/core/polyphase/workflow/structured-output.d.ts +22 -0
- package/dist/core/polyphase/workflow/structured-output.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/structured-output.js +66 -0
- package/dist/core/polyphase/workflow/structured-output.js.map +1 -0
- package/dist/core/polyphase/workflow/tool.d.ts +24 -0
- package/dist/core/polyphase/workflow/tool.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/tool.js +139 -0
- package/dist/core/polyphase/workflow/tool.js.map +1 -0
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +27 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/socket-server/permission-relay.js +4 -0
- package/dist/core/socket-server/permission-relay.js.map +1 -1
- package/dist/core/trust-manager.d.ts +3 -2
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +5 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/experimental/micro/runtime.js +1 -1
- package/dist/experimental/micro/runtime.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +18 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +11 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +9 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/prompts/commands/orchestrate.md +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +7 -1
- package/dist/utils/shell.js.map +1 -1
- package/docs/docs.json +4 -0
- package/docs/duet.md +3 -3
- package/docs/environment-variables.md +11 -0
- package/docs/json.md +7 -0
- package/docs/keybindings.md +20 -0
- package/docs/polyphase.md +391 -0
- package/docs/rpc-commands.md +9 -9
- package/docs/settings.md +12 -0
- package/docs/virtual-models.md +3 -3
- package/examples/extensions/preset.ts +3 -3
- package/examples/extensions/subagent/README.md +1 -1
- package/examples/extensions/subagent/agents/planner.md +1 -1
- package/examples/extensions/subagent/agents/reviewer.md +1 -1
- package/examples/extensions/subagent/agents/scout.md +1 -1
- package/examples/extensions/subagent/agents/worker.md +1 -1
- package/examples/extensions/summarize.ts +3 -3
- package/examples/sdk/02-custom-model.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/package.json +10 -10
- package/prompts/commands/orchestrate.md +1 -1
- package/dist/bundle/chunks/chunk-6MSE6LZ3.js +0 -6
- package/dist/bundle/chunks/chunk-6ZJKIMU7.js +0 -2
- package/dist/bundle/chunks/chunk-736QBNUZ.js +0 -12
- package/dist/bundle/chunks/chunk-CEJJ5XF2.js +0 -170
- package/dist/bundle/chunks/chunk-IWTUBX6V.js +0 -4
- package/dist/bundle/chunks/chunk-TIA2T6EO.js +0 -3
- package/dist/bundle/chunks/execute-VCYDHEYA.js +0 -328
- package/dist/bundle/chunks/https-proxy-agent-O2PVUIOI.js +0 -13
- package/dist/bundle/chunks/lib-XOG5PI3Y.js +0 -9
- package/dist/bundle/chunks/src-TIBHS42X.js +0 -4
- package/dist/bundle/chunks/virtual-modules-JTCGDL2Z.js +0 -2
- /package/dist/bundle/chunks/{chunk-ZZD35WKM.js → chunk-FBU742QF.js} +0 -0
- /package/dist/bundle/chunks/{chunk-SVNWI7EV.js → chunk-XHCO4PPH.js} +0 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-row renderers for `subagent` and `workflow` (§11.5): lazy call previews, result blocks
|
|
3
|
+
* reused from the live store or persisted details, the legacy fallback for old sessions, and the
|
|
4
|
+
* `polyphase-workflow` custom-message renderer. No timers anywhere (§11.2.5): rows re-render on
|
|
5
|
+
* emitter updates (at least every second via the heartbeat), never from a renderer-owned clock.
|
|
6
|
+
*/
|
|
7
|
+
import { Text } from "@draht/tui";
|
|
8
|
+
import { isPolyphaseDetails } from "../details.js";
|
|
9
|
+
import { peekWorkflowMeta } from "../workflow/meta.js";
|
|
10
|
+
import { fitLine, oneLine } from "./format.js";
|
|
11
|
+
import { PolyphaseRunBlock, sanitizeChildText } from "./run-block.js";
|
|
12
|
+
import { snapshotFromDetails, snapshotFromRun } from "./snapshot.js";
|
|
13
|
+
function extractTextOutput(result) {
|
|
14
|
+
return result.content
|
|
15
|
+
.filter((content) => content.type === "text")
|
|
16
|
+
.map((content) => content.text)
|
|
17
|
+
.join("\n");
|
|
18
|
+
}
|
|
19
|
+
function subagentTitleLine(args, theme) {
|
|
20
|
+
if (args.chain?.length) {
|
|
21
|
+
const names = args.chain.map((step) => step.agent ?? "?").join(" → ");
|
|
22
|
+
return `${theme.fg("toolTitle", theme.bold("subagent chain"))} ${theme.fg("accent", names)}`;
|
|
23
|
+
}
|
|
24
|
+
if (args.tasks?.length) {
|
|
25
|
+
return `${theme.fg("toolTitle", theme.bold("subagent parallel"))} ${theme.fg("muted", `· ${args.tasks.length} agents`)}`;
|
|
26
|
+
}
|
|
27
|
+
if (args.agent) {
|
|
28
|
+
return `${theme.fg("toolTitle", theme.bold("subagent"))} ${theme.fg("accent", args.agent)}`;
|
|
29
|
+
}
|
|
30
|
+
return theme.fg("toolTitle", theme.bold("subagent"));
|
|
31
|
+
}
|
|
32
|
+
function subagentPreviewLines(args, theme) {
|
|
33
|
+
const lines = [subagentTitleLine(args, theme)];
|
|
34
|
+
const items = args.chain ??
|
|
35
|
+
args.tasks ??
|
|
36
|
+
(args.agent !== undefined ? [{ agent: args.agent, task: args.task, label: args.label, model: args.model }] : []);
|
|
37
|
+
for (const item of items) {
|
|
38
|
+
const label = item.label ?? item.agent ?? "?";
|
|
39
|
+
const agentName = item.agent ?? "?";
|
|
40
|
+
const task = item.task ? oneLine(item.task) : "";
|
|
41
|
+
const modelSuffix = item.model ? ` · ${item.model}` : "";
|
|
42
|
+
const taskSuffix = task ? ` ${theme.fg("toolOutput", task)}` : "";
|
|
43
|
+
lines.push(` ${theme.fg("accent", label)} (${agentName})${taskSuffix}${modelSuffix}`);
|
|
44
|
+
}
|
|
45
|
+
return lines;
|
|
46
|
+
}
|
|
47
|
+
function workflowTitleLine(args, theme) {
|
|
48
|
+
if (args.name) {
|
|
49
|
+
return `${theme.fg("toolTitle", theme.bold("workflow"))} ${theme.fg("accent", sanitizeChildText(args.name))}`;
|
|
50
|
+
}
|
|
51
|
+
const peek = peekWorkflowMeta(args.script ?? "");
|
|
52
|
+
if (peek.name) {
|
|
53
|
+
const description = peek.description ? ` — ${sanitizeChildText(peek.description)}` : "";
|
|
54
|
+
return `${theme.fg("toolTitle", theme.bold("workflow"))} ${theme.fg("accent", sanitizeChildText(peek.name))}${theme.fg("muted", description)}`;
|
|
55
|
+
}
|
|
56
|
+
return `${theme.fg("toolTitle", theme.bold("workflow"))} ${theme.fg("muted", `· writing script… ${peek.lines} lines`)}`;
|
|
57
|
+
}
|
|
58
|
+
function workflowPreviewLines(args, theme, expanded) {
|
|
59
|
+
const lines = [workflowTitleLine(args, theme)];
|
|
60
|
+
const peek = peekWorkflowMeta(args.script ?? "");
|
|
61
|
+
if (peek.name && peek.phases && peek.phases.length > 0) {
|
|
62
|
+
const phasesText = peek.phases.map((title, index) => `${index + 1} ${sanitizeChildText(title)}`).join(" · ");
|
|
63
|
+
const argsSuffix = args.args
|
|
64
|
+
? ` ${theme.fg("muted", `args ${JSON.stringify(sanitizeChildText(args.args))}`)}`
|
|
65
|
+
: "";
|
|
66
|
+
lines.push(` ${theme.fg("muted", "phases")} ${phasesText}${argsSuffix}`);
|
|
67
|
+
}
|
|
68
|
+
if (expanded && args.script) {
|
|
69
|
+
for (const line of args.script.split("\n").slice(0, 60)) {
|
|
70
|
+
lines.push(` ${theme.fg("dim", "│")} ${sanitizeChildText(line)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return lines;
|
|
74
|
+
}
|
|
75
|
+
/** Lazily decides, at render time, whether to show the title line only (once execution has
|
|
76
|
+
* started, or `renderResult` already ran once — for resumed rows) or the call preview (§11.5).
|
|
77
|
+
* Generic over its `titleLine`/`previewLines` pair rather than a `kind` discriminant, so the two
|
|
78
|
+
* concrete subclasses below need no cast to narrow `args` back from a union. */
|
|
79
|
+
class PolyphaseCallView {
|
|
80
|
+
titleLine;
|
|
81
|
+
previewLines;
|
|
82
|
+
args;
|
|
83
|
+
theme;
|
|
84
|
+
context;
|
|
85
|
+
// Recomputing scans the script for its meta header and, when expanded, re-splits it into lines
|
|
86
|
+
// (peekWorkflowMeta, workflowPreviewLines): work that must happen once per args update, never
|
|
87
|
+
// once per frame. `args` is replaced wholesale whenever the tool-call JSON actually changes, so
|
|
88
|
+
// reference equality is enough to detect "nothing changed since the last render".
|
|
89
|
+
cachedArgs;
|
|
90
|
+
cachedShowTitleOnly;
|
|
91
|
+
cachedExpanded;
|
|
92
|
+
cachedLines = [];
|
|
93
|
+
constructor(titleLine, previewLines) {
|
|
94
|
+
this.titleLine = titleLine;
|
|
95
|
+
this.previewLines = previewLines;
|
|
96
|
+
}
|
|
97
|
+
update(args, theme, context) {
|
|
98
|
+
this.args = args;
|
|
99
|
+
this.theme = theme;
|
|
100
|
+
this.context = context;
|
|
101
|
+
}
|
|
102
|
+
render(width) {
|
|
103
|
+
if (this.args === undefined || !this.theme || !this.context)
|
|
104
|
+
return [];
|
|
105
|
+
const args = this.args;
|
|
106
|
+
const theme = this.theme;
|
|
107
|
+
const context = this.context;
|
|
108
|
+
const showTitleOnly = context.state.hasResult === true || context.executionStarted;
|
|
109
|
+
if (args !== this.cachedArgs ||
|
|
110
|
+
showTitleOnly !== this.cachedShowTitleOnly ||
|
|
111
|
+
context.expanded !== this.cachedExpanded) {
|
|
112
|
+
this.cachedArgs = args;
|
|
113
|
+
this.cachedShowTitleOnly = showTitleOnly;
|
|
114
|
+
this.cachedExpanded = context.expanded;
|
|
115
|
+
this.cachedLines = showTitleOnly
|
|
116
|
+
? [this.titleLine(args, theme)]
|
|
117
|
+
: this.previewLines(args, theme, context.expanded);
|
|
118
|
+
}
|
|
119
|
+
return this.cachedLines.map((line) => fitLine(line, width));
|
|
120
|
+
}
|
|
121
|
+
invalidate() {
|
|
122
|
+
this.cachedArgs = undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
class SubagentCallView extends PolyphaseCallView {
|
|
126
|
+
constructor() {
|
|
127
|
+
super(subagentTitleLine, (args, theme) => subagentPreviewLines(args, theme));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
class WorkflowCallView extends PolyphaseCallView {
|
|
131
|
+
constructor() {
|
|
132
|
+
super(workflowTitleLine, workflowPreviewLines);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function tailItemsFor(mode) {
|
|
136
|
+
return mode === "single" ? 8 : 4;
|
|
137
|
+
}
|
|
138
|
+
function computeMaxLines(viewportRows, isPartial, expanded) {
|
|
139
|
+
if (isPartial) {
|
|
140
|
+
return expanded ? Math.min(40, Math.max(6, viewportRows - 12)) : Math.min(12, Math.max(4, viewportRows - 12));
|
|
141
|
+
}
|
|
142
|
+
return expanded ? 200 : 12;
|
|
143
|
+
}
|
|
144
|
+
/** §11.2's source-selection rule: the live store run while partial and present, else details via
|
|
145
|
+
* `isPolyphaseDetails`, else `undefined` to signal the legacy fallback. */
|
|
146
|
+
function resolveSnapshot(deps, toolCallId, isPartial, details, now) {
|
|
147
|
+
if (isPartial) {
|
|
148
|
+
const run = deps.getStore()?.getRun(toolCallId);
|
|
149
|
+
if (run)
|
|
150
|
+
return snapshotFromRun(run, { now, tailItems: tailItemsFor(run.mode), limiter: deps.limiterStats?.() });
|
|
151
|
+
}
|
|
152
|
+
if (isPolyphaseDetails(details))
|
|
153
|
+
return snapshotFromDetails(details, { now });
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
export function renderLegacySubagentResult(result, options, theme) {
|
|
157
|
+
const d = result.details;
|
|
158
|
+
const status = typeof d === "object" && d !== null && "status" in d && typeof d.status === "string" ? d.status : undefined;
|
|
159
|
+
const output = extractTextOutput(result);
|
|
160
|
+
const lines = [];
|
|
161
|
+
if (status)
|
|
162
|
+
lines.push(theme.fg("muted", status));
|
|
163
|
+
if (output.trim()) {
|
|
164
|
+
const trimmed = output.trim();
|
|
165
|
+
if (options.expanded || options.isPartial) {
|
|
166
|
+
for (const line of trimmed.split("\n"))
|
|
167
|
+
lines.push(theme.fg("toolOutput", line));
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const allLines = trimmed.split("\n");
|
|
171
|
+
const previewLines = allLines.slice(0, 8);
|
|
172
|
+
lines.push(theme.fg("toolOutput", previewLines.join("\n")));
|
|
173
|
+
if (allLines.length > 8)
|
|
174
|
+
lines.push(theme.fg("muted", `... (${allLines.length - 8} more lines)`));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (lines.length === 0)
|
|
178
|
+
return new Text("", 0, 0);
|
|
179
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
180
|
+
}
|
|
181
|
+
function renderLegacyWorkflowResult(result, options, theme) {
|
|
182
|
+
const output = extractTextOutput(result).trim();
|
|
183
|
+
if (!output)
|
|
184
|
+
return new Text("", 0, 0);
|
|
185
|
+
const lines = output.split("\n");
|
|
186
|
+
const shown = options.expanded ? lines : lines.slice(0, 8);
|
|
187
|
+
const rendered = shown.map((line) => theme.fg("toolOutput", line)).join("\n");
|
|
188
|
+
return new Text(rendered, 0, 0);
|
|
189
|
+
}
|
|
190
|
+
function renderPolyphaseResult(deps, result, options, theme, context, kind) {
|
|
191
|
+
const now = deps.now?.() ?? Date.now();
|
|
192
|
+
const snapshot = resolveSnapshot(deps, context.toolCallId, options.isPartial, result.details, now);
|
|
193
|
+
if (!snapshot) {
|
|
194
|
+
return kind === "subagent"
|
|
195
|
+
? renderLegacySubagentResult(result, options, theme)
|
|
196
|
+
: renderLegacyWorkflowResult(result, options, theme);
|
|
197
|
+
}
|
|
198
|
+
context.state.hasResult = true;
|
|
199
|
+
const focus = !options.isPartial || deps.getStore()?.focusRunId() === context.toolCallId;
|
|
200
|
+
const maxLines = computeMaxLines(deps.viewportRows(), options.isPartial, options.expanded);
|
|
201
|
+
const layoutOptions = {
|
|
202
|
+
expanded: options.expanded,
|
|
203
|
+
partial: options.isPartial,
|
|
204
|
+
focus,
|
|
205
|
+
maxLines,
|
|
206
|
+
hints: true,
|
|
207
|
+
now,
|
|
208
|
+
};
|
|
209
|
+
const block = context.lastComponent instanceof PolyphaseRunBlock ? context.lastComponent : new PolyphaseRunBlock();
|
|
210
|
+
block.update(snapshot, theme, layoutOptions);
|
|
211
|
+
return block;
|
|
212
|
+
}
|
|
213
|
+
export function createSubagentRenderers(deps) {
|
|
214
|
+
return {
|
|
215
|
+
renderCall(args, theme, context) {
|
|
216
|
+
const view = context.lastComponent instanceof SubagentCallView ? context.lastComponent : new SubagentCallView();
|
|
217
|
+
view.update(args, theme, context);
|
|
218
|
+
return view;
|
|
219
|
+
},
|
|
220
|
+
renderResult(result, options, theme, context) {
|
|
221
|
+
return renderPolyphaseResult(deps, result, options, theme, context, "subagent");
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export function createWorkflowRenderers(deps) {
|
|
226
|
+
return {
|
|
227
|
+
renderCall(args, theme, context) {
|
|
228
|
+
const view = context.lastComponent instanceof WorkflowCallView ? context.lastComponent : new WorkflowCallView();
|
|
229
|
+
view.update(args, theme, context);
|
|
230
|
+
return view;
|
|
231
|
+
},
|
|
232
|
+
renderResult(result, options, theme, context) {
|
|
233
|
+
return renderPolyphaseResult(deps, result, options, theme, context, "workflow");
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Combines a static prefix line with a `PolyphaseRunBlock`'s lines, both fitted at render time
|
|
238
|
+
* (the block is built once from `details`, which never changes for a persisted custom message). */
|
|
239
|
+
class PrefixedRunBlock {
|
|
240
|
+
prefixLine;
|
|
241
|
+
block;
|
|
242
|
+
constructor(prefixLine, block) {
|
|
243
|
+
this.prefixLine = prefixLine;
|
|
244
|
+
this.block = block;
|
|
245
|
+
}
|
|
246
|
+
render(width) {
|
|
247
|
+
return [fitLine(this.prefixLine, width), ...this.block.render(width)];
|
|
248
|
+
}
|
|
249
|
+
invalidate() {
|
|
250
|
+
this.block.invalidate();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** Renders `polyphase-workflow` custom messages (command-run results) as a static block built from
|
|
254
|
+
* `message.details`, prefixed with `▶ /<name> <args>` (§11.5). */
|
|
255
|
+
export function createPolyphaseMessageRenderer() {
|
|
256
|
+
return (message, options, theme) => {
|
|
257
|
+
const details = message.details;
|
|
258
|
+
if (!details || !isPolyphaseDetails(details))
|
|
259
|
+
return undefined;
|
|
260
|
+
const snapshot = snapshotFromDetails(details);
|
|
261
|
+
const name = details.workflow?.name ?? details.title;
|
|
262
|
+
const argsSuffix = details.workflow?.args ? ` ${details.workflow.args}` : "";
|
|
263
|
+
const prefixLine = `${theme.fg("accent", "▶")} ${theme.fg("toolTitle", `/${name}${argsSuffix}`)}`;
|
|
264
|
+
const layoutOptions = {
|
|
265
|
+
expanded: options.expanded,
|
|
266
|
+
partial: false,
|
|
267
|
+
focus: false,
|
|
268
|
+
maxLines: options.expanded ? 200 : 12,
|
|
269
|
+
hints: false,
|
|
270
|
+
now: Date.now(),
|
|
271
|
+
};
|
|
272
|
+
const block = new PolyphaseRunBlock();
|
|
273
|
+
block.update(snapshot, theme, layoutOptions);
|
|
274
|
+
return new PrefixedRunBlock(prefixLine, block);
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=renderers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../../../src/core/polyphase/render/renderers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAkB,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAyB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmCrE,SAAS,iBAAiB,CAAC,MAAgC;IAC1D,OAAO,MAAM,CAAC,OAAO;SACnB,MAAM,CAAC,CAAC,OAAO,EAA6C,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;SACvF,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,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;YACvC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACrC,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;SACf,CAAC;QACF,MAAM,KAAK,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACtC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;QAC7C,OAAO,IAAI,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tool-row renderers for `subagent` and `workflow` (§11.5): lazy call previews, result blocks\n * reused from the live store or persisted details, the legacy fallback for old sessions, and the\n * `polyphase-workflow` custom-message renderer. No timers anywhere (§11.2.5): rows re-render on\n * emitter updates (at least every second via the heartbeat), never from a renderer-owned clock.\n */\n\nimport type { AgentToolResult } from \"@draht/agent-core\";\nimport { type Component, Text } from \"@draht/tui\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport type { MessageRenderer, ToolRenderContext, ToolRenderResultOptions } from \"../../extensions/types.ts\";\nimport { isPolyphaseDetails } from \"../details.ts\";\nimport type { LimiterStats } from \"../limiter.ts\";\nimport type { PolyphaseStore } from \"../store.ts\";\nimport type { PolyphaseDetails, SubagentMode } from \"../types.ts\";\nimport { peekWorkflowMeta } from \"../workflow/meta.ts\";\nimport { fitLine, oneLine } from \"./format.ts\";\nimport { PolyphaseRunBlock, type RunLayoutOptions, sanitizeChildText } from \"./run-block.ts\";\nimport { snapshotFromDetails, snapshotFromRun } from \"./snapshot.ts\";\n\nexport interface PolyphaseRenderDeps {\n\tgetStore(): PolyphaseStore | undefined;\n\tviewportRows(): number;\n\tnow?(): number;\n\t/** Optional: when present, `(a/c slots busy)` can appear on a live tool row's summary line\n\t * (§11.3). Left undefined, the suffix never shows, which matches today's wiring. */\n\tlimiterStats?(): LimiterStats | undefined;\n}\n\nexport interface SubagentCallArgs {\n\tagent?: string;\n\ttask?: string;\n\tlabel?: string;\n\tmodel?: string;\n\tthinking?: string;\n\ttasks?: Array<{ agent?: string; task?: string; label?: string; model?: string }>;\n\tchain?: Array<{ agent?: string; task?: string; label?: string; model?: string }>;\n\tworktree?: boolean;\n}\n\nexport interface WorkflowCallArgs {\n\tscript?: string;\n\tname?: string;\n\targs?: string;\n\tbudgetTokens?: number;\n}\n\nexport interface PolyphaseRowState {\n\thasResult?: boolean;\n}\n\ntype PolyphaseCallArgs = SubagentCallArgs | WorkflowCallArgs;\n\nfunction extractTextOutput(result: AgentToolResult<unknown>): string {\n\treturn result.content\n\t\t.filter((content): content is { type: \"text\"; text: string } => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\\n\");\n}\n\nfunction subagentTitleLine(args: SubagentCallArgs, theme: Theme): string {\n\tif (args.chain?.length) {\n\t\tconst names = args.chain.map((step) => step.agent ?? \"?\").join(\" → \");\n\t\treturn `${theme.fg(\"toolTitle\", theme.bold(\"subagent chain\"))} ${theme.fg(\"accent\", names)}`;\n\t}\n\tif (args.tasks?.length) {\n\t\treturn `${theme.fg(\"toolTitle\", theme.bold(\"subagent parallel\"))} ${theme.fg(\"muted\", `· ${args.tasks.length} agents`)}`;\n\t}\n\tif (args.agent) {\n\t\treturn `${theme.fg(\"toolTitle\", theme.bold(\"subagent\"))} ${theme.fg(\"accent\", args.agent)}`;\n\t}\n\treturn theme.fg(\"toolTitle\", theme.bold(\"subagent\"));\n}\n\ninterface PreviewItem {\n\tagent?: string;\n\ttask?: string;\n\tlabel?: string;\n\tmodel?: string;\n}\n\nfunction subagentPreviewLines(args: SubagentCallArgs, theme: Theme): string[] {\n\tconst lines = [subagentTitleLine(args, theme)];\n\tconst items: readonly PreviewItem[] =\n\t\targs.chain ??\n\t\targs.tasks ??\n\t\t(args.agent !== undefined ? [{ agent: args.agent, task: args.task, label: args.label, model: args.model }] : []);\n\tfor (const item of items) {\n\t\tconst label = item.label ?? item.agent ?? \"?\";\n\t\tconst agentName = item.agent ?? \"?\";\n\t\tconst task = item.task ? oneLine(item.task) : \"\";\n\t\tconst modelSuffix = item.model ? ` · ${item.model}` : \"\";\n\t\tconst taskSuffix = task ? ` ${theme.fg(\"toolOutput\", task)}` : \"\";\n\t\tlines.push(` ${theme.fg(\"accent\", label)} (${agentName})${taskSuffix}${modelSuffix}`);\n\t}\n\treturn lines;\n}\n\nfunction workflowTitleLine(args: WorkflowCallArgs, theme: Theme): string {\n\tif (args.name) {\n\t\treturn `${theme.fg(\"toolTitle\", theme.bold(\"workflow\"))} ${theme.fg(\"accent\", sanitizeChildText(args.name))}`;\n\t}\n\tconst peek = peekWorkflowMeta(args.script ?? \"\");\n\tif (peek.name) {\n\t\tconst description = peek.description ? ` — ${sanitizeChildText(peek.description)}` : \"\";\n\t\treturn `${theme.fg(\"toolTitle\", theme.bold(\"workflow\"))} ${theme.fg(\"accent\", sanitizeChildText(peek.name))}${theme.fg(\"muted\", description)}`;\n\t}\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"workflow\"))} ${theme.fg(\"muted\", `· writing script… ${peek.lines} lines`)}`;\n}\n\nfunction workflowPreviewLines(args: WorkflowCallArgs, theme: Theme, expanded: boolean): string[] {\n\tconst lines = [workflowTitleLine(args, theme)];\n\tconst peek = peekWorkflowMeta(args.script ?? \"\");\n\tif (peek.name && peek.phases && peek.phases.length > 0) {\n\t\tconst phasesText = peek.phases.map((title, index) => `${index + 1} ${sanitizeChildText(title)}`).join(\" · \");\n\t\tconst argsSuffix = args.args\n\t\t\t? ` ${theme.fg(\"muted\", `args ${JSON.stringify(sanitizeChildText(args.args))}`)}`\n\t\t\t: \"\";\n\t\tlines.push(` ${theme.fg(\"muted\", \"phases\")} ${phasesText}${argsSuffix}`);\n\t}\n\tif (expanded && args.script) {\n\t\tfor (const line of args.script.split(\"\\n\").slice(0, 60)) {\n\t\t\tlines.push(` ${theme.fg(\"dim\", \"│\")} ${sanitizeChildText(line)}`);\n\t\t}\n\t}\n\treturn lines;\n}\n\n/** Lazily decides, at render time, whether to show the title line only (once execution has\n * started, or `renderResult` already ran once — for resumed rows) or the call preview (§11.5).\n * Generic over its `titleLine`/`previewLines` pair rather than a `kind` discriminant, so the two\n * concrete subclasses below need no cast to narrow `args` back from a union. */\nclass PolyphaseCallView<TArgs> implements Component {\n\tprivate readonly titleLine: (args: TArgs, theme: Theme) => string;\n\tprivate readonly previewLines: (args: TArgs, theme: Theme, expanded: boolean) => string[];\n\tprivate args: TArgs | undefined;\n\tprivate theme: Theme | undefined;\n\tprivate context: ToolRenderContext<PolyphaseRowState, TArgs> | undefined;\n\t// Recomputing scans the script for its meta header and, when expanded, re-splits it into lines\n\t// (peekWorkflowMeta, workflowPreviewLines): work that must happen once per args update, never\n\t// once per frame. `args` is replaced wholesale whenever the tool-call JSON actually changes, so\n\t// reference equality is enough to detect \"nothing changed since the last render\".\n\tprivate cachedArgs: TArgs | undefined;\n\tprivate cachedShowTitleOnly: boolean | undefined;\n\tprivate cachedExpanded: boolean | undefined;\n\tprivate cachedLines: string[] = [];\n\n\tconstructor(\n\t\ttitleLine: (args: TArgs, theme: Theme) => string,\n\t\tpreviewLines: (args: TArgs, theme: Theme, expanded: boolean) => string[],\n\t) {\n\t\tthis.titleLine = titleLine;\n\t\tthis.previewLines = previewLines;\n\t}\n\n\tupdate(args: TArgs, theme: Theme, context: ToolRenderContext<PolyphaseRowState, TArgs>): void {\n\t\tthis.args = args;\n\t\tthis.theme = theme;\n\t\tthis.context = context;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.args === undefined || !this.theme || !this.context) return [];\n\t\tconst args = this.args;\n\t\tconst theme = this.theme;\n\t\tconst context = this.context;\n\t\tconst showTitleOnly = context.state.hasResult === true || context.executionStarted;\n\t\tif (\n\t\t\targs !== this.cachedArgs ||\n\t\t\tshowTitleOnly !== this.cachedShowTitleOnly ||\n\t\t\tcontext.expanded !== this.cachedExpanded\n\t\t) {\n\t\t\tthis.cachedArgs = args;\n\t\t\tthis.cachedShowTitleOnly = showTitleOnly;\n\t\t\tthis.cachedExpanded = context.expanded;\n\t\t\tthis.cachedLines = showTitleOnly\n\t\t\t\t? [this.titleLine(args, theme)]\n\t\t\t\t: this.previewLines(args, theme, context.expanded);\n\t\t}\n\t\treturn this.cachedLines.map((line) => fitLine(line, width));\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedArgs = undefined;\n\t}\n}\n\nclass SubagentCallView extends PolyphaseCallView<SubagentCallArgs> {\n\tconstructor() {\n\t\tsuper(subagentTitleLine, (args, theme) => subagentPreviewLines(args, theme));\n\t}\n}\n\nclass WorkflowCallView extends PolyphaseCallView<WorkflowCallArgs> {\n\tconstructor() {\n\t\tsuper(workflowTitleLine, workflowPreviewLines);\n\t}\n}\n\nfunction tailItemsFor(mode: SubagentMode | undefined): number {\n\treturn mode === \"single\" ? 8 : 4;\n}\n\nfunction computeMaxLines(viewportRows: number, isPartial: boolean, expanded: boolean): number {\n\tif (isPartial) {\n\t\treturn expanded ? Math.min(40, Math.max(6, viewportRows - 12)) : Math.min(12, Math.max(4, viewportRows - 12));\n\t}\n\treturn expanded ? 200 : 12;\n}\n\n/** §11.2's source-selection rule: the live store run while partial and present, else details via\n * `isPolyphaseDetails`, else `undefined` to signal the legacy fallback. */\nfunction resolveSnapshot(\n\tdeps: PolyphaseRenderDeps,\n\ttoolCallId: string,\n\tisPartial: boolean,\n\tdetails: unknown,\n\tnow: number,\n) {\n\tif (isPartial) {\n\t\tconst run = deps.getStore()?.getRun(toolCallId);\n\t\tif (run) return snapshotFromRun(run, { now, tailItems: tailItemsFor(run.mode), limiter: deps.limiterStats?.() });\n\t}\n\tif (isPolyphaseDetails(details)) return snapshotFromDetails(details, { now });\n\treturn undefined;\n}\n\nexport function renderLegacySubagentResult(\n\tresult: AgentToolResult<unknown>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n): Component {\n\tconst d = result.details;\n\tconst status =\n\t\ttypeof d === \"object\" && d !== null && \"status\" in d && typeof d.status === \"string\" ? d.status : undefined;\n\tconst output = extractTextOutput(result);\n\tconst lines: string[] = [];\n\n\tif (status) lines.push(theme.fg(\"muted\", status));\n\n\tif (output.trim()) {\n\t\tconst trimmed = output.trim();\n\t\tif (options.expanded || options.isPartial) {\n\t\t\tfor (const line of trimmed.split(\"\\n\")) lines.push(theme.fg(\"toolOutput\", line));\n\t\t} else {\n\t\t\tconst allLines = trimmed.split(\"\\n\");\n\t\t\tconst previewLines = allLines.slice(0, 8);\n\t\t\tlines.push(theme.fg(\"toolOutput\", previewLines.join(\"\\n\")));\n\t\t\tif (allLines.length > 8) lines.push(theme.fg(\"muted\", `... (${allLines.length - 8} more lines)`));\n\t\t}\n\t}\n\n\tif (lines.length === 0) return new Text(\"\", 0, 0);\n\treturn new Text(lines.join(\"\\n\"), 0, 0);\n}\n\nfunction renderLegacyWorkflowResult(\n\tresult: AgentToolResult<unknown>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n): Component {\n\tconst output = extractTextOutput(result).trim();\n\tif (!output) return new Text(\"\", 0, 0);\n\tconst lines = output.split(\"\\n\");\n\tconst shown = options.expanded ? lines : lines.slice(0, 8);\n\tconst rendered = shown.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\");\n\treturn new Text(rendered, 0, 0);\n}\n\nfunction renderPolyphaseResult(\n\tdeps: PolyphaseRenderDeps,\n\tresult: AgentToolResult<unknown>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<PolyphaseRowState, PolyphaseCallArgs>,\n\tkind: \"subagent\" | \"workflow\",\n): Component {\n\tconst now = deps.now?.() ?? Date.now();\n\tconst snapshot = resolveSnapshot(deps, context.toolCallId, options.isPartial, result.details, now);\n\tif (!snapshot) {\n\t\treturn kind === \"subagent\"\n\t\t\t? renderLegacySubagentResult(result, options, theme)\n\t\t\t: renderLegacyWorkflowResult(result, options, theme);\n\t}\n\tcontext.state.hasResult = true;\n\n\tconst focus = !options.isPartial || deps.getStore()?.focusRunId() === context.toolCallId;\n\tconst maxLines = computeMaxLines(deps.viewportRows(), options.isPartial, options.expanded);\n\tconst layoutOptions: RunLayoutOptions = {\n\t\texpanded: options.expanded,\n\t\tpartial: options.isPartial,\n\t\tfocus,\n\t\tmaxLines,\n\t\thints: true,\n\t\tnow,\n\t};\n\n\tconst block = context.lastComponent instanceof PolyphaseRunBlock ? context.lastComponent : new PolyphaseRunBlock();\n\tblock.update(snapshot, theme, layoutOptions);\n\treturn block;\n}\n\nexport function createSubagentRenderers(deps: PolyphaseRenderDeps): {\n\trenderCall(\n\t\targs: SubagentCallArgs,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<PolyphaseRowState, SubagentCallArgs>,\n\t): Component;\n\trenderResult(\n\t\tresult: AgentToolResult<unknown>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<PolyphaseRowState, SubagentCallArgs>,\n\t): Component;\n} {\n\treturn {\n\t\trenderCall(args, theme, context) {\n\t\t\tconst view =\n\t\t\t\tcontext.lastComponent instanceof SubagentCallView ? context.lastComponent : new SubagentCallView();\n\t\t\tview.update(args, theme, context);\n\t\t\treturn view;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\treturn renderPolyphaseResult(deps, result, options, theme, context, \"subagent\");\n\t\t},\n\t};\n}\n\nexport function createWorkflowRenderers(deps: PolyphaseRenderDeps): {\n\trenderCall(\n\t\targs: WorkflowCallArgs,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<PolyphaseRowState, WorkflowCallArgs>,\n\t): Component;\n\trenderResult(\n\t\tresult: AgentToolResult<unknown>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<PolyphaseRowState, WorkflowCallArgs>,\n\t): Component;\n} {\n\treturn {\n\t\trenderCall(args, theme, context) {\n\t\t\tconst view =\n\t\t\t\tcontext.lastComponent instanceof WorkflowCallView ? context.lastComponent : new WorkflowCallView();\n\t\t\tview.update(args, theme, context);\n\t\t\treturn view;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\treturn renderPolyphaseResult(deps, result, options, theme, context, \"workflow\");\n\t\t},\n\t};\n}\n\n/** Combines a static prefix line with a `PolyphaseRunBlock`'s lines, both fitted at render time\n * (the block is built once from `details`, which never changes for a persisted custom message). */\nclass PrefixedRunBlock implements Component {\n\tprivate readonly prefixLine: string;\n\tprivate readonly block: PolyphaseRunBlock;\n\n\tconstructor(prefixLine: string, block: PolyphaseRunBlock) {\n\t\tthis.prefixLine = prefixLine;\n\t\tthis.block = block;\n\t}\n\n\trender(width: number): string[] {\n\t\treturn [fitLine(this.prefixLine, width), ...this.block.render(width)];\n\t}\n\n\tinvalidate(): void {\n\t\tthis.block.invalidate();\n\t}\n}\n\n/** Renders `polyphase-workflow` custom messages (command-run results) as a static block built from\n * `message.details`, prefixed with `▶ /<name> <args>` (§11.5). */\nexport function createPolyphaseMessageRenderer(): MessageRenderer<PolyphaseDetails> {\n\treturn (message, options, theme) => {\n\t\tconst details = message.details;\n\t\tif (!details || !isPolyphaseDetails(details)) return undefined;\n\n\t\tconst snapshot = snapshotFromDetails(details);\n\t\tconst name = details.workflow?.name ?? details.title;\n\t\tconst argsSuffix = details.workflow?.args ? ` ${details.workflow.args}` : \"\";\n\t\tconst prefixLine = `${theme.fg(\"accent\", \"▶\")} ${theme.fg(\"toolTitle\", `/${name}${argsSuffix}`)}`;\n\n\t\tconst layoutOptions: RunLayoutOptions = {\n\t\t\texpanded: options.expanded,\n\t\t\tpartial: false,\n\t\t\tfocus: false,\n\t\t\tmaxLines: options.expanded ? 200 : 12,\n\t\t\thints: false,\n\t\t\tnow: Date.now(),\n\t\t};\n\t\tconst block = new PolyphaseRunBlock();\n\t\tblock.update(snapshot, theme, layoutOptions);\n\t\treturn new PrefixedRunBlock(prefixLine, block);\n\t};\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout for one polyphase run's tool-row content (§11.3-11.4): `layoutRun` turns a `RunSnapshot`
|
|
3
|
+
* into fitted lines, and `PolyphaseRunBlock` is the `Component` `render/renderers.ts` reuses across
|
|
4
|
+
* re-renders of the same tool call. Every line goes through `fitLine` as the last step (§0 width
|
|
5
|
+
* safety); no timers live here (§11.2.5) — the animated frame comes from `options.now`.
|
|
6
|
+
*/
|
|
7
|
+
import { type Component } from "@draht/tui";
|
|
8
|
+
import type { Theme } from "../../../modes/interactive/theme/theme.ts";
|
|
9
|
+
import type { RunSnapshot } from "./snapshot.ts";
|
|
10
|
+
export interface RunLayoutOptions {
|
|
11
|
+
expanded: boolean;
|
|
12
|
+
partial: boolean;
|
|
13
|
+
/** Only the focused row animates and shows live elapsed/now/tokens (§11.2.2). */
|
|
14
|
+
focus: boolean;
|
|
15
|
+
/** Row budget for agent/phase content, excluding the summary and hint lines (§11.2.3). */
|
|
16
|
+
maxLines: number;
|
|
17
|
+
hints: boolean;
|
|
18
|
+
now: number;
|
|
19
|
+
}
|
|
20
|
+
/** Child-sourced text (output, error, status/now lines, task, tool summaries, labels, log lines,
|
|
21
|
+
* result previews) may carry ANSI/OSC sequences, raw tabs or a trailing CR. Stripped and normalized
|
|
22
|
+
* before any width math runs, so `visibleWidth`/`fitLine` see exactly what the terminal will draw
|
|
23
|
+
* (§0 width safety): a bare tab would otherwise jump to the terminal's own 8-column stop regardless
|
|
24
|
+
* of the 3-column width this file assumes, and a CR would move the cursor back to column 0. */
|
|
25
|
+
export declare function sanitizeChildText(text: string): string;
|
|
26
|
+
/** Every child- or script-supplied string a `RunSnapshot` carries, sanitized once so every renderer
|
|
27
|
+
* that consumes the snapshot (this file's `layoutRun`, `ui/inspector.ts`) works on already-clean
|
|
28
|
+
* text instead of each re-implementing the same stripping. */
|
|
29
|
+
export declare function sanitizeSnapshot(snapshot: RunSnapshot): RunSnapshot;
|
|
30
|
+
/** Everything after `renderCall`'s title line (§11.4): the summary, the agent rows or workflow
|
|
31
|
+
* phase tree, and the hint line, each fitted to `width`. */
|
|
32
|
+
export declare function layoutRun(snapshot: RunSnapshot, width: number, theme: Theme, options: RunLayoutOptions): string[];
|
|
33
|
+
/** Reused across re-renders of the same tool call (`context.lastComponent`). Caches its lines by
|
|
34
|
+
* `(snapshot.version, width, options, spinner frame when focus && partial)` (§11.2.6). */
|
|
35
|
+
export declare class PolyphaseRunBlock implements Component {
|
|
36
|
+
private snapshot;
|
|
37
|
+
private theme;
|
|
38
|
+
private options;
|
|
39
|
+
private cacheKey;
|
|
40
|
+
private cachedLines;
|
|
41
|
+
update(snapshot: RunSnapshot, theme: Theme, options: RunLayoutOptions): void;
|
|
42
|
+
render(width: number): string[];
|
|
43
|
+
invalidate(): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=run-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-block.d.ts","sourceRoot":"","sources":["../../../../src/core/polyphase/render/run-block.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAgB,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAiBvE,OAAO,KAAK,EAAmC,WAAW,EAAE,MAAM,eAAe,CAAC;AAElF,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,KAAK,EAAE,OAAO,CAAC;IACf,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACZ;AAiHD;;;;+FAI+F;AAC/F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM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