@caupulican/pi-adaptative 0.78.1 → 0.78.3

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 (101) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +14 -12
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +1 -1
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/agent-session.d.ts +1 -0
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +34 -12
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/extensions/types.d.ts +16 -1
  11. package/dist/core/extensions/types.d.ts.map +1 -1
  12. package/dist/core/extensions/types.js.map +1 -1
  13. package/dist/core/model-registry.d.ts.map +1 -1
  14. package/dist/core/model-registry.js +10 -0
  15. package/dist/core/model-registry.js.map +1 -1
  16. package/dist/core/model-resolver.d.ts.map +1 -1
  17. package/dist/core/model-resolver.js +1 -0
  18. package/dist/core/model-resolver.js.map +1 -1
  19. package/dist/core/prompt-templates.d.ts +3 -2
  20. package/dist/core/prompt-templates.d.ts.map +1 -1
  21. package/dist/core/prompt-templates.js +8 -3
  22. package/dist/core/prompt-templates.js.map +1 -1
  23. package/dist/core/provider-display-names.d.ts.map +1 -1
  24. package/dist/core/provider-display-names.js +1 -0
  25. package/dist/core/provider-display-names.js.map +1 -1
  26. package/dist/core/resource-loader.d.ts +5 -5
  27. package/dist/core/resource-loader.d.ts.map +1 -1
  28. package/dist/core/resource-loader.js +1 -9
  29. package/dist/core/resource-loader.js.map +1 -1
  30. package/dist/core/session-manager.d.ts.map +1 -1
  31. package/dist/core/session-manager.js +169 -80
  32. package/dist/core/session-manager.js.map +1 -1
  33. package/dist/core/settings-manager.d.ts +23 -0
  34. package/dist/core/settings-manager.d.ts.map +1 -1
  35. package/dist/core/settings-manager.js +19 -0
  36. package/dist/core/settings-manager.js.map +1 -1
  37. package/dist/core/skills.d.ts.map +1 -1
  38. package/dist/core/skills.js +3 -7
  39. package/dist/core/skills.js.map +1 -1
  40. package/dist/core/slash-commands.d.ts.map +1 -1
  41. package/dist/core/slash-commands.js +6 -3
  42. package/dist/core/slash-commands.js.map +1 -1
  43. package/dist/core/system-prompt.d.ts +3 -3
  44. package/dist/core/system-prompt.d.ts.map +1 -1
  45. package/dist/core/system-prompt.js +27 -18
  46. package/dist/core/system-prompt.js.map +1 -1
  47. package/dist/core/tools/find.d.ts.map +1 -1
  48. package/dist/core/tools/find.js +4 -3
  49. package/dist/core/tools/find.js.map +1 -1
  50. package/dist/core/tools/grep.d.ts.map +1 -1
  51. package/dist/core/tools/grep.js +4 -3
  52. package/dist/core/tools/grep.js.map +1 -1
  53. package/dist/core/tools/ls.d.ts.map +1 -1
  54. package/dist/core/tools/ls.js +1 -0
  55. package/dist/core/tools/ls.js.map +1 -1
  56. package/dist/core/tools/render-utils.d.ts +1 -1
  57. package/dist/core/tools/render-utils.d.ts.map +1 -1
  58. package/dist/core/tools/render-utils.js +29 -4
  59. package/dist/core/tools/render-utils.js.map +1 -1
  60. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  61. package/dist/modes/interactive/components/footer.js +2 -2
  62. package/dist/modes/interactive/components/footer.js.map +1 -1
  63. package/dist/modes/interactive/components/index.d.ts +2 -0
  64. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  65. package/dist/modes/interactive/components/index.js +2 -0
  66. package/dist/modes/interactive/components/index.js.map +1 -1
  67. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  68. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  69. package/dist/modes/interactive/components/tool-execution.js +66 -8
  70. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  71. package/dist/modes/interactive/components/tool-group.d.ts +17 -0
  72. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -0
  73. package/dist/modes/interactive/components/tool-group.js +63 -0
  74. package/dist/modes/interactive/components/tool-group.js.map +1 -0
  75. package/dist/modes/interactive/components/tool-panel-registry.d.ts +23 -0
  76. package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -0
  77. package/dist/modes/interactive/components/tool-panel-registry.js +70 -0
  78. package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -0
  79. package/dist/modes/interactive/interactive-mode.d.ts +6 -1
  80. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  81. package/dist/modes/interactive/interactive-mode.js +119 -60
  82. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  83. package/dist/utils/paths.d.ts.map +1 -1
  84. package/dist/utils/paths.js +4 -1
  85. package/dist/utils/paths.js.map +1 -1
  86. package/docs/extensions.md +6 -3
  87. package/docs/quickstart.md +3 -3
  88. package/docs/sdk.md +1 -1
  89. package/docs/settings.md +50 -0
  90. package/docs/skills.md +3 -3
  91. package/docs/usage.md +3 -3
  92. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  93. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  94. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  95. package/examples/extensions/sandbox/package-lock.json +2 -2
  96. package/examples/extensions/sandbox/package.json +1 -1
  97. package/examples/extensions/with-deps/package-lock.json +2 -2
  98. package/examples/extensions/with-deps/package.json +1 -1
  99. package/examples/sdk/07-context-files.ts +3 -14
  100. package/npm-shrinkwrap.json +18 -15
  101. package/package.json +4 -4
