@ashx-j/lunr 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-extensions/ashxj-spinners.d.ts +4 -0
- package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-spinners.js +14 -3
- package/dist/builtin-extensions/ashxj-spinners.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +4 -0
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +49 -4
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-behavior.d.ts +2 -1
- package/dist/builtin-extensions/lunr-behavior.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-behavior.js +26 -14
- package/dist/builtin-extensions/lunr-behavior.js.map +1 -1
- package/dist/builtin-extensions/lunr-todos.d.ts +4 -7
- package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-todos.js +18 -10
- package/dist/builtin-extensions/lunr-todos.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +4 -4
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +4 -5
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +5 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +6 -18
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +13 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts +21 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js +22 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +2 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +10 -18
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +4 -6
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +26 -18
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +3 -1
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/render-search-error.js +1 -1
- package/dist/builtin-extensions/pi-web-access/render-search-error.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/nvidia.json +1 -1
- package/dist/catalog/providers/opencode-go.json +1 -1
- package/dist/catalog/providers/opencode.json +1 -1
- package/dist/catalog/providers/openrouter.json +1 -1
- package/dist/catalog/providers/qwen-cloud-cn.json +1 -1
- package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
- package/dist/catalog/providers/xai.json +1 -1
- package/dist/catalog/publication.json +2 -2
- package/dist/cli/update-cli.d.ts +16 -0
- package/dist/cli/update-cli.d.ts.map +1 -0
- package/dist/cli/update-cli.js +83 -0
- package/dist/cli/update-cli.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +9 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/behavior-preset.d.ts +60 -0
- package/dist/core/behavior-preset.d.ts.map +1 -0
- package/dist/core/behavior-preset.js +257 -0
- package/dist/core/behavior-preset.js.map +1 -0
- package/dist/core/customize.d.ts +4 -0
- package/dist/core/customize.d.ts.map +1 -1
- package/dist/core/customize.js +12 -0
- package/dist/core/customize.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +12 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +70 -5
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-tiers.d.ts +9 -0
- package/dist/core/model-tiers.d.ts.map +1 -1
- package/dist/core/model-tiers.js +16 -0
- package/dist/core/model-tiers.js.map +1 -1
- package/dist/core/settings-manager.d.ts +26 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +74 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +9 -6
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +2 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +2 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +2 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +2 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +13 -3
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +10 -2
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +5 -3
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/update-check.d.ts +32 -0
- package/dist/core/update-check.d.ts.map +1 -0
- package/dist/core/update-check.js +112 -0
- package/dist/core/update-check.js.map +1 -0
- package/dist/core/usage-service.d.ts +24 -1
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +91 -14
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +1 -0
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +5 -1
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +5 -1
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +4 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +68 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +15 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +168 -11
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.d.ts +1 -0
- package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-tail.js +2 -6
- package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +84 -16
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +19 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +221 -37
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/terminal-setup.md +2 -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/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -32,6 +32,8 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
32
32
|
private hideComponent;
|
|
33
33
|
private groupContinuation;
|
|
34
34
|
private groupFollowed;
|
|
35
|
+
private groupPrev?;
|
|
36
|
+
private groupNext?;
|
|
35
37
|
constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolDefinition<any, any> | undefined, ui: TUI, cwd: string);
|
|
36
38
|
private getCallRenderer;
|
|
37
39
|
private getResultRenderer;
|
|
@@ -56,11 +58,16 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
56
58
|
}, isPartial?: boolean): void;
|
|
57
59
|
private maybeConvertImagesForKitty;
|
|
58
60
|
setExpanded(expanded: boolean): void;
|
|
61
|
+
handleClick(_localY: number, _width: number): boolean;
|
|
59
62
|
getToolName(): string;
|
|
60
63
|
setGroupContinuation(on: boolean): void;
|
|
61
64
|
setGroupFollowed(on: boolean): void;
|
|
65
|
+
linkGroupNext(next: ToolExecutionComponent): void;
|
|
62
66
|
private applyGroupPadding;
|
|
67
|
+
private shouldHideGroupedErrorBody;
|
|
63
68
|
private shouldSkipCompactResult;
|
|
69
|
+
private formatHoistedGroupErrors;
|
|
70
|
+
private refreshGroupTail;
|
|
64
71
|
setShowImages(show: boolean): void;
|
|
65
72
|
setImageWidthCells(width: number): void;
|
|
66
73
|
invalidate(): void;
|
|
@@ -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;AACxH,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AAW3F,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,mBAAmB,CAAY;IAGvC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,qBAAqB,CAAC,CAAY;IAC1C,OAAO,CAAC,uBAAuB,CAAC,CAAY;IAC5C,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,cAAc,CAAC,CAA2B;IAClD,OAAO,CAAC,qBAAqB,CAAC,CAA2B;IACzD,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAC,CAIb;IACF,OAAO,CAAC,eAAe,CAA8D;IACrF,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OA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ED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAgCvC;IAED,OAAO,CAAC,aAAa;IAqHrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CAqB3B;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,EAC5C,IAAI,EAAE,sBAAsB,GAC1B,IAAI,CAKN","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@ashx-j/lunr-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport {\n\tformatGroupedCall,\n\tgetTextOutput as getRenderedTextOutput,\n\ttoolGroupRole,\n\ttoolStatusDot,\n} from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.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\t// lunr: top spacer kept as a field so consecutive same-tool calls can be\n\t// grouped into one continuous background by zeroing it (setGroupContinuation).\n\tprivate topSpacer: Spacer;\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\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\tprivate groupContinuation = false;\n\tprivate groupFollowed = 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.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.topSpacer = new Spacer(1);\n\t\tthis.addChild(this.topSpacer);\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\t// lunr: default Box(1, 1). Same-name neighbors collapse facing pad only\n\t\t// (setGroupContinuation / setGroupFollowed); mixed and lone cards keep air.\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 getRenderContext(lastComponent: Component | undefined): 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\trequestRender: () => {\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\tresult: this.result,\n\t\t\tgroupRole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t};\n\t}\n\n\tprivate getStatusDot(): string {\n\t\tconst state = this.isPartial ? \"pending\" : this.result?.isError ? \"error\" : \"success\";\n\t\treturn toolStatusDot(state, theme);\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(\n\t\t\tformatGroupedCall({\n\t\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\t\tcompact: !this.isPartial && !this.expanded && !this.result?.isError,\n\t\t\t\tdot: this.getStatusDot(),\n\t\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\t}),\n\t\t\t0,\n\t\t\t0,\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\t// lunr: consecutive same-tool grouping — exposes the tool name so the caller\n\t// can detect adjacency.\n\tgetToolName(): string {\n\t\treturn this.toolName;\n\t}\n\n\t// lunr: consecutive same-tool grouping — continuation calls hide the top\n\t// spacer and top box pad so adjacent same-bg boxes read as one continuous\n\t// background; the last card in a run keeps its bottom pad.\n\tsetGroupContinuation(on: boolean): void {\n\t\tthis.groupContinuation = on;\n\t\tthis.topSpacer.setLines(on ? 0 : 1);\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: previous card in a same-name run drops its bottom pad so the next\n\t// header sits flush. Singletons and mixed neighbors keep paddingBottom = 1.\n\tsetGroupFollowed(on: boolean): void {\n\t\tthis.groupFollowed = on;\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\tprivate applyGroupPadding(): void {\n\t\tconst top = this.groupContinuation ? 0 : 1;\n\t\tconst bottom = this.groupFollowed ? 0 : 1;\n\t\tthis.contentBox.setPaddingTop(top);\n\t\tthis.contentBox.setPaddingBottom(bottom);\n\t\tthis.contentText.setPaddingTop(top);\n\t\tthis.contentText.setPaddingBottom(bottom);\n\t\tif (this.getRenderShell() === \"self\" && this.callRendererComponent instanceof Box) {\n\t\t\tthis.callRendererComponent.setPaddingTop(top);\n\t\t\tthis.callRendererComponent.setPaddingBottom(bottom);\n\t\t}\n\t}\n\n\tprivate shouldSkipCompactResult(): boolean {\n\t\treturn (\n\t\t\tthis.getRenderShell() === \"default\" &&\n\t\t\tthis.result !== undefined &&\n\t\t\t!this.isPartial &&\n\t\t\t!this.expanded &&\n\t\t\t!this.result.isError\n\t\t);\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\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tif (!this.groupContinuation) {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", 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 skipCompactBody = this.shouldSkipCompactResult();\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tif (!skipCompactBody) {\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} 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\tif (!skipCompactBody) {\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} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t\t}\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\n\t\tthis.applyGroupPadding();\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst compact = !this.isPartial && !this.expanded && !this.result?.isError;\n\t\tlet text = formatGroupedCall({\n\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\tcompact,\n\t\t\tdot: this.getStatusDot(),\n\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t});\n\t\tif (compact) {\n\t\t\treturn text;\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\n/** Collapse facing pad when `next` is appended after a same-name tool card. */\nexport function applySameToolGrouping(\n\tprevious: ToolExecutionComponent | undefined,\n\tnext: ToolExecutionComponent,\n): void {\n\tif (previous && previous.getToolName() === next.getToolName()) {\n\t\tprevious.setGroupFollowed(true);\n\t\tnext.setGroupContinuation(true);\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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YlC,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,gBAAgB;IASxB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAGjC;IAED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAgCvC;IAED,OAAO,CAAC,aAAa;IA0HrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CA0B3B;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,EAC5C,IAAI,EAAE,sBAAsB,GAC1B,IAAI,CAMN","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@ashx-j/lunr-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport {\n\tformatGroupedCall,\n\tgetTextOutput as getRenderedTextOutput,\n\ttoolGroupRole,\n\ttoolGroupTree,\n\ttoolStatusDot,\n} from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.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\t// lunr: top spacer kept as a field so consecutive same-tool calls can be\n\t// grouped into one continuous background by zeroing it (setGroupContinuation).\n\tprivate topSpacer: Spacer;\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\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\tprivate groupContinuation = false;\n\tprivate groupFollowed = false;\n\tprivate groupPrev?: ToolExecutionComponent;\n\tprivate groupNext?: ToolExecutionComponent;\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.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.topSpacer = new Spacer(1);\n\t\tthis.addChild(this.topSpacer);\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\t// lunr: default Box(1, 1). Same-name neighbors collapse facing pad only\n\t\t// (setGroupContinuation / setGroupFollowed); mixed and lone cards keep air.\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 getRenderContext(lastComponent: Component | undefined): 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\trequestRender: () => {\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\tresult: this.result,\n\t\t\tgroupRole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t};\n\t}\n\n\tprivate getStatusDot(): string {\n\t\tconst state = this.isPartial ? \"pending\" : this.result?.isError ? \"error\" : \"success\";\n\t\treturn toolStatusDot(state, theme);\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(\n\t\t\tformatGroupedCall({\n\t\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\t\tcompact: !this.isPartial && !this.expanded && !this.result?.isError,\n\t\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\t\tdot: this.getStatusDot(),\n\t\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\t}),\n\t\t\t0,\n\t\t\t0,\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.refreshGroupTail();\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\tthis.refreshGroupTail();\n\t}\n\n\thandleClick(_localY: number, _width: number): boolean {\n\t\tif (this.isPartial) return false;\n\t\tif (this.toolName === \"subagent\" || this.toolName === \"subagent_wait\") return false;\n\t\tthis.setExpanded(!this.expanded);\n\t\tthis.ui.requestRender();\n\t\treturn true;\n\t}\n\n\t// lunr: consecutive same-tool grouping — exposes the tool name so the caller\n\t// can detect adjacency.\n\tgetToolName(): string {\n\t\treturn this.toolName;\n\t}\n\n\t// lunr: consecutive same-tool grouping — continuation calls hide the top\n\t// spacer and top box pad so adjacent same-bg boxes read as one continuous\n\t// background; the last card in a run keeps its bottom pad.\n\tsetGroupContinuation(on: boolean): void {\n\t\tthis.groupContinuation = on;\n\t\tthis.topSpacer.setLines(on ? 0 : 1);\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: previous card in a same-name run drops its bottom pad so the next\n\t// header sits flush. Singletons and mixed neighbors keep paddingBottom = 1.\n\tsetGroupFollowed(on: boolean): void {\n\t\tthis.groupFollowed = on;\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: same-name run link so a later card can hoist earlier error bodies\n\t// under the last leaf instead of splitting the tree.\n\tlinkGroupNext(next: ToolExecutionComponent): void {\n\t\tthis.groupNext = next;\n\t\tnext.groupPrev = this;\n\t}\n\n\tprivate applyGroupPadding(): void {\n\t\tconst top = this.groupContinuation ? 0 : 1;\n\t\tconst bottom = this.groupFollowed ? 0 : 1;\n\t\tthis.contentBox.setPaddingTop(top);\n\t\tthis.contentBox.setPaddingBottom(bottom);\n\t\tthis.contentText.setPaddingTop(top);\n\t\tthis.contentText.setPaddingBottom(bottom);\n\t\tif (this.getRenderShell() === \"self\" && this.callRendererComponent instanceof Box) {\n\t\t\tthis.callRendererComponent.setPaddingTop(top);\n\t\t\tthis.callRendererComponent.setPaddingBottom(bottom);\n\t\t}\n\t}\n\n\tprivate shouldHideGroupedErrorBody(): boolean {\n\t\treturn (\n\t\t\tBoolean(this.result?.isError) &&\n\t\t\tthis.groupFollowed &&\n\t\t\t!this.expanded &&\n\t\t\t!this.isPartial &&\n\t\t\tthis.getRenderShell() === \"default\" &&\n\t\t\tthis.toolName !== \"subagent\" &&\n\t\t\tthis.toolName !== \"subagent_wait\"\n\t\t);\n\t}\n\n\tprivate shouldSkipCompactResult(): boolean {\n\t\tif (this.result === undefined || this.isPartial || this.expanded) {\n\t\t\treturn false;\n\t\t}\n\t\t// lunr: collapsed mid-group errors stay header-only so the same-name\n\t\t// tree is not split; the last card hoists those bodies underneath.\n\t\tif (this.result.isError) {\n\t\t\treturn this.shouldHideGroupedErrorBody();\n\t\t}\n\t\treturn this.getRenderShell() === \"default\";\n\t}\n\n\tprivate formatHoistedGroupErrors(): string | undefined {\n\t\tif (this.groupFollowed || this.expanded) return undefined;\n\t\tconst texts: string[] = [];\n\t\tlet prev = this.groupPrev;\n\t\twhile (prev) {\n\t\t\tif (prev.shouldHideGroupedErrorBody()) {\n\t\t\t\tconst output = prev.getTextOutput().trim();\n\t\t\t\tif (output) texts.unshift(output);\n\t\t\t}\n\t\t\tprev = prev.groupPrev;\n\t\t}\n\t\treturn texts.length > 0 ? `\\n${texts.join(\"\\n\")}` : undefined;\n\t}\n\n\tprivate refreshGroupTail(): void {\n\t\tlet next = this.groupNext;\n\t\twhile (next) {\n\t\t\tconst card = next;\n\t\t\tnext = next.groupNext;\n\t\t\tif (!next) card.updateDisplay();\n\t\t}\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\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tif (!this.groupContinuation) {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", 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 skipCompactBody = this.shouldSkipCompactResult();\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tif (!skipCompactBody) {\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} 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\tif (!skipCompactBody) {\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} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst hoisted = this.formatHoistedGroupErrors();\n\t\t\t\tif (hoisted) {\n\t\t\t\t\trenderContainer.addChild(new Text(theme.fg(\"toolOutput\", hoisted), 0, 0));\n\t\t\t\t\thasContent = true;\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\n\t\tthis.applyGroupPadding();\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst hideGroupedErrorBody = Boolean(this.result?.isError && this.groupFollowed && !this.expanded);\n\t\tconst compact = !this.isPartial && !this.expanded && (!this.result?.isError || hideGroupedErrorBody);\n\t\tlet text = formatGroupedCall({\n\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\tcompact,\n\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\tdot: this.getStatusDot(),\n\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t});\n\t\tif (!compact) {\n\t\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\t\tif (content) {\n\t\t\t\ttext += `\\n\\n${content}`;\n\t\t\t}\n\t\t\tconst output = this.getTextOutput();\n\t\t\tif (output) {\n\t\t\t\ttext += `\\n${output}`;\n\t\t\t}\n\t\t}\n\t\tconst hoisted = this.formatHoistedGroupErrors();\n\t\tif (hoisted) {\n\t\t\ttext += hoisted;\n\t\t}\n\t\treturn text;\n\t}\n}\n\n/** Collapse facing pad when `next` is appended after a same-name tool card. */\nexport function applySameToolGrouping(\n\tprevious: ToolExecutionComponent | undefined,\n\tnext: ToolExecutionComponent,\n): void {\n\tif (previous && previous.getToolName() === next.getToolName()) {\n\t\tprevious.linkGroupNext(next);\n\t\tprevious.setGroupFollowed(true);\n\t\tnext.setGroupContinuation(true);\n\t}\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Box, Container, getCapabilities, Image, Spacer, Text } from "@ashx-j/lunr-tui";
|
|
2
2
|
import { createAllToolDefinitions } from "../../../core/tools/index.js";
|
|
3
|
-
import { formatGroupedCall, getTextOutput as getRenderedTextOutput, toolGroupRole, toolStatusDot, } from "../../../core/tools/render-utils.js";
|
|
3
|
+
import { formatGroupedCall, getTextOutput as getRenderedTextOutput, toolGroupRole, toolGroupTree, toolStatusDot, } from "../../../core/tools/render-utils.js";
|
|
4
4
|
import { convertToPng } from "../../../utils/image-convert.js";
|
|
5
5
|
import { theme } from "../theme/theme.js";
|
|
6
6
|
export class ToolExecutionComponent extends Container {
|
|
@@ -33,6 +33,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
33
33
|
hideComponent = false;
|
|
34
34
|
groupContinuation = false;
|
|
35
35
|
groupFollowed = false;
|
|
36
|
+
groupPrev;
|
|
37
|
+
groupNext;
|
|
36
38
|
constructor(toolName, toolCallId, args, options = {}, toolDefinition, ui, cwd) {
|
|
37
39
|
super();
|
|
38
40
|
this.toolName = toolName;
|
|
@@ -124,6 +126,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
124
126
|
return new Text(formatGroupedCall({
|
|
125
127
|
role: toolGroupRole(this.groupContinuation, this.groupFollowed),
|
|
126
128
|
compact: !this.isPartial && !this.expanded && !this.result?.isError,
|
|
129
|
+
tree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),
|
|
127
130
|
dot: this.getStatusDot(),
|
|
128
131
|
title: theme.fg("toolTitle", theme.bold(this.toolName)),
|
|
129
132
|
}), 0, 0);
|
|
@@ -153,6 +156,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
153
156
|
this.result = result;
|
|
154
157
|
this.isPartial = isPartial;
|
|
155
158
|
this.updateDisplay();
|
|
159
|
+
this.refreshGroupTail();
|
|
156
160
|
this.maybeConvertImagesForKitty();
|
|
157
161
|
}
|
|
158
162
|
maybeConvertImagesForKitty() {
|
|
@@ -183,6 +187,16 @@ export class ToolExecutionComponent extends Container {
|
|
|
183
187
|
setExpanded(expanded) {
|
|
184
188
|
this.expanded = expanded;
|
|
185
189
|
this.updateDisplay();
|
|
190
|
+
this.refreshGroupTail();
|
|
191
|
+
}
|
|
192
|
+
handleClick(_localY, _width) {
|
|
193
|
+
if (this.isPartial)
|
|
194
|
+
return false;
|
|
195
|
+
if (this.toolName === "subagent" || this.toolName === "subagent_wait")
|
|
196
|
+
return false;
|
|
197
|
+
this.setExpanded(!this.expanded);
|
|
198
|
+
this.ui.requestRender();
|
|
199
|
+
return true;
|
|
186
200
|
}
|
|
187
201
|
// lunr: consecutive same-tool grouping — exposes the tool name so the caller
|
|
188
202
|
// can detect adjacency.
|
|
@@ -205,6 +219,12 @@ export class ToolExecutionComponent extends Container {
|
|
|
205
219
|
this.applyGroupPadding();
|
|
206
220
|
this.invalidate();
|
|
207
221
|
}
|
|
222
|
+
// lunr: same-name run link so a later card can hoist earlier error bodies
|
|
223
|
+
// under the last leaf instead of splitting the tree.
|
|
224
|
+
linkGroupNext(next) {
|
|
225
|
+
this.groupNext = next;
|
|
226
|
+
next.groupPrev = this;
|
|
227
|
+
}
|
|
208
228
|
applyGroupPadding() {
|
|
209
229
|
const top = this.groupContinuation ? 0 : 1;
|
|
210
230
|
const bottom = this.groupFollowed ? 0 : 1;
|
|
@@ -217,12 +237,49 @@ export class ToolExecutionComponent extends Container {
|
|
|
217
237
|
this.callRendererComponent.setPaddingBottom(bottom);
|
|
218
238
|
}
|
|
219
239
|
}
|
|
220
|
-
|
|
221
|
-
return (this.
|
|
222
|
-
this.
|
|
223
|
-
!this.isPartial &&
|
|
240
|
+
shouldHideGroupedErrorBody() {
|
|
241
|
+
return (Boolean(this.result?.isError) &&
|
|
242
|
+
this.groupFollowed &&
|
|
224
243
|
!this.expanded &&
|
|
225
|
-
!this.
|
|
244
|
+
!this.isPartial &&
|
|
245
|
+
this.getRenderShell() === "default" &&
|
|
246
|
+
this.toolName !== "subagent" &&
|
|
247
|
+
this.toolName !== "subagent_wait");
|
|
248
|
+
}
|
|
249
|
+
shouldSkipCompactResult() {
|
|
250
|
+
if (this.result === undefined || this.isPartial || this.expanded) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
// lunr: collapsed mid-group errors stay header-only so the same-name
|
|
254
|
+
// tree is not split; the last card hoists those bodies underneath.
|
|
255
|
+
if (this.result.isError) {
|
|
256
|
+
return this.shouldHideGroupedErrorBody();
|
|
257
|
+
}
|
|
258
|
+
return this.getRenderShell() === "default";
|
|
259
|
+
}
|
|
260
|
+
formatHoistedGroupErrors() {
|
|
261
|
+
if (this.groupFollowed || this.expanded)
|
|
262
|
+
return undefined;
|
|
263
|
+
const texts = [];
|
|
264
|
+
let prev = this.groupPrev;
|
|
265
|
+
while (prev) {
|
|
266
|
+
if (prev.shouldHideGroupedErrorBody()) {
|
|
267
|
+
const output = prev.getTextOutput().trim();
|
|
268
|
+
if (output)
|
|
269
|
+
texts.unshift(output);
|
|
270
|
+
}
|
|
271
|
+
prev = prev.groupPrev;
|
|
272
|
+
}
|
|
273
|
+
return texts.length > 0 ? `\n${texts.join("\n")}` : undefined;
|
|
274
|
+
}
|
|
275
|
+
refreshGroupTail() {
|
|
276
|
+
let next = this.groupNext;
|
|
277
|
+
while (next) {
|
|
278
|
+
const card = next;
|
|
279
|
+
next = next.groupNext;
|
|
280
|
+
if (!next)
|
|
281
|
+
card.updateDisplay();
|
|
282
|
+
}
|
|
226
283
|
}
|
|
227
284
|
setShowImages(show) {
|
|
228
285
|
this.showImages = show;
|
|
@@ -330,6 +387,11 @@ export class ToolExecutionComponent extends Container {
|
|
|
330
387
|
}
|
|
331
388
|
}
|
|
332
389
|
}
|
|
390
|
+
const hoisted = this.formatHoistedGroupErrors();
|
|
391
|
+
if (hoisted) {
|
|
392
|
+
renderContainer.addChild(new Text(theme.fg("toolOutput", hoisted), 0, 0));
|
|
393
|
+
hasContent = true;
|
|
394
|
+
}
|
|
333
395
|
}
|
|
334
396
|
}
|
|
335
397
|
else {
|
|
@@ -374,23 +436,28 @@ export class ToolExecutionComponent extends Container {
|
|
|
374
436
|
return getRenderedTextOutput(this.result, this.showImages);
|
|
375
437
|
}
|
|
376
438
|
formatToolExecution() {
|
|
377
|
-
const
|
|
439
|
+
const hideGroupedErrorBody = Boolean(this.result?.isError && this.groupFollowed && !this.expanded);
|
|
440
|
+
const compact = !this.isPartial && !this.expanded && (!this.result?.isError || hideGroupedErrorBody);
|
|
378
441
|
let text = formatGroupedCall({
|
|
379
442
|
role: toolGroupRole(this.groupContinuation, this.groupFollowed),
|
|
380
443
|
compact,
|
|
444
|
+
tree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),
|
|
381
445
|
dot: this.getStatusDot(),
|
|
382
446
|
title: theme.fg("toolTitle", theme.bold(this.toolName)),
|
|
383
447
|
});
|
|
384
|
-
if (compact) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
448
|
+
if (!compact) {
|
|
449
|
+
const content = JSON.stringify(this.args, null, 2);
|
|
450
|
+
if (content) {
|
|
451
|
+
text += `\n\n${content}`;
|
|
452
|
+
}
|
|
453
|
+
const output = this.getTextOutput();
|
|
454
|
+
if (output) {
|
|
455
|
+
text += `\n${output}`;
|
|
456
|
+
}
|
|
390
457
|
}
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
393
|
-
text +=
|
|
458
|
+
const hoisted = this.formatHoistedGroupErrors();
|
|
459
|
+
if (hoisted) {
|
|
460
|
+
text += hoisted;
|
|
394
461
|
}
|
|
395
462
|
return text;
|
|
396
463
|
}
|
|
@@ -398,6 +465,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
398
465
|
/** Collapse facing pad when `next` is appended after a same-name tool card. */
|
|
399
466
|
export function applySameToolGrouping(previous, next) {
|
|
400
467
|
if (previous && previous.getToolName() === next.getToolName()) {
|
|
468
|
+
previous.linkGroupNext(next);
|
|
401
469
|
previous.setGroupFollowed(true);
|
|
402
470
|
next.setGroupContinuation(true);
|
|
403
471
|
}
|
|
@@ -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,EACN,iBAAiB,EACjB,aAAa,IAAI,qBAAqB,EACtC,aAAa,EACb,aAAa,GACb,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,UAAU,CAAM;IAChB,WAAW,CAAO;IAClB,mBAAmB,CAAY;IACvC,yEAAyE;IACzE,+EAA+E;IACvE,SAAS,CAAS;IAClB,qBAAqB,CAAa;IAClC,uBAAuB,CAAa;IACpC,aAAa,GAAQ,EAAE,CAAC;IACxB,eAAe,GAAY,EAAE,CAAC;IAC9B,YAAY,G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AC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD;AAED,+EAA+E;AAC/E,MAAM,UAAU,qBAAqB,CACpC,QAA4C,EAC5C,IAA4B,EACrB;IACP,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QAC/D,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;AAAA,CACD","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@ashx-j/lunr-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport {\n\tformatGroupedCall,\n\tgetTextOutput as getRenderedTextOutput,\n\ttoolGroupRole,\n\ttoolStatusDot,\n} from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.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\t// lunr: top spacer kept as a field so consecutive same-tool calls can be\n\t// grouped into one continuous background by zeroing it (setGroupContinuation).\n\tprivate topSpacer: Spacer;\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\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\tprivate groupContinuation = false;\n\tprivate groupFollowed = 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.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.topSpacer = new Spacer(1);\n\t\tthis.addChild(this.topSpacer);\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\t// lunr: default Box(1, 1). Same-name neighbors collapse facing pad only\n\t\t// (setGroupContinuation / setGroupFollowed); mixed and lone cards keep air.\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 getRenderContext(lastComponent: Component | undefined): 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\trequestRender: () => {\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\tresult: this.result,\n\t\t\tgroupRole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t};\n\t}\n\n\tprivate getStatusDot(): string {\n\t\tconst state = this.isPartial ? \"pending\" : this.result?.isError ? \"error\" : \"success\";\n\t\treturn toolStatusDot(state, theme);\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(\n\t\t\tformatGroupedCall({\n\t\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\t\tcompact: !this.isPartial && !this.expanded && !this.result?.isError,\n\t\t\t\tdot: this.getStatusDot(),\n\t\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\t}),\n\t\t\t0,\n\t\t\t0,\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\t// lunr: consecutive same-tool grouping — exposes the tool name so the caller\n\t// can detect adjacency.\n\tgetToolName(): string {\n\t\treturn this.toolName;\n\t}\n\n\t// lunr: consecutive same-tool grouping — continuation calls hide the top\n\t// spacer and top box pad so adjacent same-bg boxes read as one continuous\n\t// background; the last card in a run keeps its bottom pad.\n\tsetGroupContinuation(on: boolean): void {\n\t\tthis.groupContinuation = on;\n\t\tthis.topSpacer.setLines(on ? 0 : 1);\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: previous card in a same-name run drops its bottom pad so the next\n\t// header sits flush. Singletons and mixed neighbors keep paddingBottom = 1.\n\tsetGroupFollowed(on: boolean): void {\n\t\tthis.groupFollowed = on;\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\tprivate applyGroupPadding(): void {\n\t\tconst top = this.groupContinuation ? 0 : 1;\n\t\tconst bottom = this.groupFollowed ? 0 : 1;\n\t\tthis.contentBox.setPaddingTop(top);\n\t\tthis.contentBox.setPaddingBottom(bottom);\n\t\tthis.contentText.setPaddingTop(top);\n\t\tthis.contentText.setPaddingBottom(bottom);\n\t\tif (this.getRenderShell() === \"self\" && this.callRendererComponent instanceof Box) {\n\t\t\tthis.callRendererComponent.setPaddingTop(top);\n\t\t\tthis.callRendererComponent.setPaddingBottom(bottom);\n\t\t}\n\t}\n\n\tprivate shouldSkipCompactResult(): boolean {\n\t\treturn (\n\t\t\tthis.getRenderShell() === \"default\" &&\n\t\t\tthis.result !== undefined &&\n\t\t\t!this.isPartial &&\n\t\t\t!this.expanded &&\n\t\t\t!this.result.isError\n\t\t);\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\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tif (!this.groupContinuation) {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", 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 skipCompactBody = this.shouldSkipCompactResult();\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tif (!skipCompactBody) {\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} 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\tif (!skipCompactBody) {\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} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t\t}\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\n\t\tthis.applyGroupPadding();\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst compact = !this.isPartial && !this.expanded && !this.result?.isError;\n\t\tlet text = formatGroupedCall({\n\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\tcompact,\n\t\t\tdot: this.getStatusDot(),\n\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t});\n\t\tif (compact) {\n\t\t\treturn text;\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\n/** Collapse facing pad when `next` is appended after a same-name tool card. */\nexport function applySameToolGrouping(\n\tprevious: ToolExecutionComponent | undefined,\n\tnext: ToolExecutionComponent,\n): void {\n\tif (previous && previous.getToolName() === next.getToolName()) {\n\t\tprevious.setGroupFollowed(true);\n\t\tnext.setGroupContinuation(true);\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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AAC;QAC7B,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;AAAA,CACD","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@ashx-j/lunr-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport {\n\tformatGroupedCall,\n\tgetTextOutput as getRenderedTextOutput,\n\ttoolGroupRole,\n\ttoolGroupTree,\n\ttoolStatusDot,\n} from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.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\t// lunr: top spacer kept as a field so consecutive same-tool calls can be\n\t// grouped into one continuous background by zeroing it (setGroupContinuation).\n\tprivate topSpacer: Spacer;\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\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\tprivate groupContinuation = false;\n\tprivate groupFollowed = false;\n\tprivate groupPrev?: ToolExecutionComponent;\n\tprivate groupNext?: ToolExecutionComponent;\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.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.topSpacer = new Spacer(1);\n\t\tthis.addChild(this.topSpacer);\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\t// lunr: default Box(1, 1). Same-name neighbors collapse facing pad only\n\t\t// (setGroupContinuation / setGroupFollowed); mixed and lone cards keep air.\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 getRenderContext(lastComponent: Component | undefined): 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\trequestRender: () => {\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\tresult: this.result,\n\t\t\tgroupRole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t};\n\t}\n\n\tprivate getStatusDot(): string {\n\t\tconst state = this.isPartial ? \"pending\" : this.result?.isError ? \"error\" : \"success\";\n\t\treturn toolStatusDot(state, theme);\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(\n\t\t\tformatGroupedCall({\n\t\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\t\tcompact: !this.isPartial && !this.expanded && !this.result?.isError,\n\t\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\t\tdot: this.getStatusDot(),\n\t\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t\t}),\n\t\t\t0,\n\t\t\t0,\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.refreshGroupTail();\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\tthis.refreshGroupTail();\n\t}\n\n\thandleClick(_localY: number, _width: number): boolean {\n\t\tif (this.isPartial) return false;\n\t\tif (this.toolName === \"subagent\" || this.toolName === \"subagent_wait\") return false;\n\t\tthis.setExpanded(!this.expanded);\n\t\tthis.ui.requestRender();\n\t\treturn true;\n\t}\n\n\t// lunr: consecutive same-tool grouping — exposes the tool name so the caller\n\t// can detect adjacency.\n\tgetToolName(): string {\n\t\treturn this.toolName;\n\t}\n\n\t// lunr: consecutive same-tool grouping — continuation calls hide the top\n\t// spacer and top box pad so adjacent same-bg boxes read as one continuous\n\t// background; the last card in a run keeps its bottom pad.\n\tsetGroupContinuation(on: boolean): void {\n\t\tthis.groupContinuation = on;\n\t\tthis.topSpacer.setLines(on ? 0 : 1);\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: previous card in a same-name run drops its bottom pad so the next\n\t// header sits flush. Singletons and mixed neighbors keep paddingBottom = 1.\n\tsetGroupFollowed(on: boolean): void {\n\t\tthis.groupFollowed = on;\n\t\tthis.applyGroupPadding();\n\t\tthis.invalidate();\n\t}\n\n\t// lunr: same-name run link so a later card can hoist earlier error bodies\n\t// under the last leaf instead of splitting the tree.\n\tlinkGroupNext(next: ToolExecutionComponent): void {\n\t\tthis.groupNext = next;\n\t\tnext.groupPrev = this;\n\t}\n\n\tprivate applyGroupPadding(): void {\n\t\tconst top = this.groupContinuation ? 0 : 1;\n\t\tconst bottom = this.groupFollowed ? 0 : 1;\n\t\tthis.contentBox.setPaddingTop(top);\n\t\tthis.contentBox.setPaddingBottom(bottom);\n\t\tthis.contentText.setPaddingTop(top);\n\t\tthis.contentText.setPaddingBottom(bottom);\n\t\tif (this.getRenderShell() === \"self\" && this.callRendererComponent instanceof Box) {\n\t\t\tthis.callRendererComponent.setPaddingTop(top);\n\t\t\tthis.callRendererComponent.setPaddingBottom(bottom);\n\t\t}\n\t}\n\n\tprivate shouldHideGroupedErrorBody(): boolean {\n\t\treturn (\n\t\t\tBoolean(this.result?.isError) &&\n\t\t\tthis.groupFollowed &&\n\t\t\t!this.expanded &&\n\t\t\t!this.isPartial &&\n\t\t\tthis.getRenderShell() === \"default\" &&\n\t\t\tthis.toolName !== \"subagent\" &&\n\t\t\tthis.toolName !== \"subagent_wait\"\n\t\t);\n\t}\n\n\tprivate shouldSkipCompactResult(): boolean {\n\t\tif (this.result === undefined || this.isPartial || this.expanded) {\n\t\t\treturn false;\n\t\t}\n\t\t// lunr: collapsed mid-group errors stay header-only so the same-name\n\t\t// tree is not split; the last card hoists those bodies underneath.\n\t\tif (this.result.isError) {\n\t\t\treturn this.shouldHideGroupedErrorBody();\n\t\t}\n\t\treturn this.getRenderShell() === \"default\";\n\t}\n\n\tprivate formatHoistedGroupErrors(): string | undefined {\n\t\tif (this.groupFollowed || this.expanded) return undefined;\n\t\tconst texts: string[] = [];\n\t\tlet prev = this.groupPrev;\n\t\twhile (prev) {\n\t\t\tif (prev.shouldHideGroupedErrorBody()) {\n\t\t\t\tconst output = prev.getTextOutput().trim();\n\t\t\t\tif (output) texts.unshift(output);\n\t\t\t}\n\t\t\tprev = prev.groupPrev;\n\t\t}\n\t\treturn texts.length > 0 ? `\\n${texts.join(\"\\n\")}` : undefined;\n\t}\n\n\tprivate refreshGroupTail(): void {\n\t\tlet next = this.groupNext;\n\t\twhile (next) {\n\t\t\tconst card = next;\n\t\t\tnext = next.groupNext;\n\t\t\tif (!next) card.updateDisplay();\n\t\t}\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\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tif (!this.groupContinuation) {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", 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 skipCompactBody = this.shouldSkipCompactResult();\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tif (!skipCompactBody) {\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} 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\tif (!skipCompactBody) {\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} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tif (!skipCompactBody) {\n\t\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst hoisted = this.formatHoistedGroupErrors();\n\t\t\t\tif (hoisted) {\n\t\t\t\t\trenderContainer.addChild(new Text(theme.fg(\"toolOutput\", hoisted), 0, 0));\n\t\t\t\t\thasContent = true;\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\n\t\tthis.applyGroupPadding();\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst hideGroupedErrorBody = Boolean(this.result?.isError && this.groupFollowed && !this.expanded);\n\t\tconst compact = !this.isPartial && !this.expanded && (!this.result?.isError || hideGroupedErrorBody);\n\t\tlet text = formatGroupedCall({\n\t\t\trole: toolGroupRole(this.groupContinuation, this.groupFollowed),\n\t\t\tcompact,\n\t\t\ttree: toolGroupTree({ expanded: this.expanded, isError: this.result?.isError }),\n\t\t\tdot: this.getStatusDot(),\n\t\t\ttitle: theme.fg(\"toolTitle\", theme.bold(this.toolName)),\n\t\t});\n\t\tif (!compact) {\n\t\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\t\tif (content) {\n\t\t\t\ttext += `\\n\\n${content}`;\n\t\t\t}\n\t\t\tconst output = this.getTextOutput();\n\t\t\tif (output) {\n\t\t\t\ttext += `\\n${output}`;\n\t\t\t}\n\t\t}\n\t\tconst hoisted = this.formatHoistedGroupErrors();\n\t\tif (hoisted) {\n\t\t\ttext += hoisted;\n\t\t}\n\t\treturn text;\n\t}\n}\n\n/** Collapse facing pad when `next` is appended after a same-name tool card. */\nexport function applySameToolGrouping(\n\tprevious: ToolExecutionComponent | undefined,\n\tnext: ToolExecutionComponent,\n): void {\n\tif (previous && previous.getToolName() === next.getToolName()) {\n\t\tprevious.linkGroupNext(next);\n\t\tprevious.setGroupFollowed(true);\n\t\tnext.setGroupContinuation(true);\n\t}\n}\n"]}
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* Interactive mode for the coding agent.
|
|
3
3
|
* Handles TUI rendering and user interaction, delegating business logic to AgentSession.
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
5
|
+
import { type ImageContent } from "@ashx-j/lunr-ai/compat";
|
|
6
6
|
import { type AgentSessionRuntime } from "../../core/agent-session-runtime.ts";
|
|
7
7
|
import type { InlineExtension } from "../../core/extensions/index.ts";
|
|
8
8
|
import { SessionManager } from "../../core/session-manager.ts";
|
|
9
|
+
type QueuedUserInput = {
|
|
10
|
+
text: string;
|
|
11
|
+
images?: ImageContent[];
|
|
12
|
+
};
|
|
9
13
|
export declare function formatResumeCommand(sessionManager: SessionManager): string | undefined;
|
|
10
14
|
/**
|
|
11
15
|
* Options for InteractiveMode initialization.
|
|
@@ -51,6 +55,8 @@ export declare class InteractiveMode {
|
|
|
51
55
|
private isInitialized;
|
|
52
56
|
private onInputCallback?;
|
|
53
57
|
private pendingUserInputs;
|
|
58
|
+
private stagedSubmitImages;
|
|
59
|
+
private fallbackImageAttachments;
|
|
54
60
|
private activeStatusIndicator;
|
|
55
61
|
private readonly idleStatus;
|
|
56
62
|
private workingMessage;
|
|
@@ -122,6 +128,9 @@ export declare class InteractiveMode {
|
|
|
122
128
|
init(): Promise<void>;
|
|
123
129
|
/** Wait until deferred builtins have attached (or were skipped). */
|
|
124
130
|
waitForDeferredBuiltins(): Promise<void>;
|
|
131
|
+
private planUsageTimer;
|
|
132
|
+
private startPlanUsagePolling;
|
|
133
|
+
private maybeNotifyCliUpdate;
|
|
125
134
|
/**
|
|
126
135
|
* Update terminal title with session name and cwd.
|
|
127
136
|
*/
|
|
@@ -251,6 +260,13 @@ export declare class InteractiveMode {
|
|
|
251
260
|
*/
|
|
252
261
|
private showExtensionError;
|
|
253
262
|
private setupKeyHandlers;
|
|
263
|
+
private writeClipboardImageFile;
|
|
264
|
+
private insertImageChip;
|
|
265
|
+
private takeSubmittedImages;
|
|
266
|
+
private consumeStagedSubmitImages;
|
|
267
|
+
private loadImageAttachments;
|
|
268
|
+
private restoreEditorDraft;
|
|
269
|
+
private restoreEditorFromTreeResult;
|
|
254
270
|
private handleClipboardPaste;
|
|
255
271
|
private setupEditorSubmitHandler;
|
|
256
272
|
/** Smooth streaming tick rate (~30 FPS). TUI already caps paints at 16ms. */
|
|
@@ -299,7 +315,7 @@ export declare class InteractiveMode {
|
|
|
299
315
|
private addCacheMissNotice;
|
|
300
316
|
renderInitialMessages(): void;
|
|
301
317
|
private renderProjectTrustWarningIfNeeded;
|
|
302
|
-
getUserInput(): Promise<
|
|
318
|
+
getUserInput(): Promise<QueuedUserInput>;
|
|
303
319
|
private rebuildChatFromMessages;
|
|
304
320
|
private handleCtrlC;
|
|
305
321
|
private handleCtrlD;
|
|
@@ -471,4 +487,5 @@ export declare class InteractiveMode {
|
|
|
471
487
|
private handleCompactCommand;
|
|
472
488
|
stop(): void;
|
|
473
489
|
}
|
|
490
|
+
export {};
|
|
474
491
|
//# sourceMappingURL=interactive-mode.d.ts.map
|