@yandy0725/pi-subagents 0.2.1 → 0.3.0
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/README.md +1 -2
- package/README.zh.md +1 -2
- package/package.json +6 -9
- package/src/config/agent-types.ts +2 -2
- package/src/config/default-agents.ts +0 -51
- package/src/lifecycle/subagent-manager.ts +1 -1
- package/src/lifecycle/subagent-state.ts +1 -1
- package/src/observation/notification.ts +2 -2
- package/src/observation/renderer.ts +4 -4
- package/src/service/service-adapter.ts +3 -4
- package/src/session/conversation.ts +1 -1
- package/src/session/prompts.ts +2 -7
- package/src/tools/agent-tool.ts +2 -6
- package/src/tools/result-renderer.ts +13 -13
- package/src/tools/spawn-config.ts +8 -5
- package/src/ui/agent-widget.ts +3 -3
- package/src/ui/display.ts +2 -2
- package/src/ui/session-navigator.ts +1 -1
- package/src/ui/widget-renderer.ts +4 -4
package/README.md
CHANGED
|
@@ -44,7 +44,6 @@ Foreground agents block until complete. Background agents return an ID immediate
|
|
|
44
44
|
|------|-------|-------|-------------|
|
|
45
45
|
| `general-purpose` | all | inherit | Full parent system prompt — same rules, same conventions |
|
|
46
46
|
| `Explore` | read, bash, grep, find, ls | haiku (fallback: inherit) | Fast codebase exploration (read-only) |
|
|
47
|
-
| `Plan` | read, bash, grep, find, ls | inherit | Software architect for implementation planning (read-only) |
|
|
48
47
|
|
|
49
48
|
## Custom Agents
|
|
50
49
|
|
|
@@ -142,7 +141,7 @@ When `@yandy0725/pi-permission-system` is installed, the package integrates auto
|
|
|
142
141
|
|
|
143
142
|
```bash
|
|
144
143
|
npm run typecheck # tsc --noEmit
|
|
145
|
-
npm run
|
|
144
|
+
npm run lint # biome lint
|
|
146
145
|
npm test # vitest run
|
|
147
146
|
```
|
|
148
147
|
|
package/README.zh.md
CHANGED
|
@@ -44,7 +44,6 @@ subagent({
|
|
|
44
44
|
|------|------|------|------|
|
|
45
45
|
| `general-purpose` | 全部 | 继承父级 | 完整父级系统提示词——相同规则、相同约定 |
|
|
46
46
|
| `Explore` | read, bash, grep, find, ls | haiku(回退:继承) | 快速代码库探索(只读) |
|
|
47
|
-
| `Plan` | read, bash, grep, find, ls | 继承父级 | 软件架构师,实现方案设计(只读) |
|
|
48
47
|
|
|
49
48
|
## 自定义代理
|
|
50
49
|
|
|
@@ -142,7 +141,7 @@ max_turns: 30
|
|
|
142
141
|
|
|
143
142
|
```bash
|
|
144
143
|
npm run typecheck # tsc --noEmit
|
|
145
|
-
npm run
|
|
144
|
+
npm run lint # biome lint
|
|
146
145
|
npm test # vitest run
|
|
147
146
|
```
|
|
148
147
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.3.0",
|
|
7
7
|
"description": "Focused, in-process sub-agent core for pi — autonomous agents plus a typed API and lifecycle events",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"test:watch": "vitest",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"lint": "biome lint .",
|
|
27
|
-
"format": "biome format --write ."
|
|
28
|
-
"check": "biome check ."
|
|
27
|
+
"format": "biome format --write ."
|
|
29
28
|
},
|
|
30
29
|
"pi": {
|
|
31
30
|
"extensions": [
|
|
@@ -35,15 +34,13 @@
|
|
|
35
34
|
"peerDependencies": {
|
|
36
35
|
"@earendil-works/pi-ai": ">=0.80.2",
|
|
37
36
|
"@earendil-works/pi-coding-agent": ">=0.80.2",
|
|
38
|
-
"@earendil-works/pi-tui": ">=0.80.2"
|
|
39
|
-
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@sinclair/typebox": "^0.34.49"
|
|
37
|
+
"@earendil-works/pi-tui": ">=0.80.2",
|
|
38
|
+
"@sinclair/typebox": "*"
|
|
42
39
|
},
|
|
43
40
|
"devDependencies": {
|
|
44
|
-
"@biomejs/biome": "^2.5.
|
|
41
|
+
"@biomejs/biome": "^2.5.2",
|
|
45
42
|
"@types/node": "^22.0.0",
|
|
46
|
-
"typescript": "~
|
|
43
|
+
"typescript": "~6.0.3",
|
|
47
44
|
"vitest": "^3.0.0"
|
|
48
45
|
}
|
|
49
46
|
}
|
|
@@ -31,8 +31,8 @@ export interface AgentConfigLookup {
|
|
|
31
31
|
export class AgentTypeRegistry implements AgentConfigLookup {
|
|
32
32
|
private agents = new Map<string, AgentConfig>();
|
|
33
33
|
|
|
34
|
-
/** The
|
|
35
|
-
static readonly DEFAULT_AGENT_NAMES = ["general-purpose", "Explore"
|
|
34
|
+
/** The two embedded default agent names. */
|
|
35
|
+
static readonly DEFAULT_AGENT_NAMES = ["general-purpose", "Explore"] as const;
|
|
36
36
|
|
|
37
37
|
constructor(private loadUserAgents: () => Map<string, AgentConfig>) {
|
|
38
38
|
this.reload();
|
|
@@ -63,55 +63,4 @@ Use Bash ONLY for read-only operations: ls, git status, git log, git diff, find,
|
|
|
63
63
|
isDefault: true,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
-
[
|
|
67
|
-
"Plan",
|
|
68
|
-
{
|
|
69
|
-
name: "Plan",
|
|
70
|
-
displayName: "Plan",
|
|
71
|
-
description: "Software architect for implementation planning (read-only)",
|
|
72
|
-
builtinToolNames: READ_ONLY_TOOLS,
|
|
73
|
-
systemPrompt: `# CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS
|
|
74
|
-
You are a software architect and planning specialist.
|
|
75
|
-
Your role is EXCLUSIVELY to explore the codebase and design implementation plans.
|
|
76
|
-
You do NOT have access to file editing tools — attempting to edit files will fail.
|
|
77
|
-
|
|
78
|
-
You are STRICTLY PROHIBITED from:
|
|
79
|
-
- Creating new files
|
|
80
|
-
- Modifying existing files
|
|
81
|
-
- Deleting files
|
|
82
|
-
- Moving or copying files
|
|
83
|
-
- Creating temporary files anywhere, including /tmp
|
|
84
|
-
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
85
|
-
- Running ANY commands that change system state
|
|
86
|
-
|
|
87
|
-
# Planning Process
|
|
88
|
-
1. Understand requirements
|
|
89
|
-
2. Explore thoroughly (read files, find patterns, understand architecture)
|
|
90
|
-
3. Design solution based on your assigned perspective
|
|
91
|
-
4. Detail the plan with step-by-step implementation strategy
|
|
92
|
-
|
|
93
|
-
# Requirements
|
|
94
|
-
- Consider trade-offs and architectural decisions
|
|
95
|
-
- Identify dependencies and sequencing
|
|
96
|
-
- Anticipate potential challenges
|
|
97
|
-
- Follow existing patterns where appropriate
|
|
98
|
-
|
|
99
|
-
# Tool Usage
|
|
100
|
-
- Use the find tool for file pattern matching (NOT the bash find command)
|
|
101
|
-
- Use the grep tool for content search (NOT bash grep/rg command)
|
|
102
|
-
- Use the read tool for reading files (NOT bash cat/head/tail)
|
|
103
|
-
- Use Bash ONLY for read-only operations
|
|
104
|
-
|
|
105
|
-
# Output Format
|
|
106
|
-
- Use absolute file paths
|
|
107
|
-
- Do not use emojis
|
|
108
|
-
- End your response with:
|
|
109
|
-
|
|
110
|
-
### Critical Files for Implementation
|
|
111
|
-
List 3-5 files most critical for implementing this plan:
|
|
112
|
-
- /absolute/path/to/file.ts - [Brief reason]`,
|
|
113
|
-
promptMode: "replace",
|
|
114
|
-
isDefault: true,
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
66
|
]);
|
|
@@ -134,7 +134,7 @@ export class SubagentManager {
|
|
|
134
134
|
this.observer?.onSubagentStarted(agent);
|
|
135
135
|
},
|
|
136
136
|
onSessionCreated: options.observer?.onSessionCreated
|
|
137
|
-
? (agent) => options.observer
|
|
137
|
+
? (agent) => options.observer?.onSessionCreated?.(agent)
|
|
138
138
|
: undefined,
|
|
139
139
|
onRunFinished: (agent) => {
|
|
140
140
|
if (options.isBackground) {
|
|
@@ -122,7 +122,7 @@ export class SubagentState {
|
|
|
122
122
|
|
|
123
123
|
/** Record a tool starting. Called by record-observer on tool_execution_start. */
|
|
124
124
|
addActiveTool(toolName: string): void {
|
|
125
|
-
this._activeTools.set(toolName
|
|
125
|
+
this._activeTools.set(`${toolName}_${++this._toolKeySeq}`, toolName);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/** Remove one active tool by name (first match). Called by record-observer on tool_execution_end. */
|
|
@@ -53,7 +53,7 @@ export function formatTaskNotification(record: Subagent, resultMaxLen: number):
|
|
|
53
53
|
|
|
54
54
|
const resultPreview = record.result
|
|
55
55
|
? record.result.length > resultMaxLen
|
|
56
|
-
? record.result.slice(0, resultMaxLen)
|
|
56
|
+
? `${record.result.slice(0, resultMaxLen)}\n...(truncated, use get_subagent_result for full output)`
|
|
57
57
|
: record.result
|
|
58
58
|
: "No output.";
|
|
59
59
|
|
|
@@ -92,7 +92,7 @@ export function buildNotificationDetails(record: Subagent, resultMaxLen: number)
|
|
|
92
92
|
modelName: record.modelName,
|
|
93
93
|
resultPreview: record.result
|
|
94
94
|
? record.result.length > resultMaxLen
|
|
95
|
-
? record.result.slice(0, resultMaxLen)
|
|
95
|
+
? `${record.result.slice(0, resultMaxLen)}…`
|
|
96
96
|
: record.result
|
|
97
97
|
: "No output.",
|
|
98
98
|
};
|
|
@@ -42,21 +42,21 @@ export function createNotificationRenderer() {
|
|
|
42
42
|
if (d.totalTokens > 0) parts.push(formatTokens(d.totalTokens));
|
|
43
43
|
if (d.durationMs > 0) parts.push(formatMs(d.durationMs));
|
|
44
44
|
if (parts.length) {
|
|
45
|
-
line +=
|
|
45
|
+
line += `\n ${parts.map((p) => theme.fg("dim", p)).join(` ${theme.fg("dim", "·")} `)}`;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Line 3: result preview (collapsed) or full (expanded)
|
|
49
49
|
if (expanded) {
|
|
50
50
|
const lines = d.resultPreview.split("\n").slice(0, 30);
|
|
51
|
-
for (const l of lines) line +=
|
|
51
|
+
for (const l of lines) line += `\n${theme.fg("dim", ` ${l}`)}`;
|
|
52
52
|
} else {
|
|
53
53
|
const preview = d.resultPreview.split("\n")[0]?.slice(0, 80) ?? "";
|
|
54
|
-
line +=
|
|
54
|
+
line += `\n ${theme.fg("dim", `⎿ ${preview}`)}`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Line 4: output file link (if present)
|
|
58
58
|
if (d.outputFile) {
|
|
59
|
-
line +=
|
|
59
|
+
line += `\n ${theme.fg("muted", `transcript: ${d.outputFile}`)}`;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return new Text(line, 0, 0);
|
|
@@ -46,7 +46,6 @@ export class SubagentsServiceAdapter implements SubagentsService {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
let model: unknown;
|
|
49
|
-
let modelName: string | undefined;
|
|
50
49
|
if (options?.model) {
|
|
51
50
|
const registry = this.runtime.currentCtx.modelRegistry;
|
|
52
51
|
if (!registry) {
|
|
@@ -59,9 +58,9 @@ export class SubagentsServiceAdapter implements SubagentsService {
|
|
|
59
58
|
model = resolved;
|
|
60
59
|
}
|
|
61
60
|
// Always compute display model name, even when same as parent
|
|
62
|
-
modelName = resolveModelName(
|
|
63
|
-
(model as { id?: string; name?: string } | undefined) ??
|
|
64
|
-
(this.runtime.currentCtx.model as { id?: string; name?: string } | undefined),
|
|
61
|
+
const modelName = resolveModelName(
|
|
62
|
+
(model as { id?: string; name?: string; provider?: string } | undefined) ??
|
|
63
|
+
(this.runtime.currentCtx.model as { id?: string; name?: string; provider?: string } | undefined),
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
const description = options?.description ?? prompt.slice(0, 80);
|
|
@@ -27,7 +27,7 @@ export function getAgentConversation(session: AgentSession): string {
|
|
|
27
27
|
if (toolNames.length > 0) parts.push(`[Tool Calls]:\n${toolNames.map((n) => ` Tool: ${n}`).join("\n")}`);
|
|
28
28
|
} else if (msg.role === "toolResult") {
|
|
29
29
|
const text = extractText(msg.content);
|
|
30
|
-
const truncated = text.length > 200 ? text.slice(0, 200)
|
|
30
|
+
const truncated = text.length > 200 ? `${text.slice(0, 200)}...` : text;
|
|
31
31
|
parts.push(`[Tool Result (${msg.toolName})]: ${truncated}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/session/prompts.ts
CHANGED
|
@@ -46,11 +46,6 @@ Platform: ${env.platform}`;
|
|
|
46
46
|
if (config.promptMode === "append") {
|
|
47
47
|
const bridge = `<sub_agent_context>
|
|
48
48
|
You are operating as a sub-agent invoked to handle a specific task.
|
|
49
|
-
- Use the read tool instead of cat/head/tail
|
|
50
|
-
- Use the edit tool instead of sed/awk
|
|
51
|
-
- Use the write tool instead of echo/heredoc
|
|
52
|
-
- Use the find tool instead of bash find/ls for file search
|
|
53
|
-
- Use the grep tool instead of bash grep/rg for content search
|
|
54
49
|
- Make independent tool calls in parallel
|
|
55
50
|
- Use absolute file paths
|
|
56
51
|
- Do not use emojis
|
|
@@ -66,14 +61,14 @@ You are operating as a sub-agent invoked to handle a specific task.
|
|
|
66
61
|
// placed verbatim (no wrapper tag) so it forms an identical byte prefix
|
|
67
62
|
// with the parent session, maximising KV cache hits. The <active_agent>
|
|
68
63
|
// tag and env block vary per call and are placed after the cached prefix.
|
|
69
|
-
return identity
|
|
64
|
+
return `${identity}\n\n${bridge}\n\n${activeAgentTag}${envBlock}${customSection}`;
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
// "replace" mode — parent/genericBase prefix first for KV cache reuse, then
|
|
73
68
|
// the active_agent tag, env block, and the config's full system prompt.
|
|
74
69
|
// Unlike append mode, no <sub_agent_context> bridge or <agent_instructions>
|
|
75
70
|
// wrapper is injected — the custom prompt retains full control.
|
|
76
|
-
return identity
|
|
71
|
+
return `${identity}\n\n${activeAgentTag}${envBlock}\n\n${config.systemPrompt}`;
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
/** Fallback base prompt when parent system prompt is unavailable (both modes). */
|
package/src/tools/agent-tool.ts
CHANGED
|
@@ -113,7 +113,6 @@ export class AgentTool {
|
|
|
113
113
|
toToolDefinition() {
|
|
114
114
|
const typeListText = this.typeListText;
|
|
115
115
|
const availableTypesText = this.availableTypesText;
|
|
116
|
-
const agentDir = this.agentDir;
|
|
117
116
|
const registry = this.registry;
|
|
118
117
|
|
|
119
118
|
return defineTool({
|
|
@@ -129,9 +128,6 @@ ${typeListText}
|
|
|
129
128
|
|
|
130
129
|
Guidelines:
|
|
131
130
|
- For parallel work, use run_in_background: true on each agent. Foreground calls run sequentially — only one executes at a time.
|
|
132
|
-
- Use Explore for codebase searches and code understanding.
|
|
133
|
-
- Use Plan for architecture and implementation planning.
|
|
134
|
-
- Use general-purpose for complex tasks that need file editing.
|
|
135
131
|
- Provide clear, detailed prompts so the agent can work autonomously.
|
|
136
132
|
- Subagent results are returned as text — summarize them for the user.
|
|
137
133
|
- Use run_in_background for work you don't need immediately. You will be notified when it completes.
|
|
@@ -149,7 +145,7 @@ Guidelines:
|
|
|
149
145
|
description: "A short (3-5 word) description of the task (shown in UI).",
|
|
150
146
|
}),
|
|
151
147
|
subagent_type: Type.String({
|
|
152
|
-
description: `The type of specialized agent to use. Available types: ${availableTypesText}
|
|
148
|
+
description: `The type of specialized agent to use. Available types: ${availableTypesText}.`,
|
|
153
149
|
}),
|
|
154
150
|
model: Type.Optional(
|
|
155
151
|
Type.String({
|
|
@@ -192,7 +188,7 @@ Guidelines:
|
|
|
192
188
|
const displayName = args.subagent_type ? getDisplayName(args.subagent_type as string, registry) : "Subagent";
|
|
193
189
|
const desc = (args.description as string | undefined) ?? "";
|
|
194
190
|
return new Text(
|
|
195
|
-
|
|
191
|
+
`▸ ${theme.fg("toolTitle", theme.bold(displayName))}${desc ? ` ${theme.fg("muted", desc)}` : ""}`,
|
|
196
192
|
0,
|
|
197
193
|
0,
|
|
198
194
|
);
|
|
@@ -33,8 +33,8 @@ export function renderAgentResult(
|
|
|
33
33
|
export function renderRunning(details: AgentDetails, theme: Theme): string {
|
|
34
34
|
const frame = SPINNER[details.spinnerFrame ?? 0];
|
|
35
35
|
const s = renderStats(details, theme);
|
|
36
|
-
let line = theme.fg("accent", frame) + (s ?
|
|
37
|
-
line +=
|
|
36
|
+
let line = theme.fg("accent", frame) + (s ? ` ${s}` : "");
|
|
37
|
+
line += `\n${theme.fg("dim", ` ⎿ ${details.activity ?? "thinking\u2026"}`)}`;
|
|
38
38
|
return line;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -49,22 +49,22 @@ export function renderCompleted(details: AgentDetails, resultText: string, expan
|
|
|
49
49
|
const isSteered = details.status === "steered";
|
|
50
50
|
const icon = isSteered ? theme.fg("warning", "\u2713") : theme.fg("success", "\u2713");
|
|
51
51
|
const s = renderStats(details, theme);
|
|
52
|
-
let line = icon + (s ?
|
|
53
|
-
line +=
|
|
52
|
+
let line = icon + (s ? ` ${s}` : "");
|
|
53
|
+
line += ` ${theme.fg("dim", "\u00B7")} ${theme.fg("dim", duration)}`;
|
|
54
54
|
|
|
55
55
|
if (expanded) {
|
|
56
56
|
if (resultText) {
|
|
57
57
|
const lines = resultText.split("\n").slice(0, 50);
|
|
58
58
|
for (const l of lines) {
|
|
59
|
-
line +=
|
|
59
|
+
line += `\n${theme.fg("dim", ` ${l}`)}`;
|
|
60
60
|
}
|
|
61
61
|
if (resultText.split("\n").length > 50) {
|
|
62
|
-
line +=
|
|
62
|
+
line += `\n${theme.fg("muted", " ... (use get_subagent_result with verbose for full output)")}`;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
} else {
|
|
66
66
|
const doneText = isSteered ? "Wrapped up (turn limit)" : "Done";
|
|
67
|
-
line +=
|
|
67
|
+
line += `\n${theme.fg("dim", ` \u23BF ${doneText}`)}`;
|
|
68
68
|
}
|
|
69
69
|
return line;
|
|
70
70
|
}
|
|
@@ -72,20 +72,20 @@ export function renderCompleted(details: AgentDetails, resultText: string, expan
|
|
|
72
72
|
/** Render stopped status: dim stop icon + stats + "Stopped". */
|
|
73
73
|
export function renderStopped(details: AgentDetails, theme: Theme): string {
|
|
74
74
|
const s = renderStats(details, theme);
|
|
75
|
-
let line = theme.fg("dim", "\u25A0") + (s ?
|
|
76
|
-
line +=
|
|
75
|
+
let line = theme.fg("dim", "\u25A0") + (s ? ` ${s}` : "");
|
|
76
|
+
line += `\n${theme.fg("dim", " \u23BF Stopped")}`;
|
|
77
77
|
return line;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** Render error or aborted status: error icon + stats + status message. */
|
|
81
81
|
export function renderFailed(details: AgentDetails, theme: Theme): string {
|
|
82
82
|
const s = renderStats(details, theme);
|
|
83
|
-
let line = theme.fg("error", "\u2717") + (s ?
|
|
83
|
+
let line = theme.fg("error", "\u2717") + (s ? ` ${s}` : "");
|
|
84
84
|
|
|
85
85
|
if (details.status === "error") {
|
|
86
|
-
line +=
|
|
86
|
+
line += `\n${theme.fg("error", ` \u23BF Error: ${details.error ?? "unknown"}`)}`;
|
|
87
87
|
} else {
|
|
88
|
-
line +=
|
|
88
|
+
line += `\n${theme.fg("warning", " \u23BF Aborted (max turns exceeded)")}`;
|
|
89
89
|
}
|
|
90
90
|
return line;
|
|
91
91
|
}
|
|
@@ -105,5 +105,5 @@ export function renderStats(details: AgentDetails, theme: Theme): string {
|
|
|
105
105
|
}
|
|
106
106
|
if (details.toolUses > 0) parts.push(`${details.toolUses} tool use${details.toolUses === 1 ? "" : "s"}`);
|
|
107
107
|
if (details.tokens) parts.push(details.tokens);
|
|
108
|
-
return parts.map((p) => theme.fg("dim", p)).join(
|
|
108
|
+
return parts.map((p) => theme.fg("dim", p)).join(` ${theme.fg("dim", "\u00B7")} `);
|
|
109
109
|
}
|
|
@@ -16,16 +16,19 @@ import type { AgentInvocation, SubagentType, ThinkingLevel } from "../types";
|
|
|
16
16
|
import { type AgentDetails, buildInvocationTags, getDisplayName, getPromptModeLabel } from "../ui/display";
|
|
17
17
|
|
|
18
18
|
/** Derive a short display model name from a model object (or undefined). */
|
|
19
|
-
export function resolveModelName(
|
|
19
|
+
export function resolveModelName(
|
|
20
|
+
model: { id?: string; name?: string; provider?: string } | undefined,
|
|
21
|
+
): string | undefined {
|
|
20
22
|
if (!model) return undefined;
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
23
|
+
// Primary: provider/id complete format
|
|
24
|
+
if (model.provider && model.id) return `${model.provider}/${model.id}`;
|
|
25
|
+
// Fallback: raw name or id, no transformation
|
|
26
|
+
return model.name ?? model.id ?? undefined;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
/** Model info extracted from the parent session context. */
|
|
27
30
|
export interface ModelInfo {
|
|
28
|
-
parentModel: { id: string; name?: string } | undefined;
|
|
31
|
+
parentModel: { id: string; name?: string; provider?: string } | undefined;
|
|
29
32
|
modelRegistry: unknown;
|
|
30
33
|
}
|
|
31
34
|
|
package/src/ui/agent-widget.ts
CHANGED
|
@@ -203,12 +203,12 @@ export class AgentWidget implements SubagentManagerObserver {
|
|
|
203
203
|
*/
|
|
204
204
|
private clearWidget(backgroundAgents: readonly AgentSummary[]): void {
|
|
205
205
|
if (this.widgetRegistered) {
|
|
206
|
-
this.uiCtx
|
|
206
|
+
this.uiCtx?.setWidget("agents", undefined);
|
|
207
207
|
this.widgetRegistered = false;
|
|
208
208
|
this.tui = undefined;
|
|
209
209
|
}
|
|
210
210
|
if (this.lastStatusText !== undefined) {
|
|
211
|
-
this.uiCtx
|
|
211
|
+
this.uiCtx?.setStatus("subagents", undefined);
|
|
212
212
|
this.lastStatusText = undefined;
|
|
213
213
|
}
|
|
214
214
|
if (this.widgetInterval) {
|
|
@@ -234,7 +234,7 @@ export class AgentWidget implements SubagentManagerObserver {
|
|
|
234
234
|
newStatusText = `${statusParts.join(", ")} agent${total === 1 ? "" : "s"}`;
|
|
235
235
|
}
|
|
236
236
|
if (newStatusText !== this.lastStatusText) {
|
|
237
|
-
this.uiCtx
|
|
237
|
+
this.uiCtx?.setStatus("subagents", newStatusText);
|
|
238
238
|
this.lastStatusText = newStatusText;
|
|
239
239
|
}
|
|
240
240
|
}
|
package/src/ui/display.ts
CHANGED
|
@@ -142,7 +142,7 @@ function truncateLine(text: string, len = 60): string {
|
|
|
142
142
|
.find((l) => l.trim())
|
|
143
143
|
?.trim() ?? "";
|
|
144
144
|
if (line.length <= len) return line;
|
|
145
|
-
return line.slice(0, len)
|
|
145
|
+
return `${line.slice(0, len)}…`;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/** Build a human-readable activity string from currently-running tools or response text. */
|
|
@@ -162,7 +162,7 @@ export function describeActivity(activeTools: ReadonlyMap<string, string>, respo
|
|
|
162
162
|
parts.push(action);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
return parts.join(", ")
|
|
165
|
+
return `${parts.join(", ")}…`;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// No tools active — show truncated response text if available
|
|
@@ -270,7 +270,7 @@ export class TranscriptOverlay implements Component {
|
|
|
270
270
|
|
|
271
271
|
const pad = (s: string, len: number): string => s + " ".repeat(Math.max(0, len - visibleWidth(s)));
|
|
272
272
|
const row = (content: string): string =>
|
|
273
|
-
th.fg("border", "│")
|
|
273
|
+
`${th.fg("border", "│")} ${truncateToWidth(pad(content, innerW), innerW)} ${th.fg("border", "│")}`;
|
|
274
274
|
const hrTop = th.fg("border", `╭${"─".repeat(width - 2)}╮`);
|
|
275
275
|
const hrBot = th.fg("border", `╰${"─".repeat(width - 2)}╯`);
|
|
276
276
|
const hrMid = row(th.fg("dim", "─".repeat(innerW)));
|
|
@@ -159,14 +159,14 @@ function buildSections(
|
|
|
159
159
|
): WidgetSections {
|
|
160
160
|
const finishedLines: string[] = [];
|
|
161
161
|
for (const a of categories.finished) {
|
|
162
|
-
finishedLines.push(truncate(theme.fg("dim", "\u251C\u2500")
|
|
162
|
+
finishedLines.push(truncate(`${theme.fg("dim", "\u251C\u2500")} ${renderFinishedLine(a, registry, theme)}`));
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
const runningLines: [string, string][] = [];
|
|
166
166
|
for (const a of categories.running) {
|
|
167
167
|
const [header, act] = renderRunningLines(a, registry, spinnerFrame, theme);
|
|
168
168
|
runningLines.push([
|
|
169
|
-
truncate(theme.fg("dim", "\u251C\u2500")
|
|
169
|
+
truncate(`${theme.fg("dim", "\u251C\u2500")} ${header}`),
|
|
170
170
|
truncate(theme.fg("dim", "\u2502 ") + act),
|
|
171
171
|
]);
|
|
172
172
|
}
|
|
@@ -252,7 +252,7 @@ function assembleOverflow(
|
|
|
252
252
|
const overflowText = overflowParts.join(", ");
|
|
253
253
|
lines.push(
|
|
254
254
|
truncate(
|
|
255
|
-
theme.fg("dim", "\u2514\u2500")
|
|
255
|
+
`${theme.fg("dim", "\u2514\u2500")} ${theme.fg("dim", `+${hiddenRunning + hiddenFinished} more (${overflowText})`)}`,
|
|
256
256
|
),
|
|
257
257
|
);
|
|
258
258
|
return lines;
|
|
@@ -291,7 +291,7 @@ export function renderWidgetLines(params: {
|
|
|
291
291
|
// Assemble with overflow cap (heading takes 1 line).
|
|
292
292
|
const maxBody = MAX_WIDGET_LINES - 1;
|
|
293
293
|
const totalBody = finishedLines.length + runningLines.length * 2 + (queuedLine ? 1 : 0);
|
|
294
|
-
const heading = truncate(theme.fg(headingColor, headingIcon)
|
|
294
|
+
const heading = truncate(`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, "Agents")}`);
|
|
295
295
|
|
|
296
296
|
if (totalBody <= maxBody) {
|
|
297
297
|
return assembleWithinBudget(heading, { finishedLines, runningLines, queuedLine });
|