@astralyn/pi 1.4.1 → 1.4.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.
- package/CHANGELOG.md +14 -0
- package/dist/bundle/chunks/{chunk-N77PYEXG.js → chunk-ISXCH6TG.js} +1 -1
- package/dist/bundle/chunks/{chunk-KSKBY3VV.js → chunk-Z2YN4E74.js} +117 -111
- package/dist/bundle/chunks/{virtual-modules-XNEYDLXF.js → virtual-modules-QX6D3D7X.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +15 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/distribution-api.d.ts +1 -1
- package/dist/core/extensions/distribution-api.d.ts.map +1 -1
- package/dist/core/extensions/distribution-api.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +29 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybinding-registry.d.ts +16 -1
- package/dist/core/keybinding-registry.d.ts.map +1 -1
- package/dist/core/keybinding-registry.js +20 -0
- package/dist/core/keybinding-registry.js.map +1 -1
- package/dist/core/keybindings-schema.d.ts.map +1 -1
- package/dist/core/keybindings-schema.js +2 -1
- package/dist/core/keybindings-schema.js.map +1 -1
- package/dist/core/keybindings.d.ts +4 -106
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -13
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/format.d.ts.map +1 -1
- package/dist/core/tasks/format.js +10 -4
- package/dist/core/tasks/format.js.map +1 -1
- package/dist/core/tasks/limits.d.ts +5 -0
- package/dist/core/tasks/limits.d.ts.map +1 -0
- package/dist/core/tasks/limits.js +5 -0
- package/dist/core/tasks/limits.js.map +1 -0
- package/dist/core/tasks/runtime.d.ts +1 -0
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +7 -3
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/session.d.ts +1 -1
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +10 -2
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/types.d.ts +13 -0
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.js.map +1 -1
- package/dist/core/tools/bash.d.ts +98 -9
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +308 -11
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/index.d.ts +5 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +3 -11
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +2 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +2 -1
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js +7 -5
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/core/tools/shell-execution.d.ts +2 -2
- package/dist/core/tools/shell-execution.d.ts.map +1 -1
- package/dist/core/tools/shell-execution.js +0 -21
- package/dist/core/tools/shell-execution.js.map +1 -1
- package/dist/core/tools/shell-operations.d.ts +12 -0
- package/dist/core/tools/shell-operations.d.ts.map +1 -0
- package/dist/core/tools/shell-operations.js +38 -0
- package/dist/core/tools/shell-operations.js.map +1 -0
- package/dist/core/tools/shell-tool.d.ts +8 -64
- package/dist/core/tools/shell-tool.d.ts.map +1 -1
- package/dist/core/tools/shell-tool.js +27 -125
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +5 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/keybindings.d.ts +6 -0
- package/dist/extensions/keybindings.d.ts.map +1 -0
- package/dist/extensions/keybindings.js +6 -0
- package/dist/extensions/keybindings.js.map +1 -0
- package/dist/extensions/tasks/index.d.ts +5 -0
- package/dist/extensions/tasks/index.d.ts.map +1 -0
- package/dist/extensions/tasks/index.js +42 -0
- package/dist/extensions/tasks/index.js.map +1 -0
- package/dist/extensions/tasks/keybindings.d.ts +19 -0
- package/dist/extensions/tasks/keybindings.d.ts.map +1 -0
- package/dist/extensions/tasks/keybindings.js +30 -0
- package/dist/extensions/tasks/keybindings.js.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/actions.d.ts +2 -2
- package/dist/extensions/tasks/tool/actions.d.ts.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/actions.js +4 -4
- package/dist/extensions/tasks/tool/actions.js.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/constants.d.ts +1 -3
- package/dist/extensions/tasks/tool/constants.d.ts.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/constants.js +1 -3
- package/dist/extensions/tasks/tool/constants.js.map +1 -0
- package/dist/extensions/tasks/tool/schema.d.ts.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/schema.js +5 -4
- package/dist/extensions/tasks/tool/schema.js.map +1 -0
- package/dist/{core/tools/tasks → extensions/tasks/tool}/types.d.ts +1 -1
- package/dist/extensions/tasks/tool/types.d.ts.map +1 -0
- package/dist/extensions/tasks/tool/types.js.map +1 -0
- package/dist/extensions/tasks/tool.d.ts +6 -0
- package/dist/extensions/tasks/tool.d.ts.map +1 -0
- package/dist/{core/tools/tasks.js → extensions/tasks/tool.js} +6 -10
- package/dist/extensions/tasks/tool.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/completion-render.d.ts +1 -1
- package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/completion-render.js +2 -2
- package/dist/extensions/tasks/ui/completion-render.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/index.d.ts +1 -1
- package/dist/extensions/tasks/ui/index.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/index.js +4 -4
- package/dist/extensions/tasks/ui/index.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/inspector.d.ts +1 -1
- package/dist/extensions/tasks/ui/inspector.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/inspector.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/layout.d.ts +1 -1
- package/dist/extensions/tasks/ui/layout.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/layout.js +1 -1
- package/dist/extensions/tasks/ui/layout.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/list.d.ts +1 -1
- package/dist/extensions/tasks/ui/list.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/list.js +1 -1
- package/dist/extensions/tasks/ui/list.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/manager.d.ts +2 -1
- package/dist/extensions/tasks/ui/manager.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/manager.js +2 -1
- package/dist/extensions/tasks/ui/manager.js.map +1 -0
- package/dist/extensions/tasks/ui/model.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/model.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/render.d.ts +3 -3
- package/dist/extensions/tasks/ui/render.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/render.js +2 -2
- package/dist/extensions/tasks/ui/render.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/task-view.d.ts +1 -1
- package/dist/extensions/tasks/ui/task-view.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/task-view.js +1 -1
- package/dist/extensions/tasks/ui/task-view.js.map +1 -0
- package/dist/extensions/tasks/ui/text.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/text.js.map +1 -0
- package/dist/extensions/tasks/ui/tree.d.ts +7 -0
- package/dist/extensions/tasks/ui/tree.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks/host-hooks.js → extensions/tasks/ui/tree.js} +1 -18
- package/dist/extensions/tasks/ui/tree.js.map +1 -0
- package/dist/extensions/tasks/ui/viewport.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/viewport.js.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/views.d.ts +1 -1
- package/dist/extensions/tasks/ui/views.d.ts.map +1 -0
- package/dist/{modes/interactive/tasks → extensions/tasks/ui}/views.js +1 -1
- package/dist/extensions/tasks/ui/views.js.map +1 -0
- package/dist/extensions/tool-presentation/index.d.ts +7 -0
- package/dist/extensions/tool-presentation/index.d.ts.map +1 -0
- package/dist/extensions/tool-presentation/index.js +9 -0
- package/dist/extensions/tool-presentation/index.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +65 -18
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -3
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +85 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +362 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +5 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +14 -29
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tool-view/chat.d.ts +1 -1
- package/dist/modes/interactive/tool-view/chat.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/chat.js +2 -3
- package/dist/modes/interactive/tool-view/chat.js.map +1 -1
- package/dist/modes/interactive/tool-view/shell.d.ts +15 -0
- package/dist/modes/interactive/tool-view/shell.d.ts.map +1 -0
- package/dist/modes/interactive/tool-view/shell.js +51 -0
- package/dist/modes/interactive/tool-view/shell.js.map +1 -0
- package/dist/modes/interactive/tool-view/tool-execution.d.ts +10 -79
- package/dist/modes/interactive/tool-view/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/tool-execution.js +7 -298
- package/dist/modes/interactive/tool-view/tool-execution.js.map +1 -1
- package/docs/bundled/README.md +1 -4
- package/docs/bundled/tasks.md +3 -3
- package/docs/bundled/tool-presentation.md +9 -7
- package/docs/extensions.md +9 -4
- package/docs/settings.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/keybindings.schema.json +84 -52
- package/dist/core/tools/tasks/actions.d.ts.map +0 -1
- package/dist/core/tools/tasks/actions.js.map +0 -1
- package/dist/core/tools/tasks/constants.d.ts.map +0 -1
- package/dist/core/tools/tasks/constants.js.map +0 -1
- package/dist/core/tools/tasks/schema.d.ts.map +0 -1
- package/dist/core/tools/tasks/schema.js.map +0 -1
- package/dist/core/tools/tasks/types.d.ts.map +0 -1
- package/dist/core/tools/tasks/types.js.map +0 -1
- package/dist/core/tools/tasks.d.ts +0 -14
- package/dist/core/tools/tasks.d.ts.map +0 -1
- package/dist/core/tools/tasks.js.map +0 -1
- package/dist/modes/interactive/tasks/completion-render.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/completion-render.js.map +0 -1
- package/dist/modes/interactive/tasks/host-hooks.d.ts +0 -14
- package/dist/modes/interactive/tasks/host-hooks.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/host-hooks.js.map +0 -1
- package/dist/modes/interactive/tasks/index.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/index.js.map +0 -1
- package/dist/modes/interactive/tasks/inspector.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/inspector.js.map +0 -1
- package/dist/modes/interactive/tasks/layout.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/layout.js.map +0 -1
- package/dist/modes/interactive/tasks/list.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/list.js.map +0 -1
- package/dist/modes/interactive/tasks/manager.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/manager.js.map +0 -1
- package/dist/modes/interactive/tasks/model.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/model.js.map +0 -1
- package/dist/modes/interactive/tasks/render.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/render.js.map +0 -1
- package/dist/modes/interactive/tasks/task-view.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/task-view.js.map +0 -1
- package/dist/modes/interactive/tasks/text.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/text.js.map +0 -1
- package/dist/modes/interactive/tasks/viewport.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/viewport.js.map +0 -1
- package/dist/modes/interactive/tasks/views.d.ts.map +0 -1
- package/dist/modes/interactive/tasks/views.js.map +0 -1
- /package/dist/{core/tools/tasks → extensions/tasks/tool}/schema.d.ts +0 -0
- /package/dist/{core/tools/tasks → extensions/tasks/tool}/types.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/inspector.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/model.d.ts +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/model.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/text.d.ts +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/text.js +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/viewport.d.ts +0 -0
- /package/dist/{modes/interactive/tasks → extensions/tasks/ui}/viewport.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Container } from "@earendil-works/pi-tui";
|
|
2
|
-
import { ToolExecutionComponent } from "
|
|
2
|
+
import { ToolExecutionComponent } from "../components/tool-execution.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Chat container that keeps tool blocks compact and disposes them with the chat.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AASzE;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IACtC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IA0B/B,KAAK,IAAI,IAAI;CAItB;AAED,0EAA0E;AAC1E,qBAAa,cAAe,SAAQ,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAC7D,KAAK,IAAI,IAAI;CAItB;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAErD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Container } from "@earendil-works/pi-tui";
|
|
2
2
|
import { stripAnsi } from "../../../utils/ansi.js";
|
|
3
|
-
import {
|
|
4
|
-
import { ToolExecutionComponent } from "./tool-execution.js";
|
|
3
|
+
import { ToolExecutionComponent } from "../components/tool-execution.js";
|
|
5
4
|
function disposeAll(components) {
|
|
6
5
|
for (const component of components) {
|
|
7
6
|
const disposable = component;
|
|
@@ -27,7 +26,7 @@ export class ToolChatContainer extends Container {
|
|
|
27
26
|
const start = lines.findIndex((line) => stripAnsi(line).trim().length > 0);
|
|
28
27
|
if (start === -1)
|
|
29
28
|
continue;
|
|
30
|
-
const { afterTool, afterMultilineTool, afterOther } =
|
|
29
|
+
const { afterTool, afterMultilineTool, afterOther } = child.getToolRowGap();
|
|
31
30
|
child.setLeadingGap(previous instanceof ToolExecutionComponent
|
|
32
31
|
? previousHeight > 1
|
|
33
32
|
? afterMultilineTool
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,sBAA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,gEAAgE;QAChE,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAEQ,KAAK;QACb,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,KAAK,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACD;AAED,0EAA0E;AAC1E,MAAM,OAAO,cAAe,SAAQ,GAAmC;IAC7D,KAAK;QACb,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACD;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,IAAe;IAC9C,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { type Component, Container } from \"@earendil-works/pi-tui\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { ToolExecutionComponent } from \"../components/tool-execution.ts\";\n\nfunction disposeAll(components: Iterable<unknown>): void {\n\tfor (const component of components) {\n\t\tconst disposable = component as { dispose?: () => void };\n\t\tif (typeof disposable.dispose === \"function\") disposable.dispose();\n\t}\n}\n\n/**\n * Chat container that keeps tool blocks compact and disposes them with the chat.\n *\n * Single-line tools read as one compact list; a multiline tool leaves a blank line before the\n * next tool. Clearing the chat disposes its tool rows, so renderer timers never outlive them.\n */\nexport class ToolChatContainer extends Container {\n\toverride render(width: number): string[] {\n\t\tlet previous: Component | undefined;\n\t\tlet previousHeight = 0;\n\t\tfor (const child of this.children) {\n\t\t\tif (child instanceof ToolExecutionComponent) {\n\t\t\t\t// Measure at this width without external spacing, including wrapped titles and images.\n\t\t\t\tchild.setLeadingGap(0);\n\t\t\t\tconst lines = child.render(width);\n\t\t\t\tconst start = lines.findIndex((line) => stripAnsi(line).trim().length > 0);\n\t\t\t\tif (start === -1) continue;\n\t\t\t\tconst { afterTool, afterMultilineTool, afterOther } = child.getToolRowGap();\n\t\t\t\tchild.setLeadingGap(\n\t\t\t\t\tprevious instanceof ToolExecutionComponent\n\t\t\t\t\t\t? previousHeight > 1\n\t\t\t\t\t\t\t? afterMultilineTool\n\t\t\t\t\t\t\t: afterTool\n\t\t\t\t\t\t: afterOther,\n\t\t\t\t);\n\t\t\t\tpreviousHeight = lines.length - start;\n\t\t\t}\n\t\t\tprevious = child;\n\t\t}\n\t\t// Keep Container's mouse layout in sync with the final spacing.\n\t\treturn super.render(width);\n\t}\n\n\toverride clear(): void {\n\t\tdisposeAll(this.children);\n\t\tsuper.clear();\n\t}\n}\n\n/** Pending tool rows by call ID; clear() disposes the rows it forgets. */\nexport class PendingToolMap extends Map<string, ToolExecutionComponent> {\n\toverride clear(): void {\n\t\tdisposeAll(this.values());\n\t\tsuper.clear();\n\t}\n}\n\n/** Dispose every row still shown, for mode shutdown where the chat is not cleared. */\nexport function disposeChatRows(chat: Container): void {\n\tdisposeAll(chat.children);\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolExecutionShell, ToolRenderers } from "../../../core/extensions/types.ts";
|
|
2
|
+
export type ToolDefinitionLike = ToolRenderers | ToolDefinition<any, any, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Create the distribution's TUI chrome without changing a tool's call or result renderers.
|
|
5
|
+
* The native component invokes these fallbacks only when the corresponding renderer slot is empty
|
|
6
|
+
* or fails. HTML export never reads this object.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createToolShell(toolName: string, definition: ToolDefinitionLike | undefined): ToolExecutionShell;
|
|
9
|
+
/**
|
|
10
|
+
* Attach the distribution shell while preserving renderer identity and explicit shell ownership.
|
|
11
|
+
* In particular, this does not set renderShell or wrap renderCall/renderResult, so HTML export and
|
|
12
|
+
* other renderer resolvers continue to see the original functions.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withToolShell(toolName: string, definition: ToolDefinitionLike | undefined): ToolDefinitionLike;
|
|
15
|
+
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/shell.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,cAAc,EACd,kBAAkB,EAElB,aAAa,EACb,MAAM,mCAAmC,CAAC;AAM3C,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAS/E;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,SAAS,GAAG,kBAAkB,CAuBhH;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,SAAS,GAAG,kBAAkB,CAG9G"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Container } from "@earendil-works/pi-tui";
|
|
2
|
+
import { getTextOutput as getRenderedTextOutput } from "../../../core/tools/render-utils.js";
|
|
3
|
+
import { createAllToolRenderers } from "../../../core/tools/renderers/index.js";
|
|
4
|
+
import { createCallFallback, FallbackResultComponent } from "./fallback.js";
|
|
5
|
+
import { FramedComponent, toolMarkerColor, toolStatus, toolStyle } from "./style.js";
|
|
6
|
+
let builtInRenderers;
|
|
7
|
+
function builtInResultRenderer(toolName) {
|
|
8
|
+
builtInRenderers ??= createAllToolRenderers();
|
|
9
|
+
return builtInRenderers[toolName]?.renderResult;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create the distribution's TUI chrome without changing a tool's call or result renderers.
|
|
13
|
+
* The native component invokes these fallbacks only when the corresponding renderer slot is empty
|
|
14
|
+
* or fails. HTML export never reads this object.
|
|
15
|
+
*/
|
|
16
|
+
export function createToolShell(toolName, definition) {
|
|
17
|
+
const resultRenderer = definition?.renderResult;
|
|
18
|
+
return {
|
|
19
|
+
get gap() {
|
|
20
|
+
return toolStyle.gap;
|
|
21
|
+
},
|
|
22
|
+
frame(component, kind, context) {
|
|
23
|
+
return new FramedComponent(component, kind, () => toolMarkerColor(toolStatus(context)));
|
|
24
|
+
},
|
|
25
|
+
renderCall(args, _theme, context) {
|
|
26
|
+
return createCallFallback(toolName, args, context.expanded);
|
|
27
|
+
},
|
|
28
|
+
renderResult(result, _options, _theme, context) {
|
|
29
|
+
const output = getRenderedTextOutput(result, context.showImages);
|
|
30
|
+
return output ? new FallbackResultComponent(output, context.expanded) : new Container();
|
|
31
|
+
},
|
|
32
|
+
shouldHideResult(context) {
|
|
33
|
+
if (context.expanded || context.isError || !toolStyle.collapsed.headerOnly.has(toolName))
|
|
34
|
+
return false;
|
|
35
|
+
const builtIn = builtInResultRenderer(toolName);
|
|
36
|
+
// Only fold the built-in result renderer. An extension that replaces it owns its collapsed view.
|
|
37
|
+
return builtIn !== undefined && builtIn === resultRenderer;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Attach the distribution shell while preserving renderer identity and explicit shell ownership.
|
|
43
|
+
* In particular, this does not set renderShell or wrap renderCall/renderResult, so HTML export and
|
|
44
|
+
* other renderer resolvers continue to see the original functions.
|
|
45
|
+
*/
|
|
46
|
+
export function withToolShell(toolName, definition) {
|
|
47
|
+
if (definition?.renderShell === "self" || definition?.shell)
|
|
48
|
+
return definition;
|
|
49
|
+
return { ...(definition ?? {}), shell: createToolShell(toolName, definition) };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAOnE,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AACh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AS,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,OAAO,KAAK,CAAC;YACvG,MAAM,OAAO,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAChD,iGAAiG;YACjG,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,cAAc,CAAC;QAC5D,CAAC;KACD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,UAA0C;IACzF,IAAI,UAAU,EAAE,WAAW,KAAK,MAAM,IAAI,UAAU,EAAE,KAAK;QAAE,OAAO,UAAU,CAAC;IAC/E,OAAO,EAAE,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;AAChF,CAAC","sourcesContent":["import { type Component, Container } from \"@earendil-works/pi-tui\";\nimport type {\n\tToolDefinition,\n\tToolExecutionShell,\n\tToolRenderContext,\n\tToolRenderers,\n} from \"../../../core/extensions/types.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { createAllToolRenderers } from \"../../../core/tools/renderers/index.ts\";\nimport { createCallFallback, FallbackResultComponent } from \"./fallback.ts\";\nimport { FramedComponent, toolMarkerColor, toolStatus, toolStyle } from \"./style.ts\";\n\nexport type ToolDefinitionLike = ToolRenderers | ToolDefinition<any, any, any>;\n\nlet builtInRenderers: ReturnType<typeof createAllToolRenderers> | undefined;\n\nfunction builtInResultRenderer(toolName: string): ToolRenderers[\"renderResult\"] {\n\tbuiltInRenderers ??= createAllToolRenderers();\n\treturn (builtInRenderers as Record<string, ToolRenderers>)[toolName]?.renderResult;\n}\n\n/**\n * Create the distribution's TUI chrome without changing a tool's call or result renderers.\n * The native component invokes these fallbacks only when the corresponding renderer slot is empty\n * or fails. HTML export never reads this object.\n */\nexport function createToolShell(toolName: string, definition: ToolDefinitionLike | undefined): ToolExecutionShell {\n\tconst resultRenderer = definition?.renderResult;\n\treturn {\n\t\tget gap() {\n\t\t\treturn toolStyle.gap;\n\t\t},\n\t\tframe(component: Component, kind: \"header\" | \"body\", context: ToolRenderContext): Component {\n\t\t\treturn new FramedComponent(component, kind, () => toolMarkerColor(toolStatus(context)));\n\t\t},\n\t\trenderCall(args, _theme, context) {\n\t\t\treturn createCallFallback(toolName, args, context.expanded);\n\t\t},\n\t\trenderResult(result, _options, _theme, context) {\n\t\t\tconst output = getRenderedTextOutput(result, context.showImages);\n\t\t\treturn output ? new FallbackResultComponent(output, context.expanded) : new Container();\n\t\t},\n\t\tshouldHideResult(context) {\n\t\t\tif (context.expanded || context.isError || !toolStyle.collapsed.headerOnly.has(toolName)) return false;\n\t\t\tconst builtIn = builtInResultRenderer(toolName);\n\t\t\t// Only fold the built-in result renderer. An extension that replaces it owns its collapsed view.\n\t\t\treturn builtIn !== undefined && builtIn === resultRenderer;\n\t\t},\n\t};\n}\n\n/**\n * Attach the distribution shell while preserving renderer identity and explicit shell ownership.\n * In particular, this does not set renderShell or wrap renderCall/renderResult, so HTML export and\n * other renderer resolvers continue to see the original functions.\n */\nexport function withToolShell(toolName: string, definition: ToolDefinitionLike | undefined): ToolDefinitionLike {\n\tif (definition?.renderShell === \"self\" || definition?.shell) return definition;\n\treturn { ...(definition ?? {}), shell: createToolShell(toolName, definition) };\n}\n"]}
|
|
@@ -1,83 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
imageWidthCells?: number;
|
|
7
|
-
outputPad?: number;
|
|
8
|
-
}
|
|
1
|
+
import type { TUI } from "@earendil-works/pi-tui";
|
|
2
|
+
import { ToolExecutionComponent as NativeToolExecutionComponent, type ToolExecutionOptions } from "../components/tool-execution.ts";
|
|
3
|
+
import { type ToolDefinitionLike } from "./shell.ts";
|
|
4
|
+
export type { ToolRenderers } from "../../../core/extensions/types.ts";
|
|
5
|
+
export type { ToolExecutionOptions } from "../components/tool-execution.ts";
|
|
9
6
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Compatibility entry point for the distribution's original tool-view import path.
|
|
8
|
+
* Lifecycle and renderer composition live in the native component; this adapter only supplies
|
|
9
|
+
* the default shell for callers that construct the old distribution component directly.
|
|
12
10
|
*/
|
|
13
|
-
export declare class ToolExecutionComponent extends
|
|
14
|
-
|
|
15
|
-
private contentContainer;
|
|
16
|
-
private selfRenderContainer;
|
|
17
|
-
private selfRenderHeight;
|
|
18
|
-
private callRendererComponent?;
|
|
19
|
-
private resultRendererComponent?;
|
|
20
|
-
private rendererState;
|
|
21
|
-
private imageComponents;
|
|
22
|
-
private imageSources;
|
|
23
|
-
private imageSpacers;
|
|
24
|
-
private toolName;
|
|
25
|
-
private toolCallId;
|
|
26
|
-
private args;
|
|
27
|
-
private expanded;
|
|
28
|
-
private showImages;
|
|
29
|
-
private imageWidthCells;
|
|
30
|
-
private outputPad;
|
|
31
|
-
private isPartial;
|
|
32
|
-
private toolDefinition?;
|
|
33
|
-
private ui;
|
|
34
|
-
private cwd;
|
|
35
|
-
private executionStarted;
|
|
36
|
-
private argsComplete;
|
|
37
|
-
private result?;
|
|
38
|
-
private hideComponent;
|
|
39
|
-
private disposed;
|
|
40
|
-
constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolRenderers | ToolDefinition<any, any, any> | undefined, ui: TUI, cwd: string);
|
|
41
|
-
private getCallRenderer;
|
|
42
|
-
private getResultRenderer;
|
|
43
|
-
private isSelfRendered;
|
|
44
|
-
private status;
|
|
45
|
-
/** Blank lines above this row; the chat sets it from what precedes the row. */
|
|
46
|
-
setLeadingGap(lines: number): void;
|
|
47
|
-
private getRenderContext;
|
|
48
|
-
private frame;
|
|
49
|
-
private createResultFallback;
|
|
50
|
-
/**
|
|
51
|
-
* A successful result of an explore tool stays hidden until expanded; a failure always shows.
|
|
52
|
-
* Only the built-in result renderer is folded, so an extension that overrides the tool with its
|
|
53
|
-
* own renderResult keeps control of what its row shows.
|
|
54
|
-
*/
|
|
55
|
-
private hidesCollapsedResult;
|
|
56
|
-
private createResultRegion;
|
|
57
|
-
updateArgs(args: any): void;
|
|
58
|
-
markExecutionStarted(): void;
|
|
59
|
-
setArgsComplete(): void;
|
|
60
|
-
updateResult(result: {
|
|
61
|
-
content: Array<{
|
|
62
|
-
type: string;
|
|
63
|
-
text?: string;
|
|
64
|
-
data?: string;
|
|
65
|
-
mimeType?: string;
|
|
66
|
-
}>;
|
|
67
|
-
details?: any;
|
|
68
|
-
isError: boolean;
|
|
69
|
-
/** Execution time of a final result. */
|
|
70
|
-
durationMs?: number;
|
|
71
|
-
}, isPartial?: boolean): void;
|
|
72
|
-
setExpanded(expanded: boolean): void;
|
|
73
|
-
setOutputPad(outputPad: number): void;
|
|
74
|
-
setShowImages(show: boolean): void;
|
|
75
|
-
setImageWidthCells(width: number): void;
|
|
76
|
-
invalidate(): void;
|
|
77
|
-
render(width: number): string[];
|
|
78
|
-
handleMouse(event: TuiMouseEvent): ReturnType<Container["handleMouse"]>;
|
|
79
|
-
private updateDisplay;
|
|
80
|
-
private getTextOutput;
|
|
81
|
-
dispose(): void;
|
|
11
|
+
export declare class ToolExecutionComponent extends NativeToolExecutionComponent {
|
|
12
|
+
constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolDefinitionLike | undefined, ui: TUI, cwd: string);
|
|
82
13
|
}
|
|
83
14
|
//# sourceMappingURL=tool-execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/tool-execution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EACN,sBAAsB,IAAI,4BAA4B,EACtD,KAAK,oBAAoB,EACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,YAAY,CAAC;AAEpE,YAAY,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,YAAY,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,4BAA4B;gBAEtE,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,oBAAoB,YAAK,EAClC,cAAc,EAAE,kBAAkB,GAAG,SAAS,EAC9C,EAAE,EAAE,GAAG,EACP,GAAG,EAAE,MAAM;CAIZ"}
|
|
@@ -1,304 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createAllToolRenderers } from "../../../core/tools/renderers/index.js";
|
|
4
|
-
import { ensurePngTranscoder } from "../../../utils/image-convert.js";
|
|
5
|
-
import { theme } from "../theme/theme.js";
|
|
6
|
-
import { createCallFallback, FallbackResultComponent } from "./fallback.js";
|
|
7
|
-
import { FramedComponent, toolMarkerColor, toolStatus, toolStyle } from "./style.js";
|
|
8
|
-
let builtInRenderers;
|
|
1
|
+
import { ToolExecutionComponent as NativeToolExecutionComponent, } from "../components/tool-execution.js";
|
|
2
|
+
import { withToolShell } from "./shell.js";
|
|
9
3
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* Compatibility entry point for the distribution's original tool-view import path.
|
|
5
|
+
* Lifecycle and renderer composition live in the native component; this adapter only supplies
|
|
6
|
+
* the default shell for callers that construct the old distribution component directly.
|
|
12
7
|
*/
|
|
13
|
-
export class ToolExecutionComponent extends
|
|
8
|
+
export class ToolExecutionComponent extends NativeToolExecutionComponent {
|
|
14
9
|
constructor(toolName, toolCallId, args, options = {}, toolDefinition, ui, cwd) {
|
|
15
|
-
super();
|
|
16
|
-
this.selfRenderHeight = 0;
|
|
17
|
-
this.rendererState = {};
|
|
18
|
-
this.imageComponents = [];
|
|
19
|
-
this.imageSources = [];
|
|
20
|
-
this.imageSpacers = [];
|
|
21
|
-
this.expanded = false;
|
|
22
|
-
this.isPartial = true;
|
|
23
|
-
this.executionStarted = false;
|
|
24
|
-
this.argsComplete = false;
|
|
25
|
-
this.hideComponent = false;
|
|
26
|
-
this.disposed = false;
|
|
27
|
-
this.toolName = toolName;
|
|
28
|
-
this.toolCallId = toolCallId;
|
|
29
|
-
this.args = args;
|
|
30
|
-
this.toolDefinition = toolDefinition;
|
|
31
|
-
this.showImages = options.showImages ?? true;
|
|
32
|
-
this.imageWidthCells = options.imageWidthCells ?? 60;
|
|
33
|
-
this.outputPad = options.outputPad ?? 1;
|
|
34
|
-
this.ui = ui;
|
|
35
|
-
this.cwd = cwd;
|
|
36
|
-
this.gap = new Spacer(toolStyle.gap.afterOther);
|
|
37
|
-
this.addChild(this.gap);
|
|
38
|
-
this.contentContainer = new Container();
|
|
39
|
-
this.selfRenderContainer = new Container();
|
|
40
|
-
this.addChild(this.isSelfRendered() ? this.selfRenderContainer : this.contentContainer);
|
|
41
|
-
this.updateDisplay();
|
|
42
|
-
}
|
|
43
|
-
getCallRenderer() {
|
|
44
|
-
return this.toolDefinition?.renderCall;
|
|
45
|
-
}
|
|
46
|
-
getResultRenderer() {
|
|
47
|
-
return this.toolDefinition?.renderResult;
|
|
48
|
-
}
|
|
49
|
-
isSelfRendered() {
|
|
50
|
-
return this.toolDefinition?.renderShell === "self";
|
|
51
|
-
}
|
|
52
|
-
status() {
|
|
53
|
-
return toolStatus({ isPartial: this.isPartial, isError: this.result?.isError ?? false });
|
|
54
|
-
}
|
|
55
|
-
/** Blank lines above this row; the chat sets it from what precedes the row. */
|
|
56
|
-
setLeadingGap(lines) {
|
|
57
|
-
this.gap.setLines(lines);
|
|
58
|
-
}
|
|
59
|
-
getRenderContext(lastComponent) {
|
|
60
|
-
return {
|
|
61
|
-
args: this.args,
|
|
62
|
-
toolCallId: this.toolCallId,
|
|
63
|
-
invalidate: () => {
|
|
64
|
-
if (this.disposed)
|
|
65
|
-
return;
|
|
66
|
-
this.invalidate();
|
|
67
|
-
this.ui.requestRender();
|
|
68
|
-
},
|
|
69
|
-
lastComponent,
|
|
70
|
-
state: this.rendererState,
|
|
71
|
-
cwd: this.cwd,
|
|
72
|
-
executionStarted: this.executionStarted,
|
|
73
|
-
argsComplete: this.argsComplete,
|
|
74
|
-
isPartial: this.isPartial,
|
|
75
|
-
expanded: this.expanded,
|
|
76
|
-
showImages: this.showImages,
|
|
77
|
-
isError: this.result?.isError ?? false,
|
|
78
|
-
durationMs: this.isPartial ? undefined : this.result?.durationMs,
|
|
79
|
-
outputPad: this.outputPad,
|
|
80
|
-
result: this.result
|
|
81
|
-
? {
|
|
82
|
-
content: this.result.content,
|
|
83
|
-
details: this.result.details,
|
|
84
|
-
}
|
|
85
|
-
: undefined,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
frame(component, kind) {
|
|
89
|
-
return new FramedComponent(component, kind, () => toolMarkerColor(this.status()));
|
|
90
|
-
}
|
|
91
|
-
createResultFallback() {
|
|
92
|
-
const output = this.getTextOutput();
|
|
93
|
-
if (!output) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
return new FallbackResultComponent(output, this.expanded);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* A successful result of an explore tool stays hidden until expanded; a failure always shows.
|
|
100
|
-
* Only the built-in result renderer is folded, so an extension that overrides the tool with its
|
|
101
|
-
* own renderResult keeps control of what its row shows.
|
|
102
|
-
*/
|
|
103
|
-
hidesCollapsedResult() {
|
|
104
|
-
if (this.expanded || this.result?.isError || !toolStyle.collapsed.headerOnly.has(this.toolName))
|
|
105
|
-
return false;
|
|
106
|
-
builtInRenderers ??= createAllToolRenderers();
|
|
107
|
-
const builtIn = builtInRenderers[this.toolName];
|
|
108
|
-
return builtIn?.renderResult !== undefined && builtIn.renderResult === this.getResultRenderer();
|
|
109
|
-
}
|
|
110
|
-
createResultRegion(component) {
|
|
111
|
-
return new MouseRegion(component, (event) => {
|
|
112
|
-
if (!this.result || event.type !== "click" || event.button !== "left")
|
|
113
|
-
return undefined;
|
|
114
|
-
this.setExpanded(!this.expanded);
|
|
115
|
-
return { handled: true };
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
updateArgs(args) {
|
|
119
|
-
this.args = args;
|
|
120
|
-
this.updateDisplay();
|
|
121
|
-
}
|
|
122
|
-
markExecutionStarted() {
|
|
123
|
-
if (this.disposed)
|
|
124
|
-
return;
|
|
125
|
-
this.executionStarted = true;
|
|
126
|
-
this.updateDisplay();
|
|
127
|
-
this.ui.requestRender();
|
|
128
|
-
}
|
|
129
|
-
setArgsComplete() {
|
|
130
|
-
this.argsComplete = true;
|
|
131
|
-
this.updateDisplay();
|
|
132
|
-
this.ui.requestRender();
|
|
133
|
-
}
|
|
134
|
-
updateResult(result, isPartial = false) {
|
|
135
|
-
this.result = result;
|
|
136
|
-
this.isPartial = isPartial;
|
|
137
|
-
this.updateDisplay();
|
|
138
|
-
}
|
|
139
|
-
setExpanded(expanded) {
|
|
140
|
-
this.expanded = expanded;
|
|
141
|
-
this.updateDisplay();
|
|
142
|
-
}
|
|
143
|
-
setOutputPad(outputPad) {
|
|
144
|
-
this.outputPad = outputPad;
|
|
145
|
-
this.updateDisplay();
|
|
146
|
-
}
|
|
147
|
-
setShowImages(show) {
|
|
148
|
-
this.showImages = show;
|
|
149
|
-
this.updateDisplay();
|
|
150
|
-
}
|
|
151
|
-
setImageWidthCells(width) {
|
|
152
|
-
this.imageWidthCells = Math.max(1, Math.floor(width));
|
|
153
|
-
this.updateDisplay();
|
|
154
|
-
}
|
|
155
|
-
invalidate() {
|
|
156
|
-
super.invalidate();
|
|
157
|
-
this.updateDisplay();
|
|
158
|
-
}
|
|
159
|
-
render(width) {
|
|
160
|
-
if (this.hideComponent) {
|
|
161
|
-
return [];
|
|
162
|
-
}
|
|
163
|
-
if (this.isSelfRendered()) {
|
|
164
|
-
const contentLines = this.selfRenderContainer.render(width);
|
|
165
|
-
this.selfRenderHeight = contentLines.length;
|
|
166
|
-
if (contentLines.length === 0 && this.imageComponents.length === 0) {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
const lines = [];
|
|
170
|
-
if (contentLines.length > 0) {
|
|
171
|
-
lines.push("");
|
|
172
|
-
lines.push(...contentLines);
|
|
173
|
-
}
|
|
174
|
-
for (let i = 0; i < this.imageComponents.length; i++) {
|
|
175
|
-
const spacer = this.imageSpacers[i];
|
|
176
|
-
if (spacer) {
|
|
177
|
-
lines.push(...spacer.render(width));
|
|
178
|
-
}
|
|
179
|
-
const imageComponent = this.imageComponents[i];
|
|
180
|
-
if (imageComponent) {
|
|
181
|
-
lines.push(...imageComponent.render(width));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return lines;
|
|
185
|
-
}
|
|
186
|
-
return super.render(width);
|
|
187
|
-
}
|
|
188
|
-
handleMouse(event) {
|
|
189
|
-
if (!this.isSelfRendered())
|
|
190
|
-
return super.handleMouse(event);
|
|
191
|
-
if (event.y <= 0 || event.y > this.selfRenderHeight)
|
|
192
|
-
return undefined;
|
|
193
|
-
return this.selfRenderContainer.handleMouse({
|
|
194
|
-
...event,
|
|
195
|
-
y: event.y - 1,
|
|
196
|
-
height: this.selfRenderHeight,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
updateDisplay() {
|
|
200
|
-
let hasContent = false;
|
|
201
|
-
this.hideComponent = false;
|
|
202
|
-
const selfRendered = this.isSelfRendered();
|
|
203
|
-
const renderContainer = selfRendered ? this.selfRenderContainer : this.contentContainer;
|
|
204
|
-
renderContainer.clear();
|
|
205
|
-
const addCall = (component) => {
|
|
206
|
-
renderContainer.addChild(selfRendered ? component : this.createResultRegion(this.frame(component, "header")));
|
|
207
|
-
hasContent = true;
|
|
208
|
-
};
|
|
209
|
-
const addResult = (component) => {
|
|
210
|
-
renderContainer.addChild(selfRendered ? component : this.createResultRegion(this.frame(component, "body")));
|
|
211
|
-
hasContent = true;
|
|
212
|
-
};
|
|
213
|
-
const callRenderer = this.getCallRenderer();
|
|
214
|
-
if (!callRenderer) {
|
|
215
|
-
addCall(createCallFallback(this.toolName, this.args, this.expanded));
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
try {
|
|
219
|
-
const component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));
|
|
220
|
-
this.callRendererComponent = component;
|
|
221
|
-
addCall(component);
|
|
222
|
-
}
|
|
223
|
-
catch {
|
|
224
|
-
this.callRendererComponent = undefined;
|
|
225
|
-
addCall(createCallFallback(this.toolName, this.args, this.expanded));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (this.result && (selfRendered || !this.hidesCollapsedResult())) {
|
|
229
|
-
const resultRenderer = this.getResultRenderer();
|
|
230
|
-
if (!resultRenderer) {
|
|
231
|
-
const component = this.createResultFallback();
|
|
232
|
-
if (component)
|
|
233
|
-
addResult(component);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
try {
|
|
237
|
-
const component = resultRenderer({ content: this.result.content, details: this.result.details }, { expanded: this.expanded, isPartial: this.isPartial }, theme, this.getRenderContext(this.resultRendererComponent));
|
|
238
|
-
this.resultRendererComponent = component;
|
|
239
|
-
addResult(component);
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
242
|
-
this.resultRendererComponent = undefined;
|
|
243
|
-
const component = this.createResultFallback();
|
|
244
|
-
if (component)
|
|
245
|
-
addResult(component);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const previousImages = this.imageComponents;
|
|
250
|
-
const previousSources = this.imageSources;
|
|
251
|
-
for (const img of this.imageComponents) {
|
|
252
|
-
this.removeChild(img);
|
|
253
|
-
}
|
|
254
|
-
this.imageComponents = [];
|
|
255
|
-
this.imageSources = [];
|
|
256
|
-
for (const spacer of this.imageSpacers) {
|
|
257
|
-
this.removeChild(spacer);
|
|
258
|
-
}
|
|
259
|
-
this.imageSpacers = [];
|
|
260
|
-
if (this.result) {
|
|
261
|
-
const imageBlocks = this.result.content.filter((c) => c.type === "image");
|
|
262
|
-
const caps = getCapabilities();
|
|
263
|
-
for (const img of imageBlocks) {
|
|
264
|
-
if (caps.images && this.showImages && img.data && img.mimeType) {
|
|
265
|
-
const spacer = new Spacer(1);
|
|
266
|
-
this.addChild(spacer);
|
|
267
|
-
this.imageSpacers.push(spacer);
|
|
268
|
-
const source = { data: img.data, mimeType: img.mimeType, widthCells: this.imageWidthCells };
|
|
269
|
-
const index = this.imageComponents.length;
|
|
270
|
-
const previous = previousSources[index];
|
|
271
|
-
const imageComponent = previous?.data === source.data &&
|
|
272
|
-
previous.mimeType === source.mimeType &&
|
|
273
|
-
previous.widthCells === source.widthCells
|
|
274
|
-
? previousImages[index]
|
|
275
|
-
: new Image(source.data, source.mimeType, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: source.widthCells });
|
|
276
|
-
if (source.mimeType !== "image/png") {
|
|
277
|
-
ensurePngTranscoder(() => {
|
|
278
|
-
if (this.disposed)
|
|
279
|
-
return;
|
|
280
|
-
this.invalidate();
|
|
281
|
-
this.ui.requestRender();
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
this.imageComponents.push(imageComponent);
|
|
285
|
-
this.imageSources.push(source);
|
|
286
|
-
this.addChild(imageComponent);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (!hasContent && this.imageComponents.length === 0) {
|
|
291
|
-
this.hideComponent = true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
getTextOutput() {
|
|
295
|
-
return getRenderedTextOutput(this.result, this.showImages);
|
|
296
|
-
}
|
|
297
|
-
dispose() {
|
|
298
|
-
if (this.disposed)
|
|
299
|
-
return;
|
|
300
|
-
this.disposed = true;
|
|
301
|
-
this.rendererState.dispose?.();
|
|
10
|
+
super(toolName, toolCallId, args, options, withToolShell(toolName, toolDefinition), ui, cwd);
|
|
302
11
|
}
|
|
303
12
|
}
|
|
304
13
|
//# sourceMappingURL=tool-execution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/tool-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,SAAS,EACT,eAAe,EACf,KAAK,EACL,WAAW,EACX,MAAM,GAGN,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAmB,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAUtG,IAAI,gBAAuE,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAiCpD,YACC,QAAgB,EAChB,UAAkB,EAClB,IAAS,EACT,UAAgC,EAAE,EAClC,cAAyE,EACzE,EAAO,EACP,GAAW;QAEX,KAAK,EAAE,CAAC;QAtCD,qBAAgB,GAAG,CAAC,CAAC;QAGrB,kBAAa,GAAQ,EAAE,CAAC;QACxB,oBAAe,GAAY,EAAE,CAAC;QAC9B,iBAAY,GAAkE,EAAE,CAAC;QACjF,iBAAY,GAAa,EAAE,CAAC;QAI5B,aAAQ,GAAG,KAAK,CAAC;QAIjB,cAAS,GAAG,IAAI,CAAC;QAIjB,qBAAgB,GAAG,KA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O;4BAC1B,IAAI,CAAC,UAAU,EAAE,CAAC;4BAClB,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;wBACzB,CAAC,CAAC,CAAC;oBACJ,CAAC;oBACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;oBAC1C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC/B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3B,CAAC;IACF,CAAC;IAEO,aAAa;QACpB,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO;QACN,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,aAA0C,CAAC,OAAO,EAAE,EAAE,CAAC;IAC9D,CAAC;CACD","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport {\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\tImage,\n\tMouseRegion,\n\tSpacer,\n\ttype TUI,\n\ttype TuiMouseEvent,\n} from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext, ToolRenderers } from \"../../../core/extensions/types.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { createAllToolRenderers } from \"../../../core/tools/renderers/index.ts\";\nimport { ensurePngTranscoder } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { createCallFallback, FallbackResultComponent } from \"./fallback.ts\";\nimport { FramedComponent, type ToolStatus, toolMarkerColor, toolStatus, toolStyle } from \"./style.ts\";\n\nexport type { ToolRenderers };\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\toutputPad?: number;\n}\n\nlet builtInRenderers: ReturnType<typeof createAllToolRenderers> | undefined;\n\n/**\n * One tool call in the transcript: a marker line for the call and a rail for its result.\n * `style.ts` owns how that looks; this class owns the call's lifecycle.\n */\nexport class ToolExecutionComponent extends Container {\n\tprivate gap: Spacer;\n\tprivate contentContainer: Container;\n\tprivate selfRenderContainer: Container;\n\tprivate selfRenderHeight = 0;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSources: Array<{ data: string; mimeType: string; widthCells: number }> = [];\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 outputPad: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolRenderers;\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\tdurationMs?: number;\n\t};\n\tprivate hideComponent = false;\n\tprivate disposed = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolRenderers | ToolDefinition<any, 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.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.outputPad = options.outputPad ?? 1;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.gap = new Spacer(toolStyle.gap.afterOther);\n\t\tthis.addChild(this.gap);\n\n\t\tthis.contentContainer = new Container();\n\t\tthis.selfRenderContainer = new Container();\n\t\tthis.addChild(this.isSelfRendered() ? this.selfRenderContainer : this.contentContainer);\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\treturn this.toolDefinition?.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\treturn this.toolDefinition?.renderResult;\n\t}\n\n\tprivate isSelfRendered(): boolean {\n\t\treturn this.toolDefinition?.renderShell === \"self\";\n\t}\n\n\tprivate status(): ToolStatus {\n\t\treturn toolStatus({ isPartial: this.isPartial, isError: this.result?.isError ?? false });\n\t}\n\n\t/** Blank lines above this row; the chat sets it from what precedes the row. */\n\tsetLeadingGap(lines: number): void {\n\t\tthis.gap.setLines(lines);\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\tif (this.disposed) return;\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\tdurationMs: this.isPartial ? undefined : this.result?.durationMs,\n\t\t\toutputPad: this.outputPad,\n\t\t\tresult: this.result\n\t\t\t\t? {\n\t\t\t\t\t\tcontent: this.result.content as AgentToolResult<unknown>[\"content\"],\n\t\t\t\t\t\tdetails: this.result.details,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\tprivate frame(component: Component, kind: \"header\" | \"body\"): Component {\n\t\treturn new FramedComponent(component, kind, () => toolMarkerColor(this.status()));\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 FallbackResultComponent(output, this.expanded);\n\t}\n\n\t/**\n\t * A successful result of an explore tool stays hidden until expanded; a failure always shows.\n\t * Only the built-in result renderer is folded, so an extension that overrides the tool with its\n\t * own renderResult keeps control of what its row shows.\n\t */\n\tprivate hidesCollapsedResult(): boolean {\n\t\tif (this.expanded || this.result?.isError || !toolStyle.collapsed.headerOnly.has(this.toolName)) return false;\n\t\tbuiltInRenderers ??= createAllToolRenderers();\n\t\tconst builtIn = (builtInRenderers as Record<string, ToolRenderers>)[this.toolName];\n\t\treturn builtIn?.renderResult !== undefined && builtIn.renderResult === this.getResultRenderer();\n\t}\n\n\tprivate createResultRegion(component: Component): MouseRegion {\n\t\treturn new MouseRegion(component, (event) => {\n\t\t\tif (!this.result || event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\t\tthis.setExpanded(!this.expanded);\n\t\t\treturn { handled: true };\n\t\t});\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\tif (this.disposed) return;\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\t/** Execution time of a final result. */\n\t\t\tdurationMs?: number;\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}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\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\n\t\tif (this.isSelfRendered()) {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tthis.selfRenderHeight = contentLines.length;\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst lines: string[] = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\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\treturn lines;\n\t\t}\n\n\t\treturn super.render(width);\n\t}\n\n\toverride handleMouse(event: TuiMouseEvent): ReturnType<Container[\"handleMouse\"]> {\n\t\tif (!this.isSelfRendered()) return super.handleMouse(event);\n\t\tif (event.y <= 0 || event.y > this.selfRenderHeight) return undefined;\n\t\treturn this.selfRenderContainer.handleMouse({\n\t\t\t...event,\n\t\t\ty: event.y - 1,\n\t\t\theight: this.selfRenderHeight,\n\t\t});\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tconst selfRendered = this.isSelfRendered();\n\t\tconst renderContainer = selfRendered ? this.selfRenderContainer : this.contentContainer;\n\t\trenderContainer.clear();\n\n\t\tconst addCall = (component: Component) => {\n\t\t\trenderContainer.addChild(selfRendered ? component : this.createResultRegion(this.frame(component, \"header\")));\n\t\t\thasContent = true;\n\t\t};\n\t\tconst addResult = (component: Component) => {\n\t\t\trenderContainer.addChild(selfRendered ? component : this.createResultRegion(this.frame(component, \"body\")));\n\t\t\thasContent = true;\n\t\t};\n\n\t\tconst callRenderer = this.getCallRenderer();\n\t\tif (!callRenderer) {\n\t\t\taddCall(createCallFallback(this.toolName, this.args, this.expanded));\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\taddCall(component);\n\t\t\t} catch {\n\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\taddCall(createCallFallback(this.toolName, this.args, this.expanded));\n\t\t\t}\n\t\t}\n\n\t\tif (this.result && (selfRendered || !this.hidesCollapsedResult())) {\n\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\tif (!resultRenderer) {\n\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\tif (component) addResult(component);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\ttheme,\n\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t);\n\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\taddResult(component);\n\t\t\t\t} catch {\n\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) addResult(component);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst previousImages = this.imageComponents;\n\t\tconst previousSources = this.imageSources;\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tthis.imageSources = [];\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 (const img of imageBlocks) {\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\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 source = { data: img.data, mimeType: img.mimeType, widthCells: this.imageWidthCells };\n\t\t\t\t\tconst index = this.imageComponents.length;\n\t\t\t\t\tconst previous = previousSources[index];\n\t\t\t\t\tconst imageComponent =\n\t\t\t\t\t\tprevious?.data === source.data &&\n\t\t\t\t\t\tprevious.mimeType === source.mimeType &&\n\t\t\t\t\t\tprevious.widthCells === source.widthCells\n\t\t\t\t\t\t\t? previousImages[index]\n\t\t\t\t\t\t\t: new Image(\n\t\t\t\t\t\t\t\t\tsource.data,\n\t\t\t\t\t\t\t\t\tsource.mimeType,\n\t\t\t\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t\t\t\t{ maxWidthCells: source.widthCells },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\tif (source.mimeType !== \"image/png\") {\n\t\t\t\t\t\tensurePngTranscoder(() => {\n\t\t\t\t\t\t\tif (this.disposed) return;\n\t\t\t\t\t\t\tthis.invalidate();\n\t\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.imageSources.push(source);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!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\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\t(this.rendererState as { dispose?: () => void }).dispose?.();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/tool-view/tool-execution.ts"],"names":[],"mappings":"AACA,OAAO,EACN,sBAAsB,IAAI,4BAA4B,GAEtD,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAA2B,aAAa,EAAE,MAAM,YAAY,CAAC;AAKpE;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,4BAA4B;IACvE,YACC,QAAgB,EAChB,UAAkB,EAClB,IAAS,EACT,UAAgC,EAAE,EAClC,cAA8C,EAC9C,EAAO,EACP,GAAW;QAEX,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAC9F,CAAC;CACD","sourcesContent":["import type { TUI } from \"@earendil-works/pi-tui\";\nimport {\n\tToolExecutionComponent as NativeToolExecutionComponent,\n\ttype ToolExecutionOptions,\n} from \"../components/tool-execution.ts\";\nimport { type ToolDefinitionLike, withToolShell } from \"./shell.ts\";\n\nexport type { ToolRenderers } from \"../../../core/extensions/types.ts\";\nexport type { ToolExecutionOptions } from \"../components/tool-execution.ts\";\n\n/**\n * Compatibility entry point for the distribution's original tool-view import path.\n * Lifecycle and renderer composition live in the native component; this adapter only supplies\n * the default shell for callers that construct the old distribution component directly.\n */\nexport class ToolExecutionComponent extends NativeToolExecutionComponent {\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinitionLike | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper(toolName, toolCallId, args, options, withToolShell(toolName, toolDefinition), ui, cwd);\n\t}\n}\n"]}
|
package/docs/bundled/README.md
CHANGED
|
@@ -25,13 +25,10 @@ The following extensions are additions maintained by `@astralyn/pi`:
|
|
|
25
25
|
| [Provider](extensions/provider.md) | `/provider` | Edit models.json providers: connection, API type, and models |
|
|
26
26
|
| [Statusline](extensions/statusline.md) | Footer status | Show concise extension-managed activity state |
|
|
27
27
|
| [Search](extensions/search.md) | `code_search`, `web_search` | Devin-driven semantic code search and web search with one shared key |
|
|
28
|
+
| [Tasks](tasks.md) | `tasks`, `/tasks` | Inspect and control native shell and extension-owned executions |
|
|
28
29
|
|
|
29
30
|
All bundled extensions use the public Extension API. Enable or disable them in `pi config` or through `builtin:<name>` entries in [settings](../settings.md#codemode-and-tool-selection). `--no-extensions` disables them; `-e builtin:<name>` loads one explicitly.
|
|
30
31
|
|
|
31
|
-
## Tasks
|
|
32
|
-
|
|
33
|
-
[Tasks](tasks.md) is a distribution-owned built-in capability, with the `tasks` tool and `/tasks` panel for native shell commands and extension-owned work. Ctrl+B hands foreground work to the background without restarting it.
|
|
34
|
-
|
|
35
32
|
## Context safety
|
|
36
33
|
|
|
37
34
|
Upstream Pi checks context after a completed tool batch and before the next provider request. If the active context crosses the configured auto-compaction threshold, Pi compacts and rebuilds it before continuing the same run. Cancellation, compaction failure, an unavailable cut point, or retained context that remains unsafe stops the run. This distribution adds a percentage-based trigger setting to upstream's compaction lifecycle.
|