@code-yeongyu/senpi 2026.7.10-2 → 2026.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +3 -1
  3. package/dist/core/extensions/builtin/bash-timeout/timeout.js +2 -2
  4. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  5. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  6. package/dist/core/extensions/builtin/compaction/index.js +10 -1
  7. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  8. package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
  9. package/dist/core/extensions/builtin/goal/store.js +88 -3
  10. package/dist/core/extensions/builtin/goal/store.js.map +1 -1
  11. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +3 -0
  12. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -0
  13. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +83 -0
  14. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -0
  15. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  16. package/dist/core/extensions/builtin/prompt-preset/presets.js +6 -0
  17. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  18. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  19. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  20. package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
  21. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  22. package/dist/core/extensions/builtin/terminal/notify.d.ts +3 -3
  23. package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
  24. package/dist/core/extensions/builtin/terminal/notify.js +7 -4
  25. package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
  26. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +5 -3
  27. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
  28. package/dist/core/extensions/builtin/terminal/runtime-session.js +32 -16
  29. package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
  30. package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts +1 -1
  31. package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
  32. package/dist/core/extensions/builtin/terminal/tools/bash-output.js +10 -4
  33. package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
  34. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -1
  35. package/dist/core/extensions/builtin/todotools/tools/todowrite.js +5 -8
  36. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -1
  37. package/dist/core/extensions/runner.d.ts +1 -0
  38. package/dist/core/extensions/runner.d.ts.map +1 -1
  39. package/dist/core/extensions/runner.js +5 -0
  40. package/dist/core/extensions/runner.js.map +1 -1
  41. package/dist/core/extensions/types.d.ts +3 -1
  42. package/dist/core/extensions/types.d.ts.map +1 -1
  43. package/dist/core/extensions/types.js.map +1 -1
  44. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  45. package/dist/core/extensions/wrapper.js +22 -3
  46. package/dist/core/extensions/wrapper.js.map +1 -1
  47. package/dist/core/keybindings.d.ts +8 -3
  48. package/dist/core/keybindings.d.ts.map +1 -1
  49. package/dist/core/keybindings.js +7 -3
  50. package/dist/core/keybindings.js.map +1 -1
  51. package/dist/core/model-registry.d.ts.map +1 -1
  52. package/dist/core/model-registry.js +2 -0
  53. package/dist/core/model-registry.js.map +1 -1
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1 -0
  57. package/dist/index.js.map +1 -1
  58. package/dist/modes/interactive/components/custom-editor.js +1 -1
  59. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  60. package/dist/modes/interactive/components/login-dialog.d.ts +4 -0
  61. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  62. package/dist/modes/interactive/components/login-dialog.js +9 -2
  63. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  64. package/dist/modes/interactive/components/tool-execution-fallback.d.ts +6 -0
  65. package/dist/modes/interactive/components/tool-execution-fallback.d.ts.map +1 -0
  66. package/dist/modes/interactive/components/tool-execution-fallback.js +40 -0
  67. package/dist/modes/interactive/components/tool-execution-fallback.js.map +1 -0
  68. package/dist/modes/interactive/components/tool-execution-images.d.ts +23 -0
  69. package/dist/modes/interactive/components/tool-execution-images.d.ts.map +1 -0
  70. package/dist/modes/interactive/components/tool-execution-images.js +104 -0
  71. package/dist/modes/interactive/components/tool-execution-images.js.map +1 -0
  72. package/dist/modes/interactive/components/tool-execution-renderer.d.ts +28 -0
  73. package/dist/modes/interactive/components/tool-execution-renderer.d.ts.map +1 -0
  74. package/dist/modes/interactive/components/tool-execution-renderer.js +135 -0
  75. package/dist/modes/interactive/components/tool-execution-renderer.js.map +1 -0
  76. package/dist/modes/interactive/components/tool-execution-types.d.ts +23 -0
  77. package/dist/modes/interactive/components/tool-execution-types.d.ts.map +1 -0
  78. package/dist/modes/interactive/components/tool-execution-types.js +2 -0
  79. package/dist/modes/interactive/components/tool-execution-types.js.map +1 -0
  80. package/dist/modes/interactive/components/tool-execution.d.ts +13 -39
  81. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  82. package/dist/modes/interactive/components/tool-execution.js +51 -294
  83. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  84. package/dist/modes/interactive/components/tool-renderer-boundary.d.ts +17 -0
  85. package/dist/modes/interactive/components/tool-renderer-boundary.d.ts.map +1 -0
  86. package/dist/modes/interactive/components/tool-renderer-boundary.js +75 -0
  87. package/dist/modes/interactive/components/tool-renderer-boundary.js.map +1 -0
  88. package/dist/modes/interactive/components/tree-selector.d.ts +5 -0
  89. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  90. package/dist/modes/interactive/components/tree-selector.js +50 -17
  91. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  92. package/dist/modes/interactive/interactive-mode.d.ts +1 -2
  93. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  94. package/dist/modes/interactive/interactive-mode.js +44 -40
  95. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  96. package/dist/utils/clipboard-native.d.ts +1 -0
  97. package/dist/utils/clipboard-native.d.ts.map +1 -1
  98. package/dist/utils/clipboard-native.js.map +1 -1
  99. package/dist/utils/clipboard.d.ts +2 -0
  100. package/dist/utils/clipboard.d.ts.map +1 -1
  101. package/dist/utils/clipboard.js +13 -0
  102. package/dist/utils/clipboard.js.map +1 -1
  103. package/docs/extensions.md +139 -0
  104. package/docs/keybindings.md +1 -0
  105. package/docs/providers.md +3 -0
  106. package/docs/quickstart.md +1 -1
  107. package/docs/settings.md +1 -1
  108. package/docs/usage.md +1 -0
  109. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +3 -0
  110. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  111. package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/protocol.ts +7 -7
  112. package/node_modules/@code-yeongyu/senpi-codemode/src/completion/tool-bridge.ts +3 -0
  113. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +69 -8
  114. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +39 -13
  115. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/context-manager.ts +191 -148
  116. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker-entry.js +23 -0
  117. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker.ts +4 -175
  118. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/kernel-contract.ts +38 -0
  119. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/run-queue.ts +82 -0
  120. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-core.js +7 -3
  121. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-host.ts +117 -0
  122. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel-contract.ts +32 -0
  123. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel.ts +231 -199
  124. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/process.ts +119 -0
  125. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +237 -0
  126. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-contract.ts +22 -0
  127. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +214 -189
  128. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-process.ts +174 -0
  129. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-queue.ts +100 -0
  130. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-run.ts +98 -0
  131. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +205 -0
  132. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +208 -203
  133. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +215 -25
  134. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +1 -0
  135. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +2 -0
  136. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  137. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +2 -0
  138. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  139. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  140. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  141. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  142. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +82 -32
  143. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  144. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  145. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +4 -1
  146. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  147. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  148. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +5 -2
  149. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  150. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +3 -1
  151. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  152. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +29 -0
  153. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  154. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  155. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
  156. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  157. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  158. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +8 -3
  159. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  160. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  161. package/node_modules/@earendil-works/pi-ai/dist/compat.js +2 -1
  162. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  163. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +270 -21
  164. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  165. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  166. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +5 -1
  167. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  168. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +17 -0
  169. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
  170. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +17 -0
  171. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
  172. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.d.ts.map +1 -1
  173. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js +9 -6
  174. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js.map +1 -1
  175. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +92 -0
  176. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
  177. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +59 -1
  178. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
  179. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +18 -0
  180. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
  181. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +6 -0
  182. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
  183. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +38 -0
  184. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
  185. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +24 -0
  186. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
  187. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +66 -0
  188. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
  189. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +55 -1
  190. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
  191. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +5 -21
  192. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
  193. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +48 -65
  194. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  195. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +34 -0
  196. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  197. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +37 -3
  198. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  199. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +15 -1
  200. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  201. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  202. package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.d.ts +9 -0
  203. package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.d.ts.map +1 -0
  204. package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +36 -0
  205. package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js.map +1 -0
  206. package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.d.ts.map +1 -1
  207. package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +18 -5
  208. package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js.map +1 -1
  209. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  210. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  211. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  212. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +2 -1
  213. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  214. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -1
  215. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  216. package/node_modules/@earendil-works/pi-tui/dist/index.js +2 -1
  217. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  218. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
  219. package/node_modules/@earendil-works/pi-tui/dist/keys.js +6 -5
  220. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
  221. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -1
  222. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  223. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -9
  224. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  225. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +4 -0
  226. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -0
  227. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +18 -0
  228. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -0
  229. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  230. package/package.json +6 -6
