@caupulican/pi-adaptative 0.80.103 → 0.81.0
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 +120 -0
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +6 -6
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +152 -512
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +635 -4590
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/status.d.ts +1 -0
- package/dist/core/autonomy/status.d.ts.map +1 -1
- package/dist/core/autonomy/status.js +1 -0
- package/dist/core/autonomy/status.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +80 -0
- package/dist/core/autonomy-telemetry.d.ts.map +1 -0
- package/dist/core/autonomy-telemetry.js +266 -0
- package/dist/core/autonomy-telemetry.js.map +1 -0
- package/dist/core/background-lane-controller.d.ts +186 -0
- package/dist/core/background-lane-controller.d.ts.map +1 -0
- package/dist/core/background-lane-controller.js +691 -0
- package/dist/core/background-lane-controller.js.map +1 -0
- package/dist/core/bash-execution-controller.d.ts +51 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -0
- package/dist/core/bash-execution-controller.js +96 -0
- package/dist/core/bash-execution-controller.js.map +1 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +9 -2
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction-support.d.ts +56 -0
- package/dist/core/compaction-support.d.ts.map +1 -0
- package/dist/core/compaction-support.js +99 -0
- package/dist/core/compaction-support.js.map +1 -0
- package/dist/core/context/artifact-retrieval.d.ts +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/context-composition.d.ts.map +1 -1
- package/dist/core/context/context-composition.js +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +1 -1
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +223 -0
- package/dist/core/context-pipeline.d.ts.map +1 -0
- package/dist/core/context-pipeline.js +594 -0
- package/dist/core/context-pipeline.js.map +1 -0
- package/dist/core/cost/daily-usage.d.ts +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +1 -1
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/delegation/session-worker-result.d.ts +1 -1
- package/dist/core/delegation/session-worker-result.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-result.js.map +1 -1
- package/dist/core/exec.d.ts +2 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +15 -9
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -2
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +2 -2
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +24 -0
- package/dist/core/goal-loop-controller.d.ts.map +1 -0
- package/dist/core/goal-loop-controller.js +83 -0
- package/dist/core/goal-loop-controller.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +1 -1
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +1 -1
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +1 -1
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +99 -0
- package/dist/core/local-runtime-controller.d.ts.map +1 -0
- package/dist/core/local-runtime-controller.js +214 -0
- package/dist/core/local-runtime-controller.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
- package/dist/core/memory/providers/transcript-recall.js +1 -1
- package/dist/core/memory/providers/transcript-recall.js.map +1 -1
- package/dist/core/memory-controller.d.ts +139 -0
- package/dist/core/memory-controller.d.ts.map +1 -0
- package/dist/core/memory-controller.js +323 -0
- package/dist/core/memory-controller.js.map +1 -0
- package/dist/core/model-router/status.d.ts +1 -1
- package/dist/core/model-router/status.d.ts.map +1 -1
- package/dist/core/model-router/status.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +140 -0
- package/dist/core/model-router-controller.d.ts.map +1 -0
- package/dist/core/model-router-controller.js +623 -0
- package/dist/core/model-router-controller.js.map +1 -0
- package/dist/core/model-selection-controller.d.ts +95 -0
- package/dist/core/model-selection-controller.d.ts.map +1 -0
- package/dist/core/model-selection-controller.js +252 -0
- package/dist/core/model-selection-controller.js.map +1 -0
- package/dist/core/models/model-ref.d.ts +13 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +22 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +77 -0
- package/dist/core/profile-filter-controller.d.ts.map +1 -0
- package/dist/core/profile-filter-controller.js +159 -0
- package/dist/core/profile-filter-controller.js.map +1 -0
- package/dist/core/reflection-controller.d.ts +111 -0
- package/dist/core/reflection-controller.d.ts.map +1 -0
- package/dist/core/reflection-controller.js +412 -0
- package/dist/core/reflection-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +12 -0
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +21 -0
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/session-evidence-bundle.d.ts +1 -1
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +222 -0
- package/dist/core/runtime-builder.d.ts.map +1 -0
- package/dist/core/runtime-builder.js +640 -0
- package/dist/core/runtime-builder.js.map +1 -0
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-analytics.d.ts +96 -0
- package/dist/core/session-analytics.d.ts.map +1 -0
- package/dist/core/session-analytics.js +331 -0
- package/dist/core/session-analytics.js.map +1 -0
- package/dist/core/session-manager-factory.d.ts +18 -0
- package/dist/core/session-manager-factory.d.ts.map +1 -0
- package/dist/core/session-manager-factory.js +32 -0
- package/dist/core/session-manager-factory.js.map +1 -0
- package/dist/core/session-tree-navigator.d.ts +68 -0
- package/dist/core/session-tree-navigator.d.ts.map +1 -0
- package/dist/core/session-tree-navigator.js +217 -0
- package/dist/core/session-tree-navigator.js.map +1 -0
- package/dist/core/system-prompt-builder.d.ts +63 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -0
- package/dist/core/system-prompt-builder.js +181 -0
- package/dist/core/system-prompt-builder.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts +36 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -0
- package/dist/core/tool-gate-controller.js +94 -0
- package/dist/core/tool-gate-controller.js.map +1 -0
- package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
- package/dist/core/tools/artifact-retrieve.js +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/bash.d.ts +4 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +49 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +61 -1
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +1 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -12
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +59 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -0
- package/dist/modes/interactive/auth-dialogs-controller.js +398 -0
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -0
- package/dist/modes/interactive/auto-learn-controller.d.ts +168 -0
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -0
- package/dist/modes/interactive/auto-learn-controller.js +1239 -0
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -0
- package/dist/modes/interactive/autocomplete-provider.d.ts +26 -0
- package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -0
- package/dist/modes/interactive/autocomplete-provider.js +103 -0
- package/dist/modes/interactive/autocomplete-provider.js.map +1 -0
- package/dist/modes/interactive/autonomy-commands.d.ts +38 -0
- package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -0
- package/dist/modes/interactive/autonomy-commands.js +142 -0
- package/dist/modes/interactive/autonomy-commands.js.map +1 -0
- package/dist/modes/interactive/clipboard-input.d.ts +37 -0
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -0
- package/dist/modes/interactive/clipboard-input.js +59 -0
- package/dist/modes/interactive/clipboard-input.js.map +1 -0
- package/dist/modes/interactive/compaction-queue.d.ts +30 -0
- package/dist/modes/interactive/compaction-queue.d.ts.map +1 -0
- package/dist/modes/interactive/compaction-queue.js +91 -0
- package/dist/modes/interactive/compaction-queue.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -2
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts +27 -0
- package/dist/modes/interactive/config-backup.d.ts.map +1 -0
- package/dist/modes/interactive/config-backup.js +146 -0
- package/dist/modes/interactive/config-backup.js.map +1 -0
- package/dist/modes/interactive/editor-overlay-host.d.ts +48 -0
- package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -0
- package/dist/modes/interactive/editor-overlay-host.js +43 -0
- package/dist/modes/interactive/editor-overlay-host.js.map +1 -0
- package/dist/modes/interactive/extension-ui-host.d.ts +165 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -0
- package/dist/modes/interactive/extension-ui-host.js +610 -0
- package/dist/modes/interactive/extension-ui-host.js.map +1 -0
- package/dist/modes/interactive/external-editor.d.ts +18 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +107 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/history-reload-math.d.ts +24 -0
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -0
- package/dist/modes/interactive/history-reload-math.js +129 -0
- package/dist/modes/interactive/history-reload-math.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +22 -238
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +714 -5910
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts +46 -0
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -0
- package/dist/modes/interactive/key-handlers.js +80 -0
- package/dist/modes/interactive/key-handlers.js.map +1 -0
- package/dist/modes/interactive/local-model-commands.d.ts +68 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -0
- package/dist/modes/interactive/local-model-commands.js +288 -0
- package/dist/modes/interactive/local-model-commands.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts +77 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.js +917 -0
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -0
- package/dist/modes/interactive/report-commands.d.ts +46 -0
- package/dist/modes/interactive/report-commands.d.ts.map +1 -0
- package/dist/modes/interactive/report-commands.js +255 -0
- package/dist/modes/interactive/report-commands.js.map +1 -0
- package/dist/modes/interactive/resource-display.d.ts +73 -0
- package/dist/modes/interactive/resource-display.d.ts.map +1 -0
- package/dist/modes/interactive/resource-display.js +278 -0
- package/dist/modes/interactive/resource-display.js.map +1 -0
- package/dist/modes/interactive/resource-shell-commands.d.ts +64 -0
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -0
- package/dist/modes/interactive/resource-shell-commands.js +202 -0
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -0
- package/dist/modes/interactive/session-flow-commands.d.ts +139 -0
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -0
- package/dist/modes/interactive/session-flow-commands.js +458 -0
- package/dist/modes/interactive/session-flow-commands.js.map +1 -0
- package/dist/modes/interactive/session-io-commands.d.ts +73 -0
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -0
- package/dist/modes/interactive/session-io-commands.js +202 -0
- package/dist/modes/interactive/session-io-commands.js.map +1 -0
- package/dist/modes/interactive/settings-selector-flow.d.ts +42 -0
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -0
- package/dist/modes/interactive/settings-selector-flow.js +287 -0
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -0
- package/dist/modes/interactive/signal-lifecycle.d.ts +55 -0
- package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -0
- package/dist/modes/interactive/signal-lifecycle.js +177 -0
- package/dist/modes/interactive/signal-lifecycle.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts +38 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -0
- package/dist/modes/interactive/startup-checks.js +189 -0
- package/dist/modes/interactive/startup-checks.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -14
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +5 -30
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/process-memory.d.ts +8 -0
- package/dist/utils/process-memory.d.ts.map +1 -0
- package/dist/utils/process-memory.js +11 -0
- package/dist/utils/process-memory.js.map +1 -0
- package/dist/utils/shell.d.ts +0 -9
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +0 -37
- package/dist/utils/shell.js.map +1 -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/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/examples/sdk/11-sessions.ts +8 -8
- package/examples/sdk/13-session-runtime.ts +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
- package/dist/core/compaction/branch-summarization.d.ts +0 -88
- package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
- package/dist/core/compaction/branch-summarization.js +0 -243
- package/dist/core/compaction/branch-summarization.js.map +0 -1
- package/dist/core/compaction/compaction.d.ts +0 -143
- package/dist/core/compaction/compaction.d.ts.map +0 -1
- package/dist/core/compaction/compaction.js +0 -659
- package/dist/core/compaction/compaction.js.map +0 -1
- package/dist/core/compaction/index.d.ts +0 -7
- package/dist/core/compaction/index.d.ts.map +0 -1
- package/dist/core/compaction/index.js +0 -7
- package/dist/core/compaction/index.js.map +0 -1
- package/dist/core/compaction/utils.d.ts +0 -38
- package/dist/core/compaction/utils.d.ts.map +0 -1
- package/dist/core/compaction/utils.js +0 -153
- package/dist/core/compaction/utils.js.map +0 -1
- package/dist/core/message-retention.d.ts +0 -26
- package/dist/core/message-retention.d.ts.map +0 -1
- package/dist/core/message-retention.js +0 -95
- package/dist/core/message-retention.js.map +0 -1
- package/dist/core/messages.d.ts +0 -77
- package/dist/core/messages.d.ts.map +0 -1
- package/dist/core/messages.js +0 -123
- package/dist/core/messages.js.map +0 -1
- package/dist/core/session-manager.d.ts +0 -337
- package/dist/core/session-manager.d.ts.map +0 -1
- package/dist/core/session-manager.js +0 -1328
- package/dist/core/session-manager.js.map +0 -1
- package/dist/core/tools/truncate.d.ts +0 -70
- package/dist/core/tools/truncate.d.ts.map +0 -1
- package/dist/core/tools/truncate.js +0 -215
- package/dist/core/tools/truncate.js.map +0 -1
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension UI host.
|
|
3
|
+
*
|
|
4
|
+
* Extracted verbatim from interactive-mode.ts (god-file decomposition). Owns the interactive-mode
|
|
5
|
+
* surface of the extension UI API: extension-provided dialogs (selector / confirm / input / multi-line
|
|
6
|
+
* editor / custom component), widget mounting above and below the editor, extension status text, custom
|
|
7
|
+
* footer and header swaps, the custom editor-component swap, keyboard-shortcut wiring, terminal-input
|
|
8
|
+
* listeners, and the `ExtensionUIContext` handed to extensions. It owns exactly the state this cluster
|
|
9
|
+
* mutates (the live dialog components, the widget maps, the terminal-input unsubscribers, the custom
|
|
10
|
+
* footer/header, and the current custom-editor factory) and reaches everything else — the mutable
|
|
11
|
+
* `editor`, the render-core containers, the working-indicator, autocomplete wiring, theme/tools state —
|
|
12
|
+
* through a narrow deps/ui surface rather than the whole InteractiveMode instance. Extensions must see
|
|
13
|
+
* identical behavior, so the render-core operations (working indicator, hidden-thinking label,
|
|
14
|
+
* autocomplete rebuild) stay host-side and are invoked here as delegations.
|
|
15
|
+
*/
|
|
16
|
+
import { Container, matchesKey, Spacer, Text } from "@caupulican/pi-tui";
|
|
17
|
+
import { ExtensionEditorComponent } from "./components/extension-editor.js";
|
|
18
|
+
import { ExtensionInputComponent } from "./components/extension-input.js";
|
|
19
|
+
import { ExtensionSelectorComponent } from "./components/extension-selector.js";
|
|
20
|
+
import { getAvailableThemesWithPaths, getEditorTheme, getThemeByName, setTheme, setThemeInstance, Theme, theme, } from "./theme/theme.js";
|
|
21
|
+
function isExpandable(obj) {
|
|
22
|
+
return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
|
|
23
|
+
}
|
|
24
|
+
export class ExtensionUiHost {
|
|
25
|
+
deps;
|
|
26
|
+
// Extension UI state
|
|
27
|
+
extensionSelector = undefined;
|
|
28
|
+
extensionInput = undefined;
|
|
29
|
+
extensionEditor = undefined;
|
|
30
|
+
extensionTerminalInputUnsubscribers = new Set();
|
|
31
|
+
// Extension widgets (components rendered above/below the editor)
|
|
32
|
+
extensionWidgetsAbove = new Map();
|
|
33
|
+
extensionWidgetsBelow = new Map();
|
|
34
|
+
// Custom footer from extension (undefined = use built-in footer)
|
|
35
|
+
customFooter = undefined;
|
|
36
|
+
// Custom header from extension (undefined = use built-in header)
|
|
37
|
+
customHeader = undefined;
|
|
38
|
+
// Current custom editor-component factory (undefined = default editor)
|
|
39
|
+
editorComponentFactory;
|
|
40
|
+
constructor(deps) {
|
|
41
|
+
this.deps = deps;
|
|
42
|
+
}
|
|
43
|
+
get session() {
|
|
44
|
+
return this.deps.getSession();
|
|
45
|
+
}
|
|
46
|
+
get ui() {
|
|
47
|
+
return this.deps.ui;
|
|
48
|
+
}
|
|
49
|
+
/** The active custom header, if an extension has installed one. */
|
|
50
|
+
getCustomHeader() {
|
|
51
|
+
return this.customHeader;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set up keyboard shortcuts registered by extensions.
|
|
55
|
+
*/
|
|
56
|
+
setupExtensionShortcuts(extensionRunner) {
|
|
57
|
+
const shortcuts = extensionRunner.getShortcuts(this.ui.keybindings.getEffectiveConfig());
|
|
58
|
+
if (shortcuts.size === 0)
|
|
59
|
+
return;
|
|
60
|
+
// Create a context for shortcut handlers
|
|
61
|
+
const createContext = () => ({
|
|
62
|
+
ui: this.createExtensionUIContext(),
|
|
63
|
+
hasUI: true,
|
|
64
|
+
mode: "tui",
|
|
65
|
+
cwd: this.session.sessionManager.getCwd(),
|
|
66
|
+
sessionManager: this.session.sessionManager,
|
|
67
|
+
modelRegistry: this.session.modelRegistry,
|
|
68
|
+
model: this.session.model,
|
|
69
|
+
isIdle: () => !this.session.isStreaming,
|
|
70
|
+
signal: this.session.agent.signal,
|
|
71
|
+
abort: () => {
|
|
72
|
+
this.ui.abort();
|
|
73
|
+
},
|
|
74
|
+
hasPendingMessages: () => this.session.pendingMessageCount > 0,
|
|
75
|
+
shutdown: () => {
|
|
76
|
+
this.ui.markShutdownRequested();
|
|
77
|
+
},
|
|
78
|
+
getContextUsage: () => this.session.getContextUsage(),
|
|
79
|
+
compact: (options) => {
|
|
80
|
+
void (async () => {
|
|
81
|
+
try {
|
|
82
|
+
const result = await this.session.compact(options?.customInstructions);
|
|
83
|
+
options?.onComplete?.(result);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
87
|
+
options?.onError?.(err);
|
|
88
|
+
}
|
|
89
|
+
})();
|
|
90
|
+
},
|
|
91
|
+
reload: async () => {
|
|
92
|
+
await this.ui.reload();
|
|
93
|
+
},
|
|
94
|
+
getSystemPrompt: () => this.session.systemPrompt,
|
|
95
|
+
});
|
|
96
|
+
// Set up the extension shortcut handler on the default editor
|
|
97
|
+
this.ui.defaultEditor.onExtensionShortcut = (data) => {
|
|
98
|
+
for (const [shortcutStr, shortcut] of shortcuts) {
|
|
99
|
+
// Cast to KeyId - extension shortcuts use the same format
|
|
100
|
+
if (matchesKey(data, shortcutStr)) {
|
|
101
|
+
// Run handler async, don't block input
|
|
102
|
+
Promise.resolve(shortcut.handler(createContext())).catch((err) => {
|
|
103
|
+
this.ui.showError(`Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`);
|
|
104
|
+
});
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Set extension status text in the footer.
|
|
113
|
+
*/
|
|
114
|
+
setExtensionStatus(key, text) {
|
|
115
|
+
this.ui.footerDataProvider.setExtensionStatus(key, text);
|
|
116
|
+
this.ui.tui.requestRender();
|
|
117
|
+
}
|
|
118
|
+
// Maximum total widget lines to prevent viewport overflow
|
|
119
|
+
static MAX_WIDGET_LINES = 10;
|
|
120
|
+
/**
|
|
121
|
+
* Set an extension widget (string array or custom component).
|
|
122
|
+
*/
|
|
123
|
+
setExtensionWidget(key, content, options) {
|
|
124
|
+
const placement = options?.placement ?? "aboveEditor";
|
|
125
|
+
const removeExisting = (map) => {
|
|
126
|
+
const existing = map.get(key);
|
|
127
|
+
if (existing?.dispose)
|
|
128
|
+
existing.dispose();
|
|
129
|
+
map.delete(key);
|
|
130
|
+
};
|
|
131
|
+
removeExisting(this.extensionWidgetsAbove);
|
|
132
|
+
removeExisting(this.extensionWidgetsBelow);
|
|
133
|
+
if (content === undefined) {
|
|
134
|
+
this.renderWidgets();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let component;
|
|
138
|
+
if (Array.isArray(content)) {
|
|
139
|
+
// Wrap string array in a Container with Text components
|
|
140
|
+
const container = new Container();
|
|
141
|
+
for (const line of content.slice(0, ExtensionUiHost.MAX_WIDGET_LINES)) {
|
|
142
|
+
container.addChild(new Text(line, 1, 0));
|
|
143
|
+
}
|
|
144
|
+
if (content.length > ExtensionUiHost.MAX_WIDGET_LINES) {
|
|
145
|
+
container.addChild(new Text(theme.fg("muted", "... (widget truncated)"), 1, 0));
|
|
146
|
+
}
|
|
147
|
+
component = container;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Factory function - create component
|
|
151
|
+
component = content(this.ui.tui, theme);
|
|
152
|
+
}
|
|
153
|
+
const targetMap = placement === "belowEditor" ? this.extensionWidgetsBelow : this.extensionWidgetsAbove;
|
|
154
|
+
targetMap.set(key, component);
|
|
155
|
+
this.renderWidgets();
|
|
156
|
+
}
|
|
157
|
+
clearExtensionWidgets() {
|
|
158
|
+
for (const widget of this.extensionWidgetsAbove.values()) {
|
|
159
|
+
widget.dispose?.();
|
|
160
|
+
}
|
|
161
|
+
for (const widget of this.extensionWidgetsBelow.values()) {
|
|
162
|
+
widget.dispose?.();
|
|
163
|
+
}
|
|
164
|
+
this.extensionWidgetsAbove.clear();
|
|
165
|
+
this.extensionWidgetsBelow.clear();
|
|
166
|
+
this.renderWidgets();
|
|
167
|
+
}
|
|
168
|
+
resetExtensionUI() {
|
|
169
|
+
if (this.extensionSelector) {
|
|
170
|
+
this.hideExtensionSelector();
|
|
171
|
+
}
|
|
172
|
+
if (this.extensionInput) {
|
|
173
|
+
this.hideExtensionInput();
|
|
174
|
+
}
|
|
175
|
+
if (this.extensionEditor) {
|
|
176
|
+
this.hideExtensionEditor();
|
|
177
|
+
}
|
|
178
|
+
this.ui.tui.hideOverlay();
|
|
179
|
+
this.clearExtensionTerminalInputListeners();
|
|
180
|
+
this.setExtensionFooter(undefined);
|
|
181
|
+
this.setExtensionHeader(undefined);
|
|
182
|
+
this.clearExtensionWidgets();
|
|
183
|
+
this.ui.footerDataProvider.clearExtensionStatuses();
|
|
184
|
+
this.ui.footer.invalidate();
|
|
185
|
+
this.ui.resetAutocompleteProviderWrappers();
|
|
186
|
+
this.setCustomEditorComponent(undefined);
|
|
187
|
+
this.ui.setupAutocompleteProvider();
|
|
188
|
+
this.ui.defaultEditor.onExtensionShortcut = undefined;
|
|
189
|
+
this.ui.updateTerminalTitle();
|
|
190
|
+
this.ui.resetWorkingIndicators();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Render all extension widgets to the widget container.
|
|
194
|
+
*/
|
|
195
|
+
renderWidgets() {
|
|
196
|
+
if (!this.ui.widgetContainerAbove || !this.ui.widgetContainerBelow)
|
|
197
|
+
return;
|
|
198
|
+
this.renderWidgetContainer(this.ui.widgetContainerAbove, this.extensionWidgetsAbove, true, true);
|
|
199
|
+
this.renderWidgetContainer(this.ui.widgetContainerBelow, this.extensionWidgetsBelow, false, false);
|
|
200
|
+
this.ui.tui.requestRender();
|
|
201
|
+
}
|
|
202
|
+
renderWidgetContainer(container, widgets, spacerWhenEmpty, leadingSpacer) {
|
|
203
|
+
container.clear();
|
|
204
|
+
if (widgets.size === 0) {
|
|
205
|
+
if (spacerWhenEmpty) {
|
|
206
|
+
container.addChild(new Spacer(1));
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (leadingSpacer) {
|
|
211
|
+
container.addChild(new Spacer(1));
|
|
212
|
+
}
|
|
213
|
+
for (const component of widgets.values()) {
|
|
214
|
+
container.addChild(component);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set a custom footer component, or restore the built-in footer.
|
|
219
|
+
*/
|
|
220
|
+
setExtensionFooter(factory) {
|
|
221
|
+
// Dispose existing custom footer
|
|
222
|
+
if (this.customFooter?.dispose) {
|
|
223
|
+
this.customFooter.dispose();
|
|
224
|
+
}
|
|
225
|
+
// Remove current footer from UI
|
|
226
|
+
if (this.customFooter) {
|
|
227
|
+
this.ui.tui.removeChild(this.customFooter);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this.ui.tui.removeChild(this.ui.footer);
|
|
231
|
+
}
|
|
232
|
+
if (factory) {
|
|
233
|
+
// Create and add custom footer, passing the data provider
|
|
234
|
+
this.customFooter = factory(this.ui.tui, theme, this.ui.footerDataProvider);
|
|
235
|
+
this.ui.tui.addChild(this.customFooter);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
// Restore built-in footer
|
|
239
|
+
this.customFooter = undefined;
|
|
240
|
+
this.ui.tui.addChild(this.ui.footer);
|
|
241
|
+
}
|
|
242
|
+
this.ui.tui.requestRender();
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Set a custom header component, or restore the built-in header.
|
|
246
|
+
*/
|
|
247
|
+
setExtensionHeader(factory) {
|
|
248
|
+
// Header may not be initialized yet if called during early initialization
|
|
249
|
+
const builtInHeader = this.ui.getBuiltInHeader();
|
|
250
|
+
if (!builtInHeader) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
// Dispose existing custom header
|
|
254
|
+
if (this.customHeader?.dispose) {
|
|
255
|
+
this.customHeader.dispose();
|
|
256
|
+
}
|
|
257
|
+
// Find the index of the current header in the header container
|
|
258
|
+
const currentHeader = this.customHeader || builtInHeader;
|
|
259
|
+
const index = this.ui.headerContainer.children.indexOf(currentHeader);
|
|
260
|
+
if (factory) {
|
|
261
|
+
// Create and add custom header
|
|
262
|
+
this.customHeader = factory(this.ui.tui, theme);
|
|
263
|
+
if (isExpandable(this.customHeader)) {
|
|
264
|
+
this.customHeader.setExpanded(this.ui.getToolsExpanded());
|
|
265
|
+
}
|
|
266
|
+
if (index !== -1) {
|
|
267
|
+
this.ui.headerContainer.children[index] = this.customHeader;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
// If not found (e.g. builtInHeader was never added), add at the top
|
|
271
|
+
this.ui.headerContainer.children.unshift(this.customHeader);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
// Restore built-in header
|
|
276
|
+
this.customHeader = undefined;
|
|
277
|
+
if (isExpandable(builtInHeader)) {
|
|
278
|
+
builtInHeader.setExpanded(this.ui.getToolsExpanded());
|
|
279
|
+
}
|
|
280
|
+
if (index !== -1) {
|
|
281
|
+
this.ui.headerContainer.children[index] = builtInHeader;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
this.ui.tui.requestRender();
|
|
285
|
+
}
|
|
286
|
+
addExtensionTerminalInputListener(handler) {
|
|
287
|
+
const unsubscribe = this.ui.tui.addInputListener(handler);
|
|
288
|
+
this.extensionTerminalInputUnsubscribers.add(unsubscribe);
|
|
289
|
+
return () => {
|
|
290
|
+
unsubscribe();
|
|
291
|
+
this.extensionTerminalInputUnsubscribers.delete(unsubscribe);
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
clearExtensionTerminalInputListeners() {
|
|
295
|
+
for (const unsubscribe of this.extensionTerminalInputUnsubscribers) {
|
|
296
|
+
unsubscribe();
|
|
297
|
+
}
|
|
298
|
+
this.extensionTerminalInputUnsubscribers.clear();
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Create the ExtensionUIContext for extensions.
|
|
302
|
+
*/
|
|
303
|
+
createExtensionUIContext() {
|
|
304
|
+
return {
|
|
305
|
+
select: (title, options, opts) => this.showExtensionSelector(title, options, opts),
|
|
306
|
+
confirm: (title, message, opts) => this.showExtensionConfirm(title, message, opts),
|
|
307
|
+
input: (title, placeholder, opts) => this.showExtensionInput(title, placeholder, opts),
|
|
308
|
+
notify: (message, type) => this.showExtensionNotify(message, type),
|
|
309
|
+
onTerminalInput: (handler) => this.addExtensionTerminalInputListener(handler),
|
|
310
|
+
setStatus: (key, text) => this.setExtensionStatus(key, text),
|
|
311
|
+
setWorkingMessage: (message) => this.ui.setWorkingMessage(message),
|
|
312
|
+
setWorkingVisible: (visible) => this.ui.setWorkingVisible(visible),
|
|
313
|
+
setWorkingIndicator: (options) => this.ui.setWorkingIndicator(options),
|
|
314
|
+
setHiddenThinkingLabel: (label) => this.ui.setHiddenThinkingLabel(label),
|
|
315
|
+
setWidget: (key, content, options) => this.setExtensionWidget(key, content, options),
|
|
316
|
+
setFooter: (factory) => this.setExtensionFooter(factory),
|
|
317
|
+
setHeader: (factory) => this.setExtensionHeader(factory),
|
|
318
|
+
setTitle: (title) => this.ui.tui.terminal.setTitle(title),
|
|
319
|
+
custom: (factory, options) => this.showExtensionCustom(factory, options),
|
|
320
|
+
pasteToEditor: (text) => this.ui.getEditor().handleInput(`\x1b[200~${text}\x1b[201~`),
|
|
321
|
+
setEditorText: (text) => this.ui.getEditor().setText(text),
|
|
322
|
+
getEditorText: () => this.ui.getEditor().getExpandedText?.() ?? this.ui.getEditor().getText(),
|
|
323
|
+
editor: (title, prefill) => this.showExtensionEditor(title, prefill),
|
|
324
|
+
addAutocompleteProvider: (factory) => {
|
|
325
|
+
this.ui.pushAutocompleteProviderWrapper(factory);
|
|
326
|
+
this.ui.setupAutocompleteProvider();
|
|
327
|
+
},
|
|
328
|
+
setEditorComponent: (factory) => this.setCustomEditorComponent(factory),
|
|
329
|
+
getEditorComponent: () => this.editorComponentFactory,
|
|
330
|
+
get theme() {
|
|
331
|
+
return theme;
|
|
332
|
+
},
|
|
333
|
+
getAllThemes: () => getAvailableThemesWithPaths(),
|
|
334
|
+
getTheme: (name) => getThemeByName(name),
|
|
335
|
+
setTheme: (themeOrName) => {
|
|
336
|
+
if (themeOrName instanceof Theme) {
|
|
337
|
+
setThemeInstance(themeOrName);
|
|
338
|
+
this.ui.tui.requestRender();
|
|
339
|
+
return { success: true };
|
|
340
|
+
}
|
|
341
|
+
const result = setTheme(themeOrName, true);
|
|
342
|
+
if (result.success) {
|
|
343
|
+
if (this.session.settingsManager.getTheme() !== themeOrName) {
|
|
344
|
+
this.session.settingsManager.setTheme(themeOrName);
|
|
345
|
+
}
|
|
346
|
+
this.ui.tui.requestRender();
|
|
347
|
+
}
|
|
348
|
+
return result;
|
|
349
|
+
},
|
|
350
|
+
getToolsExpanded: () => this.ui.getToolsExpanded(),
|
|
351
|
+
setToolsExpanded: (expanded) => this.ui.setToolsExpanded(expanded),
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Show a selector for extensions.
|
|
356
|
+
*/
|
|
357
|
+
showExtensionSelector(title, options, opts) {
|
|
358
|
+
return new Promise((resolve) => {
|
|
359
|
+
if (opts?.signal?.aborted) {
|
|
360
|
+
resolve(undefined);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const onAbort = () => {
|
|
364
|
+
this.hideExtensionSelector();
|
|
365
|
+
resolve(undefined);
|
|
366
|
+
};
|
|
367
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
368
|
+
this.extensionSelector = new ExtensionSelectorComponent(title, options, (option) => {
|
|
369
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
370
|
+
this.hideExtensionSelector();
|
|
371
|
+
resolve(option);
|
|
372
|
+
}, () => {
|
|
373
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
374
|
+
this.hideExtensionSelector();
|
|
375
|
+
resolve(undefined);
|
|
376
|
+
}, { tui: this.ui.tui, timeout: opts?.timeout, onToggleToolsExpanded: () => this.ui.toggleToolsExpanded() });
|
|
377
|
+
this.ui.overlayHost.swap(this.extensionSelector);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Hide the extension selector.
|
|
382
|
+
*/
|
|
383
|
+
hideExtensionSelector() {
|
|
384
|
+
this.extensionSelector?.dispose();
|
|
385
|
+
this.extensionSelector = undefined;
|
|
386
|
+
this.ui.overlayHost.swap(this.ui.getEditor());
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Show a confirmation dialog for extensions.
|
|
390
|
+
*/
|
|
391
|
+
async showExtensionConfirm(title, message, opts) {
|
|
392
|
+
const result = await this.showExtensionSelector(`${title}\n${message}`, ["Yes", "No"], opts);
|
|
393
|
+
return result === "Yes";
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Show a text input for extensions.
|
|
397
|
+
*/
|
|
398
|
+
showExtensionInput(title, placeholder, opts) {
|
|
399
|
+
return new Promise((resolve) => {
|
|
400
|
+
if (opts?.signal?.aborted) {
|
|
401
|
+
resolve(undefined);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const onAbort = () => {
|
|
405
|
+
this.hideExtensionInput();
|
|
406
|
+
resolve(undefined);
|
|
407
|
+
};
|
|
408
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
409
|
+
this.extensionInput = new ExtensionInputComponent(title, placeholder, (value) => {
|
|
410
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
411
|
+
this.hideExtensionInput();
|
|
412
|
+
resolve(value);
|
|
413
|
+
}, () => {
|
|
414
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
415
|
+
this.hideExtensionInput();
|
|
416
|
+
resolve(undefined);
|
|
417
|
+
}, { tui: this.ui.tui, timeout: opts?.timeout });
|
|
418
|
+
this.ui.overlayHost.swap(this.extensionInput);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Hide the extension input.
|
|
423
|
+
*/
|
|
424
|
+
hideExtensionInput() {
|
|
425
|
+
this.extensionInput?.dispose();
|
|
426
|
+
this.extensionInput = undefined;
|
|
427
|
+
this.ui.overlayHost.swap(this.ui.getEditor());
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Show a multi-line editor for extensions (with Ctrl+G support).
|
|
431
|
+
*/
|
|
432
|
+
showExtensionEditor(title, prefill) {
|
|
433
|
+
return new Promise((resolve) => {
|
|
434
|
+
this.extensionEditor = new ExtensionEditorComponent(this.ui.tui, this.ui.keybindings, title, prefill, (value) => {
|
|
435
|
+
this.hideExtensionEditor();
|
|
436
|
+
resolve(value);
|
|
437
|
+
}, () => {
|
|
438
|
+
this.hideExtensionEditor();
|
|
439
|
+
resolve(undefined);
|
|
440
|
+
});
|
|
441
|
+
this.ui.overlayHost.swap(this.extensionEditor);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Hide the extension editor.
|
|
446
|
+
*/
|
|
447
|
+
hideExtensionEditor() {
|
|
448
|
+
this.extensionEditor = undefined;
|
|
449
|
+
this.ui.overlayHost.swap(this.ui.getEditor());
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Set a custom editor component from an extension.
|
|
453
|
+
* Pass undefined to restore the default editor.
|
|
454
|
+
*/
|
|
455
|
+
setCustomEditorComponent(factory) {
|
|
456
|
+
this.editorComponentFactory = factory;
|
|
457
|
+
// Save text from current editor before switching
|
|
458
|
+
const currentText = this.ui.getEditor().getText();
|
|
459
|
+
this.ui.editorContainer.clear();
|
|
460
|
+
if (factory) {
|
|
461
|
+
// Create the custom editor with tui, theme, and keybindings
|
|
462
|
+
const newEditor = factory(this.ui.tui, getEditorTheme(), this.ui.keybindings);
|
|
463
|
+
// Wire up callbacks from the default editor
|
|
464
|
+
newEditor.onSubmit = this.ui.defaultEditor.onSubmit;
|
|
465
|
+
newEditor.onChange = this.ui.defaultEditor.onChange;
|
|
466
|
+
// Copy text from previous editor
|
|
467
|
+
newEditor.setText(currentText);
|
|
468
|
+
// Copy appearance settings if supported
|
|
469
|
+
if (newEditor.borderColor !== undefined) {
|
|
470
|
+
newEditor.borderColor = this.ui.defaultEditor.borderColor;
|
|
471
|
+
}
|
|
472
|
+
if (newEditor.setPaddingX !== undefined) {
|
|
473
|
+
newEditor.setPaddingX(this.ui.defaultEditor.getPaddingX());
|
|
474
|
+
}
|
|
475
|
+
// Set autocomplete if supported
|
|
476
|
+
const autocompleteProvider = this.ui.getAutocompleteProvider();
|
|
477
|
+
if (newEditor.setAutocompleteProvider && autocompleteProvider) {
|
|
478
|
+
newEditor.setAutocompleteProvider(autocompleteProvider);
|
|
479
|
+
}
|
|
480
|
+
// If extending CustomEditor, copy app-level handlers
|
|
481
|
+
// Use duck typing since instanceof fails across jiti module boundaries
|
|
482
|
+
const customEditor = newEditor;
|
|
483
|
+
if ("actionHandlers" in customEditor && customEditor.actionHandlers instanceof Map) {
|
|
484
|
+
if (!customEditor.onEscape) {
|
|
485
|
+
customEditor.onEscape = () => this.ui.defaultEditor.onEscape?.();
|
|
486
|
+
}
|
|
487
|
+
if (!customEditor.onCtrlD) {
|
|
488
|
+
customEditor.onCtrlD = () => this.ui.defaultEditor.onCtrlD?.();
|
|
489
|
+
}
|
|
490
|
+
if (!customEditor.onPasteImage) {
|
|
491
|
+
customEditor.onPasteImage = () => this.ui.defaultEditor.onPasteImage?.();
|
|
492
|
+
}
|
|
493
|
+
if (!customEditor.onExtensionShortcut) {
|
|
494
|
+
customEditor.onExtensionShortcut = (data) => this.ui.defaultEditor.onExtensionShortcut?.(data);
|
|
495
|
+
}
|
|
496
|
+
// Copy action handlers (clear, suspend, model switching, etc.)
|
|
497
|
+
for (const [action, handler] of this.ui.defaultEditor.actionHandlers) {
|
|
498
|
+
customEditor.actionHandlers.set(action, handler);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
this.ui.setEditor(newEditor);
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
// Restore default editor with text from custom editor
|
|
505
|
+
this.ui.defaultEditor.setText(currentText);
|
|
506
|
+
this.ui.setEditor(this.ui.defaultEditor);
|
|
507
|
+
}
|
|
508
|
+
this.ui.editorContainer.addChild(this.ui.getEditor());
|
|
509
|
+
this.ui.tui.setFocus(this.ui.getEditor());
|
|
510
|
+
this.ui.tui.requestRender();
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Show a notification for extensions.
|
|
514
|
+
*/
|
|
515
|
+
showExtensionNotify(message, type) {
|
|
516
|
+
if (type === "error") {
|
|
517
|
+
this.ui.showError(message);
|
|
518
|
+
}
|
|
519
|
+
else if (type === "warning") {
|
|
520
|
+
this.ui.showWarning(message);
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
this.ui.showStatus(message);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
/** Show a custom component with keyboard focus. Overlay mode renders on top of existing content. */
|
|
527
|
+
async showExtensionCustom(factory, options) {
|
|
528
|
+
const savedText = this.ui.getEditor().getText();
|
|
529
|
+
const isOverlay = options?.overlay ?? false;
|
|
530
|
+
const restoreEditor = () => {
|
|
531
|
+
this.ui.getEditor().setText(savedText);
|
|
532
|
+
this.ui.overlayHost.swap(this.ui.getEditor(), { focusMode: "restore" });
|
|
533
|
+
};
|
|
534
|
+
return new Promise((resolve, reject) => {
|
|
535
|
+
let component;
|
|
536
|
+
let closed = false;
|
|
537
|
+
const close = (result) => {
|
|
538
|
+
if (closed)
|
|
539
|
+
return;
|
|
540
|
+
closed = true;
|
|
541
|
+
if (isOverlay)
|
|
542
|
+
this.ui.tui.hideOverlay();
|
|
543
|
+
else
|
|
544
|
+
restoreEditor();
|
|
545
|
+
// Note: both branches above already call requestRender
|
|
546
|
+
resolve(result);
|
|
547
|
+
try {
|
|
548
|
+
component?.dispose?.();
|
|
549
|
+
}
|
|
550
|
+
catch {
|
|
551
|
+
/* ignore dispose errors */
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
Promise.resolve(factory(this.ui.tui, theme, this.ui.keybindings, close))
|
|
555
|
+
.then((c) => {
|
|
556
|
+
if (closed)
|
|
557
|
+
return;
|
|
558
|
+
component = c;
|
|
559
|
+
if (isOverlay) {
|
|
560
|
+
// Resolve overlay options - can be static or dynamic function
|
|
561
|
+
const resolveOptions = () => {
|
|
562
|
+
if (options?.overlayOptions) {
|
|
563
|
+
const opts = typeof options.overlayOptions === "function"
|
|
564
|
+
? options.overlayOptions()
|
|
565
|
+
: options.overlayOptions;
|
|
566
|
+
return opts;
|
|
567
|
+
}
|
|
568
|
+
// Fallback: use component's width property if available
|
|
569
|
+
const w = component.width;
|
|
570
|
+
return w ? { width: w } : undefined;
|
|
571
|
+
};
|
|
572
|
+
const handle = this.ui.tui.showOverlay(component, resolveOptions());
|
|
573
|
+
// Expose handle to caller for visibility control
|
|
574
|
+
options?.onHandle?.(handle);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
this.ui.overlayHost.swap(component);
|
|
578
|
+
}
|
|
579
|
+
})
|
|
580
|
+
.catch((err) => {
|
|
581
|
+
if (closed)
|
|
582
|
+
return;
|
|
583
|
+
if (!isOverlay)
|
|
584
|
+
restoreEditor();
|
|
585
|
+
reject(err);
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Show an extension error in the UI.
|
|
591
|
+
*/
|
|
592
|
+
showExtensionError(extensionPath, error, stack) {
|
|
593
|
+
const errorMsg = `Extension "${extensionPath}" error: ${error}`;
|
|
594
|
+
const errorText = new Text(theme.fg("error", errorMsg), 1, 0);
|
|
595
|
+
this.ui.chatContainer.addChild(errorText);
|
|
596
|
+
if (stack) {
|
|
597
|
+
// Show stack trace in dim color, indented
|
|
598
|
+
const stackLines = stack
|
|
599
|
+
.split("\n")
|
|
600
|
+
.slice(1) // Skip first line (duplicates error message)
|
|
601
|
+
.map((line) => theme.fg("dim", ` ${line.trim()}`))
|
|
602
|
+
.join("\n");
|
|
603
|
+
if (stackLines) {
|
|
604
|
+
this.ui.chatContainer.addChild(new Text(stackLines, 1, 0));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
this.ui.tui.requestRender();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
//# sourceMappingURL=extension-ui-host.js.map
|