@caupulican/pi-adaptative 0.80.10 → 0.80.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +0 -2
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-title.d.ts +1 -1
- package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-title.js +28 -3
- package/dist/modes/interactive/components/tool-title.js.map +1 -1
- package/docs/tui.md +4 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.80.11] - 2026-06-07
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Made centralized TUI title badges use theme-balanced state colors for running, success, warning, persistent, failure, blocked, and muted states.
|
|
8
|
+
- Updated tool execution fallback labels to show status colors instead of forcing the neutral tool-title color.
|
|
9
|
+
|
|
3
10
|
## [0.80.8] - 2026-06-04
|
|
4
11
|
|
|
5
12
|
### Changed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAwC,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACx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AiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAazC;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKvC;IAED,OAAO,CAAC,aAAa;IAwGrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CAgB3B","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\nimport { renderTitleBadge, titleBadge } from \"./tool-title.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\ttoolGroup: string | undefined;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate resolveToolGroup(): string | undefined {\n\t\tconst configuredGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;\n\t\tif (configuredGroup !== undefined) {\n\t\t\tconst trimmed = configuredGroup.trim();\n\t\t\treturn trimmed || undefined;\n\t\t}\n\t\tconst defaultGroup = this.toolName.trim();\n\t\treturn defaultGroup || undefined;\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined, toolGroupSummary = false): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\ttoolGroupSummary,\n\t\t};\n\t}\n\n\tprivate humanizeToolName(name: string): string {\n\t\tconst words = name\n\t\t\t.replace(/[_-]+/g, \" \")\n\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t.trim()\n\t\t\t.split(/\\s+/)\n\t\t\t.filter(Boolean);\n\t\tif (words.length === 0) return name;\n\t\treturn words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n\t}\n\n\tprivate getDisplayLabel(): string {\n\t\tconst label = (this.toolDefinition?.label ?? this.builtInToolDefinition?.label)?.trim();\n\t\tif (this.builtInToolDefinition) return label || this.toolName;\n\t\tif (!label || label === this.toolName) return this.humanizeToolName(this.toolName);\n\t\treturn label;\n\t}\n\n\tresetInvocation(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t): void {\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(this.cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.executionStarted = false;\n\t\tthis.argsComplete = false;\n\t\tthis.isPartial = true;\n\t\tthis.result = undefined;\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\tthis.rendererState = {};\n\t\tthis.convertedImages.clear();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate titleBadgeStatus(): \"pending\" | \"running\" | \"success\" | \"error\" {\n\t\tif (this.result?.isError) return \"error\";\n\t\tif (this.isPartial) return this.executionStarted ? \"running\" : \"pending\";\n\t\treturn \"success\";\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn titleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tbadgeColor: \"toolTitle\",\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\tgetBackgroundColor(): ThemeBg {\n\t\tif (this.isPartial) return \"toolPendingBg\";\n\t\tif (this.result?.isError) return \"toolErrorBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\trenderCallSummary(width: number): string[] {\n\t\tconst callRenderer = this.getCallRenderer();\n\t\tlet component: Component;\n\t\tif (!callRenderer) {\n\t\t\tcomponent = this.createCallFallback();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tcomponent = callRenderer(this.args, theme, this.getRenderContext(undefined, true));\n\t\t\t} catch {\n\t\t\t\tcomponent = this.createCallFallback();\n\t\t\t}\n\t\t}\n\t\treturn component.render(width);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = (text: string) => theme.bg(this.getBackgroundColor(), text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\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\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = renderTitleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tbadgeColor: \"toolTitle\",\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAwC,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,KAA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AK,EAAE,MAAM,GAAG,MAAM,EAAE,CAazC;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKvC;IAED,OAAO,CAAC,aAAa;IAwGrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CAe3B","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\nimport { renderTitleBadge, titleBadge } from \"./tool-title.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\ttoolGroup: string | undefined;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate resolveToolGroup(): string | undefined {\n\t\tconst configuredGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;\n\t\tif (configuredGroup !== undefined) {\n\t\t\tconst trimmed = configuredGroup.trim();\n\t\t\treturn trimmed || undefined;\n\t\t}\n\t\tconst defaultGroup = this.toolName.trim();\n\t\treturn defaultGroup || undefined;\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined, toolGroupSummary = false): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\ttoolGroupSummary,\n\t\t};\n\t}\n\n\tprivate humanizeToolName(name: string): string {\n\t\tconst words = name\n\t\t\t.replace(/[_-]+/g, \" \")\n\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t.trim()\n\t\t\t.split(/\\s+/)\n\t\t\t.filter(Boolean);\n\t\tif (words.length === 0) return name;\n\t\treturn words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n\t}\n\n\tprivate getDisplayLabel(): string {\n\t\tconst label = (this.toolDefinition?.label ?? this.builtInToolDefinition?.label)?.trim();\n\t\tif (this.builtInToolDefinition) return label || this.toolName;\n\t\tif (!label || label === this.toolName) return this.humanizeToolName(this.toolName);\n\t\treturn label;\n\t}\n\n\tresetInvocation(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t): void {\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(this.cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.executionStarted = false;\n\t\tthis.argsComplete = false;\n\t\tthis.isPartial = true;\n\t\tthis.result = undefined;\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\tthis.rendererState = {};\n\t\tthis.convertedImages.clear();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate titleBadgeStatus(): \"pending\" | \"running\" | \"success\" | \"error\" {\n\t\tif (this.result?.isError) return \"error\";\n\t\tif (this.isPartial) return this.executionStarted ? \"running\" : \"pending\";\n\t\treturn \"success\";\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn titleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\tgetBackgroundColor(): ThemeBg {\n\t\tif (this.isPartial) return \"toolPendingBg\";\n\t\tif (this.result?.isError) return \"toolErrorBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\trenderCallSummary(width: number): string[] {\n\t\tconst callRenderer = this.getCallRenderer();\n\t\tlet component: Component;\n\t\tif (!callRenderer) {\n\t\t\tcomponent = this.createCallFallback();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tcomponent = callRenderer(this.args, theme, this.getRenderContext(undefined, true));\n\t\t\t} catch {\n\t\t\t\tcomponent = this.createCallFallback();\n\t\t\t}\n\t\t}\n\t\treturn component.render(width);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = (text: string) => theme.bg(this.getBackgroundColor(), text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\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\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = renderTitleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
|
|
@@ -162,7 +162,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
162
162
|
createCallFallback() {
|
|
163
163
|
return titleBadge(theme, {
|
|
164
164
|
label: this.getDisplayLabel(),
|
|
165
|
-
badgeColor: "toolTitle",
|
|
166
165
|
status: this.titleBadgeStatus(),
|
|
167
166
|
});
|
|
168
167
|
}
|
|
@@ -361,7 +360,6 @@ export class ToolExecutionComponent extends Container {
|
|
|
361
360
|
formatToolExecution() {
|
|
362
361
|
let text = renderTitleBadge(theme, {
|
|
363
362
|
label: this.getDisplayLabel(),
|
|
364
|
-
badgeColor: "toolTitle",
|
|
365
363
|
status: this.titleBadgeStatus(),
|
|
366
364
|
});
|
|
367
365
|
const content = JSON.stringify(this.args, null, 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,wBAAwB,CAAC;AAExH,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAgB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO/D,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,UAAU,CAAM;IAChB,WAAW,CAAO;IAClB,mBAAmB,CAAY;IAC/B,qBAAqB,CAAa;IAClC,uBAAuB,CAAa;IACpC,aAAa,GAAQ,EAAE,CAAC;IACxB,eAAe,GAAY,EAAE,CAAC;IAC9B,YAAY,GAAa,EAAE,CAAC;IAC5B,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,IAAI,CAAM;IACV,QAAQ,GAAG,KAAK,CAAC;IACjB,UAAU,CAAU;IACpB,eAAe,CAAS;IACxB,SAAS,GAAG,IAAI,CAAC;IACjB,cAAc,CAA4B;IAC1C,qBAAqB,CAA4B;IACzD,SAAS,CAAqB;IACtB,EAAE,CAAM;IACR,GAAG,CAAS;IACZ,gBAAgB,GAAG,KAAK,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EAAE,IAAI,CAAC,eAAe,EAAE,CACvC,CAAC;oBACF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;oBAC1C,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3B,CAAC;IAAA,CACD;IAEO,aAAa,GAAW;QAC/B,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3D;IAEO,mBAAmB,GAAW;QACrC,IAAI,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE;YAClC,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE;YAC7B,UAAU,EAAE,WAAW;YACvB,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE;SAC/B,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\nimport { renderTitleBadge, titleBadge } from \"./tool-title.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\ttoolGroup: string | undefined;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate resolveToolGroup(): string | undefined {\n\t\tconst configuredGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;\n\t\tif (configuredGroup !== undefined) {\n\t\t\tconst trimmed = configuredGroup.trim();\n\t\t\treturn trimmed || undefined;\n\t\t}\n\t\tconst defaultGroup = this.toolName.trim();\n\t\treturn defaultGroup || undefined;\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined, toolGroupSummary = false): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\ttoolGroupSummary,\n\t\t};\n\t}\n\n\tprivate humanizeToolName(name: string): string {\n\t\tconst words = name\n\t\t\t.replace(/[_-]+/g, \" \")\n\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t.trim()\n\t\t\t.split(/\\s+/)\n\t\t\t.filter(Boolean);\n\t\tif (words.length === 0) return name;\n\t\treturn words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n\t}\n\n\tprivate getDisplayLabel(): string {\n\t\tconst label = (this.toolDefinition?.label ?? this.builtInToolDefinition?.label)?.trim();\n\t\tif (this.builtInToolDefinition) return label || this.toolName;\n\t\tif (!label || label === this.toolName) return this.humanizeToolName(this.toolName);\n\t\treturn label;\n\t}\n\n\tresetInvocation(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t): void {\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(this.cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.executionStarted = false;\n\t\tthis.argsComplete = false;\n\t\tthis.isPartial = true;\n\t\tthis.result = undefined;\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\tthis.rendererState = {};\n\t\tthis.convertedImages.clear();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate titleBadgeStatus(): \"pending\" | \"running\" | \"success\" | \"error\" {\n\t\tif (this.result?.isError) return \"error\";\n\t\tif (this.isPartial) return this.executionStarted ? \"running\" : \"pending\";\n\t\treturn \"success\";\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn titleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tbadgeColor: \"toolTitle\",\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\tgetBackgroundColor(): ThemeBg {\n\t\tif (this.isPartial) return \"toolPendingBg\";\n\t\tif (this.result?.isError) return \"toolErrorBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\trenderCallSummary(width: number): string[] {\n\t\tconst callRenderer = this.getCallRenderer();\n\t\tlet component: Component;\n\t\tif (!callRenderer) {\n\t\t\tcomponent = this.createCallFallback();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tcomponent = callRenderer(this.args, theme, this.getRenderContext(undefined, true));\n\t\t\t} catch {\n\t\t\t\tcomponent = this.createCallFallback();\n\t\t\t}\n\t\t}\n\t\treturn component.render(width);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = (text: string) => theme.bg(this.getBackgroundColor(), text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\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\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = renderTitleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tbadgeColor: \"toolTitle\",\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,wBAAwB,CAAC;AAExH,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAgB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO/D,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,UAAU,CAAM;IAChB,WAAW,C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O,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\nimport { renderTitleBadge, titleBadge } from \"./tool-title.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\ttoolGroup: string | undefined;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate resolveToolGroup(): string | undefined {\n\t\tconst configuredGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;\n\t\tif (configuredGroup !== undefined) {\n\t\t\tconst trimmed = configuredGroup.trim();\n\t\t\treturn trimmed || undefined;\n\t\t}\n\t\tconst defaultGroup = this.toolName.trim();\n\t\treturn defaultGroup || undefined;\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined, toolGroupSummary = false): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\ttoolGroupSummary,\n\t\t};\n\t}\n\n\tprivate humanizeToolName(name: string): string {\n\t\tconst words = name\n\t\t\t.replace(/[_-]+/g, \" \")\n\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t.trim()\n\t\t\t.split(/\\s+/)\n\t\t\t.filter(Boolean);\n\t\tif (words.length === 0) return name;\n\t\treturn words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n\t}\n\n\tprivate getDisplayLabel(): string {\n\t\tconst label = (this.toolDefinition?.label ?? this.builtInToolDefinition?.label)?.trim();\n\t\tif (this.builtInToolDefinition) return label || this.toolName;\n\t\tif (!label || label === this.toolName) return this.humanizeToolName(this.toolName);\n\t\treturn label;\n\t}\n\n\tresetInvocation(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t): void {\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(this.cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.resolveToolGroup();\n\t\tthis.executionStarted = false;\n\t\tthis.argsComplete = false;\n\t\tthis.isPartial = true;\n\t\tthis.result = undefined;\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\tthis.rendererState = {};\n\t\tthis.convertedImages.clear();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate titleBadgeStatus(): \"pending\" | \"running\" | \"success\" | \"error\" {\n\t\tif (this.result?.isError) return \"error\";\n\t\tif (this.isPartial) return this.executionStarted ? \"running\" : \"pending\";\n\t\treturn \"success\";\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn titleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\tgetBackgroundColor(): ThemeBg {\n\t\tif (this.isPartial) return \"toolPendingBg\";\n\t\tif (this.result?.isError) return \"toolErrorBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\trenderCallSummary(width: number): string[] {\n\t\tconst callRenderer = this.getCallRenderer();\n\t\tlet component: Component;\n\t\tif (!callRenderer) {\n\t\t\tcomponent = this.createCallFallback();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tcomponent = callRenderer(this.args, theme, this.getRenderContext(undefined, true));\n\t\t\t} catch {\n\t\t\t\tcomponent = this.createCallFallback();\n\t\t\t}\n\t\t}\n\t\treturn component.render(width);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = (text: string) => theme.bg(this.getBackgroundColor(), text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\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\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = renderTitleBadge(theme, {\n\t\t\tlabel: this.getDisplayLabel(),\n\t\t\tstatus: this.titleBadgeStatus(),\n\t\t});\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Component } from "@earendil-works/pi-tui";
|
|
2
2
|
import type { Theme, ThemeColor } from "../theme/theme.ts";
|
|
3
|
-
export type TitleBadgeStatus = "pending" | "running" | "success" | "warning" | "error" | "muted" | "info";
|
|
3
|
+
export type TitleBadgeStatus = "pending" | "running" | "success" | "warning" | "error" | "failed" | "failure" | "blocked" | "cancelled" | "persistent" | "idle" | "disabled" | "muted" | "info";
|
|
4
4
|
export interface TitleBadgeSegment {
|
|
5
5
|
text: string | number | undefined | null;
|
|
6
6
|
color?: ThemeColor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-title.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-title.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"tool-title.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-title.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GACzB,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,GACP,QAAQ,GACR,SAAS,GACT,SAAS,GACT,WAAW,GACX,YAAY,GACZ,MAAM,GACN,UAAU,GACV,OAAO,GACP,MAAM,CAAC;AAEV,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACzC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IACjC,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC5C,gDA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\"@earendil-works/pi-tui\";\nimport type { Theme, ThemeColor } from \"../theme/theme.ts\";\n\nexport type TitleBadgeStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"success\"\n\t| \"warning\"\n\t| \"error\"\n\t| \"failed\"\n\t| \"failure\"\n\t| \"blocked\"\n\t| \"cancelled\"\n\t| \"persistent\"\n\t| \"idle\"\n\t| \"disabled\"\n\t| \"muted\"\n\t| \"info\";\n\nexport interface TitleBadgeSegment {\n\ttext: string | number | undefined | null;\n\tcolor?: ThemeColor;\n\tbold?: boolean;\n\titalic?: boolean;\n}\n\nexport interface TitleBadgeOptions {\n\t/** Human-facing label rendered inside the badge, e.g. \"skill\" or \"background script\". */\n\tlabel: string;\n\t/** Optional glyph rendered before the badge. Keep it one display cell when possible. */\n\ticon?: string;\n\t/** Primary action or state, e.g. start/status/logs. */\n\taction?: string | number | undefined | null;\n\t/** Secondary details shown after the action. */\n\tdetails?: Array<TitleBadgeSegment | string | number | undefined | null>;\n\t/** Status controls badge/accent color. */\n\tstatus?: TitleBadgeStatus;\n\t/** Override badge color when status is not enough. */\n\tbadgeColor?: ThemeColor;\n\t/** Override action color. */\n\tactionColor?: ThemeColor;\n}\n\nexport type ToolTitleStatus = TitleBadgeStatus;\nexport type ToolTitleSegment = TitleBadgeSegment;\nexport type ToolTitleOptions = TitleBadgeOptions;\n\nconst STATUS_BADGE_COLORS: Record<TitleBadgeStatus, ThemeColor> = {\n\tpending: \"warning\",\n\trunning: \"accent\",\n\tsuccess: \"success\",\n\twarning: \"warning\",\n\terror: \"error\",\n\tfailed: \"error\",\n\tfailure: \"error\",\n\tblocked: \"error\",\n\tcancelled: \"warning\",\n\tpersistent: \"warning\",\n\tidle: \"muted\",\n\tdisabled: \"muted\",\n\tmuted: \"muted\",\n\tinfo: \"customMessageLabel\",\n};\n\nconst STATUS_ACTION_COLORS: Record<TitleBadgeStatus, ThemeColor> = {\n\tpending: \"warning\",\n\trunning: \"accent\",\n\tsuccess: \"success\",\n\twarning: \"warning\",\n\terror: \"error\",\n\tfailed: \"error\",\n\tfailure: \"error\",\n\tblocked: \"error\",\n\tcancelled: \"warning\",\n\tpersistent: \"warning\",\n\tidle: \"dim\",\n\tdisabled: \"muted\",\n\tmuted: \"muted\",\n\tinfo: \"accent\",\n};\n\nfunction styleSegment(theme: Theme, segment: TitleBadgeSegment): string {\n\tif (segment.text === undefined || segment.text === null || segment.text === \"\") return \"\";\n\tconst raw = String(segment.text);\n\tlet text = segment.bold ? theme.bold(raw) : raw;\n\tif (segment.italic) text = theme.italic(text);\n\treturn segment.color ? theme.fg(segment.color, text) : text;\n}\n\nfunction normalizeDetail(\n\tdetail: TitleBadgeSegment | string | number | undefined | null,\n): TitleBadgeSegment | undefined {\n\tif (detail === undefined || detail === null || detail === \"\") return undefined;\n\tif (typeof detail === \"object\" && \"text\" in detail) return detail;\n\treturn { text: detail, color: \"dim\" };\n}\n\nexport function renderTitleBadge(theme: Theme, options: TitleBadgeOptions): string {\n\tconst status = options.status ?? \"info\";\n\tconst badgeColor = options.badgeColor ?? STATUS_BADGE_COLORS[status];\n\tconst actionColor = options.actionColor ?? STATUS_ACTION_COLORS[status];\n\tconst icon = options.icon ? `${theme.fg(badgeColor, options.icon)} ` : \"\";\n\tconst badge = theme.fg(badgeColor, theme.bold(`[${options.label}]`));\n\tconst parts = [icon + badge];\n\n\tif (options.action !== undefined && options.action !== null && options.action !== \"\") {\n\t\tparts.push(theme.fg(actionColor, String(options.action)));\n\t}\n\n\tfor (const detail of options.details ?? []) {\n\t\tconst normalized = normalizeDetail(detail);\n\t\tif (!normalized) continue;\n\t\tconst styled = styleSegment(theme, normalized);\n\t\tif (styled) parts.push(styled);\n\t}\n\n\treturn parts.join(\" \");\n}\n\nexport function renderToolTitle(theme: Theme, options: ToolTitleOptions): string {\n\treturn renderTitleBadge(theme, options);\n}\n\nexport class TitleBadgeComponent implements Component {\n\tprivate cachedWidth?: number;\n\tprivate cachedLines?: string[];\n\tprivate readonly theme: Theme;\n\tprivate readonly options: TitleBadgeOptions;\n\n\tconstructor(theme: Theme, options: TitleBadgeOptions) {\n\t\tthis.theme = theme;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.cachedLines && this.cachedWidth === width) return this.cachedLines;\n\t\tconst safeWidth = Math.max(0, width);\n\t\tconst title = renderTitleBadge(this.theme, this.options);\n\t\tthis.cachedLines = [truncateToWidth(title, safeWidth, \"\")];\n\t\tthis.cachedWidth = width;\n\t\treturn this.cachedLines;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n}\n\nexport const ToolTitleComponent = TitleBadgeComponent;\n\nexport function titleBadge(theme: Theme, options: TitleBadgeOptions): TitleBadgeComponent {\n\treturn new TitleBadgeComponent(theme, options);\n}\n\nexport function toolTitle(theme: Theme, options: ToolTitleOptions): TitleBadgeComponent {\n\treturn titleBadge(theme, options);\n}\n"]}
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
2
|
-
const
|
|
2
|
+
const STATUS_BADGE_COLORS = {
|
|
3
3
|
pending: "warning",
|
|
4
4
|
running: "accent",
|
|
5
5
|
success: "success",
|
|
6
6
|
warning: "warning",
|
|
7
7
|
error: "error",
|
|
8
|
+
failed: "error",
|
|
9
|
+
failure: "error",
|
|
10
|
+
blocked: "error",
|
|
11
|
+
cancelled: "warning",
|
|
12
|
+
persistent: "warning",
|
|
13
|
+
idle: "muted",
|
|
14
|
+
disabled: "muted",
|
|
8
15
|
muted: "muted",
|
|
9
16
|
info: "customMessageLabel",
|
|
10
17
|
};
|
|
18
|
+
const STATUS_ACTION_COLORS = {
|
|
19
|
+
pending: "warning",
|
|
20
|
+
running: "accent",
|
|
21
|
+
success: "success",
|
|
22
|
+
warning: "warning",
|
|
23
|
+
error: "error",
|
|
24
|
+
failed: "error",
|
|
25
|
+
failure: "error",
|
|
26
|
+
blocked: "error",
|
|
27
|
+
cancelled: "warning",
|
|
28
|
+
persistent: "warning",
|
|
29
|
+
idle: "dim",
|
|
30
|
+
disabled: "muted",
|
|
31
|
+
muted: "muted",
|
|
32
|
+
info: "accent",
|
|
33
|
+
};
|
|
11
34
|
function styleSegment(theme, segment) {
|
|
12
35
|
if (segment.text === undefined || segment.text === null || segment.text === "")
|
|
13
36
|
return "";
|
|
@@ -25,12 +48,14 @@ function normalizeDetail(detail) {
|
|
|
25
48
|
return { text: detail, color: "dim" };
|
|
26
49
|
}
|
|
27
50
|
export function renderTitleBadge(theme, options) {
|
|
28
|
-
const
|
|
51
|
+
const status = options.status ?? "info";
|
|
52
|
+
const badgeColor = options.badgeColor ?? STATUS_BADGE_COLORS[status];
|
|
53
|
+
const actionColor = options.actionColor ?? STATUS_ACTION_COLORS[status];
|
|
29
54
|
const icon = options.icon ? `${theme.fg(badgeColor, options.icon)} ` : "";
|
|
30
55
|
const badge = theme.fg(badgeColor, theme.bold(`[${options.label}]`));
|
|
31
56
|
const parts = [icon + badge];
|
|
32
57
|
if (options.action !== undefined && options.action !== null && options.action !== "") {
|
|
33
|
-
parts.push(theme.fg(
|
|
58
|
+
parts.push(theme.fg(actionColor, String(options.action)));
|
|
34
59
|
}
|
|
35
60
|
for (const detail of options.details ?? []) {
|
|
36
61
|
const normalized = normalizeDetail(detail);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-title.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-title.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-title.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-title.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AA+CzD,MAAM,mBAAmB,GAAyC;IACjE,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,SAAS;IA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ACxB;IAED,UAAU,GAAS;QAClB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAAA,CAC7B;CACD;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAEtD,MAAM,UAAU,UAAU,CAAC,KAAY,EAAE,OAA0B,EAAuB;IACzF,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAAA,CAC/C;AAED,MAAM,UAAU,SAAS,CAAC,KAAY,EAAE,OAAyB,EAAuB;IACvF,OAAO,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAAA,CAClC","sourcesContent":["import type { Component } from \"@earendil-works/pi-tui\";\nimport { truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { Theme, ThemeColor } from \"../theme/theme.ts\";\n\nexport type TitleBadgeStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"success\"\n\t| \"warning\"\n\t| \"error\"\n\t| \"failed\"\n\t| \"failure\"\n\t| \"blocked\"\n\t| \"cancelled\"\n\t| \"persistent\"\n\t| \"idle\"\n\t| \"disabled\"\n\t| \"muted\"\n\t| \"info\";\n\nexport interface TitleBadgeSegment {\n\ttext: string | number | undefined | null;\n\tcolor?: ThemeColor;\n\tbold?: boolean;\n\titalic?: boolean;\n}\n\nexport interface TitleBadgeOptions {\n\t/** Human-facing label rendered inside the badge, e.g. \"skill\" or \"background script\". */\n\tlabel: string;\n\t/** Optional glyph rendered before the badge. Keep it one display cell when possible. */\n\ticon?: string;\n\t/** Primary action or state, e.g. start/status/logs. */\n\taction?: string | number | undefined | null;\n\t/** Secondary details shown after the action. */\n\tdetails?: Array<TitleBadgeSegment | string | number | undefined | null>;\n\t/** Status controls badge/accent color. */\n\tstatus?: TitleBadgeStatus;\n\t/** Override badge color when status is not enough. */\n\tbadgeColor?: ThemeColor;\n\t/** Override action color. */\n\tactionColor?: ThemeColor;\n}\n\nexport type ToolTitleStatus = TitleBadgeStatus;\nexport type ToolTitleSegment = TitleBadgeSegment;\nexport type ToolTitleOptions = TitleBadgeOptions;\n\nconst STATUS_BADGE_COLORS: Record<TitleBadgeStatus, ThemeColor> = {\n\tpending: \"warning\",\n\trunning: \"accent\",\n\tsuccess: \"success\",\n\twarning: \"warning\",\n\terror: \"error\",\n\tfailed: \"error\",\n\tfailure: \"error\",\n\tblocked: \"error\",\n\tcancelled: \"warning\",\n\tpersistent: \"warning\",\n\tidle: \"muted\",\n\tdisabled: \"muted\",\n\tmuted: \"muted\",\n\tinfo: \"customMessageLabel\",\n};\n\nconst STATUS_ACTION_COLORS: Record<TitleBadgeStatus, ThemeColor> = {\n\tpending: \"warning\",\n\trunning: \"accent\",\n\tsuccess: \"success\",\n\twarning: \"warning\",\n\terror: \"error\",\n\tfailed: \"error\",\n\tfailure: \"error\",\n\tblocked: \"error\",\n\tcancelled: \"warning\",\n\tpersistent: \"warning\",\n\tidle: \"dim\",\n\tdisabled: \"muted\",\n\tmuted: \"muted\",\n\tinfo: \"accent\",\n};\n\nfunction styleSegment(theme: Theme, segment: TitleBadgeSegment): string {\n\tif (segment.text === undefined || segment.text === null || segment.text === \"\") return \"\";\n\tconst raw = String(segment.text);\n\tlet text = segment.bold ? theme.bold(raw) : raw;\n\tif (segment.italic) text = theme.italic(text);\n\treturn segment.color ? theme.fg(segment.color, text) : text;\n}\n\nfunction normalizeDetail(\n\tdetail: TitleBadgeSegment | string | number | undefined | null,\n): TitleBadgeSegment | undefined {\n\tif (detail === undefined || detail === null || detail === \"\") return undefined;\n\tif (typeof detail === \"object\" && \"text\" in detail) return detail;\n\treturn { text: detail, color: \"dim\" };\n}\n\nexport function renderTitleBadge(theme: Theme, options: TitleBadgeOptions): string {\n\tconst status = options.status ?? \"info\";\n\tconst badgeColor = options.badgeColor ?? STATUS_BADGE_COLORS[status];\n\tconst actionColor = options.actionColor ?? STATUS_ACTION_COLORS[status];\n\tconst icon = options.icon ? `${theme.fg(badgeColor, options.icon)} ` : \"\";\n\tconst badge = theme.fg(badgeColor, theme.bold(`[${options.label}]`));\n\tconst parts = [icon + badge];\n\n\tif (options.action !== undefined && options.action !== null && options.action !== \"\") {\n\t\tparts.push(theme.fg(actionColor, String(options.action)));\n\t}\n\n\tfor (const detail of options.details ?? []) {\n\t\tconst normalized = normalizeDetail(detail);\n\t\tif (!normalized) continue;\n\t\tconst styled = styleSegment(theme, normalized);\n\t\tif (styled) parts.push(styled);\n\t}\n\n\treturn parts.join(\" \");\n}\n\nexport function renderToolTitle(theme: Theme, options: ToolTitleOptions): string {\n\treturn renderTitleBadge(theme, options);\n}\n\nexport class TitleBadgeComponent implements Component {\n\tprivate cachedWidth?: number;\n\tprivate cachedLines?: string[];\n\tprivate readonly theme: Theme;\n\tprivate readonly options: TitleBadgeOptions;\n\n\tconstructor(theme: Theme, options: TitleBadgeOptions) {\n\t\tthis.theme = theme;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.cachedLines && this.cachedWidth === width) return this.cachedLines;\n\t\tconst safeWidth = Math.max(0, width);\n\t\tconst title = renderTitleBadge(this.theme, this.options);\n\t\tthis.cachedLines = [truncateToWidth(title, safeWidth, \"\")];\n\t\tthis.cachedWidth = width;\n\t\treturn this.cachedLines;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n}\n\nexport const ToolTitleComponent = TitleBadgeComponent;\n\nexport function titleBadge(theme: Theme, options: TitleBadgeOptions): TitleBadgeComponent {\n\treturn new TitleBadgeComponent(theme, options);\n}\n\nexport function toolTitle(theme: Theme, options: ToolTitleOptions): TitleBadgeComponent {\n\treturn titleBadge(theme, options);\n}\n"]}
|
package/docs/tui.md
CHANGED
|
@@ -587,7 +587,9 @@ These patterns cover the most common UI needs in extensions. **Copy these patter
|
|
|
587
587
|
|
|
588
588
|
### Pattern 0: Title Badge
|
|
589
589
|
|
|
590
|
-
For compact status labels in custom messages, skill renderers, and `renderCall`/`renderResult`, use `TitleBadgeComponent` or `titleBadge()` from `@earendil-works/pi-coding-agent`. It keeps titles visually consistent, compact, and width-bounded. `ToolTitleComponent`/`toolTitle()` remain aliases for tool-specific code.
|
|
590
|
+
For compact status labels in custom messages, skill renderers, and `renderCall`/`renderResult`, use `TitleBadgeComponent` or `titleBadge()` from `@earendil-works/pi-coding-agent`. It keeps titles visually consistent, compact, theme-balanced, and width-bounded. `ToolTitleComponent`/`toolTitle()` remain aliases for tool-specific code.
|
|
591
|
+
|
|
592
|
+
Status colors intentionally map to theme tokens instead of hard-coded ANSI values: `error`/`failed`/`failure`/`blocked` use `error` red, `persistent`/`pending`/`warning`/`cancelled` use `warning` yellow, `success` uses `success` green, `running` uses `accent`, and `idle`/`disabled`/`muted` stay subdued. Keep generated ids out of badge text and `details`; store ids in result metadata for control/debug flows instead.
|
|
591
593
|
|
|
592
594
|
```typescript
|
|
593
595
|
import { titleBadge } from "@earendil-works/pi-coding-agent";
|
|
@@ -597,7 +599,7 @@ renderCall(args, theme) {
|
|
|
597
599
|
label: "background script",
|
|
598
600
|
icon: "◆",
|
|
599
601
|
action: args.action || "list",
|
|
600
|
-
details: [args.
|
|
602
|
+
details: [args.name],
|
|
601
603
|
status: args.action === "stop" ? "warning" : "running",
|
|
602
604
|
});
|
|
603
605
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.11",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.80.
|
|
9
|
+
"version": "0.80.11",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.11",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "0.80.
|
|
9
|
+
"version": "0.80.11",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.11",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.80.
|
|
9
|
+
"version": "0.80.11",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-adaptative",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.11",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@caupulican/pi-adaptative",
|
|
9
|
-
"version": "0.80.
|
|
9
|
+
"version": "0.80.11",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@earendil-works/pi-agent-core": "npm:@caupulican/pi-agent-core@0.80.
|
|
13
|
-
"@earendil-works/pi-ai": "npm:@caupulican/pi-ai@0.80.
|
|
14
|
-
"@earendil-works/pi-tui": "npm:@caupulican/pi-tui@0.80.
|
|
12
|
+
"@earendil-works/pi-agent-core": "npm:@caupulican/pi-agent-core@0.80.11",
|
|
13
|
+
"@earendil-works/pi-ai": "npm:@caupulican/pi-ai@0.80.11",
|
|
14
|
+
"@earendil-works/pi-tui": "npm:@caupulican/pi-tui@0.80.11",
|
|
15
15
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
16
16
|
"chalk": "5.6.2",
|
|
17
17
|
"cross-spawn": "7.0.6",
|
|
@@ -474,11 +474,11 @@
|
|
|
474
474
|
}
|
|
475
475
|
},
|
|
476
476
|
"node_modules/@earendil-works/pi-agent-core": {
|
|
477
|
-
"version": "0.80.
|
|
478
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.80.
|
|
477
|
+
"version": "0.80.11",
|
|
478
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.80.11.tgz",
|
|
479
479
|
"license": "MIT",
|
|
480
480
|
"dependencies": {
|
|
481
|
-
"@earendil-works/pi-ai": "npm:@caupulican/pi-ai@0.80.
|
|
481
|
+
"@earendil-works/pi-ai": "npm:@caupulican/pi-ai@0.80.11",
|
|
482
482
|
"ignore": "7.0.5",
|
|
483
483
|
"typebox": "1.1.38",
|
|
484
484
|
"yaml": "2.9.0"
|
|
@@ -488,8 +488,8 @@
|
|
|
488
488
|
}
|
|
489
489
|
},
|
|
490
490
|
"node_modules/@earendil-works/pi-ai": {
|
|
491
|
-
"version": "0.80.
|
|
492
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.80.
|
|
491
|
+
"version": "0.80.11",
|
|
492
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.80.11.tgz",
|
|
493
493
|
"license": "MIT",
|
|
494
494
|
"dependencies": {
|
|
495
495
|
"@anthropic-ai/sdk": "0.91.1",
|
|
@@ -511,8 +511,8 @@
|
|
|
511
511
|
}
|
|
512
512
|
},
|
|
513
513
|
"node_modules/@earendil-works/pi-tui": {
|
|
514
|
-
"version": "0.80.
|
|
515
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.80.
|
|
514
|
+
"version": "0.80.11",
|
|
515
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.80.11.tgz",
|
|
516
516
|
"license": "MIT",
|
|
517
517
|
"dependencies": {
|
|
518
518
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-adaptative",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.11",
|
|
4
4
|
"description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@earendil-works/pi-agent-core": "npm:@caupulican/pi-agent-core@0.80.
|
|
45
|
-
"@earendil-works/pi-ai": "npm:@caupulican/pi-ai@0.80.
|
|
46
|
-
"@earendil-works/pi-tui": "npm:@caupulican/pi-tui@0.80.
|
|
44
|
+
"@earendil-works/pi-agent-core": "npm:@caupulican/pi-agent-core@0.80.11",
|
|
45
|
+
"@earendil-works/pi-ai": "npm:@caupulican/pi-ai@0.80.11",
|
|
46
|
+
"@earendil-works/pi-tui": "npm:@caupulican/pi-tui@0.80.11",
|
|
47
47
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
48
48
|
"chalk": "5.6.2",
|
|
49
49
|
"cross-spawn": "7.0.6",
|