@@ -1,72 +1,46 @@
1
- import type { AgentToolResult } from "@earendil-works/pi-agent-core";
2
1
  import { Container, type TUI } from "@earendil-works/pi-tui";
3
- import type { ToolDefinition } from "../../../core/extensions/types.ts";
2
+ import type { ToolDef } from "../../../core/tools/index.ts";
3
+ import type { ToolExecutionResult } from "./tool-execution-types.ts";
4
4
  export interface ToolExecutionOptions {
5
5
  showImages?: boolean;
6
6
  imageWidthCells?: number;
7
7
  }
8
- type ToolExecutionResult = Omit<AgentToolResult<unknown>, "details"> & {
9
- details?: unknown;
10
- isError: boolean;
11
- };
12
8
  export declare class ToolExecutionComponent extends Container {
13
- private cachedLines?;
14
- private cachedSignature?;
15
- private cachedWidth?;
16
- private contentBox;
17
- private contentText;
18
- private selfRenderContainer;
19
- private callRendererComponent?;
20
- private resultRendererComponent?;
21
- private rendererState;
22
- private imageComponents;
23
- private imageSpacers;
24
- private toolName;
25
- private toolCallId;
9
+ private readonly identity;
10
+ private readonly ui;
11
+ private readonly renderer;
12
+ private readonly images;
26
13
  private args;
27
14
  private expanded;
28
15
  private showImages;
29
16
  private imageWidthCells;
30
17
  private isPartial;
31
- private toolDefinition?;
32
- private builtInToolDefinition?;
33
- private ui;
34
- private cwd;
35
18
  private executionStarted;
36
19
  private argsComplete;
37
20
  private spinnerFrame?;
38
21
  private spinnerInterval?;
39
22
  private result?;
40
- private convertedImages;
41
- private hideComponent;
42
- constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolDefinition<any, any> | undefined, ui: TUI, cwd: string);
43
- private getCallRenderer;
44
- private getResultRenderer;
45
- private hasRendererDefinition;
46
- private getRenderShell;
47
- private getRenderContext;
48
- private createCallFallback;
49
- private createResultFallback;
50
- updateArgs(args: any): void;
23
+ private cachedLines?;
24
+ private cachedSignature?;
25
+ private cachedWidth?;
26
+ private lastDisplaySignature?;
27
+ constructor(toolName: string, toolCallId: string, args: unknown, options: ToolExecutionOptions | undefined, toolDefinition: ToolDef | undefined, ui: TUI, cwd: string);
28
+ updateArgs(args: unknown): void;
51
29
  markExecutionStarted(): void;
