@code-yeongyu/senpi 2026.7.10 → 2026.7.13
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 +79 -0
- package/README.md +4 -2
- package/dist/core/agent-session.d.ts +9 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +56 -15
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/timeout.js +2 -2
- package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +10 -1
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js +88 -3
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +134 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +6 -0
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
- package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts +3 -3
- package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.js +7 -4
- package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +5 -3
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.js +32 -16
- package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js +10 -4
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/tools/todowrite.js +5 -8
- package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +5 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +5 -8
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +22 -3
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/keybindings.d.ts +8 -3
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +7 -3
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -6
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +19 -6
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/resource-loader.d.ts +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +20 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +2 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/compaction-queue-transfer.d.ts +22 -0
- package/dist/modes/interactive/compaction-queue-transfer.d.ts.map +1 -0
- package/dist/modes/interactive/compaction-queue-transfer.js +82 -0
- package/dist/modes/interactive/compaction-queue-transfer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +4 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution-fallback.d.ts +6 -0
- package/dist/modes/interactive/components/tool-execution-fallback.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-fallback.js +40 -0
- package/dist/modes/interactive/components/tool-execution-fallback.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts +23 -0
- package/dist/modes/interactive/components/tool-execution-images.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-images.js +104 -0
- package/dist/modes/interactive/components/tool-execution-images.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution-renderer.d.ts +28 -0
- package/dist/modes/interactive/components/tool-execution-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-renderer.js +135 -0
- package/dist/modes/interactive/components/tool-execution-renderer.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution-types.d.ts +23 -0
- package/dist/modes/interactive/components/tool-execution-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution-types.js +2 -0
- package/dist/modes/interactive/components/tool-execution-types.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +13 -39
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +51 -294
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-renderer-boundary.d.ts +17 -0
- package/dist/modes/interactive/components/tool-renderer-boundary.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-renderer-boundary.js +75 -0
- package/dist/modes/interactive/components/tool-renderer-boundary.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +5 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +50 -17
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +5 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +127 -109
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +3 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +11 -4
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +13 -0
- package/dist/utils/clipboard.js.map +1 -1
- package/docs/custom-provider.md +4 -3
- package/docs/extensions.md +140 -1
- package/docs/keybindings.md +1 -0
- package/docs/models.md +45 -4
- package/docs/providers.md +3 -0
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +3 -3
- package/docs/themes.md +5 -3
- package/docs/tui.md +1 -1
- package/docs/usage.md +2 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@babel/helper-string-parser/LICENSE +22 -0
- package/node_modules/@babel/helper-string-parser/README.md +19 -0
- package/node_modules/@babel/helper-string-parser/lib/index.js +295 -0
- package/node_modules/@babel/helper-string-parser/lib/index.js.map +1 -0
- package/node_modules/@babel/helper-string-parser/package.json +31 -0
- package/node_modules/@babel/helper-validator-identifier/LICENSE +22 -0
- package/node_modules/@babel/helper-validator-identifier/README.md +19 -0
- package/node_modules/@babel/helper-validator-identifier/lib/identifier.js +70 -0
- package/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +1 -0
- package/node_modules/@babel/helper-validator-identifier/lib/index.js +57 -0
- package/node_modules/@babel/helper-validator-identifier/lib/index.js.map +1 -0
- package/node_modules/@babel/helper-validator-identifier/lib/keyword.js +35 -0
- package/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +1 -0
- package/node_modules/@babel/helper-validator-identifier/package.json +31 -0
- package/node_modules/@babel/parser/LICENSE +19 -0
- package/node_modules/@babel/parser/README.md +19 -0
- package/node_modules/@babel/parser/bin/babel-parser.js +15 -0
- package/node_modules/@babel/parser/lib/index.js +14599 -0
- package/node_modules/@babel/parser/lib/index.js.map +1 -0
- package/node_modules/@babel/parser/package.json +50 -0
- package/node_modules/@babel/parser/typings/babel-parser.d.ts +262 -0
- package/node_modules/@babel/types/LICENSE +22 -0
- package/node_modules/@babel/types/README.md +19 -0
- package/node_modules/@babel/types/lib/asserts/assertNode.js +16 -0
- package/node_modules/@babel/types/lib/asserts/assertNode.js.map +1 -0
- package/node_modules/@babel/types/lib/asserts/generated/index.js +1251 -0
- package/node_modules/@babel/types/lib/asserts/generated/index.js.map +1 -0
- package/node_modules/@babel/types/lib/ast-types/generated/index.js +3 -0
- package/node_modules/@babel/types/lib/ast-types/generated/index.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js +18 -0
- package/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js +31 -0
- package/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/generated/index.js +29 -0
- package/node_modules/@babel/types/lib/builders/generated/index.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/generated/lowercase.js +2902 -0
- package/node_modules/@babel/types/lib/builders/generated/lowercase.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/generated/uppercase.js +272 -0
- package/node_modules/@babel/types/lib/builders/generated/uppercase.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/productions.js +12 -0
- package/node_modules/@babel/types/lib/builders/productions.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/react/buildChildren.js +24 -0
- package/node_modules/@babel/types/lib/builders/react/buildChildren.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js +22 -0
- package/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map +1 -0
- package/node_modules/@babel/types/lib/builders/validateNode.js +21 -0
- package/node_modules/@babel/types/lib/builders/validateNode.js.map +1 -0
- package/node_modules/@babel/types/lib/clone/clone.js +12 -0
- package/node_modules/@babel/types/lib/clone/clone.js.map +1 -0
- package/node_modules/@babel/types/lib/clone/cloneDeep.js +12 -0
- package/node_modules/@babel/types/lib/clone/cloneDeep.js.map +1 -0
- package/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js +12 -0
- package/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js.map +1 -0
- package/node_modules/@babel/types/lib/clone/cloneNode.js +107 -0
- package/node_modules/@babel/types/lib/clone/cloneNode.js.map +1 -0
- package/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js +12 -0
- package/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/addComment.js +15 -0
- package/node_modules/@babel/types/lib/comments/addComment.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/addComments.js +22 -0
- package/node_modules/@babel/types/lib/comments/addComments.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/inheritInnerComments.js +12 -0
- package/node_modules/@babel/types/lib/comments/inheritInnerComments.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/inheritLeadingComments.js +12 -0
- package/node_modules/@babel/types/lib/comments/inheritLeadingComments.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/inheritTrailingComments.js +12 -0
- package/node_modules/@babel/types/lib/comments/inheritTrailingComments.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/inheritsComments.js +17 -0
- package/node_modules/@babel/types/lib/comments/inheritsComments.js.map +1 -0
- package/node_modules/@babel/types/lib/comments/removeComments.js +15 -0
- package/node_modules/@babel/types/lib/comments/removeComments.js.map +1 -0
- package/node_modules/@babel/types/lib/constants/generated/index.js +60 -0
- package/node_modules/@babel/types/lib/constants/generated/index.js.map +1 -0
- package/node_modules/@babel/types/lib/constants/index.js +31 -0
- package/node_modules/@babel/types/lib/constants/index.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/ensureBlock.js +14 -0
- package/node_modules/@babel/types/lib/converters/ensureBlock.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js +65 -0
- package/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js +14 -0
- package/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toBlock.js +29 -0
- package/node_modules/@babel/types/lib/converters/toBlock.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toComputedKey.js +14 -0
- package/node_modules/@babel/types/lib/converters/toComputedKey.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toExpression.js +28 -0
- package/node_modules/@babel/types/lib/converters/toExpression.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toIdentifier.js +25 -0
- package/node_modules/@babel/types/lib/converters/toIdentifier.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toKeyAlias.js +38 -0
- package/node_modules/@babel/types/lib/converters/toKeyAlias.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toSequenceExpression.js +19 -0
- package/node_modules/@babel/types/lib/converters/toSequenceExpression.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/toStatement.js +39 -0
- package/node_modules/@babel/types/lib/converters/toStatement.js.map +1 -0
- package/node_modules/@babel/types/lib/converters/valueToNode.js +89 -0
- package/node_modules/@babel/types/lib/converters/valueToNode.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/core.js +1725 -0
- package/node_modules/@babel/types/lib/definitions/core.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/deprecated-aliases.js +11 -0
- package/node_modules/@babel/types/lib/definitions/deprecated-aliases.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/experimental.js +124 -0
- package/node_modules/@babel/types/lib/definitions/experimental.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/flow.js +495 -0
- package/node_modules/@babel/types/lib/definitions/flow.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/index.js +106 -0
- package/node_modules/@babel/types/lib/definitions/index.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/jsx.js +157 -0
- package/node_modules/@babel/types/lib/definitions/jsx.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/misc.js +31 -0
- package/node_modules/@babel/types/lib/definitions/misc.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/placeholders.js +27 -0
- package/node_modules/@babel/types/lib/definitions/placeholders.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/typescript.js +528 -0
- package/node_modules/@babel/types/lib/definitions/typescript.js.map +1 -0
- package/node_modules/@babel/types/lib/definitions/utils.js +296 -0
- package/node_modules/@babel/types/lib/definitions/utils.js.map +1 -0
- package/node_modules/@babel/types/lib/index-legacy.d.ts +2797 -0
- package/node_modules/@babel/types/lib/index.d.ts +3617 -0
- package/node_modules/@babel/types/lib/index.js +582 -0
- package/node_modules/@babel/types/lib/index.js.flow +2650 -0
- package/node_modules/@babel/types/lib/index.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js +15 -0
- package/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js +65 -0
- package/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/inherits.js +28 -0
- package/node_modules/@babel/types/lib/modifications/inherits.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js +17 -0
- package/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/removeProperties.js +24 -0
- package/node_modules/@babel/types/lib/modifications/removeProperties.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js +14 -0
- package/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js.map +1 -0
- package/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js +66 -0
- package/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js.map +1 -0
- package/node_modules/@babel/types/lib/retrievers/getAssignmentIdentifiers.js +48 -0
- package/node_modules/@babel/types/lib/retrievers/getAssignmentIdentifiers.js.map +1 -0
- package/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js +102 -0
- package/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js.map +1 -0
- package/node_modules/@babel/types/lib/retrievers/getFunctionName.js +63 -0
- package/node_modules/@babel/types/lib/retrievers/getFunctionName.js.map +1 -0
- package/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js +13 -0
- package/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js.map +1 -0
- package/node_modules/@babel/types/lib/traverse/traverse.js +50 -0
- package/node_modules/@babel/types/lib/traverse/traverse.js.map +1 -0
- package/node_modules/@babel/types/lib/traverse/traverseFast.js +40 -0
- package/node_modules/@babel/types/lib/traverse/traverseFast.js.map +1 -0
- package/node_modules/@babel/types/lib/utils/deprecationWarning.js +44 -0
- package/node_modules/@babel/types/lib/utils/deprecationWarning.js.map +1 -0
- package/node_modules/@babel/types/lib/utils/inherit.js +13 -0
- package/node_modules/@babel/types/lib/utils/inherit.js.map +1 -0
- package/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js +40 -0
- package/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js.map +1 -0
- package/node_modules/@babel/types/lib/utils/shallowEqual.js +17 -0
- package/node_modules/@babel/types/lib/utils/shallowEqual.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js +13 -0
- package/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/generated/index.js +2797 -0
- package/node_modules/@babel/types/lib/validators/generated/index.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/is.js +27 -0
- package/node_modules/@babel/types/lib/validators/is.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isBinding.js +27 -0
- package/node_modules/@babel/types/lib/validators/isBinding.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isBlockScoped.js +13 -0
- package/node_modules/@babel/types/lib/validators/isBlockScoped.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isImmutable.js +21 -0
- package/node_modules/@babel/types/lib/validators/isImmutable.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isLet.js +13 -0
- package/node_modules/@babel/types/lib/validators/isLet.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isNode.js +12 -0
- package/node_modules/@babel/types/lib/validators/isNode.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isNodesEquivalent.js +57 -0
- package/node_modules/@babel/types/lib/validators/isNodesEquivalent.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isPlaceholderType.js +15 -0
- package/node_modules/@babel/types/lib/validators/isPlaceholderType.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isReferenced.js +96 -0
- package/node_modules/@babel/types/lib/validators/isReferenced.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isScope.js +18 -0
- package/node_modules/@babel/types/lib/validators/isScope.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +14 -0
- package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isType.js +17 -0
- package/node_modules/@babel/types/lib/validators/isType.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isValidES3Identifier.js +13 -0
- package/node_modules/@babel/types/lib/validators/isValidES3Identifier.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isValidIdentifier.js +18 -0
- package/node_modules/@babel/types/lib/validators/isValidIdentifier.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/isVar.js +15 -0
- package/node_modules/@babel/types/lib/validators/isVar.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/matchesPattern.js +44 -0
- package/node_modules/@babel/types/lib/validators/matchesPattern.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/react/isCompatTag.js +11 -0
- package/node_modules/@babel/types/lib/validators/react/isCompatTag.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/react/isReactComponent.js +11 -0
- package/node_modules/@babel/types/lib/validators/react/isReactComponent.js.map +1 -0
- package/node_modules/@babel/types/lib/validators/validate.js +42 -0
- package/node_modules/@babel/types/lib/validators/validate.js.map +1 -0
- package/node_modules/@babel/types/package.json +39 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +13 -2
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +128 -78
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/protocol.ts +22 -9
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/reserved.ts +9 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridges/agent-bridge.ts +197 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridges/output-bridge.ts +96 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/bridges/schema-injection.ts +3 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/completion/handler.ts +95 -26
- package/node_modules/@code-yeongyu/senpi-codemode/src/completion/tool-bridge.ts +14 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/config/settings.ts +96 -8
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +92 -10
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +187 -27
- package/node_modules/@code-yeongyu/senpi-codemode/src/interpreters/detect.ts +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/jl/prelude.jl +252 -48
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/jl/runner.jl +263 -83
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/context-manager.ts +198 -149
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker-entry.js +23 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker.ts +4 -175
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/kernel-contract.ts +38 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/local-module-loader.ts +108 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/prelude.ts +8 -6
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/rewrite-imports.ts +164 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/run-queue.ts +82 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-core.js +13 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-host.ts +117 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-runtime.js +307 -41
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel-contract.ts +32 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel.ts +232 -199
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +792 -79
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/process.ts +119 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +237 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/rb/prelude.rb +234 -21
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/rb/runner.rb +154 -51
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-contract.ts +22 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +214 -189
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-process.ts +174 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-queue.ts +101 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-run.ts +98 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/output/output-meta.ts +89 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/output/streaming-output.ts +296 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +107 -30
- package/node_modules/@code-yeongyu/senpi-codemode/src/timeouts/bridge-timeout.ts +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/timeouts/idle-timeout.ts +8 -19
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +267 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +226 -211
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/image.ts +274 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/json-tree.ts +247 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +828 -35
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/status-events.ts +12 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +30 -1
- package/node_modules/@earendil-works/pi-agent-core/README.md +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +4 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/README.md +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +89 -40
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +7 -7
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +10 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +35 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +8 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +483 -61
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +13 -4
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +5 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +62 -5
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +32 -20
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +6 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +7 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +20 -21
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +11 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +6 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js +9 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +100 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +64 -5
- package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +56 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +20 -9
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +77 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +37 -24
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +80 -4
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +64 -8
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +25 -22
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +68 -83
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +45 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +49 -13
- package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +30 -7
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.d.ts +9 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.d.ts +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +35 -14
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +2 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.js +6 -5
- package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -9
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +4 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +18 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -0
- package/node_modules/@earendil-works/pi-tui/package.json +2 -2
- package/package.json +6 -6
|
@@ -1,126 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createAllToolDefinitions } from "../../../core/tools/index.js";
|
|
3
|
-
import { getTextOutput as getRenderedTextOutput } from "../../../core/tools/render-utils.js";
|
|
4
|
-
import { stripAnsi } from "../../../utils/ansi.js";
|
|
5
|
-
import { convertToPng } from "../../../utils/image-convert.js";
|
|
6
|
-
import { theme } from "../theme/theme.js";
|
|
1
|
+
import { Container, Spacer } from "@earendil-works/pi-tui";
|
|
7
2
|
import { createBoundedRenderSignature } from "./render-signature.js";
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { ToolExecutionImages } from "./tool-execution-images.js";
|
|
4
|
+
import { ToolExecutionRenderer } from "./tool-execution-renderer.js";
|
|
10
5
|
const PENDING_RENDER_FRAME_INTERVAL_MS = 80;
|
|
11
|
-
function sanitizeFallbackString(value, maxLength = FALLBACK_STRING_MAX_LENGTH) {
|
|
12
|
-
const sanitized = stripAnsi(value)
|
|
13
|
-
.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ")
|
|
14
|
-
.replace(/\s+/g, " ")
|
|
15
|
-
.trim();
|
|
16
|
-
if (sanitized.length <= maxLength) {
|
|
17
|
-
return sanitized;
|
|
18
|
-
}
|
|
19
|
-
return `${sanitized.slice(0, Math.max(0, maxLength - 3))}...`;
|
|
20
|
-
}
|
|
21
|
-
function sanitizeFallbackJsonValue(_key, value) {
|
|
22
|
-
if (typeof value === "string") {
|
|
23
|
-
return sanitizeFallbackString(value);
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
6
|
export class ToolExecutionComponent extends Container {
|
|
28
7
|
constructor(toolName, toolCallId, args, options = {}, toolDefinition, ui, cwd) {
|
|
29
8
|
super();
|
|
30
|
-
this.rendererState = {};
|
|
31
|
-
this.imageComponents = [];
|
|
32
|
-
this.imageSpacers = [];
|
|
33
9
|
this.expanded = false;
|
|
34
10
|
this.isPartial = true;
|
|
35
11
|
this.executionStarted = false;
|
|
36
12
|
this.argsComplete = false;
|
|
37
|
-
this.
|
|
38
|
-
this.hideComponent = false;
|
|
39
|
-
this.toolName = toolName;
|
|
40
|
-
this.toolCallId = toolCallId;
|
|
13
|
+
this.identity = { toolName, toolCallId, cwd, toolDefinition };
|
|
41
14
|
this.args = args;
|
|
42
|
-
this.toolDefinition = toolDefinition;
|
|
43
|
-
this.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName];
|
|
44
15
|
this.showImages = options.showImages ?? true;
|
|
45
16
|
this.imageWidthCells = options.imageWidthCells ?? 60;
|
|
46
17
|
this.ui = ui;
|
|
47
|
-
|
|
18
|
+
const initialState = this.createRenderState();
|
|
19
|
+
this.renderer = new ToolExecutionRenderer(this.identity, initialState, () => {
|
|
20
|
+
this.invalidate();
|
|
21
|
+
this.ui.requestRender();
|
|
22
|
+
});
|
|
23
|
+
this.images = new ToolExecutionImages(() => {
|
|
24
|
+
this.invalidateRenderCache();
|
|
25
|
+
this.ui.requestRender();
|
|
26
|
+
});
|
|
48
27
|
this.addChild(new Spacer(1));
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// contentText is reserved for generic fallback rendering when no tool definition exists.
|
|
52
|
-
this.contentBox = new Box(1, 1, (text) => theme.bg("toolPendingBg", text));
|
|
53
|
-
this.contentText = new Text("", 1, 1, (text) => theme.bg("toolPendingBg", text));
|
|
54
|
-
this.selfRenderContainer = new Container();
|
|
55
|
-
if (this.hasRendererDefinition()) {
|
|
56
|
-
this.addChild(this.getRenderShell() === "self" ? this.selfRenderContainer : this.contentBox);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
this.addChild(this.contentText);
|
|
60
|
-
}
|
|
28
|
+
this.addChild(this.renderer);
|
|
29
|
+
this.addChild(this.images);
|
|
61
30
|
this.updateSpinnerAnimation();
|
|
62
31
|
this.updateDisplay();
|
|
63
32
|
}
|
|
64
|
-
getCallRenderer() {
|
|
65
|
-
if (!this.builtInToolDefinition) {
|
|
66
|
-
return this.toolDefinition?.renderCall;
|
|
67
|
-
}
|
|
68
|
-
if (!this.toolDefinition) {
|
|
69
|
-
return this.builtInToolDefinition.renderCall;
|
|
70
|
-
}
|
|
71
|
-
return this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;
|
|
72
|
-
}
|
|
73
|
-
getResultRenderer() {
|
|
74
|
-
if (!this.builtInToolDefinition) {
|
|
75
|
-
return this.toolDefinition?.renderResult;
|
|
76
|
-
}
|
|
77
|
-
if (!this.toolDefinition) {
|
|
78
|
-
return this.builtInToolDefinition.renderResult;
|
|
79
|
-
}
|
|
80
|
-
return this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;
|
|
81
|
-
}
|
|
82
|
-
hasRendererDefinition() {
|
|
83
|
-
return this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;
|
|
84
|
-
}
|
|
85
|
-
getRenderShell() {
|
|
86
|
-
if (!this.builtInToolDefinition) {
|
|
87
|
-
return this.toolDefinition?.renderShell ?? "default";
|
|
88
|
-
}
|
|
89
|
-
if (!this.toolDefinition) {
|
|
90
|
-
return this.builtInToolDefinition.renderShell ?? "default";
|
|
91
|
-
}
|
|
92
|
-
return this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? "default";
|
|
93
|
-
}
|
|
94
|
-
getRenderContext(lastComponent) {
|
|
95
|
-
return {
|
|
96
|
-
args: this.args,
|
|
97
|
-
toolCallId: this.toolCallId,
|
|
98
|
-
invalidate: () => {
|
|
99
|
-
this.invalidate();
|
|
100
|
-
this.ui.requestRender();
|
|
101
|
-
},
|
|
102
|
-
lastComponent,
|
|
103
|
-
state: this.rendererState,
|
|
104
|
-
cwd: this.cwd,
|
|
105
|
-
executionStarted: this.executionStarted,
|
|
106
|
-
argsComplete: this.argsComplete,
|
|
107
|
-
isPartial: this.isPartial,
|
|
108
|
-
expanded: this.expanded,
|
|
109
|
-
showImages: this.showImages,
|
|
110
|
-
isError: this.result?.isError ?? false,
|
|
111
|
-
spinnerFrame: this.spinnerFrame,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
createCallFallback() {
|
|
115
|
-
return new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0);
|
|
116
|
-
}
|
|
117
|
-
createResultFallback() {
|
|
118
|
-
const output = this.getTextOutput();
|
|
119
|
-
if (!output) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
return new Text(theme.fg("toolOutput", output), 0, 0);
|
|
123
|
-
}
|
|
124
33
|
updateArgs(args) {
|
|
125
34
|
this.args = args;
|
|
126
35
|
this.lastDisplaySignature = undefined;
|
|
@@ -142,42 +51,17 @@ export class ToolExecutionComponent extends Container {
|
|
|
142
51
|
updateResult(result, isPartial = false) {
|
|
143
52
|
this.result = result;
|
|
144
53
|
this.isPartial = isPartial;
|
|
145
|
-
if (!isPartial)
|
|
54
|
+
if (!isPartial)
|
|
146
55
|
this.argsComplete = true;
|
|
147
|
-
}
|
|
148
56
|
this.lastDisplaySignature = undefined;
|
|
149
57
|
this.updateSpinnerAnimation();
|
|
150
58
|
this.updateDisplay();
|
|
151
|
-
this.
|
|
59
|
+
this.images.updateResult(result);
|
|
60
|
+
this.invalidateRenderCache();
|
|
152
61
|
}
|
|
153
62
|
stopAnimation() {
|
|
154
63
|
this.stopSpinnerAnimation();
|
|
155
64
|
}
|
|
156
|
-
maybeConvertImagesForKitty() {
|
|
157
|
-
const caps = getCapabilities();
|
|
158
|
-
if (caps.images !== "kitty")
|
|
159
|
-
return;
|
|
160
|
-
if (!this.result)
|
|
161
|
-
return;
|
|
162
|
-
const imageBlocks = this.result.content.filter((c) => c.type === "image");
|
|
163
|
-
for (let i = 0; i < imageBlocks.length; i++) {
|
|
164
|
-
const img = imageBlocks[i];
|
|
165
|
-
if (!img.data || !img.mimeType)
|
|
166
|
-
continue;
|
|
167
|
-
if (img.mimeType === "image/png")
|
|
168
|
-
continue;
|
|
169
|
-
if (this.convertedImages.has(i))
|
|
170
|
-
continue;
|
|
171
|
-
const index = i;
|
|
172
|
-
convertToPng(img.data, img.mimeType).then((converted) => {
|
|
173
|
-
if (converted) {
|
|
174
|
-
this.convertedImages.set(index, converted);
|
|
175
|
-
this.updateDisplay();
|
|
176
|
-
this.ui.requestRender();
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
65
|
setExpanded(expanded) {
|
|
182
66
|
this.expanded = expanded;
|
|
183
67
|
this.updateDisplay();
|
|
@@ -197,34 +81,17 @@ export class ToolExecutionComponent extends Container {
|
|
|
197
81
|
this.updateDisplay();
|
|
198
82
|
}
|
|
199
83
|
render(width) {
|
|
200
|
-
if (this.hideComponent) {
|
|
201
|
-
return [];
|
|
202
|
-
}
|
|
203
84
|
const signature = this.createRenderSignature();
|
|
204
85
|
if (this.cachedLines && this.cachedWidth === width && this.cachedSignature === signature) {
|
|
205
86
|
return [...this.cachedLines];
|
|
206
87
|
}
|
|
207
88
|
let lines;
|
|
208
|
-
if (this.hasRendererDefinition
|
|
209
|
-
const contentLines = this.
|
|
210
|
-
|
|
89
|
+
if (this.renderer.hasRendererDefinition && this.renderer.renderShell === "self") {
|
|
90
|
+
const contentLines = this.renderer.render(width);
|
|
91
|
+
const imageLines = this.images.render(width);
|
|
92
|
+
if (contentLines.length === 0 && imageLines.length === 0)
|
|
211
93
|
return [];
|
|
212
|
-
|
|
213
|
-
lines = [];
|
|
214
|
-
if (contentLines.length > 0) {
|
|
215
|
-
lines.push("");
|
|
216
|
-
lines.push(...contentLines);
|
|
217
|
-
}
|
|
218
|
-
for (let i = 0; i < this.imageComponents.length; i++) {
|
|
219
|
-
const spacer = this.imageSpacers[i];
|
|
220
|
-
if (spacer) {
|
|
221
|
-
lines.push(...spacer.render(width));
|
|
222
|
-
}
|
|
223
|
-
const imageComponent = this.imageComponents[i];
|
|
224
|
-
if (imageComponent) {
|
|
225
|
-
lines.push(...imageComponent.render(width));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
94
|
+
lines = contentLines.length > 0 ? ["", ...contentLines, ...imageLines] : imageLines;
|
|
228
95
|
}
|
|
229
96
|
else {
|
|
230
97
|
lines = super.render(width);
|
|
@@ -236,158 +103,49 @@ export class ToolExecutionComponent extends Container {
|
|
|
236
103
|
}
|
|
237
104
|
updateDisplay() {
|
|
238
105
|
const displaySignature = this.createRenderSignature();
|
|
239
|
-
if (this.lastDisplaySignature === displaySignature)
|
|
106
|
+
if (this.lastDisplaySignature === displaySignature)
|
|
240
107
|
return;
|
|
241
|
-
}
|
|
242
108
|
this.lastDisplaySignature = displaySignature;
|
|
243
109
|
this.invalidateRenderCache();
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (this.hasRendererDefinition()) {
|
|
252
|
-
const renderContainer = this.getRenderShell() === "self" ? this.selfRenderContainer : this.contentBox;
|
|
253
|
-
if (renderContainer instanceof Box) {
|
|
254
|
-
renderContainer.setBgFn(bgFn);
|
|
255
|
-
}
|
|
256
|
-
renderContainer.detachAll();
|
|
257
|
-
const callRenderer = this.getCallRenderer();
|
|
258
|
-
if (!callRenderer) {
|
|
259
|
-
renderContainer.addChild(this.createCallFallback());
|
|
260
|
-
hasContent = true;
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
try {
|
|
264
|
-
const component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));
|
|
265
|
-
this.callRendererComponent = component;
|
|
266
|
-
renderContainer.addChild(component);
|
|
267
|
-
hasContent = true;
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
270
|
-
this.callRendererComponent = undefined;
|
|
271
|
-
renderContainer.addChild(this.createCallFallback());
|
|
272
|
-
hasContent = true;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (this.result) {
|
|
276
|
-
const resultRenderer = this.getResultRenderer();
|
|
277
|
-
if (!resultRenderer) {
|
|
278
|
-
const component = this.createResultFallback();
|
|
279
|
-
if (component) {
|
|
280
|
-
renderContainer.addChild(component);
|
|
281
|
-
hasContent = true;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
try {
|
|
286
|
-
const agentToolResult = {
|
|
287
|
-
content: this.result.content,
|
|
288
|
-
details: this.result.details,
|
|
289
|
-
};
|
|
290
|
-
const component = resultRenderer(agentToolResult, { expanded: this.expanded, isPartial: this.isPartial }, theme, this.getRenderContext(this.resultRendererComponent));
|
|
291
|
-
this.resultRendererComponent = component;
|
|
292
|
-
renderContainer.addChild(component);
|
|
293
|
-
hasContent = true;
|
|
294
|
-
}
|
|
295
|
-
catch {
|
|
296
|
-
this.resultRendererComponent = undefined;
|
|
297
|
-
const component = this.createResultFallback();
|
|
298
|
-
if (component) {
|
|
299
|
-
renderContainer.addChild(component);
|
|
300
|
-
hasContent = true;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
this.contentText.setCustomBgFn(bgFn);
|
|
308
|
-
this.contentText.setText(this.formatToolExecution());
|
|
309
|
-
hasContent = true;
|
|
310
|
-
}
|
|
311
|
-
for (const img of this.imageComponents) {
|
|
312
|
-
this.removeChild(img);
|
|
313
|
-
}
|
|
314
|
-
this.imageComponents = [];
|
|
315
|
-
for (const spacer of this.imageSpacers) {
|
|
316
|
-
this.removeChild(spacer);
|
|
317
|
-
}
|
|
318
|
-
this.imageSpacers = [];
|
|
319
|
-
if (this.result) {
|
|
320
|
-
const imageBlocks = this.result.content.filter((c) => c.type === "image");
|
|
321
|
-
const caps = getCapabilities();
|
|
322
|
-
for (let i = 0; i < imageBlocks.length; i++) {
|
|
323
|
-
const img = imageBlocks[i];
|
|
324
|
-
if (caps.images && this.showImages && img.data && img.mimeType) {
|
|
325
|
-
const converted = this.convertedImages.get(i);
|
|
326
|
-
const imageData = converted?.data ?? img.data;
|
|
327
|
-
const imageMimeType = converted?.mimeType ?? img.mimeType;
|
|
328
|
-
if (caps.images === "kitty" && imageMimeType !== "image/png")
|
|
329
|
-
continue;
|
|
330
|
-
const spacer = new Spacer(1);
|
|
331
|
-
this.addChild(spacer);
|
|
332
|
-
this.imageSpacers.push(spacer);
|
|
333
|
-
const imageComponent = new Image(imageData, imageMimeType, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: this.imageWidthCells });
|
|
334
|
-
this.imageComponents.push(imageComponent);
|
|
335
|
-
this.addChild(imageComponent);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
if (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {
|
|
340
|
-
this.hideComponent = true;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
getTextOutput() {
|
|
344
|
-
return getRenderedTextOutput(this.result, this.showImages);
|
|
345
|
-
}
|
|
346
|
-
formatToolExecution() {
|
|
347
|
-
let text = theme.fg("toolTitle", theme.bold(sanitizeFallbackString(this.toolName)));
|
|
348
|
-
const content = JSON.stringify(this.args, sanitizeFallbackJsonValue, 2);
|
|
349
|
-
if (content) {
|
|
350
|
-
const boundedContent = content.length > FALLBACK_JSON_MAX_LENGTH
|
|
351
|
-
? `${content.slice(0, FALLBACK_JSON_MAX_LENGTH - 3)}...`
|
|
352
|
-
: content;
|
|
353
|
-
text += `\n\n${boundedContent}`;
|
|
354
|
-
}
|
|
355
|
-
const output = this.getTextOutput();
|
|
356
|
-
if (output) {
|
|
357
|
-
text += `\n${sanitizeFallbackString(output, FALLBACK_JSON_MAX_LENGTH)}`;
|
|
358
|
-
}
|
|
359
|
-
return text;
|
|
110
|
+
const state = this.createRenderState();
|
|
111
|
+
this.renderer.update(state);
|
|
112
|
+
this.images.updateOptions({
|
|
113
|
+
showImages: state.showImages,
|
|
114
|
+
maxWidthCells: this.imageWidthCells,
|
|
115
|
+
showRendererFallback: this.renderer.hasResultRenderer,
|
|
116
|
+
});
|
|
360
117
|
}
|
|
361
|
-
|
|
362
|
-
return
|
|
118
|
+
createRenderState() {
|
|
119
|
+
return {
|
|
363
120
|
args: this.args,
|
|
364
|
-
argsComplete: this.argsComplete,
|
|
365
121
|
executionStarted: this.executionStarted,
|
|
366
|
-
|
|
367
|
-
hideComponent: this.hideComponent,
|
|
368
|
-
imageWidthCells: this.imageWidthCells,
|
|
122
|
+
argsComplete: this.argsComplete,
|
|
369
123
|
isPartial: this.isPartial,
|
|
370
|
-
|
|
124
|
+
expanded: this.expanded,
|
|
371
125
|
showImages: this.showImages,
|
|
372
126
|
spinnerFrame: this.spinnerFrame,
|
|
373
|
-
|
|
374
|
-
|
|
127
|
+
result: this.result,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
createRenderSignature() {
|
|
131
|
+
return createBoundedRenderSignature({
|
|
132
|
+
...this.createRenderState(),
|
|
133
|
+
imageWidthCells: this.imageWidthCells,
|
|
134
|
+
toolCallId: this.identity.toolCallId,
|
|
135
|
+
toolName: this.identity.toolName,
|
|
375
136
|
});
|
|
376
137
|
}
|
|
377
138
|
updateSpinnerAnimation() {
|
|
378
|
-
const isStreamingArgs = !this.argsComplete &&
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (isStreamingArgs || isPartialTask) {
|
|
139
|
+
const isStreamingArgs = !this.argsComplete && ["edit", "write", "apply_patch"].includes(this.identity.toolName);
|
|
140
|
+
const isPartialTask = this.isPartial && this.identity.toolName === "task" && this.result !== undefined;
|
|
141
|
+
if (isStreamingArgs || isPartialTask)
|
|
382
142
|
this.startSpinnerAnimation();
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.stopSpinnerAnimation();
|
|
143
|
+
else
|
|
144
|
+
this.stopSpinnerAnimation();
|
|
386
145
|
}
|
|
387
146
|
startSpinnerAnimation() {
|
|
388
|
-
if (this.spinnerInterval)
|
|
147
|
+
if (this.spinnerInterval)
|
|
389
148
|
return;
|
|
390
|
-
}
|
|
391
149
|
this.spinnerInterval = setInterval(() => {
|
|
392
150
|
this.spinnerFrame = ((this.spinnerFrame ?? -1) + 1) % 10;
|
|
393
151
|
this.invalidateRenderCache();
|
|
@@ -397,9 +155,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
397
155
|
this.spinnerInterval.unref?.();
|
|
398
156
|
}
|
|
399
157
|
stopSpinnerAnimation() {
|
|
400
|
-
if (!this.spinnerInterval)
|
|
158
|
+
if (!this.spinnerInterval)
|
|
401
159
|
return;
|
|
402
|
-
}
|
|
403
160
|
clearInterval(this.spinnerInterval);
|
|
404
161
|
this.spinnerInterval = undefined;
|
|
405
162
|
this.spinnerFrame = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAkB,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,wBAAwB,CAAC;AAExH,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAA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C;IAC7B,CAAC;IAEO,qBAAqB;QAC5B,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,OAAO;QACR,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACvC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;YACzD,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,EAAE,gCAAgC,CAAC,CAAC;QACrC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC;IAChC,CAAC;IAEO,oBAAoB;QAC3B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC3B,OAAO;QACR,CAAC;QACD,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC9B,CAAC;IAEO,qBAAqB;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Box, type Component, Container, getCapabilities, Image, Spacer, Text, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.ts\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.ts\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { createBoundedRenderSignature } from \"./render-signature.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\ntype ToolExecutionResult = Omit<AgentToolResult<unknown>, \"details\"> & {\n\tdetails?: unknown;\n\tisError: boolean;\n};\n\nconst FALLBACK_STRING_MAX_LENGTH = 160;\nconst FALLBACK_JSON_MAX_LENGTH = 2000;\nconst PENDING_RENDER_FRAME_INTERVAL_MS = 80;\n\nfunction sanitizeFallbackString(value: string, maxLength = FALLBACK_STRING_MAX_LENGTH): string {\n\tconst sanitized = stripAnsi(value)\n\t\t.replace(/[\\u0000-\\u001f\\u007f-\\u009f]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\tif (sanitized.length <= maxLength) {\n\t\treturn sanitized;\n\t}\n\treturn `${sanitized.slice(0, Math.max(0, maxLength - 3))}...`;\n}\n\nfunction sanitizeFallbackJsonValue(_key: string, value: unknown): unknown {\n\tif (typeof value === \"string\") {\n\t\treturn sanitizeFallbackString(value);\n\t}\n\treturn value;\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate cachedLines?: string[];\n\tprivate cachedSignature?: string;\n\tprivate cachedWidth?: number;\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate spinnerFrame?: number;\n\tprivate spinnerInterval?: NodeJS.Timeout;\n\tprivate result?: ToolExecutionResult;\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\tthis.contentBox = new Box(1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.contentText = new Text(\"\", 1, 1, (text: string) => theme.bg(\"toolPendingBg\", text));\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t};\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.toolName)), 0, 0);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(result: ToolExecutionResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tif (!isPartial) {\n\t\t\tthis.argsComplete = true;\n\t\t}\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tstopAnimation(): void {\n\t\tthis.stopSpinnerAnimation();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tthis.invalidateRenderCache();\n\t\tsuper.invalidate();\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\tconst signature = this.createRenderSignature();\n\t\tif (this.cachedLines && this.cachedWidth === width && this.cachedSignature === signature) {\n\t\t\treturn [...this.cachedLines];\n\t\t}\n\n\t\tlet lines: string[];\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\tconst contentLines = this.selfRenderContainer.render(width);\n\t\t\tif (contentLines.length === 0 && this.imageComponents.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tlines = [];\n\t\t\tif (contentLines.length > 0) {\n\t\t\t\tlines.push(\"\");\n\t\t\t\tlines.push(...contentLines);\n\t\t\t}\n\t\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\t\tif (spacer) {\n\t\t\t\t\tlines.push(...spacer.render(width));\n\t\t\t\t}\n\t\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\t\tif (imageComponent) {\n\t\t\t\t\tlines.push(...imageComponent.render(width));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlines = super.render(width);\n\t\t}\n\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedSignature = signature;\n\t\tthis.cachedLines = [...lines];\n\t\treturn lines;\n\t}\n\n\tprivate lastDisplaySignature?: string;\n\n\tprivate updateDisplay(): void {\n\t\tconst displaySignature = this.createRenderSignature();\n\t\tif (this.lastDisplaySignature === displaySignature) {\n\t\t\treturn;\n\t\t}\n\t\tthis.lastDisplaySignature = displaySignature;\n\t\tthis.invalidateRenderCache();\n\n\t\tconst bgFn = this.isPartial\n\t\t\t? (text: string) => theme.bg(\"toolPendingBg\", text)\n\t\t\t: this.result?.isError\n\t\t\t\t? (text: string) => theme.bg(\"toolErrorBg\", text)\n\t\t\t\t: (text: string) => theme.bg(\"toolSuccessBg\", text);\n\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(bgFn);\n\t\t\t}\n\t\t\trenderContainer.detachAll();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createCallFallback());\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst agentToolResult = {\n\t\t\t\t\t\t\tcontent: this.result.content,\n\t\t\t\t\t\t\tdetails: this.result.details,\n\t\t\t\t\t\t} satisfies AgentToolResult<unknown>;\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\tagentToolResult,\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.contentText.setCustomBgFn(bgFn);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tlet text = theme.fg(\"toolTitle\", theme.bold(sanitizeFallbackString(this.toolName)));\n\t\tconst content = JSON.stringify(this.args, sanitizeFallbackJsonValue, 2);\n\t\tif (content) {\n\t\t\tconst boundedContent =\n\t\t\t\tcontent.length > FALLBACK_JSON_MAX_LENGTH\n\t\t\t\t\t? `${content.slice(0, FALLBACK_JSON_MAX_LENGTH - 3)}...`\n\t\t\t\t\t: content;\n\t\t\ttext += `\\n\\n${boundedContent}`;\n\t\t}\n\t\tconst output = this.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${sanitizeFallbackString(output, FALLBACK_JSON_MAX_LENGTH)}`;\n\t\t}\n\t\treturn text;\n\t}\n\n\tprivate createRenderSignature(): string {\n\t\treturn createBoundedRenderSignature({\n\t\t\targs: this.args,\n\t\t\targsComplete: this.argsComplete,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\texpanded: this.expanded,\n\t\t\thideComponent: this.hideComponent,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\tisPartial: this.isPartial,\n\t\t\tresult: this.result,\n\t\t\tshowImages: this.showImages,\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\ttoolName: this.toolName,\n\t\t});\n\t}\n\n\tprivate updateSpinnerAnimation(): void {\n\t\tconst isStreamingArgs =\n\t\t\t!this.argsComplete &&\n\t\t\t(this.toolName === \"edit\" || this.toolName === \"write\" || this.toolName === \"apply_patch\");\n\t\tconst isPartialTask = this.isPartial && this.toolName === \"task\" && this.result !== undefined;\n\t\tif (isStreamingArgs || isPartialTask) {\n\t\t\tthis.startSpinnerAnimation();\n\t\t\treturn;\n\t\t}\n\t\tthis.stopSpinnerAnimation();\n\t}\n\n\tprivate startSpinnerAnimation(): void {\n\t\tif (this.spinnerInterval) {\n\t\t\treturn;\n\t\t}\n\t\tthis.spinnerInterval = setInterval(() => {\n\t\t\tthis.spinnerFrame = ((this.spinnerFrame ?? -1) + 1) % 10;\n\t\t\tthis.invalidateRenderCache();\n\t\t\tthis.updateDisplay();\n\t\t\tthis.ui.requestRender();\n\t\t}, PENDING_RENDER_FRAME_INTERVAL_MS);\n\t\tthis.spinnerInterval.unref?.();\n\t}\n\n\tprivate stopSpinnerAnimation(): void {\n\t\tif (!this.spinnerInterval) {\n\t\t\treturn;\n\t\t}\n\t\tclearInterval(this.spinnerInterval);\n\t\tthis.spinnerInterval = undefined;\n\t\tthis.spinnerFrame = undefined;\n\t\tthis.invalidateRenderCache();\n\t}\n\n\tprivate invalidateRenderCache(): void {\n\t\tthis.cachedLines = undefined;\n\t\tthis.cachedSignature = undefined;\n\t\tthis.cachedWidth = undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAY,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAQrE,MAAM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AEO,oBAAoB;QAC3B,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAO;QAClC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC9B,CAAC;IAEO,qBAAqB;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import { Container, Spacer, type TUI } from \"@earendil-works/pi-tui\";\nimport type { ToolDef } from \"../../../core/tools/index.ts\";\nimport { createBoundedRenderSignature } from \"./render-signature.ts\";\nimport { ToolExecutionImages } from \"./tool-execution-images.ts\";\nimport { ToolExecutionRenderer } from \"./tool-execution-renderer.ts\";\nimport type { ToolExecutionIdentity, ToolExecutionRenderState, ToolExecutionResult } from \"./tool-execution-types.ts\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n}\n\nconst PENDING_RENDER_FRAME_INTERVAL_MS = 80;\n\nexport class ToolExecutionComponent extends Container {\n\tprivate readonly identity: ToolExecutionIdentity;\n\tprivate readonly ui: TUI;\n\tprivate readonly renderer: ToolExecutionRenderer;\n\tprivate readonly images: ToolExecutionImages;\n\tprivate args: unknown;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate spinnerFrame?: number;\n\tprivate spinnerInterval?: NodeJS.Timeout;\n\tprivate result?: ToolExecutionResult;\n\tprivate cachedLines?: string[];\n\tprivate cachedSignature?: string;\n\tprivate cachedWidth?: number;\n\tprivate lastDisplaySignature?: string;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDef | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.identity = { toolName, toolCallId, cwd, toolDefinition };\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.ui = ui;\n\t\tconst initialState = this.createRenderState();\n\t\tthis.renderer = new ToolExecutionRenderer(this.identity, initialState, () => {\n\t\t\tthis.invalidate();\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t\tthis.images = new ToolExecutionImages(() => {\n\t\t\tthis.invalidateRenderCache();\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(this.renderer);\n\t\tthis.addChild(this.images);\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tupdateArgs(args: unknown): void {\n\t\tthis.args = args;\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(result: ToolExecutionResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tif (!isPartial) this.argsComplete = true;\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateSpinnerAnimation();\n\t\tthis.updateDisplay();\n\t\tthis.images.updateResult(result);\n\t\tthis.invalidateRenderCache();\n\t}\n\n\tstopAnimation(): void {\n\t\tthis.stopSpinnerAnimation();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tthis.invalidateRenderCache();\n\t\tsuper.invalidate();\n\t\tthis.lastDisplaySignature = undefined;\n\t\tthis.updateDisplay();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst signature = this.createRenderSignature();\n\t\tif (this.cachedLines && this.cachedWidth === width && this.cachedSignature === signature) {\n\t\t\treturn [...this.cachedLines];\n\t\t}\n\n\t\tlet lines: string[];\n\t\tif (this.renderer.hasRendererDefinition && this.renderer.renderShell === \"self\") {\n\t\t\tconst contentLines = this.renderer.render(width);\n\t\t\tconst imageLines = this.images.render(width);\n\t\t\tif (contentLines.length === 0 && imageLines.length === 0) return [];\n\t\t\tlines = contentLines.length > 0 ? [\"\", ...contentLines, ...imageLines] : imageLines;\n\t\t} else {\n\t\t\tlines = super.render(width);\n\t\t}\n\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedSignature = signature;\n\t\tthis.cachedLines = [...lines];\n\t\treturn lines;\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tconst displaySignature = this.createRenderSignature();\n\t\tif (this.lastDisplaySignature === displaySignature) return;\n\t\tthis.lastDisplaySignature = displaySignature;\n\t\tthis.invalidateRenderCache();\n\t\tconst state = this.createRenderState();\n\t\tthis.renderer.update(state);\n\t\tthis.images.updateOptions({\n\t\t\tshowImages: state.showImages,\n\t\t\tmaxWidthCells: this.imageWidthCells,\n\t\t\tshowRendererFallback: this.renderer.hasResultRenderer,\n\t\t});\n\t}\n\n\tprivate createRenderState(): ToolExecutionRenderState {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\tresult: this.result,\n\t\t};\n\t}\n\n\tprivate createRenderSignature(): string {\n\t\treturn createBoundedRenderSignature({\n\t\t\t...this.createRenderState(),\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\ttoolCallId: this.identity.toolCallId,\n\t\t\ttoolName: this.identity.toolName,\n\t\t});\n\t}\n\n\tprivate updateSpinnerAnimation(): void {\n\t\tconst isStreamingArgs = !this.argsComplete && [\"edit\", \"write\", \"apply_patch\"].includes(this.identity.toolName);\n\t\tconst isPartialTask = this.isPartial && this.identity.toolName === \"task\" && this.result !== undefined;\n\t\tif (isStreamingArgs || isPartialTask) this.startSpinnerAnimation();\n\t\telse this.stopSpinnerAnimation();\n\t}\n\n\tprivate startSpinnerAnimation(): void {\n\t\tif (this.spinnerInterval) return;\n\t\tthis.spinnerInterval = setInterval(() => {\n\t\t\tthis.spinnerFrame = ((this.spinnerFrame ?? -1) + 1) % 10;\n\t\t\tthis.invalidateRenderCache();\n\t\t\tthis.updateDisplay();\n\t\t\tthis.ui.requestRender();\n\t\t}, PENDING_RENDER_FRAME_INTERVAL_MS);\n\t\tthis.spinnerInterval.unref?.();\n\t}\n\n\tprivate stopSpinnerAnimation(): void {\n\t\tif (!this.spinnerInterval) return;\n\t\tclearInterval(this.spinnerInterval);\n\t\tthis.spinnerInterval = undefined;\n\t\tthis.spinnerFrame = undefined;\n\t\tthis.invalidateRenderCache();\n\t}\n\n\tprivate invalidateRenderCache(): void {\n\t\tthis.cachedLines = undefined;\n\t\tthis.cachedSignature = undefined;\n\t\tthis.cachedWidth = undefined;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
+
export declare function isComponent(value: unknown): value is Component;
|
|
3
|
+
export declare class ToolRendererBoundary implements Component {
|
|
4
|
+
private component;
|
|
5
|
+
private componentDisposed;
|
|
6
|
+
private fallback?;
|
|
7
|
+
private failed;
|
|
8
|
+
private onFailure;
|
|
9
|
+
constructor(component: Component, fallback: Component | undefined, onFailure: () => void);
|
|
10
|
+
render(width: number): string[];
|
|
11
|
+
invalidate(): void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
private fail;
|
|
14
|
+
private disposeComponent;
|
|
15
|
+
private renderFallback;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=tool-renderer-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-renderer-boundary.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-renderer-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAO9D;AAED,qBAAa,oBAAqB,YAAW,SAAS;IACrD,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAa;IAE9B,YAAY,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,IAAI,EAIvF;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB9B;IAED,UAAU,IAAI,IAAI,CASjB;IAED,OAAO,IAAI,IAAI,CAGd;IAED,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,cAAc;CAGtB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export function isComponent(value) {
|
|
2
|
+
return ((typeof value === "object" || typeof value === "function") &&
|
|
3
|
+
value !== null &&
|
|
4
|
+
typeof Reflect.get(value, "render") === "function" &&
|
|
5
|
+
typeof Reflect.get(value, "invalidate") === "function");
|
|
6
|
+
}
|
|
7
|
+
export class ToolRendererBoundary {
|
|
8
|
+
constructor(component, fallback, onFailure) {
|
|
9
|
+
this.componentDisposed = false;
|
|
10
|
+
this.failed = false;
|
|
11
|
+
this.component = component;
|
|
12
|
+
this.fallback = fallback;
|
|
13
|
+
this.onFailure = onFailure;
|
|
14
|
+
}
|
|
15
|
+
render(width) {
|
|
16
|
+
if (!this.failed) {
|
|
17
|
+
try {
|
|
18
|
+
const lines = this.component.render(width);
|
|
19
|
+
if (Array.isArray(lines)) {
|
|
20
|
+
const safeLines = [];
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
if (typeof line !== "string") {
|
|
23
|
+
throw new TypeError("Tool renderer returned a non-string line");
|
|
24
|
+
}
|
|
25
|
+
safeLines.push(line);
|
|
26
|
+
}
|
|
27
|
+
return safeLines;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
this.fail();
|
|
32
|
+
return this.renderFallback(width);
|
|
33
|
+
}
|
|
34
|
+
this.fail();
|
|
35
|
+
}
|
|
36
|
+
return this.renderFallback(width);
|
|
37
|
+
}
|
|
38
|
+
invalidate() {
|
|
39
|
+
if (!this.failed) {
|
|
40
|
+
try {
|
|
41
|
+
this.component.invalidate();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
this.fail();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this.fallback?.invalidate();
|
|
48
|
+
}
|
|
49
|
+
dispose() {
|
|
50
|
+
this.disposeComponent();
|
|
51
|
+
this.fallback?.dispose?.();
|
|
52
|
+
}
|
|
53
|
+
fail() {
|
|
54
|
+
if (this.failed)
|
|
55
|
+
return;
|
|
56
|
+
this.failed = true;
|
|
57
|
+
this.onFailure();
|
|
58
|
+
this.disposeComponent();
|
|
59
|
+
}
|
|
60
|
+
disposeComponent() {
|
|
61
|
+
if (this.componentDisposed)
|
|
62
|
+
return;
|
|
63
|
+
this.componentDisposed = true;
|
|
64
|
+
try {
|
|
65
|
+
this.component.dispose?.();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
renderFallback(width) {
|
|
72
|
+
return this.fallback?.render(width) ?? [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=tool-renderer-boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-renderer-boundary.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-renderer-boundary.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,KAAc;IACzC,OAAO,CACN,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;QAC1D,KAAK,KAAK,IAAI;QACd,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,UAAU;QAClD,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,UAAU,CACtD,CAAC;AACH,CAAC;AAED,MAAM,OAAO,oBAAoB;IAOhC,YAAY,SAAoB,EAAE,QAA+B,EAAE,SAAqB;QALhF,sBAAiB,GAAG,KAAK,CAAC;QAE1B,WAAM,GAAG,KAAK,CAAC;QAItB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC;gBACJ,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3C,IAAI,KAAK,CAAC,OAAO,CAAC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,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC;YACJ,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACR,OAAO;QACR,CAAC;IACF,CAAC;IAEO,cAAc,CAAC,KAAa;QACnC,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;CACD","sourcesContent":["import type { Component } from \"@earendil-works/pi-tui\";\n\nexport function isComponent(value: unknown): value is Component {\n\treturn (\n\t\t(typeof value === \"object\" || typeof value === \"function\") &&\n\t\tvalue !== null &&\n\t\ttypeof Reflect.get(value, \"render\") === \"function\" &&\n\t\ttypeof Reflect.get(value, \"invalidate\") === \"function\"\n\t);\n}\n\nexport class ToolRendererBoundary implements Component {\n\tprivate component: Component;\n\tprivate componentDisposed = false;\n\tprivate fallback?: Component;\n\tprivate failed = false;\n\tprivate onFailure: () => void;\n\n\tconstructor(component: Component, fallback: Component | undefined, onFailure: () => void) {\n\t\tthis.component = component;\n\t\tthis.fallback = fallback;\n\t\tthis.onFailure = onFailure;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.failed) {\n\t\t\ttry {\n\t\t\t\tconst lines = this.component.render(width);\n\t\t\t\tif (Array.isArray(lines)) {\n\t\t\t\t\tconst safeLines: string[] = [];\n\t\t\t\t\tfor (const line of lines) {\n\t\t\t\t\t\tif (typeof line !== \"string\") {\n\t\t\t\t\t\t\tthrow new TypeError(\"Tool renderer returned a non-string line\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsafeLines.push(line);\n\t\t\t\t\t}\n\t\t\t\t\treturn safeLines;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tthis.fail();\n\t\t\t\treturn this.renderFallback(width);\n\t\t\t}\n\t\t\tthis.fail();\n\t\t}\n\t\treturn this.renderFallback(width);\n\t}\n\n\tinvalidate(): void {\n\t\tif (!this.failed) {\n\t\t\ttry {\n\t\t\t\tthis.component.invalidate();\n\t\t\t} catch {\n\t\t\t\tthis.fail();\n\t\t\t}\n\t\t}\n\t\tthis.fallback?.invalidate();\n\t}\n\n\tdispose(): void {\n\t\tthis.disposeComponent();\n\t\tthis.fallback?.dispose?.();\n\t}\n\n\tprivate fail(): void {\n\t\tif (this.failed) return;\n\t\tthis.failed = true;\n\t\tthis.onFailure();\n\t\tthis.disposeComponent();\n\t}\n\n\tprivate disposeComponent(): void {\n\t\tif (this.componentDisposed) return;\n\t\tthis.componentDisposed = true;\n\t\ttry {\n\t\t\tthis.component.dispose?.();\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate renderFallback(width: number): string[] {\n\t\treturn this.fallback?.render(width) ?? [];\n\t}\n}\n"]}
|