@astralyn/pi 0.84.4 → 0.84.5
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 +30 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +5 -4
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -6
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/experimental.d.ts +4 -0
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +4 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -1
- 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 +29 -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/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +1 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/project-trust.js +2 -2
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/sdk.d.ts +5 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.js +2 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +12 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +2 -0
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/background/index.d.ts +74 -0
- package/dist/extensions/background/index.d.ts.map +1 -0
- package/dist/extensions/background/index.js +332 -0
- package/dist/extensions/background/index.js.map +1 -0
- package/dist/extensions/background/manager.d.ts +81 -0
- package/dist/extensions/background/manager.d.ts.map +1 -0
- package/dist/extensions/background/manager.js +320 -0
- package/dist/extensions/background/manager.js.map +1 -0
- package/dist/extensions/background/registry.d.ts +138 -0
- package/dist/extensions/background/registry.d.ts.map +1 -0
- package/dist/extensions/background/registry.js +358 -0
- package/dist/extensions/background/registry.js.map +1 -0
- package/dist/extensions/background/render.d.ts +26 -0
- package/dist/extensions/background/render.d.ts.map +1 -0
- package/dist/extensions/background/render.js +118 -0
- package/dist/extensions/background/render.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/subagent/activity.d.ts +0 -1
- package/dist/extensions/subagent/activity.d.ts.map +1 -1
- package/dist/extensions/subagent/activity.js +2 -5
- package/dist/extensions/subagent/activity.js.map +1 -1
- package/dist/extensions/subagent/agents-command.d.ts.map +1 -1
- package/dist/extensions/subagent/agents-command.js +308 -153
- package/dist/extensions/subagent/agents-command.js.map +1 -1
- package/dist/extensions/subagent/agents.d.ts +3 -6
- package/dist/extensions/subagent/agents.d.ts.map +1 -1
- package/dist/extensions/subagent/agents.js +22 -192
- package/dist/extensions/subagent/agents.js.map +1 -1
- package/dist/extensions/subagent/constants.d.ts +4 -5
- package/dist/extensions/subagent/constants.d.ts.map +1 -1
- package/dist/extensions/subagent/constants.js +11 -7
- package/dist/extensions/subagent/constants.js.map +1 -1
- package/dist/extensions/subagent/index.d.ts +0 -3
- package/dist/extensions/subagent/index.d.ts.map +1 -1
- package/dist/extensions/subagent/index.js +56 -188
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/extensions/subagent/render.d.ts +1 -1
- package/dist/extensions/subagent/render.d.ts.map +1 -1
- package/dist/extensions/subagent/render.js +208 -576
- package/dist/extensions/subagent/render.js.map +1 -1
- package/dist/extensions/subagent/resolve.d.ts +2 -2
- package/dist/extensions/subagent/resolve.d.ts.map +1 -1
- package/dist/extensions/subagent/resolve.js +23 -15
- package/dist/extensions/subagent/resolve.js.map +1 -1
- package/dist/extensions/subagent/runner.d.ts +1 -2
- package/dist/extensions/subagent/runner.d.ts.map +1 -1
- package/dist/extensions/subagent/runner.js +109 -131
- package/dist/extensions/subagent/runner.js.map +1 -1
- package/dist/extensions/subagent/schema.d.ts +4 -10
- package/dist/extensions/subagent/schema.d.ts.map +1 -1
- package/dist/extensions/subagent/schema.js +8 -13
- package/dist/extensions/subagent/schema.js.map +1 -1
- package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -1
- package/dist/extensions/subagent/sdk-runner.js +9 -20
- package/dist/extensions/subagent/sdk-runner.js.map +1 -1
- package/dist/extensions/subagent/settings.d.ts +2 -2
- package/dist/extensions/subagent/settings.d.ts.map +1 -1
- package/dist/extensions/subagent/settings.js +27 -14
- package/dist/extensions/subagent/settings.js.map +1 -1
- package/dist/extensions/subagent/text.d.ts +3 -0
- package/dist/extensions/subagent/text.d.ts.map +1 -0
- package/dist/extensions/subagent/text.js +16 -0
- package/dist/extensions/subagent/text.js.map +1 -0
- package/dist/extensions/subagent/types.d.ts +13 -35
- package/dist/extensions/subagent/types.d.ts.map +1 -1
- package/dist/extensions/subagent/types.js.map +1 -1
- package/dist/extensions/subagent/ui/model-list.d.ts +4 -3
- package/dist/extensions/subagent/ui/model-list.d.ts.map +1 -1
- package/dist/extensions/subagent/ui/model-list.js +10 -4
- package/dist/extensions/subagent/ui/model-list.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +8 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +77 -25
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +36 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +2 -0
- package/dist/modes/interactive/theme/light.json +2 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +23 -10
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive/theme/theme.d.ts +5 -3
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +12 -2
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +4 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +5 -2
- package/dist/modes/json-event.js.map +1 -1
- package/dist/package-manager-cli.js +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/server/create-harness.d.ts.map +1 -1
- package/dist/server/create-harness.js +2 -0
- package/dist/server/create-harness.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +10 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +14 -19
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/bundled/README.md +1 -0
- package/docs/bundled/extensions/background.md +64 -0
- package/docs/bundled/extensions/subagent.md +83 -71
- package/docs/compaction.md +6 -6
- package/docs/custom-provider.md +1 -1
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +8 -2
- package/docs/extensions.md +6 -2
- package/docs/json.md +6 -4
- package/docs/keybindings.md +9 -2
- package/docs/rpc.md +15 -4
- package/docs/sdk.md +9 -0
- package/docs/settings.md +31 -0
- package/docs/terminal-setup.md +23 -2
- package/docs/themes.md +24 -3
- package/docs/tui.md +2 -2
- package/docs/usage.md +4 -3
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +170 -221
- package/package.json +6 -6
- package/dist/extensions/subagent/display-name.d.ts +0 -6
- package/dist/extensions/subagent/display-name.d.ts.map +0 -1
- package/dist/extensions/subagent/display-name.js +0 -13
- package/dist/extensions/subagent/display-name.js.map +0 -1
- package/dist/extensions/subagent/ui/profile-editor.d.ts +0 -54
- package/dist/extensions/subagent/ui/profile-editor.d.ts.map +0 -1
- package/dist/extensions/subagent/ui/profile-editor.js +0 -154
- package/dist/extensions/subagent/ui/profile-editor.js.map +0 -1
- package/dist/extensions/subagent/ui/profile-picker.d.ts +0 -32
- package/dist/extensions/subagent/ui/profile-picker.d.ts.map +0 -1
- package/dist/extensions/subagent/ui/profile-picker.js +0 -149
- package/dist/extensions/subagent/ui/profile-picker.js.map +0 -1
- package/examples/extensions/subagent/README.md +0 -175
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -126
- package/examples/extensions/subagent/index.ts +0 -1009
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
|
@@ -1,223 +1,52 @@
|
|
|
1
1
|
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
2
|
-
import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
3
2
|
import { getMarkdownTheme } from "../../modes/interactive/theme/theme.js";
|
|
4
|
-
import { displayAgentName } from "./display-name.js";
|
|
5
3
|
import { getSubagentRetryView } from "./retry.js";
|
|
6
4
|
import { statusSummary } from "./runner.js";
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const PROMPT_PREVIEW_LINES = 2;
|
|
14
|
-
const PROMPT_PREVIEW_LINE_LIMIT = 120;
|
|
15
|
-
const ACTIVITY_SUMMARY_LIMIT = 96;
|
|
16
|
-
const ACTIVITY_RESULT_LIMIT = 64;
|
|
17
|
-
// Sub-10s tool calls are routine; a duration only earns ink when it
|
|
18
|
-
// explains where the time went.
|
|
5
|
+
import { firstPlainLine, plainLine } from "./text.js";
|
|
6
|
+
const TASK_SUMMARY_LIMIT = 72;
|
|
7
|
+
const ACTIVITY_SUMMARY_LIMIT = 120;
|
|
8
|
+
const ACTIVITY_RESULT_LIMIT = 96;
|
|
9
|
+
const RETRY_ERROR_LIMIT = 160;
|
|
10
|
+
const FALLBACK_OUTPUT_LIMIT = 4_000;
|
|
19
11
|
const ACTIVITY_DURATION_MIN_MS = 10_000;
|
|
20
|
-
const EXPANDED_LIVE_TAIL_LINES = 3;
|
|
21
|
-
class IndentedText {
|
|
22
|
-
constructor(text, indent) {
|
|
23
|
-
this.text = new Text(text, 0, 0);
|
|
24
|
-
this.indent = indent;
|
|
25
|
-
}
|
|
26
|
-
render(width) {
|
|
27
|
-
const indent = Math.min(this.indent, Math.max(0, width - 1));
|
|
28
|
-
const prefix = " ".repeat(indent);
|
|
29
|
-
return this.text.render(Math.max(1, width - indent)).map((line) => `${prefix}${line}`);
|
|
30
|
-
}
|
|
31
|
-
invalidate() {
|
|
32
|
-
this.text.invalidate();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function singleAgentName(args) {
|
|
36
|
-
return displayAgentName(args.agent ?? "general");
|
|
37
|
-
}
|
|
38
12
|
function truncate(text, limit) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const trimmedAfter = text.slice(offset + match.length).trimStart();
|
|
59
|
-
const operatorAdjacent = CODE_OPERATOR_SUFFIX_PATTERN.test(trimmedBefore) || CODE_OPERATOR_PREFIX_PATTERN.test(trimmedAfter);
|
|
60
|
-
const keywordAdjacent = CODE_KEYWORD_SUFFIX_PATTERN.test(trimmedBefore);
|
|
61
|
-
return DUNDER_IDENTIFIER_PATTERN.test(content) &&
|
|
62
|
-
(pairedCodeDelimiter || codeAdjacent || operatorAdjacent || keywordAdjacent)
|
|
63
|
-
? match
|
|
64
|
-
: content;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// Transcript excerpts render inside plain Text components, so markdown
|
|
68
|
-
// punctuation would show up literally; strip the common inline syntax.
|
|
69
|
-
function stripInlineMarkdown(text) {
|
|
70
|
-
return (stripUnderscoreStrong(text.replace(/```[a-zA-Z0-9-]*/gu, ""))
|
|
71
|
-
.replace(/`([^`]*)`/gu, "$1")
|
|
72
|
-
// Demarcated bold only: `x**2**` is exponentiation, not emphasis.
|
|
73
|
-
.replace(/(?<![A-Za-z0-9])\*\*([^*]+)\*\*(?![A-Za-z0-9])/gu, "$1")
|
|
74
|
-
.replace(/\[([^\]]+)\]\([^)]*\)/gu, "$1")
|
|
75
|
-
.replace(/^#{1,6}\s+/gmu, ""));
|
|
76
|
-
}
|
|
77
|
-
// Markdown tables and horizontal rules turn into symbol soup when
|
|
78
|
-
// flattened onto one line; drop those lines before inline stripping.
|
|
79
|
-
function stripBlockMarkdown(text) {
|
|
80
|
-
return text
|
|
81
|
-
.split("\n")
|
|
82
|
-
.filter((line) => {
|
|
83
|
-
const trimmed = line.trim();
|
|
84
|
-
if (trimmed.startsWith("|"))
|
|
85
|
-
return false;
|
|
86
|
-
return !(trimmed.length >= 3 && /^[-—─═=*_|:\s]+$/u.test(trimmed));
|
|
87
|
-
})
|
|
88
|
-
.join("\n");
|
|
89
|
-
}
|
|
90
|
-
// finalOutput/liveText carry model-facing truncation notices from
|
|
91
|
-
// boundText/tailText. Only recognize their exact boundary lines so literal
|
|
92
|
-
// discussion of the marker remains visible in the transcript.
|
|
93
|
-
const OUTPUT_TRUNCATION_NOTICE_PATTERN = /^\[Output truncated(?:: \d+ bytes omitted)?\.\]$/u;
|
|
94
|
-
const EARLIER_OUTPUT_NOTICE = "[Earlier output omitted.]";
|
|
95
|
-
function terminalOutputNotice(text) {
|
|
96
|
-
const lines = text.split("\n");
|
|
97
|
-
let index = lines.length - 1;
|
|
98
|
-
while (index >= 0 && !lines[index]?.trim())
|
|
99
|
-
index--;
|
|
100
|
-
if (index < 0 || !OUTPUT_TRUNCATION_NOTICE_PATTERN.test(lines[index]?.trim() ?? "")) {
|
|
101
|
-
return { text, truncated: false };
|
|
102
|
-
}
|
|
103
|
-
lines.splice(index, 1);
|
|
104
|
-
return { text: lines.join("\n").trimEnd(), truncated: true };
|
|
105
|
-
}
|
|
106
|
-
function replaceBoundaryNotices(text) {
|
|
107
|
-
const lines = text.split("\n");
|
|
108
|
-
const first = lines.findIndex((line) => Boolean(line.trim()));
|
|
109
|
-
if (first >= 0 && lines[first]?.trim() === EARLIER_OUTPUT_NOTICE)
|
|
110
|
-
lines[first] = "…";
|
|
111
|
-
let last = lines.length - 1;
|
|
112
|
-
while (last >= 0 && !lines[last]?.trim())
|
|
113
|
-
last--;
|
|
114
|
-
if (last >= 0 && OUTPUT_TRUNCATION_NOTICE_PATTERN.test(lines[last]?.trim() ?? ""))
|
|
115
|
-
lines[last] = "…";
|
|
116
|
-
return lines.join("\n");
|
|
117
|
-
}
|
|
118
|
-
function plainExcerpt(text, limit) {
|
|
119
|
-
return truncate(stripInlineMarkdown(stripBlockMarkdown(text)).replace(/\s+/gu, " ").trim(), limit);
|
|
120
|
-
}
|
|
121
|
-
function excerpt(text, limit) {
|
|
122
|
-
return plainExcerpt(replaceBoundaryNotices(text), limit);
|
|
123
|
-
}
|
|
124
|
-
// Generated notice-only boundary lines must never become the live line the
|
|
125
|
-
// user watches; identical text in the body remains ordinary model output.
|
|
126
|
-
function liveTailLines(run) {
|
|
127
|
-
const { text } = terminalOutputNotice(run.liveText);
|
|
128
|
-
const lines = text
|
|
129
|
-
.split("\n")
|
|
130
|
-
.map((line) => line.trim())
|
|
131
|
-
.filter(Boolean);
|
|
132
|
-
if (lines[0] === EARLIER_OUTPUT_NOTICE)
|
|
133
|
-
lines.shift();
|
|
134
|
-
return lines;
|
|
135
|
-
}
|
|
136
|
-
function liveTail(run) {
|
|
137
|
-
const last = liveTailLines(run).at(-1);
|
|
138
|
-
return last ? excerpt(last, LIVE_TAIL_LIMIT) : undefined;
|
|
139
|
-
}
|
|
140
|
-
// Completed-run excerpts read better cut at a sentence boundary than
|
|
141
|
-
// mid-word; fall back to a hard truncate when no boundary lands in the
|
|
142
|
-
// second half of the window.
|
|
143
|
-
function leadingSentences(text, limit) {
|
|
144
|
-
const cleaned = excerpt(text, Number.MAX_SAFE_INTEGER);
|
|
145
|
-
if (cleaned.length <= limit)
|
|
146
|
-
return cleaned;
|
|
147
|
-
const window = cleaned.slice(0, limit);
|
|
148
|
-
let boundary = -1;
|
|
149
|
-
for (const match of window.matchAll(/[.!?。!?](?=\s|$)/gu)) {
|
|
150
|
-
boundary = (match.index ?? 0) + match[0].length;
|
|
151
|
-
}
|
|
152
|
-
if (boundary >= limit / 2)
|
|
153
|
-
return window.slice(0, boundary).trimEnd();
|
|
154
|
-
return truncate(cleaned, limit);
|
|
13
|
+
const characters = [...text];
|
|
14
|
+
return characters.length <= limit ? text : `${characters.slice(0, Math.max(0, limit - 1)).join("")}…`;
|
|
15
|
+
}
|
|
16
|
+
function taskPrompt(args, index, run) {
|
|
17
|
+
// Tool calls restored from before the tasks-array shape carry a legacy
|
|
18
|
+
// args object without `tasks`; those rows fall back to the description.
|
|
19
|
+
const tasks = args.tasks;
|
|
20
|
+
return tasks?.[index]?.prompt ?? run.description;
|
|
21
|
+
}
|
|
22
|
+
function taskSummary(args, index, run) {
|
|
23
|
+
const firstLine = firstPlainLine(taskPrompt(args, index, run));
|
|
24
|
+
return truncate(firstLine || plainLine(run.description) || `Task ${index + 1}`, TASK_SUMMARY_LIMIT);
|
|
25
|
+
}
|
|
26
|
+
function profileLabel(agent) {
|
|
27
|
+
if (agent === "explorer")
|
|
28
|
+
return "Explorer";
|
|
29
|
+
if (agent === "general")
|
|
30
|
+
return "General";
|
|
31
|
+
return agent;
|
|
155
32
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (!retry)
|
|
163
|
-
return undefined;
|
|
164
|
-
const status = retry.remainingSeconds > 0
|
|
165
|
-
? `Retrying (${retry.attempt}/${retry.maxAttempts}) in ${retry.remainingSeconds}s`
|
|
166
|
-
: `Retrying now… (${retry.attempt}/${retry.maxAttempts})`;
|
|
167
|
-
const error = excerpt(retry.error, RETRY_ERROR_EXCERPT_LIMIT);
|
|
168
|
-
return error ? `${status} — ${error}` : status;
|
|
169
|
-
}
|
|
170
|
-
// Translates raw tool traffic into what the worker is doing right now, so
|
|
171
|
-
// the collapsed card reads as a phase instead of a command line. Modelled
|
|
172
|
-
// on tool-type classification; the raw tool summary stays as evidence on
|
|
173
|
-
// the next line.
|
|
174
|
-
function runIntent(run) {
|
|
175
|
-
const retry = retryText(run);
|
|
176
|
-
if (retry)
|
|
177
|
-
return retry;
|
|
178
|
-
const current = run.currentActivity;
|
|
179
|
-
if (current && RETRY_MARKER_PATTERN.test(current))
|
|
180
|
-
return current;
|
|
181
|
-
const running = [...run.activities].reverse().find((activity) => activity.status === "running");
|
|
182
|
-
if (running) {
|
|
183
|
-
if (running.toolName === "edit" || running.toolName === "write")
|
|
184
|
-
return "Applying changes";
|
|
185
|
-
if (running.toolName === "bash") {
|
|
186
|
-
if (VERIFY_COMMAND_PATTERN.test(running.summary))
|
|
187
|
-
return "Verifying changes";
|
|
188
|
-
return INSPECT_COMMAND_PATTERN.test(running.summary) ? "Exploring code" : "Running commands";
|
|
189
|
-
}
|
|
190
|
-
return "Exploring code";
|
|
191
|
-
}
|
|
192
|
-
const recent = run.activities.slice(-5);
|
|
193
|
-
if (current && STREAM_MARKERS.has(current)) {
|
|
194
|
-
if (recent.some((activity) => activity.status === "failed"))
|
|
195
|
-
return "Investigating a failure";
|
|
196
|
-
return current;
|
|
197
|
-
}
|
|
198
|
-
if (recent.some((activity) => activity.status === "failed"))
|
|
199
|
-
return "Investigating a failure";
|
|
200
|
-
if (recent.some((activity) => activity.toolName === "edit" || activity.toolName === "write"))
|
|
201
|
-
return "Reviewing changes";
|
|
202
|
-
if (recent.length > 0)
|
|
203
|
-
return "Exploring code";
|
|
204
|
-
return current ?? "Thinking…";
|
|
33
|
+
function formatTokens(value) {
|
|
34
|
+
if (value < 1_000)
|
|
35
|
+
return String(value);
|
|
36
|
+
if (value < 1_000_000)
|
|
37
|
+
return `${(value / 1_000).toFixed(value < 10_000 ? 1 : 0)}k`;
|
|
38
|
+
return `${(value / 1_000_000).toFixed(1)}M`;
|
|
205
39
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const current = run.currentActivity;
|
|
212
|
-
if (!current || STREAM_MARKERS.has(current) || RETRY_MARKER_PATTERN.test(current))
|
|
213
|
-
return undefined;
|
|
214
|
-
return current;
|
|
40
|
+
function formatDuration(seconds) {
|
|
41
|
+
const roundedSeconds = Math.round(seconds);
|
|
42
|
+
if (roundedSeconds >= 60)
|
|
43
|
+
return `${Math.floor(roundedSeconds / 60)}m ${roundedSeconds % 60}s`;
|
|
44
|
+
return `${seconds.toFixed(seconds < 10 ? 1 : 0)}s`;
|
|
215
45
|
}
|
|
216
|
-
function
|
|
217
|
-
if (
|
|
46
|
+
function elapsed(startedAt, endedAt) {
|
|
47
|
+
if (startedAt === undefined)
|
|
218
48
|
return undefined;
|
|
219
|
-
|
|
220
|
-
return formatDuration(Math.max(0, (end - run.startedAt) / 1000));
|
|
49
|
+
return formatDuration(Math.max(0, ((endedAt ?? Date.now()) - startedAt) / 1_000));
|
|
221
50
|
}
|
|
222
51
|
function statusColor(status) {
|
|
223
52
|
switch (status) {
|
|
@@ -233,9 +62,6 @@ function statusColor(status) {
|
|
|
233
62
|
return "muted";
|
|
234
63
|
}
|
|
235
64
|
}
|
|
236
|
-
// The tool shell already paints a call-level status dot (● in
|
|
237
|
-
// warning/success/error), so `●` is off-limits here: `›` marks where the
|
|
238
|
-
// work currently is, and the remaining glyphs are terminal states.
|
|
239
65
|
function statusMarker(status, theme) {
|
|
240
66
|
const glyph = status === "completed"
|
|
241
67
|
? "✓"
|
|
@@ -249,413 +75,219 @@ function statusMarker(status, theme) {
|
|
|
249
75
|
return theme.fg(statusColor(status), glyph);
|
|
250
76
|
}
|
|
251
77
|
function statusWord(status) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
default:
|
|
262
|
-
return "Queued";
|
|
263
|
-
}
|
|
78
|
+
if (status === "completed")
|
|
79
|
+
return "Completed";
|
|
80
|
+
if (status === "failed")
|
|
81
|
+
return "Failed";
|
|
82
|
+
if (status === "aborted")
|
|
83
|
+
return "Aborted";
|
|
84
|
+
if (status === "running")
|
|
85
|
+
return "Running";
|
|
86
|
+
return "Queued";
|
|
264
87
|
}
|
|
265
|
-
function
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (run.usage.contextTokens)
|
|
275
|
-
items.push(`ctx: ${formatTokens(run.usage.contextTokens)}`);
|
|
276
|
-
return items.join(" · ");
|
|
88
|
+
function retryText(run) {
|
|
89
|
+
const retry = getSubagentRetryView(run);
|
|
90
|
+
if (!retry)
|
|
91
|
+
return undefined;
|
|
92
|
+
const state = retry.remainingSeconds > 0
|
|
93
|
+
? `Retrying (${retry.attempt}/${retry.maxAttempts}) in ${retry.remainingSeconds}s`
|
|
94
|
+
: `Retrying now… (${retry.attempt}/${retry.maxAttempts})`;
|
|
95
|
+
const error = truncate(plainLine(retry.error), RETRY_ERROR_LIMIT);
|
|
96
|
+
return error ? `${state} — ${error}` : state;
|
|
277
97
|
}
|
|
278
|
-
function
|
|
279
|
-
let line = runTitle(run, theme, index);
|
|
98
|
+
function runningDetail(run) {
|
|
280
99
|
const retry = retryText(run);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (
|
|
100
|
+
if (retry)
|
|
101
|
+
return retry;
|
|
102
|
+
if (run.currentActivity)
|
|
103
|
+
return truncate(plainLine(run.currentActivity), ACTIVITY_SUMMARY_LIMIT);
|
|
104
|
+
if (run.status === "queued")
|
|
105
|
+
return "Waiting for a worker slot";
|
|
106
|
+
if (run.status === "running" && run.usage.turns === 0 && run.usage.toolUses === 0)
|
|
107
|
+
return "Initializing…";
|
|
108
|
+
if (run.status === "running")
|
|
109
|
+
return "Thinking…";
|
|
110
|
+
if ((run.status === "failed" || run.status === "aborted") && run.error) {
|
|
111
|
+
return truncate(plainLine(run.error), ACTIVITY_RESULT_LIMIT);
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
function batchMarker(details, theme) {
|
|
116
|
+
if (details.runs.some((run) => run.status === "failed"))
|
|
117
|
+
return theme.fg("error", "×");
|
|
118
|
+
if (details.runs.some((run) => run.status === "aborted"))
|
|
119
|
+
return theme.fg("warning", "■");
|
|
120
|
+
return theme.fg("success", "✓");
|
|
121
|
+
}
|
|
122
|
+
function progressHeader(details, theme) {
|
|
123
|
+
const settled = details.runs.filter((run) => run.status !== "running" && run.status !== "queued").length;
|
|
124
|
+
return theme.fg("accent", `› ${settled}/${details.runs.length} done · ${elapsed(details.startedAt) ?? "0.0s"}`);
|
|
125
|
+
}
|
|
126
|
+
function taskRow(run, index, args, theme, live) {
|
|
127
|
+
let line = ` ${statusMarker(run.status, theme)} ${theme.fg("accent", profileLabel(run.agent))}${theme.fg("dim", ` · ${taskSummary(args, index, run)}`)}`;
|
|
128
|
+
const detail = live ? runningDetail(run) : undefined;
|
|
129
|
+
if (detail) {
|
|
288
130
|
line += theme.fg("dim", ` — ${detail}`);
|
|
289
|
-
if (run.status === "running") {
|
|
290
|
-
line += theme.fg("dim", ` · ${runProgressText(run)}`);
|
|
291
|
-
if (run.usage.cost)
|
|
292
|
-
line += theme.fg("dim", ` · $${run.usage.cost.toFixed(3)}`);
|
|
293
|
-
const elapsed = liveElapsed(run);
|
|
294
|
-
if (elapsed)
|
|
295
|
-
line += theme.fg("dim", ` · ${elapsed}`);
|
|
296
131
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
132
|
+
else if (run.status !== "running" && run.status !== "queued") {
|
|
133
|
+
const duration = elapsed(run.startedAt, run.endedAt);
|
|
134
|
+
if (duration)
|
|
135
|
+
line += theme.fg("dim", ` · ${duration}`);
|
|
300
136
|
}
|
|
301
137
|
return line;
|
|
302
138
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
return [...retrying, ...otherActive, ...settled].slice(0, COLLAPSED_RUN_LIMIT);
|
|
330
|
-
}
|
|
331
|
-
function singleCollapsedLines(details, theme) {
|
|
332
|
-
const run = details.runs[0];
|
|
333
|
-
if (!run)
|
|
334
|
-
return [theme.fg("muted", "Initializing…")];
|
|
335
|
-
if (run.status === "running" || run.status === "queued") {
|
|
336
|
-
const retry = retryText(run);
|
|
337
|
-
const isInitializing = run.status === "running" &&
|
|
338
|
-
!retry &&
|
|
339
|
-
run.usage.turns === 0 &&
|
|
340
|
-
run.usage.toolUses === 0 &&
|
|
341
|
-
run.liveText.length === 0;
|
|
342
|
-
const rawIntent = retry ??
|
|
343
|
-
(run.status === "queued"
|
|
344
|
-
? (run.currentActivity ?? statusWord(run.status))
|
|
345
|
-
: isInitializing
|
|
346
|
-
? "Initializing…"
|
|
347
|
-
: runIntent(run));
|
|
348
|
-
const intent = excerpt(rawIntent, LIVE_TAIL_LIMIT);
|
|
349
|
-
// No status marker here: the shell's call-level dot already covers
|
|
350
|
-
// the whole card, and a single run has nothing to disambiguate.
|
|
351
|
-
let status = theme.fg("dim", intent);
|
|
352
|
-
if (run.status === "running" && !isInitializing) {
|
|
353
|
-
status += theme.fg("dim", ` · ${runProgressText(run)}`);
|
|
354
|
-
if (run.usage.cost)
|
|
355
|
-
status += theme.fg("dim", ` · $${run.usage.cost.toFixed(3)}`);
|
|
356
|
-
const elapsed = liveElapsed(run);
|
|
357
|
-
if (elapsed)
|
|
358
|
-
status += theme.fg("dim", ` · ${elapsed}`);
|
|
359
|
-
}
|
|
360
|
-
const lines = [status];
|
|
361
|
-
const evidence = runEvidence(run);
|
|
362
|
-
if (evidence && evidence !== rawIntent)
|
|
363
|
-
lines.push(`${theme.fg("accent", "›")} ${theme.fg("dim", excerpt(evidence, LIVE_TAIL_LIMIT))}`);
|
|
364
|
-
const tail = liveTail(run);
|
|
365
|
-
if (tail)
|
|
366
|
-
lines.push(theme.fg("dim", tail));
|
|
367
|
-
return lines;
|
|
368
|
-
}
|
|
369
|
-
if (run.error)
|
|
370
|
-
return [theme.fg("error", excerpt(run.error, SINGLE_EXCERPT_LIMIT))];
|
|
371
|
-
if (run.finalOutput)
|
|
372
|
-
return [theme.fg("toolOutput", leadingSentences(run.finalOutput, SINGLE_EXCERPT_LIMIT))];
|
|
373
|
-
return [theme.fg("muted", statusWord(run.status))];
|
|
374
|
-
}
|
|
375
|
-
// Deep-trimmed settled footer: turns and per-run breakdowns belong to the
|
|
376
|
-
// expanded view. Parallel batches keep only whole-call numbers — the run
|
|
377
|
-
// rows above already localize the work.
|
|
378
|
-
function collapsedUsageText(details, extended) {
|
|
379
|
-
const usage = details.usage;
|
|
380
|
-
const items = [];
|
|
381
|
-
if (usage.totalTokens)
|
|
382
|
-
items.push(`${formatTokens(usage.totalTokens)} tok`);
|
|
383
|
-
if (extended && usage.toolUses)
|
|
384
|
-
items.push(`${usage.toolUses} tool use${usage.toolUses === 1 ? "" : "s"}`);
|
|
385
|
-
if (extended && usage.contextTokens)
|
|
386
|
-
items.push(`ctx: ${formatTokens(usage.contextTokens)}`);
|
|
387
|
-
if (usage.cost)
|
|
388
|
-
items.push(`$${usage.cost.toFixed(3)}`);
|
|
389
|
-
if (details.endedAt !== undefined) {
|
|
390
|
-
items.push(formatDuration(Math.max(0, (details.endedAt - details.startedAt) / 1000)));
|
|
391
|
-
}
|
|
392
|
-
return items.join(" · ");
|
|
393
|
-
}
|
|
394
|
-
function batchUsageText(details, isPartial) {
|
|
395
|
-
const usage = details.usage;
|
|
396
|
-
const items = [];
|
|
397
|
-
// The aggregate mixes settled and running runs while partial, and the
|
|
398
|
-
// running share is cache-inflated — quote the total only once settled.
|
|
399
|
-
if (!isPartial && usage.totalTokens)
|
|
400
|
-
items.push(`${formatTokens(usage.totalTokens)} tok`);
|
|
401
|
-
if (usage.toolUses)
|
|
402
|
-
items.push(`${usage.toolUses} tool use${usage.toolUses === 1 ? "" : "s"}`);
|
|
403
|
-
if (usage.turns)
|
|
404
|
-
items.push(`${usage.turns} turn${usage.turns === 1 ? "" : "s"}`);
|
|
405
|
-
if (usage.contextTokens)
|
|
406
|
-
items.push(`ctx: ${formatTokens(usage.contextTokens)}`);
|
|
407
|
-
if (usage.cost)
|
|
408
|
-
items.push(`$${usage.cost.toFixed(3)}`);
|
|
409
|
-
if (details.endedAt !== undefined) {
|
|
410
|
-
items.push(formatDuration(Math.max(0, (details.endedAt - details.startedAt) / 1000)));
|
|
411
|
-
}
|
|
412
|
-
return items.join(" · ");
|
|
413
|
-
}
|
|
414
|
-
function formatTokens(value) {
|
|
415
|
-
if (value < 1_000)
|
|
416
|
-
return String(value);
|
|
417
|
-
if (value < 1_000_000)
|
|
418
|
-
return `${(value / 1_000).toFixed(value < 10_000 ? 1 : 0)}k`;
|
|
419
|
-
return `${(value / 1_000_000).toFixed(1)}M`;
|
|
420
|
-
}
|
|
421
|
-
function formatDuration(seconds) {
|
|
422
|
-
const roundedSeconds = Math.round(seconds);
|
|
423
|
-
if (roundedSeconds >= 60)
|
|
424
|
-
return `${Math.floor(roundedSeconds / 60)}m ${roundedSeconds % 60}s`;
|
|
425
|
-
return `${seconds.toFixed(seconds < 10 ? 1 : 0)}s`;
|
|
426
|
-
}
|
|
427
|
-
function runDurationText(run) {
|
|
428
|
-
if (run.startedAt === undefined || run.endedAt === undefined)
|
|
429
|
-
return undefined;
|
|
430
|
-
return formatDuration(Math.max(0, (run.endedAt - run.startedAt) / 1000));
|
|
431
|
-
}
|
|
432
|
-
// One dim line per run: what it cost. Settled runs quote the real token
|
|
433
|
-
// total; running runs skip it (cache-inflated mid-run) and tick elapsed
|
|
434
|
-
// time instead. Batch sections fold model/thinking/cwd in here because
|
|
435
|
-
// their `──` header already carries verdict and duration.
|
|
436
|
-
function runMetricsText(run, includeIdentity) {
|
|
437
|
-
const usage = run.usage;
|
|
139
|
+
function outcomeSummary(details) {
|
|
140
|
+
const completed = details.runs.filter((run) => run.status === "completed").length;
|
|
141
|
+
const failed = details.runs.filter((run) => run.status === "failed").length;
|
|
142
|
+
const aborted = details.runs.filter((run) => run.status === "aborted").length;
|
|
143
|
+
const parts = [];
|
|
144
|
+
if (completed)
|
|
145
|
+
parts.push(`${completed} completed`);
|
|
146
|
+
if (failed)
|
|
147
|
+
parts.push(`${failed} failed`);
|
|
148
|
+
if (aborted)
|
|
149
|
+
parts.push(`${aborted} aborted`);
|
|
150
|
+
if (parts.length === 0)
|
|
151
|
+
parts.push(statusSummary(details));
|
|
152
|
+
const duration = elapsed(details.startedAt, details.endedAt);
|
|
153
|
+
if (duration)
|
|
154
|
+
parts.push(duration);
|
|
155
|
+
if (details.usage.cost)
|
|
156
|
+
parts.push(`$${details.usage.cost.toFixed(3)}`);
|
|
157
|
+
return parts.join(" · ");
|
|
158
|
+
}
|
|
159
|
+
function runMetrics(run) {
|
|
160
|
+
const items = [run.model];
|
|
161
|
+
if (run.thinking !== "off")
|
|
162
|
+
items.push(`${run.thinking} thinking`);
|
|
163
|
+
if (run.cwd)
|
|
164
|
+
items.push(`cwd: ${run.cwd}`);
|
|
438
165
|
const settled = run.status !== "running" && run.status !== "queued";
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
if (
|
|
448
|
-
items.push(
|
|
449
|
-
|
|
450
|
-
items.push(`${usage.toolUses} tool use${usage.toolUses === 1 ? "" : "s"}`);
|
|
451
|
-
if (usage.turns)
|
|
452
|
-
items.push(`${usage.turns} turn${usage.turns === 1 ? "" : "s"}`);
|
|
453
|
-
if (usage.contextTokens)
|
|
454
|
-
items.push(`ctx: ${formatTokens(usage.contextTokens)}`);
|
|
455
|
-
if (usage.cost)
|
|
456
|
-
items.push(`$${usage.cost.toFixed(3)}`);
|
|
457
|
-
const duration = settled ? (includeIdentity ? undefined : runDurationText(run)) : liveElapsed(run);
|
|
166
|
+
if (settled && run.usage.totalTokens)
|
|
167
|
+
items.push(`${formatTokens(run.usage.totalTokens)} tok`);
|
|
168
|
+
if (run.usage.toolUses)
|
|
169
|
+
items.push(`${run.usage.toolUses} tool use${run.usage.toolUses === 1 ? "" : "s"}`);
|
|
170
|
+
if (run.usage.turns)
|
|
171
|
+
items.push(`${run.usage.turns} turn${run.usage.turns === 1 ? "" : "s"}`);
|
|
172
|
+
if (run.usage.contextTokens)
|
|
173
|
+
items.push(`ctx: ${formatTokens(run.usage.contextTokens)}`);
|
|
174
|
+
if (run.usage.cost)
|
|
175
|
+
items.push(`$${run.usage.cost.toFixed(3)}`);
|
|
176
|
+
const duration = elapsed(run.startedAt, run.endedAt);
|
|
458
177
|
if (duration)
|
|
459
178
|
items.push(duration);
|
|
460
179
|
return items.join(" · ");
|
|
461
180
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const capped = boundedPrompt.truncated;
|
|
477
|
-
const section = [theme.fg("muted", "Prompt"), ...preview];
|
|
478
|
-
if (remaining > 0 || capped || clipped) {
|
|
479
|
-
let note = "… continues";
|
|
480
|
-
if (remaining > 0)
|
|
481
|
-
note += `, ${remaining} more line${remaining === 1 ? "" : "s"}`;
|
|
482
|
-
if (capped)
|
|
483
|
-
note += " · capped at 1KB";
|
|
484
|
-
section.push(theme.fg("muted", note));
|
|
181
|
+
function activityLine(activity, run, theme) {
|
|
182
|
+
const summary = activity.status === "running" && run.currentActivity
|
|
183
|
+
? truncate(plainLine(run.currentActivity), ACTIVITY_SUMMARY_LIMIT)
|
|
184
|
+
: truncate(plainLine(activity.summary), ACTIVITY_SUMMARY_LIMIT);
|
|
185
|
+
let line = activity.status === "failed"
|
|
186
|
+
? `${theme.fg("error", "×")} ${theme.fg("toolOutput", summary)}`
|
|
187
|
+
: activity.status === "running"
|
|
188
|
+
? `${theme.fg("accent", "›")} ${theme.fg("toolOutput", summary)}`
|
|
189
|
+
: ` ${theme.fg("toolOutput", summary)}`;
|
|
190
|
+
if (activity.status === "failed" && activity.resultSummary) {
|
|
191
|
+
line += theme.fg("error", ` · ${truncate(plainLine(activity.resultSummary), ACTIVITY_RESULT_LIMIT)}`);
|
|
192
|
+
}
|
|
193
|
+
if (activity.endedAt !== undefined && activity.endedAt - activity.startedAt >= ACTIVITY_DURATION_MIN_MS) {
|
|
194
|
+
line += theme.fg("dim", ` · ${formatDuration((activity.endedAt - activity.startedAt) / 1_000)}`);
|
|
485
195
|
}
|
|
486
|
-
return
|
|
196
|
+
return line;
|
|
197
|
+
}
|
|
198
|
+
function runHeader(run, index, args, theme) {
|
|
199
|
+
return `${theme.fg("dim", `── #${index + 1} `)}${statusMarker(run.status, theme)} ${theme.fg("accent", profileLabel(run.agent))}${theme.fg("dim", ` · ${taskSummary(args, index, run)}`)}`;
|
|
487
200
|
}
|
|
488
|
-
|
|
489
|
-
// bounded Prompt/Activity digest in the middle, then the full Report —
|
|
490
|
-
// the one unbounded element, placed last so the card ends where reading
|
|
491
|
-
// begins. Single runs skip the `──` header (the call header already names
|
|
492
|
-
// them); batch sections carry a numbered header matching the contents
|
|
493
|
-
// list above.
|
|
494
|
-
function renderRunDetails(run, theme, single, index) {
|
|
201
|
+
function renderRunningRun(run, index, args, theme) {
|
|
495
202
|
const container = new Container();
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
const identity = [run.model];
|
|
499
|
-
if (run.thinking !== "off")
|
|
500
|
-
identity.push(`${run.thinking} thinking`);
|
|
501
|
-
if (run.cwd)
|
|
502
|
-
identity.push(`cwd: ${run.cwd}`);
|
|
503
|
-
container.addChild(new Text(`${statusMarker(run.status, theme)} ${theme.fg(statusColor(run.status), statusWord(run.status))}${theme.fg("dim", ` · ${identity.join(" · ")}`)}`, 0, 0));
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
const label = index === undefined ? "" : `${index} · `;
|
|
507
|
-
const duration = settled ? runDurationText(run) : undefined;
|
|
508
|
-
container.addChild(new Text(`${theme.fg("dim", `── ${label}`)}${statusMarker(run.status, theme)} ${theme.fg("accent", displayAgentName(run.agent))}${theme.fg("dim", ` · ${truncate(run.description, 48)}`)}${duration ? theme.fg("dim", ` · ${duration}`) : ""}`, 0, 0));
|
|
509
|
-
}
|
|
510
|
-
if (run.status !== "queued") {
|
|
511
|
-
const metrics = runMetricsText(run, !single);
|
|
512
|
-
if (metrics)
|
|
513
|
-
container.addChild(new Text(theme.fg("dim", metrics), 0, 0));
|
|
514
|
-
}
|
|
203
|
+
container.addChild(new Text(runHeader(run, index, args, theme), 0, 0));
|
|
204
|
+
container.addChild(new Text(theme.fg("dim", runMetrics(run)), 0, 0));
|
|
515
205
|
const retry = retryText(run);
|
|
516
206
|
if (retry)
|
|
517
207
|
container.addChild(new Text(theme.fg("accent", retry), 0, 0));
|
|
518
208
|
container.addChild(new Spacer(1));
|
|
519
|
-
|
|
520
|
-
|
|
209
|
+
const total = Math.max(run.usage.toolUses, run.activities.length);
|
|
210
|
+
const label = total > run.activities.length ? `Activity · last ${run.activities.length} of ${total}` : "Activity";
|
|
211
|
+
container.addChild(new Text(theme.fg("muted", label), 0, 0));
|
|
521
212
|
if (run.activities.length > 0) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const label = total > run.activities.length ? `Activity · last ${run.activities.length} of ${total}` : "Activity";
|
|
525
|
-
container.addChild(new Text(theme.fg("muted", label), 0, 0));
|
|
526
|
-
for (const activity of run.activities) {
|
|
527
|
-
// Deviation earns ink: × and › are marked, success rows are quiet
|
|
528
|
-
// one-liners without result echoes.
|
|
529
|
-
let text;
|
|
530
|
-
if (activity.status === "failed") {
|
|
531
|
-
text = `${theme.fg("error", "×")} ${theme.fg("toolOutput", excerpt(activity.summary, ACTIVITY_SUMMARY_LIMIT))}`;
|
|
532
|
-
if (activity.resultSummary) {
|
|
533
|
-
text += ` ${theme.fg("error", `· ${excerpt(activity.resultSummary, ACTIVITY_RESULT_LIMIT)}`)}`;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
else if (activity.status === "running") {
|
|
537
|
-
text = `${theme.fg("accent", "›")} ${theme.fg("toolOutput", excerpt(activity.summary, ACTIVITY_SUMMARY_LIMIT))}`;
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
text = ` ${theme.fg("toolOutput", excerpt(activity.summary, ACTIVITY_SUMMARY_LIMIT))}`;
|
|
541
|
-
}
|
|
542
|
-
if (activity.endedAt !== undefined && activity.endedAt - activity.startedAt >= ACTIVITY_DURATION_MIN_MS) {
|
|
543
|
-
text += ` ${theme.fg("dim", `· ${formatDuration((activity.endedAt - activity.startedAt) / 1000)}`)}`;
|
|
544
|
-
}
|
|
545
|
-
container.addChild(new Text(text, 0, 0));
|
|
546
|
-
}
|
|
213
|
+
for (const activity of run.activities)
|
|
214
|
+
container.addChild(new Text(activityLine(activity, run, theme), 0, 0));
|
|
547
215
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
for (const line of tail) {
|
|
556
|
-
container.addChild(new Text(theme.fg("dim", excerpt(line, LIVE_TAIL_LIMIT)), 0, 0));
|
|
557
|
-
}
|
|
558
|
-
}
|
|
216
|
+
else {
|
|
217
|
+
const fallback = retry
|
|
218
|
+
? "Waiting to retry"
|
|
219
|
+
: run.status === "failed" || run.status === "aborted"
|
|
220
|
+
? "No activity recorded"
|
|
221
|
+
: (runningDetail(run) ?? statusWord(run.status));
|
|
222
|
+
container.addChild(new Text(theme.fg("dim", ` ${fallback}`), 0, 0));
|
|
559
223
|
}
|
|
560
224
|
if (run.error) {
|
|
561
225
|
container.addChild(new Spacer(1));
|
|
562
226
|
container.addChild(new Text(theme.fg("muted", "Error"), 0, 0));
|
|
563
227
|
container.addChild(new Text(theme.fg("error", run.error), 0, 0));
|
|
564
228
|
}
|
|
565
|
-
|
|
229
|
+
return container;
|
|
230
|
+
}
|
|
231
|
+
function renderSettledRun(run, index, args, theme) {
|
|
232
|
+
const container = new Container();
|
|
233
|
+
container.addChild(new Text(runHeader(run, index, args, theme), 0, 0));
|
|
234
|
+
container.addChild(new Text(theme.fg("dim", runMetrics(run)), 0, 0));
|
|
235
|
+
container.addChild(new Spacer(1));
|
|
236
|
+
container.addChild(new Text(theme.fg("muted", "Prompt"), 0, 0));
|
|
237
|
+
container.addChild(new Text(theme.fg("toolOutput", taskPrompt(args, index, run)), 0, 0));
|
|
238
|
+
if (run.error) {
|
|
566
239
|
container.addChild(new Spacer(1));
|
|
567
|
-
|
|
568
|
-
container.addChild(new Text(theme.fg("
|
|
569
|
-
|
|
240
|
+
container.addChild(new Text(theme.fg("muted", "Error"), 0, 0));
|
|
241
|
+
container.addChild(new Text(theme.fg("error", run.error), 0, 0));
|
|
242
|
+
}
|
|
243
|
+
container.addChild(new Spacer(1));
|
|
244
|
+
const reportLabel = run.status !== "completed" && run.report ? "Report · partial" : "Report";
|
|
245
|
+
container.addChild(new Text(theme.fg("muted", reportLabel), 0, 0));
|
|
246
|
+
if (run.report) {
|
|
247
|
+
container.addChild(new Markdown(run.report, 0, 0, getMarkdownTheme(), {
|
|
570
248
|
color: (text) => theme.fg("toolOutput", text),
|
|
571
249
|
}));
|
|
572
250
|
}
|
|
251
|
+
else {
|
|
252
|
+
container.addChild(new Text(theme.fg("muted", "(No report.)"), 0, 0));
|
|
253
|
+
}
|
|
573
254
|
return container;
|
|
574
255
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
256
|
+
function fallbackResult(result, theme, isError) {
|
|
257
|
+
const text = result.content.find((part) => part.type === "text");
|
|
258
|
+
const value = text?.type === "text" ? truncate(text.text, FALLBACK_OUTPUT_LIMIT) : "(no output)";
|
|
259
|
+
return new Text(theme.fg(isError ? "error" : "muted", value), 0, 0);
|
|
260
|
+
}
|
|
579
261
|
export function renderSubagentCall(args, theme) {
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
if (args.tasks) {
|
|
585
|
-
return new Text(`${theme.fg("toolTitle", theme.bold("Multi-Agent"))}${theme.fg("dim", ` · ${args.tasks.length} task${args.tasks.length === 1 ? "" : "s"}`)}`, 0, 0);
|
|
586
|
-
}
|
|
587
|
-
let text = theme.fg("toolTitle", theme.bold(`${singleAgentName(args)} Agent`));
|
|
588
|
-
if (args.description)
|
|
589
|
-
text += theme.fg("dim", ` · ${truncate(args.description, 72)}`);
|
|
590
|
-
return new Text(text, 0, 0);
|
|
262
|
+
const count = Array.isArray(args.tasks) ? args.tasks.length : 0;
|
|
263
|
+
const label = `${count} task${count === 1 ? "" : "s"}`;
|
|
264
|
+
return new Text(`${theme.fg("toolTitle", theme.bold("Subagent"))}${theme.fg(count > 0 ? "dim" : "error", ` · ${label}`)}`, 0, 0);
|
|
591
265
|
}
|
|
592
|
-
export function renderSubagentResult(result, options, theme, isError) {
|
|
266
|
+
export function renderSubagentResult(result, options, theme, args, isError) {
|
|
593
267
|
const details = result.details;
|
|
594
|
-
if (!details)
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
return new Text(theme.fg(isError ? "error" : "muted", label), 0, 0);
|
|
598
|
-
}
|
|
599
|
-
// The pre-resolution first paint carries no runs yet, in either mode.
|
|
600
|
-
if (details.runs.length === 0) {
|
|
268
|
+
if (!details || !Array.isArray(details.runs))
|
|
269
|
+
return fallbackResult(result, theme, isError);
|
|
270
|
+
if (details.runs.length === 0)
|
|
601
271
|
return new Text(theme.fg("muted", "Initializing…"), 0, 0);
|
|
602
|
-
}
|
|
603
272
|
if (!options.expanded) {
|
|
604
|
-
if (details.mode === "single") {
|
|
605
|
-
const lines = singleCollapsedLines(details, theme);
|
|
606
|
-
if (!options.isPartial) {
|
|
607
|
-
const usage = collapsedUsageText(details, true);
|
|
608
|
-
if (usage)
|
|
609
|
-
lines.push(theme.fg("dim", usage));
|
|
610
|
-
lines.push(theme.fg("muted", `(${keyHint("app.tools.expand", "to expand")})`));
|
|
611
|
-
}
|
|
612
|
-
return new Text(lines.join("\n"), 0, 0);
|
|
613
|
-
}
|
|
614
273
|
const container = new Container();
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
// Stable ordinals (the run's task position, not its display slot)
|
|
622
|
-
// keep identity readable while active-first ordering reshuffles
|
|
623
|
-
// rows, and match the expanded section numbers.
|
|
624
|
-
for (const run of shown)
|
|
625
|
-
addRunSummary(container, run, theme, details.runs.indexOf(run) + 1);
|
|
626
|
-
const hidden = details.runs.length - shown.length;
|
|
627
|
-
if (hidden > 0)
|
|
628
|
-
container.addChild(new Text(theme.fg("muted", `+${hidden} more`), 0, 0));
|
|
629
|
-
if (!options.isPartial) {
|
|
630
|
-
const usage = collapsedUsageText(details, false);
|
|
631
|
-
if (usage)
|
|
632
|
-
container.addChild(new Text(theme.fg("dim", usage), 0, 0));
|
|
633
|
-
container.addChild(new Text(theme.fg("muted", `(${keyHint("app.tools.expand", "to expand")})`), 0, 0));
|
|
274
|
+
const header = options.isPartial
|
|
275
|
+
? progressHeader(details, theme)
|
|
276
|
+
: `${batchMarker(details, theme)} ${theme.fg(isError ? "error" : "muted", outcomeSummary(details))}`;
|
|
277
|
+
container.addChild(new Text(header, 0, 0));
|
|
278
|
+
for (const [index, run] of details.runs.entries()) {
|
|
279
|
+
container.addChild(new Text(taskRow(run, index, args, theme, options.isPartial), 0, 0));
|
|
634
280
|
}
|
|
635
281
|
return container;
|
|
636
282
|
}
|
|
637
283
|
const container = new Container();
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
addRunSummary(container, run, theme, index + 1);
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
details.runs.forEach((run, index) => {
|
|
649
|
-
if (!single || index > 0)
|
|
650
|
-
container.addChild(new Spacer(1));
|
|
651
|
-
container.addChild(renderRunDetails(run, theme, single, single ? undefined : index + 1));
|
|
652
|
-
});
|
|
653
|
-
if (!single) {
|
|
654
|
-
const usage = batchUsageText(details, Boolean(options.isPartial));
|
|
655
|
-
if (usage) {
|
|
656
|
-
container.addChild(new Spacer(1));
|
|
657
|
-
container.addChild(new Text(theme.fg("dim", usage), 0, 0));
|
|
658
|
-
}
|
|
284
|
+
const header = options.isPartial
|
|
285
|
+
? progressHeader(details, theme)
|
|
286
|
+
: `${batchMarker(details, theme)} ${theme.fg(isError ? "error" : "toolTitle", outcomeSummary(details))}`;
|
|
287
|
+
container.addChild(new Text(header, 0, 0));
|
|
288
|
+
for (const [index, run] of details.runs.entries()) {
|
|
289
|
+
container.addChild(new Spacer(1));
|
|
290
|
+
container.addChild(options.isPartial ? renderRunningRun(run, index, args, theme) : renderSettledRun(run, index, args, theme));
|
|
659
291
|
}
|
|
660
292
|
return container;
|
|
661
293
|
}
|