52
30
  setArgsComplete(): void;
53
31
  updateResult(result: ToolExecutionResult, isPartial?: boolean): void;
54
32
  stopAnimation(): void;
55
- private maybeConvertImagesForKitty;
56
33
  setExpanded(expanded: boolean): void;
57
34
  setShowImages(show: boolean): void;
58
35
  setImageWidthCells(width: number): void;
59
36
  invalidate(): void;
60
37
  render(width: number): string[];
61
- private lastDisplaySignature?;
62
38
  private updateDisplay;
63
- private getTextOutput;
64
- private formatToolExecution;
39
+ private createRenderState;
65
40
  private createRenderSignature;
66
41
  private updateSpinnerAnimation;
67
42
  private startSpinnerAnimation;
68
43
  private stopSpinnerAnimation;
69
44
  private invalidateRenderCache;
70
45
  }
71
- export {};
72
46
  //# sourceMappingURL=tool-execution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAuB,SAAS,EAAwC,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AAQ3F,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,KAAK,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,GAAG;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAwBF,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,WAAW,CAAC,CAAW;IAC/B,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,mBAAmB,CAAY;IACvC,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,UAA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ions } from "../../../core/tools/index.js";
3
- import { getTextOutput as getRenderedTextOutput } from "../../../core/tools/render-utils.js";
4
- import { stripAnsi } from "../../../utils/ansi.js";
5
- import { convertToPng } from "../../../utils/image-convert.js";
6
- import { theme } from "../theme/theme.js";
1
+ import { Container, Spacer } from "@earendil-works/pi-tui";
7
2
  import { createBoundedRenderSignature } from "./render-signature.js";
8
- const FALLBACK_STRING_MAX_LENGTH = 160;
9
- const FALLBACK_JSON_MAX_LENGTH = 2000;
3
+ import { ToolExecutionImages } from "./tool-execution-images.js";
4
+ import { ToolExecutionRenderer } from "./tool-execution-renderer.js";
10
5
  const PENDING_RENDER_FRAME_INTERVAL_MS = 80;
11
- function sanitizeFallbackString(value, maxLength = FALLBACK_STRING_MAX_LENGTH) {
12
- const sanitized = stripAnsi(value)
13
- .replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ")
14
- .replace(/\s+/g, " ")
15
- .trim();
16
- if (sanitized.length <= maxLength) {
17
- return sanitized;
18
- }
19
- return `${sanitized.slice(0, Math.max(0, maxLength - 3))}...`;
20
- }
21
- function sanitizeFallbackJsonValue(_key, value) {
22
- if (typeof value === "string") {
23
- return sanitizeFallbackString(value);
24
- }
25
- return value;
26
- }
27
6
  export class ToolExecutionComponent extends Container {
28
7
  constructor(toolName, toolCallId, args, options = {}, toolDefinition, ui, cwd) {
29
8
  super();
30
- this.rendererState = {};
31
- this.imageComponents = [];
32
- this.imageSpacers = [];
33
9
  this.expanded = false;
34
10
  this.isPartial = true;
35
11
  this.executionStarted = false;
36
12
  this.argsComplete = false;
37
- this.convertedImages = new Map();
38
- this.hideComponent = false;
39
- this.toolName = toolName;
40
- this.toolCallId = toolCallId;
13
+ this.identity = { toolName, toolCallId, cwd, toolDefinition };
41
14
  this.args = args;
42
- this.toolDefinition = toolDefinition;
43
- this.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName];
44
15
  this.showImages = options.showImages ?? true;
45
16
  this.imageWidthCells = options.imageWidthCells ?? 60;
46
17
  this.ui = ui;
47
- this.cwd = cwd;
18
+ const initialState = this.createRenderState();
19
+ this.renderer = new ToolExecutionRenderer(this.identity, initialState, () => {
20
+ this.invalidate();
21
+ this.ui.requestRender();
22
+ });
23
+ this.images = new ToolExecutionImages(() => {
24
+ this.invalidateRenderCache();
25
+ this.ui.requestRender();
26
+ });
48
27
  this.addChild(new Spacer(1));
49
- // Always create all shell variants. contentBox is used for default renderer-based composition.
50
- // selfRenderContainer is used when the tool renders its own framing.
51
- // contentText is reserved for generic fallback rendering when no tool definition exists.
52
- this.contentBox = new Box(1, 1, (text) => theme.bg("toolPendingBg", text));
53
- this.contentText = new Text("", 1, 1, (text) => theme.bg("toolPendingBg", text));
54
- this.selfRenderContainer = new Container();
55
- if (this.hasRendererDefinition()) {
56
- this.addChild(this.getRenderShell() === "self" ? this.selfRenderContainer : this.contentBox);
57
- }
58
- else {
59
- this.addChild(this.contentText);
60
- }
28
+ this.addChild(this.renderer);
29
+ this.addChild(this.images);
61
30
  this.updateSpinnerAnimation();
62
31
  this.updateDisplay();
63
32
  }
