@bastani/atomic 0.9.27 → 0.9.28-alpha.2
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 +61 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/broker.ts +13 -1
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/web-access/index.bundle.mjs +194 -44
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/workflows/CHANGELOG.md +31 -0
- package/dist/builtin/workflows/builtin/{chunk-gw7rghda.js → chunk-aqv8ny38.js} +257 -259
- package/dist/builtin/workflows/builtin/{chunk-gts8wgjr.js → chunk-br4ac9a3.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-9bhs02gm.js → chunk-p3xmajmj.js} +439 -40
- package/dist/builtin/workflows/builtin/chunk-p6jagvyf.js +8 -0
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +14 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +108110 -107201
- package/dist/builtin/workflows/src/index.js +42226 -41077
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +16 -11
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +16 -1
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +12 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/credential-print.d.ts +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +2 -56
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/codemode-worker.js +99 -3
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +6 -1
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +20 -3
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +3 -2
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +6 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +96 -12
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +19 -3
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +3 -2
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +11 -16
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +1 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts.map +1 -1
- package/dist/core/auth-storage-backends.js +2 -1
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +15 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/azure-provider-compat.d.ts +8 -0
- package/dist/core/azure-provider-compat.d.ts.map +1 -0
- package/dist/core/azure-provider-compat.js +65 -0
- package/dist/core/azure-provider-compat.js.map +1 -0
- package/dist/core/child-session-options.d.ts +1 -1
- package/dist/core/child-session-options.d.ts.map +1 -1
- package/dist/core/child-session-options.js +11 -2
- package/dist/core/child-session-options.js.map +1 -1
- package/dist/core/compaction/classifier-compaction.d.ts +13 -0
- package/dist/core/compaction/classifier-compaction.d.ts.map +1 -0
- package/dist/core/compaction/classifier-compaction.js +110 -0
- package/dist/core/compaction/classifier-compaction.js.map +1 -0
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +2 -6
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +16 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +97 -12
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +18 -1
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/fallback-planner.d.ts +1 -0
- package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
- package/dist/core/compaction/fallback-planner.js +2 -0
- package/dist/core/compaction/fallback-planner.js.map +1 -1
- package/dist/core/compaction/index.d.ts +3 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +3 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/model-resolver.d.ts +16 -0
- package/dist/core/compaction/model-resolver.d.ts.map +1 -0
- package/dist/core/compaction/model-resolver.js +18 -0
- package/dist/core/compaction/model-resolver.js.map +1 -0
- package/dist/core/compaction/morph-compaction.d.ts +14 -0
- package/dist/core/compaction/morph-compaction.d.ts.map +1 -0
- package/dist/core/compaction/morph-compaction.js +99 -0
- package/dist/core/compaction/morph-compaction.js.map +1 -0
- package/dist/core/compaction/pi-summary-fallback.d.ts +34 -0
- package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -0
- package/dist/core/compaction/pi-summary-fallback.js +357 -0
- package/dist/core/compaction/pi-summary-fallback.js.map +1 -0
- package/dist/core/compaction/planner-outcome.d.ts +10 -6
- package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
- package/dist/core/compaction/planner-outcome.js +11 -4
- package/dist/core/compaction/planner-outcome.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +3 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.js +11 -0
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
- package/dist/core/compaction/range-planner.d.ts +3 -3
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +59 -28
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/region-trimming.d.ts.map +1 -1
- package/dist/core/compaction/region-trimming.js +7 -0
- package/dist/core/compaction/region-trimming.js.map +1 -1
- package/dist/core/compaction/structured-compaction-input.d.ts +19 -0
- package/dist/core/compaction/structured-compaction-input.d.ts.map +1 -0
- package/dist/core/compaction/structured-compaction-input.js +70 -0
- package/dist/core/compaction/structured-compaction-input.js.map +1 -0
- package/dist/core/compaction/transcript-serialization.d.ts +1 -0
- package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
- package/dist/core/compaction/transcript-serialization.js +26 -0
- package/dist/core/compaction/transcript-serialization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +3 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +1 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +5 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts +1 -0
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +12 -0
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +10 -4
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +47 -3
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +11 -4
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +38 -9
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +2 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +49 -0
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.d.ts +16 -4
- package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control-hub.js +72 -1
- package/dist/core/extensions/workflow-run-control-hub.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +11 -3
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +1 -1
- package/dist/core/fast-model-variants.js +1 -1
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/keybindings.d.ts +4 -4
- package/dist/core/messages.d.ts +1 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +5 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +5 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +5 -1
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +6 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.js +2 -1
- package/dist/core/model-resolver-patterns.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +3 -1
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +2 -0
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +48 -22
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +4 -1
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-display-names.js +1 -1
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +3 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +4 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +1 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -1
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +28 -5
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +2 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +6 -4
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-work.d.ts +2 -1
- package/dist/core/session-lifecycle-work.d.ts.map +1 -1
- package/dist/core/session-lifecycle-work.js +15 -1
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +4 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +2 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +33 -4
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +2 -0
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +2 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +3 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +8 -1
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tool-selection.d.ts +13 -0
- package/dist/core/tool-selection.d.ts.map +1 -0
- package/dist/core/tool-selection.js +43 -0
- package/dist/core/tool-selection.js.map +1 -0
- package/dist/core/tools/read.d.ts +7 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +11 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/transcript.d.ts +58 -0
- package/dist/core/transcript.d.ts.map +1 -0
- package/dist/core/transcript.js +185 -0
- package/dist/core/transcript.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +2 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +1 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +4 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +6 -3
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +15 -10
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/extensions/herdr/pane-owner.d.ts +6 -2
- package/dist/extensions/herdr/pane-owner.d.ts.map +1 -1
- package/dist/extensions/herdr/pane-owner.js +19 -4
- package/dist/extensions/herdr/pane-owner.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.js +14 -1
- package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/types.d.ts +1 -0
- package/dist/extensions/mcp/client/oauth/types.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/types.js.map +1 -1
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +5 -2
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +18 -4
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/migrations-azure.d.ts +4 -0
- package/dist/migrations-azure.d.ts.map +1 -0
- package/dist/migrations-azure.js +41 -0
- package/dist/migrations-azure.js.map +1 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -1
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +2 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +9 -3
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +15 -3
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +43 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +6 -4
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +13 -1
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +8 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +2 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.js +1 -0
- package/dist/modes/interactive/theme/tui-theme.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +1 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/utils/credential-redaction.d.ts +2 -0
- package/dist/utils/credential-redaction.d.ts.map +1 -0
- package/dist/utils/credential-redaction.js +20 -0
- package/dist/utils/credential-redaction.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/codemode.md +3 -2
- package/docs/compaction/reference.md +10 -4
- package/docs/compaction.md +40 -8
- package/docs/docs.json +1 -0
- package/docs/extensions/api-reference.md +18 -0
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/events.md +2 -2
- package/docs/extensions.md +2 -0
- package/docs/keybindings.md +9 -9
- package/docs/mcp-servers.md +4 -0
- package/docs/providers.md +33 -3
- package/docs/reference/cli.md +10 -3
- package/docs/sdk/reference.md +16 -1
- package/docs/sdk/web-server.md +325 -0
- package/docs/sdk.md +83 -1
- package/docs/security.md +1 -1
- package/docs/workflows/api-reference.md +74 -4
- package/docs/workflows/authoring.md +6 -2
- package/docs/workflows/builtins.md +4 -0
- package/docs/workflows/operations.md +12 -4
- package/npm-shrinkwrap.json +78 -74
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAOvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,CAAkB;IAE9B,MAAM,CAA8B;IACpC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAwC,EAAE,CAAC;IACrD,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAG,EAAE,CAAC;IACnB,+FAA+F;IAC/F,kBAAkB,CAAqB;IACvC,UAAU,GAAG,KAAK,CAAC;IACnB,gBAAgB,GAAG,KAAK,CAAC;IACzB,OAAO,GAAG,KAAK,CAAC;IAChB,yEAAyE;IACzE,mBAAmB,CAA4B;IAC/C,4EAA4E;IAC5E,uBAAuB,CAAqB;IAC5C,cAAc,CAAqB;IACnC,YAAY,GAAG,CAAC,CAAC;IACjB,sBAAsB,CAAU;IAChC,0BAA0B,GAAG,CAAC,CAAC;IAC/B,2BAA2B,GAAG,KAAK,CAAC;IACpC,QAAQ,GAAG,KAAK,CAAC;IACjB,uBAAuB,GAAsB,EAAE,CAAC;IAChD,uBAAuB,GAAsB,EAAE,CAAC;IAChD,wBAAwB,GAAsB,EAAE,CAAC;IACjD,UAAU,GAAG,KAAK,CAAC;IACnB,mFAAmF;IACnF,+BAA+B,GAAG,KAAK,CAAC;IACxC,cAAc,CAA6C;IAC3D,mBAAmB,CAA4C;IAC/D,YAAY,
|
|
1
|
+
{"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAOvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,CAAkB;IAE9B,MAAM,CAA8B;IACpC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAwC,EAAE,CAAC;IACrD,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAG,EAAE,CAAC;IACnB,+FAA+F;IAC/F,kBAAkB,CAAqB;IACvC,UAAU,GAAG,KAAK,CAAC;IACnB,gBAAgB,GAAG,KAAK,CAAC;IACzB,OAAO,GAAG,KAAK,CAAC;IAChB,yEAAyE;IACzE,mBAAmB,CAA4B;IAC/C,4EAA4E;IAC5E,uBAAuB,CAAqB;IAC5C,cAAc,CAAqB;IACnC,YAAY,GAAG,CAAC,CAAC;IACjB,sBAAsB,CAAU;IAChC,0BAA0B,GAAG,CAAC,CA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QAChD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,IAAI,CAAC,UAAU,EACf,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly string[] = [];\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport: ScrollableComponentViewport;\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.bodyViewport = new ScrollableComponentViewport(opts.keybindings);\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
|
|
@@ -87,6 +87,8 @@ export declare class ScrollableComponentViewport implements Component {
|
|
|
87
87
|
* honour it. See `scrollTo` for why the request has to outlive the call.
|
|
88
88
|
*/
|
|
89
89
|
private pendingScrollRow;
|
|
90
|
+
private readonly keybindings;
|
|
91
|
+
constructor(keybindings?: unknown);
|
|
90
92
|
setComponents(components: readonly Component[]): void;
|
|
91
93
|
setVisibleRows(rows: number): void;
|
|
92
94
|
getScrollFromBottom(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-transcript.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chat-transcript.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,SAAS,EACd,KAAK,SAAS,EAKd,MAAM,wBAAwB,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAC3B,W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AED;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9B;IAED;;;;;;OAMG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpE;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAwBjC;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAyD9B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,WAAW;CAGnB;AAgHD,qBAAa,iCAAiC,CAAC,MAAM,SAAS,uBAAuB,CAAE,YAAW,SAAS;IAC1G,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkC;IAE7D,YAAY,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,sBAAsB,CAAC,MAAM,CAAC,EAGlF;IAED,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjC;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjC;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,mBAAmB,IAAI,MAAM,CAE5B;IAED,YAAY,IAAI,MAAM,CAErB;IAED,cAAc,IAAI,IAAI,CAErB;CACD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { matchesKey, Spacer } from "@earendil-works/pi-tui";
|
|
1
|
+
import { getKeybindings, matchesKey, Spacer, } from "@earendil-works/pi-tui";
|
|
2
2
|
export function addChatTranscriptEntry(container, component, role) {
|
|
3
3
|
if (needsLeadingSpacer(role) && container.children.length > 0) {
|
|
4
4
|
container.addChild(new Spacer(1));
|
|
@@ -185,6 +185,12 @@ export class ScrollableComponentViewport {
|
|
|
185
185
|
* honour it. See `scrollTo` for why the request has to outlive the call.
|
|
186
186
|
*/
|
|
187
187
|
pendingScrollRow;
|
|
188
|
+
keybindings;
|
|
189
|
+
constructor(keybindings) {
|
|
190
|
+
const candidate = keybindings;
|
|
191
|
+
this.keybindings =
|
|
192
|
+
typeof candidate?.matches === "function" ? candidate : undefined;
|
|
193
|
+
}
|
|
188
194
|
setComponents(components) {
|
|
189
195
|
this.components = components;
|
|
190
196
|
}
|
|
@@ -272,11 +278,11 @@ export class ScrollableComponentViewport {
|
|
|
272
278
|
this.scrollBy(this.pageSize());
|
|
273
279
|
return true;
|
|
274
280
|
}
|
|
275
|
-
if (
|
|
281
|
+
if ((this.keybindings ?? getKeybindings()).matches(data, "tui.altScreen.top")) {
|
|
276
282
|
this.scrollToTop();
|
|
277
283
|
return true;
|
|
278
284
|
}
|
|
279
|
-
if (
|
|
285
|
+
if ((this.keybindings ?? getKeybindings()).matches(data, "tui.altScreen.bottom")) {
|
|
280
286
|
this.scrollToBottom();
|
|
281
287
|
return true;
|
|
282
288
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-transcript.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAoF5F,MAAM,UAAU,sBAAsB,CAAC,SAAoB,EAAE,SAAoB,EAAE,IAAwB;IAC1G,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,SA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AAE,OAAO,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC;IAC3B,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,wBAAwB,CAAC;IACtD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,wBAAwB,CAAC;IACrD,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import { type Component, type Container, matchesKey, Spacer } from \"@earendil-works/pi-tui\";\n\n/**\n * Roles that participate in pi's chat spacing contract.\n *\n * Assistant turns own their leading whitespace internally, and tool rows attach\n * directly under the assistant/tool-call row they belong to. User-like rows get\n * one blank line when they are not the first row in the transcript.\n */\nexport type ChatTranscriptRole =\n\t| \"assistant\"\n\t| \"thinking\"\n\t| \"tool\"\n\t| \"user\"\n\t| \"custom\"\n\t| \"notice\"\n\t| \"system\"\n\t| \"summary\";\n\nexport interface ChatTranscriptEntryLike {\n\treadonly role: ChatTranscriptRole;\n}\n\nexport type ChatTranscriptRenderer<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry) => Component;\n\nexport type ChatTranscriptCacheKey<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry, index: number) => string;\n\ninterface CachedChatTranscriptBlock<TEntry extends ChatTranscriptEntryLike> {\n\treadonly entry: TEntry;\n\treadonly key: string;\n\treadonly width: number;\n\treadonly component: Component;\n\treadonly lines: readonly string[];\n}\n\ntype DisposableComponent = Component & { dispose?: () => void };\n\n/**\n * A run of rows inside a windowed component, tagged with the identity of the\n * thing that produced them.\n *\n * `id` is compared with `===` only, and is never rendered. Entry *objects* are\n * the natural id for a transcript: cache keys carry the entry's index and so\n * change for every survivor of a splice, while the entry objects themselves are\n * moved, not rebuilt.\n */\nexport interface RowWindowSegment {\n\treadonly id: unknown;\n\treadonly rows: number;\n}\n\ninterface RowWindowComponent extends Component {\n\treadonly supportsRowWindow: true;\n\trowCount(width: number): number;\n\trenderRows(width: number, startRow: number, endRow: number): string[];\n\t/**\n\t * Optional row map, letting the viewport keep a scroll anchor that sits\n\t * *inside* this component when its interior changes height.\n\t */\n\trowSegments?(width: number): readonly RowWindowSegment[];\n}\n\ninterface WindowedComponentRows {\n\treadonly kind: \"windowed\";\n\treadonly component: RowWindowComponent;\n\treadonly rowCount: number;\n\treadonly segments: readonly RowWindowSegment[] | undefined;\n}\n\ninterface StaticComponentRows {\n\treadonly kind: \"static\";\n\treadonly lines: readonly string[];\n\treadonly rowCount: number;\n\t/**\n\t * Present when a static component can still identify its own rows. A\n\t * transcript built without a cache key renders every row each frame rather\n\t * than windowing, but it knows just as well which entry produced which rows,\n\t * and the anchor needs that whenever it is the component spanning the anchor.\n\t */\n\treadonly segments?: readonly RowWindowSegment[] | undefined;\n}\n\ntype ComponentRows = WindowedComponentRows | StaticComponentRows;\n\nexport function addChatTranscriptEntry(container: Container, component: Component, role: ChatTranscriptRole): void {\n\tif (needsLeadingSpacer(role) && container.children.length > 0) {\n\t\tcontainer.addChild(new Spacer(1));\n\t}\n\tcontainer.addChild(component);\n}\n\nfunction needsLeadingSpacer(role: ChatTranscriptRole): boolean {\n\treturn role === \"user\" || role === \"custom\" || role === \"notice\" || role === \"system\" || role === \"summary\";\n}\n\n/**\n * Reusable pi chat transcript scaffold for extension surfaces.\n *\n * This intentionally mirrors InteractiveMode.addMessageToChat spacing without\n * coupling consumers to a full AgentSession. Extension UIs can bring their own\n * message model while still rendering inside the same Container/Spacer rhythm\n * as the main chat.\n */\nexport class ChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly entries: readonly TEntry[];\n\tprivate readonly renderEntry: ChatTranscriptRenderer<TEntry>;\n\treadonly supportsRowWindow: boolean;\n\n\tprivate readonly cacheKey: ChatTranscriptCacheKey<TEntry> | undefined;\n\tprivate blockCache: Array<CachedChatTranscriptBlock<TEntry> | undefined> = [];\n\t/** Per-entry heights recorded by the most recent `renderAllRows`. */\n\tprivate staticSegments: readonly RowWindowSegment[] = [];\n\t/** Width those heights were measured at; they mean nothing at another width. */\n\tprivate staticSegmentsWidth: number | undefined;\n\n\tconstructor(\n\t\tentries: readonly TEntry[],\n\t\trenderEntry: ChatTranscriptRenderer<TEntry>,\n\t\tcacheKey?: ChatTranscriptCacheKey<TEntry>,\n\t) {\n\t\tthis.entries = entries;\n\t\tthis.renderEntry = renderEntry;\n\t\tthis.cacheKey = cacheKey;\n\t\tthis.supportsRowWindow = cacheKey !== undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width);\n\t\treturn this.renderRows(width, 0, this.rowCount(width));\n\t}\n\n\trowCount(width: number): number {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).length;\n\t\tthis.ensureBlockCache(width);\n\t\tlet count = 0;\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) count += block.lines.length;\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * One segment per cached entry block, identified by the entry object itself.\n\t */\n\trowSegments(width: number): readonly RowWindowSegment[] {\n\t\tif (!this.supportsRowWindow) {\n\t\t\t// Recorded by the last renderAllRows. The viewport measures a static\n\t\t\t// component by rendering it and only then reads its segments, so this\n\t\t\t// is populated for the frame being measured. A width mismatch means the\n\t\t\t// heights describe a different layout, and reporting them would move the\n\t\t\t// anchor by a stale delta; the caller falls back to whole-component\n\t\t\t// accounting instead.\n\t\t\treturn this.staticSegmentsWidth === width ? this.staticSegments : [];\n\t\t}\n\t\tthis.ensureBlockCache(width);\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) segments.push({ id: block.entry, rows: block.lines.length });\n\t\t}\n\t\treturn segments;\n\t}\n\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\tconst start = Math.max(0, Math.floor(startRow));\n\t\tconst end = Math.max(start, Math.floor(endRow));\n\t\tif (end <= start) return [];\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).slice(start, end);\n\n\t\tthis.ensureBlockCache(width);\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst block = this.blockCache[index];\n\t\t\tif (block === undefined) continue;\n\t\t\tconst blockStart = cursor;\n\t\t\tconst blockEnd = blockStart + block.lines.length;\n\t\t\tif (blockEnd > start && blockStart < end) {\n\t\t\t\tconst localStart = Math.max(0, start - blockStart);\n\t\t\t\tconst localEnd = Math.min(block.lines.length, end - blockStart);\n\t\t\t\tlines.push(...block.lines.slice(localStart, localEnd));\n\t\t\t}\n\t\t\tcursor = blockEnd;\n\t\t\tif (cursor >= end) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const block of this.blockCache) disposeComponent(block?.component);\n\t\tthis.blockCache = [];\n\t}\n\n\tprivate ensureBlockCache(width: number): void {\n\t\tif (this.blockCache.length > this.entries.length) {\n\t\t\tfor (let index = this.entries.length; index < this.blockCache.length; index += 1) {\n\t\t\t\tdisposeComponent(this.blockCache[index]?.component);\n\t\t\t}\n\t\t\tthis.blockCache.length = this.entries.length;\n\t\t}\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst key = this.cacheKey?.(entry, index) ?? `${index}:${entry.role}`;\n\t\t\tconst cached = this.blockCache[index];\n\t\t\tif (cached !== undefined && cached.entry === entry && cached.key === key && cached.width === width) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdisposeComponent(cached?.component);\n\t\t\tconst component = this.renderEntry(entry);\n\t\t\tthis.blockCache[index] = {\n\t\t\t\tentry,\n\t\t\t\tkey,\n\t\t\t\twidth,\n\t\t\t\tcomponent,\n\t\t\t\tlines: this.renderEntryBlock(component, entry, index, width),\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Render every entry, recording each one's height as it goes.\n\t *\n\t * The heights are what `rowSegments` reports on this path. They are a\n\t * by-product of work this method already does, so identifying rows costs\n\t * nothing extra and, unlike a cache key, cannot miss an entry mutated in\n\t * place -- which is the behaviour a transcript without a cache key exists to\n\t * provide.\n\t */\n\tprivate renderAllRows(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst block = this.renderEntryBlock(this.renderEntry(entry), entry, index, width);\n\t\t\tsegments.push({ id: entry, rows: block.length });\n\t\t\tlines.push(...block);\n\t\t}\n\t\tthis.staticSegments = segments;\n\t\tthis.staticSegmentsWidth = width;\n\t\treturn lines;\n\t}\n\n\tprivate renderEntryBlock(component: Component, entry: TEntry, index: number, width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tif (index > 0 && needsLeadingSpacer(entry.role)) lines.push(\"\");\n\t\tlines.push(...component.render(width));\n\t\treturn lines;\n\t}\n}\n\nfunction disposeComponent(component: Component | undefined): void {\n\t(component as DisposableComponent | undefined)?.dispose?.();\n}\n\nconst DEFAULT_SCROLL_STEP_ROWS = 4;\n\n/**\n * Sticky-bottom, scrollable viewport for chat-like component stacks.\n *\n * Pi's main interactive chat gets terminal scrollback for free. Extension\n * overlays render into a fixed rectangle, so they need an explicit viewport\n * with the same sticky-bottom default plus keyboard and mouse history controls.\n */\nexport class ScrollableComponentViewport implements Component {\n\tprivate components: readonly Component[] = [];\n\tprivate visibleRows = 1;\n\tprivate scrollFromBottom = 0;\n\tprivate lastLineCount = 0;\n\tprivate lastComponentSegments: readonly (readonly RowWindowSegment[] | undefined)[] = [];\n\tprivate lastComponentRowCounts: readonly number[] = [];\n\tprivate lastWidth = 0;\n\tprivate maxScroll = 0;\n\t/**\n\t * Absolute row `scrollTo` asked for, still waiting for the render that can\n\t * honour it. See `scrollTo` for why the request has to outlive the call.\n\t */\n\tprivate pendingScrollRow: number | undefined;\n\n\tsetComponents(components: readonly Component[]): void {\n\t\tthis.components = components;\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.visibleRows = Math.max(1, Math.floor(rows));\n\t\tthis.clampScroll();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.scrollFromBottom;\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.maxScroll;\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = 0;\n\t}\n\n\tscrollToTop(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = this.maxScroll;\n\t}\n\n\tscrollBy(deltaRows: number): void {\n\t\t// Positive deltas move toward newer content; negative deltas move up\n\t\t// into older history. Store the offset from the sticky bottom so new\n\t\t// streaming output can keep following when the offset is zero.\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom -= deltaRows;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Park the viewport with `row` as its first visible row.\n\t *\n\t * The absolute counterpart of `scrollBy`, for a caller that already knows\n\t * which row it wants on screen.\n\t *\n\t * The request is *also* recorded for the next render, and that is the half\n\t * that matters. `scrollFromBottom` is a distance from the bottom, so the\n\t * row it names moves whenever the stack grows; and the render that follows\n\t * re-derives the offset from the previous frame's layout to hold a\n\t * scrolled-up reader's content still, which would drag this request back\n\t * with it. A caller who has just measured rows the last render never saw\n\t * would otherwise be answered with the old layout's clamp and the old\n\t * frame's anchor. The next render resolves the row against the layout it\n\t * actually paints; any other scroll before then withdraws the request.\n\t */\n\tscrollTo(row: number): void {\n\t\tconst requestedRow = Number.isNaN(row) ? 0 : Math.max(0, Math.floor(row));\n\t\tthis.pendingScrollRow = requestedRow;\n\t\tconst target = Math.min(this.maxScroll, requestedRow);\n\t\tthis.scrollFromBottom = this.maxScroll - target;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Total rows the component stack occupies at `width`, on and off screen.\n\t *\n\t * This measures rather than paints: it is what lets a search read the whole\n\t * transcript instead of the window the reader happens to be parked on.\n\t */\n\trowCount(width: number): number {\n\t\treturn this.measureComponentRows(width).reduce((sum, rows) => sum + rows.rowCount, 0);\n\t}\n\n\t/**\n\t * Rows `startRow` (inclusive) through `endRow` (exclusive) of the whole\n\t * stack, independent of the current scroll offset. Deliberately not paired\n\t * with `supportsRowWindow`: a viewport is a scroll container rather than a\n\t * windowed component, and an enclosing viewport must keep measuring it by\n\t * its visible height.\n\t */\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\treturn this.renderVisibleRows(this.measureComponentRows(width), width, startRow, endRow);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\tconst wheelDeltaRows = mouseWheelDeltaRows(data);\n\t\tif (wheelDeltaRows !== 0) {\n\t\t\tthis.scrollBy(wheelDeltaRows);\n\t\t\treturn true;\n\t\t}\n\t\tif (isMouseSequence(data)) return true;\n\t\tif (matchesKey(data, \"pageUp\")) {\n\t\t\tthis.scrollBy(-this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"pageDown\")) {\n\t\t\tthis.scrollBy(this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"home\")) {\n\t\t\tthis.scrollToTop();\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"end\")) {\n\t\t\tthis.scrollToBottom();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst componentRows = this.measureComponentRows(width);\n\t\tconst rowCounts = componentRows.map((rows) => rows.rowCount);\n\t\tconst lineCount = rowCounts.reduce((sum, count) => sum + count, 0);\n\t\tconst maxScroll = Math.max(0, lineCount - this.visibleRows);\n\t\t// The offset is a distance from the bottom, so the first visible row is\n\t\t// `maxScroll - scrollFromBottom`. Rows appearing or disappearing move the\n\t\t// content a scrolled-up viewer is reading unless the offset moves with\n\t\t// them -- a live subagent widget does exactly that every time it gains or\n\t\t// drops its current-tool row.\n\t\t//\n\t\t// Which way the offset must move depends on where the rows changed, so a\n\t\t// plain `scrollFromBottom += lineCount - lastLineCount` is wrong half the\n\t\t// time. Rows changing *below* the anchor need the offset adjusted by that\n\t\t// delta; rows changing *above* it need the offset left alone, because the\n\t\t// bottom-relative distance to the anchored content did not change. Anchor\n\t\t// on the row the viewer is actually reading and re-derive the offset from\n\t\t// it. A viewer already at the bottom keeps scrollFromBottom === 0 and is\n\t\t// skipped entirely, so sticky-bottom following is untouched.\n\t\t//\n\t\t// Per-component row counts alone cannot place a change that happens\n\t\t// inside the component holding the anchor -- and in the chat host the\n\t\t// whole transcript is one component, so that is the normal case. A\n\t\t// component that can hand over a row map turns the \"where\" question into\n\t\t// \"where did the anchored segment go\". Both kinds may supply one: a\n\t\t// transcript built without a cache key is not windowed, but it is still\n\t\t// one component spanning the anchor and still knows its own rows.\n\t\tconst segments = componentRows.map((rows) => rows.segments);\n\t\tconst pendingScrollRow = this.pendingScrollRow;\n\t\tthis.pendingScrollRow = undefined;\n\t\tif (pendingScrollRow !== undefined) {\n\t\t\t// An absolute request outranks the anchor: the caller measured this\n\t\t\t// frame's rows and named one of them. Re-deriving the anchor here\n\t\t\t// would answer with the previous frame's layout instead.\n\t\t\tthis.scrollFromBottom = maxScroll - Math.min(maxScroll, pendingScrollRow);\n\t\t} else if (this.scrollFromBottom > 0 && this.lastWidth === width) {\n\t\t\tconst previousMaxScroll = Math.max(0, this.lastLineCount - this.visibleRows);\n\t\t\tconst anchorRow = Math.max(0, previousMaxScroll - this.scrollFromBottom);\n\t\t\tconst shift = rowsShiftedAboveAnchor(\n\t\t\t\t{ rowCounts: this.lastComponentRowCounts, segments: this.lastComponentSegments },\n\t\t\t\t{ rowCounts, segments },\n\t\t\t\tanchorRow,\n\t\t\t);\n\t\t\tconst nextAnchorRow = Math.max(0, Math.min(maxScroll, anchorRow + shift));\n\t\t\tthis.scrollFromBottom = maxScroll - nextAnchorRow;\n\t\t}\n\t\tthis.lastLineCount = lineCount;\n\t\tthis.lastComponentRowCounts = rowCounts;\n\t\tthis.lastComponentSegments = segments;\n\t\tthis.lastWidth = width;\n\t\tthis.maxScroll = maxScroll;\n\t\tthis.clampScroll();\n\n\t\tconst start = Math.max(0, maxScroll - this.scrollFromBottom);\n\t\tconst visible = this.renderVisibleRows(componentRows, width, start, start + this.visibleRows);\n\t\twhile (visible.length < this.visibleRows) visible.push(\" \".repeat(width));\n\t\treturn visible;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const component of this.components) component.invalidate();\n\t}\n\n\tprivate measureComponentRows(width: number): ComponentRows[] {\n\t\treturn this.components.map((component) => {\n\t\t\tif (isRowWindowComponent(component)) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"windowed\",\n\t\t\t\t\tcomponent,\n\t\t\t\t\trowCount: component.rowCount(width),\n\t\t\t\t\tsegments: component.rowSegments?.(width),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst lines = component.render(width);\n\t\t\t// Read segments only after rendering: a static transcript records its\n\t\t\t// per-entry heights as a by-product of that render, so asking first\n\t\t\t// would return the previous frame's layout.\n\t\t\tconst segments = segmentReporter(component)?.rowSegments(width);\n\t\t\treturn {\n\t\t\t\tkind: \"static\",\n\t\t\t\tlines,\n\t\t\t\trowCount: lines.length,\n\t\t\t\tsegments: segments !== undefined && segments.length > 0 ? segments : undefined,\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate renderVisibleRows(\n\t\tcomponentRows: readonly ComponentRows[],\n\t\twidth: number,\n\t\tstartRow: number,\n\t\tendRow: number,\n\t): string[] {\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (const rows of componentRows) {\n\t\t\tconst componentStart = cursor;\n\t\t\tconst componentEnd = componentStart + rows.rowCount;\n\t\t\tif (componentEnd > startRow && componentStart < endRow) {\n\t\t\t\tconst localStart = Math.max(0, startRow - componentStart);\n\t\t\t\tconst localEnd = Math.min(rows.rowCount, endRow - componentStart);\n\t\t\t\tif (rows.kind === \"windowed\") {\n\t\t\t\t\tlines.push(...rows.component.renderRows(width, localStart, localEnd));\n\t\t\t\t} else {\n\t\t\t\t\tlines.push(...rows.lines.slice(localStart, localEnd));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcursor = componentEnd;\n\t\t\tif (cursor >= endRow) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate pageSize(): number {\n\t\treturn Math.max(4, this.visibleRows - 2);\n\t}\n\n\tprivate clampScroll(): void {\n\t\tthis.scrollFromBottom = Math.max(0, Math.min(this.maxScroll, this.scrollFromBottom));\n\t}\n}\n\n/** One rendered frame's row layout, as the viewport measured it. */\ninterface ComponentRowLayout {\n\treadonly rowCounts: readonly number[];\n\treadonly segments: readonly (readonly RowWindowSegment[] | undefined)[];\n}\n\n/**\n * Rows gained or lost above `anchorRow`, measured in the previous frame's rows.\n *\n * The anchored row moves down by exactly this many rows, so adding it to the\n * anchor keeps the same content under the viewer.\n *\n * Components entirely above the anchor contribute their whole height delta.\n * The component that *spans* the anchor contributes only what changed above the\n * anchored row, which needs its row map (`rowSegments`); without one it\n * contributes nothing, which is the old behaviour and is right for the\n * append-and-mutate-at-the-tail widgets that have no interior.\n *\n * Row counts are compared positionally over the shared prefix, which is what the\n * chat stacks this viewport drives actually do — they append and mutate at the\n * tail. A component inserted or removed *ahead* of the anchor would be\n * misattributed; the anchor then lands one component off rather than drifting on\n * every frame, and the next user scroll re-establishes it.\n */\nfunction rowsShiftedAboveAnchor(previous: ComponentRowLayout, next: ComponentRowLayout, anchorRow: number): number {\n\tlet cursor = 0;\n\tlet shift = 0;\n\tconst shared = Math.min(previous.rowCounts.length, next.rowCounts.length);\n\tfor (let index = 0; index < shared; index += 1) {\n\t\tconst previousRows = previous.rowCounts[index] ?? 0;\n\t\tconst componentEnd = cursor + previousRows;\n\t\tif (componentEnd > anchorRow) {\n\t\t\treturn shift + rowsShiftedInsideComponent(previous.segments[index], next.segments[index], anchorRow - cursor);\n\t\t}\n\t\tshift += (next.rowCounts[index] ?? 0) - previousRows;\n\t\tcursor = componentEnd;\n\t}\n\treturn shift;\n}\n\n/**\n * Rows gained or lost above `anchorRow` *within* one windowed component.\n *\n * Rather than diffing heights, this finds the segment the viewer is parked on\n * and reports how far that same segment moved. Segments are matched by `===` on\n * their id, so a transcript splice that renumbers every cache key still lines\n * up: the entry objects survive it. If the anchored segment itself is gone\n * (the viewer was reading rows that were compacted away) the nearest surviving\n * neighbour above it — then below it — stands in, so the viewer lands on the\n * closest content that still exists instead of drifting by the whole delta.\n */\nfunction rowsShiftedInsideComponent(\n\tpreviousSegments: readonly RowWindowSegment[] | undefined,\n\tnextSegments: readonly RowWindowSegment[] | undefined,\n\tanchorRow: number,\n): number {\n\tif (previousSegments === undefined || nextSegments === undefined) return 0;\n\tconst nextStarts = new Map<unknown, number>();\n\tlet cursor = 0;\n\tfor (const segment of nextSegments) {\n\t\tif (!nextStarts.has(segment.id)) nextStarts.set(segment.id, cursor);\n\t\tcursor += segment.rows;\n\t}\n\tconst previousStarts: number[] = [];\n\tlet anchorIndex = -1;\n\tcursor = 0;\n\tfor (let index = 0; index < previousSegments.length; index += 1) {\n\t\tpreviousStarts.push(cursor);\n\t\tcursor += previousSegments[index]?.rows ?? 0;\n\t\tif (anchorIndex < 0 && cursor > anchorRow) anchorIndex = index;\n\t}\n\tif (anchorIndex < 0) return 0;\n\tfor (let index = anchorIndex; index >= 0; index -= 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\tfor (let index = anchorIndex + 1; index < previousSegments.length; index += 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\treturn 0;\n}\n\nfunction isRowWindowComponent(component: Component): component is RowWindowComponent {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn (\n\t\tcandidate.supportsRowWindow === true &&\n\t\ttypeof candidate.rowCount === \"function\" &&\n\t\ttypeof candidate.renderRows === \"function\"\n\t);\n}\n\n/**\n * A component that can identify its own rows without being windowed.\n *\n * `ScrollableChatTranscriptComponent` builds its transcript without a cache key\n * — deliberately, because that is what lets it reflect entries mutated in place\n * — so it is not a `RowWindowComponent` and renders every row each frame. It\n * still knows which entry produced which rows, and it is still the component\n * spanning the anchor, so the anchor needs to ask.\n */\nfunction segmentReporter(\n\tcomponent: Component,\n): { rowSegments(width: number): readonly RowWindowSegment[] } | undefined {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn typeof candidate.rowSegments === \"function\"\n\t\t? (candidate as { rowSegments(width: number): readonly RowWindowSegment[] })\n\t\t: undefined;\n}\n\nexport class ScrollableChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly viewport = new ScrollableComponentViewport();\n\tprivate readonly transcript: ChatTranscriptComponent<TEntry>;\n\n\tconstructor(entries: readonly TEntry[], renderEntry: ChatTranscriptRenderer<TEntry>) {\n\t\tthis.transcript = new ChatTranscriptComponent(entries, renderEntry);\n\t\tthis.viewport.setComponents([this.transcript]);\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.viewport.setVisibleRows(rows);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\treturn this.viewport.handleInput(data);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.viewport.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.viewport.invalidate();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.viewport.getScrollFromBottom();\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.viewport.getMaxScroll();\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.viewport.scrollToBottom();\n\t}\n}\n\nexport function mouseWheelDeltaRows(data: string): number {\n\tconst sgr = data.match(/^\\x1b\\[<(\\d+);\\d+;\\d+M$/);\n\tif (sgr) return wheelDeltaForButtonCode(Number.parseInt(sgr[1]!, 10));\n\tif (data.startsWith(\"\\x1b[M\") && data.length >= 6) {\n\t\treturn wheelDeltaForButtonCode(data.charCodeAt(3) - 32);\n\t}\n\treturn 0;\n}\n\nfunction wheelDeltaForButtonCode(code: number): number {\n\tif ((code & 64) === 0) return 0;\n\tconst direction = code & 3;\n\tif (direction === 0) return -DEFAULT_SCROLL_STEP_ROWS;\n\tif (direction === 1) return DEFAULT_SCROLL_STEP_ROWS;\n\treturn 0;\n}\n\nfunction isMouseSequence(data: string): boolean {\n\treturn /^\\x1b\\[<\\d+;\\d+;\\d+[mM]$/.test(data) || data.startsWith(\"\\x1b[M\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat-transcript.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,cAAc,EAEd,UAAU,EACV,MAAM,GACN,MAAM,wBAAwB,CAAC;AAoFhC,MAAM,UAAU,sBAAsB,CAAC,SAAoB,EAAE,SAAoB,EAAE,IAAwB;IAC1G,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAwB;IACnD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC;AAC7G,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAuB;IAClB,OAAO,CAAoB;IAC3B,WAAW,CAAiC;IACpD,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E,OAAO,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC;IAC3B,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,wBAAwB,CAAC;IACtD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,wBAAwB,CAAC;IACrD,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import {\n\ttype Component,\n\ttype Container,\n\tgetKeybindings,\n\ttype KeybindingsManager,\n\tmatchesKey,\n\tSpacer,\n} from \"@earendil-works/pi-tui\";\n\n/**\n * Roles that participate in pi's chat spacing contract.\n *\n * Assistant turns own their leading whitespace internally, and tool rows attach\n * directly under the assistant/tool-call row they belong to. User-like rows get\n * one blank line when they are not the first row in the transcript.\n */\nexport type ChatTranscriptRole =\n\t| \"assistant\"\n\t| \"thinking\"\n\t| \"tool\"\n\t| \"user\"\n\t| \"custom\"\n\t| \"notice\"\n\t| \"system\"\n\t| \"summary\";\n\nexport interface ChatTranscriptEntryLike {\n\treadonly role: ChatTranscriptRole;\n}\n\nexport type ChatTranscriptRenderer<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry) => Component;\n\nexport type ChatTranscriptCacheKey<TEntry extends ChatTranscriptEntryLike> = (entry: TEntry, index: number) => string;\n\ninterface CachedChatTranscriptBlock<TEntry extends ChatTranscriptEntryLike> {\n\treadonly entry: TEntry;\n\treadonly key: string;\n\treadonly width: number;\n\treadonly component: Component;\n\treadonly lines: readonly string[];\n}\n\ntype DisposableComponent = Component & { dispose?: () => void };\n\n/**\n * A run of rows inside a windowed component, tagged with the identity of the\n * thing that produced them.\n *\n * `id` is compared with `===` only, and is never rendered. Entry *objects* are\n * the natural id for a transcript: cache keys carry the entry's index and so\n * change for every survivor of a splice, while the entry objects themselves are\n * moved, not rebuilt.\n */\nexport interface RowWindowSegment {\n\treadonly id: unknown;\n\treadonly rows: number;\n}\n\ninterface RowWindowComponent extends Component {\n\treadonly supportsRowWindow: true;\n\trowCount(width: number): number;\n\trenderRows(width: number, startRow: number, endRow: number): string[];\n\t/**\n\t * Optional row map, letting the viewport keep a scroll anchor that sits\n\t * *inside* this component when its interior changes height.\n\t */\n\trowSegments?(width: number): readonly RowWindowSegment[];\n}\n\ninterface WindowedComponentRows {\n\treadonly kind: \"windowed\";\n\treadonly component: RowWindowComponent;\n\treadonly rowCount: number;\n\treadonly segments: readonly RowWindowSegment[] | undefined;\n}\n\ninterface StaticComponentRows {\n\treadonly kind: \"static\";\n\treadonly lines: readonly string[];\n\treadonly rowCount: number;\n\t/**\n\t * Present when a static component can still identify its own rows. A\n\t * transcript built without a cache key renders every row each frame rather\n\t * than windowing, but it knows just as well which entry produced which rows,\n\t * and the anchor needs that whenever it is the component spanning the anchor.\n\t */\n\treadonly segments?: readonly RowWindowSegment[] | undefined;\n}\n\ntype ComponentRows = WindowedComponentRows | StaticComponentRows;\n\nexport function addChatTranscriptEntry(container: Container, component: Component, role: ChatTranscriptRole): void {\n\tif (needsLeadingSpacer(role) && container.children.length > 0) {\n\t\tcontainer.addChild(new Spacer(1));\n\t}\n\tcontainer.addChild(component);\n}\n\nfunction needsLeadingSpacer(role: ChatTranscriptRole): boolean {\n\treturn role === \"user\" || role === \"custom\" || role === \"notice\" || role === \"system\" || role === \"summary\";\n}\n\n/**\n * Reusable pi chat transcript scaffold for extension surfaces.\n *\n * This intentionally mirrors InteractiveMode.addMessageToChat spacing without\n * coupling consumers to a full AgentSession. Extension UIs can bring their own\n * message model while still rendering inside the same Container/Spacer rhythm\n * as the main chat.\n */\nexport class ChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly entries: readonly TEntry[];\n\tprivate readonly renderEntry: ChatTranscriptRenderer<TEntry>;\n\treadonly supportsRowWindow: boolean;\n\n\tprivate readonly cacheKey: ChatTranscriptCacheKey<TEntry> | undefined;\n\tprivate blockCache: Array<CachedChatTranscriptBlock<TEntry> | undefined> = [];\n\t/** Per-entry heights recorded by the most recent `renderAllRows`. */\n\tprivate staticSegments: readonly RowWindowSegment[] = [];\n\t/** Width those heights were measured at; they mean nothing at another width. */\n\tprivate staticSegmentsWidth: number | undefined;\n\n\tconstructor(\n\t\tentries: readonly TEntry[],\n\t\trenderEntry: ChatTranscriptRenderer<TEntry>,\n\t\tcacheKey?: ChatTranscriptCacheKey<TEntry>,\n\t) {\n\t\tthis.entries = entries;\n\t\tthis.renderEntry = renderEntry;\n\t\tthis.cacheKey = cacheKey;\n\t\tthis.supportsRowWindow = cacheKey !== undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width);\n\t\treturn this.renderRows(width, 0, this.rowCount(width));\n\t}\n\n\trowCount(width: number): number {\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).length;\n\t\tthis.ensureBlockCache(width);\n\t\tlet count = 0;\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) count += block.lines.length;\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * One segment per cached entry block, identified by the entry object itself.\n\t */\n\trowSegments(width: number): readonly RowWindowSegment[] {\n\t\tif (!this.supportsRowWindow) {\n\t\t\t// Recorded by the last renderAllRows. The viewport measures a static\n\t\t\t// component by rendering it and only then reads its segments, so this\n\t\t\t// is populated for the frame being measured. A width mismatch means the\n\t\t\t// heights describe a different layout, and reporting them would move the\n\t\t\t// anchor by a stale delta; the caller falls back to whole-component\n\t\t\t// accounting instead.\n\t\t\treturn this.staticSegmentsWidth === width ? this.staticSegments : [];\n\t\t}\n\t\tthis.ensureBlockCache(width);\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (const block of this.blockCache) {\n\t\t\tif (block !== undefined) segments.push({ id: block.entry, rows: block.lines.length });\n\t\t}\n\t\treturn segments;\n\t}\n\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\tconst start = Math.max(0, Math.floor(startRow));\n\t\tconst end = Math.max(start, Math.floor(endRow));\n\t\tif (end <= start) return [];\n\t\tif (!this.supportsRowWindow) return this.renderAllRows(width).slice(start, end);\n\n\t\tthis.ensureBlockCache(width);\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst block = this.blockCache[index];\n\t\t\tif (block === undefined) continue;\n\t\t\tconst blockStart = cursor;\n\t\t\tconst blockEnd = blockStart + block.lines.length;\n\t\t\tif (blockEnd > start && blockStart < end) {\n\t\t\t\tconst localStart = Math.max(0, start - blockStart);\n\t\t\t\tconst localEnd = Math.min(block.lines.length, end - blockStart);\n\t\t\t\tlines.push(...block.lines.slice(localStart, localEnd));\n\t\t\t}\n\t\t\tcursor = blockEnd;\n\t\t\tif (cursor >= end) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const block of this.blockCache) disposeComponent(block?.component);\n\t\tthis.blockCache = [];\n\t}\n\n\tprivate ensureBlockCache(width: number): void {\n\t\tif (this.blockCache.length > this.entries.length) {\n\t\t\tfor (let index = this.entries.length; index < this.blockCache.length; index += 1) {\n\t\t\t\tdisposeComponent(this.blockCache[index]?.component);\n\t\t\t}\n\t\t\tthis.blockCache.length = this.entries.length;\n\t\t}\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst key = this.cacheKey?.(entry, index) ?? `${index}:${entry.role}`;\n\t\t\tconst cached = this.blockCache[index];\n\t\t\tif (cached !== undefined && cached.entry === entry && cached.key === key && cached.width === width) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdisposeComponent(cached?.component);\n\t\t\tconst component = this.renderEntry(entry);\n\t\t\tthis.blockCache[index] = {\n\t\t\t\tentry,\n\t\t\t\tkey,\n\t\t\t\twidth,\n\t\t\t\tcomponent,\n\t\t\t\tlines: this.renderEntryBlock(component, entry, index, width),\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Render every entry, recording each one's height as it goes.\n\t *\n\t * The heights are what `rowSegments` reports on this path. They are a\n\t * by-product of work this method already does, so identifying rows costs\n\t * nothing extra and, unlike a cache key, cannot miss an entry mutated in\n\t * place -- which is the behaviour a transcript without a cache key exists to\n\t * provide.\n\t */\n\tprivate renderAllRows(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst segments: RowWindowSegment[] = [];\n\t\tfor (let index = 0; index < this.entries.length; index += 1) {\n\t\t\tconst entry = this.entries[index];\n\t\t\tif (entry === undefined) continue;\n\t\t\tconst block = this.renderEntryBlock(this.renderEntry(entry), entry, index, width);\n\t\t\tsegments.push({ id: entry, rows: block.length });\n\t\t\tlines.push(...block);\n\t\t}\n\t\tthis.staticSegments = segments;\n\t\tthis.staticSegmentsWidth = width;\n\t\treturn lines;\n\t}\n\n\tprivate renderEntryBlock(component: Component, entry: TEntry, index: number, width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tif (index > 0 && needsLeadingSpacer(entry.role)) lines.push(\"\");\n\t\tlines.push(...component.render(width));\n\t\treturn lines;\n\t}\n}\n\nfunction disposeComponent(component: Component | undefined): void {\n\t(component as DisposableComponent | undefined)?.dispose?.();\n}\n\nconst DEFAULT_SCROLL_STEP_ROWS = 4;\n\n/**\n * Sticky-bottom, scrollable viewport for chat-like component stacks.\n *\n * Pi's main interactive chat gets terminal scrollback for free. Extension\n * overlays render into a fixed rectangle, so they need an explicit viewport\n * with the same sticky-bottom default plus keyboard and mouse history controls.\n */\nexport class ScrollableComponentViewport implements Component {\n\tprivate components: readonly Component[] = [];\n\tprivate visibleRows = 1;\n\tprivate scrollFromBottom = 0;\n\tprivate lastLineCount = 0;\n\tprivate lastComponentSegments: readonly (readonly RowWindowSegment[] | undefined)[] = [];\n\tprivate lastComponentRowCounts: readonly number[] = [];\n\tprivate lastWidth = 0;\n\tprivate maxScroll = 0;\n\t/**\n\t * Absolute row `scrollTo` asked for, still waiting for the render that can\n\t * honour it. See `scrollTo` for why the request has to outlive the call.\n\t */\n\tprivate pendingScrollRow: number | undefined;\n\tprivate readonly keybindings: Pick<KeybindingsManager, \"matches\"> | undefined;\n\n\tconstructor(keybindings?: unknown) {\n\t\tconst candidate = keybindings as Partial<Pick<KeybindingsManager, \"matches\">> | undefined;\n\t\tthis.keybindings =\n\t\t\ttypeof candidate?.matches === \"function\" ? (candidate as Pick<KeybindingsManager, \"matches\">) : undefined;\n\t}\n\n\tsetComponents(components: readonly Component[]): void {\n\t\tthis.components = components;\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.visibleRows = Math.max(1, Math.floor(rows));\n\t\tthis.clampScroll();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.scrollFromBottom;\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.maxScroll;\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = 0;\n\t}\n\n\tscrollToTop(): void {\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom = this.maxScroll;\n\t}\n\n\tscrollBy(deltaRows: number): void {\n\t\t// Positive deltas move toward newer content; negative deltas move up\n\t\t// into older history. Store the offset from the sticky bottom so new\n\t\t// streaming output can keep following when the offset is zero.\n\t\tthis.pendingScrollRow = undefined;\n\t\tthis.scrollFromBottom -= deltaRows;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Park the viewport with `row` as its first visible row.\n\t *\n\t * The absolute counterpart of `scrollBy`, for a caller that already knows\n\t * which row it wants on screen.\n\t *\n\t * The request is *also* recorded for the next render, and that is the half\n\t * that matters. `scrollFromBottom` is a distance from the bottom, so the\n\t * row it names moves whenever the stack grows; and the render that follows\n\t * re-derives the offset from the previous frame's layout to hold a\n\t * scrolled-up reader's content still, which would drag this request back\n\t * with it. A caller who has just measured rows the last render never saw\n\t * would otherwise be answered with the old layout's clamp and the old\n\t * frame's anchor. The next render resolves the row against the layout it\n\t * actually paints; any other scroll before then withdraws the request.\n\t */\n\tscrollTo(row: number): void {\n\t\tconst requestedRow = Number.isNaN(row) ? 0 : Math.max(0, Math.floor(row));\n\t\tthis.pendingScrollRow = requestedRow;\n\t\tconst target = Math.min(this.maxScroll, requestedRow);\n\t\tthis.scrollFromBottom = this.maxScroll - target;\n\t\tthis.clampScroll();\n\t}\n\n\t/**\n\t * Total rows the component stack occupies at `width`, on and off screen.\n\t *\n\t * This measures rather than paints: it is what lets a search read the whole\n\t * transcript instead of the window the reader happens to be parked on.\n\t */\n\trowCount(width: number): number {\n\t\treturn this.measureComponentRows(width).reduce((sum, rows) => sum + rows.rowCount, 0);\n\t}\n\n\t/**\n\t * Rows `startRow` (inclusive) through `endRow` (exclusive) of the whole\n\t * stack, independent of the current scroll offset. Deliberately not paired\n\t * with `supportsRowWindow`: a viewport is a scroll container rather than a\n\t * windowed component, and an enclosing viewport must keep measuring it by\n\t * its visible height.\n\t */\n\trenderRows(width: number, startRow: number, endRow: number): string[] {\n\t\treturn this.renderVisibleRows(this.measureComponentRows(width), width, startRow, endRow);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\tconst wheelDeltaRows = mouseWheelDeltaRows(data);\n\t\tif (wheelDeltaRows !== 0) {\n\t\t\tthis.scrollBy(wheelDeltaRows);\n\t\t\treturn true;\n\t\t}\n\t\tif (isMouseSequence(data)) return true;\n\t\tif (matchesKey(data, \"pageUp\")) {\n\t\t\tthis.scrollBy(-this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, \"pageDown\")) {\n\t\t\tthis.scrollBy(this.pageSize());\n\t\t\treturn true;\n\t\t}\n\t\tif ((this.keybindings ?? getKeybindings()).matches(data, \"tui.altScreen.top\")) {\n\t\t\tthis.scrollToTop();\n\t\t\treturn true;\n\t\t}\n\t\tif ((this.keybindings ?? getKeybindings()).matches(data, \"tui.altScreen.bottom\")) {\n\t\t\tthis.scrollToBottom();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst componentRows = this.measureComponentRows(width);\n\t\tconst rowCounts = componentRows.map((rows) => rows.rowCount);\n\t\tconst lineCount = rowCounts.reduce((sum, count) => sum + count, 0);\n\t\tconst maxScroll = Math.max(0, lineCount - this.visibleRows);\n\t\t// The offset is a distance from the bottom, so the first visible row is\n\t\t// `maxScroll - scrollFromBottom`. Rows appearing or disappearing move the\n\t\t// content a scrolled-up viewer is reading unless the offset moves with\n\t\t// them -- a live subagent widget does exactly that every time it gains or\n\t\t// drops its current-tool row.\n\t\t//\n\t\t// Which way the offset must move depends on where the rows changed, so a\n\t\t// plain `scrollFromBottom += lineCount - lastLineCount` is wrong half the\n\t\t// time. Rows changing *below* the anchor need the offset adjusted by that\n\t\t// delta; rows changing *above* it need the offset left alone, because the\n\t\t// bottom-relative distance to the anchored content did not change. Anchor\n\t\t// on the row the viewer is actually reading and re-derive the offset from\n\t\t// it. A viewer already at the bottom keeps scrollFromBottom === 0 and is\n\t\t// skipped entirely, so sticky-bottom following is untouched.\n\t\t//\n\t\t// Per-component row counts alone cannot place a change that happens\n\t\t// inside the component holding the anchor -- and in the chat host the\n\t\t// whole transcript is one component, so that is the normal case. A\n\t\t// component that can hand over a row map turns the \"where\" question into\n\t\t// \"where did the anchored segment go\". Both kinds may supply one: a\n\t\t// transcript built without a cache key is not windowed, but it is still\n\t\t// one component spanning the anchor and still knows its own rows.\n\t\tconst segments = componentRows.map((rows) => rows.segments);\n\t\tconst pendingScrollRow = this.pendingScrollRow;\n\t\tthis.pendingScrollRow = undefined;\n\t\tif (pendingScrollRow !== undefined) {\n\t\t\t// An absolute request outranks the anchor: the caller measured this\n\t\t\t// frame's rows and named one of them. Re-deriving the anchor here\n\t\t\t// would answer with the previous frame's layout instead.\n\t\t\tthis.scrollFromBottom = maxScroll - Math.min(maxScroll, pendingScrollRow);\n\t\t} else if (this.scrollFromBottom > 0 && this.lastWidth === width) {\n\t\t\tconst previousMaxScroll = Math.max(0, this.lastLineCount - this.visibleRows);\n\t\t\tconst anchorRow = Math.max(0, previousMaxScroll - this.scrollFromBottom);\n\t\t\tconst shift = rowsShiftedAboveAnchor(\n\t\t\t\t{ rowCounts: this.lastComponentRowCounts, segments: this.lastComponentSegments },\n\t\t\t\t{ rowCounts, segments },\n\t\t\t\tanchorRow,\n\t\t\t);\n\t\t\tconst nextAnchorRow = Math.max(0, Math.min(maxScroll, anchorRow + shift));\n\t\t\tthis.scrollFromBottom = maxScroll - nextAnchorRow;\n\t\t}\n\t\tthis.lastLineCount = lineCount;\n\t\tthis.lastComponentRowCounts = rowCounts;\n\t\tthis.lastComponentSegments = segments;\n\t\tthis.lastWidth = width;\n\t\tthis.maxScroll = maxScroll;\n\t\tthis.clampScroll();\n\n\t\tconst start = Math.max(0, maxScroll - this.scrollFromBottom);\n\t\tconst visible = this.renderVisibleRows(componentRows, width, start, start + this.visibleRows);\n\t\twhile (visible.length < this.visibleRows) visible.push(\" \".repeat(width));\n\t\treturn visible;\n\t}\n\n\tinvalidate(): void {\n\t\tfor (const component of this.components) component.invalidate();\n\t}\n\n\tprivate measureComponentRows(width: number): ComponentRows[] {\n\t\treturn this.components.map((component) => {\n\t\t\tif (isRowWindowComponent(component)) {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"windowed\",\n\t\t\t\t\tcomponent,\n\t\t\t\t\trowCount: component.rowCount(width),\n\t\t\t\t\tsegments: component.rowSegments?.(width),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst lines = component.render(width);\n\t\t\t// Read segments only after rendering: a static transcript records its\n\t\t\t// per-entry heights as a by-product of that render, so asking first\n\t\t\t// would return the previous frame's layout.\n\t\t\tconst segments = segmentReporter(component)?.rowSegments(width);\n\t\t\treturn {\n\t\t\t\tkind: \"static\",\n\t\t\t\tlines,\n\t\t\t\trowCount: lines.length,\n\t\t\t\tsegments: segments !== undefined && segments.length > 0 ? segments : undefined,\n\t\t\t};\n\t\t});\n\t}\n\n\tprivate renderVisibleRows(\n\t\tcomponentRows: readonly ComponentRows[],\n\t\twidth: number,\n\t\tstartRow: number,\n\t\tendRow: number,\n\t): string[] {\n\t\tconst lines: string[] = [];\n\t\tlet cursor = 0;\n\t\tfor (const rows of componentRows) {\n\t\t\tconst componentStart = cursor;\n\t\t\tconst componentEnd = componentStart + rows.rowCount;\n\t\t\tif (componentEnd > startRow && componentStart < endRow) {\n\t\t\t\tconst localStart = Math.max(0, startRow - componentStart);\n\t\t\t\tconst localEnd = Math.min(rows.rowCount, endRow - componentStart);\n\t\t\t\tif (rows.kind === \"windowed\") {\n\t\t\t\t\tlines.push(...rows.component.renderRows(width, localStart, localEnd));\n\t\t\t\t} else {\n\t\t\t\t\tlines.push(...rows.lines.slice(localStart, localEnd));\n\t\t\t\t}\n\t\t\t}\n\t\t\tcursor = componentEnd;\n\t\t\tif (cursor >= endRow) break;\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate pageSize(): number {\n\t\treturn Math.max(4, this.visibleRows - 2);\n\t}\n\n\tprivate clampScroll(): void {\n\t\tthis.scrollFromBottom = Math.max(0, Math.min(this.maxScroll, this.scrollFromBottom));\n\t}\n}\n\n/** One rendered frame's row layout, as the viewport measured it. */\ninterface ComponentRowLayout {\n\treadonly rowCounts: readonly number[];\n\treadonly segments: readonly (readonly RowWindowSegment[] | undefined)[];\n}\n\n/**\n * Rows gained or lost above `anchorRow`, measured in the previous frame's rows.\n *\n * The anchored row moves down by exactly this many rows, so adding it to the\n * anchor keeps the same content under the viewer.\n *\n * Components entirely above the anchor contribute their whole height delta.\n * The component that *spans* the anchor contributes only what changed above the\n * anchored row, which needs its row map (`rowSegments`); without one it\n * contributes nothing, which is the old behaviour and is right for the\n * append-and-mutate-at-the-tail widgets that have no interior.\n *\n * Row counts are compared positionally over the shared prefix, which is what the\n * chat stacks this viewport drives actually do — they append and mutate at the\n * tail. A component inserted or removed *ahead* of the anchor would be\n * misattributed; the anchor then lands one component off rather than drifting on\n * every frame, and the next user scroll re-establishes it.\n */\nfunction rowsShiftedAboveAnchor(previous: ComponentRowLayout, next: ComponentRowLayout, anchorRow: number): number {\n\tlet cursor = 0;\n\tlet shift = 0;\n\tconst shared = Math.min(previous.rowCounts.length, next.rowCounts.length);\n\tfor (let index = 0; index < shared; index += 1) {\n\t\tconst previousRows = previous.rowCounts[index] ?? 0;\n\t\tconst componentEnd = cursor + previousRows;\n\t\tif (componentEnd > anchorRow) {\n\t\t\treturn shift + rowsShiftedInsideComponent(previous.segments[index], next.segments[index], anchorRow - cursor);\n\t\t}\n\t\tshift += (next.rowCounts[index] ?? 0) - previousRows;\n\t\tcursor = componentEnd;\n\t}\n\treturn shift;\n}\n\n/**\n * Rows gained or lost above `anchorRow` *within* one windowed component.\n *\n * Rather than diffing heights, this finds the segment the viewer is parked on\n * and reports how far that same segment moved. Segments are matched by `===` on\n * their id, so a transcript splice that renumbers every cache key still lines\n * up: the entry objects survive it. If the anchored segment itself is gone\n * (the viewer was reading rows that were compacted away) the nearest surviving\n * neighbour above it — then below it — stands in, so the viewer lands on the\n * closest content that still exists instead of drifting by the whole delta.\n */\nfunction rowsShiftedInsideComponent(\n\tpreviousSegments: readonly RowWindowSegment[] | undefined,\n\tnextSegments: readonly RowWindowSegment[] | undefined,\n\tanchorRow: number,\n): number {\n\tif (previousSegments === undefined || nextSegments === undefined) return 0;\n\tconst nextStarts = new Map<unknown, number>();\n\tlet cursor = 0;\n\tfor (const segment of nextSegments) {\n\t\tif (!nextStarts.has(segment.id)) nextStarts.set(segment.id, cursor);\n\t\tcursor += segment.rows;\n\t}\n\tconst previousStarts: number[] = [];\n\tlet anchorIndex = -1;\n\tcursor = 0;\n\tfor (let index = 0; index < previousSegments.length; index += 1) {\n\t\tpreviousStarts.push(cursor);\n\t\tcursor += previousSegments[index]?.rows ?? 0;\n\t\tif (anchorIndex < 0 && cursor > anchorRow) anchorIndex = index;\n\t}\n\tif (anchorIndex < 0) return 0;\n\tfor (let index = anchorIndex; index >= 0; index -= 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\tfor (let index = anchorIndex + 1; index < previousSegments.length; index += 1) {\n\t\tconst nextStart = nextStarts.get(previousSegments[index]?.id);\n\t\tif (nextStart !== undefined) return nextStart - (previousStarts[index] ?? 0);\n\t}\n\treturn 0;\n}\n\nfunction isRowWindowComponent(component: Component): component is RowWindowComponent {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn (\n\t\tcandidate.supportsRowWindow === true &&\n\t\ttypeof candidate.rowCount === \"function\" &&\n\t\ttypeof candidate.renderRows === \"function\"\n\t);\n}\n\n/**\n * A component that can identify its own rows without being windowed.\n *\n * `ScrollableChatTranscriptComponent` builds its transcript without a cache key\n * — deliberately, because that is what lets it reflect entries mutated in place\n * — so it is not a `RowWindowComponent` and renders every row each frame. It\n * still knows which entry produced which rows, and it is still the component\n * spanning the anchor, so the anchor needs to ask.\n */\nfunction segmentReporter(\n\tcomponent: Component,\n): { rowSegments(width: number): readonly RowWindowSegment[] } | undefined {\n\tconst candidate = component as Partial<RowWindowComponent>;\n\treturn typeof candidate.rowSegments === \"function\"\n\t\t? (candidate as { rowSegments(width: number): readonly RowWindowSegment[] })\n\t\t: undefined;\n}\n\nexport class ScrollableChatTranscriptComponent<TEntry extends ChatTranscriptEntryLike> implements Component {\n\tprivate readonly viewport = new ScrollableComponentViewport();\n\tprivate readonly transcript: ChatTranscriptComponent<TEntry>;\n\n\tconstructor(entries: readonly TEntry[], renderEntry: ChatTranscriptRenderer<TEntry>) {\n\t\tthis.transcript = new ChatTranscriptComponent(entries, renderEntry);\n\t\tthis.viewport.setComponents([this.transcript]);\n\t}\n\n\tsetVisibleRows(rows: number): void {\n\t\tthis.viewport.setVisibleRows(rows);\n\t}\n\n\thandleInput(data: string): boolean {\n\t\treturn this.viewport.handleInput(data);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.viewport.render(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.viewport.invalidate();\n\t}\n\n\tgetScrollFromBottom(): number {\n\t\treturn this.viewport.getScrollFromBottom();\n\t}\n\n\tgetMaxScroll(): number {\n\t\treturn this.viewport.getMaxScroll();\n\t}\n\n\tscrollToBottom(): void {\n\t\tthis.viewport.scrollToBottom();\n\t}\n}\n\nexport function mouseWheelDeltaRows(data: string): number {\n\tconst sgr = data.match(/^\\x1b\\[<(\\d+);\\d+;\\d+M$/);\n\tif (sgr) return wheelDeltaForButtonCode(Number.parseInt(sgr[1]!, 10));\n\tif (data.startsWith(\"\\x1b[M\") && data.length >= 6) {\n\t\treturn wheelDeltaForButtonCode(data.charCodeAt(3) - 32);\n\t}\n\treturn 0;\n}\n\nfunction wheelDeltaForButtonCode(code: number): number {\n\tif ((code & 64) === 0) return 0;\n\tconst direction = code & 3;\n\tif (direction === 0) return -DEFAULT_SCROLL_STEP_ROWS;\n\tif (direction === 1) return DEFAULT_SCROLL_STEP_ROWS;\n\treturn 0;\n}\n\nfunction isMouseSequence(data: string): boolean {\n\treturn /^\\x1b\\[<\\d+;\\d+;\\d+[mM]$/.test(data) || data.startsWith(\"\\x1b[M\");\n}\n"]}
|
|
@@ -5,6 +5,8 @@ interface BoundaryView {
|
|
|
5
5
|
text: string;
|
|
6
6
|
stats: VerbatimCompactionStats;
|
|
7
7
|
rung: VerbatimCompactionDetails["rung"];
|
|
8
|
+
backend?: VerbatimCompactionDetails["backend"];
|
|
9
|
+
model?: string;
|
|
8
10
|
/** Authoritative whole-context count, preferred for "Compacted from N tokens". */
|
|
9
11
|
tokensBefore?: number;
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-boundary-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/compaction-boundary-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwC,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,EACX,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"compaction-boundary-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/compaction-boundary-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwC,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,EACX,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,aAAa,EAAyD,MAAM,2BAA2B,CAAC;AAItH,UAAU,YAAY;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,uBAAuB,CAAC;IAC/B,IAAI,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,gFAAgF;AAChF,qBAAa,kCAAmC,SAAQ,GAAG;IAC1D,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAe;IAEpC,YAAY,MAAM,EAAE,wBAAwB,GAAG,YAAY,EAe1D;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IACQ,UAAU,IAAI,IAAI,CAG1B;IAED,OAAO,CAAC,aAAa;CA2DrB;AAED,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,OAAO,GACf,kCAAkC,CAmBpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Box, Container, MouseRegion, Spacer, Text } from "@earendil-works/pi-tui";
|
|
2
|
-
import { VERBATIM_COMPACTION_PREFIX } from "../../../core/messages.js";
|
|
2
|
+
import { SUMMARY_COMPACTION_PREFIX, VERBATIM_COMPACTION_PREFIX } from "../../../core/messages.js";
|
|
3
3
|
import { theme } from "../theme/theme.js";
|
|
4
4
|
import { parenthesizedKeyHint } from "./keybinding-hints.js";
|
|
5
5
|
/** Renders the durable verbatim compaction boundary without markdown reflow. */
|
|
@@ -14,6 +14,8 @@ export class CompactionBoundaryMessageComponent extends Box {
|
|
|
14
14
|
stats: result.stats,
|
|
15
15
|
rung: result.rung,
|
|
16
16
|
tokensBefore: result.tokensBefore,
|
|
17
|
+
backend: result.backend,
|
|
18
|
+
model: result.model,
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
21
|
else {
|
|
@@ -34,8 +36,15 @@ export class CompactionBoundaryMessageComponent extends Box {
|
|
|
34
36
|
const content = new Container();
|
|
35
37
|
const tokenStr = (this.view.tokensBefore ?? this.view.stats.tokensBefore).toLocaleString();
|
|
36
38
|
// The fresh rung destroyed the compactable conversation; say so plainly.
|
|
37
|
-
const label = theme.fg("customMessageLabel", theme.bold(this.view.rung === "fresh"
|
|
39
|
+
const label = theme.fg("customMessageLabel", theme.bold(this.view.rung === "fresh"
|
|
40
|
+
? "✻ Context cleared (compaction degraded)"
|
|
41
|
+
: this.view.backend === "summary"
|
|
42
|
+
? "✻ Context compacted · summary (pi fallback)"
|
|
43
|
+
: "✻ Context compacted"));
|
|
38
44
|
content.addChild(new Text(label, 0, 0));
|
|
45
|
+
if (this.view.backend && this.view.model) {
|
|
46
|
+
content.addChild(new Text(theme.fg("dim", `${this.view.backend === "summary" ? "summary (pi fallback)" : this.view.backend} · ${this.view.model}`), 0, 0));
|
|
47
|
+
}
|
|
39
48
|
content.addChild(new Spacer(1));
|
|
40
49
|
if (this.expanded) {
|
|
41
50
|
content.addChild(new Text(theme.bold(theme.fg("customMessageText", `Compacted from ${tokenStr} tokens`)), 0, 0));
|
|
@@ -66,11 +75,14 @@ export function compactionBoundaryFromMessage(message, expanded) {
|
|
|
66
75
|
.map((block) => block.text)
|
|
67
76
|
.join("\n")
|
|
68
77
|
: message.content;
|
|
78
|
+
const prefix = details.backend === "summary" ? SUMMARY_COMPACTION_PREFIX : VERBATIM_COMPACTION_PREFIX;
|
|
69
79
|
const component = new CompactionBoundaryMessageComponent({
|
|
70
|
-
text: content.startsWith(
|
|
80
|
+
text: content.startsWith(prefix) ? content.slice(prefix.length) : content,
|
|
71
81
|
stats: details.stats,
|
|
72
82
|
rung: details.rung,
|
|
73
83
|
tokensBefore: details.tokensBefore ?? details.stats.tokensBefore,
|
|
84
|
+
backend: details.backend,
|
|
85
|
+
model: details.model,
|
|
74
86
|
});
|
|
75
87
|
component.setExpanded(expanded);
|
|
76
88
|
return component;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-boundary-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/compaction-boundary-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAMnF,OAAO,EAAsB,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"compaction-boundary-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/compaction-boundary-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAMnF,OAAO,EAAsB,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACtH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAY7D,gFAAgF;AAChF,MAAM,OAAO,kCAAmC,SAAQ,GAAG;IAClD,QAAQ,GAAG,KAAK,CAAC;IACR,IAAI,CAAe;IAEpC,YA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,CAAC;aAC1B,IAAI,CAAC,IAAI,CAAC;QACb,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACnB,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,0BAA0B,CAAC;IACtG,MAAM,SAAS,GAAG,IAAI,kCAAkC,CAAC;QACxD,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO;QACzE,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY;QAChE,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,OAAO,CAAC,KAAK;KACpB,CAAC,CAAC;IACH,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { Box, Container, MouseRegion, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type {\n\tVerbatimCompactionDetails,\n\tVerbatimCompactionResult,\n\tVerbatimCompactionStats,\n} from \"../../../core/compaction/index.ts\";\nimport { type CustomMessage, SUMMARY_COMPACTION_PREFIX, VERBATIM_COMPACTION_PREFIX } from \"../../../core/messages.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { parenthesizedKeyHint } from \"./keybinding-hints.js\";\n\ninterface BoundaryView {\n\ttext: string;\n\tstats: VerbatimCompactionStats;\n\trung: VerbatimCompactionDetails[\"rung\"];\n\tbackend?: VerbatimCompactionDetails[\"backend\"];\n\tmodel?: string;\n\t/** Authoritative whole-context count, preferred for \"Compacted from N tokens\". */\n\ttokensBefore?: number;\n}\n\n/** Renders the durable verbatim compaction boundary without markdown reflow. */\nexport class CompactionBoundaryMessageComponent extends Box {\n\tprivate expanded = false;\n\tprivate readonly view: BoundaryView;\n\n\tconstructor(result: VerbatimCompactionResult | BoundaryView) {\n\t\tsuper(1, 1, (text) => theme.bg(\"customMessageBg\", text));\n\t\tif (\"compactedText\" in result) {\n\t\t\tthis.view = {\n\t\t\t\ttext: result.compactedText,\n\t\t\t\tstats: result.stats,\n\t\t\t\trung: result.rung,\n\t\t\t\ttokensBefore: result.tokensBefore,\n\t\t\t\tbackend: result.backend,\n\t\t\t\tmodel: result.model,\n\t\t\t};\n\t\t} else {\n\t\t\tthis.view = result;\n\t\t}\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.clear();\n\t\tconst content = new Container();\n\t\tconst tokenStr = (this.view.tokensBefore ?? this.view.stats.tokensBefore).toLocaleString();\n\t\t// The fresh rung destroyed the compactable conversation; say so plainly.\n\t\tconst label = theme.fg(\n\t\t\t\"customMessageLabel\",\n\t\t\ttheme.bold(\n\t\t\t\tthis.view.rung === \"fresh\"\n\t\t\t\t\t? \"✻ Context cleared (compaction degraded)\"\n\t\t\t\t\t: this.view.backend === \"summary\"\n\t\t\t\t\t\t? \"✻ Context compacted · summary (pi fallback)\"\n\t\t\t\t\t\t: \"✻ Context compacted\",\n\t\t\t),\n\t\t);\n\t\tcontent.addChild(new Text(label, 0, 0));\n\t\tif (this.view.backend && this.view.model) {\n\t\t\tcontent.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"dim\",\n\t\t\t\t\t\t`${this.view.backend === \"summary\" ? \"summary (pi fallback)\" : this.view.backend} · ${this.view.model}`,\n\t\t\t\t\t),\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tcontent.addChild(new Spacer(1));\n\t\tif (this.expanded) {\n\t\t\tcontent.addChild(\n\t\t\t\tnew Text(theme.bold(theme.fg(\"customMessageText\", `Compacted from ${tokenStr} tokens`)), 0, 0),\n\t\t\t);\n\t\t\tcontent.addChild(new Spacer(1));\n\t\t\tconst rendered = this.view.text\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.map((line) =>\n\t\t\t\t\t/^\\(filtered \\d+ lines\\)$/.test(line) ? theme.fg(\"dim\", line) : theme.fg(\"customMessageText\", line),\n\t\t\t\t)\n\t\t\t\t.join(\"\\n\");\n\t\t\tcontent.addChild(new Text(rendered, 0, 0));\n\t\t} else {\n\t\t\tconst hint = parenthesizedKeyHint(\"app.tools.expand\", \"to expand\");\n\t\t\tcontent.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\"customMessageText\", `Compacted from ${tokenStr} tokens`) + (hint ? ` ${hint}` : \"\"),\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tthis.addChild(\n\t\t\tnew MouseRegion(content, (event) => {\n\t\t\t\tif (event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\t\t\tthis.setExpanded(!this.expanded);\n\t\t\t\treturn { handled: true };\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function compactionBoundaryFromMessage(\n\tmessage: CustomMessage,\n\texpanded: boolean,\n): CompactionBoundaryMessageComponent {\n\tconst details = message.details as VerbatimCompactionDetails;\n\tconst content = Array.isArray(message.content)\n\t\t? message.content\n\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t.map((block) => block.text)\n\t\t\t\t.join(\"\\n\")\n\t\t: message.content;\n\tconst prefix = details.backend === \"summary\" ? SUMMARY_COMPACTION_PREFIX : VERBATIM_COMPACTION_PREFIX;\n\tconst component = new CompactionBoundaryMessageComponent({\n\t\ttext: content.startsWith(prefix) ? content.slice(prefix.length) : content,\n\t\tstats: details.stats,\n\t\trung: details.rung,\n\t\ttokensBefore: details.tokensBefore ?? details.stats.tokensBefore,\n\t\tbackend: details.backend,\n\t\tmodel: details.model,\n\t});\n\tcomponent.setExpanded(expanded);\n\treturn component;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-selector-items.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector-items.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAqJtF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"settings-selector-items.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/settings-selector-items.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAqJtF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,GAAG,WAAW,EAAE,CAiUtG"}
|
|
@@ -309,6 +309,49 @@ export function buildSettingsItems(config, callbacks) {
|
|
|
309
309
|
}, () => done(), undefined, true);
|
|
310
310
|
},
|
|
311
311
|
},
|
|
312
|
+
{
|
|
313
|
+
id: "compaction-model",
|
|
314
|
+
label: "Compaction model",
|
|
315
|
+
description: `Saves to ${config.compactionModelScope ?? "global"} settings; changes compaction, not the chat model`,
|
|
316
|
+
currentValue: config.compactionModel && config.compactionModel !== "auto"
|
|
317
|
+
? config.compactionModel
|
|
318
|
+
: "Auto (current model)",
|
|
319
|
+
submenu: (_currentValue, done) => {
|
|
320
|
+
const configured = config.compactionModel === "auto" ? "" : (config.compactionModel ?? "");
|
|
321
|
+
const permitsModel = (id) => config.compactionModelScope !== "project" || !id.startsWith("morph/");
|
|
322
|
+
const current = permitsModel(configured) ? configured : "";
|
|
323
|
+
const models = [
|
|
324
|
+
...(config.availableDefaultModels ?? []).filter((model) => isModelType(model, "chat")),
|
|
325
|
+
...(config.availableClassifierModels ?? []),
|
|
326
|
+
...(config.availableCompactorModels ?? []),
|
|
327
|
+
].filter((model) => permitsModel(`${model.provider}/${model.id}`));
|
|
328
|
+
const options = [
|
|
329
|
+
{ value: "", label: "Auto (current model)", description: "Use the current chat model" },
|
|
330
|
+
...models.map((model) => ({
|
|
331
|
+
value: `${model.provider}/${model.id}`,
|
|
332
|
+
label: `${model.provider}/${model.id}`,
|
|
333
|
+
description: model.provider === "morph" && !config.morphAuthenticated
|
|
334
|
+
? `${model.name} · requires /login morph`
|
|
335
|
+
: model.name,
|
|
336
|
+
})),
|
|
337
|
+
];
|
|
338
|
+
if (current && !options.some((option) => option.value === current)) {
|
|
339
|
+
options.push({
|
|
340
|
+
value: current,
|
|
341
|
+
label: current,
|
|
342
|
+
description: "Configured model is not currently available",
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return new SelectSubmenu("Compaction model", `Saves to ${config.compactionModelScope ?? "global"} settings. Selected providers receive the compactable conversation.`, options.map((option) => ({
|
|
346
|
+
...option,
|
|
347
|
+
label: `${option.value === current ? "✓ " : " "}${option.label}`,
|
|
348
|
+
})), current, (value) => {
|
|
349
|
+
callbacks.onCompactionModelChange?.(value);
|
|
350
|
+
config.compactionModel = value;
|
|
351
|
+
done(value || "Auto (current model)");
|
|
352
|
+
}, () => done(), undefined, true);
|
|
353
|
+
},
|
|
354
|
+
},
|
|
312
355
|
{
|
|
313
356
|
id: "model-thinking",
|
|
314
357
|
label: "Default thinking level per model",
|