@herbertgao/pi-extensions 2026.11.8 → 2026.11.10
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 +16 -0
- package/README.md +9 -9
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +8 -6
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +8 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +12 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +36 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +4 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +7 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +115 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +47 -15
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/startup-header.ts +3 -18
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +27 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +30 -17
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +4 -21
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +3 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-mode.ts +34 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +25 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/keybindings.ts +75 -0
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +26 -17
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +71 -8
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +83 -34
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +18 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +10 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-tree.ts +47 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +7 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +211 -47
- package/node_modules/@narumitw/pi-btw/CHANGELOG.md +7 -0
- package/node_modules/@narumitw/pi-btw/package.json +2 -2
- package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +7 -0
- package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
- package/node_modules/pi-commandcode-provider/CHANGELOG.md +5 -0
- package/node_modules/pi-commandcode-provider/package.json +1 -1
- package/node_modules/pi-commandcode-provider/src/pricing.ts +4 -4
- package/package.json +7 -7
|
@@ -171,6 +171,7 @@ import {
|
|
|
171
171
|
mentionRoster,
|
|
172
172
|
type TypeInfo,
|
|
173
173
|
} from "./ui/agent-mention.js"
|
|
174
|
+
import { agentTree } from "./ui/agent-tree.js"
|
|
174
175
|
import {
|
|
175
176
|
type AgentActivity,
|
|
176
177
|
type AgentDetails,
|
|
@@ -714,7 +715,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
714
715
|
widget.update()
|
|
715
716
|
fleet.update()
|
|
716
717
|
}
|
|
717
|
-
/** Name the model and thinking level on the widget's running rows. */
|
|
718
|
+
/** Name the model and thinking level on the widget's running rows and the fleet rows. */
|
|
718
719
|
let showModel = false
|
|
719
720
|
function isShowModelEnabled(): boolean {
|
|
720
721
|
return showModel
|
|
@@ -722,6 +723,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
722
723
|
function setShowModel(b: boolean): void {
|
|
723
724
|
showModel = b
|
|
724
725
|
widget.update()
|
|
726
|
+
fleet.update()
|
|
725
727
|
}
|
|
726
728
|
/**
|
|
727
729
|
* How much of the conversation viewer renders as Markdown. Read through a
|
|
@@ -1733,6 +1735,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1733
1735
|
),
|
|
1734
1736
|
getFullscreenScrollbar,
|
|
1735
1737
|
backgroundActionFor,
|
|
1738
|
+
isShowModelEnabled,
|
|
1736
1739
|
)
|
|
1737
1740
|
let fleetViewEnabled = true
|
|
1738
1741
|
function isFleetViewEnabled(): boolean {
|
|
@@ -2079,6 +2082,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2079
2082
|
{
|
|
2080
2083
|
setMaxConcurrent: (n) => manager.setMaxConcurrent(n),
|
|
2081
2084
|
setMaxConcurrentForeground: (n) => manager.setMaxConcurrentForeground(n),
|
|
2085
|
+
setMaxConcurrentNested: (n) => manager.setMaxConcurrentNested(n),
|
|
2082
2086
|
setDefaultMaxTurns,
|
|
2083
2087
|
setGraceTurns,
|
|
2084
2088
|
setDefaultJoinMode,
|
|
@@ -4026,7 +4030,7 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4026
4030
|
const options: string[] = []
|
|
4027
4031
|
|
|
4028
4032
|
// Running agents entry (only if there are active agents)
|
|
4029
|
-
const agents =
|
|
4033
|
+
const agents = runningAgentsRoster().map((row) => row.record)
|
|
4030
4034
|
if (agents.length > 0) {
|
|
4031
4035
|
const running = agents.filter(
|
|
4032
4036
|
(a) => a.status === "running" || a.status === "queued",
|
|
@@ -4163,9 +4167,21 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4163
4167
|
}
|
|
4164
4168
|
}
|
|
4165
4169
|
|
|
4170
|
+
/**
|
|
4171
|
+
* The session's agents plus their nested children, as a tree (newest
|
|
4172
|
+
* top-level first). Nested children are listed here as in FleetView: this
|
|
4173
|
+
* list keeps finished agents until eviction, so it is where a finished child
|
|
4174
|
+
* stays reachable. Workflow agents stay in the workflow inspector.
|
|
4175
|
+
*/
|
|
4176
|
+
function runningAgentsRoster() {
|
|
4177
|
+
return agentTree(
|
|
4178
|
+
manager.listAgents().filter((a) => a.workflowId === undefined),
|
|
4179
|
+
)
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4166
4182
|
async function showRunningAgents(ctx: ExtensionCommandContext) {
|
|
4167
|
-
const
|
|
4168
|
-
if (
|
|
4183
|
+
const rows = runningAgentsRoster()
|
|
4184
|
+
if (rows.length === 0) {
|
|
4169
4185
|
ctx.ui.notify("No agents.", "info")
|
|
4170
4186
|
return
|
|
4171
4187
|
}
|
|
@@ -4173,12 +4189,18 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4173
4189
|
// Numbered + item-paired. Two same-type agents spawned together with the
|
|
4174
4190
|
// same description render identically here, and resolving the choice by
|
|
4175
4191
|
// string match would open whichever came first.
|
|
4176
|
-
const
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4192
|
+
const row = await selectItem(
|
|
4193
|
+
ctx.ui,
|
|
4194
|
+
"Running agents",
|
|
4195
|
+
rows,
|
|
4196
|
+
({ record: a, prefix }) => {
|
|
4197
|
+
const dn = getDisplayName(a.type)
|
|
4198
|
+
const dur = formatDuration(a.startedAt, a.completedAt)
|
|
4199
|
+
return `${prefix}${dn} (${a.description}) · ${a.toolUses} tools · ${a.status} · ${dur}`
|
|
4200
|
+
},
|
|
4201
|
+
)
|
|
4202
|
+
if (!row) return
|
|
4203
|
+
const record = row.record
|
|
4182
4204
|
|
|
4183
4205
|
await viewAgentConversation(ctx, record)
|
|
4184
4206
|
// Back-navigation: re-show the list
|
|
@@ -4672,6 +4694,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4672
4694
|
maxConcurrent: manager.getMaxConcurrent(),
|
|
4673
4695
|
// 0 = unlimited, and the default — see SubagentsSettings.
|
|
4674
4696
|
maxConcurrentForeground: manager.getMaxConcurrentForeground(),
|
|
4697
|
+
maxConcurrentNested: manager.getMaxConcurrentNested(),
|
|
4675
4698
|
// 0 = unlimited — per SubagentsSettings.defaultMaxTurns docstring and
|
|
4676
4699
|
// normalizeMaxTurns() in agent-runner.ts (which maps 0 → undefined).
|
|
4677
4700
|
defaultMaxTurns: getDefaultMaxTurns() ?? 0,
|
|
@@ -4758,6 +4781,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4758
4781
|
const NUMERIC_IDS = new Set([
|
|
4759
4782
|
"maxConcurrent",
|
|
4760
4783
|
"maxConcurrentForeground",
|
|
4784
|
+
"maxConcurrentNested",
|
|
4761
4785
|
"defaultMaxTurns",
|
|
4762
4786
|
"graceTurns",
|
|
4763
4787
|
"maxSubagentDepth",
|
|
@@ -4767,6 +4791,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4767
4791
|
function buildItems(): SettingItem[] {
|
|
4768
4792
|
const mc = manager.getMaxConcurrent()
|
|
4769
4793
|
const mcf = manager.getMaxConcurrentForeground()
|
|
4794
|
+
const mcn = manager.getMaxConcurrentNested()
|
|
4770
4795
|
const dmt = getDefaultMaxTurns() ?? 0
|
|
4771
4796
|
const gt = getGraceTurns()
|
|
4772
4797
|
const msd = getMaxSubagentDepth()
|
|
@@ -4781,8 +4806,9 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4781
4806
|
return [
|
|
4782
4807
|
{
|
|
4783
4808
|
id: "maxConcurrent",
|
|
4784
|
-
label: "Max concurrency",
|
|
4785
|
-
description:
|
|
4809
|
+
label: "Max background concurrency",
|
|
4810
|
+
description:
|
|
4811
|
+
"Max concurrent background agents; extras wait in a queue (Enter to type)",
|
|
4786
4812
|
currentValue: String(mc),
|
|
4787
4813
|
values: [String(mc)],
|
|
4788
4814
|
},
|
|
@@ -4790,10 +4816,26 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4790
4816
|
id: "maxConcurrentForeground",
|
|
4791
4817
|
label: "Max foreground concurrency",
|
|
4792
4818
|
description:
|
|
4793
|
-
"Max concurrent foreground (blocking) agents (0 = unlimited, Enter to type)",
|
|
4819
|
+
"Max concurrent foreground (blocking) agents; extras wait in a queue (0 = unlimited, Enter to type)",
|
|
4794
4820
|
currentValue: String(mcf),
|
|
4795
4821
|
values: [String(mcf)],
|
|
4796
4822
|
},
|
|
4823
|
+
{
|
|
4824
|
+
id: "maxConcurrentNested",
|
|
4825
|
+
label: "Max nested concurrency",
|
|
4826
|
+
description:
|
|
4827
|
+
"Max concurrent nested agents (started by subagents); extras are refused (0 = unlimited, Enter to type)",
|
|
4828
|
+
currentValue: String(mcn),
|
|
4829
|
+
values: [String(mcn)],
|
|
4830
|
+
},
|
|
4831
|
+
{
|
|
4832
|
+
id: "maxSubagentDepth",
|
|
4833
|
+
label: "Nested depth",
|
|
4834
|
+
description:
|
|
4835
|
+
"Hard cap on nested delegation — main is 0, its subagents 1 (0/1 = nesting off, Enter to type)",
|
|
4836
|
+
currentValue: String(msd),
|
|
4837
|
+
values: [String(msd)],
|
|
4838
|
+
},
|
|
4797
4839
|
{
|
|
4798
4840
|
id: "defaultMaxTurns",
|
|
4799
4841
|
label: "Default max turns",
|
|
@@ -4809,14 +4851,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4809
4851
|
currentValue: String(gt),
|
|
4810
4852
|
values: [String(gt)],
|
|
4811
4853
|
},
|
|
4812
|
-
{
|
|
4813
|
-
id: "maxSubagentDepth",
|
|
4814
|
-
label: "Nested depth",
|
|
4815
|
-
description:
|
|
4816
|
-
"Hard cap on nested delegation — main is 0, its subagents 1 (0/1 = nesting off, Enter to type)",
|
|
4817
|
-
currentValue: String(msd),
|
|
4818
|
-
values: [String(msd)],
|
|
4819
|
-
},
|
|
4820
4854
|
{
|
|
4821
4855
|
id: "joinMode",
|
|
4822
4856
|
label: "Join mode",
|
|
@@ -4944,7 +4978,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4944
4978
|
id: "showModel",
|
|
4945
4979
|
label: "Show model",
|
|
4946
4980
|
description:
|
|
4947
|
-
"Name the model driving each agent, and the thinking level it is running at, on the widget's running rows. The Agent tool result and the conversation viewer show the pair either way — this adds it
|
|
4981
|
+
"Name the model driving each agent, and the thinking level it is running at, on the widget's running rows and the fleet view rows. The Agent tool result and the conversation viewer show the pair either way — this adds it where the rows are already dense.",
|
|
4948
4982
|
currentValue: isShowModelEnabled() ? "on" : "off",
|
|
4949
4983
|
values: ["on", "off"],
|
|
4950
4984
|
},
|
|
@@ -5004,7 +5038,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5004
5038
|
const n = parseInt(value, 10)
|
|
5005
5039
|
if (n >= 1) {
|
|
5006
5040
|
manager.setMaxConcurrent(n)
|
|
5007
|
-
notifyApplied(ctx, `Max concurrency set to ${n}`)
|
|
5041
|
+
notifyApplied(ctx, `Max background concurrency set to ${n}`)
|
|
5008
5042
|
}
|
|
5009
5043
|
} else if (id === "maxConcurrentForeground") {
|
|
5010
5044
|
// 0 is meaningful here, unlike maxConcurrent above: it means unlimited.
|
|
@@ -5018,6 +5052,17 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5018
5052
|
: `Max foreground concurrency set to ${n}`,
|
|
5019
5053
|
)
|
|
5020
5054
|
}
|
|
5055
|
+
} else if (id === "maxConcurrentNested") {
|
|
5056
|
+
const n = parseInt(value, 10)
|
|
5057
|
+
if (n >= 0) {
|
|
5058
|
+
manager.setMaxConcurrentNested(n)
|
|
5059
|
+
notifyApplied(
|
|
5060
|
+
ctx,
|
|
5061
|
+
n === 0
|
|
5062
|
+
? "Max nested concurrency set to unlimited"
|
|
5063
|
+
: `Max nested concurrency set to ${n}`,
|
|
5064
|
+
)
|
|
5065
|
+
}
|
|
5021
5066
|
} else if (id === "defaultMaxTurns") {
|
|
5022
5067
|
const n = parseInt(value, 10)
|
|
5023
5068
|
if (n === 0) {
|
|
@@ -5265,22 +5310,26 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5265
5310
|
? String(manager.getMaxConcurrent())
|
|
5266
5311
|
: result === "maxConcurrentForeground"
|
|
5267
5312
|
? String(manager.getMaxConcurrentForeground())
|
|
5268
|
-
: result === "
|
|
5269
|
-
? String(
|
|
5270
|
-
: result === "
|
|
5271
|
-
? String(
|
|
5272
|
-
:
|
|
5313
|
+
: result === "maxConcurrentNested"
|
|
5314
|
+
? String(manager.getMaxConcurrentNested())
|
|
5315
|
+
: result === "defaultMaxTurns"
|
|
5316
|
+
? String(getDefaultMaxTurns() ?? 0)
|
|
5317
|
+
: result === "maxSubagentDepth"
|
|
5318
|
+
? String(getMaxSubagentDepth())
|
|
5319
|
+
: String(getGraceTurns())
|
|
5273
5320
|
|
|
5274
5321
|
const label =
|
|
5275
5322
|
result === "maxConcurrent"
|
|
5276
|
-
? "Max concurrency (1+)"
|
|
5323
|
+
? "Max background concurrency (1+)"
|
|
5277
5324
|
: result === "maxConcurrentForeground"
|
|
5278
5325
|
? "Max foreground concurrency (0 = unlimited)"
|
|
5279
|
-
: result === "
|
|
5280
|
-
? "
|
|
5281
|
-
: result === "
|
|
5282
|
-
? "
|
|
5283
|
-
:
|
|
5326
|
+
: result === "maxConcurrentNested"
|
|
5327
|
+
? "Max nested concurrency (0 = unlimited)"
|
|
5328
|
+
: result === "defaultMaxTurns"
|
|
5329
|
+
? "Default max turns (0 = unlimited)"
|
|
5330
|
+
: result === "maxSubagentDepth"
|
|
5331
|
+
? "Nested depth (0/1 = nesting off)"
|
|
5332
|
+
: "Grace turns (1+)"
|
|
5284
5333
|
|
|
5285
5334
|
// Loop until user enters a valid integer or cancels (Esc / null).
|
|
5286
5335
|
// Silently trims whitespace; rejects non-numeric input by re-prompting.
|
|
@@ -37,6 +37,13 @@ export interface SubagentsSettings {
|
|
|
37
37
|
* several blocking resumes in one message can still exceed the limit.
|
|
38
38
|
*/
|
|
39
39
|
maxConcurrentForeground?: number
|
|
40
|
+
/**
|
|
41
|
+
* Cap on running nested children (outside workflows) — `0` = unlimited,
|
|
42
|
+
* default 10. A nested spawn over it is refused, not queued, and the parent
|
|
43
|
+
* is told to do the work itself (#352). Top-level and workflow agents neither
|
|
44
|
+
* count nor are refused.
|
|
45
|
+
*/
|
|
46
|
+
maxConcurrentNested?: number
|
|
40
47
|
/**
|
|
41
48
|
* 0 = unlimited — the extension's single source of truth for that convention:
|
|
42
49
|
* `normalizeMaxTurns()` in agent-runner.ts treats 0 → `undefined`, and the
|
|
@@ -351,6 +358,7 @@ export type ToolDescriptionMode = "full" | "compact" | "custom"
|
|
|
351
358
|
export interface SettingsAppliers {
|
|
352
359
|
setMaxConcurrent: (n: number) => void
|
|
353
360
|
setMaxConcurrentForeground: (n: number) => void
|
|
361
|
+
setMaxConcurrentNested: (n: number) => void
|
|
354
362
|
setDefaultMaxTurns: (n: number) => void
|
|
355
363
|
setGraceTurns: (n: number) => void
|
|
356
364
|
setDefaultJoinMode: (mode: JoinMode) => void
|
|
@@ -448,6 +456,14 @@ function sanitize(raw: unknown): SubagentsSettings {
|
|
|
448
456
|
) {
|
|
449
457
|
out.maxConcurrentForeground = r.maxConcurrentForeground as number
|
|
450
458
|
}
|
|
459
|
+
// Floor 0 for the same reason: 0 is the documented "unlimited".
|
|
460
|
+
if (
|
|
461
|
+
Number.isInteger(r.maxConcurrentNested) &&
|
|
462
|
+
(r.maxConcurrentNested as number) >= 0 &&
|
|
463
|
+
(r.maxConcurrentNested as number) <= MAX_CONCURRENT_CEILING
|
|
464
|
+
) {
|
|
465
|
+
out.maxConcurrentNested = r.maxConcurrentNested as number
|
|
466
|
+
}
|
|
451
467
|
if (
|
|
452
468
|
Number.isInteger(r.defaultMaxTurns) &&
|
|
453
469
|
(r.defaultMaxTurns as number) >= 0 &&
|
|
@@ -625,6 +641,8 @@ export function applySettings(
|
|
|
625
641
|
if (typeof s.maxConcurrentForeground === "number") {
|
|
626
642
|
appliers.setMaxConcurrentForeground(s.maxConcurrentForeground)
|
|
627
643
|
}
|
|
644
|
+
if (typeof s.maxConcurrentNested === "number")
|
|
645
|
+
appliers.setMaxConcurrentNested(s.maxConcurrentNested)
|
|
628
646
|
if (typeof s.defaultMaxTurns === "number")
|
|
629
647
|
appliers.setDefaultMaxTurns(s.defaultMaxTurns)
|
|
630
648
|
if (typeof s.graceTurns === "number") appliers.setGraceTurns(s.graceTurns)
|
|
@@ -265,8 +265,18 @@ export interface AgentRecord {
|
|
|
265
265
|
* Lifetime usage breakdown, accumulated via `message_end` events. Survives
|
|
266
266
|
* compaction. Total = input + output + cacheWrite (cacheRead deliberately
|
|
267
267
|
* excluded — see issue #38). Initialized to zeros at spawn.
|
|
268
|
+
*
|
|
269
|
+
* Includes every descendant's spend: `nested-tools.ts` folds a nested
|
|
270
|
+
* child's turns into all its ancestors, because the child itself is hidden
|
|
271
|
+
* from the surfaces that read this field.
|
|
268
272
|
*/
|
|
269
273
|
lifetimeUsage: LifetimeUsage
|
|
274
|
+
/**
|
|
275
|
+
* This agent's own turns only — `lifetimeUsage` minus its descendants. What
|
|
276
|
+
* the fleet list shows, since it gives nested children rows of their own and
|
|
277
|
+
* the rolled-up figure would count their spend twice.
|
|
278
|
+
*/
|
|
279
|
+
ownUsage: LifetimeUsage
|
|
270
280
|
/** Number of times this agent's session has compacted. Initialized to 0 at spawn. */
|
|
271
281
|
compactionCount: number
|
|
272
282
|
/**
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-tree.ts — Nested subagents laid out under their parent.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the two surfaces that list nested children — FleetView and
|
|
5
|
+
* `/agents → Running agents` — so both draw the same tree. Every other
|
|
6
|
+
* user-facing surface filters on `isTopLevelAgent`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AgentRecord } from "../types.js"
|
|
10
|
+
|
|
11
|
+
export interface AgentTreeRow {
|
|
12
|
+
record: AgentRecord
|
|
13
|
+
/** Tree glyphs before the row (`├ `, `└ `, `│ ` continuation); `""` at top level. */
|
|
14
|
+
prefix: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `records` as a tree: each top-level record in the order given, then its
|
|
19
|
+
* children depth-first under it, siblings earliest-launched first. A child
|
|
20
|
+
* whose parent is not in `records` is dropped — it has no row to hang from.
|
|
21
|
+
*/
|
|
22
|
+
export function agentTree(records: readonly AgentRecord[]): AgentTreeRow[] {
|
|
23
|
+
const children = new Map<string, AgentRecord[]>()
|
|
24
|
+
for (const record of records) {
|
|
25
|
+
if (record.parentAgentId === undefined) continue
|
|
26
|
+
const siblings = children.get(record.parentAgentId)
|
|
27
|
+
if (siblings) siblings.push(record)
|
|
28
|
+
else children.set(record.parentAgentId, [record])
|
|
29
|
+
}
|
|
30
|
+
for (const siblings of children.values())
|
|
31
|
+
siblings.sort((a, b) => a.startedAt - b.startedAt)
|
|
32
|
+
|
|
33
|
+
const rows: AgentTreeRow[] = []
|
|
34
|
+
// `indent` is what a child's own children continue with: a rail under a
|
|
35
|
+
// `├`, blank under the last sibling's `└`.
|
|
36
|
+
const visit = (record: AgentRecord, prefix: string, indent: string): void => {
|
|
37
|
+
rows.push({ record, prefix })
|
|
38
|
+
const kids = children.get(record.id) ?? []
|
|
39
|
+
kids.forEach((kid, i) => {
|
|
40
|
+
const last = i === kids.length - 1
|
|
41
|
+
visit(kid, indent + (last ? "└ " : "├ "), indent + (last ? " " : "│ "))
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
for (const record of records)
|
|
45
|
+
if (record.parentAgentId === undefined) visit(record, "", "")
|
|
46
|
+
return rows
|
|
47
|
+
}
|
|
@@ -235,6 +235,7 @@ export function getPromptModeLabel(type: SubagentType): string | undefined {
|
|
|
235
235
|
export function buildInvocationTags(invocation: AgentInvocation | undefined): {
|
|
236
236
|
modelName?: string
|
|
237
237
|
modelId?: string
|
|
238
|
+
thinking?: string
|
|
238
239
|
tags: string[]
|
|
239
240
|
} {
|
|
240
241
|
const tags: string[] = []
|
|
@@ -257,6 +258,7 @@ export function buildInvocationTags(invocation: AgentInvocation | undefined): {
|
|
|
257
258
|
return {
|
|
258
259
|
modelName: asked(invocation.modelName, invocation.requestedModel),
|
|
259
260
|
modelId: asked(invocation.modelId, invocation.requestedModel),
|
|
261
|
+
thinking,
|
|
260
262
|
tags,
|
|
261
263
|
}
|
|
262
264
|
}
|
|
@@ -558,12 +560,12 @@ export class AgentWidget {
|
|
|
558
560
|
const parts: string[] = []
|
|
559
561
|
if (this.showModel()) {
|
|
560
562
|
// Leading, and paired: a thinking level means nothing without the model
|
|
561
|
-
// it applies to.
|
|
562
|
-
//
|
|
563
|
-
|
|
563
|
+
// it applies to. Both come from buildInvocationTags so the "(asked X)"
|
|
564
|
+
// annotation survives. The level is bare, not "thinking: high", as on
|
|
565
|
+
// the fleet row; the tag list keeps the label for the viewer and tool result.
|
|
566
|
+
const { modelName, thinking } = buildInvocationTags(a.invocation)
|
|
564
567
|
if (modelName) parts.push(modelName)
|
|
565
|
-
|
|
566
|
-
if (thinkingTag) parts.push(thinkingTag)
|
|
568
|
+
if (thinking) parts.push(thinking)
|
|
567
569
|
}
|
|
568
570
|
if (bg) parts.push(formatTurns(bg.turnCount, bg.maxTurns))
|
|
569
571
|
if (toolUses > 0)
|