64
- getCallRenderer() {
65
- if (!this.builtInToolDefinition) {
66
- return this.toolDefinition?.renderCall;
67
- }
68
- if (!this.toolDefinition) {
69
- return this.builtInToolDefinition.renderCall;
70
- }
71
- return this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;
72
- }
73
- getResultRenderer() {
74
- if (!this.builtInToolDefinition) {
75
- return this.toolDefinition?.renderResult;
76
- }
77
- if (!this.toolDefinition) {
78
- return this.builtInToolDefinition.renderResult;
79
- }
80
- return this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;
81
- }
82
- hasRendererDefinition() {
83
- return this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;
84
- }
85
- getRenderShell() {
86
- if (!this.builtInToolDefinition) {
87
- return this.toolDefinition?.renderShell ?? "default";
88
- }
89
- if (!this.toolDefinition) {
90
- return this.builtInToolDefinition.renderShell ?? "default";
91
- }
92
- return this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? "default";
93
- }
94
- getRenderContext(lastComponent) {
95
- return {
96
- args: this.args,
97
- toolCallId: this.toolCallId,
98
- invalidate: () => {
99
- this.invalidate();
100
- this.ui.requestRender();
101
- },
102
- lastComponent,
103
- state: this.rendererState,
104
- cwd: this.cwd,
105
- executionStarted: this.executionStarted,
106
- argsComplete: this.argsComplete,
107
- isPartial: this.isPartial,
108
- expanded: this.expanded,
109
- showImages: this.showImages,
110
- isError: this.result?.isError ?? false,
111
- spinnerFrame: this.spinnerFrame,
112
- };
113
- }
114
- createCallFallback() {
115
- return new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0);
116
- }
117
- createResultFallback() {
118
- const output = this.getTextOutput();
119
- if (!output) {
120
- return undefined;
121
- }
122
- return new Text(theme.fg("toolOutput", output), 0, 0);
123
- }
124
33
  updateArgs(args) {
125
34
  this.args = args;
126
35
  this.lastDisplaySignature = undefined;
@@ -142,42 +51,17 @@ export class ToolExecutionComponent extends Container {
142
51
  updateResult(result, isPartial = false) {
143
52
  this.result = result;
144
53
  this.isPartial = isPartial;
145
- if (!isPartial) {
54
+ if (!isPartial)
146
55
  this.argsComplete = true;
147
- }
148
56
  this.lastDisplaySignature = undefined;
149
57
  this.updateSpinnerAnimation();
150
58
  this.updateDisplay();
151
- this.maybeConvertImagesForKitty();
59
+ this.images.updateResult(result);
60
+ this.invalidateRenderCache();
152
61
  }
153
62
  stopAnimation() {
154
63
  this.stopSpinnerAnimation();
155
64
  }
156
- maybeConvertImagesForKitty() {
157
- const caps = getCapabilities();
158
- if (caps.images !== "kitty")
159
- return;
160
- if (!this.result)
161
- return;
162
- const imageBlocks = this.result.content.filter((c) => c.type === "image");
163
- for (let i = 0; i < imageBlocks.length; i++) {
164
- const img = imageBlocks[i];
165
- if (!img.data || !img.mimeType)
166
- continue;
167
- if (img.mimeType === "image/png")
168
- continue;
169
- if (this.convertedImages.has(i))
170
- continue;
171
- const index = i;
172
- convertToPng(img.data, img.mimeType).then((converted) => {
173
- if (converted) {
174
- this.convertedImages.set(index, converted);
175
- this.updateDisplay();
176
- this.ui.requestRender();
177
- }
178
- });
179
- }
180
- }
181
65
  setExpanded(expanded) {
182
66
  this.expanded = expanded;
183
67
  this.updateDisplay();
@@ -197,34 +81,17 @@ export class ToolExecutionComponent extends Container {
197
81
  this.updateDisplay();
198
82
  }
199
83
  render(width) {
200
- if (this.hideComponent) {
201
- return [];
202
- }
203
84
  const signature = this.createRenderSignature();
204
85
  if (this.cachedLines && this.cachedWidth === width && this.cachedSignature === signature) {
205
86
  return [...this.cachedLines];
206
87
  }
207
88
  let lines;
208
- if (this.hasRendererDefinition() && this.getRenderShell() === "self") {
209
- const contentLines = this.selfRenderContainer.render(width);
210
- if (contentLines.length === 0 && this.imageComponents.length === 0) {
89
+ if (this.renderer.hasRendererDefinition && this.renderer.renderShell === "self") {
90
+ const contentLines = this.renderer.render(width);
91
+ const imageLines = this.images.render(width);
92
+ if (contentLines.length === 0 && imageLines.length === 0)
211
93
  return [];
212
- }
213
- lines = [];
214
- if (contentLines.length > 0) {
215
- lines.push("");
216
- lines.push(...contentLines);
217
- }
218
- for (let i = 0; i < this.imageComponents.length; i++) {
219
- const spacer = this.imageSpacers[i];
220
- if (spacer) {
221
- lines.push(...spacer.render(width));
222
- }
223
- const imageComponent = this.imageComponents[i];
224
- if (imageComponent) {
225
- lines.push(...imageComponent.render(width));
226
- }
227
- }
94
+ lines = contentLines.length > 0 ? ["", ...contentLines, ...imageLines] : imageLines;
228
95
  }
229
96
  else {
230
97
  lines = super.render(width);
@@ -236,158 +103,49 @@ export class ToolExecutionComponent extends Container {
236
103
  }
237
104
  updateDisplay() {
238
105
  const displaySignature = this.createRenderSignature();
239
- if (this.lastDisplaySignature === displaySignature) {
106
+ if (this.lastDisplaySignature === displaySignature)
240
107
  return;
241
- }
242
108
  this.lastDisplaySignature = displaySignature;
243
109
  this.invalidateRenderCache();
244
- const bgFn = this.isPartial
245
- ? (text) => theme.bg("toolPendingBg", text)
246
- : this.result?.isError
247
- ? (text) => theme.bg("toolErrorBg", text)
248
- : (text) => theme.bg("toolSuccessBg", text);
249
- let hasContent = false;
250
- this.hideComponent = false;
251
- if (this.hasRendererDefinition()) {
252
- const renderContainer = this.getRenderShell() === "self" ? this.selfRenderContainer : this.contentBox;
253
- if (renderContainer instanceof Box) {
254
- renderContainer.setBgFn(bgFn);
255
- }
256
- renderContainer.detachAll();
257
- const callRenderer = this.getCallRenderer();
258
- if (!callRenderer) {
259
- renderContainer.addChild(this.createCallFallback());
260
- hasContent = true;
261
- }
262
- else {
263
- try {
264
- const component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));
265
- this.callRendererComponent = component;
266
- renderContainer.addChild(component);
267
- hasContent = true;
268
- }
269
- catch {
270
- this.callRendererComponent = undefined;
271
- renderContainer.addChild(this.createCallFallback());
272
- hasContent = true;
273
- }
274
- }
275
- if (this.result) {
276
- const resultRenderer = this.getResultRenderer();
277
- if (!resultRenderer) {
278
- const component = this.createResultFallback();
279
- if (component) {
280
- renderContainer.addChild(component);
281
- hasContent = true;
282
- }
283
- }
284
- else {
285
- try {
286
- const agentToolResult = {
287
- content: this.result.content,
288
- details: this.result.details,
289
- };
290
- const component = resultRenderer(agentToolResult, { expanded: this.expanded, isPartial: this.isPartial }, theme, this.getRenderContext(this.resultRendererComponent));
291
- this.resultRendererComponent = component;
292
- renderContainer.addChild(component);
293
- hasContent = true;
294
- }
295
- catch {
296
- this.resultRendererComponent = undefined;
297
- const component = this.createResultFallback();
298
- if (component) {
299
- renderContainer.addChild(component);
300
- hasContent = true;
301
- }
302
- }
303
- }
304
- }
305
- }
306
- else {
307
- this.contentText.setCustomBgFn(bgFn);
308
- this.contentText.setText(this.formatToolExecution());
309
- hasContent = true;
310
- }
311
- for (const img of this.imageComponents) {
312
- this.removeChild(img);
313
- }
314
- this.imageComponents = [];
315
- for (const spacer of this.imageSpacers) {
316
- this.removeChild(spacer);
317
- }
318
- this.imageSpacers = [];
319
- if (this.result) {
320
- const imageBlocks = this.result.content.filter((c) => c.type === "image");
321
- const caps = getCapabilities();
322
- for (let i = 0; i < imageBlocks.length; i++) {
323
- const img = imageBlocks[i];
324
- if (caps.images && this.showImages && img.data && img.mimeType) {
325
- const converted = this.convertedImages.get(i);
326
- const imageData = converted?.data ?? img.data;
327
- const imageMimeType = converted?.mimeType ?? img.mimeType;
328
- if (caps.images === "kitty" && imageMimeType !== "image/png")
329
- continue;
330
- const spacer = new Spacer(1);
331
- this.addChild(spacer);
332
- this.imageSpacers.push(spacer);
333
- const imageComponent = new Image(imageData, imageMimeType, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: this.imageWidthCells });
334
- this.imageComponents.push(imageComponent);
335
- this.addChild(imageComponent);
336
- }
337
- }
338
- }
339
- if (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {
340
- this.hideComponent = true;
341
- }
342
- }
343
- getTextOutput() {
344
- return getRenderedTextOutput(this.result, this.showImages);
345
- }
346
- formatToolExecution() {
347
- let text = theme.fg("toolTitle", theme.bold(sanitizeFallbackString(this.toolName)));
348
- const content = JSON.stringify(this.args, sanitizeFallbackJsonValue, 2);
349
- if (content) {
350
- const boundedContent = content.length > FALLBACK_JSON_MAX_LENGTH
351
- ? `${content.slice(0, FALLBACK_JSON_MAX_LENGTH - 3)}...`
352
- : content;
353
- text += `\n\n${boundedContent}`;
354
- }
355
- const output = this.getTextOutput();
356
- if (output) {
357
- text += `\n${sanitizeFallbackString(output, FALLBACK_JSON_MAX_LENGTH)}`;
358
- }
359
- return text;
110
+ const state = this.createRenderState();
111
+ this.renderer.update(state);
112
+ this.images.updateOptions({
113
+ showImages: state.showImages,
114
+ maxWidthCells: this.imageWidthCells,
115
+ showRendererFallback: this.renderer.hasResultRenderer,
116
+ });
360
117
  }
361
- createRenderSignature() {
362
- return createBoundedRenderSignature({
118
+ createRenderState() {
119
+ return {
363
120
  args: this.args,
364
- argsComplete: this.argsComplete,
365
121
  executionStarted: this.executionStarted,
366
- expanded: this.expanded,
367
- hideComponent: this.hideComponent,
368
- imageWidthCells: this.imageWidthCells,
122
+ argsComplete: this.argsComplete,
369
123
  isPartial: this.isPartial,
370
- result: this.result,
124
+ expanded: this.expanded,
371
125
  showImages: this.showImages,
372
126
  spinnerFrame: this.spinnerFrame,
373
- toolCallId: this.toolCallId,
374
- toolName: this.toolName,
127
+ result: this.result,
128
+ };
129
+ }
130
+ createRenderSignature() {
131
+ return createBoundedRenderSignature({
132
+ ...this.createRenderState(),
133
+ imageWidthCells: this.imageWidthCells,
134
+ toolCallId: this.identity.toolCallId,
135
+ toolName: this.identity.toolName,
375
136
  });
376
137
  }
377
138
  updateSpinnerAnimation() {
378
- const isStreamingArgs = !this.argsComplete &&
379
- (this.toolName === "edit" || this.toolName === "write" || this.toolName === "apply_patch");
380
- const isPartialTask = this.isPartial && this.toolName === "task" && this.result !== undefined;
381
- if (isStreamingArgs || isPartialTask) {
139
+ const isStreamingArgs = !this.argsComplete && ["edit", "write", "apply_patch"].includes(this.identity.toolName);
140
+ const isPartialTask = this.isPartial && this.identity.toolName === "task" && this.result !== undefined;
141
+ if (isStreamingArgs || isPartialTask)
382
142
  this.startSpinnerAnimation();
383
- return;
384
- }
385
- this.stopSpinnerAnimation();
143
+ else
144
+ this.stopSpinnerAnimation();
386
145
  }
387
146
  startSpinnerAnimation() {
388
- if (this.spinnerInterval) {
147
+ if (this.spinnerInterval)
389
148
  return;
390
- }
391
149
  this.spinnerInterval = setInterval(() => {
392
150
  this.spinnerFrame = ((this.spinnerFrame ?? -1) + 1) % 10;
393
151
  this.invalidateRenderCache();
@@ -397,9 +155,8 @@ export class ToolExecutionComponent extends Container {
397
155
  this.spinnerInterval.unref?.();
398
156
  }
399
157
  stopSpinnerAnimation() {
400
- if (!this.spinnerInterval) {
158
+ if (!this.spinnerInterval)
401
159
  return;
402
- }
403
160
  clearInterval(this.spinnerInterval);
404
161
  this.spinnerInterval = undefined;
405
162
  this.spinnerFrame = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAkB,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,wBAAwB,CAAC;AAExH,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAYrE,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AAE5C,SAAS,sBAAsB,CAAC,KAAa,EAAE,SAAS,GAAG,0BAA0B;IACpF,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC;SAChC,OAAO,CAAC,gCAAgC,EAAE,GAAG,CAAC;SAC9C,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;IACT,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAY,EAAE,KAAc;IAC9D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,sBAAsB,CAAC,KAA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,SAAS,CAAC;QAC9B,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC9B,CAAC;IAEO,qBAAqB;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { createBoundedRenderSignature } from \"./render-signature.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\ntype ToolExecutionResult = Omit<AgentToolResult<unknown>, \"details\"> & {\n\tdetails?: unknown;\n\tisError: boolean;\n};\n\nconst FALLBACK_STRING_MAX_LENGTH = 160;\nconst FALLBACK_JSON_MAX_LENGTH = 2000;\nconst PENDING_RENDER_FRAME_INTERVAL_MS = 80;\n\nfunction sanitizeFallbackString(value: string, maxLength = FALLBACK_STRING_MAX_LENGTH): string {\n\tconst sanitized = stripAnsi(value)\n\t\t.replace(/[\\u0000-\\u001f\\u007f-\\u009f]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\tif (sanitized.length <= maxLength) {\n\t\treturn sanitized;\n\t}\n\treturn `${sanitized.slice(0, Math.max(0, maxLength - 3))}...`;\n}\n\nfunction sanitizeFallbackJsonValue(_key: string, value: unknown): unknown {\n\tif (typeof value === \"string\") {\n\t\treturn sanitizeFallbackString(value);\n\t}\n\treturn value;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate cachedLines?: string[];\n\tprivate cachedSignature?: string;\n\tprivate cachedWidth?: number;\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate spinnerFrame?: number;\n\tprivate spinnerInterval?: NodeJS.Timeout;\n\tprivate result?: ToolExecutionResult;\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateSpinnerAnimation();\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\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\tspinnerFrame: this.spinnerFrame,\n\t\t};\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.toolName)), 0, 0);\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.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(result: ToolExecutionResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tif (!isPartial) {\n\t\t\tthis.argsComplete = true;\n\t\t}\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tstopAnimation(): void {\n\t\tthis.stopSpinnerAnimation();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tthis.invalidateRenderCache();\n\t\tsuper.invalidate();\n\t\tthis.lastDisplaySignature = undefined;\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\t\tconst signature = this.createRenderSignature();\n\t\tif (this.cachedLines && this.cachedWidth === width && this.cachedSignature === signature) {\n\t\t\treturn [...this.cachedLines];\n\t\t}\n\n\t\tlet lines: string[];\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\tlines = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tlines.push(\"\");\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} else {\n\t\t\tlines = super.render(width);\n\t\t}\n\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedSignature = signature;\n\t\tthis.cachedLines = [...lines];\n\t\treturn lines;\n\t}\n\n\tprivate lastDisplaySignature?: string;\n\n\tprivate updateDisplay(): void {\n\t\tconst displaySignature = this.createRenderSignature();\n\t\tif (this.lastDisplaySignature === displaySignature) {\n\t\t\treturn;\n\t\t}\n\t\tthis.lastDisplaySignature = displaySignature;\n\t\tthis.invalidateRenderCache();\n\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.detachAll();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst agentToolResult = {\n\t\t\t\t\t\t\tcontent: this.result.content,\n\t\t\t\t\t\t\tdetails: this.result.details,\n\t\t\t\t\t\t} satisfies AgentToolResult<unknown>;\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\tagentToolResult,\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = theme.fg(\"toolTitle\", theme.bold(sanitizeFallbackString(this.toolName)));\n\t\tconst content = JSON.stringify(this.args, sanitizeFallbackJsonValue, 2);\n\t\tif (content) {\n\t\t\tconst boundedContent =\n\t\t\t\tcontent.length > FALLBACK_JSON_MAX_LENGTH\n\t\t\t\t\t? `${content.slice(0, FALLBACK_JSON_MAX_LENGTH - 3)}...`\n\t\t\t\t\t: content;\n\t\t\ttext += `\\n\\n${boundedContent}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${sanitizeFallbackString(output, FALLBACK_JSON_MAX_LENGTH)}`;\n\t\t}\n\t\treturn text;\n\t}\n\n\tprivate createRenderSignature(): string {\n\t\treturn createBoundedRenderSignature({\n\t\t\targs: this.args,\n\t\t\targsComplete: this.argsComplete,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\texpanded: this.expanded,\n\t\t\thideComponent: this.hideComponent,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\tisPartial: this.isPartial,\n\t\t\tresult: this.result,\n\t\t\tshowImages: this.showImages,\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\ttoolName: this.toolName,\n\t\t});\n\t}\n\n\tprivate updateSpinnerAnimation(): void {\n\t\tconst isStreamingArgs =\n\t\t\t!this.argsComplete &&\n\t\t\t(this.toolName === \"edit\" || this.toolName === \"write\" || this.toolName === \"apply_patch\");\n\t\tconst isPartialTask = this.isPartial && this.toolName === \"task\" && this.result !== undefined;\n\t\tif (isStreamingArgs || isPartialTask) {\n\t\t\tthis.startSpinnerAnimation();\n\t\t\treturn;\n\t\t}\n\t\tthis.stopSpinnerAnimation();\n\t}\n\n\tprivate startSpinnerAnimation(): void {\n\t\tif (this.spinnerInterval) {\n\t\t\treturn;\n\t\t}\n\t\tthis.spinnerInterval = setInterval(() => {\n\t\t\tthis.spinnerFrame = ((this.spinnerFrame ?? -1) + 1) % 10;\n\t\t\tthis.invalidateRenderCache();\n\t\t\tthis.updateDisplay();\n\t\t\tthis.ui.requestRender();\n\t\t}, PENDING_RENDER_FRAME_INTERVAL_MS);\n\t\tthis.spinnerInterval.unref?.();\n\t}\n\n\tprivate stopSpinnerAnimation(): void {\n\t\tif (!this.spinnerInterval) {\n\t\t\treturn;\n\t\t}\n\t\tclearInterval(this.spinnerInterval);\n\t\tthis.spinnerInterval = undefined;\n\t\tthis.spinnerFrame = undefined;\n\t\tthis.invalidateRenderCache();\n\t}\n\n\tprivate invalidateRenderCache(): void {\n\t\tthis.cachedLines = undefined;\n\t\tthis.cachedSignature = undefined;\n\t\tthis.cachedWidth = undefined;\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,SAAS,EAAE,MAAM,EAAY,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAQrE,MAAM,gCAAgC,GAAG,EAAE,CAAC;AAE5C,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAoBpD,YACC,QAAgB,EAChB,UAAkB,EAClB,IAAa,EACb,OAAO,GAAyB,EAAE,EAClC,cAAmC,EACnC,EAAO,EACP,GAAW;QAEX,KAAK,EAAE,CAAC;QAvBD,aAAQ,GAAG,KAAK,CAAC;QAGjB,cAAS,GAAG,IAAI,CAAC;QACjB,qBAAgB,GAAG,KAAK,CAAC;QACzB,iBAAY,GAAG,KAAK,CAAC;QAmB5B,IAAI,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;QACrD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC9C,IAAI,CAA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AAC;;YAC9D,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAClC,CAAC;IAEO,qBAAqB;QAC5B,IAAI,IAAI,CAAC,eAAe;YAAE,OAAO;QACjC,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACvC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;YACzD,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,EAAE,gCAAgC,CAAC,CAAC;QACrC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC;IAChC,CAAC;IAEO,oBAAoB;QAC3B,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAO;QAClC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC9B,CAAC;IAEO,qBAAqB;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import { Container, Spacer, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDef } from \"../../../core/tools/index.ts\";\nimport { createBoundedRenderSignature } from \"./render-signature.ts\";\nimport { ToolExecutionImages } from \"./tool-execution-images.ts\";\nimport { ToolExecutionRenderer } from \"./tool-execution-renderer.ts\";\nimport type { ToolExecutionIdentity, ToolExecutionRenderState, ToolExecutionResult } from \"./tool-execution-types.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nconst PENDING_RENDER_FRAME_INTERVAL_MS = 80;\n\nexport class ToolExecutionComponent extends Container {\n\tprivate readonly identity: ToolExecutionIdentity;\n\tprivate readonly ui: TUI;\n\tprivate readonly renderer: ToolExecutionRenderer;\n\tprivate readonly images: ToolExecutionImages;\n\tprivate args: unknown;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate spinnerFrame?: number;\n\tprivate spinnerInterval?: NodeJS.Timeout;\n\tprivate result?: ToolExecutionResult;\n\tprivate cachedLines?: string[];\n\tprivate cachedSignature?: string;\n\tprivate cachedWidth?: number;\n\tprivate lastDisplaySignature?: string;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDef | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.identity = { toolName, toolCallId, cwd, toolDefinition };\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tconst initialState = this.createRenderState();\n\t\tthis.renderer = new ToolExecutionRenderer(this.identity, initialState, () => {\n\t\t\tthis.invalidate();\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t\tthis.images = new ToolExecutionImages(() => {\n\t\t\tthis.invalidateRenderCache();\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(this.renderer);\n\t\tthis.addChild(this.images);\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tupdateArgs(args: unknown): void {\n\t\tthis.args = args;\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(result: ToolExecutionResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tif (!isPartial) this.argsComplete = true;\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.images.updateResult(result);\n\t\tthis.invalidateRenderCache();\n\t}\n\n\tstopAnimation(): void {\n\t\tthis.stopSpinnerAnimation();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tthis.invalidateRenderCache();\n\t\tsuper.invalidate();\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst signature = this.createRenderSignature();\n\t\tif (this.cachedLines && this.cachedWidth === width && this.cachedSignature === signature) {\n\t\t\treturn [...this.cachedLines];\n\t\t}\n\n\t\tlet lines: string[];\n\t\tif (this.renderer.hasRendererDefinition && this.renderer.renderShell === \"self\") {\n\t\t\tconst contentLines = this.renderer.render(width);\n\t\t\tconst imageLines = this.images.render(width);\n\t\t\tif (contentLines.length === 0 && imageLines.length === 0) return [];\n\t\t\tlines = contentLines.length > 0 ? [\"\", ...contentLines, ...imageLines] : imageLines;\n\t\t} else {\n\t\t\tlines = super.render(width);\n\t\t}\n\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedSignature = signature;\n\t\tthis.cachedLines = [...lines];\n\t\treturn lines;\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst displaySignature = this.createRenderSignature();\n\t\tif (this.lastDisplaySignature === displaySignature) return;\n\t\tthis.lastDisplaySignature = displaySignature;\n\t\tthis.invalidateRenderCache();\n\t\tconst state = this.createRenderState();\n\t\tthis.renderer.update(state);\n\t\tthis.images.updateOptions({\n\t\t\tshowImages: state.showImages,\n\t\t\tmaxWidthCells: this.imageWidthCells,\n\t\t\tshowRendererFallback: this.renderer.hasResultRenderer,\n\t\t});\n\t}\n\n\tprivate createRenderState(): ToolExecutionRenderState {\n\t\treturn {\n\t\t\targs: this.args,\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\tspinnerFrame: this.spinnerFrame,\n\t\t\tresult: this.result,\n\t\t};\n\t}\n\n\tprivate createRenderSignature(): string {\n\t\treturn createBoundedRenderSignature({\n\t\t\t...this.createRenderState(),\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\ttoolCallId: this.identity.toolCallId,\n\t\t\ttoolName: this.identity.toolName,\n\t\t});\n\t}\n\n\tprivate updateSpinnerAnimation(): void {\n\t\tconst isStreamingArgs = !this.argsComplete && [\"edit\", \"write\", \"apply_patch\"].includes(this.identity.toolName);\n\t\tconst isPartialTask = this.isPartial && this.identity.toolName === \"task\" && this.result !== undefined;\n\t\tif (isStreamingArgs || isPartialTask) this.startSpinnerAnimation();\n\t\telse this.stopSpinnerAnimation();\n\t}\n\n\tprivate startSpinnerAnimation(): void {\n\t\tif (this.spinnerInterval) return;\n\t\tthis.spinnerInterval = setInterval(() => {\n\t\t\tthis.spinnerFrame = ((this.spinnerFrame ?? -1) + 1) % 10;\n\t\t\tthis.invalidateRenderCache();\n\t\t\tthis.updateDisplay();\n\t\t\tthis.ui.requestRender();\n\t\t}, PENDING_RENDER_FRAME_INTERVAL_MS);\n\t\tthis.spinnerInterval.unref?.();\n\t}\n\n\tprivate stopSpinnerAnimation(): void {\n\t\tif (!this.spinnerInterval) return;\n\t\tclearInterval(this.spinnerInterval);\n\t\tthis.spinnerInterval = undefined;\n\t\tthis.spinnerFrame = undefined;\n\t\tthis.invalidateRenderCache();\n\t}\n\n\tprivate invalidateRenderCache(): void {\n\t\tthis.cachedLines = undefined;\n\t\tthis.cachedSignature = undefined;\n\t\tthis.cachedWidth = undefined;\n\t}\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { Component } from "@earendil-works/pi-tui";
2
+ export declare function isComponent(value: unknown): value is Component;
3
+ export declare class ToolRendererBoundary implements Component {
4
+ private component;
5
+ private componentDisposed;
6
+ private fallback?;
7
+ private failed;
8
+ private onFailure;
9
+ constructor(component: Component, fallback: Component | undefined, onFailure: () => void);
10
+ render(width: number): string[];
11
+ invalidate(): void;
12
+ dispose(): void;
13
+ private fail;
14
+ private disposeComponent;
15
+ private renderFallback;
16
+ }
17
+ //# sourceMappingURL=tool-renderer-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-renderer-boundary.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-renderer-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAO9D;AAED,qBAAa,oBAAqB,YAAW,SAAS;IACrD,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAa;IAE9B,YAAY,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,IAAI,EAIvF;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB9B;IAED,UAAU,IAAI,IAAI,CASjB;IAED,OAAO,IAAI,IAAI,CAGd;IAED,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,cAAc;CAGtB"}