@@ -21,6 +21,7 @@ export class ToolExecutionComponent extends Container {
21
21
  isPartial = true;
22
22
  toolDefinition;
23
23
  builtInToolDefinition;
24
+ toolGroup;
24
25
  ui;
25
26
  cwd;
26
27
  executionStarted = false;
@@ -35,6 +36,7 @@ export class ToolExecutionComponent extends Container {
35
36
  this.args = args;
36
37
  this.toolDefinition = toolDefinition;
37
38
  this.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName];
39
+ this.toolGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;
38
40
  this.showImages = options.showImages ?? true;
39
41
  this.imageWidthCells = options.imageWidthCells ?? 60;
40
42
  this.ui = ui;
@@ -84,7 +86,7 @@ export class ToolExecutionComponent extends Container {
84
86
  }
85
87
  return this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? "default";
86
88
  }
87
- getRenderContext(lastComponent) {
89
+ getRenderContext(lastComponent, toolGroupSummary = false) {
88
90
  return {
89
91
  args: this.args,
90
92
  toolCallId: this.toolCallId,
@@ -101,10 +103,47 @@ export class ToolExecutionComponent extends Container {
101
103
  expanded: this.expanded,
102
104
  showImages: this.showImages,
103
105
  isError: this.result?.isError ?? false,
106
+ toolGroupSummary,
104
107
  };
105
108
  }
109
+ humanizeToolName(name) {
110
+ const words = name
111
+ .replace(/[_-]+/g, " ")
112
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
113
+ .trim()
114
+ .split(/\s+/)
115
+ .filter(Boolean);
116
+ if (words.length === 0)
117
+ return name;
118
+ return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
119
+ }
120
+ getDisplayLabel() {
121
+ const label = (this.toolDefinition?.label ?? this.builtInToolDefinition?.label)?.trim();
122
+ if (this.builtInToolDefinition)
123
+ return label || this.toolName;
124
+ if (!label || label === this.toolName)
125
+ return this.humanizeToolName(this.toolName);
126
+ return label;
127
+ }
128
+ resetInvocation(toolName, toolCallId, args, toolDefinition) {
129
+ this.toolName = toolName;
130
+ this.toolCallId = toolCallId;
131
+ this.args = args;
132
+ this.toolDefinition = toolDefinition;
133
+ this.builtInToolDefinition = createAllToolDefinitions(this.cwd)[toolName];
134
+ this.toolGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;
135
+ this.executionStarted = false;
136
+ this.argsComplete = false;
137
+ this.isPartial = true;
138
+ this.result = undefined;
139
+ this.callRendererComponent = undefined;
140
+ this.resultRendererComponent = undefined;
141
+ this.rendererState = {};
142
+ this.convertedImages.clear();
143
+ this.updateDisplay();
144
+ }
106
145
  createCallFallback() {
107
- return new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0);
146
+ return new Text(theme.fg("toolTitle", theme.bold(this.getDisplayLabel())), 0, 0);
108
147
  }
109
148
  createResultFallback() {
110
149
  const output = this.getTextOutput();
@@ -170,10 +209,33 @@ export class ToolExecutionComponent extends Container {
170
209
  this.imageWidthCells = Math.max(1, Math.floor(width));
171
210
  this.updateDisplay();
172
211
  }
212
+ getBackgroundColor() {
213
+ if (this.isPartial)
214
+ return "toolPendingBg";
215
+ if (this.result?.isError)
216
+ return "toolErrorBg";
217
+ return "toolSuccessBg";
218
+ }
173
219
  invalidate() {
174
220
  super.invalidate();
175
221
  this.updateDisplay();
176
222
  }
223
+ renderCallSummary(width) {
224
+ const callRenderer = this.getCallRenderer();
225
+ let component;
226
+ if (!callRenderer) {
227
+ component = this.createCallFallback();
228
+ }
229
+ else {
230
+ try {
231
+ component = callRenderer(this.args, theme, this.getRenderContext(undefined, true));
232
+ }
233
+ catch {
234
+ component = this.createCallFallback();
235
+ }
236
+ }
237
+ return component.render(width);
238
+ }
177
239
  render(width) {
178
240
  if (this.hideComponent) {
179
241
  return [];
@@ -181,11 +243,7 @@ export class ToolExecutionComponent extends Container {
181
243
  return super.render(width);
182
244
  }
183
245
  updateDisplay() {
184
- const bgFn = this.isPartial
185
- ? (text) => theme.bg("toolPendingBg", text)
186
- : this.result?.isError
187
- ? (text) => theme.bg("toolErrorBg", text)
188
- : (text) => theme.bg("toolSuccessBg", text);
246
+ const bgFn = (text) => theme.bg(this.getBackgroundColor(), text);
189
247
  let hasContent = false;
190
248
  this.hideComponent = false;
191
249
  if (this.hasRendererDefinition()) {
@@ -280,7 +338,7 @@ export class ToolExecutionComponent extends Container {
280
338
  return getRenderedTextOutput(this.result, this.showImages);
281
339
  }
282
340
  formatToolExecution() {
283
- let text = theme.fg("toolTitle", theme.bold(this.toolName));
341
+ let text = theme.fg("toolTitle", theme.bold(this.getDisplayLabel()));
284
342
  const content = JSON.stringify(this.args, null, 2);
285
343
  if (content) {
286
344
  text += `\n\n${content}`;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,wBAAwB,CAAC;AAExH,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,UAAU,CAAM;IAChB,WAAW,CAAO;IAClB,mBAAmB,CAAY;IAC/B,qBAAqB,CAAa;IAClC,uBAAuB,CAAa;IACpC,aAAa,GAAQ,EAAE,CAAC;IACxB,eAAe,GAAY,EAAE,CAAC;IAC9B,YAAY,GAAa,EAAE,CAAC;IAC5B,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,IAAI,CAAM;IACV,QAAQ,GAAG,KAAK,CAAC;IACjB,UAAU,CAAU;IACpB,eAAe,CAAS;IACxB,SAAS,GAAG,IAAI,CAAC;IACjB,cAAc,CAA4B;IAC1C,qBAAqB,CAA4B;IACjD,EAAE,CAAM;IACR,GAAG,CAAS;IACZ,gBAAgB,GAAG,KAAK,CAAC;IACzB,YAAY,GAAG,KAAK,CAAC;IACrB,MAAM,CAIZ;IACM,eAAe,GAAoD,IAAI,GAAG,EAAE,CAAC;IAC7E,aAAa,GAAG,KAAK,CAAC;IAE9B,YACC,QAAgB,EAChB,UAAkB,EAClB,IAAS,EACT,OAAO,GAAyB,EAAE,EAClC,cAAoD,EACpD,EAAO,EACP,GAAW,EACV;QACD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,QAAQ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I,OAAO,EAAE,CAAC;YACb,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { 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\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\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.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};\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.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\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\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 resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = theme.fg(\"toolTitle\", theme.bold(this.toolName));\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,wBAAwB,CAAC;AAExH,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAgB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAOxD,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,UAAU,CAAM;IAChB,WAAW,CAAO;IAClB,mBAAmB,CAAY;IAC/B,qBAAqB,CAAa;IAClC,uBAAuB,CAAa;IACpC,aAAa,GAAQ,EAAE,CAAC;IACxB,eAAe,GAAY,EAAE,CAAC;IAC9B,YAAY,GAAa,EAAE,CAAC;IAC5B,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,IAAI,CAAM;IACV,QAAQ,GAAG,KAAK,CAAC;IACjB,UAAU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A,CACD;IAEO,aAAa,GAAW;QAC/B,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3D;IAEO,mBAAmB,GAAW;QACrC,IAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\ttoolGroup: string | undefined;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined, toolGroupSummary = false): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\ttoolGroupSummary,\n\t\t};\n\t}\n\n\tprivate humanizeToolName(name: string): string {\n\t\tconst words = name\n\t\t\t.replace(/[_-]+/g, \" \")\n\t\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t\t.trim()\n\t\t\t.split(/\\s+/)\n\t\t\t.filter(Boolean);\n\t\tif (words.length === 0) return name;\n\t\treturn words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(\" \");\n\t}\n\n\tprivate getDisplayLabel(): string {\n\t\tconst label = (this.toolDefinition?.label ?? this.builtInToolDefinition?.label)?.trim();\n\t\tif (this.builtInToolDefinition) return label || this.toolName;\n\t\tif (!label || label === this.toolName) return this.humanizeToolName(this.toolName);\n\t\treturn label;\n\t}\n\n\tresetInvocation(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t): void {\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(this.cwd)[toolName as ToolName];\n\t\tthis.toolGroup = this.toolDefinition?.toolGroup ?? this.builtInToolDefinition?.toolGroup;\n\t\tthis.executionStarted = false;\n\t\tthis.argsComplete = false;\n\t\tthis.isPartial = true;\n\t\tthis.result = undefined;\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\tthis.rendererState = {};\n\t\tthis.convertedImages.clear();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.getDisplayLabel())), 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.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\tgetBackgroundColor(): ThemeBg {\n\t\tif (this.isPartial) return \"toolPendingBg\";\n\t\tif (this.result?.isError) return \"toolErrorBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\trenderCallSummary(width: number): string[] {\n\t\tconst callRenderer = this.getCallRenderer();\n\t\tlet component: Component;\n\t\tif (!callRenderer) {\n\t\t\tcomponent = this.createCallFallback();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tcomponent = callRenderer(this.args, theme, this.getRenderContext(undefined, true));\n\t\t\t} catch {\n\t\t\t\tcomponent = this.createCallFallback();\n\t\t\t}\n\t\t}\n\t\treturn component.render(width);\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\treturn super.render(width);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst bgFn = (text: string) => theme.bg(this.getBackgroundColor(), text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = theme.fg(\"toolTitle\", theme.bold(this.getDisplayLabel()));\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"]}
@@ -0,0 +1,17 @@
1
+ import { type Component } from "@earendil-works/pi-tui";
2
+ import type { ToolExecutionComponent } from "./tool-execution.ts";
3
+ export declare class ToolGroupComponent implements Component {
4
+ readonly toolGroup: string;
5
+ private readonly tools;
6
+ private expanded;
7
+ constructor(toolGroup: string, tools?: ToolExecutionComponent[]);
8
+ addTool(tool: ToolExecutionComponent): void;
9
+ setExpanded(expanded: boolean): void;
10
+ setShowImages(show: boolean): void;
11
+ setImageWidthCells(width: number): void;
12
+ invalidate(): void;
13
+ render(width: number): string[];
14
+ private renderCollapsed;
15
+ private getBackgroundColor;
16
+ }
17
+ //# sourceMappingURL=tool-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-group.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,qBAAa,kBAAmB,YAAW,SAAS;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IACtD,OAAO,CAAC,QAAQ,CAAS;IAEzB,YAAY,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,sBAAsB,EAAO,EAGlE;IAED,OAAO,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAG1C;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IAED,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAEjC;IAED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEtC;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ9B;IAED,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,kBAAkB;CAM1B","sourcesContent":["import { Box, type Component } from \"@earendil-works/pi-tui\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\nimport { keyText } from \"./keybinding-hints.ts\";\nimport type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport class ToolGroupComponent implements Component {\n\treadonly toolGroup: string;\n\tprivate readonly tools: ToolExecutionComponent[] = [];\n\tprivate expanded = false;\n\n\tconstructor(toolGroup: string, tools: ToolExecutionComponent[] = []) {\n\t\tthis.toolGroup = toolGroup;\n\t\tfor (const tool of tools) this.addTool(tool);\n\t}\n\n\taddTool(tool: ToolExecutionComponent): void {\n\t\ttool.setExpanded(this.expanded);\n\t\tthis.tools.push(tool);\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tfor (const tool of this.tools) tool.setExpanded(expanded);\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tfor (const tool of this.tools) tool.setShowImages(show);\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tfor (const tool of this.tools) tool.setImageWidthCells(width);\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const tool of this.tools) tool.invalidate();\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.tools.length === 0) return [];\n\t\tconst safeWidth = Math.max(1, width);\n\t\tif (this.expanded) return this.tools.flatMap((tool) => tool.render(safeWidth));\n\n\t\tconst box = new Box(1, 1, (text) => theme.bg(this.getBackgroundColor(), text));\n\t\tbox.addChild({ render: (contentWidth) => this.renderCollapsed(contentWidth), invalidate: () => {} });\n\t\treturn [\" \".repeat(safeWidth), ...box.render(safeWidth)];\n\t}\n\n\tprivate renderCollapsed(width: number): string[] {\n\t\tconst lines = this.tools.flatMap((tool) =>\n\t\t\ttool.renderCallSummary(width).map((line) => line.replace(/[ \\t]+$/g, \"\")),\n\t\t);\n\t\tfor (let i = lines.length - 1; i >= 0; i--) {\n\t\t\tif (lines[i]?.trim()) {\n\t\t\t\tlines[i] += theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate getBackgroundColor(): ThemeBg {\n\t\tconst colors = this.tools.map((tool) => tool.getBackgroundColor());\n\t\tif (colors.includes(\"toolErrorBg\")) return \"toolErrorBg\";\n\t\tif (colors.includes(\"toolPendingBg\")) return \"toolPendingBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n}\n"]}
@@ -0,0 +1,63 @@
1
+ import { Box } from "@earendil-works/pi-tui";
2
+ import { theme } from "../theme/theme.js";
3
+ import { keyText } from "./keybinding-hints.js";
4
+ export class ToolGroupComponent {
5
+ toolGroup;
6
+ tools = [];
7
+ expanded = false;
8
+ constructor(toolGroup, tools = []) {
9
+ this.toolGroup = toolGroup;
10
+ for (const tool of tools)
11
+ this.addTool(tool);
12
+ }
13
+ addTool(tool) {
14
+ tool.setExpanded(this.expanded);
15
+ this.tools.push(tool);
16
+ }
17
+ setExpanded(expanded) {
18
+ this.expanded = expanded;
19
+ for (const tool of this.tools)
20
+ tool.setExpanded(expanded);
21
+ }
22
+ setShowImages(show) {
23
+ for (const tool of this.tools)
24
+ tool.setShowImages(show);
25
+ }
26
+ setImageWidthCells(width) {
27
+ for (const tool of this.tools)
28
+ tool.setImageWidthCells(width);
29
+ }
30
+ invalidate() {
31
+ for (const tool of this.tools)
32
+ tool.invalidate();
33
+ }
34
+ render(width) {
35
+ if (this.tools.length === 0)
36
+ return [];
37
+ const safeWidth = Math.max(1, width);
38
+ if (this.expanded)
39
+ return this.tools.flatMap((tool) => tool.render(safeWidth));
40
+ const box = new Box(1, 1, (text) => theme.bg(this.getBackgroundColor(), text));
41
+ box.addChild({ render: (contentWidth) => this.renderCollapsed(contentWidth), invalidate: () => { } });
42
+ return [" ".repeat(safeWidth), ...box.render(safeWidth)];
43
+ }
44
+ renderCollapsed(width) {
45
+ const lines = this.tools.flatMap((tool) => tool.renderCallSummary(width).map((line) => line.replace(/[ \t]+$/g, "")));
46
+ for (let i = lines.length - 1; i >= 0; i--) {
47
+ if (lines[i]?.trim()) {
48
+ lines[i] += theme.fg("dim", ` (${keyText("app.tools.expand")} to expand)`);
49
+ break;
50
+ }
51
+ }
52
+ return lines;
53
+ }
54
+ getBackgroundColor() {
55
+ const colors = this.tools.map((tool) => tool.getBackgroundColor());
56
+ if (colors.includes("toolErrorBg"))
57
+ return "toolErrorBg";
58
+ if (colors.includes("toolPendingBg"))
59
+ return "toolPendingBg";
60
+ return "toolSuccessBg";
61
+ }
62
+ }
63
+ //# sourceMappingURL=tool-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-group.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAgB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,MAAM,OAAO,kBAAkB;IACrB,SAAS,CAAS;IACV,KAAK,GAA6B,EAAE,CAAC;IAC9C,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAAY,SAAiB,EAAE,KAAK,GAA6B,EAAE,EAAE;QACpE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAAA,CAC7C;IAED,OAAO,CAAC,IAA4B,EAAQ;QAC3C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAAA,CACtB;IAED,WAAW,CAAC,QAAiB,EAAQ;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAAA,CAC1D;IAED,aAAa,CAAC,IAAa,EAAQ;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAAA,CACxD;IAED,kBAAkB,CAAC,KAAa,EAAQ;QACvC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,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,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CACzE,CAAC;QACF,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5C,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;gBACtB,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,OAAO,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;gBAC3E,MAAM;YACP,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;IAEO,kBAAkB,GAAY;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;YAAE,OAAO,aAAa,CAAC;QACzD,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC;YAAE,OAAO,eAAe,CAAC;QAC7D,OAAO,eAAe,CAAC;IAAA,CACvB;CACD","sourcesContent":["import { Box, type Component } from \"@earendil-works/pi-tui\";\nimport { type ThemeBg, theme } from \"../theme/theme.ts\";\nimport { keyText } from \"./keybinding-hints.ts\";\nimport type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport class ToolGroupComponent implements Component {\n\treadonly toolGroup: string;\n\tprivate readonly tools: ToolExecutionComponent[] = [];\n\tprivate expanded = false;\n\n\tconstructor(toolGroup: string, tools: ToolExecutionComponent[] = []) {\n\t\tthis.toolGroup = toolGroup;\n\t\tfor (const tool of tools) this.addTool(tool);\n\t}\n\n\taddTool(tool: ToolExecutionComponent): void {\n\t\ttool.setExpanded(this.expanded);\n\t\tthis.tools.push(tool);\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tfor (const tool of this.tools) tool.setExpanded(expanded);\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tfor (const tool of this.tools) tool.setShowImages(show);\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tfor (const tool of this.tools) tool.setImageWidthCells(width);\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const tool of this.tools) tool.invalidate();\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.tools.length === 0) return [];\n\t\tconst safeWidth = Math.max(1, width);\n\t\tif (this.expanded) return this.tools.flatMap((tool) => tool.render(safeWidth));\n\n\t\tconst box = new Box(1, 1, (text) => theme.bg(this.getBackgroundColor(), text));\n\t\tbox.addChild({ render: (contentWidth) => this.renderCollapsed(contentWidth), invalidate: () => {} });\n\t\treturn [\" \".repeat(safeWidth), ...box.render(safeWidth)];\n\t}\n\n\tprivate renderCollapsed(width: number): string[] {\n\t\tconst lines = this.tools.flatMap((tool) =>\n\t\t\ttool.renderCallSummary(width).map((line) => line.replace(/[ \\t]+$/g, \"\")),\n\t\t);\n\t\tfor (let i = lines.length - 1; i >= 0; i--) {\n\t\t\tif (lines[i]?.trim()) {\n\t\t\t\tlines[i] += theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate getBackgroundColor(): ThemeBg {\n\t\tconst colors = this.tools.map((tool) => tool.getBackgroundColor());\n\t\tif (colors.includes(\"toolErrorBg\")) return \"toolErrorBg\";\n\t\tif (colors.includes(\"toolPendingBg\")) return \"toolPendingBg\";\n\t\treturn \"toolSuccessBg\";\n\t}\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { ToolExecutionComponent } from "./tool-execution.ts";
2
+ export interface ToolPanelTenantScope {
3
+ sessionId?: string;
4
+ sessionFile?: string;
5
+ cwd: string;
6
+ }
7
+ export declare function createToolPanelTenantKey(scope: ToolPanelTenantScope): string;
8
+ export declare function getToolPanelActionKey(scope: ToolPanelTenantScope, toolName: string, args: unknown): string | undefined;
9
+ export declare class ToolPanelRegistry {
10
+ private readonly panelsByAction;
11
+ private readonly activeByCallId;
12
+ private readonly actionKeyByCallId;
13
+ getReusable(actionKey: string | undefined): ToolExecutionComponent | undefined;
14
+ register(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void;
15
+ hasActive(toolCallId: string): boolean;
16
+ getActive(toolCallId: string): ToolExecutionComponent | undefined;
17
+ activeEntries(): IterableIterator<[string, ToolExecutionComponent]>;
18
+ isActive(panel: ToolExecutionComponent): boolean;
19
+ finish(toolCallId: string): void;
20
+ clearActive(): void;
21
+ clearAll(): void;
22
+ }
23
+ //# sourceMappingURL=tool-panel-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-panel-registry.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAE5E;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACX,MAAM,GAAG,SAAS,CAYpB;AAED,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAE/D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,sBAAsB,GAAG,SAAS,CAK7E;IAED,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAMpF;IAED,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAErC;IAED,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAEhE;IAED,aAAa,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAElE;IAED,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAK/C;IAED,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAG/B;IAED,WAAW,IAAI,IAAI,CAGlB;IAED,QAAQ,IAAI,IAAI,CAIf;CACD","sourcesContent":["import type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport interface ToolPanelTenantScope {\n\tsessionId?: string;\n\tsessionFile?: string;\n\tcwd: string;\n}\n\nexport function createToolPanelTenantKey(scope: ToolPanelTenantScope): string {\n\treturn [scope.sessionId || \"no-session-id\", scope.sessionFile || \"no-session-file\", scope.cwd].join(\"\\0\");\n}\n\nexport function getToolPanelActionKey(\n\tscope: ToolPanelTenantScope,\n\ttoolName: string,\n\targs: unknown,\n): string | undefined {\n\tconst tenantKey = createToolPanelTenantKey(scope);\n\tif (!args || typeof args !== \"object\") return toolName.endsWith(\"_status\") ? `${tenantKey}\\0${toolName}` : undefined;\n\tconst record = args as Record<string, unknown>;\n\tconst pathValue = record.path ?? record.file_path;\n\tif ([\"read\", \"edit\", \"write\"].includes(toolName) && typeof pathValue === \"string\" && pathValue.trim()) {\n\t\treturn `${tenantKey}\\0${toolName}:${pathValue.trim()}`;\n\t}\n\tif (toolName.endsWith(\"_status\")) return `${tenantKey}\\0${toolName}`;\n\tif (toolName === \"learning_auto_learn_state\") return `${tenantKey}\\0${toolName}:${String(record.action || \"read\")}`;\n\tif (toolName === \"task_steps\") return `${tenantKey}\\0${toolName}:${String(record.action || \"list\")}`;\n\treturn undefined;\n}\n\nexport class ToolPanelRegistry {\n\tprivate readonly panelsByAction = new Map<string, ToolExecutionComponent>();\n\tprivate readonly activeByCallId = new Map<string, ToolExecutionComponent>();\n\tprivate readonly actionKeyByCallId = new Map<string, string>();\n\n\tgetReusable(actionKey: string | undefined): ToolExecutionComponent | undefined {\n\t\tif (!actionKey) return undefined;\n\t\tconst panel = this.panelsByAction.get(actionKey);\n\t\tif (!panel || this.isActive(panel)) return undefined;\n\t\treturn panel;\n\t}\n\n\tregister(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void {\n\t\tthis.activeByCallId.set(toolCallId, panel);\n\t\tif (actionKey) {\n\t\t\tthis.panelsByAction.set(actionKey, panel);\n\t\t\tthis.actionKeyByCallId.set(toolCallId, actionKey);\n\t\t}\n\t}\n\n\thasActive(toolCallId: string): boolean {\n\t\treturn this.activeByCallId.has(toolCallId);\n\t}\n\n\tgetActive(toolCallId: string): ToolExecutionComponent | undefined {\n\t\treturn this.activeByCallId.get(toolCallId);\n\t}\n\n\tactiveEntries(): IterableIterator<[string, ToolExecutionComponent]> {\n\t\treturn this.activeByCallId.entries();\n\t}\n\n\tisActive(panel: ToolExecutionComponent): boolean {\n\t\tfor (const active of this.activeByCallId.values()) {\n\t\t\tif (active === panel) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfinish(toolCallId: string): void {\n\t\tthis.activeByCallId.delete(toolCallId);\n\t\tthis.actionKeyByCallId.delete(toolCallId);\n\t}\n\n\tclearActive(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n\n\tclearAll(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.panelsByAction.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n}\n"]}
@@ -0,0 +1,70 @@
1
+ export function createToolPanelTenantKey(scope) {
2
+ return [scope.sessionId || "no-session-id", scope.sessionFile || "no-session-file", scope.cwd].join("\0");
3
+ }
4
+ export function getToolPanelActionKey(scope, toolName, args) {
5
+ const tenantKey = createToolPanelTenantKey(scope);
6
+ if (!args || typeof args !== "object")
7
+ return toolName.endsWith("_status") ? `${tenantKey}\0${toolName}` : undefined;
8
+ const record = args;
9
+ const pathValue = record.path ?? record.file_path;
10
+ if (["read", "edit", "write"].includes(toolName) && typeof pathValue === "string" && pathValue.trim()) {
11
+ return `${tenantKey}\0${toolName}:${pathValue.trim()}`;
12
+ }
13
+ if (toolName.endsWith("_status"))
14
+ return `${tenantKey}\0${toolName}`;
15
+ if (toolName === "learning_auto_learn_state")
16
+ return `${tenantKey}\0${toolName}:${String(record.action || "read")}`;
17
+ if (toolName === "task_steps")
18
+ return `${tenantKey}\0${toolName}:${String(record.action || "list")}`;
19
+ return undefined;
20
+ }
21
+ export class ToolPanelRegistry {
22
+ panelsByAction = new Map();
23
+ activeByCallId = new Map();
24
+ actionKeyByCallId = new Map();
25
+ getReusable(actionKey) {
26
+ if (!actionKey)
27
+ return undefined;
28
+ const panel = this.panelsByAction.get(actionKey);
29
+ if (!panel || this.isActive(panel))
30
+ return undefined;
31
+ return panel;
32
+ }
33
+ register(toolCallId, panel, actionKey) {
34
+ this.activeByCallId.set(toolCallId, panel);
35
+ if (actionKey) {
36
+ this.panelsByAction.set(actionKey, panel);
37
+ this.actionKeyByCallId.set(toolCallId, actionKey);
38
+ }
39
+ }
40
+ hasActive(toolCallId) {
41
+ return this.activeByCallId.has(toolCallId);
42
+ }
43
+ getActive(toolCallId) {
44
+ return this.activeByCallId.get(toolCallId);
45
+ }
46
+ activeEntries() {
47
+ return this.activeByCallId.entries();
48
+ }
49
+ isActive(panel) {
50
+ for (const active of this.activeByCallId.values()) {
51
+ if (active === panel)
52
+ return true;
53
+ }
54
+ return false;
55
+ }
56
+ finish(toolCallId) {
57
+ this.activeByCallId.delete(toolCallId);
58
+ this.actionKeyByCallId.delete(toolCallId);
59
+ }
60
+ clearActive() {
61
+ this.activeByCallId.clear();
62
+ this.actionKeyByCallId.clear();
63
+ }
64
+ clearAll() {
65
+ this.activeByCallId.clear();
66
+ this.panelsByAction.clear();
67
+ this.actionKeyByCallId.clear();
68
+ }
69
+ }
70
+ //# sourceMappingURL=tool-panel-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-panel-registry.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel-registry.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,wBAAwB,CAAC,KAA2B,EAAU;IAC7E,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI,eAAe,EAAE,KAAK,CAAC,WAAW,IAAI,iBAAiB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CAC1G;AAED,MAAM,UAAU,qBAAqB,CACpC,KAA2B,EAC3B,QAAgB,EAChB,IAAa,EACQ;IACrB,MAAM,SAAS,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrH,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAClD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QACvG,OAAO,GAAG,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,GAAG,SAAS,KAAK,QAAQ,EAAE,CAAC;IACrE,IAAI,QAAQ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AC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3C;IAED,aAAa,GAAuD;QACnE,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAAA,CACrC;IAED,QAAQ,CAAC,KAA6B,EAAW;QAChD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC;YACnD,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;IAED,MAAM,CAAC,UAAkB,EAAQ;QAChC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAAA,CAC1C;IAED,WAAW,GAAS;QACnB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAAA,CAC/B;IAED,QAAQ,GAAS;QAChB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAAA,CAC/B;CACD","sourcesContent":["import type { ToolExecutionComponent } from \"./tool-execution.ts\";\n\nexport interface ToolPanelTenantScope {\n\tsessionId?: string;\n\tsessionFile?: string;\n\tcwd: string;\n}\n\nexport function createToolPanelTenantKey(scope: ToolPanelTenantScope): string {\n\treturn [scope.sessionId || \"no-session-id\", scope.sessionFile || \"no-session-file\", scope.cwd].join(\"\\0\");\n}\n\nexport function getToolPanelActionKey(\n\tscope: ToolPanelTenantScope,\n\ttoolName: string,\n\targs: unknown,\n): string | undefined {\n\tconst tenantKey = createToolPanelTenantKey(scope);\n\tif (!args || typeof args !== \"object\") return toolName.endsWith(\"_status\") ? `${tenantKey}\\0${toolName}` : undefined;\n\tconst record = args as Record<string, unknown>;\n\tconst pathValue = record.path ?? record.file_path;\n\tif ([\"read\", \"edit\", \"write\"].includes(toolName) && typeof pathValue === \"string\" && pathValue.trim()) {\n\t\treturn `${tenantKey}\\0${toolName}:${pathValue.trim()}`;\n\t}\n\tif (toolName.endsWith(\"_status\")) return `${tenantKey}\\0${toolName}`;\n\tif (toolName === \"learning_auto_learn_state\") return `${tenantKey}\\0${toolName}:${String(record.action || \"read\")}`;\n\tif (toolName === \"task_steps\") return `${tenantKey}\\0${toolName}:${String(record.action || \"list\")}`;\n\treturn undefined;\n}\n\nexport class ToolPanelRegistry {\n\tprivate readonly panelsByAction = new Map<string, ToolExecutionComponent>();\n\tprivate readonly activeByCallId = new Map<string, ToolExecutionComponent>();\n\tprivate readonly actionKeyByCallId = new Map<string, string>();\n\n\tgetReusable(actionKey: string | undefined): ToolExecutionComponent | undefined {\n\t\tif (!actionKey) return undefined;\n\t\tconst panel = this.panelsByAction.get(actionKey);\n\t\tif (!panel || this.isActive(panel)) return undefined;\n\t\treturn panel;\n\t}\n\n\tregister(toolCallId: string, panel: ToolExecutionComponent, actionKey?: string): void {\n\t\tthis.activeByCallId.set(toolCallId, panel);\n\t\tif (actionKey) {\n\t\t\tthis.panelsByAction.set(actionKey, panel);\n\t\t\tthis.actionKeyByCallId.set(toolCallId, actionKey);\n\t\t}\n\t}\n\n\thasActive(toolCallId: string): boolean {\n\t\treturn this.activeByCallId.has(toolCallId);\n\t}\n\n\tgetActive(toolCallId: string): ToolExecutionComponent | undefined {\n\t\treturn this.activeByCallId.get(toolCallId);\n\t}\n\n\tactiveEntries(): IterableIterator<[string, ToolExecutionComponent]> {\n\t\treturn this.activeByCallId.entries();\n\t}\n\n\tisActive(panel: ToolExecutionComponent): boolean {\n\t\tfor (const active of this.activeByCallId.values()) {\n\t\t\tif (active === panel) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfinish(toolCallId: string): void {\n\t\tthis.activeByCallId.delete(toolCallId);\n\t\tthis.actionKeyByCallId.delete(toolCallId);\n\t}\n\n\tclearActive(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n\n\tclearAll(): void {\n\t\tthis.activeByCallId.clear();\n\t\tthis.panelsByAction.clear();\n\t\tthis.actionKeyByCallId.clear();\n\t}\n}\n"]}
@@ -61,7 +61,7 @@ export declare class InteractiveMode {
61
61
  private lastStatusText;
62
62
  private streamingComponent;
63
63
  private streamingMessage;
64
- private pendingTools;
64
+ private toolPanels;
65
65
  private toolOutputExpanded;
66
66
  private hideThinkingBlock;
67
67
  private skillCommands;
@@ -152,6 +152,11 @@ export declare class InteractiveMode {
152
152
  * Get a registered tool definition by name (for custom rendering).
153
153
  */
154
154
  private getRegisteredToolDefinition;
155
+ private getToolPanelScope;
156
+ private appendToolExecutionComponent;
157
+ private attachToolExecutionComponent;
158
+ private clearActiveToolCalls;
159
+ private clearRenderedToolPanelState;
155
160
  /**
156
161
  * Set up keyboard shortcuts registered by extensions.
157
162
  */