pi-my-compact-ui 0.2.2 → 0.4.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 +31 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2464 -0
- package/dist/index.js.map +7 -0
- package/dist/src/animation.d.ts +6 -0
- package/dist/src/assistant-patches.d.ts +31 -0
- package/dist/src/compaction.d.ts +8 -0
- package/dist/src/config.d.ts +18 -0
- package/dist/src/constants.d.ts +21 -0
- package/dist/src/extension.d.ts +3 -0
- package/dist/src/grouping.d.ts +16 -0
- package/dist/src/guards.d.ts +12 -0
- package/dist/src/helpers.d.ts +19 -0
- package/dist/src/markdown.d.ts +7 -0
- package/dist/src/modals.d.ts +38 -0
- package/dist/src/settings.d.ts +31 -0
- package/dist/src/state.d.ts +45 -0
- package/dist/src/streaming-tools.d.ts +16 -0
- package/dist/src/thinking.d.ts +5 -0
- package/dist/src/tool-group.d.ts +41 -0
- package/dist/src/types.d.ts +59 -0
- package/package.json +15 -5
- package/index.ts +0 -1744
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/guards.ts", "../src/tool-group.ts", "../src/state.ts", "../src/constants.ts", "../src/helpers.ts", "../src/assistant-patches.ts", "../src/markdown.ts", "../src/streaming-tools.ts", "../src/animation.ts", "../src/config.ts", "../src/thinking.ts", "../src/grouping.ts", "../src/compaction.ts", "../src/modals.ts", "../src/extension.ts", "../src/settings.ts"],
|
|
4
|
+
"sourcesContent": ["/** \u517C\u5BB9\u4E0D\u540C Pi/TUI \u6A21\u5757\u5B9E\u4F8B\u7684\u7EC4\u4EF6\u8BC6\u522B\u4E0E\u539F\u751F\u5DE5\u5177\u6E32\u67D3\u6291\u5236\u3002 */\nimport { Container, Spacer, Markdown, Text } from \"@earendil-works/pi-tui\";\nimport { AssistantMessageComponent, ToolExecutionComponent } from \"@earendil-works/pi-coding-agent\";\nimport { ToolGroupComponent } from \"./tool-group.js\";\nimport { TOOL_RENDER_PATCH_KEY, PARENT_KEY } from \"./constants.js\";\n\nexport function isContainer(val: any): val is Container {\n\treturn Boolean(\n\t\tval &&\n\t\t\t(val instanceof Container ||\n\t\t\t\tval.constructor?.name === \"Container\" ||\n\t\t\t\t(Array.isArray((val as any).children) && typeof (val as any).addChild === \"function\")),\n\t);\n}\n\nexport function isAssistantMessage(val: any): val is AssistantMessageComponent {\n\treturn Boolean(\n\t\tval &&\n\t\t\t(val instanceof AssistantMessageComponent ||\n\t\t\t\tval.constructor?.name === \"AssistantMessageComponent\"),\n\t);\n}\n\nexport function isToolExecution(val: any): val is ToolExecutionComponent {\n\treturn Boolean(\n\t\tval &&\n\t\t\t(val instanceof ToolExecutionComponent ||\n\t\t\t\tval.constructor?.name === \"ToolExecutionComponent\"),\n\t);\n}\n\nexport function isSpacer(val: any): val is Spacer {\n\treturn Boolean(val && (val instanceof Spacer || val.constructor?.name === \"Spacer\"));\n}\n\nexport function isMarkdown(val: any): val is Markdown {\n\treturn Boolean(val && (val instanceof Markdown || val.constructor?.name === \"Markdown\"));\n}\n\nexport function isText(val: any): val is Text {\n\treturn Boolean(val && (val instanceof Text || val.constructor?.name === \"Text\"));\n}\n\nexport function isToolGroup(val: any): val is ToolGroupComponent {\n\treturn Boolean(val && (val instanceof ToolGroupComponent || val.constructor?.name === \"ToolGroupComponent\"));\n}\n\nexport function hideGroupedToolRender(tool: any): void {\n\tconst prototype = tool ? Object.getPrototypeOf(tool) : undefined;\n\tif (!prototype || typeof prototype.render !== \"function\" || prototype[TOOL_RENDER_PATCH_KEY]) return;\n\tconst original = prototype.render as (this: any, width: number) => string[];\n\tconst installed = function (this: any, width: number): string[] {\n\t\tif (this?.[PARENT_KEY]) return [];\n\t\treturn original.call(this, width);\n\t};\n\tprototype.render = installed;\n\tprototype[TOOL_RENDER_PATCH_KEY] = { original, installed };\n}\n", "/** \u6309\u7167\u539F\u59CB\u6761\u76EE\u987A\u5E8F\u6E32\u67D3\u6298\u53E0\u5206\u7EC4\u4E0E\u6709\u754C Markdown \u9884\u89C8\u3002 */\nimport { Container, Markdown, visibleWidth, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { DefaultTextStyle } from \"@earendil-works/pi-tui\";\nimport type { GroupEntry, MarkdownPreview, ThinkingEntry } from \"./types.js\";\nimport { absorbPreparingTool, rememberToolStart, toolElapsed } from \"./streaming-tools.js\";\nimport { hideGroupedToolRender } from \"./guards.js\";\nimport { PARENT_KEY, SPINNER, spinnerStart, SPINNER_MS, GROUP_PADDING_X, GROUP_PADDING_RIGHT } from \"./constants.js\";\nimport { toolStatus, toolSummary, thinkingTokenLabel, toolResultText } from \"./helpers.js\";\nimport { getCompactMarkdownTheme, normalizeCompactCodeBlockLines } from \"./markdown.js\";\nimport { runtime } from \"./state.js\";\nimport { thinkingSpinnerFrame, scheduleAnimation } from \"./animation.js\";\nimport { config } from \"./config.js\";\n\nexport class ToolGroupComponent extends Container {\n\treadonly toolCallId = `compact-group-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;\n\ttoolName = \"group\";\n\t/** Nested at a visible-text boundary rather than rendered at chat level. */\n\tanchored = false;\n\tprivate _expanded = false;\n\tget expanded(): boolean {\n\t\treturn this._expanded;\n\t}\n\t/** Sealed: this block was closed by real text output \u2014 no further entries. */\n\tsealed = false;\n\t/** Thinking runs and tool calls, in the exact order they streamed in. */\n\tentries: GroupEntry[] = [];\n\tprivate markdownPreviewCache = new Map<string, MarkdownPreview>();\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis._expanded = expanded;\n\t\tfor (const tool of this.children as any[]) tool.setExpanded?.(expanded);\n\t\tthis.invalidate();\n\t}\n\n\taddTool(tool: any): void {\n\t\tabsorbPreparingTool(tool);\n\t\thideGroupedToolRender(tool);\n\t\tif (!tool?.result && !runtime.toolDurations.has(tool?.toolCallId)) {\n\t\t\trememberToolStart(String(tool?.toolCallId ?? \"\"));\n\t\t}\n\t\tthis.children.push(tool);\n\t\tif ((tool as any)._groupedAt === undefined) (tool as any)._groupedAt = Date.now();\n\t\t(tool as any)[PARENT_KEY] = this;\n\t\tthis.entries.push({ kind: \"tool\", tool });\n\t}\n\n\t/** Append a thinking run. Idempotent: a run belongs to exactly one group. */\n\taddThinking(entry: ThinkingEntry): void {\n\t\tif (entry.owner) return;\n\t\tentry.owner = this;\n\t\tthis.entries.push(entry);\n\t}\n\n\tremoveTool(tool: any): void {\n\t\tconst index = this.children.indexOf(tool);\n\t\tif (index >= 0) this.children.splice(index, 1);\n\t\tconst entryIndex = this.entries.findIndex((item) => item.kind === \"tool\" && item.tool === tool);\n\t\tif (entryIndex >= 0) this.entries.splice(entryIndex, 1);\n\t\tif ((tool as any)?.[PARENT_KEY] === this) delete (tool as any)[PARENT_KEY];\n\t}\n\n\t/** Return only entries that should be displayed (tools, or thinking with non-empty text). */\n\tgetVisibleEntries(): GroupEntry[] {\n\t\treturn this.entries.filter((entry) => {\n\t\t\tif (entry.kind === \"tool\") return true;\n\t\t\tif (entry.kind === \"thinking\") {\n\t\t\t\treturn entry.text.trim().length > 0;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\t}\n\n\thasVisibleEntries(): boolean {\n\t\treturn this.getVisibleEntries().length > 0;\n\t}\n\n\thasPending(): boolean {\n\t\treturn this.getVisibleEntries().some((entry) => entry.kind === \"tool\" && toolStatus(entry.tool) === \"pending\");\n\t}\n\n\t/** True while a thinking run in this group is still streaming. */\n\thasActiveThinking(): boolean {\n\t\treturn this.getVisibleEntries().some((entry) => entry.kind === \"thinking\" && entry.active);\n\t}\n\n\t/** True once any thinking run has been added to this group. */\n\thasThinking(): boolean {\n\t\treturn this.getVisibleEntries().some((entry) => entry.kind === \"thinking\");\n\t}\n\n\t/** True while this group should keep its spinner animating. */\n\tneedsAnimation(): boolean {\n\t\tif (this.sealed) return false;\n\t\treturn this.hasVisibleEntries() && (this.hasPending() || this.hasActiveThinking());\n\t}\n\n\toverride invalidate(): void {\n\t\t// Theme changes and tool/thinking updates must rebuild ANSI markdown.\n\t\tthis.markdownPreviewCache.clear();\n\t\tsuper.invalidate();\n\t}\n\n\tprivate renderMarkdownPreview(\n\t\tcacheKey: string,\n\t\tsource: string,\n\t\twidth: number,\n\t\tmaxLines: number,\n\t\tdefaultTextStyle?: DefaultTextStyle,\n\t): MarkdownPreview {\n\t\tconst renderWidth = Math.max(1, width);\n\t\tconst lineLimit = Math.max(1, maxLines);\n\t\tconst cached = this.markdownPreviewCache.get(cacheKey);\n\t\tif (cached && cached.source === source && cached.width === renderWidth && cached.maxLines === lineLimit) {\n\t\t\treturn cached;\n\t\t}\n\n\t\t// Only a bounded prefix can become visible. This prevents a very large\n\t\t// command result from being reparsed in full merely to display a handful\n\t\t// of expanded lines. Incomplete closing fences are supported by pi-tui.\n\t\tconst sourceRows = source.split(\"\\n\");\n\t\tconst sourceLineLimit = Math.max(lineLimit * 4, lineLimit + 20);\n\t\tconst sourceCharLimit = Math.max(4096, lineLimit * Math.max(40, renderWidth) * 4);\n\t\tlet markdownSource = sourceRows.slice(0, sourceLineLimit).join(\"\\n\");\n\t\tlet sourceTruncated = sourceRows.length > sourceLineLimit;\n\t\tif (markdownSource.length > sourceCharLimit) {\n\t\t\tmarkdownSource = markdownSource.slice(0, sourceCharLimit);\n\t\t\tsourceTruncated = true;\n\t\t}\n\n\t\tconst markdown = new Markdown(markdownSource, 0, 0, getCompactMarkdownTheme(), defaultTextStyle);\n\t\tconst rendered = normalizeCompactCodeBlockLines(markdown.render(renderWidth), renderWidth);\n\t\tconst preview: MarkdownPreview = {\n\t\t\tsource,\n\t\t\twidth: renderWidth,\n\t\t\tmaxLines: lineLimit,\n\t\t\tlines: rendered.slice(0, lineLimit),\n\t\t\ttruncated: sourceTruncated || rendered.length > lineLimit,\n\t\t};\n\t\tthis.markdownPreviewCache.set(cacheKey, preview);\n\t\treturn preview;\n\t}\n\n\tprivate iconFor(tool: any, frame: string): string {\n\t\tconst st = toolStatus(tool);\n\t\treturn st === \"pending\" ? frame : st === \"error\" ? \"\u2717\" : \"\u2713\";\n\t}\n\tprivate colorFor(status: string): string {\n\t\treturn status === \"pending\" ? \"accent\" : status === \"error\" ? \"error\" : \"success\";\n\t}\n\t// Tool name in bold accent, tool payload in dim, elapsed right-aligned to width.\n\tprivate toolRow(rail: string, tool: any, frame: string, width: number, isDim = false): string {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;\n\t\tconst bold = theme?.bold ? theme.bold : (t: string) => t;\n\t\tconst st = toolStatus(tool);\n\t\tconst s = toolSummary(tool.toolName, tool.args);\n\t\tconst prefix = rail ? fg(\"dim\", rail) : \"\";\n\t\tconst leftHeader = isDim\n\t\t\t? `${prefix}${fg(\"dim\", this.iconFor(tool, frame))} ${fg(\"dim\", s.name)}`\n\t\t\t: `${prefix}${fg(this.colorFor(st), this.iconFor(tool, frame))} ${fg(\"toolTitle\", bold(s.name))}`;\n\t\tconst right = fg(isDim ? \"dim\" : \"muted\", `(${toolElapsed(tool)}s)`);\n\t\tconst rightLen = visibleWidth(right);\n\t\tconst headerLen = visibleWidth(leftHeader);\n\n\t\tif (s.content) {\n\t\t\tconst maxContentLen = width - headerLen - 1 - rightLen - 1;\n\t\t\tif (maxContentLen > 3) {\n\t\t\t\tconst truncatedContent = truncateToWidth(s.content, maxContentLen, fg(\"dim\", \"...\"));\n\t\t\t\tconst left = `${leftHeader} ${fg(\"dim\", truncatedContent)}`;\n\t\t\t\tconst gap = Math.max(1, width - visibleWidth(left) - rightLen);\n\t\t\t\treturn `${left}${\" \".repeat(gap)}${right}`;\n\t\t\t}\n\t\t}\n\n\t\tconst gap = Math.max(1, width - headerLen - rightLen);\n\t\treturn `${leftHeader}${\" \".repeat(gap)}${right}`;\n\t}\n\n\t// One row per thinking run. The spinner marks the run that is still streaming;\n\t// the completion mark is written as soon as the run ends. Token label is right-aligned.\n\tprivate thinkingRow(\n\t\trail: string,\n\t\tentry: ThinkingEntry,\n\t\twidth: number,\n\t\tshowPreview = true,\n\t\tisDim = false,\n\t): string {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;\n\t\tconst spin = entry.active ? thinkingSpinnerFrame() : undefined;\n\t\tconst icon = spin?.frame ?? \"\u2713\";\n\t\tconst iconColor = isDim ? \"dim\" : (spin?.color ?? \"thinkingText\");\n\t\tconst prefix = rail ? fg(\"dim\", rail) : \"\";\n\t\tconst preview = showPreview ? entry.text.trim().replace(/[*_#`>]+/g, \"\") : \"\";\n\n\t\tif (showPreview && !preview) {\n\t\t\tconst label = entry.active ? \"thinking...\" : \"thinking\";\n\t\t\tconst titleColor = isDim ? \"dim\" : \"toolTitle\";\n\t\t\treturn `${prefix}${fg(iconColor, icon)} ${fg(titleColor, label)}`;\n\t\t}\n\n\t\tconst titleColor = isDim ? \"dim\" : \"toolTitle\";\n\t\tconst leftHeader = `${prefix}${fg(iconColor, icon)} ${fg(titleColor, \"thinking\")}`;\n\n\t\tconst tokenLabel = thinkingTokenLabel(entry);\n\t\tconst right = fg(isDim ? \"dim\" : \"muted\", tokenLabel);\n\t\tconst rightLen = visibleWidth(right);\n\t\tconst headerLen = visibleWidth(leftHeader);\n\n\t\tif (preview) {\n\t\t\tconst maxPreviewLen = width - headerLen - 1 - rightLen - 1;\n\t\t\tif (maxPreviewLen > 3) {\n\t\t\t\tconst contentColor = isDim ? \"dim\" : \"thinkingText\";\n\t\t\t\tconst ellipsis = fg(contentColor, \"...\");\n\t\t\t\tconst truncated = truncateToWidth(preview.replace(/\\s+/g, \" \"), maxPreviewLen, ellipsis);\n\t\t\t\tconst left = `${leftHeader} ${fg(contentColor, truncated)}`;\n\t\t\t\tconst gap = Math.max(1, width - visibleWidth(left) - rightLen);\n\t\t\t\treturn `${left}${\" \".repeat(gap)}${right}`;\n\t\t\t}\n\t\t}\n\n\t\tconst gap = Math.max(1, width - headerLen - rightLen);\n\t\treturn `${leftHeader}${\" \".repeat(gap)}${right}`;\n\t}\n\n\t// Folded: header + one line per entry, in stream order (oldest first).\n\t// When there is only 1 visible entry, do not show hierarchy (no header, no tree rail).\n\tprivate renderCollapsed(width: number, visible: GroupEntry[]): string[] {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;\n\t\tconst frame = SPINNER[Math.floor((Date.now() - spinnerStart) / SPINNER_MS) % SPINNER.length]!;\n\n\t\tif (visible.length === 1) {\n\t\t\tconst entry = visible[0]!;\n\t\t\tif (entry.kind === \"tool\") {\n\t\t\t\treturn [this.toolRow(\"\", entry.tool, frame, width)];\n\t\t\t}\n\t\t\treturn [this.thinkingRow(\"\", entry, width)];\n\t\t}\n\n\t\tconst lines: string[] = [];\n\n\t\tconst hasPendingTool = visible.some((e) => e.kind === \"tool\" && toolStatus(e.tool) === \"pending\");\n\t\tconst isThinking = !this.sealed && visible.some((e) => e.kind === \"thinking\" && e.active);\n\t\tconst hasTools = visible.some((e) => e.kind === \"tool\");\n\t\tconst hasThinking = visible.some((e) => e.kind === \"thinking\");\n\t\tconst openNoTools = !this.sealed && !hasTools;\n\t\tconst working = hasPendingTool || isThinking || openNoTools;\n\t\tconst state = hasPendingTool\n\t\t\t? \"tool calling...\"\n\t\t\t: !hasTools\n\t\t\t\t? working\n\t\t\t\t\t? \"thinking...\"\n\t\t\t\t\t: \"thinking\"\n\t\t\t\t: isThinking\n\t\t\t\t\t? \"thinking...\"\n\t\t\t\t\t: hasThinking\n\t\t\t\t\t\t? \"tools and thinking done\"\n\t\t\t\t\t\t: \"tools done\";\n\t\tconst stateColor = hasPendingTool ? \"accent\" : hasTools && !isThinking ? \"success\" : \"thinkingText\";\n\t\tconst thinkingSpin = !hasPendingTool && working ? thinkingSpinnerFrame() : undefined;\n\t\t// Left icon: spinner while working, completion mark once the group is done.\n\t\tconst leftIcon = working ? (thinkingSpin?.frame ?? frame) : \"\u2713\";\n\t\tconst leftColor = thinkingSpin?.color ?? stateColor;\n\n\t\tconst maxEntries = config.maxGroupEntries ?? 5;\n\t\tconst hiddenCount = visible.length > maxEntries ? visible.length - maxEntries : 0;\n\t\tconst hiddenSuffix = hiddenCount > 0 ? ` ${fg(\"muted\", `(${hiddenCount} hidden)`)}` : \"\";\n\t\tlines.push(`${fg(leftColor, leftIcon)} ${fg(stateColor, state)}${hiddenSuffix}`);\n\n\t\t// Every entry is shown, one line each, in the order the model produced it.\n\t\t// When hiddenCount > 0, hide oldest entries and fade the top visible entry.\n\t\tconst entriesToRender = hiddenCount > 0 ? visible.slice(hiddenCount) : visible;\n\t\tconst total = entriesToRender.length;\n\t\tfor (let index = 0; index < total; index++) {\n\t\t\tconst entry = entriesToRender[index]!;\n\t\t\tconst rail = index === total - 1 ? \"\u2514 \" : \"\u2502 \";\n\t\t\tconst isDim = hiddenCount > 0 && index === 0;\n\t\t\tlines.push(\n\t\t\t\tentry.kind === \"thinking\"\n\t\t\t\t\t? this.thinkingRow(rail, entry, width, true, isDim)\n\t\t\t\t\t: this.toolRow(rail, entry.tool, frame, width, isDim),\n\t\t\t);\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\t// Expanded: per-tool detail + every thinking run, in stream order.\n\t// When there is only 1 visible entry, do not show hierarchy (no header, no tree rail).\n\tprivate renderExpanded(width: number, visible: GroupEntry[]): string[] {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;\n\t\tconst frame = SPINNER[Math.floor((Date.now() - spinnerStart) / SPINNER_MS) % SPINNER.length]!;\n\t\tconst lines: string[] = [];\n\n\t\tif (visible.length === 1) {\n\t\t\tconst entry = visible[0]!;\n\t\t\tconst sub = \" \";\n\t\t\tif (entry.kind === \"tool\") {\n\t\t\t\tconst tool = entry.tool;\n\t\t\t\tlines.push(this.toolRow(\"\", tool, frame, width));\n\t\t\t\tconst result = toolResultText(tool);\n\t\t\t\tif (result) {\n\t\t\t\t\tconst markdownWidth = Math.max(1, width - sub.length);\n\t\t\t\t\tconst preview = this.renderMarkdownPreview(\n\t\t\t\t\t\t`tool:${tool.toolCallId ?? 0}`,\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tmarkdownWidth,\n\t\t\t\t\t\tconfig.expandedToolLines,\n\t\t\t\t\t\t{ color: (text) => runtime.currentTheme?.fg?.(\"toolOutput\", text) ?? text },\n\t\t\t\t\t);\n\t\t\t\t\tfor (const row of preview.lines) {\n\t\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${row}`);\n\t\t\t\t\t}\n\t\t\t\t\tif (preview.truncated) {\n\t\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${fg(\"muted\", \"...\")}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn lines;\n\t\t\t}\n\n\t\t\tlines.push(this.thinkingRow(\"\", entry, width, false));\n\t\t\tconst tText = entry.text.trim();\n\t\t\tif (tText) {\n\t\t\t\tconst markdownWidth = Math.max(1, width - sub.length);\n\t\t\t\tconst preview = this.renderMarkdownPreview(\n\t\t\t\t\t`thinking:${entry.id}`,\n\t\t\t\t\ttText,\n\t\t\t\t\tmarkdownWidth,\n\t\t\t\t\tconfig.expandedThinkingLines,\n\t\t\t\t\t{ color: (text) => runtime.currentTheme?.fg?.(\"thinkingText\", text) ?? text, italic: true },\n\t\t\t\t);\n\t\t\t\tfor (const row of preview.lines) {\n\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${row}`);\n\t\t\t\t}\n\t\t\t\tif (preview.truncated) {\n\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${fg(\"muted\", \"...\")}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\tconst hasPendingTool = visible.some((e) => e.kind === \"tool\" && toolStatus(e.tool) === \"pending\");\n\t\tconst isThinking = !this.sealed && visible.some((e) => e.kind === \"thinking\" && e.active);\n\t\t// See renderCollapsed: a block without tools keeps the thinking label, and a\n\t\t// block with reasoning must not claim \"tools done\" alone.\n\t\tconst hasTools = visible.some((e) => e.kind === \"tool\");\n\t\tconst hasThinking = visible.some((e) => e.kind === \"thinking\");\n\t\tconst openNoTools = !this.sealed && !hasTools;\n\t\tconst working = hasPendingTool || isThinking || openNoTools;\n\t\tconst state = hasPendingTool\n\t\t\t? \"tool calling...\"\n\t\t\t: !hasTools\n\t\t\t\t? working\n\t\t\t\t\t? \"thinking...\"\n\t\t\t\t\t: \"thinking\"\n\t\t\t\t: isThinking\n\t\t\t\t\t? \"thinking...\"\n\t\t\t\t\t: hasThinking\n\t\t\t\t\t\t? \"tools and thinking done\"\n\t\t\t\t\t\t: \"tools done\";\n\t\tconst stateColor = hasPendingTool ? \"accent\" : hasTools && !isThinking ? \"success\" : \"thinkingText\";\n\t\tconst thinkingSpin = !hasPendingTool && working ? thinkingSpinnerFrame() : undefined;\n\t\t// Left icon: spinner while working, completion mark once the group is done.\n\t\tconst leftIcon = working ? (thinkingSpin?.frame ?? frame) : \"\u2713\";\n\t\tconst leftColor = thinkingSpin?.color ?? stateColor;\n\t\tlines.push(`${fg(leftColor, leftIcon)} ${fg(stateColor, state)}`);\n\n\t\tconst total = visible.length;\n\t\tfor (let index = 0; index < total; index++) {\n\t\t\tconst entry = visible[index]!;\n\t\t\tconst isLast = index === total - 1;\n\t\t\tconst rail = isLast ? \"\u2514\u2500 \" : \"\u251C\u2500 \";\n\t\t\tconst sub = isLast ? \" \" : \"\u2502 \";\n\t\t\tif (entry.kind === \"tool\") {\n\t\t\t\tconst tool = entry.tool;\n\t\t\t\tlines.push(this.toolRow(rail, tool, frame, width));\n\t\t\t\tconst result = toolResultText(tool);\n\t\t\t\tif (result) {\n\t\t\t\t\tconst markdownWidth = Math.max(1, width - sub.length);\n\t\t\t\t\tconst preview = this.renderMarkdownPreview(\n\t\t\t\t\t\t`tool:${tool.toolCallId ?? index}`,\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tmarkdownWidth,\n\t\t\t\t\t\tconfig.expandedToolLines,\n\t\t\t\t\t\t{ color: (text) => runtime.currentTheme?.fg?.(\"toolOutput\", text) ?? text },\n\t\t\t\t\t);\n\t\t\t\t\tfor (const row of preview.lines) {\n\t\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${row}`);\n\t\t\t\t\t}\n\t\t\t\t\tif (preview.truncated) {\n\t\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${fg(\"muted\", \"...\")}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlines.push(this.thinkingRow(rail, entry, width, false));\n\t\t\tconst tText = entry.text.trim();\n\t\t\tif (tText) {\n\t\t\t\tconst markdownWidth = Math.max(1, width - sub.length);\n\t\t\t\tconst preview = this.renderMarkdownPreview(\n\t\t\t\t\t`thinking:${entry.id}`,\n\t\t\t\t\ttText,\n\t\t\t\t\tmarkdownWidth,\n\t\t\t\t\tconfig.expandedThinkingLines,\n\t\t\t\t\t{ color: (text) => runtime.currentTheme?.fg?.(\"thinkingText\", text) ?? text, italic: true },\n\t\t\t\t);\n\t\t\t\tfor (const row of preview.lines) {\n\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${row}`);\n\t\t\t\t}\n\t\t\t\tif (preview.truncated) {\n\t\t\t\t\tlines.push(`${fg(\"dim\", sub)}${fg(\"muted\", \"...\")}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\n\n\n\n\toverride render(width: number): string[] {\n\t\tconst visible = this.getVisibleEntries();\n\t\tif (visible.length === 0) return [];\n\n\t\tif (this.needsAnimation()) scheduleAnimation();\n\n\t\tconst padding = \" \".repeat(Math.min(GROUP_PADDING_X, Math.max(0, width - 1)));\n\t\tconst contentWidth = Math.max(1, width - padding.length - GROUP_PADDING_RIGHT);\n\t\tconst lines = this._expanded\n\t\t\t? this.renderExpanded(contentWidth, visible)\n\t\t\t: this.renderCollapsed(contentWidth, visible);\n\t\tif (lines.length === 0) return [];\n\t\tconst rendered = lines.map((line) => padding + truncateToWidth(line, contentWidth, \"...\"));\n\t\t// Native ToolExecutionComponent starts with Spacer(1). Our custom render\n\t\t// bypasses that child tree, so restore the same single leading gap while\n\t\t// the group is top-level. Anchored groups receive deterministic spacing\n\t\t// from placeAnchoredGroupBeforeText() instead.\n\t\treturn this.anchored ? rendered : [\"\", ...rendered];\n\t}\n}\n", "/** \u96C6\u4E2D\u7BA1\u7406\u4F1A\u8BDD\u72B6\u6001\uFF1B\u96C6\u5408\u4E0E\u951A\u70B9\u901A\u8FC7\u5DE5\u5382\u521B\u5EFA\uFF0C\u4FBF\u4E8E\u6D4B\u8BD5\u9694\u79BB\u3002 */\nimport type { ThinkingEntry, PreparingTool, AssistantContentState } from \"./types.js\";\nimport type { ToolGroupComponent } from \"./tool-group.js\";\nimport type { OverlayHandle, Container } from \"@earendil-works/pi-tui\";\nimport type { DetailModalComponent, InspectSelectorModal } from \"./modals.js\";\n\n/** Mutable session/UI state. A fresh snapshot also makes isolated tests possible. */\nexport interface RuntimeState {\n\tcurrentTheme: any;\n\tactiveThinking: ThinkingEntry | null;\n\tactiveThinkingIndex: number | null;\n\tactiveThinkingBlocks: Map<number, string>;\n\tunattachedThinking: ThinkingEntry[];\n\tthinkingEntrySeq: number;\n\thandledTextIndexes: Set<number>;\n\tsealedThinkingIndexes: Set<number>;\n\tpendingTextSeal: boolean;\n\tpendingTextOrdinal: number | null;\n\tlastActiveGroup: ToolGroupComponent | null;\n\tlastSealedThinkingEntry: ThinkingEntry | null;\n\tlastReportedReasoningTokens: number;\n\tlastStreamingComp: any;\n\tlastChatContainer: any;\n\ttoolStarts: Map<string, number>;\n\ttoolDurations: Map<string, number>;\n\tturnStartMs: number;\n\tpreparingByIndex: Map<number, PreparingTool>;\n\tactiveModalHandle: OverlayHandle | null;\n\tactiveModalComponent: DetailModalComponent | null;\n\tactiveModalCloseFn: (() => void) | null;\n\tactiveUIContext: any;\n\tactiveSelectorHandle: OverlayHandle | null;\n\tactiveSelectorComponent: InspectSelectorModal | null;\n\tactiveSelectorCloseFn: (() => void) | null;\n\tanimTimer: ReturnType<typeof setTimeout> | null;\n\tcapturedTui: any;\n\tgroups: Set<ToolGroupComponent>;\n\tassistantContentContainers: WeakSet<Container>;\n\tassistantContentStates: WeakMap<Container, AssistantContentState>;\n\tgroupAnchors: WeakMap<ToolGroupComponent, { container: Container; ordinal: number; }>;\n}\n\nexport function createRuntimeState(): RuntimeState {\n\treturn {\n\t\tcurrentTheme: null,\n\t\tactiveThinking: null,\n\t\tactiveThinkingIndex: null,\n\t\tactiveThinkingBlocks: new Map<number, string>(),\n\t\tunattachedThinking: [],\n\t\tthinkingEntrySeq: 0,\n\t\thandledTextIndexes: new Set<number>(),\n\t\tsealedThinkingIndexes: new Set<number>(),\n\t\tpendingTextSeal: false,\n\t\tpendingTextOrdinal: null,\n\t\tlastActiveGroup: null,\n\t\tlastSealedThinkingEntry: null,\n\t\tlastReportedReasoningTokens: 0,\n\t\tlastStreamingComp: null,\n\t\tlastChatContainer: null,\n\t\ttoolStarts: new Map<string, number>(),\n\t\ttoolDurations: new Map<string, number>(),\n\t\tturnStartMs: 0,\n\t\tpreparingByIndex: new Map<number, PreparingTool>(),\n\t\tactiveModalHandle: null,\n\t\tactiveModalComponent: null,\n\t\tactiveModalCloseFn: null,\n\t\tactiveUIContext: null,\n\t\tactiveSelectorHandle: null,\n\t\tactiveSelectorComponent: null,\n\t\tactiveSelectorCloseFn: null,\n\t\tanimTimer: null,\n\t\tcapturedTui: null,\n\t\tgroups: new Set<ToolGroupComponent>(),\n\t\tassistantContentContainers: new WeakSet<Container>(),\n\t\tassistantContentStates: new WeakMap<Container, AssistantContentState>(),\n\t\tgroupAnchors: new WeakMap<ToolGroupComponent, { container: Container; ordinal: number }>(),\n\t};\n}\n\nexport const runtime = createRuntimeState();\n", "/** \u6E32\u67D3\u5E38\u91CF\u4E0E\u8DE8\u70ED\u91CD\u8F7D\u7A33\u5B9A\u7684\u8865\u4E01\u6807\u8BB0\u3002 */\nexport const SPINNER = [\"\u280B\", \"\u2819\", \"\u2839\", \"\u2838\", \"\u283C\", \"\u2834\", \"\u2826\", \"\u2827\", \"\u2807\", \"\u280F\"];\n\nexport const SPINNER_MS = 100;\n\nexport const THINKING_SPINNER = {\n\trawFrames: [\"\u00B7\", \"\u2022\", \"\u25CF\", \"\u2022\"],\n\tintervalMs: 140,\n\tcolorKeys: [\"dim\", \"muted\", \"accent\", \"muted\"],\n} as const;\n\nexport const GROUP_PADDING_X = 1;\n\nexport const GROUP_PADDING_RIGHT = 2;\n\nexport const spinnerStart = Date.now();\n\nexport const PARENT_KEY = Symbol.for(\"compact-ui.group-parent\");\n\nexport const PATCH_KEY = Symbol.for(\"compact-ui.group-patch\");\n\nexport const MARKDOWN_RENDER_PATCH_KEY = Symbol.for(\"compact-ui.markdown-render-patch\");\n\nexport const COMPACTION_STYLE_PATCH_KEY = Symbol.for(\"compact-ui.compaction-style-patch\");\n\nexport const ASSISTANT_THINKING_PATCH_KEY = Symbol.for(\"compact-ui.assistant-thinking-patch\");\n\nexport const IS_STREAMING_COMP = Symbol.for(\"compact-ui.is-streaming-comp\");\n\nexport const GROUP_MOUNT = Symbol.for(\"compact-ui.group-mount\");\n\nexport const TOOL_RENDER_PATCH_KEY = Symbol.for(\"compact-ui.tool-render-patch\");\n\nexport const LIVE_ASSISTANT_KEY = Symbol.for(\"compact-ui.live-assistant\");\n\nexport const CODE_BLOCK_PADDING_X = 1;\n", "/** \u65E0\u8FD0\u884C\u72B6\u6001\u4F9D\u8D56\u7684\u683C\u5F0F\u5316\u4E0E\u6D41\u5F0F\u5DE5\u5177\u53C2\u6570\u89E3\u6790\u3002 */\nimport { homedir } from \"os\";\nimport type { ThinkingEntry, ToolStatus } from \"./types.js\";\nimport { isKeyRelease, parseKey, matchesKey } from \"@earendil-works/pi-tui\";\n\nexport function shortenPath(path: string): string {\n\tconst home = homedir();\n\treturn path.startsWith(home) ? `~${path.slice(home.length)}` : path;\n}\n\nexport function oneLine(value: unknown, max?: number): string {\n\tconst text = String(value ?? \"\").replace(/\\s+/g, \" \").trim();\n\tif (typeof max === \"number\" && text.length > max) {\n\t\treturn max <= 3 ? \"...\".slice(0, max) : `${text.slice(0, max - 3)}...`;\n\t}\n\treturn text;\n}\n\nexport function estimateTextTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\nexport function formatTokenK(tokens: number): string {\n\tif (tokens <= 0) return \"0.0K\";\n\tif (tokens < 100) return \"<0.1K\";\n\tconst value = tokens / 1000;\n\treturn value < 100 ? `${value.toFixed(1)}K` : `${Math.round(value)}K`;\n}\n\nexport function thinkingTokenLabel(entry: ThinkingEntry): string {\n\tconst tokens = Math.max(0, Math.round(Number(entry?.tokens) || 0));\n\tif (tokens < 1000) {\n\t\treturn `(${tokens}t)`;\n\t}\n\tconst k = tokens / 1000;\n\tconst formatted = k < 100 ? k.toFixed(1) : Math.round(k).toString();\n\treturn `(${formatted}k)`;\n}\n\nexport function toolSummary(name: string, args: any): { name: string; content: string } {\n\tswitch (name) {\n\t\tcase \"bash\":\n\t\tcase \"powershell\":\n\t\t\treturn { name, content: oneLine(args?.command || \"...\") };\n\t\tcase \"read\":\n\t\t\treturn { name: \"read\", content: shortenPath(args?.path || \"...\") };\n\t\tcase \"write\":\n\t\tcase \"edit\":\n\t\t\treturn { name, content: shortenPath(args?.path || \"...\") };\n\t\tcase \"find\":\n\t\t\treturn { name: \"find\", content: `${oneLine(args?.pattern || \"\")} in ${shortenPath(args?.path || \".\")}` };\n\t\tcase \"grep\":\n\t\t\treturn { name: \"grep\", content: `${oneLine(args?.pattern || \"\")} in ${shortenPath(args?.path || \".\")}` };\n\t\tcase \"ls\":\n\t\t\treturn { name: \"ls\", content: shortenPath(args?.path || \".\") };\n\t\tcase \"web_search\":\n\t\t\treturn { name: \"web_search\", content: oneLine(args?.query || \"...\") };\n\t\tcase \"subagent\":\n\t\t\treturn { name: \"subagent\", content: oneLine(args?.agent || args?.task || \"...\") };\n\t\tdefault: {\n\t\t\tconst preferred = args?.path ?? args?.query ?? args?.name ?? args?.description ?? args?.url;\n\t\t\treturn { name, content: oneLine(preferred ?? \"...\") };\n\t\t}\n\t}\n}\n\nexport function toolStatus(tool: any): ToolStatus {\n\tif (tool?.result?.isError) return \"error\";\n\tif (tool?.isPartial === true || (tool?.executionStarted && !tool?.result)) return \"pending\";\n\treturn tool?.result ? \"success\" : \"pending\";\n}\n\nexport function streamingToolArgs(block: any): any {\n\tconst args = block?.arguments && typeof block.arguments === \"object\" ? block.arguments : {};\n\tif (Object.keys(args).length > 0) return args;\n\tconst partial = String(block?.partialJson || block?.partialArgs || \"\").trim();\n\tif (!partial) return args;\n\tconst name = String(block?.name || \"\");\n\tif (name === \"bash\" || name === \"powershell\") return { command: partial };\n\tif (name === \"read\" || name === \"write\" || name === \"edit\" || name === \"ls\") return { path: partial };\n\treturn { query: partial };\n}\n\nexport function locateStreamingToolCall(\n\tcontent: any[],\n\tstreamEvent: any,\n): { index: number; block: any } | undefined {\n\tconst index = Number(streamEvent?.contentIndex);\n\tif (Number.isInteger(index) && content[index]?.type === \"toolCall\") {\n\t\treturn { index, block: content[index] };\n\t}\n\tconst fromEvent = streamEvent?.toolCall;\n\tif (fromEvent && (fromEvent.type === \"toolCall\" || fromEvent.name)) {\n\t\tconst found = content.findIndex(\n\t\t\t(item) => item?.type === \"toolCall\" && fromEvent.id && item.id === fromEvent.id,\n\t\t);\n\t\tif (found >= 0) return { index: found, block: content[found] };\n\t\treturn { index: Number.isInteger(index) ? index : content.length, block: fromEvent };\n\t}\n\treturn undefined;\n}\n\nexport function toolResultText(tool: any): string {\n\treturn (tool?.result?.content ?? [])\n\t\t.filter((c: any) => c.type === \"text\")\n\t\t.map((c: any) => String(c.text))\n\t\t.join(\"\\n\")\n\t\t.trim();\n}\n\nexport function formatWorkedTime(elapsedMs: number): string {\n\tconst totalSec = Math.max(1, Math.round(elapsedMs / 1000));\n\tconst hours = Math.floor(totalSec / 3600);\n\tconst minutes = Math.floor((totalSec % 3600) / 60);\n\tconst seconds = totalSec % 60;\n\tif (hours > 0) return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`;\n\tif (minutes > 0) return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n\treturn `${seconds}s`;\n}\n\nexport function isCtrlI(data: string): boolean {\n\t// Ignore key release events to prevent accidental toggling on key up\n\tif (isKeyRelease(data)) {\n\t\treturn false;\n\t}\n\t// In legacy terminals, Ctrl+I sends byte 0x09 (\"\\t\"), identical to Tab.\n\t// To keep Tab completion working, exclude plain \"\\t\" and only recognize\n\t// Ctrl+I under extended keyboard protocols (Kitty keyboard, modifyOtherKeys).\n\treturn data !== \"\\t\" && (parseKey(data) === \"ctrl+i\" || matchesKey(data, \"ctrl+i\"));\n}\n", "/** \u9002\u914D Pi \u539F\u751F assistant \u7EC4\u4EF6\uFF1A\u5386\u53F2\u601D\u8003\u3001\u6B63\u6587\u951A\u70B9\u4E0E\u56DE\u5408\u8017\u65F6\u5206\u9694\u7EBF\u3002 */\nimport { runtime } from \"./state.js\";\nimport type { AssistantContentState, ThinkingEntry } from \"./types.js\";\nimport { ToolGroupComponent } from \"./tool-group.js\";\nimport { estimateTextTokens, formatWorkedTime } from \"./helpers.js\";\nimport { Spacer, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { Container, Markdown } from \"@earendil-works/pi-tui\";\nimport { AssistantMessageComponent } from \"@earendil-works/pi-coding-agent\";\nimport { ASSISTANT_THINKING_PATCH_KEY, LIVE_ASSISTANT_KEY, IS_STREAMING_COMP, GROUP_MOUNT, PARENT_KEY } from \"./constants.js\";\nimport { isAssistantMessage, isContainer, isToolGroup, isMarkdown, isSpacer, isText } from \"./guards.js\";\nimport { installVisibleAssistantMarkdownRendering } from \"./markdown.js\";\n\nexport function thinkingAlreadyShown(text: string): boolean {\n\tconst norm = text.trim();\n\tif (!norm) return true;\n\tif (runtime.activeThinking && runtime.activeThinking.text.trim() === norm) return true;\n\tfor (const entry of runtime.unattachedThinking) {\n\t\tif (entry.text.trim() === norm) return true;\n\t}\n\tfor (const group of runtime.groups) {\n\t\tfor (const entry of group.entries) {\n\t\t\tif (entry.kind === \"thinking\" && entry.text.trim() === norm) return true;\n\t\t}\n\t}\n\treturn false;\n}\n\nexport function stageHistoricalThinking(\n\tstate: AssistantContentState,\n\tordinal: number,\n\ttexts: string[],\n\tmessage: any,\n): void {\n\tif (state.anchors.has(ordinal)) return;\n\tconst fresh = texts.filter((text, index) => text.trim() && texts.indexOf(text) === index && !thinkingAlreadyShown(text));\n\tif (fresh.length === 0) return;\n\tconst group = new ToolGroupComponent();\n\tgroup.anchored = true;\n\tgroup.sealed = true;\n\tconst reasoningTokens = Number(message?.usage?.reasoning);\n\tconst tokensExact = Number.isFinite(reasoningTokens) && reasoningTokens > 0;\n\tfor (const text of fresh) {\n\t\tconst entry: ThinkingEntry = {\n\t\t\tkind: \"thinking\",\n\t\t\tid: runtime.thinkingEntrySeq++,\n\t\t\ttext,\n\t\t\ttokens: tokensExact ? reasoningTokens : estimateTextTokens(text),\n\t\t\ttokensExact,\n\t\t\tactive: false,\n\t\t\towner: group,\n\t\t};\n\t\tgroup.entries.push(entry);\n\t}\n\tif (!group.hasVisibleEntries()) return;\n\tstate.anchors.set(ordinal, group);\n\truntime.groups.add(group);\n}\n\nexport function ensureHistoricalThinkingAnchors(\n\tcontentContainer: Container,\n\tmessage: any,\n): void {\n\tconst content = Array.isArray(message?.content) ? message.content : undefined;\n\tif (!content || content.length === 0) return;\n\n\tconst state = getAssistantContentState(contentContainer);\n\tlet currentThinkingBlocks: string[] = [];\n\tlet textOrdinal = 0;\n\n\tfor (const item of content) {\n\t\tif (item?.type === \"thinking\") {\n\t\t\tconst text = String(item.thinking ?? \"\").trim();\n\t\t\tif (text) currentThinkingBlocks.push(text);\n\t\t} else if (item?.type === \"text\" && String(item.text ?? \"\").trim()) {\n\t\t\tstageHistoricalThinking(state, textOrdinal, currentThinkingBlocks, message);\n\t\t\tcurrentThinkingBlocks = [];\n\t\t\ttextOrdinal++;\n\t\t}\n\t}\n\n\tconst hasToolCalls = content.some((item: any) => item?.type === \"toolCall\");\n\tif (!hasToolCalls && textOrdinal === 0 && currentThinkingBlocks.length > 0) {\n\t\tstageHistoricalThinking(state, 0, currentThinkingBlocks, message);\n\t}\n}\n\nexport function installNativeThinkingSuppression(prototype: any = AssistantMessageComponent.prototype): void {\n\tif (!prototype || typeof prototype.updateContent !== \"function\") return;\n\tconst previous = prototype[ASSISTANT_THINKING_PATCH_KEY] as\n\t\t| {\n\t\t\t\toriginalUpdateContent: (this: any, message: any, isStreaming?: boolean) => void;\n\t\t\t\tinstalledUpdateContent: (this: any, message: any, isStreaming?: boolean) => void;\n\t\t }\n\t\t| undefined;\n\tconst originalUpdateContent =\n\t\tprevious && prototype.updateContent === previous.installedUpdateContent\n\t\t\t? previous.originalUpdateContent\n\t\t\t: (prototype.updateContent as (this: any, message: any, isStreaming?: boolean) => void);\n\tconst installedUpdateContent = function (this: any, message: any, isStreaming?: boolean): void {\n\t\tconst contentContainer = this.contentContainer;\n\t\tif (contentContainer) {\n\t\t\truntime.assistantContentContainers.add(contentContainer);\n\t\t}\n\t\tif (isStreaming === true) {\n\t\t\tthis[LIVE_ASSISTANT_KEY] = true;\n\t\t}\n\t\tconst isLive = Boolean(this[LIVE_ASSISTANT_KEY]) || isStreaming === true || (this as any)[IS_STREAMING_COMP] === true || this === runtime.lastStreamingComp;\n\n\t\tconst content = Array.isArray(message?.content) ? message.content : undefined;\n\t\tconst hasToolCalls = Boolean(content?.some((item: any) => item?.type === \"toolCall\"));\n\t\tconst hasText = Boolean(content?.some((item: any) => item?.type === \"text\" && String(item?.text ?? \"\").trim()));\n\n\t\t// Historical anchor reconstruction is ONLY for non-live messages loaded from history.\n\t\t// If the message is currently live or was streamed live in this session, its thinking is ALREADY in the compact tree.\n\t\tif (!isLive && contentContainer && message?.content) {\n\t\t\tensureHistoricalThinkingAnchors(contentContainer, message);\n\t\t}\n\n\t\tif (!content?.some((item: any) => item?.type === \"thinking\")) {\n\t\t\toriginalUpdateContent.call(this, message, isStreaming);\n\t\t\treturn;\n\t\t}\n\t\toriginalUpdateContent.call(\n\t\t\tthis,\n\t\t\t{\n\t\t\t\t...message,\n\t\t\t\tcontent: content.filter((item: any) => item?.type !== \"thinking\"),\n\t\t\t},\n\t\t\tisStreaming,\n\t\t);\n\n\t\t// If this was a true historical thinking-only message (NO text AND NO tool calls), attach the group.\n\t\t// If it has tool calls, its thinking belongs to the tool group \u2014 NEVER attach it here.\n\t\tif (!isLive && !hasToolCalls && !hasText && contentContainer) {\n\t\t\tconst state = getAssistantContentState(contentContainer);\n\t\t\tconst group = state.anchors.get(0);\n\t\t\tif (group && group.hasVisibleEntries() && !contentContainer.children.includes(group)) {\n\t\t\t\tdetachGroup(group, contentContainer);\n\t\t\t\tcontentContainer.addChild(new Spacer(1));\n\t\t\t\tcontentContainer.addChild(group);\n\t\t\t\tcontentContainer.addChild(new Spacer(1));\n\t\t\t\tnoteGroupMount(contentContainer, group);\n\t\t\t}\n\t\t}\n\t};\n\tprototype.updateContent = installedUpdateContent;\n\tif (typeof prototype.setHideThinkingBlock === \"function\") {\n\t\tconst originalSetHideThinkingBlock = prototype.setHideThinkingBlock as (this: any, hide: boolean) => void;\n\t\tprototype.setHideThinkingBlock = function (this: any, _hide: boolean): void {\n\t\t\t// Thinking stays in the compact tree. Letting Pi show it again paints a second copy.\n\t\t\tthis.hiddenThinkingLabel = \"\";\n\t\t\toriginalSetHideThinkingBlock.call(this, true);\n\t\t};\n\t}\n\tif (typeof prototype.setHiddenThinkingLabel === \"function\") {\n\t\tconst originalSetHiddenThinkingLabel = prototype.setHiddenThinkingLabel as (this: any, label: string) => void;\n\t\tprototype.setHiddenThinkingLabel = function (this: any, _label: string): void {\n\t\t\tthis.hiddenThinkingLabel = \"\";\n\t\t\toriginalSetHiddenThinkingLabel.call(this, \"\");\n\t\t};\n\t}\n\tprototype[ASSISTANT_THINKING_PATCH_KEY] = {\n\t\toriginalUpdateContent,\n\t\tinstalledUpdateContent,\n\t};\n}\n\nexport function ensureAssistantThinkingPatched(component: any): boolean {\n\tconst prototype = Object.getPrototypeOf(component);\n\tconst already = Boolean(prototype?.[ASSISTANT_THINKING_PATCH_KEY]);\n\tinstallNativeThinkingSuppression(prototype);\n\tcomponent.hideThinkingBlock = true;\n\tcomponent.hiddenThinkingLabel = \"\";\n\treturn already;\n}\n\nexport function getAssistantContentState(container: Container): AssistantContentState {\n\tlet state = runtime.assistantContentStates.get(container);\n\tif (!state) {\n\t\tstate = { anchors: new Map(), nextTextOrdinal: 0 };\n\t\truntime.assistantContentStates.set(container, state);\n\t}\n\treturn state;\n}\n\nexport function removeGroupFromContainer(container: any, group: ToolGroupComponent): void {\n\tconst children = container?.children;\n\tif (!Array.isArray(children)) return;\n\tconst index = children.indexOf(group);\n\tif (index >= 0) children.splice(index, 1);\n\tif ((group as any)[GROUP_MOUNT] === container) delete (group as any)[GROUP_MOUNT];\n}\n\nexport function noteGroupMount(container: any, group: ToolGroupComponent): void {\n\t(group as any)[GROUP_MOUNT] = container;\n}\n\nexport function detachGroup(group: ToolGroupComponent, keep?: any): void {\n\tconst mounted = (group as any)[GROUP_MOUNT];\n\tif (mounted && mounted !== keep) removeGroupFromContainer(mounted, group);\n\tif (runtime.lastChatContainer && runtime.lastChatContainer !== keep) removeGroupFromContainer(runtime.lastChatContainer, group);\n\tconst anchor = runtime.groupAnchors.get(group);\n\tif (anchor?.container && anchor.container !== keep) removeGroupFromContainer(anchor.container, group);\n}\n\nexport function removeComponentFromContainer(container: any, component: any): void {\n\tconst children = container?.children;\n\tif (!Array.isArray(children)) return;\n\tconst index = children.indexOf(component);\n\tif (index >= 0) children.splice(index, 1);\n}\n\nexport class TurnDividerComponent {\n\tprivate readonly timeLabel: string;\n\n\tconstructor(timeLabel: string) {\n\t\tthis.timeLabel = timeLabel;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;\n\t\tconst middle = `worked for ${this.timeLabel}`;\n\t\tconst avail = Math.max(6, width - middle.length - 2);\n\t\tconst left = Math.floor(avail / 2);\n\t\tconst right = avail - left;\n\t\tconst dash = (n: number) => \"\u2500\".repeat(Math.max(0, n));\n\t\tconst line = `${fg(\"dim\", dash(left))} ${fg(\"muted\", middle)} ${fg(\"dim\", dash(right))}`;\n\t\treturn [truncateToWidth(line, Math.max(1, width)), \"\"];\n\t}\n\n\tinvalidate(): void {}\n}\n\nexport function placeTurnDividerBeforeText(container: Container, target: Markdown, divider: any): void {\n\tconst targetIndex = container.children.indexOf(target);\n\tif (targetIndex < 0) return;\n\tremoveComponentFromContainer(container, divider);\n\tcontainer.children.splice(targetIndex, 0, divider);\n}\n\nexport function insertTurnDivider(elapsedMs: number): void {\n\tif (elapsedMs < 1000) return;\n\tlet comp: any = runtime.lastStreamingComp;\n\tif (!comp || !isAssistantMessage(comp)) {\n\t\tif (!runtime.lastChatContainer) return;\n\t\tconst children = (runtime.lastChatContainer as any)?.children;\n\t\tif (!Array.isArray(children)) return;\n\t\tfor (let i = children.length - 1; i >= 0; i--) {\n\t\t\tif (isAssistantMessage(children[i])) {\n\t\t\t\tcomp = children[i];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (!comp) return;\n\tconst contentContainer = (comp as any).contentContainer;\n\tif (!isContainer(contentContainer)) return;\n\n\tconst markdowns = contentContainer.children.filter(isVisibleTextMarkdown);\n\tif (markdowns.length === 0) return;\n\tconst final = markdowns[markdowns.length - 1];\n\tconst finalIndex = contentContainer.children.indexOf(final);\n\t// Only separate the final text from preceding work (an anchored tool/thinking\n\t// group). A plain text-only answer gets no divider.\n\tconst hasPriorContent = contentContainer.children\n\t\t.slice(0, finalIndex)\n\t\t.some((child) => isToolGroup(child) && child.hasVisibleEntries());\n\tif (!hasPriorContent) return;\n\n\tconst state = getAssistantContentState(contentContainer);\n\tif (state.finalDivider && contentContainer.children.includes(state.finalDivider.component)) return;\n\tconst ordinal = markdowns.length - 1;\n\tconst divider = new TurnDividerComponent(formatWorkedTime(elapsedMs));\n\tstate.finalDivider = { ordinal, component: divider };\n\tplaceTurnDividerBeforeText(contentContainer, final, divider);\n\tcontentContainer.invalidate?.();\n\truntime.capturedTui?.requestRender?.();\n}\n\nexport function isVisibleTextMarkdown(component: any): component is Markdown {\n\t// Thinking Markdown receives a defaultTextStyle ({ color, italic }) from\n\t// AssistantMessageComponent; normal assistant text does not. Count only\n\t// normal text blocks so anchors remain correct if thinking visibility is\n\t// toggled on.\n\treturn isMarkdown(component) && !(component as any).defaultTextStyle;\n}\n\nexport function placeAnchoredGroupBeforeText(container: Container, target: Markdown, group: ToolGroupComponent): void {\n\tdetachGroup(group, container);\n\tconst targetIndex = container.children.indexOf(target);\n\tif (targetIndex < 0) return;\n\n\t// Pi may accumulate one Spacer for the message itself plus one Spacer for\n\t// every hidden thinking run before this text. Tool loops can therefore leave\n\t// an arbitrarily large run here. Replace the entire run with a deterministic\n\t// boundary:\n\t//\n\t// previous text/content -> one blank -> compact group -> one blank -> text\n\t//\n\t// This also makes repeated cumulative AssistantMessageComponent rebuilds\n\t// idempotent instead of accumulating more spacing around restored anchors.\n\tlet spacerStart = targetIndex;\n\twhile (spacerStart > 0 && isSpacer(container.children[spacerStart - 1])) spacerStart--;\n\tif (targetIndex > spacerStart) {\n\t\tcontainer.children.splice(spacerStart, targetIndex - spacerStart);\n\t}\n\tgroup.anchored = true;\n\tcontainer.children.splice(spacerStart, 0, new Spacer(1), group, new Spacer(1));\n\tnoteGroupMount(container, group);\n}\n\nexport function insertAnchoredGroup(container: Container, ordinal: number, group: ToolGroupComponent): void {\n\tif (!group.hasVisibleEntries()) return;\n\tconst markdowns = container.children.filter(isVisibleTextMarkdown);\n\tconst target = markdowns[ordinal];\n\tif (!target) return;\n\tremoveGroupFromContainer(container, group);\n\tplaceAnchoredGroupBeforeText(container, target, group);\n}\n\nexport function installAssistantExpansion(component: AssistantMessageComponent, contentContainer: Container): void {\n\t// Ctrl+O only visits top-level chat children. Once compact groups are\n\t// anchored inside an AssistantMessageComponent, make that top-level\n\t// component expandable and delegate the state to its nested groups.\n\t(component as any).setExpanded = (expanded: boolean) => {\n\t\tconst state = runtime.assistantContentStates.get(contentContainer);\n\t\tif (!state) return;\n\t\tfor (const group of state.anchors.values()) group.setExpanded(expanded);\n\t\tcontentContainer.invalidate();\n\t};\n}\n\nexport function anchorGroupBeforeCurrentText(group: ToolGroupComponent, ordinal: number): void {\n\tif (!runtime.lastStreamingComp || !runtime.lastChatContainer) return;\n\tconst contentContainer = (runtime.lastStreamingComp as any).contentContainer;\n\tif (!isContainer(contentContainer)) return;\n\n\t// An open group normally lives directly in the chat container. Remove it\n\t// there before nesting it at the exact text boundary.\n\tremoveGroupFromContainer(runtime.lastChatContainer, group);\n\n\tconst previousAnchor = runtime.groupAnchors.get(group);\n\tif (previousAnchor) {\n\t\tconst previousState = runtime.assistantContentStates.get(previousAnchor.container);\n\t\tif (previousState?.anchors.get(previousAnchor.ordinal) === group) {\n\t\t\tpreviousState.anchors.delete(previousAnchor.ordinal);\n\t\t}\n\t\tremoveGroupFromContainer(previousAnchor.container, group);\n\t}\n\n\tif (!group.hasVisibleEntries()) {\n\t\truntime.groups.delete(group);\n\t\treturn;\n\t}\n\n\tconst state = getAssistantContentState(contentContainer);\n\tconst replaced = state.anchors.get(ordinal);\n\tif (replaced && replaced !== group) {\n\t\tremoveGroupFromContainer(contentContainer, replaced);\n\t\treplaced.anchored = false;\n\t\truntime.groupAnchors.delete(replaced);\n\t}\n\tstate.anchors.set(ordinal, group);\n\truntime.groupAnchors.set(group, { container: contentContainer, ordinal });\n\tinsertAnchoredGroup(contentContainer, ordinal, group);\n\truntime.lastChatContainer.invalidate?.();\n\truntime.capturedTui?.requestRender?.();\n}\n\nexport function restoreAssistantAnchor(parent: any, component: any): void {\n\tif (!runtime.assistantContentContainers.has(parent) || !isVisibleTextMarkdown(component)) return;\n\tinstallVisibleAssistantMarkdownRendering(component);\n\tconst state = getAssistantContentState(parent);\n\tconst ordinal = state.nextTextOrdinal++;\n\tconst group = state.anchors.get(ordinal);\n\tif (group && group.hasVisibleEntries()) {\n\t\tremoveGroupFromContainer(parent, group);\n\t\tplaceAnchoredGroupBeforeText(parent, component, group);\n\t}\n\tconst divider = state.finalDivider;\n\tif (divider && divider.ordinal === ordinal) {\n\t\tplaceTurnDividerBeforeText(parent, component, divider.component);\n\t}\n}\n\nexport function releaseAssistantAnchors(component: any): void {\n\tif (!isAssistantMessage(component)) return;\n\tconst contentContainer = (component as any).contentContainer;\n\tif (!isContainer(contentContainer)) return;\n\tconst state = runtime.assistantContentStates.get(contentContainer);\n\tif (!state) return;\n\tfor (const group of state.anchors.values()) {\n\t\tfor (const tool of [...group.children]) delete (tool as any)[PARENT_KEY];\n\t\truntime.groupAnchors.delete(group);\n\t\truntime.groups.delete(group);\n\t}\n\tstate.anchors.clear();\n\tstate.finalDivider = undefined;\n}\n\nexport function stripAssistantPhantomPadding(parent: any, component: any): void {\n\t// Mark the plain Container that an AssistantMessageComponent owns as its\n\t// content container so we can trim its children later.\n\tif (isAssistantMessage(parent) && isContainer(component) && !isAssistantMessage(component)) {\n\t\truntime.assistantContentContainers.add(component);\n\t\tgetAssistantContentState(component);\n\t\tinstallAssistantExpansion(parent, component);\n\t\treturn;\n\t}\n\tif (!runtime.assistantContentContainers.has(parent)) return;\n\t// Pi still builds a native thinking widget (full Markdown, or the hidden\n\t// \"Thinking...\" label) beside the compact tree. Drop that widget so the run\n\t// is visible only inside the tree.\n\tif (!isNativeThinkingWidget(component)) return;\n\tconst index = parent.children.indexOf(component);\n\tif (index >= 0) parent.children.splice(index, 1);\n\tif (isSpacer(parent.children[index])) parent.children.splice(index, 1);\n\twhile (parent.children.length > 0 && parent.children.every((child: any) => isSpacer(child))) parent.children.pop();\n}\n\nexport function isNativeThinkingWidget(component: any): boolean {\n\tif (!component || isToolGroup(component)) return false;\n\tif (component.constructor?.name === \"MouseRegion\" && component.child) {\n\t\treturn isNativeThinkingWidget(component.child);\n\t}\n\tif (isMarkdown(component) && (component as any).defaultTextStyle) return true;\n\tif (!isText(component)) return false;\n\tconst visible = String((component as any).text ?? \"\").replace(/\\x1b\\[[0-9;]*m/g, \"\").trim();\n\treturn visible === \"\" || visible === \"Thinking...\" || visible === \"thinking\" || visible === \"thinking...\";\n}\n", "/** \u5C06\u5185\u90E8\u4EE3\u7801\u56F4\u680F\u6807\u8BB0\u8F6C\u6362\u4E3A\u4FDD\u7559 ANSI \u9AD8\u4EAE\u7684\u80CC\u666F\u9762\u677F\u3002 */\nimport { truncateToWidth, visibleWidth, stripTerminalSequences, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { MarkdownTheme, Markdown } from \"@earendil-works/pi-tui\";\nimport { getMarkdownTheme } from \"@earendil-works/pi-coding-agent\";\nimport { CODE_BLOCK_PADDING_X, MARKDOWN_RENDER_PATCH_KEY } from \"./constants.js\";\nimport { runtime } from \"./state.js\";\n\nexport function isCompactCodeBlockOpen(visible: string): boolean {\n\treturn visible === \"\u250C\u2500\" || visible.startsWith(\"\u250C\u2500 \");\n}\n\nexport function isCompactCodeBlockClose(visible: string): boolean {\n\treturn visible === \"\u2514\u2500\";\n}\n\nexport function getCompactMarkdownTheme(): MarkdownTheme {\n\tconst base = getMarkdownTheme();\n\tlet insideCodeBlock = false;\n\tconst theme: MarkdownTheme = {\n\t\t...base,\n\t\tcodeBlockIndent: \"\",\n\t\tcodeBlockBorder(text: string): string {\n\t\t\tconst opening = !insideCodeBlock;\n\t\t\tinsideCodeBlock = !insideCodeBlock;\n\t\t\tconst language = opening ? text.replace(/^```/, \"\").trim() : \"\";\n\t\t\tif (opening) {\n\t\t\t\ttheme.codeBlockIndent = \"\";\n\t\t\t}\n\t\t\tconst border = opening ? `\u250C\u2500${language ? ` ${language}` : \"\"}` : \"\u2514\u2500\";\n\t\t\treturn base.codeBlockBorder(border);\n\t\t},\n\t};\n\treturn theme;\n}\n\nexport function renderCodeBlockBackgroundRow(content: string, width: number): string {\n\tconst safeWidth = Math.max(1, width);\n\tconst horizontalPadding = Math.min(CODE_BLOCK_PADDING_X, Math.floor((safeWidth - 1) / 2));\n\tconst innerWidth = Math.max(1, safeWidth - horizontalPadding * 2);\n\tconst clipped = truncateToWidth(content, innerWidth, \"...\");\n\tconst rightFill = \" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)));\n\tconst row = `${\" \".repeat(horizontalPadding)}${clipped}${rightFill}${\" \".repeat(horizontalPadding)}`;\n\treturn runtime.currentTheme?.bg?.(\"toolPendingBg\", row) ?? row;\n}\n\nexport function normalizeCompactCodeBlockLines(lines: string[], width: number, paddingX = 0): string[] {\n\tconst safeWidth = Math.max(1, width);\n\tconst horizontalPadding = Math.max(0, Math.floor(paddingX));\n\tconst leftPadding = \" \".repeat(horizontalPadding);\n\tconst contentWidth = Math.max(1, safeWidth - horizontalPadding * 2);\n\tconst continuationWidth = contentWidth;\n\tconst normalized: string[] = [];\n\tlet codeBlockMode: \"none\" | \"background\" = \"none\";\n\n\tfor (const originalLine of lines) {\n\t\tconst withoutLeftPadding =\n\t\t\tleftPadding.length > 0 && originalLine.startsWith(leftPadding)\n\t\t\t\t? originalLine.slice(leftPadding.length)\n\t\t\t\t: originalLine;\n\t\tconst content = withoutLeftPadding.trimEnd();\n\t\tconst visible = stripTerminalSequences(content).trimStart();\n\t\tif (isCompactCodeBlockOpen(visible)) {\n\t\t\tcodeBlockMode = \"background\";\n\t\t\tconst language = visible.replace(/^\u250C\u2500/, \"\").trim();\n\t\t\tif (language) {\n\t\t\t\tconst label = runtime.currentTheme?.fg?.(\"muted\", language) ?? language;\n\t\t\t\tnormalized.push(`${leftPadding}${renderCodeBlockBackgroundRow(label, contentWidth)}`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (isCompactCodeBlockClose(visible)) {\n\t\t\tcodeBlockMode = \"none\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (codeBlockMode === \"background\") {\n\t\t\tconst codeWidth = Math.max(1, continuationWidth - CODE_BLOCK_PADDING_X * 2);\n\t\t\tconst wrappedRows = wrapTextWithAnsi(content, codeWidth);\n\t\t\tfor (const wrapped of wrappedRows.length > 0 ? wrappedRows : [\"\"]) {\n\t\t\t\tnormalized.push(`${leftPadding}${renderCodeBlockBackgroundRow(wrapped, contentWidth)}`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tnormalized.push(truncateToWidth(originalLine, safeWidth, \"...\"));\n\t}\n\n\treturn normalized;\n}\n\nexport function installVisibleAssistantMarkdownRendering(component: Markdown): void {\n\tconst markdown = component as any;\n\tif (markdown[MARKDOWN_RENDER_PATCH_KEY]) return;\n\tmarkdown.theme = getCompactMarkdownTheme();\n\tconst originalRender = markdown.render.bind(markdown);\n\tmarkdown.render = (width: number): string[] =>\n\t\tnormalizeCompactCodeBlockLines(originalRender(width), width, Number(markdown.paddingX) || 0);\n\tmarkdown[MARKDOWN_RENDER_PATCH_KEY] = { originalRender };\n\tmarkdown.invalidate();\n}\n", "/** \u5728\u53C2\u6570\u6D41\u5F0F\u8F93\u51FA\u9636\u6BB5\u521B\u5EFA\u5DE5\u5177\u5360\u4F4D\u884C\uFF0C\u5E76\u8FC1\u79FB\u5230\u771F\u5B9E\u5DE5\u5177\u7EC4\u4EF6\u3002 */\nimport { runtime } from \"./state.js\";\nimport { PARENT_KEY } from \"./constants.js\";\nimport { isToolGroup } from \"./guards.js\";\nimport { ToolGroupComponent } from \"./tool-group.js\";\nimport { detachGroup, noteGroupMount } from \"./assistant-patches.js\";\nimport type { PreparingTool } from \"./types.js\";\nimport { locateStreamingToolCall, streamingToolArgs } from \"./helpers.js\";\n\nexport function toolElapsed(tool: any): string {\n\tif (typeof tool?._elapsedDuration === \"number\") {\n\t\treturn tool._elapsedDuration.toFixed(1);\n\t}\n\tconst knownDuration = runtime.toolDurations.get(tool.toolCallId);\n\tif (knownDuration !== undefined) {\n\t\ttool._elapsedDuration = knownDuration;\n\t\treturn knownDuration.toFixed(1);\n\t}\n\tif (tool?._groupEndAt !== undefined) {\n\t\tconst start = runtime.toolStarts.get(tool.toolCallId) ?? tool._groupEndAt;\n\t\tconst dur = Math.max(0, (tool._groupEndAt - start) / 1000);\n\t\ttool._elapsedDuration = dur;\n\t\treturn dur.toFixed(1);\n\t}\n\tif (tool?.result) {\n\t\tconst resultTs = Number(tool.result?.timestamp);\n\t\tconst start = runtime.toolStarts.get(tool.toolCallId);\n\t\tif (start && resultTs && resultTs >= start) {\n\t\t\tconst dur = (resultTs - start) / 1000;\n\t\t\ttool._elapsedDuration = dur;\n\t\t\treturn dur.toFixed(1);\n\t\t}\n\t\ttool._elapsedDuration = 0;\n\t\treturn \"0.0\";\n\t}\n\tconst start = runtime.toolStarts.get(tool.toolCallId);\n\tif (start !== undefined) {\n\t\treturn Math.max(0, (Date.now() - start) / 1000).toFixed(1);\n\t}\n\treturn \"0.0\";\n}\n\nexport function rememberToolStart(toolCallId: string): void {\n\tif (!toolCallId || runtime.toolStarts.has(toolCallId) || runtime.toolDurations.has(toolCallId)) return;\n\truntime.toolStarts.set(toolCallId, Date.now());\n}\n\nexport function loadSessionToolTimings(entries: readonly any[]): void {\n\tif (!Array.isArray(entries)) return;\n\tfor (const entry of entries) {\n\t\tif (entry?.type === \"message\" && entry.message) {\n\t\t\tconst msg = entry.message;\n\t\t\tif (msg.role === \"assistant\" && Array.isArray(msg.content)) {\n\t\t\t\tconst startTime = Number(msg.timestamp) || (entry.timestamp ? new Date(entry.timestamp).getTime() : 0);\n\t\t\t\tfor (const block of msg.content) {\n\t\t\t\t\tif (block.type === \"toolCall\" && block.id) {\n\t\t\t\t\t\tif (startTime > 0) runtime.toolStarts.set(block.id, startTime);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (msg.role === \"toolResult\" && msg.toolCallId) {\n\t\t\t\tconst endTime = Number(msg.timestamp) || (entry.timestamp ? new Date(entry.timestamp).getTime() : 0);\n\t\t\t\tconst startTime = runtime.toolStarts.get(msg.toolCallId);\n\t\t\t\tif (startTime && endTime >= startTime) {\n\t\t\t\t\truntime.toolDurations.set(msg.toolCallId, (endTime - startTime) / 1000);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function findGroupedTool(toolCallId: string, contentIndex: number): any | undefined {\n\tfor (const group of runtime.groups) {\n\t\tfor (const entry of group.entries) {\n\t\t\tif (entry.kind !== \"tool\") continue;\n\t\t\tconst tool = entry.tool;\n\t\t\tif (toolCallId && tool?.toolCallId === toolCallId) return tool;\n\t\t\tif (tool?._contentIndex === contentIndex) return tool;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function invalidateGroupedTool(tool: any): void {\n\tconst group = tool?.owner ?? tool?.[PARENT_KEY];\n\tif (isToolGroup(group)) {\n\t\tif (!group.sealed) runtime.lastActiveGroup = group;\n\t\tgroup.invalidate();\n\t} else {\n\t\truntime.lastActiveGroup?.invalidate();\n\t}\n\truntime.capturedTui?.requestRender?.();\n}\n\nexport function findOpenGroup(): ToolGroupComponent | null {\n\tif (runtime.lastActiveGroup && !runtime.lastActiveGroup.sealed && runtime.groups.has(runtime.lastActiveGroup)) return runtime.lastActiveGroup;\n\tfor (const group of runtime.groups) {\n\t\tif (!group.sealed) return group;\n\t}\n\treturn null;\n}\n\nexport function placeGroupAfter(parent: any, after: any, group: ToolGroupComponent): void {\n\tconst children = parent?.children;\n\tif (!Array.isArray(children)) return;\n\tdetachGroup(group, parent);\n\tconst existing = children.indexOf(group);\n\tif (existing >= 0) children.splice(existing, 1);\n\tconst afterIndex = after ? children.indexOf(after) : -1;\n\tchildren.splice(afterIndex >= 0 ? afterIndex + 1 : children.length, 0, group);\n\tnoteGroupMount(parent, group);\n\truntime.lastActiveGroup = group;\n}\n\nexport function openToolGroup(): ToolGroupComponent | null {\n\tconst open = findOpenGroup();\n\tif (open) {\n\t\tif (runtime.lastChatContainer && runtime.lastStreamingComp) placeGroupAfter(runtime.lastChatContainer, runtime.lastStreamingComp, open);\n\t\treturn open;\n\t}\n\tif (!runtime.lastChatContainer || !runtime.lastStreamingComp) return null;\n\tlet group: ToolGroupComponent;\n\tconst parent = runtime.lastChatContainer;\n\tconst children = parent.children;\n\tif (!Array.isArray(children)) return null;\n\tconst idx = children.indexOf(runtime.lastStreamingComp);\n\tgroup = new ToolGroupComponent();\n\tdetachGroup(group);\n\tchildren.splice(idx >= 0 ? idx + 1 : children.length, 0, group);\n\tnoteGroupMount(parent, group);\n\truntime.groups.add(group);\n\truntime.lastActiveGroup = group;\n\tparent.invalidate?.();\n\treturn group;\n}\n\nexport function attachPreparingTool(tool: PreparingTool): void {\n\tif (tool.owner) return;\n\tconst group = openToolGroup();\n\tif (!group) return;\n\ttool.owner = group;\n\tgroup.entries.push({ kind: \"tool\", tool });\n\tgroup.invalidate();\n\truntime.lastActiveGroup = group;\n}\n\nexport function detachPreparingTool(tool: PreparingTool): void {\n\tconst group = tool.owner;\n\tif (group) {\n\t\tconst index = group.entries.findIndex((entry) => entry.kind === \"tool\" && entry.tool === tool);\n\t\tif (index >= 0) group.entries.splice(index, 1);\n\t}\n\ttool.owner = null;\n}\n\nexport function takePreparingTool(real: any): PreparingTool | undefined {\n\tconst id = String(real?.toolCallId ?? \"\");\n\tconst name = String(real?.toolName ?? \"\");\n\tif (id) {\n\t\tfor (const [index, candidate] of runtime.preparingByIndex) {\n\t\t\tif (candidate.toolCallId === id) {\n\t\t\t\truntime.preparingByIndex.delete(index);\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\t}\n\tconst matches = [...runtime.preparingByIndex.entries()].filter(([, candidate]) => candidate.toolName === name);\n\tif (matches.length === 1) {\n\t\truntime.preparingByIndex.delete(matches[0][0]);\n\t\treturn matches[0][1];\n\t}\n\treturn undefined;\n}\n\nexport function absorbPreparingTool(real: any): void {\n\tconst preparing = takePreparingTool(real);\n\tif (!preparing) return;\n\tconst id = String(real?.toolCallId ?? \"\");\n\tconst start = runtime.toolStarts.get(preparing.toolCallId);\n\tif (start !== undefined && id && !runtime.toolStarts.has(id)) runtime.toolStarts.set(id, start);\n\treal._contentIndex = preparing._contentIndex;\n\tif ((!real.args || Object.keys(real.args).length === 0) && preparing.args) real.args = preparing.args;\n\tdetachPreparingTool(preparing);\n}\n\nexport function clearPreparingTools(): void {\n\tfor (const tool of runtime.preparingByIndex.values()) detachPreparingTool(tool);\n\truntime.preparingByIndex.clear();\n}\n\nexport function noteStreamingToolCall(content: any[], streamEvent: any): void {\n\tconst located = locateStreamingToolCall(content, streamEvent);\n\tif (!located) return;\n\tconst { index, block } = located;\n\tconst id = String(block.id || \"\");\n\tconst name = String(block.name || \"tool\");\n\tconst args = streamingToolArgs(block);\n\tconst existing = findGroupedTool(id, index);\n\tif (existing && !existing._preparing) {\n\t\texisting._contentIndex = index;\n\t\texisting.args = args;\n\t\trememberToolStart(String(existing.toolCallId || id));\n\t\tinvalidateGroupedTool(existing);\n\t\treturn;\n\t}\n\n\tlet preparing = runtime.preparingByIndex.get(index);\n\tif (!preparing) {\n\t\tpreparing = {\n\t\t\ttoolName: name,\n\t\t\ttoolCallId: id || `preparing:${index}`,\n\t\t\targs,\n\t\t\tisPartial: true,\n\t\t\t_preparing: true,\n\t\t\t_contentIndex: index,\n\t\t\towner: null,\n\t\t};\n\t\truntime.preparingByIndex.set(index, preparing);\n\t\tattachPreparingTool(preparing);\n\t} else {\n\t\tif (name && name !== \"tool\") preparing.toolName = name;\n\t\tif (id && preparing.toolCallId !== id) {\n\t\t\tconst previous = preparing.toolCallId;\n\t\t\tpreparing.toolCallId = id;\n\t\t\tconst start = runtime.toolStarts.get(previous);\n\t\t\tif (start !== undefined && !runtime.toolStarts.has(id)) runtime.toolStarts.set(id, start);\n\t\t}\n\t\tpreparing.args = args;\n\t\tif (!preparing.owner) attachPreparingTool(preparing);\n\t}\n\trememberToolStart(preparing.toolCallId);\n\tinvalidateGroupedTool(preparing);\n}\n", "/** \u52A8\u753B\u8C03\u5EA6\u4E0E\u7EC8\u7AEF\u9F20\u6807\u72B6\u6001\u6E05\u7406\u3002 */\nimport { spinnerStart, THINKING_SPINNER, SPINNER_MS } from \"./constants.js\";\nimport { runtime } from \"./state.js\";\n\nexport function thinkingSpinnerFrame(now = Date.now()): { frame: string; color: string } {\n\tconst index =\n\t\tMath.floor((now - spinnerStart) / THINKING_SPINNER.intervalMs) % THINKING_SPINNER.rawFrames.length;\n\treturn {\n\t\tframe: THINKING_SPINNER.rawFrames[index]!,\n\t\tcolor: THINKING_SPINNER.colorKeys[index]!,\n\t};\n}\n\nexport function disableMouseTracking(): void {\n\tif (process.stdout.isTTY) {\n\t\tprocess.stdout.write(\"\\x1b[?1006l\\x1b[?1004l\\x1b[?1002l\\x1b[?1000l\");\n\t}\n}\n\nprocess.on(\"exit\", disableMouseTracking);\n\nexport function scheduleAnimation(): void {\n\tif (runtime.animTimer) return;\n\truntime.animTimer = setTimeout(() => {\n\t\truntime.animTimer = null;\n\t\tlet any = false;\n\t\tfor (const g of runtime.groups) {\n\t\t\tif (g.needsAnimation()) {\n\t\t\t\tany = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (any && runtime.capturedTui) {\n\t\t\truntime.capturedTui.requestRender();\n\t\t}\n\t}, [...runtime.groups].some((group) => group.hasPending()) ? SPINNER_MS : THINKING_SPINNER.intervalMs);\n}\n", "/** \u914D\u7F6E\u6301\u4E45\u5316\uFF1B\u901A\u8FC7\u53EF\u6CE8\u5165\u7684\u8BFB\u5199\u5668\u9694\u79BB\u6587\u4EF6\u7CFB\u7EDF\u3002 */\nimport { join } from \"path\";\nimport { homedir } from \"os\";\nimport { readFileSync, writeFileSync } from \"fs\";\n\nexport const CONFIG_PATH = join(homedir(), \".pi\", \"agent\", \"compact-ui.json\");\n\nexport const DEFAULT_CONFIG = { expandedToolLines: 5, expandedThinkingLines: 10, maxGroupEntries: 5 };\n\nexport const config = loadConfig(CONFIG_PATH);\n\nexport function saveConfig(\n\tvalues = config,\n\tpath = CONFIG_PATH,\n\twrite: (path: string, data: string) => void = writeFileSync,\n): void {\n\ttry {\n\t\twrite(path, JSON.stringify(values, null, 2) + \"\\n\");\n\t} catch {\n\t\t// ignore\n\t}\n}\n\n/** Read configuration without coupling tests to the user's filesystem. */\nexport function loadConfig(path: string, read: (path: string, encoding: 'utf-8') => string = readFileSync): typeof DEFAULT_CONFIG {\n\ttry {\n\t\treturn { ...DEFAULT_CONFIG, ...JSON.parse(read(path, 'utf-8')) };\n\t} catch {\n\t\treturn { ...DEFAULT_CONFIG };\n\t}\n}\n", "/** \u601D\u8003\u6BB5\u751F\u547D\u5468\u671F\u4E0E\u4F30\u7B97/\u7CBE\u786E token \u7528\u91CF\u66F4\u65B0\u3002 */\nimport { runtime } from \"./state.js\";\nimport { estimateTextTokens } from \"./helpers.js\";\nimport type { ThinkingEntry } from \"./types.js\";\n\nexport function updateActiveThinkingTokens(message: any): void {\n\tconst entry = runtime.activeThinking;\n\tif (!entry) return;\n\tentry.text = [...runtime.activeThinkingBlocks.values()].filter((text) => text.trim()).join(\"\\n\\n\");\n\t// Most providers report reasoning usage only when the response finishes. While\n\t// streaming, fall back to pi's own chars/4 token heuristic and mark it with \u2248.\n\tconst reported = Number(message?.usage?.reasoning);\n\tif (Number.isFinite(reported) && reported > 0) {\n\t\tentry.tokens = reported;\n\t\tentry.tokensExact = true;\n\t\truntime.lastReportedReasoningTokens = reported;\n\t\treturn;\n\t}\n\tentry.tokens = estimateTextTokens(entry.text);\n\tentry.tokensExact = false;\n}\n\nexport function createThinkingEntry(): ThinkingEntry {\n\tconst entry: ThinkingEntry = {\n\t\tkind: \"thinking\",\n\t\tid: runtime.thinkingEntrySeq++,\n\t\ttext: \"\",\n\t\ttokens: 0,\n\t\ttokensExact: false,\n\t\tactive: true,\n\t\towner: null,\n\t};\n\truntime.activeThinking = entry;\n\truntime.activeThinkingBlocks.clear();\n\truntime.unattachedThinking.push(entry);\n\treturn entry;\n}\n\nexport function finalizeActiveThinking(): void {\n\tconst entry = runtime.activeThinking;\n\tif (!entry) return;\n\tentry.active = false;\n\tentry.owner?.invalidate();\n\tif (runtime.activeThinkingIndex !== null) runtime.sealedThinkingIndexes.add(runtime.activeThinkingIndex);\n\truntime.lastSealedThinkingEntry = entry;\n\truntime.activeThinking = null;\n\truntime.activeThinkingIndex = null;\n\truntime.activeThinkingBlocks.clear();\n}\n\nexport function refreshSealedThinkingTokens(reportedReasoning?: unknown): void {\n\tconst reported = Number(reportedReasoning);\n\tif (Number.isFinite(reported) && reported > 0) runtime.lastReportedReasoningTokens = reported;\n\tconst entry = runtime.lastSealedThinkingEntry;\n\tif (!entry || entry.tokensExact) return;\n\tif (!entry.text.trim()) return; // no thinking row to correct\n\tif (!(runtime.lastReportedReasoningTokens > 0)) return;\n\tentry.tokens = runtime.lastReportedReasoningTokens;\n\tentry.tokensExact = true;\n\tentry.owner?.invalidate();\n\truntime.capturedTui?.requestRender?.();\n}\n", "/** \u6309\u6D41\u987A\u5E8F\u7EC4\u5408\u601D\u8003\u4E0E\u5DE5\u5177\uFF0C\u5E76\u5728\u53EF\u89C1\u6B63\u6587\u8FB9\u754C\u5C01\u7EC4\u3002 */\nimport { isToolExecution, isSpacer, isAssistantMessage, isToolGroup, isContainer } from \"./guards.js\";\nimport { ToolGroupComponent } from \"./tool-group.js\";\nimport { thinkingAlreadyShown, isVisibleTextMarkdown, anchorGroupBeforeCurrentText, detachGroup, noteGroupMount, removeGroupFromContainer, ensureAssistantThinkingPatched, stripAssistantPhantomPadding, restoreAssistantAnchor, releaseAssistantAnchors, getAssistantContentState } from \"./assistant-patches.js\";\nimport { runtime } from \"./state.js\";\nimport { estimateTextTokens } from \"./helpers.js\";\nimport { findOpenGroup, placeGroupAfter } from \"./streaming-tools.js\";\nimport { finalizeActiveThinking } from \"./thinking.js\";\nimport type { ThinkingEntry, PatchState } from \"./types.js\";\nimport { Container } from \"@earendil-works/pi-tui\";\nimport { AssistantMessageComponent } from \"@earendil-works/pi-coding-agent\";\nimport { PATCH_KEY, LIVE_ASSISTANT_KEY, IS_STREAMING_COMP, PARENT_KEY } from \"./constants.js\";\n\nexport function isGroupable(value: any): boolean {\n\treturn isToolExecution(value);\n}\n\nexport function previousGroupable(children: any[], start: number): { child: any; index: number } | undefined {\n\tfor (let i = start; i >= 0; i--) {\n\t\tconst child = children[i];\n\t\tif (isSpacer(child)) continue;\n\t\tif (isAssistantMessage(child)) continue;\n\t\t// A sealed block is a text boundary, not a reason to ignore an earlier open group.\n\t\t// Notices and other chat widgets between tool rounds are not boundaries either.\n\t\tif (isToolGroup(child) && child.sealed) continue;\n\t\tif (isToolGroup(child) || isGroupable(child)) return { child, index: i };\n\t}\n\treturn undefined;\n}\n\nexport function assistantHasVisibleText(component: any): boolean {\n\tconst content = component?.lastMessage?.content;\n\tif (!Array.isArray(content)) return false;\n\treturn content.some((item: any) => item?.type === \"text\" && String(item.text ?? \"\").trim());\n}\n\nexport function absorbThinkingBeforeText(group: ToolGroupComponent, message: any): void {\n\tconst content = message?.content;\n\tif (!Array.isArray(content)) return;\n\tfor (const item of content) {\n\t\tif (item?.type === \"text\" && String(item.text ?? \"\").trim()) break;\n\t\tif (item?.type !== \"thinking\") continue;\n\t\tconst text = String(item.thinking ?? \"\").trim();\n\t\tif (!text || thinkingAlreadyShown(text)) continue;\n\t\tgroup.entries.push({\n\t\t\tkind: \"thinking\",\n\t\t\tid: runtime.thinkingEntrySeq++,\n\t\t\ttext,\n\t\t\ttokens: estimateTextTokens(text),\n\t\t\ttokensExact: false,\n\t\t\tactive: false,\n\t\t\towner: group,\n\t\t});\n\t}\n}\n\nexport function sealOpenGroupAtAssistantText(assistant: any): void {\n\tconst open = findOpenGroup();\n\tif (!open) return;\n\tabsorbThinkingBeforeText(open, assistant.lastMessage);\n\topen.sealed = true;\n\tfinalizeActiveThinking();\n\tconst contentContainer = assistant.contentContainer;\n\tif (isContainer(contentContainer) && contentContainer.children.some(isVisibleTextMarkdown)) {\n\t\tconst previous = runtime.lastStreamingComp;\n\t\truntime.lastStreamingComp = assistant;\n\t\tanchorGroupBeforeCurrentText(open, 0);\n\t\truntime.lastStreamingComp = previous ?? assistant;\n\t}\n\topen.invalidate();\n}\n\nexport function ensureThinkingGroup(): void {\n\tif (runtime.unattachedThinking.length === 0) return;\n\tlet group = findOpenGroup();\n\tif (group && runtime.lastChatContainer && runtime.lastStreamingComp) {\n\t\tplaceGroupAfter(runtime.lastChatContainer, runtime.lastStreamingComp, group);\n\t}\n\tif (!group) {\n\t\tif (!runtime.lastChatContainer || !runtime.lastStreamingComp) return; // retry on the next event\n\t\tconst parent = runtime.lastChatContainer;\n\t\tconst children = parent.children;\n\t\tif (!Array.isArray(children)) return;\n\t\tconst idx = children.indexOf(runtime.lastStreamingComp);\n\t\tgroup = new ToolGroupComponent();\n\t\tdetachGroup(group);\n\t\tchildren.splice(idx >= 0 ? idx + 1 : children.length, 0, group);\n\t\tnoteGroupMount(parent, group);\n\t\truntime.groups.add(group);\n\t\truntime.lastActiveGroup = group;\n\t\tparent.invalidate?.();\n\t}\n\twhile (runtime.unattachedThinking.length > 0) group.addThinking(runtime.unattachedThinking.shift()!);\n\tgroup.invalidate();\n\truntime.capturedTui?.requestRender?.();\n}\n\nexport function flushPendingTextSeal(): void {\n\tif (!runtime.pendingTextSeal) return;\n\n\t// A run still streaming when the answer starts belongs to the block being\n\t// sealed, and may not have a group yet.\n\tif (runtime.activeThinking || runtime.unattachedThinking.length > 0) ensureThinkingGroup();\n\n\tif (runtime.lastActiveGroup && !runtime.lastActiveGroup.sealed) {\n\t\t// The active group contains every thinking/tool event since the previous\n\t\t// visible text. Anchor it immediately before this text block so the visual\n\t\t// component order matches the stream order:\n\t\t// group -> visible text -> next group -> next visible text\n\t\tif (runtime.lastActiveGroup.hasVisibleEntries()) {\n\t\t\tif (runtime.pendingTextOrdinal !== null) {\n\t\t\t\tanchorGroupBeforeCurrentText(runtime.lastActiveGroup, runtime.pendingTextOrdinal);\n\t\t\t}\n\t\t} else {\n\t\t\tif (runtime.lastChatContainer) removeGroupFromContainer(runtime.lastChatContainer, runtime.lastActiveGroup);\n\t\t\truntime.groups.delete(runtime.lastActiveGroup);\n\t\t}\n\t\truntime.lastActiveGroup.sealed = true;\n\t\tfinalizeActiveThinking();\n\t\truntime.lastActiveGroup.invalidate();\n\t\truntime.pendingTextSeal = false;\n\t\truntime.pendingTextOrdinal = null;\n\t\treturn;\n\t}\n\n\t// No thinking or tools preceded this text, so there is no compact block to\n\t// seal. Do not let the boundary leak forward and close a later tool group.\n\truntime.pendingTextSeal = false;\n\truntime.pendingTextOrdinal = null;\n}\n\nexport function getPrecedingAssistantThinking(children: any[], beforeIndex: number): string[] {\n\tfor (let i = beforeIndex; i >= 0; i--) {\n\t\tconst child = children[i];\n\t\tif (isSpacer(child)) continue;\n\t\tif (isAssistantMessage(child)) {\n\t\t\tconst content = (child as any).lastMessage?.content;\n\t\t\tif (!Array.isArray(content)) return [];\n\t\t\tconst texts: string[] = [];\n\t\t\tfor (const item of content) {\n\t\t\t\tif (item?.type === \"thinking\") {\n\t\t\t\t\tconst t = String(item.thinking ?? \"\").trim();\n\t\t\t\t\tif (t && !thinkingAlreadyShown(t)) texts.push(t);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn texts;\n\t\t}\n\t\tbreak;\n\t}\n\treturn [];\n}\n\nexport function attachPrecedingThinkingToGroup(group: ToolGroupComponent, children: any[], beforeIndex: number): void {\n\tconst texts = getPrecedingAssistantThinking(children, beforeIndex);\n\tif (texts.length === 0) return;\n\tfor (const text of texts) {\n\t\tif (thinkingAlreadyShown(text)) continue;\n\t\tconst entry: ThinkingEntry = {\n\t\t\tkind: \"thinking\",\n\t\t\tid: runtime.thinkingEntrySeq++,\n\t\t\ttext,\n\t\t\ttokens: estimateTextTokens(text),\n\t\t\ttokensExact: false,\n\t\t\tactive: false,\n\t\t\towner: group,\n\t\t};\n\t\tgroup.entries.push(entry);\n\t}\n}\n\nexport function joinOpenGroup(parent: any, index: number, component: any): boolean {\n\tif (!runtime.lastChatContainer || parent !== runtime.lastChatContainer) return false;\n\tconst open = findOpenGroup();\n\tif (!open) return false;\n\tconst children = parent.children;\n\tchildren.splice(index, 1);\n\tif (runtime.lastStreamingComp && children.includes(runtime.lastStreamingComp)) {\n\t\tplaceGroupAfter(parent, runtime.lastStreamingComp, open);\n\t} else if (!children.includes(open)) {\n\t\tchildren.push(open);\n\t\tnoteGroupMount(parent, open);\n\t}\n\tattachPrecedingThinkingToGroup(open, children, children.indexOf(open) - 1);\n\topen.addTool(component);\n\truntime.lastActiveGroup = open;\n\topen.invalidate();\n\treturn true;\n}\n\nexport function maybeGroup(parent: any, component: any): void {\n\tif (!isGroupable(component) || isToolGroup(parent)) return;\n\tconst children = parent?.children;\n\tif (!Array.isArray(children)) return;\n\tconst index = children.indexOf(component);\n\tif (index < 0) return;\n\tif (joinOpenGroup(parent, index, component)) return;\n\tconst prior = previousGroupable(children, index - 1);\n\n\t// Previous sibling is an open (not-yet-sealed) group \u2192 join it.\n\tif (isToolGroup(prior?.child) && !prior.child.sealed) {\n\t\tattachPrecedingThinkingToGroup(prior.child, children, index - 1);\n\t\tchildren.splice(index, 1);\n\t\tprior.child.addTool(component);\n\t\truntime.lastActiveGroup = prior.child;\n\t\treturn;\n\t}\n\t// Previous sibling is a bare tool \u2192 merge both into a new group.\n\tif (prior && isGroupable(prior.child)) {\n\t\tconst group = new ToolGroupComponent();\n\t\tattachPrecedingThinkingToGroup(group, children, prior.index - 1);\n\t\tgroup.addTool(prior.child);\n\t\tattachPrecedingThinkingToGroup(group, children, index - 1);\n\t\tgroup.addTool(component);\n\t\t(parent as any).children[prior.index] = group;\n\t\tchildren.splice(index, 1);\n\t\tnoteGroupMount(parent, group);\n\t\truntime.groups.add(group);\n\t\truntime.lastActiveGroup = group;\n\t\treturn;\n\t}\n\t// Otherwise (sealed group before, or nothing groupable) \u2192 wrap the tool in a\n\t// fresh open group so it stays visible.\n\tconst group = new ToolGroupComponent();\n\tattachPrecedingThinkingToGroup(group, children, index - 1);\n\tgroup.addTool(component);\n\t(parent as any).children[index] = group;\n\tnoteGroupMount(parent, group);\n\truntime.groups.add(group);\n\truntime.lastActiveGroup = group;\n}\n\nexport function installGrouping(): void {\n\tconst host = globalThis as any;\n\tconst prototypes: any[] = [Container.prototype];\n\tconst agentContainerProto = Object.getPrototypeOf(AssistantMessageComponent.prototype);\n\tif (agentContainerProto && agentContainerProto !== Object.prototype && !prototypes.includes(agentContainerProto)) {\n\t\tprototypes.push(agentContainerProto);\n\t}\n\n\tconst patchKey = PATCH_KEY;\n\tconst previous = host[patchKey] as Map<any, PatchState> | undefined;\n\tconst stateMap = new Map<any, PatchState>();\n\n\tfor (const prototype of prototypes) {\n\t\tconst prev = previous instanceof Map ? previous.get(prototype) : (previous as any as PatchState | undefined);\n\t\tconst original = {\n\t\t\taddChild: prev && prototype.addChild === prev.installed.addChild ? prev.original.addChild : prototype.addChild,\n\t\t\tremoveChild: prev && prototype.removeChild === prev.installed.removeChild ? prev.original.removeChild : prototype.removeChild,\n\t\t\tclear: prev && prototype.clear === prev.installed.clear ? prev.original.clear : prototype.clear,\n\t\t};\n\t\tconst state: PatchState = {\n\t\t\tactive: true,\n\t\t\tprototype,\n\t\t\toriginal,\n\t\t\tinstalled: undefined as any,\n\t\t};\n\t\tstate.installed = {\n\t\t\taddChild: function (this: any, component: any) {\n\t\t\t\tconst result = state.original.addChild.call(this, component);\n\t\t\t\tif (component && typeof component === \"object\") {\n\t\t\t\t\t// Remember where the current assistant message component lives so a\n\t\t\t\t\t// thinking-only group can be inserted right after it later.\n\t\t\t\t\tif (isAssistantMessage(component)) {\n\t\t\t\t\t\tconst assistant = component as any;\n\t\t\t\t\t\tensureAssistantThinkingPatched(assistant);\n\t\t\t\t\t\tconst streaming = assistant.isStreaming === true;\n\t\t\t\t\t\tif (streaming) {\n\t\t\t\t\t\t\tassistant[LIVE_ASSISTANT_KEY] = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\truntime.lastChatContainer = this;\n\t\t\t\t\t\truntime.lastStreamingComp = assistant;\n\t\t\t\t\t\tassistant[IS_STREAMING_COMP] = streaming;\n\t\t\t\t\t\t// Keep one open block across assistant messages until visible text.\n\t\t\t\t\t\t// A rebuilt message that already has text is that boundary.\n\t\t\t\t\t\tif (assistantHasVisibleText(assistant)) {\n\t\t\t\t\t\t\tsealOpenGroupAtAssistantText(assistant);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst open = findOpenGroup();\n\t\t\t\t\t\t\tif (open) placeGroupAfter(this, assistant, open);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A run that started before its message component existed can now\n\t\t\t\t\t\t// be placed in the transcript, in front of this message's text.\n\t\t\t\t\t\tif (runtime.unattachedThinking.length > 0) ensureThinkingGroup();\n\t\t\t\t\t\tflushPendingTextSeal();\n\t\t\t\t\t}\n\t\t\t\t\tmaybeGroup(this, component);\n\t\t\t\t\tstripAssistantPhantomPadding(this, component);\n\t\t\t\t\trestoreAssistantAnchor(this, component);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tremoveChild: function (this: any, component: any) {\n\t\t\t\tconst group = component?.[PARENT_KEY];\n\t\t\t\tif (isToolGroup(group) && (group as any)[PARENT_KEY] === this) {\n\t\t\t\t\tgroup.removeTool(component);\n\t\t\t\t\tif (group.children.length === 0 && group.entries.length === 0) runtime.groups.delete(group);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treleaseAssistantAnchors(component);\n\t\t\t\treturn state.original.removeChild.call(this, component);\n\t\t\t},\n\t\t\tclear: function (this: any) {\n\t\t\t\tif (runtime.assistantContentContainers.has(this)) {\n\t\t\t\t\t// AssistantMessageComponent rebuilds this container for every\n\t\t\t\t\t// cumulative stream update. Keep sealed compact groups in the\n\t\t\t\t\t// anchor map; restoreAssistantAnchor() reinserts each one before\n\t\t\t\t\t// its matching Markdown child as the rebuild proceeds.\n\t\t\t\t\tgetAssistantContentState(this).nextTextOrdinal = 0;\n\t\t\t\t\treturn state.original.clear.call(this);\n\t\t\t\t}\n\t\t\t\tfor (const child of [...(this.children ?? [])]) {\n\t\t\t\t\tif (isToolGroup(child)) {\n\t\t\t\t\t\tfor (const tool of [...child.children] as any[]) delete tool[PARENT_KEY];\n\t\t\t\t\t\truntime.groups.delete(child);\n\t\t\t\t\t}\n\t\t\t\t\treleaseAssistantAnchors(child);\n\t\t\t\t}\n\t\t\t\treturn state.original.clear.call(this);\n\t\t\t},\n\t\t};\n\t\tprototype.addChild = state.installed.addChild;\n\t\tprototype.removeChild = state.installed.removeChild;\n\t\tprototype.clear = state.installed.clear;\n\t\tstateMap.set(prototype, state);\n\t}\n\thost[patchKey] = stateMap;\n}\n", "/** \u538B\u7F29\u6458\u8981\u7684\u7D27\u51D1\u5448\u73B0\u4E0E\u53EF\u70ED\u91CD\u8F7D\u7684\u539F\u578B\u8865\u4E01\u3002 */\nimport { visibleWidth, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport { runtime } from \"./state.js\";\nimport { formatTokenK } from \"./helpers.js\";\nimport { CompactionSummaryMessageComponent } from \"@earendil-works/pi-coding-agent\";\nimport { COMPACTION_STYLE_PATCH_KEY, GROUP_PADDING_X } from \"./constants.js\";\n\nexport class CompactionHeaderComponent implements Component {\n\tconstructor(private readonly tokensBefore: number) {}\n\n\trender(width: number): string[] {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, text: string) => theme?.fg?.(color, text) ?? text;\n\t\tconst exactTokens = Math.max(0, this.tokensBefore).toLocaleString();\n\t\tconst icon = fg(\"success\", \"\u203A\u2039\");\n\t\tconst title = fg(\"success\", \"Context compacted\");\n\t\tconst detail = fg(\"muted\", ` \u2022 ${exactTokens} tokens \u2192 summary`);\n\t\tconst full = `${icon} ${title}${detail}`;\n\t\tif (visibleWidth(full) <= width) return [full];\n\n\t\tconst compactTitle = fg(\"success\", \"Compacted\");\n\t\tconst compactDetail = fg(\"muted\", ` \u2022 ${formatTokenK(this.tokensBefore)} tok`);\n\t\treturn [truncateToWidth(`${icon} ${compactTitle}${compactDetail}`, Math.max(1, width), \"...\")];\n\t}\n\n\tinvalidate(): void {}\n}\n\nexport function installCompactionSummaryRendering(): void {\n\tconst prototype = CompactionSummaryMessageComponent.prototype as any;\n\tconst previous = prototype[COMPACTION_STYLE_PATCH_KEY] as\n\t\t| {\n\t\t\t\toriginal?: (this: any) => void;\n\t\t\t\tinstalled?: (this: any) => void;\n\t\t\t\toriginalUpdateDisplay?: (this: any) => void;\n\t\t\t\toriginalSetExpanded?: (this: any, expanded: boolean) => void;\n\t\t\t\tinstalledUpdateDisplay?: (this: any) => void;\n\t\t\t\tinstalledSetExpanded?: (this: any, expanded: boolean) => void;\n\t\t }\n\t\t| undefined;\n\t// Replace the previous compact-ui closure on hot reload while retaining\n\t// pi's original renderer for a future replacement.\n\tconst previousInstalledUpdate = previous?.installedUpdateDisplay ?? previous?.installed;\n\tconst originalUpdateDisplay =\n\t\tprevious && previousInstalledUpdate && prototype.updateDisplay === previousInstalledUpdate\n\t\t\t? (previous.originalUpdateDisplay ?? previous.original)!\n\t\t\t: (prototype.updateDisplay as (this: any) => void);\n\tconst originalSetExpanded =\n\t\tprevious?.installedSetExpanded && prototype.setExpanded === previous.installedSetExpanded\n\t\t\t? previous.originalSetExpanded!\n\t\t\t: (prototype.setExpanded as (this: any, expanded: boolean) => void);\n\tconst installedUpdateDisplay = function (this: any): void {\n\t\tthis.paddingX = GROUP_PADDING_X;\n\t\tthis.paddingY = 0;\n\t\tthis.setBgFn(undefined);\n\t\tthis.clear();\n\n\t\tconst tokensBefore = Number(this.message?.tokensBefore);\n\t\tconst safeTokens = Number.isFinite(tokensBefore) && tokensBefore > 0 ? tokensBefore : 0;\n\t\tthis.addChild(new CompactionHeaderComponent(safeTokens));\n\t};\n\tconst installedSetExpanded = function (this: any, _expanded: boolean): void {\n\t\t// Context compaction is a static transcript event. Global Ctrl+O remains\n\t\t// available for compact thinking/tool groups but does not alter this row.\n\t};\n\tprototype.updateDisplay = installedUpdateDisplay;\n\tprototype.setExpanded = installedSetExpanded;\n\tprototype[COMPACTION_STYLE_PATCH_KEY] = {\n\t\toriginalUpdateDisplay,\n\t\toriginalSetExpanded,\n\t\tinstalledUpdateDisplay,\n\t\tinstalledSetExpanded,\n\t};\n}\n", "/** \u5DE5\u5177\u4E0E\u601D\u8003\u8BE6\u60C5\u5F39\u7A97\u3001\u4EA4\u4E92\u5F0F\u6761\u76EE\u9009\u62E9\u5668\u3002 */\nimport { matchesKey, Key, wrapTextWithAnsi, visibleWidth, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport type { GroupEntry } from \"./types.js\";\nimport { toolStatus, thinkingTokenLabel, toolResultText, toolSummary } from \"./helpers.js\";\nimport { THINKING_SPINNER, SPINNER_MS, SPINNER, spinnerStart } from \"./constants.js\";\nimport { runtime } from \"./state.js\";\nimport { thinkingSpinnerFrame } from \"./animation.js\";\nimport { toolElapsed } from \"./streaming-tools.js\";\n\nexport class DetailModalComponent implements Component {\n\treadonly entry: GroupEntry;\n\tprivate scrollTop = 0;\n\tprivate followingEnd = true;\n\tprivate lastContentLineCount = 0;\n\tprivate lastInnerHeight = 10;\n\tprivate pollTimer: ReturnType<typeof setInterval> | null = null;\n\n\tconstructor(entry: GroupEntry) {\n\t\tthis.entry = entry;\n\t\tthis.startPollingIfNeeded();\n\t}\n\n\tprivate isEntryActive(): boolean {\n\t\tif (this.entry.kind === \"thinking\") {\n\t\t\treturn this.entry.active;\n\t\t}\n\t\treturn toolStatus(this.entry.tool) === \"pending\";\n\t}\n\n\tprivate startPollingIfNeeded(): void {\n\t\tif (this.isEntryActive()) {\n\t\t\tconst interval = this.entry.kind === \"thinking\" ? THINKING_SPINNER.intervalMs : SPINNER_MS;\n\t\t\tthis.pollTimer = setInterval(() => {\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t\tif (!this.isEntryActive() && this.pollTimer) {\n\t\t\t\t\tclearInterval(this.pollTimer);\n\t\t\t\t\tthis.pollTimer = null;\n\t\t\t\t}\n\t\t\t}, interval);\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tif (this.pollTimer) {\n\t\t\tclearInterval(this.pollTimer);\n\t\t\tthis.pollTimer = null;\n\t\t}\n\t}\n\n\tinvalidate(): void {}\n\n\tscrollBy(delta: number): void {\n\t\tthis.scrollTo(this.scrollTop + delta);\n\t}\n\n\tscrollTo(newTop: number): void {\n\t\tconst maxScroll = Math.max(0, this.lastContentLineCount - this.lastInnerHeight);\n\t\tthis.scrollTop = Math.max(0, Math.min(maxScroll, newTop));\n\t\tif (this.scrollTop >= maxScroll) {\n\t\t\tthis.followingEnd = true;\n\t\t} else {\n\t\t\tthis.followingEnd = false;\n\t\t}\n\t\truntime.capturedTui?.requestRender?.();\n\t}\n\n\tscrollToEnd(): void {\n\t\tthis.followingEnd = true;\n\t\tthis.scrollTop = Math.max(0, this.lastContentLineCount - this.lastInnerHeight);\n\t\truntime.capturedTui?.requestRender?.();\n\t}\n\n\thandleInput(data: string): boolean {\n\t\tif (matchesKey(data, Key.escape) || data === \"q\" || data === \"Q\") {\n\t\t\tcloseDetailModal();\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.up) || data === \"k\" || data === \"K\") {\n\t\t\tthis.scrollBy(-1);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.down) || data === \"j\" || data === \"J\") {\n\t\t\tthis.scrollBy(1);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.pageUp) || matchesKey(data, Key.left)) {\n\t\t\tthis.scrollBy(-10);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.pageDown) || matchesKey(data, Key.right) || matchesKey(data, Key.space)) {\n\t\t\tthis.scrollBy(10);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.home)) {\n\t\t\tthis.scrollTo(0);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.end)) {\n\t\t\tthis.scrollToEnd();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, t: string) => theme?.fg?.(color, t) ?? t;\n\t\tconst bold = theme?.bold ? theme.bold : (t: string) => t;\n\t\tconst borderFg = (t: string) => fg(\"borderAccent\", fg(\"border\", t));\n\t\tconst frame = SPINNER[Math.floor((Date.now() - spinnerStart) / SPINNER_MS) % SPINNER.length]!;\n\n\t\tconst termHeight = runtime.capturedTui?.terminal?.rows ?? process.stdout?.rows ?? 24;\n\t\tconst maxInnerHeight = Math.max(5, Math.floor(termHeight * 0.8) - 2);\n\t\tconst innerWidth = Math.max(10, width - 4);\n\n\t\tlet title = \"\";\n\t\tconst contentLines: string[] = [];\n\n\t\tif (this.entry.kind === \"thinking\") {\n\t\t\tconst spin = this.entry.active ? thinkingSpinnerFrame() : undefined;\n\t\t\tconst icon = spin?.frame ?? \"\u2713\";\n\t\t\tconst tokenStr = thinkingTokenLabel(this.entry);\n\t\t\ttitle = `${fg(spin?.color ?? \"thinkingText\", icon)} ${fg(\"toolTitle\", \"Thinking\")} ${fg(\"muted\", tokenStr)}`;\n\n\t\t\tconst rawText = this.entry.text.trim();\n\t\t\tif (!rawText) {\n\t\t\t\tcontentLines.push(fg(\"dim\", \"(thinking...)\"));\n\t\t\t} else {\n\t\t\t\tfor (const rawLine of rawText.split(\"\\n\")) {\n\t\t\t\t\tconst wrapped = wrapTextWithAnsi(rawLine, innerWidth);\n\t\t\t\t\tif (wrapped.length === 0) {\n\t\t\t\t\t\tcontentLines.push(\"\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (const wl of wrapped) {\n\t\t\t\t\t\t\tcontentLines.push(fg(\"thinkingText\", wl));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst tool = this.entry.tool;\n\t\t\tconst st = toolStatus(tool);\n\t\t\tconst icon = st === \"pending\" ? frame : st === \"error\" ? \"\u2717\" : \"\u2713\";\n\t\t\tconst color = st === \"pending\" ? \"accent\" : st === \"error\" ? \"error\" : \"success\";\n\t\t\tconst elapsed = `(${toolElapsed(tool)}s)`;\n\t\t\ttitle = `${fg(color, icon)} ${fg(\"toolTitle\", bold(tool.toolName))} ${fg(\"muted\", elapsed)}`;\n\n\t\t\tif (tool.toolName === \"bash\" || tool.toolName === \"powershell\") {\n\t\t\t\tconst cmd = tool.args?.command || \"...\";\n\t\t\t\tfor (const wl of wrapTextWithAnsi(`$ ${cmd}`, innerWidth)) {\n\t\t\t\t\tcontentLines.push(fg(\"accent\", wl));\n\t\t\t\t}\n\t\t\t} else if (tool.args?.path) {\n\t\t\t\tcontentLines.push(`${fg(\"dim\", \"Path:\")} ${tool.args.path}`);\n\t\t\t} else if (tool.args) {\n\t\t\t\ttry {\n\t\t\t\t\tconst jsonStr = JSON.stringify(tool.args, null, 2);\n\t\t\t\t\tfor (const l of jsonStr.split(\"\\n\")) {\n\t\t\t\t\t\tfor (const wl of wrapTextWithAnsi(l, innerWidth)) {\n\t\t\t\t\t\t\tcontentLines.push(fg(\"dim\", wl));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\tcontentLines.push(fg(\"dim\", String(tool.args)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst resultText = toolResultText(tool);\n\t\t\tcontentLines.push(\"\");\n\t\t\tcontentLines.push(fg(\"dim\", \"\u2500\u2500 Output \u2500\u2500\"));\n\n\t\t\tif (resultText) {\n\t\t\t\tfor (const rawLine of resultText.split(\"\\n\")) {\n\t\t\t\t\tconst wrapped = wrapTextWithAnsi(rawLine, innerWidth);\n\t\t\t\t\tif (wrapped.length === 0) {\n\t\t\t\t\t\tcontentLines.push(\"\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (const wl of wrapped) {\n\t\t\t\t\t\t\tcontentLines.push(fg(\"toolOutput\", wl));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcontentLines.push(fg(\"dim\", st === \"pending\" ? \"(running, waiting for output...)\" : \"(no output)\"));\n\t\t\t}\n\t\t}\n\n\t\tconst totalLines = contentLines.length;\n\t\tconst innerHeight = Math.min(Math.max(totalLines, 5), maxInnerHeight);\n\t\tthis.lastContentLineCount = totalLines;\n\t\tthis.lastInnerHeight = innerHeight;\n\t\tconst maxScroll = Math.max(0, totalLines - innerHeight);\n\n\t\tif (this.followingEnd) {\n\t\t\tthis.scrollTop = maxScroll;\n\t\t} else {\n\t\t\tthis.scrollTop = Math.max(0, Math.min(maxScroll, this.scrollTop));\n\t\t}\n\n\t\t// Top border with close button hint\n\t\tconst closeHint = \"[Esc to close]\";\n\t\tconst visClose = visibleWidth(closeHint);\n\t\tconst maxTitleWidth = Math.max(10, width - visClose - 12);\n\t\tconst clampedTitle = truncateToWidth(title, maxTitleWidth, \"...\");\n\t\tconst visTitle = visibleWidth(clampedTitle);\n\t\tconst fillerLen = Math.max(1, width - visTitle - visClose - 8);\n\t\tconst topBorder =\n\t\t\tborderFg(\"\u250C\u2500 \") +\n\t\t\tclampedTitle +\n\t\t\tborderFg(\" \" + \"\u2500\".repeat(fillerLen) + \" \") +\n\t\t\tfg(\"muted\", closeHint) +\n\t\t\tborderFg(\" \u2500\u2510\");\n\n\t\tconst result: string[] = [truncateToWidth(topBorder, width)];\n\n\t\t// Middle content lines\n\t\tconst slice = contentLines.slice(this.scrollTop, this.scrollTop + innerHeight);\n\t\twhile (slice.length < innerHeight) {\n\t\t\tslice.push(\"\");\n\t\t}\n\n\t\tconst showScrollbar = totalLines > innerHeight;\n\t\tconst thumbY = showScrollbar && maxScroll > 0 ? Math.round((this.scrollTop / maxScroll) * (innerHeight - 1)) : -1;\n\n\t\tfor (let i = 0; i < innerHeight; i++) {\n\t\t\tconst line = slice[i] ?? \"\";\n\t\t\tconst vis = visibleWidth(line);\n\t\t\tconst truncated = vis > innerWidth ? truncateToWidth(line, innerWidth, \"...\") : line;\n\t\t\tconst truncVis = visibleWidth(truncated);\n\t\t\tconst pad = Math.max(0, innerWidth - truncVis);\n\t\t\tconst rightChar = showScrollbar && i === thumbY ? fg(\"scrollbarThumb\", \"\u2588\") : borderFg(\"\u2502\");\n\t\t\tresult.push(borderFg(\"\u2502 \") + truncated + \" \".repeat(pad) + \" \" + rightChar);\n\t\t}\n\n\t\t// Bottom border\n\t\tconst scrollInfo =\n\t\t\ttotalLines > innerHeight\n\t\t\t\t? ` [${this.scrollTop + 1}-${Math.min(totalLines, this.scrollTop + innerHeight)}/${totalLines}] `\n\t\t\t\t: \"\";\n\t\tconst visInfo = visibleWidth(scrollInfo);\n\t\tconst botFiller = Math.max(1, width - 2 - visInfo);\n\t\tconst botBorder =\n\t\t\tborderFg(\"\u2514\" + \"\u2500\".repeat(botFiller)) + (scrollInfo ? fg(\"dim\", scrollInfo) : \"\") + borderFg(\"\u2518\");\n\t\tresult.push(truncateToWidth(botBorder, width));\n\n\t\treturn result;\n\t}\n}\n\nexport function openDetailModal(entry: GroupEntry): void {\n\tcloseDetailModal();\n\n\tconst modal = new DetailModalComponent(entry);\n\truntime.activeModalComponent = modal;\n\n\tif (runtime.capturedTui) {\n\t\truntime.activeModalHandle = runtime.capturedTui.showOverlay(modal, {\n\t\t\tanchor: \"center\",\n\t\t\twidth: \"85%\",\n\t\t\tmaxHeight: \"80%\",\n\t\t});\n\t\truntime.capturedTui.requestRender();\n\t\treturn;\n\t}\n\n\tif (runtime.activeUIContext?.custom) {\n\t\truntime.activeUIContext.custom(\n\t\t\t(tui: any, _theme: any, _keybindings: any, done: () => void) => {\n\t\t\t\truntime.capturedTui = tui;\n\t\t\t\truntime.activeModalCloseFn = done;\n\t\t\t\treturn modal;\n\t\t\t},\n\t\t\t{\n\t\t\t\toverlay: true,\n\t\t\t\toverlayOptions: { anchor: \"center\", width: \"85%\", maxHeight: \"80%\" },\n\t\t\t\tonHandle: (handle: any) => {\n\t\t\t\t\truntime.activeModalHandle = handle;\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n}\n\nexport function closeDetailModal(): void {\n\tif (runtime.activeModalComponent) {\n\t\truntime.activeModalComponent.dispose();\n\t\truntime.activeModalComponent = null;\n\t}\n\tif (runtime.activeModalHandle) {\n\t\tconst handle = runtime.activeModalHandle;\n\t\truntime.activeModalHandle = null;\n\t\thandle.hide();\n\t}\n\tif (runtime.activeModalCloseFn) {\n\t\tconst done = runtime.activeModalCloseFn;\n\t\truntime.activeModalCloseFn = null;\n\t\tdone();\n\t}\n\truntime.capturedTui?.requestRender?.();\n}\n\nexport function getAllInspectableEntries(): GroupEntry[] {\n\tconst results: GroupEntry[] = [];\n\tfor (const g of runtime.groups) {\n\t\tfor (const entry of g.getVisibleEntries()) {\n\t\t\tresults.push(entry);\n\t\t}\n\t}\n\treturn results;\n}\n\nexport class InspectSelectorModal implements Component {\n\tprivate entries: GroupEntry[] = [];\n\tprivate selectedIndex = 0;\n\tprivate scrollTop = 0;\n\tprivate visibleHeight = 10;\n\n\tconstructor() {\n\t\tthis.refreshEntries(true);\n\t}\n\n\trefreshEntries(isInitial = false): void {\n\t\tconst wasAtEnd = isInitial || this.selectedIndex >= this.entries.length - 1;\n\t\tthis.entries = getAllInspectableEntries();\n\t\tif (this.entries.length === 0) {\n\t\t\tthis.selectedIndex = 0;\n\t\t\tthis.scrollTop = 0;\n\t\t\treturn;\n\t\t}\n\t\tif (wasAtEnd) {\n\t\t\t// Place newest entries at the bottom; focus starts on the latest (last) entry\n\t\t\tthis.selectedIndex = this.entries.length - 1;\n\t\t} else {\n\t\t\tthis.selectedIndex = Math.max(0, Math.min(this.selectedIndex, this.entries.length - 1));\n\t\t}\n\t\tthis.adjustScroll();\n\t}\n\n\tprivate adjustScroll(): void {\n\t\tif (this.entries.length === 0) {\n\t\t\tthis.scrollTop = 0;\n\t\t\treturn;\n\t\t}\n\t\tif (this.selectedIndex < this.scrollTop) {\n\t\t\tthis.scrollTop = this.selectedIndex;\n\t\t} else if (this.selectedIndex >= this.scrollTop + this.visibleHeight) {\n\t\t\tthis.scrollTop = this.selectedIndex - this.visibleHeight + 1;\n\t\t}\n\t\tconst maxScroll = Math.max(0, this.entries.length - this.visibleHeight);\n\t\tthis.scrollTop = Math.max(0, Math.min(this.scrollTop, maxScroll));\n\t}\n\n\thandleInput(data: string): boolean {\n\t\tif (matchesKey(data, Key.escape) || data === \"q\" || data === \"Q\") {\n\t\t\tcloseInspectSelectorModal();\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.enter) || data === \"\\r\" || data === \"\\n\") {\n\t\t\tconst selected = this.entries[this.selectedIndex];\n\t\t\tif (selected) {\n\t\t\t\topenDetailModal(selected);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.up) || data === \"k\" || data === \"K\") {\n\t\t\tif (this.entries.length > 0) {\n\t\t\t\tthis.selectedIndex = Math.max(0, this.selectedIndex - 1);\n\t\t\t\tthis.adjustScroll();\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.down) || data === \"j\" || data === \"J\") {\n\t\t\tif (this.entries.length > 0) {\n\t\t\t\tthis.selectedIndex = Math.min(this.entries.length - 1, this.selectedIndex + 1);\n\t\t\t\tthis.adjustScroll();\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.pageUp)) {\n\t\t\tif (this.entries.length > 0) {\n\t\t\t\tthis.selectedIndex = Math.max(0, this.selectedIndex - this.visibleHeight);\n\t\t\t\tthis.adjustScroll();\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.pageDown)) {\n\t\t\tif (this.entries.length > 0) {\n\t\t\t\tthis.selectedIndex = Math.min(this.entries.length - 1, this.selectedIndex + this.visibleHeight);\n\t\t\t\tthis.adjustScroll();\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.home)) {\n\t\t\tif (this.entries.length > 0) {\n\t\t\t\tthis.selectedIndex = 0;\n\t\t\t\tthis.adjustScroll();\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, Key.end)) {\n\t\t\tif (this.entries.length > 0) {\n\t\t\t\tthis.selectedIndex = this.entries.length - 1;\n\t\t\t\tthis.adjustScroll();\n\t\t\t\truntime.capturedTui?.requestRender?.();\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst theme = runtime.currentTheme;\n\t\tconst fg = (color: string, t: string) => theme?.fg?.(color, t) ?? t;\n\t\tconst bold = theme?.bold ? theme.bold : (t: string) => t;\n\t\tconst borderFg = (t: string) => fg(\"borderAccent\", fg(\"border\", t));\n\t\tconst frame = SPINNER[Math.floor((Date.now() - spinnerStart) / SPINNER_MS) % SPINNER.length]!;\n\n\t\tconst termHeight = runtime.capturedTui?.terminal?.rows ?? process.stdout?.rows ?? 24;\n\t\tconst maxInnerHeight = Math.max(5, Math.floor(termHeight * 0.7) - 2);\n\t\tconst innerHeight = this.entries.length === 0\n\t\t\t? 5\n\t\t\t: Math.min(this.entries.length, maxInnerHeight);\n\t\tthis.visibleHeight = innerHeight;\n\t\tthis.adjustScroll();\n\n\t\tconst innerWidth = Math.max(10, width - 4);\n\t\tconst lines: string[] = [];\n\n\t\tconst title = ` ${fg(\"accent\", bold(\"Inspect\"))} ${fg(\"dim\", \"(\u2191/\u2193 select \u00B7 Enter view \u00B7 Esc exit)\")} `;\n\t\tconst visTitle = visibleWidth(title);\n\t\tconst topFiller = Math.max(1, width - 2 - visTitle);\n\t\tconst topBorder = borderFg(\"\u250C\" + \"\u2500\".repeat(topFiller)) + title + borderFg(\"\u2510\");\n\t\tlines.push(truncateToWidth(topBorder, width));\n\n\t\tif (this.entries.length === 0) {\n\t\t\tconst emptyMsg = \" (no tool calls or thinking entries)\";\n\t\t\tfor (let i = 0; i < innerHeight; i++) {\n\t\t\t\tconst row = i === Math.floor(innerHeight / 2) ? fg(\"dim\", emptyMsg) : \"\";\n\t\t\t\tconst pad = Math.max(0, innerWidth - visibleWidth(row));\n\t\t\t\tlines.push(borderFg(\"\u2502 \") + row + \" \".repeat(pad) + borderFg(\" \u2502\"));\n\t\t\t}\n\t\t} else {\n\t\t\tfor (let i = 0; i < innerHeight; i++) {\n\t\t\t\tconst entryIdx = this.scrollTop + i;\n\t\t\t\tconst entry = this.entries[entryIdx];\n\t\t\t\tif (!entry) {\n\t\t\t\t\tlines.push(borderFg(\"\u2502 \") + \" \".repeat(innerWidth) + borderFg(\" \u2502\"));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst isSelected = entryIdx === this.selectedIndex;\n\t\t\t\tconst prefix = isSelected ? fg(\"accent\", bold(\"\u25B6 \")) : \" \";\n\n\t\t\t\tlet leftContent = \"\";\n\t\t\t\tlet rightStr = \"\";\n\n\t\t\t\tif (entry.kind === \"tool\") {\n\t\t\t\t\tconst tool = entry.tool;\n\t\t\t\t\tconst st = toolStatus(tool);\n\t\t\t\t\tconst icon = st === \"pending\" ? frame : st === \"error\" ? \"\u2717\" : \"\u2713\";\n\t\t\t\t\tconst iconColor = st === \"pending\" ? \"accent\" : st === \"error\" ? \"error\" : \"success\";\n\t\t\t\t\tconst s = toolSummary(tool.toolName, tool.args);\n\t\t\t\t\tconst elapsed = `(${toolElapsed(tool)}s)`;\n\t\t\t\t\tconst toolLabel = fg(\"toolTitle\", bold(s.name));\n\t\t\t\t\tconst contentText = fg(\"dim\", s.content || \"...\");\n\t\t\t\t\tleftContent = `${prefix}${fg(iconColor, icon)} ${toolLabel} ${contentText}`;\n\t\t\t\t\trightStr = fg(\"muted\", elapsed);\n\t\t\t\t} else {\n\t\t\t\t\tconst spin = entry.active ? thinkingSpinnerFrame() : undefined;\n\t\t\t\t\tconst icon = spin?.frame ?? \"\u2713\";\n\t\t\t\t\tconst tokenLabel = thinkingTokenLabel(entry);\n\t\t\t\t\tconst tText = entry.text.trim().replace(/[*_#`>]+/g, \"\").replace(/\\s+/g, \" \");\n\t\t\t\t\tconst thinkingLabel = fg(\"toolTitle\", \"thinking\");\n\t\t\t\t\tconst contentText = fg(\"thinkingText\", tText || \"(thinking...)\");\n\t\t\t\t\tleftContent = `${prefix}${fg(spin?.color ?? \"thinkingText\", icon)} ${thinkingLabel} ${contentText}`;\n\t\t\t\t\trightStr = fg(\"muted\", tokenLabel);\n\t\t\t\t}\n\n\t\t\t\tconst maxLeft = Math.max(1, innerWidth - visibleWidth(rightStr) - 1);\n\t\t\t\tconst ellipsis = entry.kind === \"thinking\" ? fg(\"thinkingText\", \"...\") : fg(\"dim\", \"...\");\n\t\t\t\tconst leftTrunc = truncateToWidth(leftContent, maxLeft, ellipsis);\n\t\t\t\tconst gap = Math.max(1, innerWidth - visibleWidth(leftTrunc) - visibleWidth(rightStr));\n\t\t\t\tlet rowLine = `${leftTrunc}${\" \".repeat(gap)}${rightStr}`;\n\n\t\t\t\tconst rowVis = visibleWidth(rowLine);\n\t\t\t\tif (rowVis < innerWidth) {\n\t\t\t\t\trowLine += \" \".repeat(innerWidth - rowVis);\n\t\t\t\t} else if (rowVis > innerWidth) {\n\t\t\t\t\trowLine = truncateToWidth(rowLine, innerWidth);\n\t\t\t\t}\n\n\t\t\t\tif (isSelected) {\n\t\t\t\t\tif (theme?.bg) {\n\t\t\t\t\t\trowLine = theme.bg(\"selectedBg\", rowLine);\n\t\t\t\t\t} else if (theme?.inverse) {\n\t\t\t\t\t\trowLine = theme.inverse(rowLine);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines.push(borderFg(\"\u2502 \") + rowLine + borderFg(\" \u2502\"));\n\t\t\t}\n\t\t}\n\n\t\tconst countInfo =\n\t\t\tthis.entries.length > 0\n\t\t\t\t? ` [${this.selectedIndex + 1}/${this.entries.length}] `\n\t\t\t\t: \"\";\n\t\tconst visCount = visibleWidth(countInfo);\n\t\tconst botFiller = Math.max(1, width - 2 - visCount);\n\t\tconst botBorder =\n\t\t\tborderFg(\"\u2514\" + \"\u2500\".repeat(botFiller)) + (countInfo ? fg(\"dim\", countInfo) : \"\") + borderFg(\"\u2518\");\n\t\tlines.push(truncateToWidth(botBorder, width));\n\n\t\treturn lines;\n\t}\n\n\tdispose(): void {}\n\tinvalidate(): void {}\n}\n\nexport function openInspectSelectorModal(): void {\n\tif (runtime.activeModalHandle) {\n\t\tcloseDetailModal();\n\t}\n\tcloseInspectSelectorModal();\n\n\tconst modal = new InspectSelectorModal();\n\truntime.activeSelectorComponent = modal;\n\n\tif (runtime.capturedTui) {\n\t\truntime.activeSelectorHandle = runtime.capturedTui.showOverlay(modal, {\n\t\t\tanchor: \"center\",\n\t\t\twidth: \"85%\",\n\t\t\tmaxHeight: \"70%\",\n\t\t});\n\t\truntime.capturedTui.requestRender();\n\t\treturn;\n\t}\n\n\tif (runtime.activeUIContext?.custom) {\n\t\truntime.activeUIContext.custom(\n\t\t\t(tui: any, _theme: any, _keybindings: any, done: () => void) => {\n\t\t\t\truntime.capturedTui = tui;\n\t\t\t\truntime.activeSelectorCloseFn = done;\n\t\t\t\treturn modal;\n\t\t\t},\n\t\t\t{\n\t\t\t\toverlay: true,\n\t\t\t\toverlayOptions: { anchor: \"center\", width: \"85%\", maxHeight: \"70%\" },\n\t\t\t\tonHandle: (handle: any) => {\n\t\t\t\t\truntime.activeSelectorHandle = handle;\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n}\n\nexport function closeInspectSelectorModal(): void {\n\tif (runtime.activeSelectorHandle) {\n\t\tconst handle = runtime.activeSelectorHandle;\n\t\truntime.activeSelectorHandle = null;\n\t\thandle.hide();\n\t}\n\tif (runtime.activeSelectorCloseFn) {\n\t\tconst done = runtime.activeSelectorCloseFn;\n\t\truntime.activeSelectorCloseFn = null;\n\t\tdone();\n\t}\n\tif (runtime.activeSelectorComponent) {\n\t\truntime.activeSelectorComponent = null;\n\t}\n\truntime.capturedTui?.requestRender?.();\n}\n", "/** Pi \u547D\u4EE4\u4E0E\u4E8B\u4EF6\u63A5\u5165\uFF1B\u5448\u73B0\u903B\u8F91\u59D4\u6258\u7ED9\u5404\u804C\u8D23\u6A21\u5757\u3002 */\nimport type { ExtensionAPI } from \"@earendil-works/pi-coding-agent\";\nimport { installGrouping, ensureThinkingGroup, flushPendingTextSeal } from \"./grouping.js\";\nimport { installNativeThinkingSuppression, removeGroupFromContainer, insertTurnDivider } from \"./assistant-patches.js\";\nimport { installCompactionSummaryRendering } from \"./compaction.js\";\nimport { openInspectSelectorModal, closeDetailModal, closeInspectSelectorModal } from \"./modals.js\";\nimport { runtime } from \"./state.js\";\nimport { isKeyRelease, matchesKey, Key } from \"@earendil-works/pi-tui\";\nimport { isCtrlI } from \"./helpers.js\";\nimport { rememberToolStart, clearPreparingTools, noteStreamingToolCall, loadSessionToolTimings } from \"./streaming-tools.js\";\nimport { finalizeActiveThinking, createThinkingEntry, updateActiveThinkingTokens, refreshSealedThinkingTokens } from \"./thinking.js\";\nimport { registerConfigCommand } from \"./settings.js\";\n\nexport default function (pi: ExtensionAPI) {\n\tinstallGrouping();\n\tinstallNativeThinkingSuppression();\n\tinstallCompactionSummaryRendering();\n\n\t// Do not use pi.registerShortcut(\"ctrl+i\") directly because pi's internal\n\t// matchesKey treats \"\\t\" as \"ctrl+i\", which breaks regular Tab completion.\n\t// Instead, recognize Ctrl+I under extended protocols via onTerminalInput + isCtrlI.\n\n\tpi.registerCommand(\"compact-inspect\", {\n\t\tdescription: \"Select a tool call or thinking entry to inspect details (Shortcut: Ctrl+I)\",\n\t\thandler: async () => {\n\t\t\topenInspectSelectorModal();\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\truntime.currentTheme = ctx.ui.theme;\n\t\truntime.activeUIContext = ctx.ui;\n\t\tctx.ui.setHiddenThinkingLabel(\"\");\n\n\t\tctx.ui.onTerminalInput((data: string) => {\n\t\t\tif (isKeyRelease(data)) {\n\t\t\t\treturn runtime.activeModalHandle || runtime.activeSelectorHandle ? { consume: true } : undefined;\n\t\t\t}\n\n\t\t\tif (runtime.activeModalHandle) {\n\t\t\t\tif (matchesKey(data, Key.escape) || data === \"q\" || data === \"Q\" || isCtrlI(data)) {\n\t\t\t\t\tcloseDetailModal();\n\t\t\t\t\treturn { consume: true };\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tif (runtime.activeSelectorHandle) {\n\t\t\t\tif (matchesKey(data, Key.escape) || data === \"q\" || data === \"Q\" || isCtrlI(data)) {\n\t\t\t\t\tcloseInspectSelectorModal();\n\t\t\t\t\treturn { consume: true };\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tif (isCtrlI(data)) {\n\t\t\t\topenInspectSelectorModal();\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t});\n\n\t\t// Capture the TUI instance via setWidget's factory so the animation can\n\t\t// call its throttled requestRender() to repaint just the changed cells.\n\t\tctx.ui.setWidget(\"compact-anim\", (tui: any) => {\n\t\t\truntime.capturedTui = tui;\n\t\t\treturn { render: () => [] as string[], invalidate() {} };\n\t\t});\n\t\tinstallGrouping();\n\t\tinstallNativeThinkingSuppression();\n\t\tinstallCompactionSummaryRendering();\n\n\t\tif ((ctx as any)?.sessionManager?.getEntries) {\n\t\t\tloadSessionToolTimings((ctx as any).sessionManager.getEntries());\n\t\t}\n\n\t\t// Replaying history builds groups that belong to finished past turns.\n\t\t// Seal them once history replay finishes so they do not animate or tick.\n\t\tqueueMicrotask(() => {\n\t\t\tfor (const g of runtime.groups) {\n\t\t\t\tg.sealed = true;\n\t\t\t\tfor (const t of g.children as any[]) {\n\t\t\t\t\tif (t.result && t._groupEndAt === undefined) {\n\t\t\t\t\t\tt._groupEndAt = Date.now();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tg.invalidate();\n\t\t\t}\n\t\t\truntime.lastActiveGroup = null;\n\t\t\tif (runtime.animTimer) {\n\t\t\t\tclearTimeout(runtime.animTimer);\n\t\t\t\truntime.animTimer = null;\n\t\t\t}\n\t\t\truntime.capturedTui?.requestRender?.();\n\t\t});\n\t});\n\n\tpi.on(\"session_shutdown\", async () => {\n\t\tcloseDetailModal();\n\t\tcloseInspectSelectorModal();\n\t});\n\n\tpi.on(\"tool_execution_start\", async (event) => {\n\t\t// Keep the timestamp captured when arguments started streaming.\n\t\trememberToolStart(event.toolCallId);\n\t\truntime.lastActiveGroup?.invalidate();\n\t\truntime.activeSelectorComponent?.refreshEntries();\n\t\truntime.capturedTui?.requestRender?.();\n\t});\n\n\tpi.on(\"tool_execution_end\", async (event) => {\n\t\tconst end = Date.now();\n\t\tconst start = runtime.toolStarts.get(event.toolCallId);\n\t\tif (start !== undefined && !runtime.toolDurations.has(event.toolCallId)) {\n\t\t\truntime.toolDurations.set(event.toolCallId, Math.max(0, (end - start) / 1000));\n\t\t}\n\t\tfor (const g of runtime.groups) {\n\t\t\tfor (const t of g.children as any[]) {\n\t\t\t\tif (t.toolCallId === event.toolCallId) t._groupEndAt = end;\n\t\t\t}\n\t\t}\n\t\truntime.lastActiveGroup?.invalidate();\n\t\truntime.activeSelectorComponent?.refreshEntries();\n\t\truntime.capturedTui?.requestRender?.();\n\t});\n\n\tpi.on(\"message_start\", async (event) => {\n\t\tconst role = (event.message as any)?.role;\n\t\t// A new user message is a hard turn boundary: seal whatever block is still\n\t\t// open. Assistant/toolResult message boundaries do NOT seal \u2014 thinking and\n\t\t// tool calls stay in one block until real (non-thinking) text appears.\n\t\tif (role === \"user\" && runtime.lastActiveGroup && !runtime.lastActiveGroup.sealed) {\n\t\t\truntime.lastActiveGroup.sealed = true;\n\t\t\tfinalizeActiveThinking();\n\t\t\truntime.lastActiveGroup.invalidate();\n\t\t}\n\t\tif (role === \"user\") {\n\t\t\tfor (const g of [...runtime.groups]) {\n\t\t\t\tif (!g.hasVisibleEntries()) {\n\t\t\t\t\tif (runtime.lastChatContainer) removeGroupFromContainer(runtime.lastChatContainer, g);\n\t\t\t\t\truntime.groups.delete(g);\n\t\t\t\t}\n\t\t\t}\n\t\t\truntime.turnStartMs = Date.now();\n\t\t\truntime.activeThinking = null;\n\t\t\truntime.activeThinkingIndex = null;\n\t\t\truntime.activeThinkingBlocks.clear();\n\t\t\truntime.unattachedThinking.length = 0;\n\t\t\tclearPreparingTools();\n\t\t\truntime.lastSealedThinkingEntry = null;\n\t\t\truntime.lastReportedReasoningTokens = 0;\n\t\t\truntime.handledTextIndexes.clear();\n\t\t\truntime.sealedThinkingIndexes.clear();\n\t\t\truntime.pendingTextSeal = false;\n\t\t\truntime.pendingTextOrdinal = null;\n\t\t\truntime.lastStreamingComp = null;\n\t\t} else if (role === \"assistant\") {\n\t\t\t// contentIndex values are local to one streamed assistant message. Close\n\t\t\t// any run left open by the previous message; a late thinking_end for it is\n\t\t\t// then rejected through sealedThinkingIndexes.\n\t\t\tfinalizeActiveThinking();\n\t\t\truntime.handledTextIndexes.clear();\n\t\t\truntime.sealedThinkingIndexes.clear();\n\t\t\t// Reported reasoning usage belongs to one assistant message; a run sealed\n\t\t\t// later must not inherit the previous message's value.\n\t\t\truntime.lastSealedThinkingEntry = null;\n\t\t\truntime.lastReportedReasoningTokens = 0;\n\t\t\truntime.pendingTextSeal = false;\n\t\t\truntime.pendingTextOrdinal = null;\n\t\t\t// Do not insert early thinking beside the previous assistant message.\n\t\t\t// The addChild patch fills this with the current streaming component.\n\t\t\truntime.lastStreamingComp = null;\n\t\t}\n\t});\n\n\tpi.on(\"message_update\", async (event) => {\n\t\tconst msg = event.message as any;\n\t\tif (!msg || msg.role !== \"assistant\") return;\n\t\tconst content = Array.isArray(msg.content) ? msg.content : [];\n\t\tconst streamEvent = event.assistantMessageEvent as any;\n\t\tconst streamType = String(streamEvent?.type ?? \"\");\n\n\t\tif (streamType.startsWith(\"thinking_\")) {\n\t\t\t// Only read the block targeted by this stream event. The surrounding\n\t\t\t// message is cumulative and may still contain thinking from before a\n\t\t\t// text boundary; scanning all content would resurrect that old block.\n\t\t\tconst contentIndex = Number(streamEvent.contentIndex);\n\t\t\tconst hasIndex = Number.isInteger(contentIndex);\n\t\t\t// A thinking_end re-emitted after a visible text boundary already sealed\n\t\t\t// this run must not create a second row for the same reasoning.\n\t\t\tif (hasIndex && runtime.sealedThinkingIndexes.has(contentIndex)) return;\n\t\t\tconst startsRun =\n\t\t\t\tstreamType === \"thinking_start\" || !runtime.activeThinking || (hasIndex && runtime.activeThinkingIndex !== contentIndex);\n\t\t\tif (startsRun) {\n\t\t\t\t// Each run is its own entry: close the previous one instead of merging.\n\t\t\t\tfinalizeActiveThinking();\n\t\t\t\truntime.activeThinkingIndex = hasIndex ? contentIndex : null;\n\t\t\t\tcreateThinkingEntry();\n\t\t\t}\n\t\t\tconst block = hasIndex ? content[contentIndex] : undefined;\n\t\t\tconst blockText =\n\t\t\t\tblock?.type === \"thinking\"\n\t\t\t\t\t? String(block.thinking ?? \"\")\n\t\t\t\t\t: streamType === \"thinking_end\"\n\t\t\t\t\t\t? String(streamEvent.content ?? \"\")\n\t\t\t\t\t\t: \"\";\n\t\t\tif (hasIndex) runtime.activeThinkingBlocks.set(contentIndex, blockText);\n\t\t\tupdateActiveThinkingTokens(msg);\n\t\t\t// Drop the row in as soon as the run starts \u2014 even before its first delta \u2014\n\t\t\t// so the spinner reports the in-progress state.\n\t\t\tensureThinkingGroup();\n\t\t\tif (streamType === \"thinking_end\") finalizeActiveThinking();\n\t\t} else if (streamType.startsWith(\"text_\")) {\n\t\t\tconst contentIndex = Number(streamEvent.contentIndex);\n\t\t\tconst block = Number.isInteger(contentIndex) ? content[contentIndex] : undefined;\n\t\t\tconst text = block?.type === \"text\" ? String(block.text ?? \"\").trim() : \"\";\n\t\t\t// The first non-whitespace text is a boundary. Deduplicate by content\n\t\t\t// index so every later cumulative delta extends the same text block.\n\t\t\tif (text.length > 0 && !runtime.handledTextIndexes.has(contentIndex)) {\n\t\t\t\tif (runtime.activeThinking) updateActiveThinkingTokens(msg);\n\t\t\t\truntime.handledTextIndexes.add(contentIndex);\n\t\t\t\truntime.pendingTextSeal = true;\n\t\t\t\truntime.pendingTextOrdinal =\n\t\t\t\t\tcontent\n\t\t\t\t\t\t.slice(0, Number.isInteger(contentIndex) ? contentIndex + 1 : content.length)\n\t\t\t\t\t\t.filter((item: any) => item?.type === \"text\" && String(item.text ?? \"\").trim()).length - 1;\n\t\t\t\tflushPendingTextSeal();\n\t\t\t}\n\t\t} else if (streamType.startsWith(\"toolcall_\")) {\n\t\t\t// Arguments are still streaming. Show the busy row before execution starts.\n\t\t\tif (runtime.activeThinking) updateActiveThinkingTokens(msg);\n\t\t\tnoteStreamingToolCall(content, streamEvent);\n\t\t} else if (streamType === \"done\" || streamType === \"error\") {\n\t\t\tif (runtime.activeThinking) updateActiveThinkingTokens(msg);\n\t\t\tfinalizeActiveThinking();\n\t\t\trefreshSealedThinkingTokens(msg?.usage?.reasoning);\n\t\t}\n\n\t\t// Refresh the active block when thinking starts/stops (event-driven only;\n\t\t// no timer, so the transcript scroll position is never yanked around).\n\t\truntime.lastActiveGroup?.invalidate();\n\t\truntime.activeSelectorComponent?.refreshEntries();\n\t\truntime.capturedTui?.requestRender?.();\n\t});\n\n\tpi.on(\"agent_end\", async () => {\n\t\t// Turn finished: seal the final block so it stops spinning and shows a\n\t\t// stable summary until the user starts the next turn.\n\t\tclearPreparingTools();\n\t\tif (runtime.lastActiveGroup && !runtime.lastActiveGroup.sealed) {\n\t\t\truntime.lastActiveGroup.sealed = true;\n\t\t\tfinalizeActiveThinking();\n\t\t\truntime.lastActiveGroup.invalidate();\n\t\t}\n\t\tfor (const g of [...runtime.groups]) {\n\t\t\tif (!g.hasVisibleEntries()) {\n\t\t\t\tif (runtime.lastChatContainer) removeGroupFromContainer(runtime.lastChatContainer, g);\n\t\t\t\truntime.groups.delete(g);\n\t\t\t}\n\t\t}\n\t\trefreshSealedThinkingTokens();\n\t\truntime.activeSelectorComponent?.refreshEntries();\n\t\truntime.capturedTui?.requestRender?.();\n\t\t// Separate the final visible text from the preceding work with a divider\n\t\t// that reports how long this turn ran.\n\t\tconst elapsedMs = Date.now() - runtime.turnStartMs;\n\t\tinsertTurnDivider(elapsedMs);\n\t\truntime.activeThinking = null;\n\t\truntime.activeThinkingIndex = null;\n\t\truntime.activeThinkingBlocks.clear();\n\t\truntime.unattachedThinking.length = 0;\n\t\truntime.lastSealedThinkingEntry = null;\n\t\truntime.lastReportedReasoningTokens = 0;\n\t\truntime.handledTextIndexes.clear();\n\t\truntime.sealedThinkingIndexes.clear();\n\t\truntime.pendingTextSeal = false;\n\t\truntime.pendingTextOrdinal = null;\n\t});\n\n\tregisterConfigCommand(pi);\n}\n", "/** \u914D\u7F6E\u4EA4\u4E92\u754C\u9762\u4E0E\u6570\u503C\u7F16\u8F91\u5668\u3002 */\nimport type { ExtensionAPI } from \"@earendil-works/pi-coding-agent\";\nimport { getSettingsListTheme } from \"@earendil-works/pi-coding-agent\";\nimport { Key, SettingsList, matchesKey, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { Component, SettingItem } from \"@earendil-works/pi-tui\";\nimport { config, saveConfig } from \"./config.js\";\nimport { runtime } from \"./state.js\";\n\nexport const CONFIG_KEYS = [\n\t{\n\t\tid: \"expandedToolLines\",\n\t\tlabel: \"Expanded tool lines\",\n\t\tdescription: \"Result lines shown per tool when expanded\",\n\t\tmin: 1,\n\t\tmax: 50,\n\t\tstep: 1,\n\t},\n\t{\n\t\tid: \"expandedThinkingLines\",\n\t\tlabel: \"Expanded thinking lines\",\n\t\tdescription: \"Thinking lines shown when expanded\",\n\t\tmin: 1,\n\t\tmax: 100,\n\t\tstep: 1,\n\t},\n\t{\n\t\tid: \"maxGroupEntries\",\n\t\tlabel: \"Max collapsed entries\",\n\t\tdescription: \"Maximum entries shown in collapsed group\",\n\t\tmin: 1,\n\t\tmax: 30,\n\t\tstep: 1,\n\t},\n] as const;\n\nexport function makeStepper(\n\ttitle: string,\n\tinitial: number,\n\tmeta: { min: number; max: number; step: number },\n\ttheme: any,\n\tdone: (value?: string) => void,\n): Component {\n\tlet value = initial;\n\tlet cachedWidth: number | undefined;\n\tlet cachedLines: string[] | undefined;\n\tconst fg = (color: string, t: string) => theme?.fg?.(color, t) ?? t;\n\n\treturn {\n\t\trender(width: number): string[] {\n\t\t\tif (cachedLines && cachedWidth === width) return cachedLines;\n\t\t\tconst barLen = Math.max(1, Math.min(width - 10, 40));\n\t\t\tconst ratio = (value - meta.min) / Math.max(1, meta.max - meta.min);\n\t\t\tconst filled = Math.round(ratio * barLen);\n\t\t\tconst bar = \"\u2588\".repeat(filled) + \"\u2591\".repeat(Math.max(0, barLen - filled));\n\t\t\tconst titleText = theme?.bold ? theme.bold(title) : title;\n\t\t\tcachedLines = [\n\t\t\t\tfg(\"accent\", titleText),\n\t\t\t\t\"\",\n\t\t\t\t` ${fg(\"accent\", String(value))}`,\n\t\t\t\t` ${fg(\"muted\", bar)}`,\n\t\t\t\t\"\",\n\t\t\t\tfg(\"dim\", \" \u25C0 \u25B6 / \u2212 + adjust Enter save Esc cancel\"),\n\t\t\t].map((line) => truncateToWidth(line, Math.max(1, width)));\n\t\t\tcachedWidth = width;\n\t\t\treturn cachedLines;\n\t\t},\n\t\thandleInput(data: string): void {\n\t\t\tif (matchesKey(data, Key.left) || matchesKey(data, Key.down) || data === \"-\" || data === \"_\") {\n\t\t\t\tvalue = Math.max(meta.min, value - meta.step);\n\t\t\t} else if (matchesKey(data, Key.right) || matchesKey(data, Key.up) || data === \"+\" || data === \"=\") {\n\t\t\t\tvalue = Math.min(meta.max, value + meta.step);\n\t\t\t} else if (matchesKey(data, Key.enter) || matchesKey(data, Key.space)) {\n\t\t\t\tdone(String(value));\n\t\t\t\treturn;\n\t\t\t} else if (matchesKey(data, Key.escape)) {\n\t\t\t\tdone(undefined);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcachedWidth = undefined;\n\t\t},\n\t\tinvalidate(): void {\n\t\t\tcachedWidth = undefined;\n\t\t},\n\t};\n}\n\nexport function registerConfigCommand(pi: ExtensionAPI): void {\n\tpi.registerCommand(\"compact-ui-config\", {\n\t\tdescription: \"Interactive compact-ui settings (arrows to select, Enter to adjust, Esc to close)\",\n\t\thandler: async (_args, ctx) => {\n\t\t\t// Non-TUI modes (print/json) can't show the interactive menu.\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`compact: expandedToolLines=${config.expandedToolLines}, expandedThinkingLines=${config.expandedThinkingLines}`,\n\t\t\t\t\t\"info\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst changed = await ctx.ui.custom<boolean>((tui, theme, _keybindings, done) => {\n\t\t\t\tlet anyChanged = false;\n\t\t\t\tconst items: SettingItem[] = CONFIG_KEYS.map((meta) => ({\n\t\t\t\t\tid: meta.id,\n\t\t\t\t\tlabel: meta.label,\n\t\t\t\t\tcurrentValue: String((config as any)[meta.id]),\n\t\t\t\t\tdescription: meta.description,\n\t\t\t\t\tsubmenu: (currentValue: string, subDone: (value?: string) => void) =>\n\t\t\t\t\t\tmakeStepper(meta.label, Number(currentValue), meta, theme, subDone),\n\t\t\t\t}));\n\t\t\t\tconst settingsList = new SettingsList(\n\t\t\t\t\titems,\n\t\t\t\t\tMath.min(items.length, 15),\n\t\t\t\t\tgetSettingsListTheme(),\n\t\t\t\t\t(id, newValue) => {\n\t\t\t\t\t\t// Persist and refresh the live groups when SettingsList commits a change.\n\t\t\t\t\t\t(config as any)[id] = Number(newValue);\n\t\t\t\t\t\tsaveConfig();\n\t\t\t\t\t\tanyChanged = true;\n\t\t\t\t\t\tfor (const g of runtime.groups) g.invalidate();\n\t\t\t\t\t},\n\t\t\t\t\t() => done(anyChanged),\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\trender(width: number) {\n\t\t\t\t\t\treturn settingsList.render(width);\n\t\t\t\t\t},\n\t\t\t\t\tinvalidate() {\n\t\t\t\t\t\tsettingsList.invalidate();\n\t\t\t\t\t},\n\t\t\t\t\thandleInput(data: string) {\n\t\t\t\t\t\tsettingsList.handleInput?.(data);\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\n\t\t\tif (changed) {\n\t\t\t\tctx.ui.notify(\"compact-ui settings saved\", \"info\");\n\t\t\t}\n\t\t},\n\t});\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,aAAAA,YAAW,UAAAC,SAAQ,YAAAC,WAAU,YAAY;AAClD,SAAS,6BAAAC,4BAA2B,8BAA8B;;;ACDlE,SAAS,WAAW,UAAU,gBAAAC,eAAc,mBAAAC,wBAAuB;;;ACyC5D,SAAS,qBAAmC;AAClD,SAAO;AAAA,IACN,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,qBAAqB;AAAA,IACrB,sBAAsB,oBAAI,IAAoB;AAAA,IAC9C,oBAAoB,CAAC;AAAA,IACrB,kBAAkB;AAAA,IAClB,oBAAoB,oBAAI,IAAY;AAAA,IACpC,uBAAuB,oBAAI,IAAY;AAAA,IACvC,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,6BAA6B;AAAA,IAC7B,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,YAAY,oBAAI,IAAoB;AAAA,IACpC,eAAe,oBAAI,IAAoB;AAAA,IACvC,aAAa;AAAA,IACb,kBAAkB,oBAAI,IAA2B;AAAA,IACjD,mBAAmB;AAAA,IACnB,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IAC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AACzB;",
|
|
6
|
+
"names": ["Container", "Spacer", "Markdown", "AssistantMessageComponent", "visibleWidth", "truncateToWidth", "truncateToWidth", "truncateToWidth", "start", "homedir", "visibleWidth", "truncateToWidth", "gap", "titleColor", "Container", "AssistantMessageComponent", "Spacer", "Markdown", "Container", "AssistantMessageComponent", "group", "Container", "AssistantMessageComponent", "visibleWidth", "truncateToWidth", "visibleWidth", "truncateToWidth", "matchesKey", "wrapTextWithAnsi", "visibleWidth", "truncateToWidth", "matchesKey", "wrapTextWithAnsi", "visibleWidth", "truncateToWidth", "isKeyRelease", "matchesKey", "Key", "Key", "matchesKey", "truncateToWidth", "truncateToWidth", "matchesKey", "Key", "isKeyRelease", "matchesKey", "Key"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AssistantContentState } from "./types.js";
|
|
2
|
+
import { ToolGroupComponent } from "./tool-group.js";
|
|
3
|
+
import type { Container, Markdown } from "@earendil-works/pi-tui";
|
|
4
|
+
import { AssistantMessageComponent } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
export declare function thinkingAlreadyShown(text: string): boolean;
|
|
6
|
+
export declare function stageHistoricalThinking(state: AssistantContentState, ordinal: number, texts: string[], message: any): void;
|
|
7
|
+
export declare function ensureHistoricalThinkingAnchors(contentContainer: Container, message: any): void;
|
|
8
|
+
export declare function installNativeThinkingSuppression(prototype?: any): void;
|
|
9
|
+
export declare function ensureAssistantThinkingPatched(component: any): boolean;
|
|
10
|
+
export declare function getAssistantContentState(container: Container): AssistantContentState;
|
|
11
|
+
export declare function removeGroupFromContainer(container: any, group: ToolGroupComponent): void;
|
|
12
|
+
export declare function noteGroupMount(container: any, group: ToolGroupComponent): void;
|
|
13
|
+
export declare function detachGroup(group: ToolGroupComponent, keep?: any): void;
|
|
14
|
+
export declare function removeComponentFromContainer(container: any, component: any): void;
|
|
15
|
+
export declare class TurnDividerComponent {
|
|
16
|
+
private readonly timeLabel;
|
|
17
|
+
constructor(timeLabel: string);
|
|
18
|
+
render(width: number): string[];
|
|
19
|
+
invalidate(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare function placeTurnDividerBeforeText(container: Container, target: Markdown, divider: any): void;
|
|
22
|
+
export declare function insertTurnDivider(elapsedMs: number): void;
|
|
23
|
+
export declare function isVisibleTextMarkdown(component: any): component is Markdown;
|
|
24
|
+
export declare function placeAnchoredGroupBeforeText(container: Container, target: Markdown, group: ToolGroupComponent): void;
|
|
25
|
+
export declare function insertAnchoredGroup(container: Container, ordinal: number, group: ToolGroupComponent): void;
|
|
26
|
+
export declare function installAssistantExpansion(component: AssistantMessageComponent, contentContainer: Container): void;
|
|
27
|
+
export declare function anchorGroupBeforeCurrentText(group: ToolGroupComponent, ordinal: number): void;
|
|
28
|
+
export declare function restoreAssistantAnchor(parent: any, component: any): void;
|
|
29
|
+
export declare function releaseAssistantAnchors(component: any): void;
|
|
30
|
+
export declare function stripAssistantPhantomPadding(parent: any, component: any): void;
|
|
31
|
+
export declare function isNativeThinkingWidget(component: any): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
+
export declare class CompactionHeaderComponent implements Component {
|
|
3
|
+
private readonly tokensBefore;
|
|
4
|
+
constructor(tokensBefore: number);
|
|
5
|
+
render(width: number): string[];
|
|
6
|
+
invalidate(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function installCompactionSummaryRendering(): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const CONFIG_PATH: string;
|
|
2
|
+
export declare const DEFAULT_CONFIG: {
|
|
3
|
+
expandedToolLines: number;
|
|
4
|
+
expandedThinkingLines: number;
|
|
5
|
+
maxGroupEntries: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const config: {
|
|
8
|
+
expandedToolLines: number;
|
|
9
|
+
expandedThinkingLines: number;
|
|
10
|
+
maxGroupEntries: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function saveConfig(values?: {
|
|
13
|
+
expandedToolLines: number;
|
|
14
|
+
expandedThinkingLines: number;
|
|
15
|
+
maxGroupEntries: number;
|
|
16
|
+
}, path?: string, write?: (path: string, data: string) => void): void;
|
|
17
|
+
/** Read configuration without coupling tests to the user's filesystem. */
|
|
18
|
+
export declare function loadConfig(path: string, read?: (path: string, encoding: 'utf-8') => string): typeof DEFAULT_CONFIG;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** 渲染常量与跨热重载稳定的补丁标记。 */
|
|
2
|
+
export declare const SPINNER: string[];
|
|
3
|
+
export declare const SPINNER_MS = 100;
|
|
4
|
+
export declare const THINKING_SPINNER: {
|
|
5
|
+
readonly rawFrames: readonly ["·", "•", "●", "•"];
|
|
6
|
+
readonly intervalMs: 140;
|
|
7
|
+
readonly colorKeys: readonly ["dim", "muted", "accent", "muted"];
|
|
8
|
+
};
|
|
9
|
+
export declare const GROUP_PADDING_X = 1;
|
|
10
|
+
export declare const GROUP_PADDING_RIGHT = 2;
|
|
11
|
+
export declare const spinnerStart: number;
|
|
12
|
+
export declare const PARENT_KEY: unique symbol;
|
|
13
|
+
export declare const PATCH_KEY: unique symbol;
|
|
14
|
+
export declare const MARKDOWN_RENDER_PATCH_KEY: unique symbol;
|
|
15
|
+
export declare const COMPACTION_STYLE_PATCH_KEY: unique symbol;
|
|
16
|
+
export declare const ASSISTANT_THINKING_PATCH_KEY: unique symbol;
|
|
17
|
+
export declare const IS_STREAMING_COMP: unique symbol;
|
|
18
|
+
export declare const GROUP_MOUNT: unique symbol;
|
|
19
|
+
export declare const TOOL_RENDER_PATCH_KEY: unique symbol;
|
|
20
|
+
export declare const LIVE_ASSISTANT_KEY: unique symbol;
|
|
21
|
+
export declare const CODE_BLOCK_PADDING_X = 1;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ToolGroupComponent } from "./tool-group.js";
|
|
2
|
+
export declare function isGroupable(value: any): boolean;
|
|
3
|
+
export declare function previousGroupable(children: any[], start: number): {
|
|
4
|
+
child: any;
|
|
5
|
+
index: number;
|
|
6
|
+
} | undefined;
|
|
7
|
+
export declare function assistantHasVisibleText(component: any): boolean;
|
|
8
|
+
export declare function absorbThinkingBeforeText(group: ToolGroupComponent, message: any): void;
|
|
9
|
+
export declare function sealOpenGroupAtAssistantText(assistant: any): void;
|
|
10
|
+
export declare function ensureThinkingGroup(): void;
|
|
11
|
+
export declare function flushPendingTextSeal(): void;
|
|
12
|
+
export declare function getPrecedingAssistantThinking(children: any[], beforeIndex: number): string[];
|
|
13
|
+
export declare function attachPrecedingThinkingToGroup(group: ToolGroupComponent, children: any[], beforeIndex: number): void;
|
|
14
|
+
export declare function joinOpenGroup(parent: any, index: number, component: any): boolean;
|
|
15
|
+
export declare function maybeGroup(parent: any, component: any): void;
|
|
16
|
+
export declare function installGrouping(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 兼容不同 Pi/TUI 模块实例的组件识别与原生工具渲染抑制。 */
|
|
2
|
+
import { Container, Spacer, Markdown, Text } from "@earendil-works/pi-tui";
|
|
3
|
+
import { AssistantMessageComponent, ToolExecutionComponent } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { ToolGroupComponent } from "./tool-group.js";
|
|
5
|
+
export declare function isContainer(val: any): val is Container;
|
|
6
|
+
export declare function isAssistantMessage(val: any): val is AssistantMessageComponent;
|
|
7
|
+
export declare function isToolExecution(val: any): val is ToolExecutionComponent;
|
|
8
|
+
export declare function isSpacer(val: any): val is Spacer;
|
|
9
|
+
export declare function isMarkdown(val: any): val is Markdown;
|
|
10
|
+
export declare function isText(val: any): val is Text;
|
|
11
|
+
export declare function isToolGroup(val: any): val is ToolGroupComponent;
|
|
12
|
+
export declare function hideGroupedToolRender(tool: any): void;
|