@timurproko/a1 0.1.8-dev.49ff83a → 0.1.8-dev.508
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/README.md +168 -65
- package/bin/cli.js +33 -11
- package/bin/guardian.js +16 -6
- package/bin/module-identity.js +76 -69
- package/bin/module-resolver.js +138 -0
- package/bin/pinned-pi-public.d.ts +3 -0
- package/bin/pinned-pi-public.js +93 -0
- package/bin/release-cleanup.js +8 -0
- package/bin/supervisor.js +2 -2
- package/bin/ui.js +67 -22
- package/bin/update-recovery.js +343 -0
- package/bin/warmup.js +28 -0
- package/dist/app/session-shell/clipboard-diagnostics.d.ts +16 -0
- package/dist/app/session-shell/clipboard-diagnostics.js +65 -0
- package/dist/app/session-shell/clipboard-image.d.ts +11 -0
- package/dist/app/session-shell/clipboard-image.js +38 -0
- package/dist/app/session-shell/editor-hyperlink-budget.d.ts +9 -0
- package/dist/app/session-shell/editor-hyperlink-budget.js +23 -0
- package/dist/app/session-shell/helper-pool.d.ts +33 -0
- package/dist/app/session-shell/helper-pool.js +98 -0
- package/dist/app/session-shell/image-preparation-client.d.ts +20 -0
- package/dist/app/session-shell/image-preparation-client.js +145 -0
- package/dist/app/session-shell/image-preparation.d.ts +18 -0
- package/dist/app/session-shell/image-preparation.js +126 -0
- package/dist/app/session-shell/image-source.d.ts +13 -0
- package/dist/app/session-shell/image-source.js +171 -0
- package/dist/app/session-shell/image-worker.d.ts +17 -0
- package/dist/app/session-shell/image-worker.js +23 -0
- package/dist/app/session-shell/index.d.ts +7 -0
- package/dist/app/session-shell/index.js +4 -0
- package/dist/app/session-shell/paste-executor.d.ts +18 -0
- package/dist/app/session-shell/paste-executor.js +253 -0
- package/dist/app/session-shell/paste-helper.js +173 -0
- package/dist/app/session-shell/paste-preparation-client.d.ts +31 -0
- package/dist/app/session-shell/paste-preparation-client.js +170 -0
- package/dist/app/session-shell/paste-protocol.d.ts +78 -0
- package/dist/app/session-shell/paste-protocol.js +18 -0
- package/dist/app/session-shell/paste-text-preparation.d.ts +6 -0
- package/dist/app/session-shell/paste-text-preparation.js +134 -0
- package/dist/app/session-shell/paste-text-worker.js +12 -0
- package/dist/app/session-shell/paste-types.d.ts +17 -0
- package/dist/app/session-shell/path-chip-presentation.d.ts +7 -0
- package/dist/app/session-shell/path-chip-presentation.js +24 -0
- package/dist/app/session-shell/prompt-chips.d.ts +76 -0
- package/dist/app/session-shell/prompt-chips.js +507 -0
- package/dist/app/session-shell/prompt-history-controller.d.ts +36 -0
- package/dist/app/session-shell/prompt-history-controller.js +170 -0
- package/dist/app/session-shell/prompt-suggestion-controller.d.ts +35 -0
- package/dist/app/session-shell/prompt-suggestion-controller.js +207 -0
- package/dist/app/session-shell/quit-outro-effects.d.ts +29 -0
- package/dist/app/session-shell/quit-outro-effects.js +242 -0
- package/dist/app/session-shell/quit-outro.d.ts +38 -0
- package/dist/app/session-shell/quit-outro.js +98 -0
- package/dist/app/session-shell/response-copy-coordinator.d.ts +27 -0
- package/dist/app/session-shell/response-copy-coordinator.js +187 -0
- package/dist/app/session-shell/response-copy-helper.js +122 -0
- package/dist/app/session-shell/response-copy-protocol.d.ts +56 -0
- package/dist/app/session-shell/response-copy-protocol.js +5 -0
- package/dist/app/session-shell/response-copy-transport.d.ts +39 -0
- package/dist/app/session-shell/response-copy-transport.js +217 -0
- package/dist/app/session-shell/session-shell-root.d.ts +265 -0
- package/dist/app/session-shell/session-shell-root.js +1366 -0
- package/dist/app/session-shell/session-shell.d.ts +59 -0
- package/dist/app/session-shell/session-shell.js +1917 -0
- package/dist/app/session-shell/session-viewport-controller.d.ts +61 -0
- package/dist/app/session-shell/session-viewport-controller.js +597 -0
- package/dist/app/session-shell/stream-presentation-coalescer.d.ts +29 -0
- package/dist/app/session-shell/stream-presentation-coalescer.js +79 -0
- package/dist/app/session-shell/system-clipboard.d.ts +20 -0
- package/dist/app/session-shell/system-clipboard.js +159 -0
- package/dist/app/session-shell/text-paste.d.ts +5 -0
- package/dist/app/session-shell/text-paste.js +16 -0
- package/dist/cli/capabilities.d.ts +6 -0
- package/dist/cli/capabilities.js +7 -0
- package/dist/cli/dispatch.d.ts +46 -0
- package/dist/cli/dispatch.js +261 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.js +4 -0
- package/dist/cli/package-messages.d.ts +26 -0
- package/dist/cli/package-messages.js +71 -0
- package/dist/cli/packages.d.ts +32 -0
- package/dist/cli/packages.js +81 -0
- package/dist/cli/version-stats.d.ts +22 -0
- package/dist/cli/version-stats.js +112 -0
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +2 -0
- package/dist/composition/owned-ui.d.ts +37 -0
- package/dist/composition/owned-ui.js +136 -0
- package/dist/composition/settings-route-host.d.ts +7 -0
- package/dist/composition/settings-route-host.js +110 -0
- package/dist/contracts/agent-engine/capability-ports.d.ts +95 -0
- package/dist/contracts/agent-engine/domain-validation.js +107 -0
- package/dist/contracts/agent-engine/domain.d.ts +138 -0
- package/dist/contracts/agent-engine/index.d.ts +11 -0
- package/dist/contracts/agent-engine/index.js +6 -0
- package/dist/contracts/agent-engine/package-ports.d.ts +60 -0
- package/dist/contracts/agent-engine/ports.js +1 -0
- package/dist/contracts/owned-ui/extension-ui.d.ts +310 -0
- package/dist/contracts/owned-ui/image-attachments.d.ts +36 -0
- package/dist/contracts/owned-ui/image-attachments.js +67 -0
- package/dist/contracts/owned-ui/index.d.ts +12 -0
- package/dist/contracts/owned-ui/index.js +8 -0
- package/dist/contracts/owned-ui/model.d.ts +378 -0
- package/dist/contracts/owned-ui/prompt-history.d.ts +55 -0
- package/dist/contracts/owned-ui/prompt-history.js +23 -0
- package/dist/contracts/owned-ui/prompt-suggestions.d.ts +3 -0
- package/dist/contracts/owned-ui/prompt-suggestions.js +44 -0
- package/dist/contracts/owned-ui/suggestion-diagnostics.d.ts +22 -0
- package/dist/contracts/owned-ui/suggestion-diagnostics.js +9 -0
- package/dist/contracts/owned-ui/transcript-lifecycle.d.ts +5 -0
- package/dist/contracts/owned-ui/transcript-lifecycle.js +33 -0
- package/dist/contracts/owned-ui/validation.d.ts +15 -0
- package/dist/contracts/owned-ui/validation.js +523 -0
- package/dist/contracts/presentation/index.d.ts +104 -0
- package/dist/features/launch/development-launch.js +36 -0
- package/dist/features/launch/index.d.ts +12 -0
- package/dist/features/launch/index.js +6 -0
- package/dist/features/launch/intent.d.ts +12 -0
- package/dist/features/launch/intent.js +8 -0
- package/dist/features/launch/prepare-launch.d.ts +11 -0
- package/dist/features/launch/prepare-launch.js +14 -0
- package/dist/features/launch/profile-paths.d.ts +16 -0
- package/dist/features/launch/profile-paths.js +36 -0
- package/dist/features/launch/runtime-selection.d.ts +16 -0
- package/dist/features/launch/runtime-selection.js +13 -0
- package/dist/features/owned-ui/index.d.ts +6 -0
- package/dist/features/owned-ui/index.js +4 -0
- package/dist/features/owned-ui/project-trust-prompt.d.ts +25 -0
- package/dist/features/owned-ui/project-trust-prompt.js +149 -0
- package/dist/features/owned-ui/run.d.ts +17 -0
- package/dist/features/owned-ui/run.js +64 -0
- package/dist/features/owned-ui/session-fork-prompt.d.ts +8 -0
- package/dist/features/owned-ui/session-fork-prompt.js +34 -0
- package/dist/features/owned-ui/settings-app.d.ts +21 -0
- package/dist/features/owned-ui/settings-app.js +807 -0
- package/dist/features/owned-ui/settings-route.d.ts +2 -0
- package/dist/features/owned-ui/settings-route.js +2 -0
- package/dist/features/prompt-history/image-sidecar.d.ts +32 -0
- package/dist/features/prompt-history/image-sidecar.js +130 -0
- package/dist/features/prompt-history/index.d.ts +4 -0
- package/dist/features/prompt-history/index.js +3 -0
- package/dist/features/prompt-history/paths.d.ts +5 -0
- package/dist/features/prompt-history/paths.js +17 -0
- package/dist/features/prompt-history/service.d.ts +54 -0
- package/dist/features/prompt-history/service.js +425 -0
- package/dist/features/prompt-history/store.d.ts +16 -0
- package/dist/features/prompt-history/store.js +219 -0
- package/dist/features/prompt-history/worker.d.ts +9 -0
- package/dist/features/prompt-history/worker.js +45 -0
- package/dist/features/prompt-suggestions/diagnostics.d.ts +18 -0
- package/dist/features/prompt-suggestions/diagnostics.js +82 -0
- package/dist/features/prompt-suggestions/index.d.ts +2 -0
- package/dist/features/prompt-suggestions/index.js +1 -0
- package/dist/foundation/launch-context/index.d.ts +59 -0
- package/dist/foundation/launch-context/index.js +136 -0
- package/dist/foundation/launch-guardian/index.d.ts +2 -0
- package/dist/foundation/launch-guardian/index.js +1 -0
- package/dist/foundation/launch-guardian/main.d.ts +33 -0
- package/dist/foundation/launch-guardian/main.js +180 -0
- package/dist/foundation/lifecycle/commands.js +1 -0
- package/dist/foundation/lifecycle/index.d.ts +11 -0
- package/dist/foundation/lifecycle/index.js +5 -0
- package/dist/foundation/lifecycle/model.d.ts +64 -0
- package/dist/foundation/lifecycle/model.js +40 -0
- package/dist/foundation/lifecycle/paths.d.ts +30 -0
- package/dist/foundation/lifecycle/paths.js +70 -0
- package/dist/foundation/lifecycle/session-selection.d.ts +9 -0
- package/dist/foundation/lifecycle/session-selection.js +39 -0
- package/dist/foundation/lifecycle/supervisor-startup.d.ts +30 -0
- package/dist/foundation/lifecycle/supervisor-startup.js +106 -0
- package/dist/foundation/process-containment/darwin-process-inspector.d.ts +5 -0
- package/dist/foundation/process-containment/darwin-process-inspector.js +7 -0
- package/dist/foundation/process-containment/index.d.ts +8 -0
- package/dist/foundation/process-containment/index.js +6 -0
- package/dist/foundation/process-containment/linux-process-inspector.d.ts +7 -0
- package/dist/foundation/process-containment/linux-process-inspector.js +27 -0
- package/dist/foundation/process-containment/native-guardian-containment.d.ts +17 -0
- package/dist/foundation/process-containment/native-guardian-containment.js +140 -0
- package/dist/foundation/process-containment/windows-process-inspector.d.ts +19 -0
- package/dist/foundation/process-containment/windows-process-inspector.js +56 -0
- package/dist/foundation/protocol/client.d.ts +18 -0
- package/dist/foundation/protocol/client.js +130 -0
- package/dist/foundation/protocol/index.d.ts +3 -0
- package/dist/foundation/protocol/index.js +2 -0
- package/dist/foundation/protocol/messages.d.ts +90 -0
- package/dist/foundation/protocol/messages.js +100 -0
- package/dist/foundation/release/bootstrap.d.ts +51 -0
- package/dist/foundation/release/bootstrap.js +427 -0
- package/dist/foundation/release/cohort-state.d.ts +157 -0
- package/dist/foundation/release/cohort-state.js +472 -0
- package/dist/foundation/release/dependency-certification-retention.d.ts +7 -0
- package/dist/foundation/release/dependency-certification-retention.js +88 -0
- package/dist/foundation/release/dependency-certification.d.ts +24 -0
- package/dist/foundation/release/dependency-certification.js +266 -0
- package/dist/foundation/release/dependency-layer.d.ts +78 -0
- package/dist/foundation/release/dependency-layer.js +466 -0
- package/dist/foundation/release/endpoints.d.ts +24 -0
- package/dist/foundation/release/endpoints.js +134 -0
- package/dist/foundation/release/immutable-platform.d.ts +6 -0
- package/dist/foundation/release/immutable-platform.js +13 -0
- package/dist/foundation/release/index.d.ts +30 -0
- package/dist/foundation/release/index.js +16 -0
- package/dist/foundation/release/release-gc.d.ts +71 -0
- package/dist/foundation/release/release-gc.js +764 -0
- package/dist/foundation/release/release-store.d.ts +49 -0
- package/dist/foundation/release/release-store.js +235 -0
- package/dist/foundation/release/release.d.ts +43 -0
- package/dist/foundation/release/release.js +215 -0
- package/dist/foundation/release/restart-certification.d.ts +68 -0
- package/dist/foundation/release/restart-certification.js +227 -0
- package/dist/foundation/release/types.d.ts +11 -0
- package/dist/foundation/release/types.js +1 -0
- package/dist/foundation/release/update-launch.d.ts +6 -0
- package/dist/foundation/release/update-launch.js +17 -0
- package/dist/foundation/release/update-recovery.d.ts +76 -0
- package/dist/foundation/release/update-recovery.js +356 -0
- package/dist/foundation/release/update-transaction.d.ts +42 -0
- package/dist/foundation/release/update-transaction.js +101 -0
- package/dist/foundation/release/update.d.ts +119 -0
- package/dist/foundation/release/update.js +632 -0
- package/dist/foundation/release/warmup.d.ts +3 -0
- package/dist/foundation/release/warmup.js +47 -0
- package/dist/foundation/startup/index.d.ts +4 -0
- package/dist/foundation/startup/index.js +2 -0
- package/dist/foundation/startup/startup-budget.d.ts +46 -0
- package/dist/foundation/startup/startup-budget.js +42 -0
- package/dist/foundation/startup/startup-descriptor.js +34 -0
- package/dist/foundation/startup/startup-runtime.d.ts +27 -0
- package/dist/foundation/startup/startup-runtime.js +128 -0
- package/dist/foundation/storage/control-store.d.ts +18 -0
- package/dist/foundation/storage/control-store.js +342 -0
- package/dist/foundation/storage/index.d.ts +1 -0
- package/dist/foundation/storage/index.js +1 -0
- package/dist/foundation/supervision/index.d.ts +3 -0
- package/dist/foundation/supervision/index.js +3 -0
- package/dist/foundation/supervision/main.d.ts +1 -0
- package/dist/foundation/supervision/main.js +84 -0
- package/dist/foundation/supervision/paths.d.ts +1 -0
- package/dist/foundation/supervision/paths.js +1 -0
- package/dist/foundation/supervision/server.d.ts +46 -0
- package/dist/foundation/supervision/server.js +573 -0
- package/dist/foundation/terminal-cleanup/fatal-exit.d.ts +12 -0
- package/dist/foundation/terminal-cleanup/fatal-exit.js +87 -0
- package/dist/foundation/terminal-cleanup/index.d.ts +3 -0
- package/dist/foundation/terminal-cleanup/index.js +2 -0
- package/dist/foundation/terminal-cleanup/terminal-reset.d.ts +4 -0
- package/dist/foundation/terminal-cleanup/terminal-reset.js +40 -0
- package/dist/integrations/pi/components/components.d.ts +4 -0
- package/dist/integrations/pi/components/components.js +64 -0
- package/dist/integrations/pi/components/conformance.d.ts +18 -0
- package/dist/integrations/pi/components/conformance.js +70 -0
- package/dist/integrations/pi/components/editor-interaction.d.ts +38 -0
- package/dist/integrations/pi/components/editor-interaction.js +1 -0
- package/dist/integrations/pi/components/history-editor-loader.d.ts +5 -0
- package/dist/integrations/pi/components/history-editor-loader.js +5 -0
- package/dist/integrations/pi/components/index.d.ts +21 -0
- package/dist/integrations/pi/components/index.js +13 -0
- package/dist/integrations/pi/components/owned-editor-ux.d.ts +74 -0
- package/dist/integrations/pi/components/owned-editor-ux.js +1094 -0
- package/dist/integrations/pi/components/path-word-ranges.d.ts +2 -0
- package/dist/integrations/pi/components/path-word-ranges.js +37 -0
- package/dist/integrations/pi/components/prompt-input-port.d.ts +18 -0
- package/dist/integrations/pi/components/prompt-input-port.js +1 -0
- package/dist/integrations/pi/components/resources/builtin-themes.d.ts +167 -0
- package/dist/integrations/pi/components/resources/builtin-themes.js +168 -0
- package/dist/integrations/pi/components/shell-components.d.ts +7 -0
- package/dist/integrations/pi/components/shell-components.js +7 -0
- package/dist/integrations/pi/components/shell-editor-autocomplete.js +298 -0
- package/dist/integrations/pi/components/shell-extension-ui.d.ts +35 -0
- package/dist/integrations/pi/components/shell-extension-ui.js +280 -0
- package/dist/integrations/pi/components/shell-footer-status.d.ts +7 -0
- package/dist/integrations/pi/components/shell-footer-status.js +248 -0
- package/dist/integrations/pi/components/shell-presenters-info.d.ts +43 -0
- package/dist/integrations/pi/components/shell-presenters-info.js +114 -0
- package/dist/integrations/pi/components/shell-presenters-transcript.d.ts +29 -0
- package/dist/integrations/pi/components/shell-presenters-transcript.js +433 -0
- package/dist/integrations/pi/components/shell-selectors-dialogs.d.ts +123 -0
- package/dist/integrations/pi/components/shell-selectors-dialogs.js +242 -0
- package/dist/integrations/pi/components/shell-shared-facade.d.ts +217 -0
- package/dist/integrations/pi/components/shell-shared-facade.js +92 -0
- package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +17 -0
- package/dist/integrations/pi/components/submitted-prompt-adapter.js +49 -0
- package/dist/integrations/pi/components/tool-image-presentation.d.ts +21 -0
- package/dist/integrations/pi/components/tool-image-presentation.js +83 -0
- package/dist/integrations/pi/components/tool-result-adapter.d.ts +6 -0
- package/dist/integrations/pi/components/tool-result-adapter.js +27 -0
- package/dist/integrations/pi/components/transcript-image-resolver.d.ts +7 -0
- package/dist/integrations/pi/components/transcript-image-resolver.js +19 -0
- package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +445 -0
- package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.js +370 -0
- package/dist/integrations/pi/components/upstream/assets/earendil-image.json +12 -0
- package/dist/integrations/pi/components/upstream/components/countdown-timer.d.ts +13 -0
- package/dist/integrations/pi/components/upstream/components/daxnuts.d.ts +29 -0
- package/dist/integrations/pi/components/upstream/components/daxnuts.js +146 -0
- package/dist/integrations/pi/components/upstream/components/earendil-announcement.d.ts +4 -0
- package/dist/integrations/pi/components/upstream/components/earendil-announcement.js +48 -0
- package/dist/integrations/pi/components/upstream/components/extension-editor.d.ts +20 -0
- package/dist/integrations/pi/components/upstream/components/extension-editor.js +84 -0
- package/dist/integrations/pi/components/upstream/components/mermaid.js +81 -0
- package/dist/integrations/pi/components/upstream/components/owned-editor.d.ts +46 -0
- package/dist/integrations/pi/components/upstream/components/owned-editor.js +187 -0
- package/dist/integrations/pi/components/upstream/components/scoped-models-selector.d.ts +59 -0
- package/dist/integrations/pi/components/upstream/components/scoped-models-selector.js +346 -0
- package/dist/integrations/pi/components/upstream/components/session-footer.d.ts +11 -0
- package/dist/integrations/pi/components/upstream/components/session-footer.js +123 -0
- package/dist/integrations/pi/components/upstream/components/session-selector-search.js +161 -0
- package/dist/integrations/pi/components/upstream/components/session-selector.d.ts +95 -0
- package/dist/integrations/pi/components/upstream/components/session-selector.js +893 -0
- package/dist/integrations/pi/components/upstream/components/skill-invocation-message.d.ts +21 -0
- package/dist/integrations/pi/components/upstream/components/skill-invocation-message.js +46 -0
- package/dist/integrations/pi/components/upstream/components/status-indicator.d.ts +35 -0
- package/dist/integrations/pi/components/upstream/components/status-indicator.js +69 -0
- package/dist/integrations/pi/components/upstream/components/tool-execution.d.ts +67 -0
- package/dist/integrations/pi/components/upstream/components/tool-execution.js +365 -0
- package/dist/integrations/pi/components/upstream/components/tree-selector.d.ts +101 -0
- package/dist/integrations/pi/components/upstream/components/tree-selector.js +1275 -0
- package/dist/integrations/pi/components/upstream/components/trust-selector.d.ts +33 -0
- package/dist/integrations/pi/components/upstream/components/trust-selector.js +81 -0
- package/dist/integrations/pi/components/upstream/external-editor.js +43 -0
- package/dist/integrations/pi/components/upstream/history/editor-core.d.ts +289 -0
- package/dist/integrations/pi/components/upstream/history/editor-core.js +2144 -0
- package/dist/integrations/pi/components/upstream/history/kill-ring.d.ts +35 -0
- package/dist/integrations/pi/components/upstream/history/kill-ring.js +51 -0
- package/dist/integrations/pi/components/upstream/history/printable-key.d.ts +1 -0
- package/dist/integrations/pi/components/upstream/history/printable-key.js +43 -0
- package/dist/integrations/pi/components/upstream/history/text-helpers.d.ts +14 -0
- package/dist/integrations/pi/components/upstream/history/text-helpers.js +31 -0
- package/dist/integrations/pi/components/upstream/history/undo-stack.d.ts +25 -0
- package/dist/integrations/pi/components/upstream/history/undo-stack.js +39 -0
- package/dist/integrations/pi/components/upstream/history/word-navigation.d.ts +24 -0
- package/dist/integrations/pi/components/upstream/history/word-navigation.js +103 -0
- package/dist/integrations/pi/components/upstream/model-search.d.ts +18 -0
- package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +33 -0
- package/dist/integrations/pi/components/upstream/theme/theme-controller.js +114 -0
- package/dist/integrations/pi/components/upstream/theme/theme.d.ts +61 -0
- package/dist/integrations/pi/components/upstream/theme/theme.js +337 -0
- package/dist/integrations/pi/engine/adapter.d.ts +135 -0
- package/dist/integrations/pi/engine/adapter.js +648 -0
- package/dist/integrations/pi/engine/changelog.d.ts +2 -0
- package/dist/integrations/pi/engine/changelog.js +63 -0
- package/dist/integrations/pi/engine/command-dispatch.d.ts +41 -0
- package/dist/integrations/pi/engine/command-dispatch.js +125 -0
- package/dist/integrations/pi/engine/compaction-progress.d.ts +28 -0
- package/dist/integrations/pi/engine/compaction-progress.js +96 -0
- package/dist/integrations/pi/engine/conformance.d.ts +39 -0
- package/dist/integrations/pi/engine/conformance.js +140 -0
- package/dist/integrations/pi/engine/event-delivery.d.ts +100 -0
- package/dist/integrations/pi/engine/event-delivery.js +184 -0
- package/dist/integrations/pi/engine/extension-ui-binding.d.ts +35 -0
- package/dist/integrations/pi/engine/extension-ui-binding.js +81 -0
- package/dist/integrations/pi/engine/http-dispatcher.d.ts +4 -0
- package/dist/integrations/pi/engine/http-dispatcher.js +25 -0
- package/dist/integrations/pi/engine/index.d.ts +18 -0
- package/dist/integrations/pi/engine/index.js +10 -0
- package/dist/integrations/pi/engine/message-values.d.ts +29 -0
- package/dist/integrations/pi/engine/message-values.js +168 -0
- package/dist/integrations/pi/engine/package-integration.d.ts +13 -0
- package/dist/integrations/pi/engine/package-integration.js +118 -0
- package/dist/integrations/pi/engine/pending-delivery.d.ts +30 -0
- package/dist/integrations/pi/engine/pending-delivery.js +156 -0
- package/dist/integrations/pi/engine/pi-settings-metadata.json +385 -0
- package/dist/integrations/pi/engine/project-trust-preflight.d.ts +22 -0
- package/dist/integrations/pi/engine/project-trust-preflight.js +50 -0
- package/dist/integrations/pi/engine/prompt-suggestions.d.ts +30 -0
- package/dist/integrations/pi/engine/prompt-suggestions.js +102 -0
- package/dist/integrations/pi/engine/provider-authentication.d.ts +34 -0
- package/dist/integrations/pi/engine/provider-authentication.js +209 -0
- package/dist/integrations/pi/engine/resource-catalog.d.ts +49 -0
- package/dist/integrations/pi/engine/resource-catalog.js +289 -0
- package/dist/integrations/pi/engine/resources/changelog.json +12 -0
- package/dist/integrations/pi/engine/runtime-integration.d.ts +53 -0
- package/dist/integrations/pi/engine/runtime-integration.js +118 -0
- package/dist/integrations/pi/engine/session-events.d.ts +48 -0
- package/dist/integrations/pi/engine/session-events.js +223 -0
- package/dist/integrations/pi/engine/session-integration.d.ts +67 -0
- package/dist/integrations/pi/engine/session-integration.js +195 -0
- package/dist/integrations/pi/engine/session-runtime.d.ts +84 -0
- package/dist/integrations/pi/engine/session-runtime.js +249 -0
- package/dist/integrations/pi/engine/session-selection.d.ts +28 -0
- package/dist/integrations/pi/engine/session-selection.js +90 -0
- package/dist/integrations/pi/engine/settings-bridge.d.ts +121 -0
- package/dist/integrations/pi/engine/settings-bridge.js +514 -0
- package/dist/integrations/pi/engine/settings-metadata.d.ts +31 -0
- package/dist/integrations/pi/engine/settings-metadata.js +67 -0
- package/dist/integrations/pi/engine/settings-port.d.ts +42 -0
- package/dist/integrations/pi/engine/settings-port.js +353 -0
- package/dist/integrations/pi/engine/tool-rendering.d.ts +13 -0
- package/dist/integrations/pi/engine/tool-rendering.js +145 -0
- package/dist/integrations/pi/engine/transcript-image-assets.d.ts +11 -0
- package/dist/integrations/pi/engine/transcript-image-assets.js +86 -0
- package/dist/integrations/pi/engine/transcript-projection.d.ts +39 -0
- package/dist/integrations/pi/engine/transcript-projection.js +405 -0
- package/dist/integrations/pi/engine/usage-view.d.ts +4 -0
- package/dist/integrations/pi/engine/usage-view.js +56 -0
- package/dist/integrations/pi/engine/windows-filesystem-hygiene.d.ts +21 -0
- package/dist/integrations/pi/engine/windows-filesystem-hygiene.js +55 -0
- package/dist/integrations/pi/engine/workflow-contexts.d.ts +59 -0
- package/dist/integrations/pi/engine/workflow-contexts.js +316 -0
- package/dist/integrations/pi/engine/workflow-runner.d.ts +60 -0
- package/dist/integrations/pi/engine/workflow-runner.js +509 -0
- package/dist/integrations/pi/engine/workflow-support.d.ts +33 -0
- package/dist/integrations/pi/engine/workflow-support.js +352 -0
- package/dist/integrations/pi/engine/workflows.d.ts +251 -0
- package/dist/integrations/pi/engine/workflows.js +63 -0
- package/dist/integrations/pi/startup-public.d.ts +2 -0
- package/dist/integrations/pi/startup-public.js +2223 -0
- package/dist/integrations/pi/startup-public.manifest.json +12502 -0
- package/dist/integrations/pi/tui-runtime/adapter.d.ts +56 -0
- package/dist/integrations/pi/tui-runtime/adapter.js +783 -0
- package/dist/integrations/pi/tui-runtime/contracts.d.ts +156 -0
- package/dist/integrations/pi/tui-runtime/contracts.js +1 -0
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +88 -0
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +433 -0
- package/dist/integrations/pi/tui-runtime/index.d.ts +9 -0
- package/dist/integrations/pi/tui-runtime/index.js +5 -0
- package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +39 -0
- package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.js +139 -0
- package/dist/integrations/pi/tui-runtime/mouse-report-input.d.ts +13 -0
- package/dist/integrations/pi/tui-runtime/mouse-report-input.js +57 -0
- package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +32 -0
- package/dist/integrations/pi/tui-runtime/overlay-geometry.js +158 -0
- package/dist/integrations/pi/tui-runtime/presentation-adapter.d.ts +4 -0
- package/dist/integrations/pi/tui-runtime/presentation-adapter.js +48 -0
- package/dist/native/darwin-arm64/manifest.json +4 -4
- package/dist/native/darwin-arm64/process-guardian +0 -0
- package/dist/native/linux-x64/manifest.json +3 -3
- package/dist/native/linux-x64/process-guardian +0 -0
- package/dist/native/win32-x64/manifest.json +3 -3
- package/dist/native/win32-x64/process-guardian.exe +0 -0
- package/dist/product-identity.d.ts +37 -0
- package/dist/product-identity.js +119 -0
- package/dist/product-identity.json +85 -0
- package/dist/runtime-payload-inventory.json +127147 -0
- package/dist/ui/apps/contracts.d.ts +64 -0
- package/dist/ui/apps/host.d.ts +42 -0
- package/dist/ui/apps/host.js +156 -0
- package/dist/ui/apps/index.d.ts +5 -0
- package/dist/ui/apps/index.js +3 -0
- package/dist/ui/apps/registry.d.ts +12 -0
- package/dist/ui/apps/registry.js +33 -0
- package/dist/ui/components/dialog-panel.js +49 -0
- package/dist/ui/components/frame.d.ts +22 -0
- package/dist/ui/components/frame.js +55 -0
- package/dist/ui/components/index.d.ts +47 -0
- package/dist/ui/components/index.js +25 -0
- package/dist/ui/components/line-input.d.ts +68 -0
- package/dist/ui/components/line-input.js +224 -0
- package/dist/ui/components/list-view.d.ts +60 -0
- package/dist/ui/components/list-view.js +82 -0
- package/dist/ui/components/mouse.d.ts +25 -0
- package/dist/ui/components/mouse.js +70 -0
- package/dist/ui/components/progress-status.d.ts +2 -0
- package/dist/ui/components/progress-status.js +4 -0
- package/dist/ui/components/prompt-input.d.ts +32 -0
- package/dist/ui/components/prompt-input.js +51 -0
- package/dist/ui/components/scrollbar.d.ts +88 -0
- package/dist/ui/components/scrollbar.js +137 -0
- package/dist/ui/components/selection-copy.d.ts +24 -0
- package/dist/ui/components/selection-copy.js +39 -0
- package/dist/ui/components/shortcuts.d.ts +58 -0
- package/dist/ui/components/shortcuts.js +82 -0
- package/dist/ui/components/spans.d.ts +28 -0
- package/dist/ui/components/spans.js +266 -0
- package/dist/ui/components/submitted-prompt.d.ts +23 -0
- package/dist/ui/components/submitted-prompt.js +50 -0
- package/dist/ui/components/surface.d.ts +20 -0
- package/dist/ui/components/surface.js +44 -0
- package/dist/ui/components/text-selection.d.ts +62 -0
- package/dist/ui/components/text-selection.js +210 -0
- package/dist/ui/components/text.d.ts +38 -0
- package/dist/ui/components/text.js +185 -0
- package/dist/ui/components/transcript-viewport.d.ts +173 -0
- package/dist/ui/components/transcript-viewport.js +753 -0
- package/dist/ui/components/visible-hyperlinks.d.ts +26 -0
- package/dist/ui/components/visible-hyperlinks.js +97 -0
- package/dist/ui/settings/declarations.d.ts +141 -0
- package/dist/ui/settings/declarations.js +135 -0
- package/dist/ui/settings/index.d.ts +10 -0
- package/dist/ui/settings/index.js +5 -0
- package/dist/ui/settings/manager.d.ts +54 -0
- package/dist/ui/settings/manager.js +256 -0
- package/dist/ui/settings/migrations.d.ts +13 -0
- package/dist/ui/settings/migrations.js +74 -0
- package/dist/ui/settings/sections.d.ts +52 -0
- package/dist/ui/settings/sections.js +112 -0
- package/docs/architecture/boundaries.md +17 -13
- package/docs/architecture/code-documentation.md +77 -0
- package/docs/architecture/history-editor-provenance.md +100 -0
- package/docs/architecture/internal-naming.md +91 -0
- package/docs/architecture/process-guardian-provenance.md +3 -1
- package/docs/architecture/project-structure.md +69 -30
- package/docs/architecture/prompt-suggestions.md +68 -0
- package/docs/architecture/resource-and-data-policy.md +28 -2
- package/docs/architecture/response-copy-delivery.md +85 -0
- package/docs/architecture/terminal-host-proof-gate.md +1 -1
- package/docs/architecture/terminal-host-spike-evidence.md +1 -1
- package/docs/architecture/tool-image-presentation.md +62 -0
- package/docs/architecture/toolchain.md +32 -10
- package/docs/architecture/ui-reference-provenance.md +60 -6
- package/docs/ci-release-runbook.md +256 -79
- package/docs/features/launch-profiles.md +24 -17
- package/docs/features/modal-content-interaction.md +37 -0
- package/docs/features/prompt-history.md +149 -0
- package/docs/local-worktree-cleanup.md +212 -0
- package/docs/manual-code-streaming-cleanup.md +88 -0
- package/docs/manual-ghost-link-baseline.md +89 -0
- package/docs/manual-launch-instance-acceptance.md +12 -35
- package/docs/manual-owned-ui-checkpoint.md +79 -0
- package/docs/manual-pi-boundary-candidate.md +4 -5
- package/docs/manual-terminal-colour-check.md +4 -3
- package/docs/openspec-archive-automation.md +259 -0
- package/docs/repository-governance-live-acceptance.md +77 -0
- package/docs/validation.md +100 -0
- package/package.json +49 -34
- package/dist/src/cli/capabilities.d.ts +0 -15
- package/dist/src/cli/capabilities.js +0 -7
- package/dist/src/cli/dispatch.d.ts +0 -32
- package/dist/src/cli/dispatch.js +0 -142
- package/dist/src/cli/index.d.ts +0 -5
- package/dist/src/cli/index.js +0 -5
- package/dist/src/cli/packages.d.ts +0 -23
- package/dist/src/cli/packages.js +0 -84
- package/dist/src/cli/version-stats.d.ts +0 -16
- package/dist/src/cli/version-stats.js +0 -72
- package/dist/src/cli/version.d.ts +0 -2
- package/dist/src/cli/version.js +0 -23
- package/dist/src/composition/index.d.ts +0 -48
- package/dist/src/composition/index.js +0 -258
- package/dist/src/features/launch/development-launch.js +0 -28
- package/dist/src/features/launch/index.d.ts +0 -7
- package/dist/src/features/launch/index.js +0 -7
- package/dist/src/features/launch/intent.d.ts +0 -7
- package/dist/src/features/launch/intent.js +0 -4
- package/dist/src/features/launch/prepare-launch.d.ts +0 -13
- package/dist/src/features/launch/prepare-launch.js +0 -21
- package/dist/src/features/launch/profile-paths.d.ts +0 -15
- package/dist/src/features/launch/profile-paths.js +0 -31
- package/dist/src/features/launch/profiles.d.ts +0 -12
- package/dist/src/features/launch/profiles.js +0 -26
- package/dist/src/features/launch/runtime-selection.d.ts +0 -19
- package/dist/src/features/launch/runtime-selection.js +0 -13
- package/dist/src/features/owned-ui/customization.d.ts +0 -38
- package/dist/src/features/owned-ui/customization.js +0 -108
- package/dist/src/features/owned-ui/diagnostics.d.ts +0 -33
- package/dist/src/features/owned-ui/diagnostics.js +0 -94
- package/dist/src/features/owned-ui/index.d.ts +0 -4
- package/dist/src/features/owned-ui/index.js +0 -4
- package/dist/src/features/owned-ui/run.d.ts +0 -11
- package/dist/src/features/owned-ui/run.js +0 -15
- package/dist/src/features/owned-ui/settings-app.d.ts +0 -22
- package/dist/src/features/owned-ui/settings-app.js +0 -633
- package/dist/src/features/workspace/capabilities.d.ts +0 -31
- package/dist/src/features/workspace/capabilities.js +0 -75
- package/dist/src/features/workspace/index.d.ts +0 -6
- package/dist/src/features/workspace/index.js +0 -6
- package/dist/src/features/workspace/presentation.d.ts +0 -30
- package/dist/src/features/workspace/presentation.js +0 -70
- package/dist/src/features/workspace/reconciliation.d.ts +0 -15
- package/dist/src/features/workspace/reconciliation.js +0 -82
- package/dist/src/features/workspace/reducer.d.ts +0 -42
- package/dist/src/features/workspace/reducer.js +0 -213
- package/dist/src/features/workspace/router.d.ts +0 -31
- package/dist/src/features/workspace/router.js +0 -124
- package/dist/src/features/workspace/store.d.ts +0 -17
- package/dist/src/features/workspace/store.js +0 -54
- package/dist/src/foundation/agent-engine-contracts/capability-ports.d.ts +0 -95
- package/dist/src/foundation/agent-engine-contracts/domain-validation.js +0 -89
- package/dist/src/foundation/agent-engine-contracts/domain.d.ts +0 -116
- package/dist/src/foundation/agent-engine-contracts/index.d.ts +0 -8
- package/dist/src/foundation/agent-engine-contracts/index.js +0 -8
- package/dist/src/foundation/agent-engine-contracts/package-ports.d.ts +0 -54
- package/dist/src/foundation/launch-guardian/index.d.ts +0 -1
- package/dist/src/foundation/launch-guardian/index.js +0 -1
- package/dist/src/foundation/launch-guardian/main.d.ts +0 -31
- package/dist/src/foundation/launch-guardian/main.js +0 -165
- package/dist/src/foundation/lifecycle/index.d.ts +0 -4
- package/dist/src/foundation/lifecycle/index.js +0 -4
- package/dist/src/foundation/lifecycle/model.d.ts +0 -64
- package/dist/src/foundation/lifecycle/model.js +0 -40
- package/dist/src/foundation/lifecycle/paths.d.ts +0 -10
- package/dist/src/foundation/lifecycle/paths.js +0 -42
- package/dist/src/foundation/native-host-protocol/codec.d.ts +0 -11
- package/dist/src/foundation/native-host-protocol/codec.js +0 -56
- package/dist/src/foundation/native-host-protocol/evidence.d.ts +0 -67
- package/dist/src/foundation/native-host-protocol/evidence.js +0 -141
- package/dist/src/foundation/native-host-protocol/index.d.ts +0 -4
- package/dist/src/foundation/native-host-protocol/index.js +0 -4
- package/dist/src/foundation/native-host-protocol/messages.d.ts +0 -56
- package/dist/src/foundation/native-host-protocol/messages.js +0 -149
- package/dist/src/foundation/native-host-protocol/proof-gate.d.ts +0 -13
- package/dist/src/foundation/native-host-protocol/proof-gate.js +0 -33
- package/dist/src/foundation/owned-ui-contracts/extension-ui.d.ts +0 -302
- package/dist/src/foundation/owned-ui-contracts/index.d.ts +0 -3
- package/dist/src/foundation/owned-ui-contracts/index.js +0 -3
- package/dist/src/foundation/owned-ui-contracts/model.d.ts +0 -241
- package/dist/src/foundation/owned-ui-contracts/validation.d.ts +0 -11
- package/dist/src/foundation/owned-ui-contracts/validation.js +0 -395
- package/dist/src/foundation/owned-ui-settings/declarations.d.ts +0 -13
- package/dist/src/foundation/owned-ui-settings/declarations.js +0 -39
- package/dist/src/foundation/owned-ui-settings/index.d.ts +0 -6
- package/dist/src/foundation/owned-ui-settings/index.js +0 -6
- package/dist/src/foundation/owned-ui-settings/migrations.d.ts +0 -13
- package/dist/src/foundation/owned-ui-settings/migrations.js +0 -28
- package/dist/src/foundation/owned-ui-settings/sections.d.ts +0 -70
- package/dist/src/foundation/owned-ui-settings/sections.js +0 -93
- package/dist/src/foundation/owned-ui-settings/session.d.ts +0 -44
- package/dist/src/foundation/owned-ui-settings/session.js +0 -145
- package/dist/src/foundation/owned-ui-settings/store.d.ts +0 -28
- package/dist/src/foundation/owned-ui-settings/store.js +0 -90
- package/dist/src/foundation/pi-component-adapter/components.d.ts +0 -4
- package/dist/src/foundation/pi-component-adapter/components.js +0 -64
- package/dist/src/foundation/pi-component-adapter/conformance.d.ts +0 -17
- package/dist/src/foundation/pi-component-adapter/conformance.js +0 -69
- package/dist/src/foundation/pi-component-adapter/index.d.ts +0 -13
- package/dist/src/foundation/pi-component-adapter/index.js +0 -13
- package/dist/src/foundation/pi-component-adapter/resources/builtin-themes.d.ts +0 -165
- package/dist/src/foundation/pi-component-adapter/resources/builtin-themes.js +0 -166
- package/dist/src/foundation/pi-component-adapter/shell-components.d.ts +0 -6
- package/dist/src/foundation/pi-component-adapter/shell-components.js +0 -6
- package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.js +0 -162
- package/dist/src/foundation/pi-component-adapter/shell-extension-ui.d.ts +0 -35
- package/dist/src/foundation/pi-component-adapter/shell-extension-ui.js +0 -279
- package/dist/src/foundation/pi-component-adapter/shell-footer-status.d.ts +0 -7
- package/dist/src/foundation/pi-component-adapter/shell-footer-status.js +0 -189
- package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts +0 -57
- package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.js +0 -429
- package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.d.ts +0 -113
- package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.js +0 -235
- package/dist/src/foundation/pi-component-adapter/shell-shared-facade.d.ts +0 -116
- package/dist/src/foundation/pi-component-adapter/shell-shared-facade.js +0 -87
- package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.d.ts +0 -422
- package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.js +0 -296
- package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.d.ts +0 -10
- package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.d.ts +0 -17
- package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.js +0 -51
- package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.d.ts +0 -22
- package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.js +0 -142
- package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.d.ts +0 -4
- package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.js +0 -19
- package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.d.ts +0 -17
- package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.js +0 -81
- package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.d.ts +0 -24
- package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.js +0 -105
- package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.d.ts +0 -2
- package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.js +0 -18
- package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.js +0 -77
- package/dist/src/foundation/pi-component-adapter/upstream/components/owned-editor.d.ts +0 -18
- package/dist/src/foundation/pi-component-adapter/upstream/components/owned-editor.js +0 -55
- package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.d.ts +0 -55
- package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.js +0 -342
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-footer.d.ts +0 -10
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-footer.js +0 -120
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.js +0 -159
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.d.ts +0 -95
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.js +0 -889
- package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.d.ts +0 -19
- package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.js +0 -44
- package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.d.ts +0 -30
- package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.js +0 -59
- package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.d.ts +0 -98
- package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.js +0 -1272
- package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.d.ts +0 -33
- package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.js +0 -76
- package/dist/src/foundation/pi-component-adapter/upstream/external-editor.js +0 -39
- package/dist/src/foundation/pi-component-adapter/upstream/model-search.d.ts +0 -15
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.d.ts +0 -25
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.js +0 -117
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.d.ts +0 -61
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.js +0 -326
- package/dist/src/foundation/pi-engine-adapter/adapter.d.ts +0 -164
- package/dist/src/foundation/pi-engine-adapter/adapter.js +0 -2367
- package/dist/src/foundation/pi-engine-adapter/conformance.d.ts +0 -37
- package/dist/src/foundation/pi-engine-adapter/conformance.js +0 -130
- package/dist/src/foundation/pi-engine-adapter/index.d.ts +0 -10
- package/dist/src/foundation/pi-engine-adapter/index.js +0 -10
- package/dist/src/foundation/pi-engine-adapter/model-auth-integration.d.ts +0 -30
- package/dist/src/foundation/pi-engine-adapter/model-auth-integration.js +0 -61
- package/dist/src/foundation/pi-engine-adapter/package-integration.d.ts +0 -13
- package/dist/src/foundation/pi-engine-adapter/package-integration.js +0 -112
- package/dist/src/foundation/pi-engine-adapter/pi-settings-metadata.json +0 -374
- package/dist/src/foundation/pi-engine-adapter/resource-extension-integration.d.ts +0 -31
- package/dist/src/foundation/pi-engine-adapter/resource-extension-integration.js +0 -80
- package/dist/src/foundation/pi-engine-adapter/runtime-integration.d.ts +0 -35
- package/dist/src/foundation/pi-engine-adapter/runtime-integration.js +0 -67
- package/dist/src/foundation/pi-engine-adapter/session-integration.d.ts +0 -43
- package/dist/src/foundation/pi-engine-adapter/session-integration.js +0 -97
- package/dist/src/foundation/pi-engine-adapter/settings-integration.d.ts +0 -55
- package/dist/src/foundation/pi-engine-adapter/settings-integration.js +0 -233
- package/dist/src/foundation/pi-engine-adapter/workflow-controllers.d.ts +0 -20
- package/dist/src/foundation/pi-engine-adapter/workflow-controllers.js +0 -48
- package/dist/src/foundation/pi-engine-adapter/workflows.d.ts +0 -173
- package/dist/src/foundation/pi-engine-adapter/workflows.js +0 -60
- package/dist/src/foundation/pi-owned-ui-integration/index.d.ts +0 -2
- package/dist/src/foundation/pi-owned-ui-integration/index.js +0 -2
- package/dist/src/foundation/pi-owned-ui-integration/route-host.d.ts +0 -29
- package/dist/src/foundation/pi-owned-ui-integration/session-shell.d.ts +0 -106
- package/dist/src/foundation/pi-owned-ui-integration/session-shell.js +0 -1518
- package/dist/src/foundation/pi-tui-runtime-adapter/adapter.d.ts +0 -39
- package/dist/src/foundation/pi-tui-runtime-adapter/adapter.js +0 -493
- package/dist/src/foundation/pi-tui-runtime-adapter/conformance.d.ts +0 -18
- package/dist/src/foundation/pi-tui-runtime-adapter/conformance.js +0 -145
- package/dist/src/foundation/pi-tui-runtime-adapter/contracts.d.ts +0 -120
- package/dist/src/foundation/pi-tui-runtime-adapter/index.d.ts +0 -4
- package/dist/src/foundation/pi-tui-runtime-adapter/index.js +0 -4
- package/dist/src/foundation/pi-tui-runtime-adapter/presentation-adapter.d.ts +0 -4
- package/dist/src/foundation/pi-tui-runtime-adapter/presentation-adapter.js +0 -48
- package/dist/src/foundation/presentation-contracts/index.d.ts +0 -96
- package/dist/src/foundation/process-containment/index.d.ts +0 -5
- package/dist/src/foundation/process-containment/index.js +0 -5
- package/dist/src/foundation/process-containment/linux-process-inspector.d.ts +0 -6
- package/dist/src/foundation/process-containment/linux-process-inspector.js +0 -26
- package/dist/src/foundation/process-containment/native-guardian-containment.d.ts +0 -16
- package/dist/src/foundation/process-containment/native-guardian-containment.js +0 -139
- package/dist/src/foundation/process-containment/windows-process-inspector.d.ts +0 -17
- package/dist/src/foundation/process-containment/windows-process-inspector.js +0 -53
- package/dist/src/foundation/protocol/client.d.ts +0 -17
- package/dist/src/foundation/protocol/client.js +0 -129
- package/dist/src/foundation/protocol/index.d.ts +0 -2
- package/dist/src/foundation/protocol/index.js +0 -2
- package/dist/src/foundation/protocol/messages.d.ts +0 -89
- package/dist/src/foundation/protocol/messages.js +0 -99
- package/dist/src/foundation/release/bootstrap.d.ts +0 -29
- package/dist/src/foundation/release/bootstrap.js +0 -335
- package/dist/src/foundation/release/cohort-state.d.ts +0 -70
- package/dist/src/foundation/release/cohort-state.js +0 -202
- package/dist/src/foundation/release/index.d.ts +0 -10
- package/dist/src/foundation/release/index.js +0 -10
- package/dist/src/foundation/release/release-gc.d.ts +0 -5
- package/dist/src/foundation/release/release-gc.js +0 -16
- package/dist/src/foundation/release/release-store.d.ts +0 -43
- package/dist/src/foundation/release/release-store.js +0 -175
- package/dist/src/foundation/release/release.d.ts +0 -38
- package/dist/src/foundation/release/release.js +0 -204
- package/dist/src/foundation/release/update-transaction.d.ts +0 -31
- package/dist/src/foundation/release/update-transaction.js +0 -89
- package/dist/src/foundation/release/update.d.ts +0 -82
- package/dist/src/foundation/release/update.js +0 -529
- package/dist/src/foundation/storage/control-store.d.ts +0 -61
- package/dist/src/foundation/storage/control-store.js +0 -530
- package/dist/src/foundation/storage/index.d.ts +0 -1
- package/dist/src/foundation/storage/index.js +0 -1
- package/dist/src/foundation/structured-agent-runtime/backpressure.d.ts +0 -46
- package/dist/src/foundation/structured-agent-runtime/backpressure.js +0 -118
- package/dist/src/foundation/structured-agent-runtime/commands.d.ts +0 -52
- package/dist/src/foundation/structured-agent-runtime/commands.js +0 -164
- package/dist/src/foundation/structured-agent-runtime/handshake.d.ts +0 -41
- package/dist/src/foundation/structured-agent-runtime/handshake.js +0 -151
- package/dist/src/foundation/structured-agent-runtime/index.d.ts +0 -5
- package/dist/src/foundation/structured-agent-runtime/index.js +0 -5
- package/dist/src/foundation/structured-agent-runtime/reconnection.d.ts +0 -37
- package/dist/src/foundation/structured-agent-runtime/reconnection.js +0 -129
- package/dist/src/foundation/structured-agent-runtime/state.d.ts +0 -56
- package/dist/src/foundation/structured-agent-runtime/state.js +0 -118
- package/dist/src/foundation/supervision/index.d.ts +0 -3
- package/dist/src/foundation/supervision/index.js +0 -3
- package/dist/src/foundation/supervision/main.d.ts +0 -1
- package/dist/src/foundation/supervision/main.js +0 -41
- package/dist/src/foundation/supervision/paths.d.ts +0 -1
- package/dist/src/foundation/supervision/paths.js +0 -1
- package/dist/src/foundation/supervision/server.d.ts +0 -22
- package/dist/src/foundation/supervision/server.js +0 -451
- package/dist/src/foundation/ui-apps/contracts.d.ts +0 -42
- package/dist/src/foundation/ui-apps/host.d.ts +0 -42
- package/dist/src/foundation/ui-apps/host.js +0 -152
- package/dist/src/foundation/ui-apps/index.d.ts +0 -3
- package/dist/src/foundation/ui-apps/index.js +0 -3
- package/dist/src/foundation/ui-apps/registry.d.ts +0 -11
- package/dist/src/foundation/ui-apps/registry.js +0 -32
- package/dist/src/foundation/ui-components/dialog-panel.js +0 -47
- package/dist/src/foundation/ui-components/frame.d.ts +0 -21
- package/dist/src/foundation/ui-components/frame.js +0 -54
- package/dist/src/foundation/ui-components/index.d.ts +0 -18
- package/dist/src/foundation/ui-components/index.js +0 -18
- package/dist/src/foundation/ui-components/line-input.d.ts +0 -74
- package/dist/src/foundation/ui-components/line-input.js +0 -245
- package/dist/src/foundation/ui-components/list-view.d.ts +0 -66
- package/dist/src/foundation/ui-components/list-view.js +0 -76
- package/dist/src/foundation/ui-components/mouse.d.ts +0 -15
- package/dist/src/foundation/ui-components/mouse.js +0 -46
- package/dist/src/foundation/ui-components/scrollbar.d.ts +0 -62
- package/dist/src/foundation/ui-components/scrollbar.js +0 -102
- package/dist/src/foundation/ui-components/shortcuts.d.ts +0 -57
- package/dist/src/foundation/ui-components/shortcuts.js +0 -81
- package/dist/src/foundation/ui-components/spans.d.ts +0 -7
- package/dist/src/foundation/ui-components/spans.js +0 -59
- package/dist/src/foundation/ui-components/surface.d.ts +0 -20
- package/dist/src/foundation/ui-components/surface.js +0 -38
- package/dist/src/foundation/ui-components/text.d.ts +0 -24
- package/dist/src/foundation/ui-components/text.js +0 -123
- package/dist/src/foundation/workspace-contracts/index.d.ts +0 -2
- package/dist/src/foundation/workspace-contracts/index.js +0 -2
- package/dist/src/foundation/workspace-contracts/model.d.ts +0 -248
- package/dist/src/foundation/workspace-contracts/model.js +0 -2
- package/dist/src/foundation/workspace-contracts/validation.d.ts +0 -13
- package/dist/src/foundation/workspace-contracts/validation.js +0 -335
- package/dist/src/product-identity.d.ts +0 -37
- package/dist/src/product-identity.js +0 -150
- package/dist/src/product-identity.json +0 -99
- package/docs/manual-transparent-checkpoint.md +0 -53
- /package/dist/{src/foundation/agent-engine-contracts/domain.js → app/session-shell/paste-helper.d.ts} +0 -0
- /package/dist/{src/foundation/agent-engine-contracts/ports.js → app/session-shell/paste-text-worker.d.ts} +0 -0
- /package/dist/{src/foundation/lifecycle/commands.js → app/session-shell/paste-types.js} +0 -0
- /package/dist/{src/foundation/pi-owned-ui-integration/route-host.js → app/session-shell/response-copy-helper.d.ts} +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/capability-ports.js +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain-validation.d.ts +0 -0
- /package/dist/{src/foundation/pi-tui-runtime-adapter/contracts.js → contracts/agent-engine/domain.js} +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.d.ts +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.js +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/package-ports.js +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/ports.d.ts +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.d.ts +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.js +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.d.ts +0 -0
- /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.js +0 -0
- /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/extension-ui.js +0 -0
- /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/model.js +0 -0
- /package/dist/{src/foundation/presentation-contracts → contracts/presentation}/index.js +0 -0
- /package/dist/{src/features → features}/launch/development-launch.d.ts +0 -0
- /package/dist/{src/features → features}/launch/initialize-profile.d.ts +0 -0
- /package/dist/{src/features → features}/launch/initialize-profile.js +0 -0
- /package/dist/{src/foundation → foundation}/lifecycle/commands.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.js +0 -0
- /package/dist/{src/foundation → foundation}/process-containment/artifact.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/process-containment/artifact.js +0 -0
- /package/dist/{src/foundation → foundation}/process-containment/contracts.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/process-containment/contracts.js +0 -0
- /package/dist/{src/foundation → foundation}/release/cohort-selection.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/release/cohort-selection.js +0 -0
- /package/dist/{src/foundation → foundation}/release/concurrency.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/release/concurrency.js +0 -0
- /package/dist/{src/foundation → foundation}/release/process-cleanup.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/release/process-cleanup.js +0 -0
- /package/dist/{src/foundation → foundation}/release/stable-release.d.ts +0 -0
- /package/dist/{src/foundation → foundation}/release/stable-release.js +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-editor-autocomplete.d.ts +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.d.ts +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.js +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/countdown-timer.js +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/mermaid.d.ts +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector-search.d.ts +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/external-editor.d.ts +0 -0
- /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/model-search.js +0 -0
- /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.d.ts +0 -0
- /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.js +0 -0
- /package/dist/{src/foundation/ui-apps → ui/apps}/contracts.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/dialog-panel.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/label.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/label.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/list-block.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/list-block.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/pane.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/pane.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/revision.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/revision.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/status-line.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/status-line.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/stepper.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/stepper.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/theme.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/theme.js +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/value-menu.d.ts +0 -0
- /package/dist/{src/foundation/ui-components → ui/components}/value-menu.js +0 -0
- /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.d.ts +0 -0
- /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.js +0 -0
|
@@ -0,0 +1,1917 @@
|
|
|
1
|
+
import { ResponseCopyCoordinator } from "./response-copy-coordinator.js";
|
|
2
|
+
import { createResponseCopyExecutor, hasAsyncClipboardOutput, responseCopyDestination } from "./response-copy-transport.js";
|
|
3
|
+
import { MAX_COPY_CONTROL_BYTES } from "./response-copy-protocol.js";
|
|
4
|
+
import { PromptHistoryController } from "./prompt-history-controller.js";
|
|
5
|
+
import { PRODUCT_TEXT } from "../../product-identity.js";
|
|
6
|
+
import { boundedCleanup } from "../../foundation/terminal-cleanup/terminal-reset.js";
|
|
7
|
+
import { assertOwnedUiCommand } from "../../contracts/owned-ui/index.js";
|
|
8
|
+
import { assertPromptImages, ImageAttachmentError } from "../../contracts/owned-ui/index.js";
|
|
9
|
+
import { ContextualPromptSuggestionController } from "./prompt-suggestion-controller.js";
|
|
10
|
+
import { MOUSE_TRACKING_OFF, MOUSE_TRACKING_ON, parseMouseInput } from "../../ui/components/mouse.js";
|
|
11
|
+
import { readVisibleHyperlinks } from "../../ui/components/visible-hyperlinks.js";
|
|
12
|
+
import { PINNED_PI_HIDDEN_COMMAND_NAMES, PINNED_PI_WORKFLOW_COMMAND_NAMES } from "../../integrations/pi/engine/workflows.js";
|
|
13
|
+
import { createPiExtensionUiBridge } from "../../integrations/pi/components/shell-extension-ui.js";
|
|
14
|
+
import { createPiShellEditor } from "../../integrations/pi/components/shell-editor-autocomplete.js";
|
|
15
|
+
import { createPiQueuedInputStatus, createPiShellFooter, createPiShellHeader, createPiShellLoadedResources, createPiShellStatus, } from "../../integrations/pi/components/shell-footer-status.js";
|
|
16
|
+
import { createPiShellArmin, createPiShellAuthProviderSelector, createPiShellDaxnuts, createPiShellDialog, createPiShellEarendilAnnouncement, createPiShellExtensionSelector, createPiShellLoginDialog, createPiShellModelSelector, createPiShellOperationLoader, createPiShellReloadBox, createPiShellScopedModelsSelector, createPiShellSelector, createPiShellSessionSelector, createPiShellSettingsSelector, createPiShellThinkingSelector, createPiShellTreeSelector, createPiShellTrustSelector, createPiShellUserMessageSelector, } from "../../integrations/pi/components/shell-selectors-dialogs.js";
|
|
17
|
+
import { createPiShellChangelog, createPiShellHotkeys, createPiShellSessionInfo, renderPiShellStatusText, } from "../../integrations/pi/components/shell-presenters-info.js";
|
|
18
|
+
import { createPiShellTranscriptComponent, renderPiShellPackageUpdateNotice, renderPiShellStartupDiagnostic, renderPiShellTranscriptBlock, } from "../../integrations/pi/components/shell-presenters-transcript.js";
|
|
19
|
+
import { onPiThemeChange, piTheme } from "../../integrations/pi/components/upstream/theme/theme.js";
|
|
20
|
+
import { DamageAwareTerminalAdapter } from "../../integrations/pi/tui-runtime/damage-aware-terminal.js";
|
|
21
|
+
import { PiTuiRuntimeAdapter } from "../../integrations/pi/tui-runtime/adapter.js";
|
|
22
|
+
import { classifyPiTuiInput } from "../../integrations/pi/tui-runtime/input-presentation-coordinator.js";
|
|
23
|
+
import { runImageWorker } from "./image-preparation-client.js";
|
|
24
|
+
import { STREAM_PRESENTATION_INTERVAL_MS, StreamPresentationCoalescer, } from "./stream-presentation-coalescer.js";
|
|
25
|
+
import { writeSystemClipboardText, } from "./system-clipboard.js";
|
|
26
|
+
import { OwnedUiSessionShellRoot, shellResourceEntries, } from "./session-shell-root.js";
|
|
27
|
+
export { OwnedUiSessionShellRoot, } from "./session-shell-root.js";
|
|
28
|
+
/** Coordinates backend, owned presentation, and Pi TUI lifecycles for one interactive session. */
|
|
29
|
+
export class OwnedUiSessionShell {
|
|
30
|
+
backend;
|
|
31
|
+
root;
|
|
32
|
+
runtime;
|
|
33
|
+
#cwd;
|
|
34
|
+
#listeners = new Set();
|
|
35
|
+
#unsubscribe;
|
|
36
|
+
#unsubscribePromptSuggestions;
|
|
37
|
+
#promptSuggestions;
|
|
38
|
+
#promptHistory = null;
|
|
39
|
+
#promptHistoryImageSidecar;
|
|
40
|
+
#extensionBridge;
|
|
41
|
+
#stopped;
|
|
42
|
+
#resolveStopped;
|
|
43
|
+
#dialogId;
|
|
44
|
+
#dialogSource;
|
|
45
|
+
#routeHost;
|
|
46
|
+
#dialogHandle;
|
|
47
|
+
#sequence = 0;
|
|
48
|
+
#editorRevision = 0;
|
|
49
|
+
#started = false;
|
|
50
|
+
#disposed = false;
|
|
51
|
+
#shutdownPromise;
|
|
52
|
+
#disposePromise;
|
|
53
|
+
#pointerReporting = false;
|
|
54
|
+
#customViewport;
|
|
55
|
+
#responseCopy;
|
|
56
|
+
// Rationale: only an executor this shell created owns a spare copy helper worth warming and disposing.
|
|
57
|
+
#copyExecutor;
|
|
58
|
+
#unbindClipboardWriter;
|
|
59
|
+
#damageTerminal;
|
|
60
|
+
#quitOutro;
|
|
61
|
+
#reloadPresentation;
|
|
62
|
+
#streamPresentation;
|
|
63
|
+
#removeViewportPreInput;
|
|
64
|
+
#unsubscribeSettings;
|
|
65
|
+
#unbindPiSettings;
|
|
66
|
+
#unbindTerminalSettings;
|
|
67
|
+
#unbindShutdownSettings;
|
|
68
|
+
#terminalProgressEnabled = false;
|
|
69
|
+
#showImages = true;
|
|
70
|
+
#imageWidthCells = 80;
|
|
71
|
+
#fullscreenExitOutput = "transcript";
|
|
72
|
+
#waitingImages = new Map();
|
|
73
|
+
#lastClearTime = 0;
|
|
74
|
+
#lastEscapeTime = 0;
|
|
75
|
+
#activeLoginDialog;
|
|
76
|
+
#sessionGeneration;
|
|
77
|
+
#sessionBindingGeneration;
|
|
78
|
+
#suggestionModelKey;
|
|
79
|
+
constructor(options) {
|
|
80
|
+
const { backend, cwd, routeHost, sessionLayout } = options.engine;
|
|
81
|
+
const { terminal, startup, viewportSettings, quitOutro, reload: reloadPresentation, stream: streamPresentationOptions, input: inputPresentation } = options.presentation ?? {};
|
|
82
|
+
const { clipboard, responseCopy, paste: pasteDiagnostics, pastePreparation } = options.diagnostics ?? {};
|
|
83
|
+
const promptHistory = options.history;
|
|
84
|
+
this.backend = backend;
|
|
85
|
+
this.#sessionGeneration = this.backend.sessionGeneration;
|
|
86
|
+
this.#sessionBindingGeneration = this.backend.sessionBindingGeneration;
|
|
87
|
+
this.#suggestionModelKey = modelKey(this.backend.view());
|
|
88
|
+
this.#cwd = cwd;
|
|
89
|
+
this.#routeHost = routeHost ?? null;
|
|
90
|
+
this.#customViewport = sessionLayout === "custom-viewport";
|
|
91
|
+
this.#stopped = new Promise(resolve => {
|
|
92
|
+
this.#resolveStopped = resolve;
|
|
93
|
+
});
|
|
94
|
+
let runtime;
|
|
95
|
+
let damageTerminal;
|
|
96
|
+
let streamPresentation;
|
|
97
|
+
let pendingClipboardWrite = Promise.resolve();
|
|
98
|
+
let promptSuggestionController = null;
|
|
99
|
+
const terminalCopy = terminal !== undefined || hasAsyncClipboardOutput();
|
|
100
|
+
this.#responseCopy = this.#customViewport ? new ResponseCopyCoordinator({
|
|
101
|
+
execute: responseCopy?.execute ?? (this.#copyExecutor = createResponseCopyExecutor({
|
|
102
|
+
...(terminal === undefined && clipboard === undefined ? {} : { destination: "terminal" }),
|
|
103
|
+
...(clipboard?.writeText === undefined ? {} : { writeText: (text, signal) => clipboard.writeText(text, signal) }),
|
|
104
|
+
...(terminalCopy ? { terminal: { submit: async (control, signal) => {
|
|
105
|
+
if (signal.aborted || this.#disposed || !runtime?.active)
|
|
106
|
+
throw new Error("Copy canceled");
|
|
107
|
+
// Performance: never grow the real terminal's pending buffer with another clipboard payload.
|
|
108
|
+
if (terminal === undefined && process.stdout.writableLength + control.length > MAX_COPY_CONTROL_BYTES) {
|
|
109
|
+
throw new Error("Clipboard terminal is busy");
|
|
110
|
+
}
|
|
111
|
+
runtime.writeControl(control);
|
|
112
|
+
} } } : {}),
|
|
113
|
+
})),
|
|
114
|
+
...(responseCopy?.onEvent === undefined ? {} : { onEvent: responseCopy.onEvent }),
|
|
115
|
+
onFailure: result => {
|
|
116
|
+
if (this.#disposed || !runtime?.active)
|
|
117
|
+
return;
|
|
118
|
+
this.root.appendWorkflowStatus(result.outcome === "timed-out" ? "Copy timed out; the clipboard did not respond."
|
|
119
|
+
: result.failure === "size" ? "Selection exceeds this clipboard route's size limit."
|
|
120
|
+
: "Could not copy the selection; the clipboard is unavailable.");
|
|
121
|
+
runtime.requestRender();
|
|
122
|
+
},
|
|
123
|
+
}) : null;
|
|
124
|
+
const readClipboard = async (signal) => {
|
|
125
|
+
if (signal.aborted)
|
|
126
|
+
throw new ImageAttachmentError("image-canceled");
|
|
127
|
+
if (clipboard === undefined)
|
|
128
|
+
return runImageWorker({ kind: "clipboard" }, signal);
|
|
129
|
+
try {
|
|
130
|
+
const image = await clipboard.readImage?.(signal);
|
|
131
|
+
if (image !== null && image !== undefined) {
|
|
132
|
+
const canonical = await runImageWorker({ kind: "canonicalize", source: image }, signal);
|
|
133
|
+
if (canonical !== null)
|
|
134
|
+
return { kind: "image", ...canonical };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof ImageAttachmentError)
|
|
139
|
+
throw error;
|
|
140
|
+
// Compatibility: an unavailable image reader can still provide text.
|
|
141
|
+
}
|
|
142
|
+
const text = await clipboard.readText(signal);
|
|
143
|
+
return text === null ? null : { kind: "text", text };
|
|
144
|
+
};
|
|
145
|
+
this.root = new OwnedUiSessionShellRoot(this.backend.view(), cwd, {
|
|
146
|
+
getColumns: () => runtime?.viewport().columns ?? terminal?.columns ?? 80,
|
|
147
|
+
getRows: () => runtime?.viewport().rows ?? terminal?.rows ?? 24,
|
|
148
|
+
requestRender: force => runtime?.requestRender(force),
|
|
149
|
+
requestHyperlinkCleanup: rows => damageTerminal?.requestHyperlinkCleanup(rows),
|
|
150
|
+
onViewportFrame: frame => damageTerminal?.arm(frame.descriptor, {
|
|
151
|
+
overlayActive: runtime?.hasOverlay() ?? false,
|
|
152
|
+
selectionActive: this.root.hasActiveSelection(),
|
|
153
|
+
replacementSurfaceActive: !this.root.usesDefaultInputSurface(),
|
|
154
|
+
}),
|
|
155
|
+
enableDockInputReuse: inputPresentation?.viewportReuse !== false,
|
|
156
|
+
persistentHistory: this.#customViewport && promptHistory !== undefined,
|
|
157
|
+
...(promptHistory === undefined ? {} : { historyEditor: promptHistory.editor }),
|
|
158
|
+
onSubmit: text => { void this.submit(text).catch(() => this.#reportSubmissionError()); },
|
|
159
|
+
onPasteRejected: error => this.#reportSubmissionError(error),
|
|
160
|
+
onInterrupt: () => { void this.interrupt(); },
|
|
161
|
+
onClear: () => { void this.clearOrExit(); },
|
|
162
|
+
onExit: () => { void this.shutdown(); },
|
|
163
|
+
onModelSelect: () => this.showModelSelector(),
|
|
164
|
+
onModelCycle: direction => { void this.cycleModel(direction); },
|
|
165
|
+
onThinkingCycle: () => { void this.cycleThinkingLevel(); },
|
|
166
|
+
onThinkingToggle: () => {
|
|
167
|
+
this.root.toggleThinkingVisibility();
|
|
168
|
+
this.runtime.requestRender();
|
|
169
|
+
},
|
|
170
|
+
onMessageCopy: () => { void this.runWorkflow({ command: "copy", argument: "" }); },
|
|
171
|
+
onFollowUp: () => { void this.queueFollowUp().catch(() => this.#reportSubmissionError()); },
|
|
172
|
+
onDequeue: () => this.restoreQueuedInput(),
|
|
173
|
+
onEditorChange: () => { this.#editorRevision++; promptSuggestionController?.invalidate(); },
|
|
174
|
+
onPromptSuggestionAccepted: () => promptSuggestionController?.accept(),
|
|
175
|
+
onInputSurfaceChanged: () => {
|
|
176
|
+
promptSuggestionController?.invalidate();
|
|
177
|
+
this.#promptHistory?.synchronize();
|
|
178
|
+
},
|
|
179
|
+
onCopyText: text => {
|
|
180
|
+
if (this.#responseCopy !== null) {
|
|
181
|
+
void this.#responseCopy.submitText(text);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const write = () => {
|
|
185
|
+
if (this.#disposed)
|
|
186
|
+
return Promise.resolve();
|
|
187
|
+
runtime?.writeControl(`\u001b]52;c;${Buffer.from(text, "utf8").toString("base64")}\u0007`);
|
|
188
|
+
return clipboard === undefined ? writeSystemClipboardText(text)
|
|
189
|
+
: clipboard.writeText?.(text) ?? Promise.resolve();
|
|
190
|
+
};
|
|
191
|
+
// Compatibility: comparison profiles retain their existing clipboard path.
|
|
192
|
+
pendingClipboardWrite = write().catch(() => { });
|
|
193
|
+
},
|
|
194
|
+
readClipboardContent: async (signal = new AbortController().signal) => {
|
|
195
|
+
await pendingClipboardWrite;
|
|
196
|
+
return readClipboard(signal);
|
|
197
|
+
},
|
|
198
|
+
captureClipboardPaste: () => {
|
|
199
|
+
const before = this.#responseCopy?.capturePasteBarrier() ?? (async () => true);
|
|
200
|
+
if (clipboard !== undefined)
|
|
201
|
+
return { kind: "provided", read: readClipboard, before };
|
|
202
|
+
if (responseCopyDestination(process.env) === "terminal")
|
|
203
|
+
return {
|
|
204
|
+
kind: "provided", before, read: async () => { throw new ImageAttachmentError("paste-unavailable"); },
|
|
205
|
+
};
|
|
206
|
+
return { kind: "native", before };
|
|
207
|
+
},
|
|
208
|
+
...(pasteDiagnostics === undefined ? {} : { pasteDiagnostics: pasteDiagnostics }),
|
|
209
|
+
...(pastePreparation === undefined ? {} : { pastePreparation }),
|
|
210
|
+
}, {
|
|
211
|
+
...startup,
|
|
212
|
+
resources: startup?.resources ?? shellResourceEntries(this.backend),
|
|
213
|
+
}, this.backend.agentDir, {
|
|
214
|
+
getMessageRenderer: customType => this.backend.pinnedMessageRenderer(customType),
|
|
215
|
+
getToolDefinition: toolName => this.backend.pinnedToolDefinition(toolName),
|
|
216
|
+
getShortcuts: bindings => this.backend.pinnedShortcutDescriptions(bindings),
|
|
217
|
+
}, sessionLayout, {
|
|
218
|
+
resolve: assetId => this.backend.resolveTranscriptImage(assetId),
|
|
219
|
+
});
|
|
220
|
+
// Invariant: bare A1 owns a bounded viewport and therefore always runs on the alternate
|
|
221
|
+
// fullscreen surface. The pinned comparison profiles still honor Pi's mode.
|
|
222
|
+
const tuiMode = this.#customViewport
|
|
223
|
+
? "fullscreen"
|
|
224
|
+
: this.backend.disposed ? "regular" : this.backend.pinnedSettingsSnapshot().tuiMode;
|
|
225
|
+
const runtimeOptions = {
|
|
226
|
+
root: this.root,
|
|
227
|
+
mode: tuiMode,
|
|
228
|
+
...(this.#customViewport ? {
|
|
229
|
+
onOverlayGeometry: surfaces => this.root.setViewportOverlaySurfaces(surfaces),
|
|
230
|
+
decorateTerminal: (terminal) => {
|
|
231
|
+
damageTerminal = new DamageAwareTerminalAdapter(terminal, {
|
|
232
|
+
regionalScroll: process.env.TERM !== "dumb",
|
|
233
|
+
inspectHyperlinks: readVisibleHyperlinks,
|
|
234
|
+
onResize: () => streamPresentation?.noteImmediatePresentation(),
|
|
235
|
+
onHyperlinkCleanupRequired: () => runtime?.requestRender(true),
|
|
236
|
+
});
|
|
237
|
+
return damageTerminal;
|
|
238
|
+
},
|
|
239
|
+
...(inputPresentation?.coordination === false ? {} : {
|
|
240
|
+
inputCoordination: {
|
|
241
|
+
classify: (data, focusedOverlay) => classifyPiTuiInput(data, focusedOverlay ?? this.root.inputCoordinationSurface()),
|
|
242
|
+
onReceipt: () => streamPresentation?.noteImmediatePresentation(),
|
|
243
|
+
...(inputPresentation?.scheduler === undefined
|
|
244
|
+
? {}
|
|
245
|
+
: { scheduler: inputPresentation.scheduler }),
|
|
246
|
+
},
|
|
247
|
+
}),
|
|
248
|
+
} : { layoutRoot: this.root.layoutRoot() }),
|
|
249
|
+
...(inputPresentation?.onEvent === undefined ? {} : {
|
|
250
|
+
inputDiagnostics: {
|
|
251
|
+
onEvent: inputPresentation.onEvent,
|
|
252
|
+
...(inputPresentation.now === undefined ? {} : { now: inputPresentation.now }),
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
...(terminal === undefined ? {} : { terminal: terminal }),
|
|
256
|
+
hardwareCursor: this.backend.view().terminal.hardwareCursor,
|
|
257
|
+
};
|
|
258
|
+
runtime = new PiTuiRuntimeAdapter(runtimeOptions);
|
|
259
|
+
this.runtime = runtime;
|
|
260
|
+
this.#damageTerminal = damageTerminal ?? null;
|
|
261
|
+
this.#quitOutro = quitOutro;
|
|
262
|
+
this.#reloadPresentation = reloadPresentation;
|
|
263
|
+
const presentationInterval = streamPresentationOptions?.intervalMs ?? STREAM_PRESENTATION_INTERVAL_MS;
|
|
264
|
+
streamPresentation = streamPresentationOptions?.scheduler === undefined
|
|
265
|
+
? new StreamPresentationCoalescer(() => this.runtime.requestRender(), presentationInterval)
|
|
266
|
+
: new StreamPresentationCoalescer(() => this.runtime.requestRender(), presentationInterval, streamPresentationOptions.scheduler);
|
|
267
|
+
this.#streamPresentation = streamPresentation;
|
|
268
|
+
const promptSuggestionOptions = this.#customViewport ? options.suggestions : undefined;
|
|
269
|
+
promptSuggestionController = promptSuggestionOptions === undefined ? null : new ContextualPromptSuggestionController({
|
|
270
|
+
generator: promptSuggestionOptions.generator,
|
|
271
|
+
enabled: promptSuggestionOptions.enabled(),
|
|
272
|
+
...(promptSuggestionOptions.diagnostics === undefined ? {} : { diagnostics: promptSuggestionOptions.diagnostics }),
|
|
273
|
+
surface: {
|
|
274
|
+
canPresent: identity => this.#promptSuggestionPresentationBlockReason(identity) === null,
|
|
275
|
+
presentationBlockReason: identity => this.#promptSuggestionPresentationBlockReason(identity),
|
|
276
|
+
present: text => {
|
|
277
|
+
if (!this.root.canPresentPromptSuggestion())
|
|
278
|
+
return false;
|
|
279
|
+
this.root.setPromptSuggestion(text);
|
|
280
|
+
return true;
|
|
281
|
+
},
|
|
282
|
+
clear: () => this.root.setPromptSuggestion(null),
|
|
283
|
+
requestRender: () => this.runtime.requestRender(),
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
this.#promptSuggestions = promptSuggestionController;
|
|
287
|
+
this.#unsubscribePromptSuggestions = promptSuggestionOptions === undefined
|
|
288
|
+
? () => { }
|
|
289
|
+
: promptSuggestionOptions.onChange(enabled => this.#promptSuggestions?.setEnabled(enabled));
|
|
290
|
+
const initialPiSettings = this.backend.pinnedSettingsSnapshot();
|
|
291
|
+
this.runtime.setHardwareCursor(initialPiSettings.showHardwareCursor);
|
|
292
|
+
this.runtime.setClearOnShrink(initialPiSettings.clearOnShrink);
|
|
293
|
+
this.#terminalProgressEnabled = initialPiSettings.showTerminalProgress;
|
|
294
|
+
this.#fullscreenExitOutput = initialPiSettings.fullscreenExitOutput;
|
|
295
|
+
// Invariant: bare A1 prints only the resume hint at exit, so the pinned exit-output
|
|
296
|
+
// choice is hidden there and cannot be bound; the comparison profile binds and honors it.
|
|
297
|
+
this.#unbindShutdownSettings = this.backend.settingsProductMode === "bare" ? () => { } : this.backend.bindSettingsOwner("shutdown", {
|
|
298
|
+
fullscreenExitOutput: { apply() { } },
|
|
299
|
+
});
|
|
300
|
+
this.#unbindTerminalSettings = this.backend.bindSettingsOwner("terminal", {
|
|
301
|
+
showHardwareCursor: { apply: value => {
|
|
302
|
+
if (typeof value !== "boolean")
|
|
303
|
+
throw new TypeError("Hardware cursor setting is invalid");
|
|
304
|
+
this.runtime.setHardwareCursor(value);
|
|
305
|
+
} },
|
|
306
|
+
clearOnShrink: { apply: value => {
|
|
307
|
+
if (typeof value !== "boolean")
|
|
308
|
+
throw new TypeError("Clear-on-shrink setting is invalid");
|
|
309
|
+
this.runtime.setClearOnShrink(value);
|
|
310
|
+
} },
|
|
311
|
+
showTerminalProgress: { apply: value => {
|
|
312
|
+
if (typeof value !== "boolean")
|
|
313
|
+
throw new TypeError("Terminal progress setting is invalid");
|
|
314
|
+
this.#terminalProgressEnabled = value;
|
|
315
|
+
this.#syncTerminalProgress(this.view());
|
|
316
|
+
} },
|
|
317
|
+
});
|
|
318
|
+
this.#removeViewportPreInput = this.#customViewport
|
|
319
|
+
? this.runtime.addPreInputListener(data => {
|
|
320
|
+
if (inputPresentation?.coordination === false)
|
|
321
|
+
this.#streamPresentation.noteImmediatePresentation();
|
|
322
|
+
// Compatibility: Pi's fullscreen renderer also intercepts plain Home/End.
|
|
323
|
+
// Deliver them to the focused owned input before that outer scroll handler;
|
|
324
|
+
// overlays retain Pi's normal dispatch, and comparison profiles never enter here.
|
|
325
|
+
if (!this.runtime.hasOverlay() && (this.root.editor.matchesTerminalKey(data, "home")
|
|
326
|
+
|| this.root.editor.matchesTerminalKey(data, "end"))) {
|
|
327
|
+
if (this.root.usesDefaultInputSurface())
|
|
328
|
+
this.root.handleViewportPreInput(data, true);
|
|
329
|
+
this.root.handleInput(data);
|
|
330
|
+
this.runtime.requestRender();
|
|
331
|
+
return { consume: true };
|
|
332
|
+
}
|
|
333
|
+
// Invariant: geometry must belong to the painted frame, including newly opened/nested
|
|
334
|
+
// surfaces. Steady pointer input does not trigger a synchronous composition.
|
|
335
|
+
const viewport = this.runtime.viewport();
|
|
336
|
+
if (data.includes("\u001b[<") && !this.root.viewportInputGeometryReady(viewport.columns, viewport.rows)) {
|
|
337
|
+
this.runtime.renderNow();
|
|
338
|
+
}
|
|
339
|
+
const routed = this.root.handleViewportPreInput(data, true, Date.now(), this.root.usesDefaultInputSurface() && !this.runtime.hasFocusedOverlay());
|
|
340
|
+
if (routed.copySelection !== undefined) {
|
|
341
|
+
void this.#responseCopy?.submit(routed.copySelection, pendingClipboardWrite);
|
|
342
|
+
}
|
|
343
|
+
if (!routed.consumed)
|
|
344
|
+
return routed.data === data ? undefined : { data: routed.data };
|
|
345
|
+
return routed.data.length === 0 ? { consume: true } : { data: routed.data };
|
|
346
|
+
})
|
|
347
|
+
: () => { };
|
|
348
|
+
const applyViewportSettings = () => {
|
|
349
|
+
const snapshot = viewportSettings?.snapshot();
|
|
350
|
+
this.root.setViewportConfig(snapshot ?? {
|
|
351
|
+
scrollbarAppearance: "auto",
|
|
352
|
+
scrollbarStyle: "thin",
|
|
353
|
+
scrollbarSpeed: "normal",
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
applyViewportSettings();
|
|
357
|
+
this.#unsubscribeSettings = this.#customViewport && viewportSettings
|
|
358
|
+
? viewportSettings.onChange(settings => this.root.setViewportConfig(settings))
|
|
359
|
+
: () => { };
|
|
360
|
+
this.root.setEditorPaddingX(initialPiSettings.editorPaddingX);
|
|
361
|
+
this.root.setAutocompleteMaxVisible(initialPiSettings.autocompleteMaxVisible);
|
|
362
|
+
this.root.setOutputPad(initialPiSettings.outputPad);
|
|
363
|
+
this.root.setHideThinkingBlock(initialPiSettings.hideThinkingBlock);
|
|
364
|
+
this.root.setMermaidRenderingMode(initialPiSettings.mermaidRenderingMode);
|
|
365
|
+
this.#showImages = initialPiSettings.showImages;
|
|
366
|
+
this.#imageWidthCells = initialPiSettings.imageWidthCells;
|
|
367
|
+
this.root.setImagePresentation(this.#showImages, this.#imageWidthCells);
|
|
368
|
+
this.#unbindPiSettings = this.backend.bindSettingsOwner("shell", {
|
|
369
|
+
editorPaddingX: { apply: value => {
|
|
370
|
+
if (typeof value !== "number")
|
|
371
|
+
throw new TypeError("Editor padding is invalid");
|
|
372
|
+
this.root.setEditorPaddingX(value);
|
|
373
|
+
} },
|
|
374
|
+
autocompleteMaxVisible: { apply: value => {
|
|
375
|
+
if (typeof value !== "number")
|
|
376
|
+
throw new TypeError("Autocomplete maximum is invalid");
|
|
377
|
+
this.root.setAutocompleteMaxVisible(value);
|
|
378
|
+
} },
|
|
379
|
+
outputPad: { apply: value => {
|
|
380
|
+
if (value !== 0 && value !== 1)
|
|
381
|
+
throw new TypeError("Output padding is invalid");
|
|
382
|
+
this.root.setOutputPad(value);
|
|
383
|
+
} },
|
|
384
|
+
hideThinkingBlock: { apply: value => {
|
|
385
|
+
if (typeof value !== "boolean")
|
|
386
|
+
throw new TypeError("Thinking-block visibility is invalid");
|
|
387
|
+
this.root.setHideThinkingBlock(value);
|
|
388
|
+
} },
|
|
389
|
+
mermaidRenderingMode: { apply: value => {
|
|
390
|
+
if (value !== "off" && value !== "final" && value !== "streaming")
|
|
391
|
+
throw new TypeError("Mermaid mode is invalid");
|
|
392
|
+
this.root.setMermaidRenderingMode(value);
|
|
393
|
+
} },
|
|
394
|
+
showImages: { apply: value => {
|
|
395
|
+
if (typeof value !== "boolean")
|
|
396
|
+
throw new TypeError("Image visibility is invalid");
|
|
397
|
+
this.#showImages = value;
|
|
398
|
+
this.root.setImagePresentation(this.#showImages, this.#imageWidthCells);
|
|
399
|
+
} },
|
|
400
|
+
imageWidthCells: { apply: value => {
|
|
401
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1)
|
|
402
|
+
throw new TypeError("Image width is invalid");
|
|
403
|
+
this.#imageWidthCells = value;
|
|
404
|
+
this.root.setImagePresentation(this.#showImages, this.#imageWidthCells);
|
|
405
|
+
} },
|
|
406
|
+
});
|
|
407
|
+
if (this.#customViewport && promptHistory !== undefined) {
|
|
408
|
+
this.#promptHistoryImageSidecar = promptHistory.imageSidecar;
|
|
409
|
+
const sidecar = this.#promptHistoryImageSidecar;
|
|
410
|
+
this.#promptHistory = new PromptHistoryController({
|
|
411
|
+
editor: this.root.editor,
|
|
412
|
+
store: promptHistory.store,
|
|
413
|
+
limit: promptHistory.limit,
|
|
414
|
+
fallback: this.view().transcript.flatMap(block => block.kind === "user" ? [block.text] : []),
|
|
415
|
+
active: () => this.root.usesDefaultInputSurface(),
|
|
416
|
+
render: () => this.runtime.requestRender(),
|
|
417
|
+
rehydrate: value => this.root.rehydrateHistoryText(value, id => sidecar?.readAttachment(id) ?? null),
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
this.#extensionBridge = createPiExtensionUiBridge({
|
|
421
|
+
runtime: {
|
|
422
|
+
getColumns: () => this.runtime.viewport().columns,
|
|
423
|
+
getRows: () => this.runtime.viewport().rows,
|
|
424
|
+
requestRender: () => this.runtime.requestRender(),
|
|
425
|
+
},
|
|
426
|
+
agentDir: this.backend.agentDir,
|
|
427
|
+
setInputSurface: component => this.root.setInputSurface(component, true, "opaque"),
|
|
428
|
+
showOverlay: (component, overlayOptions) => this.runtime.showOverlay(component, overlayOptions),
|
|
429
|
+
listenInput: handler => this.runtime.addInputListener(handler),
|
|
430
|
+
replaceWidget: (key, component, placement) => this.root.setExtensionWidget(key, component, placement),
|
|
431
|
+
replaceHeader: component => this.root.setExtensionHeader(component),
|
|
432
|
+
replaceFooter: component => this.root.setExtensionFooter(component),
|
|
433
|
+
setStatus: (key, text) => this.root.setExtensionStatus(key, text),
|
|
434
|
+
setWorking: (message, visible) => this.root.setExtensionWorking(message, visible),
|
|
435
|
+
notify: (message, type) => this.root.addExtensionNotification(message, type),
|
|
436
|
+
setTitle: title => this.runtime.setTitle(title),
|
|
437
|
+
getEditorText: () => this.root.editor.getText(),
|
|
438
|
+
setEditorText: text => this.root.editor.setText(text),
|
|
439
|
+
pasteToEditor: text => this.root.editor.insertText(text),
|
|
440
|
+
addAutocompleteProvider: factory => this.root.editor.addAutocompleteProvider(factory),
|
|
441
|
+
setCustomEditor: component => this.root.setInputSurface(component, true, "opaque"),
|
|
442
|
+
getFooterData: () => this.root.extensionFooterData(),
|
|
443
|
+
getToolsExpanded: () => this.root.toolsExpanded,
|
|
444
|
+
setToolsExpanded: expanded => this.root.setToolsExpanded(expanded),
|
|
445
|
+
});
|
|
446
|
+
this.backend.setWorkflowInteractionHost({
|
|
447
|
+
startLogin: request => this.#startWorkflowLogin(request),
|
|
448
|
+
prompt: request => this.#requestWorkflowInput(request),
|
|
449
|
+
notify: event => this.#notifyWorkflowLogin(event),
|
|
450
|
+
publish: message => {
|
|
451
|
+
this.root.appendWorkflowMessage(message);
|
|
452
|
+
this.runtime.requestRender();
|
|
453
|
+
},
|
|
454
|
+
finishLogin: () => this.#finishWorkflowLogin(),
|
|
455
|
+
});
|
|
456
|
+
this.root.editor.setAutocompleteCommands(this.backend.workflowAutocompleteCommands());
|
|
457
|
+
this.#unsubscribe = this.backend.onEvent(event => {
|
|
458
|
+
// Performance: a streamed chunk names one block, and touching only that block is what keeps the
|
|
459
|
+
// cost of a chunk the same in a long session as in a new one. Everything else
|
|
460
|
+
// resynchronizes the view, which is cheap next to re-reading the transcript.
|
|
461
|
+
if (event.type === "agent-run-started") {
|
|
462
|
+
this.#promptSuggestions?.invalidate();
|
|
463
|
+
this.root.resumeViewportFollowing();
|
|
464
|
+
}
|
|
465
|
+
if (event.type === "assistant-message-completed") {
|
|
466
|
+
this.root.noteCompletedAssistantMessage();
|
|
467
|
+
const identity = {
|
|
468
|
+
sessionId: event.sessionId,
|
|
469
|
+
sessionGeneration: event.sessionGeneration,
|
|
470
|
+
runSequence: event.runSequence,
|
|
471
|
+
responseSequence: event.responseSequence,
|
|
472
|
+
model: event.model,
|
|
473
|
+
};
|
|
474
|
+
if (event.model === null)
|
|
475
|
+
this.#promptSuggestions?.skip(identity, "no-model");
|
|
476
|
+
else
|
|
477
|
+
this.#promptSuggestions?.consider({ ...identity, model: event.model }, !event.successful ? "failed-response"
|
|
478
|
+
: event.toolContinuation || event.stopReason === "toolUse" ? "tool-continuation"
|
|
479
|
+
: event.stopReason !== "stop" ? "incomplete-response"
|
|
480
|
+
: event.assistantMessageCount < 2 ? "early-conversation"
|
|
481
|
+
: this.root.promptSuggestionPrepareBlockReason());
|
|
482
|
+
}
|
|
483
|
+
const semanticOnly = event.type === "agent-run-started" || event.type === "assistant-message-completed";
|
|
484
|
+
const view = event.type === "transcript-block" && this.#sessionGeneration === this.backend.sessionGeneration
|
|
485
|
+
? this.#syncBlock(event.block)
|
|
486
|
+
: semanticOnly ? this.view() : this.#syncView();
|
|
487
|
+
this.#syncTerminalProgress(view);
|
|
488
|
+
const currentModelKey = modelKey(view);
|
|
489
|
+
if (this.backend.sessionGeneration !== this.#sessionGeneration || currentModelKey !== this.#suggestionModelKey) {
|
|
490
|
+
this.#promptSuggestions?.invalidate();
|
|
491
|
+
this.#suggestionModelKey = currentModelKey;
|
|
492
|
+
}
|
|
493
|
+
if (event.type === "status" && /^(Retrying|Compacting)/.test(event.status.workingMessage ?? "")) {
|
|
494
|
+
this.#promptSuggestions?.invalidate();
|
|
495
|
+
}
|
|
496
|
+
if (event.type === "agent-run-settled" && event.model !== null) {
|
|
497
|
+
this.#promptSuggestions?.settle({
|
|
498
|
+
sessionId: event.sessionId,
|
|
499
|
+
sessionGeneration: event.sessionGeneration,
|
|
500
|
+
runSequence: event.runSequence,
|
|
501
|
+
responseSequence: event.responseSequence,
|
|
502
|
+
model: event.model,
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (event.type === "session-lifecycle" && event.lifecycle === "stopped")
|
|
506
|
+
this.#settleStoppedLifecycle();
|
|
507
|
+
});
|
|
508
|
+
this.#unbindClipboardWriter = this.#responseCopy === null ? () => { } : this.backend.bindClipboardWriter(async (text) => {
|
|
509
|
+
const result = await this.#responseCopy.submitText(text);
|
|
510
|
+
if (result.outcome === "delivered")
|
|
511
|
+
return true;
|
|
512
|
+
if (result.outcome === "submitted-unverified")
|
|
513
|
+
return false;
|
|
514
|
+
throw new Error(result.outcome === "timed-out" ? "Clipboard delivery timed out" : "Clipboard delivery could not be completed");
|
|
515
|
+
});
|
|
516
|
+
if (this.backend.view().lifecycle === "stopped")
|
|
517
|
+
this.#resolveStopped?.();
|
|
518
|
+
}
|
|
519
|
+
view() {
|
|
520
|
+
return this.backend.view();
|
|
521
|
+
}
|
|
522
|
+
#promptSuggestionPresentationBlockReason(identity) {
|
|
523
|
+
const view = this.view();
|
|
524
|
+
if (this.#disposed)
|
|
525
|
+
return "disposed";
|
|
526
|
+
if (identity.sessionId !== view.sessionId || identity.sessionGeneration !== this.backend.sessionGeneration
|
|
527
|
+
|| modelKey(view) !== `${identity.model.providerId}/${identity.model.modelId}`)
|
|
528
|
+
return "stale-identity";
|
|
529
|
+
return this.root.promptSuggestionPresentationBlockReason();
|
|
530
|
+
}
|
|
531
|
+
damagePresentationDecision() {
|
|
532
|
+
return this.#damageTerminal?.lastDecision ?? null;
|
|
533
|
+
}
|
|
534
|
+
start() {
|
|
535
|
+
if (this.#started)
|
|
536
|
+
return;
|
|
537
|
+
this.#started = true;
|
|
538
|
+
this.runtime.start();
|
|
539
|
+
this.#promptHistory?.start();
|
|
540
|
+
this.#syncTerminalProgress(this.view());
|
|
541
|
+
if (this.#customViewport)
|
|
542
|
+
this.#setPointerReporting(true);
|
|
543
|
+
void this.backend.bindExtensionUi(this.#extensionBridge.context, () => { void this.shutdown(); });
|
|
544
|
+
this.#syncView();
|
|
545
|
+
// Performance: the spare clipboard helpers fork after the first frame is out, so startup never waits on them.
|
|
546
|
+
setImmediate(() => {
|
|
547
|
+
if (this.#disposed || !this.#customViewport)
|
|
548
|
+
return;
|
|
549
|
+
this.root.warmPastePreparation();
|
|
550
|
+
this.#copyExecutor?.warm();
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
onView(listener) {
|
|
554
|
+
this.#listeners.add(listener);
|
|
555
|
+
listener(this.view());
|
|
556
|
+
return () => this.#listeners.delete(listener);
|
|
557
|
+
}
|
|
558
|
+
waitUntilStopped() {
|
|
559
|
+
return this.#stopped;
|
|
560
|
+
}
|
|
561
|
+
async submit(text) {
|
|
562
|
+
return this.#submitWhenReady(text, () => this.#submit(text));
|
|
563
|
+
}
|
|
564
|
+
#submitWhenReady(draft, action) {
|
|
565
|
+
const previous = this.#waitingImages.get(draft);
|
|
566
|
+
if (previous !== undefined)
|
|
567
|
+
return previous.result;
|
|
568
|
+
if (!this.root.hasPendingPastes(draft))
|
|
569
|
+
return this.#guardSubmission(draft, action);
|
|
570
|
+
const controller = new AbortController();
|
|
571
|
+
const generation = this.backend.sessionGeneration;
|
|
572
|
+
const result = this.#guardSubmission(draft, async () => {
|
|
573
|
+
await this.root.waitForPromptPastes(draft, controller.signal);
|
|
574
|
+
if (controller.signal.aborted || this.#disposed || this.backend.sessionGeneration !== generation)
|
|
575
|
+
return rejected("image submission canceled");
|
|
576
|
+
return action();
|
|
577
|
+
}).finally(() => {
|
|
578
|
+
this.#waitingImages.delete(draft);
|
|
579
|
+
if (!this.#disposed)
|
|
580
|
+
this.#showWaitingImages();
|
|
581
|
+
});
|
|
582
|
+
this.#waitingImages.set(draft, { controller, result });
|
|
583
|
+
if (this.root.editor.getText() === draft)
|
|
584
|
+
this.root.editor.setText("");
|
|
585
|
+
this.#showWaitingImages();
|
|
586
|
+
return result;
|
|
587
|
+
}
|
|
588
|
+
#showWaitingImages() {
|
|
589
|
+
const count = this.#waitingImages.size;
|
|
590
|
+
this.root.setExtensionWidget("owned-image-preparation", count === 0 ? null : {
|
|
591
|
+
render: width => [...renderPiShellStatusText(`Waiting for images (${count} submission${count === 1 ? "" : "s"}) — Esc cancels; dequeue restores`, width)],
|
|
592
|
+
invalidate: () => { },
|
|
593
|
+
}, "aboveEditor");
|
|
594
|
+
this.runtime.requestRender();
|
|
595
|
+
}
|
|
596
|
+
#cancelWaitingImages() {
|
|
597
|
+
for (const item of this.#waitingImages.values())
|
|
598
|
+
item.controller.abort();
|
|
599
|
+
}
|
|
600
|
+
#rememberInput(text, kind) {
|
|
601
|
+
this.root.editor.addToHistory(text);
|
|
602
|
+
if (this.#promptHistory !== null) {
|
|
603
|
+
const reusable = this.root.prepareHistoryText(text);
|
|
604
|
+
if (reusable.length === 0)
|
|
605
|
+
this.#promptHistory.rememberRecovery(text);
|
|
606
|
+
else {
|
|
607
|
+
this.#persistImageSidecars(text);
|
|
608
|
+
this.#promptHistory.capture(reusable, kind, this.#cwd, this.backend.sessionId);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
// Rationale: write the image chip payloads referenced by an editor draft to the sidecar
|
|
613
|
+
// directory before their history row commits. Missing sidecar dependency = silent skip; the
|
|
614
|
+
// recall path treats an absent sidecar the same as a corrupt one.
|
|
615
|
+
#persistImageSidecars(text) {
|
|
616
|
+
const sidecar = this.#promptHistoryImageSidecar;
|
|
617
|
+
if (sidecar === undefined)
|
|
618
|
+
return;
|
|
619
|
+
for (const record of this.root.imageChipAttachmentsFromEditor(text)) {
|
|
620
|
+
sidecar.write(record.id, { tag: record.tag, data: record.image.data, mimeType: record.image.mimeType, savedAt: new Date().toISOString() });
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
async #submit(text) {
|
|
624
|
+
this.#promptSuggestions?.invalidate();
|
|
625
|
+
const displayInput = text.trim();
|
|
626
|
+
if (!displayInput)
|
|
627
|
+
return { outcome: "completed", diagnostic: null };
|
|
628
|
+
if (displayInput.startsWith("/"))
|
|
629
|
+
return this.#slashCommand(displayInput);
|
|
630
|
+
const prepared = this.root.preparePromptSubmission(displayInput);
|
|
631
|
+
assertPromptImages(prepared.images);
|
|
632
|
+
const input = prepared.text.trim();
|
|
633
|
+
if (input.startsWith("!")) {
|
|
634
|
+
const excludeFromContext = input.startsWith("!!");
|
|
635
|
+
const command = input.slice(excludeFromContext ? 2 : 1).trim();
|
|
636
|
+
if (command) {
|
|
637
|
+
this.#rememberInput(displayInput, "bash");
|
|
638
|
+
try {
|
|
639
|
+
const result = await this.backend.executeBashWorkflow(command, excludeFromContext);
|
|
640
|
+
const workflow = {
|
|
641
|
+
command: "debug",
|
|
642
|
+
outcome: result.cancelled ? "cancelled" : result.exitCode === 0 || result.exitCode === undefined ? "completed" : "failed",
|
|
643
|
+
message: result.cancelled ? "Bash command cancelled" : `Bash exited ${result.exitCode ?? 0}: ${command}`,
|
|
644
|
+
...(result.output ? { detail: result.output } : {}),
|
|
645
|
+
};
|
|
646
|
+
this.root.appendWorkflowResult(workflow);
|
|
647
|
+
this.runtime.requestRender();
|
|
648
|
+
return workflow.outcome === "failed" ? rejected(workflow.message) : { outcome: "completed", diagnostic: null };
|
|
649
|
+
}
|
|
650
|
+
catch (error) {
|
|
651
|
+
const message = `Bash command failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
652
|
+
this.root.appendWorkflowResult({ command: "debug", outcome: "failed", message });
|
|
653
|
+
this.runtime.requestRender();
|
|
654
|
+
return rejected(message);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
// Compatibility: match interactive Pi: input during compaction is queued steering; the engine
|
|
659
|
+
// shows it in the pending rows and delivers it when compaction ends.
|
|
660
|
+
const type = this.view().lifecycle === "busy" ? "steer" : "prompt";
|
|
661
|
+
this.#rememberInput(displayInput, type);
|
|
662
|
+
this.root.resumeViewportFollowing();
|
|
663
|
+
return this.#execute({
|
|
664
|
+
type,
|
|
665
|
+
correlationId: this.#correlation(type),
|
|
666
|
+
sessionId: this.backend.sessionId,
|
|
667
|
+
text: input,
|
|
668
|
+
...(prepared.images.length === 0 ? {} : { images: prepared.images }),
|
|
669
|
+
}, displayInput);
|
|
670
|
+
}
|
|
671
|
+
async clearOrExit(now = Date.now()) {
|
|
672
|
+
this.#promptSuggestions?.invalidate();
|
|
673
|
+
if (now - this.#lastClearTime < 500)
|
|
674
|
+
return this.shutdown();
|
|
675
|
+
this.root.editor.setText("");
|
|
676
|
+
this.#lastClearTime = now;
|
|
677
|
+
this.runtime.requestRender();
|
|
678
|
+
return { outcome: "completed", diagnostic: null };
|
|
679
|
+
}
|
|
680
|
+
async interrupt(now = Date.now()) {
|
|
681
|
+
this.#promptSuggestions?.invalidate();
|
|
682
|
+
if (this.#waitingImages.size > 0) {
|
|
683
|
+
this.#cancelWaitingImages();
|
|
684
|
+
return { outcome: "completed", diagnostic: null };
|
|
685
|
+
}
|
|
686
|
+
if (this.view().lifecycle === "busy")
|
|
687
|
+
return this.abort();
|
|
688
|
+
if (this.root.editor.getText().trim().length > 0) {
|
|
689
|
+
this.root.editor.setText("");
|
|
690
|
+
return { outcome: "completed", diagnostic: null };
|
|
691
|
+
}
|
|
692
|
+
// Compatibility: match Pi: with an empty editor, two escapes inside 500 ms open the
|
|
693
|
+
// configured session navigator. The first escape intentionally does not
|
|
694
|
+
// interrupt or mutate the prompt.
|
|
695
|
+
const action = this.backend.pinnedSettingsSnapshot().doubleEscapeAction;
|
|
696
|
+
if (action === "none")
|
|
697
|
+
return { outcome: "rejected", diagnostic: "nothing to interrupt" };
|
|
698
|
+
if (now - this.#lastEscapeTime < 500) {
|
|
699
|
+
this.#lastEscapeTime = 0;
|
|
700
|
+
if (action === "tree")
|
|
701
|
+
this.showTreeSelector();
|
|
702
|
+
else
|
|
703
|
+
this.showForkSelector();
|
|
704
|
+
return { outcome: "completed", diagnostic: null };
|
|
705
|
+
}
|
|
706
|
+
this.#lastEscapeTime = now;
|
|
707
|
+
return { outcome: "completed", diagnostic: null };
|
|
708
|
+
}
|
|
709
|
+
async abort() {
|
|
710
|
+
return this.#execute(this.#simple("abort"));
|
|
711
|
+
}
|
|
712
|
+
async retry() {
|
|
713
|
+
this.#promptSuggestions?.invalidate();
|
|
714
|
+
return this.#execute(this.#simple("retry"));
|
|
715
|
+
}
|
|
716
|
+
async compact() {
|
|
717
|
+
this.#promptSuggestions?.invalidate();
|
|
718
|
+
return this.#execute(this.#simple("compact"));
|
|
719
|
+
}
|
|
720
|
+
async newSession() {
|
|
721
|
+
this.#promptSuggestions?.invalidate();
|
|
722
|
+
return this.#execute(this.#simple("new-session"));
|
|
723
|
+
}
|
|
724
|
+
async resumeSession(sessionPath) {
|
|
725
|
+
this.#promptSuggestions?.invalidate();
|
|
726
|
+
return this.#execute({
|
|
727
|
+
type: "resume-session",
|
|
728
|
+
correlationId: this.#correlation("resume"),
|
|
729
|
+
sessionId: this.backend.sessionId,
|
|
730
|
+
sessionPath,
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
async setModel(providerId, modelId) {
|
|
734
|
+
this.#promptSuggestions?.invalidate();
|
|
735
|
+
return this.#execute({
|
|
736
|
+
type: "set-model",
|
|
737
|
+
correlationId: this.#correlation("model"),
|
|
738
|
+
sessionId: this.backend.sessionId,
|
|
739
|
+
model: { providerId, modelId, displayName: modelId },
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
async setThinkingLevel(thinkingLevel) {
|
|
743
|
+
return this.#execute({
|
|
744
|
+
type: "set-thinking-level",
|
|
745
|
+
correlationId: this.#correlation("thinking"),
|
|
746
|
+
sessionId: this.backend.sessionId,
|
|
747
|
+
thinkingLevel,
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
async cycleThinkingLevel() {
|
|
751
|
+
const levels = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
752
|
+
const current = Math.max(0, levels.indexOf(this.view().thinkingLevel));
|
|
753
|
+
return this.setThinkingLevel(levels[(current + 1) % levels.length] ?? "off");
|
|
754
|
+
}
|
|
755
|
+
async cycleModel(direction) {
|
|
756
|
+
const result = await this.backend.cycleModelWorkflow(direction);
|
|
757
|
+
this.root.appendWorkflowResult(result);
|
|
758
|
+
if (result.outcome === "completed")
|
|
759
|
+
this.#showDaxnutsForActiveModel();
|
|
760
|
+
this.runtime.requestRender();
|
|
761
|
+
return workflowAdapterResult(result);
|
|
762
|
+
}
|
|
763
|
+
async queueFollowUp() {
|
|
764
|
+
const draft = this.root.editor.getText();
|
|
765
|
+
return this.#submitWhenReady(draft, () => this.#queueFollowUp(draft));
|
|
766
|
+
}
|
|
767
|
+
async #queueFollowUp(draft) {
|
|
768
|
+
const displayInput = draft.trim();
|
|
769
|
+
if (!displayInput)
|
|
770
|
+
return rejected("nothing to queue");
|
|
771
|
+
const prepared = this.root.preparePromptSubmission(displayInput);
|
|
772
|
+
assertPromptImages(prepared.images);
|
|
773
|
+
const text = prepared.text.trim();
|
|
774
|
+
this.#rememberInput(displayInput, "follow-up");
|
|
775
|
+
if (this.root.editor.getText() === draft)
|
|
776
|
+
this.root.editor.setText("");
|
|
777
|
+
this.root.resumeViewportFollowing();
|
|
778
|
+
return this.#execute({
|
|
779
|
+
type: "follow-up",
|
|
780
|
+
correlationId: this.#correlation("follow-up"),
|
|
781
|
+
sessionId: this.backend.sessionId,
|
|
782
|
+
text,
|
|
783
|
+
...(prepared.images.length === 0 ? {} : { images: prepared.images }),
|
|
784
|
+
}, displayInput);
|
|
785
|
+
}
|
|
786
|
+
restoreQueuedInput() {
|
|
787
|
+
const queued = [...this.#waitingImages.keys(), ...this.backend.clearQueuedWorkflows()];
|
|
788
|
+
this.#cancelWaitingImages();
|
|
789
|
+
if (queued.length === 0)
|
|
790
|
+
return;
|
|
791
|
+
this.root.editor.setText(queued.join("\n"));
|
|
792
|
+
this.runtime.requestRender();
|
|
793
|
+
}
|
|
794
|
+
showSelector(title, options, onSelect, onCancel) {
|
|
795
|
+
this.#dialogHandle?.hide();
|
|
796
|
+
this.#dialogSource = "local";
|
|
797
|
+
this.#dialogId = undefined;
|
|
798
|
+
const component = createPiShellSelector({
|
|
799
|
+
title,
|
|
800
|
+
options,
|
|
801
|
+
onSelect: id => {
|
|
802
|
+
onSelect(id);
|
|
803
|
+
this.#dialogHandle?.hide();
|
|
804
|
+
this.#dialogHandle = undefined;
|
|
805
|
+
this.#dialogSource = undefined;
|
|
806
|
+
},
|
|
807
|
+
onCancel: () => {
|
|
808
|
+
this.#dialogHandle?.hide();
|
|
809
|
+
this.#dialogHandle = undefined;
|
|
810
|
+
this.#dialogSource = undefined;
|
|
811
|
+
onCancel?.();
|
|
812
|
+
},
|
|
813
|
+
});
|
|
814
|
+
const handle = this.runtime.showOverlay(component, {
|
|
815
|
+
width: "70%",
|
|
816
|
+
maxHeight: "80%",
|
|
817
|
+
anchor: "center",
|
|
818
|
+
inputCoordination: "owned",
|
|
819
|
+
});
|
|
820
|
+
this.#dialogHandle = handle;
|
|
821
|
+
return handle;
|
|
822
|
+
}
|
|
823
|
+
showThinkingSelector() {
|
|
824
|
+
const snapshot = this.backend.pinnedSettingsSnapshot();
|
|
825
|
+
const close = () => {
|
|
826
|
+
this.root.setInputSurface(null);
|
|
827
|
+
this.runtime.requestRender();
|
|
828
|
+
};
|
|
829
|
+
const select = (level, persist) => {
|
|
830
|
+
close();
|
|
831
|
+
void this.runWorkflow({ command: "thinking", argument: "", selection: level, ...(persist ? { persist: true } : {}) });
|
|
832
|
+
};
|
|
833
|
+
const component = createPiShellThinkingSelector(snapshot.thinkingLevel, snapshot.availableThinkingLevels, level => select(level, false), close, level => select(level, true), snapshot.defaultThinkingLevel);
|
|
834
|
+
this.root.setInputSurface(component);
|
|
835
|
+
this.runtime.requestRender();
|
|
836
|
+
}
|
|
837
|
+
showModelSelector(initialSearchInput) {
|
|
838
|
+
const context = this.backend.pinnedModelSelectorContext();
|
|
839
|
+
const close = () => {
|
|
840
|
+
this.root.setInputSurface(null);
|
|
841
|
+
this.runtime.requestRender();
|
|
842
|
+
};
|
|
843
|
+
const component = createPiShellModelSelector({
|
|
844
|
+
...context,
|
|
845
|
+
runtime: {
|
|
846
|
+
getColumns: () => this.runtime.viewport().columns,
|
|
847
|
+
getRows: () => this.runtime.viewport().rows,
|
|
848
|
+
requestRender: () => this.runtime.requestRender(),
|
|
849
|
+
},
|
|
850
|
+
...(initialSearchInput === undefined ? {} : { initialSearchInput }),
|
|
851
|
+
onSelect: model => {
|
|
852
|
+
close();
|
|
853
|
+
void this.runWorkflow({ command: "model", argument: "", selection: modelReference(model) });
|
|
854
|
+
},
|
|
855
|
+
onSelectAsDefault: model => {
|
|
856
|
+
close();
|
|
857
|
+
void this.runWorkflow({ command: "model", argument: "", selection: modelReference(model), persist: true });
|
|
858
|
+
},
|
|
859
|
+
onCancel: close,
|
|
860
|
+
});
|
|
861
|
+
this.root.setInputSurface(component);
|
|
862
|
+
this.runtime.requestRender();
|
|
863
|
+
}
|
|
864
|
+
showForkSelector() {
|
|
865
|
+
const options = this.backend.pinnedForkOptions();
|
|
866
|
+
if (options.length === 0) {
|
|
867
|
+
this.root.appendWorkflowResult({ command: "fork", outcome: "completed", message: "No messages to fork from", messageKind: "status" });
|
|
868
|
+
this.runtime.requestRender();
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
const close = () => {
|
|
872
|
+
this.root.setInputSurface(null);
|
|
873
|
+
this.runtime.requestRender();
|
|
874
|
+
};
|
|
875
|
+
const component = createPiShellUserMessageSelector(options, selection => {
|
|
876
|
+
close();
|
|
877
|
+
void this.runWorkflow({ command: "fork", argument: "", selection });
|
|
878
|
+
}, close);
|
|
879
|
+
this.root.setInputSurface(component);
|
|
880
|
+
this.runtime.requestRender();
|
|
881
|
+
}
|
|
882
|
+
async showLogoutSelector() {
|
|
883
|
+
let options;
|
|
884
|
+
try {
|
|
885
|
+
options = await this.backend.pinnedLogoutOptions();
|
|
886
|
+
}
|
|
887
|
+
catch (error) {
|
|
888
|
+
this.root.appendWorkflowResult({
|
|
889
|
+
command: "logout",
|
|
890
|
+
outcome: "failed",
|
|
891
|
+
message: `Could not read stored credentials: ${error instanceof Error ? error.message : String(error)}`,
|
|
892
|
+
});
|
|
893
|
+
this.runtime.requestRender();
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (options.length === 0) {
|
|
897
|
+
this.root.appendWorkflowStatus("No stored credentials to remove. /logout only removes credentials saved by /login; environment variables and models.json config are unchanged.");
|
|
898
|
+
this.runtime.requestRender();
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const close = () => {
|
|
902
|
+
this.root.setInputSurface(null);
|
|
903
|
+
this.runtime.requestRender();
|
|
904
|
+
};
|
|
905
|
+
const component = createPiShellAuthProviderSelector("logout", options, selection => {
|
|
906
|
+
close();
|
|
907
|
+
void this.runWorkflow({ command: "logout", argument: "", selection });
|
|
908
|
+
}, close);
|
|
909
|
+
this.root.setInputSurface(component);
|
|
910
|
+
this.runtime.requestRender();
|
|
911
|
+
}
|
|
912
|
+
showLoginMethodSelector(providerReference) {
|
|
913
|
+
const method = this.backend.pinnedLoginMethodOptions(providerReference);
|
|
914
|
+
if (method.options.length === 0) {
|
|
915
|
+
this.showLoginProviderSelector(undefined, providerReference);
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (method.options.length === 1) {
|
|
919
|
+
const selection = method.options[0]?.id;
|
|
920
|
+
if (selection)
|
|
921
|
+
void this.runWorkflow({ command: "login", argument: "", selection });
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
const close = () => {
|
|
925
|
+
this.root.setInputSurface(null);
|
|
926
|
+
this.runtime.requestRender();
|
|
927
|
+
};
|
|
928
|
+
const labels = method.options.map(option => option.label);
|
|
929
|
+
const component = createPiShellExtensionSelector(method.title, labels, label => {
|
|
930
|
+
const selection = method.options.find(option => option.label === label)?.id;
|
|
931
|
+
if (!selection)
|
|
932
|
+
return;
|
|
933
|
+
close();
|
|
934
|
+
void this.runWorkflow({ command: "login", argument: "", selection });
|
|
935
|
+
}, close);
|
|
936
|
+
this.root.setInputSurface(component);
|
|
937
|
+
this.runtime.requestRender();
|
|
938
|
+
}
|
|
939
|
+
showTreeSelector(initialSelectedId) {
|
|
940
|
+
const context = this.backend.pinnedTreeSelectorContext();
|
|
941
|
+
if (context.tree.length === 0) {
|
|
942
|
+
this.root.appendWorkflowStatus("No entries in session");
|
|
943
|
+
this.runtime.requestRender();
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
const close = () => {
|
|
947
|
+
this.root.setInputSurface(null);
|
|
948
|
+
this.runtime.requestRender();
|
|
949
|
+
};
|
|
950
|
+
const component = createPiShellTreeSelector({
|
|
951
|
+
tree: context.tree,
|
|
952
|
+
currentLeafId: context.currentLeafId,
|
|
953
|
+
terminalHeight: this.runtime.viewport().rows,
|
|
954
|
+
initialFilterMode: context.filterMode,
|
|
955
|
+
...(initialSelectedId === undefined ? {} : { initialSelectedId }),
|
|
956
|
+
onLabelChange: context.appendLabelChange,
|
|
957
|
+
onCopy: text => {
|
|
958
|
+
if (!text) {
|
|
959
|
+
this.root.appendWorkflowResult({ command: "tree", outcome: "failed", message: "Selected entry has no text to copy" });
|
|
960
|
+
this.runtime.requestRender();
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
const generation = this.backend.sessionBindingGeneration;
|
|
964
|
+
void this.backend.copyWorkflowText(text).then(acknowledged => {
|
|
965
|
+
if (this.#disposed || generation !== this.backend.sessionBindingGeneration)
|
|
966
|
+
return;
|
|
967
|
+
this.root.appendWorkflowStatus(acknowledged ? "Copied selected message to clipboard" : "Submitted selected message to clipboard");
|
|
968
|
+
this.runtime.requestRender();
|
|
969
|
+
}).catch(error => {
|
|
970
|
+
if (this.#disposed || generation !== this.backend.sessionBindingGeneration)
|
|
971
|
+
return;
|
|
972
|
+
this.root.appendWorkflowResult({ command: "tree", outcome: "failed", message: error instanceof Error ? error.message : String(error) });
|
|
973
|
+
this.runtime.requestRender();
|
|
974
|
+
});
|
|
975
|
+
},
|
|
976
|
+
onCancel: close,
|
|
977
|
+
onSelect: entryId => {
|
|
978
|
+
close();
|
|
979
|
+
if (entryId === context.currentLeafId) {
|
|
980
|
+
this.root.appendWorkflowStatus("Already at this point");
|
|
981
|
+
this.runtime.requestRender();
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
void this.#completeTreeSelection(entryId, context.skipSummaryPrompt);
|
|
985
|
+
},
|
|
986
|
+
});
|
|
987
|
+
this.root.setInputSurface(component);
|
|
988
|
+
this.runtime.requestRender();
|
|
989
|
+
}
|
|
990
|
+
showLoginAuthTypeSelector() {
|
|
991
|
+
const close = () => {
|
|
992
|
+
this.root.setInputSurface(null);
|
|
993
|
+
this.runtime.requestRender();
|
|
994
|
+
};
|
|
995
|
+
const labels = ["Sign in with an account", "Sign in with an API key"];
|
|
996
|
+
const component = createPiShellExtensionSelector("Select authentication method:", labels, label => {
|
|
997
|
+
close();
|
|
998
|
+
this.showLoginProviderSelector(label === labels[0] ? "oauth" : "api_key");
|
|
999
|
+
}, close);
|
|
1000
|
+
this.root.setInputSurface(component);
|
|
1001
|
+
this.runtime.requestRender();
|
|
1002
|
+
}
|
|
1003
|
+
showLoginProviderSelector(authType, initialSearchInput) {
|
|
1004
|
+
const options = this.backend.pinnedLoginOptions(authType);
|
|
1005
|
+
if (options.length === 0) {
|
|
1006
|
+
this.root.appendWorkflowStatus(authType === "oauth" ? "No subscription providers available." : authType === "api_key" ? "No API key providers available." : "No login providers available.");
|
|
1007
|
+
this.runtime.requestRender();
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
const close = () => {
|
|
1011
|
+
this.root.setInputSurface(null);
|
|
1012
|
+
this.runtime.requestRender();
|
|
1013
|
+
};
|
|
1014
|
+
const component = createPiShellAuthProviderSelector("login", options, id => {
|
|
1015
|
+
close();
|
|
1016
|
+
void this.runWorkflow({ command: "login", argument: "", selection: id });
|
|
1017
|
+
}, () => {
|
|
1018
|
+
close();
|
|
1019
|
+
if (authType !== undefined)
|
|
1020
|
+
this.showLoginAuthTypeSelector();
|
|
1021
|
+
}, initialSearchInput);
|
|
1022
|
+
this.root.setInputSurface(component);
|
|
1023
|
+
this.runtime.requestRender();
|
|
1024
|
+
}
|
|
1025
|
+
showSessionSelector() {
|
|
1026
|
+
const context = this.backend.pinnedSessionSelectorContext();
|
|
1027
|
+
const close = () => {
|
|
1028
|
+
this.root.setInputSurface(null);
|
|
1029
|
+
this.runtime.requestRender();
|
|
1030
|
+
};
|
|
1031
|
+
const component = createPiShellSessionSelector({
|
|
1032
|
+
currentSessionsLoader: context.loadCurrentSessions,
|
|
1033
|
+
allSessionsLoader: context.loadAllSessions,
|
|
1034
|
+
currentSessionFilePath: context.currentSessionFilePath,
|
|
1035
|
+
renameSession: context.renameSession,
|
|
1036
|
+
requestRender: () => this.runtime.requestRender(),
|
|
1037
|
+
onSelect: sessionPath => {
|
|
1038
|
+
close();
|
|
1039
|
+
void this.runWorkflow({ command: "resume", argument: sessionPath });
|
|
1040
|
+
},
|
|
1041
|
+
onCancel: close,
|
|
1042
|
+
onExit: () => {
|
|
1043
|
+
close();
|
|
1044
|
+
void this.shutdown();
|
|
1045
|
+
},
|
|
1046
|
+
});
|
|
1047
|
+
this.root.setInputSurface(component);
|
|
1048
|
+
this.runtime.requestRender();
|
|
1049
|
+
}
|
|
1050
|
+
showSettingsSelector() {
|
|
1051
|
+
const snapshot = this.backend.pinnedSettingsSnapshot();
|
|
1052
|
+
const close = () => {
|
|
1053
|
+
this.root.setInputSurface(null);
|
|
1054
|
+
this.runtime.requestRender();
|
|
1055
|
+
};
|
|
1056
|
+
const { currentModel, ...settingsSnapshot } = snapshot;
|
|
1057
|
+
const component = createPiShellSettingsSelector({
|
|
1058
|
+
config: {
|
|
1059
|
+
...settingsSnapshot,
|
|
1060
|
+
availableThinkingLevels: [...snapshot.availableThinkingLevels],
|
|
1061
|
+
availableThemes: [...snapshot.availableThemes],
|
|
1062
|
+
warnings: { ...snapshot.warnings },
|
|
1063
|
+
modelThinkingLevels: { ...snapshot.modelThinkingLevels },
|
|
1064
|
+
...(currentModel === undefined ? {} : { currentModel: currentModel }),
|
|
1065
|
+
availableDefaultModels: snapshot.availableDefaultModels,
|
|
1066
|
+
},
|
|
1067
|
+
onChange: (callback, value) => {
|
|
1068
|
+
if (callback === "onCancel") {
|
|
1069
|
+
close();
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (callback === "onTuiModeChange") {
|
|
1073
|
+
// Invariant: the custom bare-A1 surface is permanently fullscreen; this callback
|
|
1074
|
+
// remains available only to pinned comparison profiles.
|
|
1075
|
+
if (this.#customViewport)
|
|
1076
|
+
return;
|
|
1077
|
+
if (value !== "regular" && value !== "fullscreen")
|
|
1078
|
+
return;
|
|
1079
|
+
if (!this.runtime.switchMode(value)) {
|
|
1080
|
+
this.root.appendWorkflowStatus("Close active overlays before changing TUI mode");
|
|
1081
|
+
this.runtime.requestRender();
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
if (this.#customViewport) {
|
|
1085
|
+
this.#pointerReporting = false;
|
|
1086
|
+
this.#setPointerReporting(true);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
void this.backend.applyPinnedSettingValue(callback, value).then(result => {
|
|
1090
|
+
if (result.outcome === "failed")
|
|
1091
|
+
this.root.appendWorkflowResult(result);
|
|
1092
|
+
else if (callback === "onTuiModeChange")
|
|
1093
|
+
this.root.appendWorkflowStatus(`TUI mode: ${value}`);
|
|
1094
|
+
this.runtime.requestRender();
|
|
1095
|
+
});
|
|
1096
|
+
},
|
|
1097
|
+
onCancel: close,
|
|
1098
|
+
});
|
|
1099
|
+
this.root.setInputSurface(component);
|
|
1100
|
+
this.runtime.requestRender();
|
|
1101
|
+
}
|
|
1102
|
+
shutdown() {
|
|
1103
|
+
this.#shutdownPromise ??= this.#shutdown();
|
|
1104
|
+
return this.#shutdownPromise;
|
|
1105
|
+
}
|
|
1106
|
+
async #shutdown() {
|
|
1107
|
+
try {
|
|
1108
|
+
const result = await this.backend.executeWorkflow({ command: "quit", argument: "" });
|
|
1109
|
+
await this.dispose();
|
|
1110
|
+
return workflowAdapterResult(result);
|
|
1111
|
+
}
|
|
1112
|
+
finally {
|
|
1113
|
+
this.#resolveStoppedLifecycle();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
async runWorkflow(request) {
|
|
1117
|
+
if (request.command === "quit")
|
|
1118
|
+
return this.shutdown();
|
|
1119
|
+
const copyGeneration = request.command === "copy" ? this.backend.sessionBindingGeneration : undefined;
|
|
1120
|
+
if (request.command === "login" && request.selection !== undefined) {
|
|
1121
|
+
const setup = this.backend.pinnedAmbientAuthentication(request.selection);
|
|
1122
|
+
if (setup) {
|
|
1123
|
+
const close = () => {
|
|
1124
|
+
this.root.setInputSurface(null);
|
|
1125
|
+
this.runtime.requestRender();
|
|
1126
|
+
};
|
|
1127
|
+
const dialog = createPiShellLoginDialog({
|
|
1128
|
+
getColumns: () => this.runtime.viewport().columns,
|
|
1129
|
+
getRows: () => this.runtime.viewport().rows,
|
|
1130
|
+
requestRender: () => this.runtime.requestRender(),
|
|
1131
|
+
}, setup.providerId, close, setup.providerName, setup.title);
|
|
1132
|
+
dialog.showInfo(setup.message, [], true);
|
|
1133
|
+
this.root.setInputSurface(dialog);
|
|
1134
|
+
this.runtime.requestRender();
|
|
1135
|
+
return { outcome: "completed", diagnostic: null };
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (request.command === "scoped-models" && request.selection === undefined && request.confirmed === undefined) {
|
|
1139
|
+
this.showScopedModelsSelector();
|
|
1140
|
+
return { outcome: "completed", diagnostic: null };
|
|
1141
|
+
}
|
|
1142
|
+
if (request.command === "model" && request.selection === undefined && request.confirmed === undefined && request.argument.trim().length === 0) {
|
|
1143
|
+
this.showModelSelector();
|
|
1144
|
+
return { outcome: "completed", diagnostic: null };
|
|
1145
|
+
}
|
|
1146
|
+
if (request.command === "fork" && request.selection === undefined && request.confirmed === undefined) {
|
|
1147
|
+
this.showForkSelector();
|
|
1148
|
+
return { outcome: "completed", diagnostic: null };
|
|
1149
|
+
}
|
|
1150
|
+
if (request.command === "thinking" && request.selection === undefined && request.argument.trim().length === 0) {
|
|
1151
|
+
this.showThinkingSelector();
|
|
1152
|
+
return { outcome: "completed", diagnostic: null };
|
|
1153
|
+
}
|
|
1154
|
+
if (request.command === "trust" && request.selection === undefined && request.confirmed === undefined) {
|
|
1155
|
+
this.showTrustSelector();
|
|
1156
|
+
return { outcome: "completed", diagnostic: null };
|
|
1157
|
+
}
|
|
1158
|
+
if (request.command === "settings" && request.selection === undefined && request.confirmed === undefined) {
|
|
1159
|
+
this.showSettingsSelector();
|
|
1160
|
+
return { outcome: "completed", diagnostic: null };
|
|
1161
|
+
}
|
|
1162
|
+
if (request.command === "resume" && request.selection === undefined && request.confirmed === undefined && request.argument.trim().length === 0) {
|
|
1163
|
+
this.showSessionSelector();
|
|
1164
|
+
return { outcome: "completed", diagnostic: null };
|
|
1165
|
+
}
|
|
1166
|
+
if (request.command === "login" && request.selection === undefined && request.confirmed === undefined) {
|
|
1167
|
+
if (request.argument.trim().length === 0)
|
|
1168
|
+
this.showLoginAuthTypeSelector();
|
|
1169
|
+
else
|
|
1170
|
+
this.showLoginMethodSelector(request.argument);
|
|
1171
|
+
return { outcome: "completed", diagnostic: null };
|
|
1172
|
+
}
|
|
1173
|
+
if (request.command === "logout" && request.selection === undefined && request.confirmed === undefined) {
|
|
1174
|
+
await this.showLogoutSelector();
|
|
1175
|
+
return { outcome: "completed", diagnostic: null };
|
|
1176
|
+
}
|
|
1177
|
+
if (request.command === "tree" && request.selection === undefined && request.confirmed === undefined && request.argument.trim().length === 0) {
|
|
1178
|
+
this.showTreeSelector();
|
|
1179
|
+
return { outcome: "completed", diagnostic: null };
|
|
1180
|
+
}
|
|
1181
|
+
if (request.command === "reload") {
|
|
1182
|
+
const blocked = this.backend.reloadBlockedResult();
|
|
1183
|
+
if (blocked) {
|
|
1184
|
+
this.root.appendWorkflowResult(blocked);
|
|
1185
|
+
this.runtime.requestRender();
|
|
1186
|
+
return workflowAdapterResult(blocked);
|
|
1187
|
+
}
|
|
1188
|
+
this.root.resetExtensionUi();
|
|
1189
|
+
}
|
|
1190
|
+
const shareSurface = request.command === "share"
|
|
1191
|
+
? createPiShellOperationLoader({
|
|
1192
|
+
getColumns: () => this.runtime.viewport().columns,
|
|
1193
|
+
getRows: () => this.runtime.viewport().rows,
|
|
1194
|
+
requestRender: () => this.runtime.requestRender(),
|
|
1195
|
+
}, "Creating gist...")
|
|
1196
|
+
: undefined;
|
|
1197
|
+
const operationSurface = shareSurface ?? (request.command === "reload" ? createPiShellReloadBox() : undefined);
|
|
1198
|
+
const now = this.#reloadPresentation?.now ?? Date.now;
|
|
1199
|
+
const shownAt = now();
|
|
1200
|
+
if (operationSurface) {
|
|
1201
|
+
this.root.setInputSurface(operationSurface);
|
|
1202
|
+
this.runtime.requestRender();
|
|
1203
|
+
}
|
|
1204
|
+
let result;
|
|
1205
|
+
try {
|
|
1206
|
+
result = await this.backend.executeWorkflow(shareSurface === undefined ? request : { ...request, signal: shareSurface.signal });
|
|
1207
|
+
}
|
|
1208
|
+
finally {
|
|
1209
|
+
if (operationSurface) {
|
|
1210
|
+
// Rationale: a near-instant reload would flash the box for a frame or skip it entirely; holding it
|
|
1211
|
+
// briefly keeps the reload legible regardless of how fast the resources actually load.
|
|
1212
|
+
if (request.command === "reload")
|
|
1213
|
+
await this.#holdReloadSurface(now() - shownAt);
|
|
1214
|
+
this.root.setInputSurface(null);
|
|
1215
|
+
this.runtime.requestRender();
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
if (copyGeneration !== undefined && (this.#disposed || copyGeneration !== this.backend.sessionBindingGeneration)) {
|
|
1219
|
+
return workflowAdapterResult({ command: "copy", outcome: "cancelled", message: "" });
|
|
1220
|
+
}
|
|
1221
|
+
if (result.outcome === "requires-selection" && request.command === "model") {
|
|
1222
|
+
if (result.messages !== undefined) {
|
|
1223
|
+
for (const message of result.messages)
|
|
1224
|
+
this.root.appendWorkflowMessage(message);
|
|
1225
|
+
}
|
|
1226
|
+
this.showModelSelector((result.detail ?? request.argument.trim()) || undefined);
|
|
1227
|
+
return { outcome: "completed", diagnostic: null };
|
|
1228
|
+
}
|
|
1229
|
+
if (result.outcome === "requires-confirmation" && request.command === "resume") {
|
|
1230
|
+
const confirmed = await this.#extensionBridge.context.confirm("Session cwd not found", result.message);
|
|
1231
|
+
return this.runWorkflow({ ...request, confirmed: confirmed === true });
|
|
1232
|
+
}
|
|
1233
|
+
if (result.outcome === "requires-confirmation" && request.command === "import") {
|
|
1234
|
+
const recoveringCwd = result.detail !== undefined;
|
|
1235
|
+
const confirmed = await this.#extensionBridge.context.confirm(recoveringCwd ? "Session cwd not found" : "Import session", result.message);
|
|
1236
|
+
return this.runWorkflow({
|
|
1237
|
+
...request,
|
|
1238
|
+
confirmed: confirmed === true,
|
|
1239
|
+
...(confirmed === true && result.detail ? { cwdOverride: result.detail } : {}),
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
if (result.outcome === "requires-selection" || result.outcome === "requires-confirmation") {
|
|
1243
|
+
this.root.appendWorkflowResult({ command: request.command, outcome: "failed", message: `Owned controller missing for ${request.command}` });
|
|
1244
|
+
this.runtime.requestRender();
|
|
1245
|
+
return { outcome: "failed", diagnostic: `Owned controller missing for ${request.command}` };
|
|
1246
|
+
}
|
|
1247
|
+
if (request.command === "reload" && result.outcome === "completed") {
|
|
1248
|
+
this.root.resetWorkflowPresentation();
|
|
1249
|
+
this.root.editor.reloadKeybindings();
|
|
1250
|
+
this.root.editor.setAutocompleteCommands(this.backend.workflowAutocompleteCommands());
|
|
1251
|
+
}
|
|
1252
|
+
this.root.appendWorkflowResult(result);
|
|
1253
|
+
if (request.command === "model" && result.outcome === "completed")
|
|
1254
|
+
this.#showDaxnutsForActiveModel();
|
|
1255
|
+
this.runtime.requestRender();
|
|
1256
|
+
return workflowAdapterResult(result);
|
|
1257
|
+
}
|
|
1258
|
+
async #holdReloadSurface(visibleMs) {
|
|
1259
|
+
const minVisibleMs = this.#reloadPresentation?.minVisibleMs ?? RELOAD_SURFACE_MIN_VISIBLE_MS;
|
|
1260
|
+
const remaining = minVisibleMs - visibleMs;
|
|
1261
|
+
if (remaining <= 0 || this.#disposed)
|
|
1262
|
+
return;
|
|
1263
|
+
const sleep = this.#reloadPresentation?.sleep ?? ((ms) => new Promise(resolve => setTimeout(resolve, ms)));
|
|
1264
|
+
await sleep(remaining);
|
|
1265
|
+
}
|
|
1266
|
+
showTrustSelector() {
|
|
1267
|
+
const context = this.backend.pinnedProjectTrustContext();
|
|
1268
|
+
const close = () => {
|
|
1269
|
+
this.root.setInputSurface(null);
|
|
1270
|
+
this.runtime.requestRender();
|
|
1271
|
+
};
|
|
1272
|
+
const component = createPiShellTrustSelector({
|
|
1273
|
+
...context,
|
|
1274
|
+
onSelect: selection => {
|
|
1275
|
+
try {
|
|
1276
|
+
this.backend.persistProjectTrust(selection.updates);
|
|
1277
|
+
close();
|
|
1278
|
+
this.root.appendWorkflowStatus(`Saved trust decision: ${selection.trusted ? "trusted" : "untrusted"}. Restart pi for this to take effect.`);
|
|
1279
|
+
}
|
|
1280
|
+
catch (error) {
|
|
1281
|
+
close();
|
|
1282
|
+
this.root.appendWorkflowResult({ command: "trust", outcome: "failed", message: error instanceof Error ? error.message : String(error) });
|
|
1283
|
+
}
|
|
1284
|
+
this.runtime.requestRender();
|
|
1285
|
+
},
|
|
1286
|
+
onCancel: close,
|
|
1287
|
+
});
|
|
1288
|
+
this.root.setInputSurface(component);
|
|
1289
|
+
this.runtime.requestRender();
|
|
1290
|
+
}
|
|
1291
|
+
showScopedModelsSelector() {
|
|
1292
|
+
const initial = this.backend.pinnedScopedModelsContext();
|
|
1293
|
+
let currentEnabledIds = initial.enabledModelIds === null ? null : [...initial.enabledModelIds];
|
|
1294
|
+
let selectionChanged = false;
|
|
1295
|
+
let disposed = false;
|
|
1296
|
+
let timedOut = false;
|
|
1297
|
+
const controller = new AbortController();
|
|
1298
|
+
const timeout = setTimeout(() => {
|
|
1299
|
+
timedOut = true;
|
|
1300
|
+
controller.abort();
|
|
1301
|
+
}, 15_000);
|
|
1302
|
+
const close = () => {
|
|
1303
|
+
disposed = true;
|
|
1304
|
+
clearTimeout(timeout);
|
|
1305
|
+
controller.abort();
|
|
1306
|
+
this.root.setInputSurface(null);
|
|
1307
|
+
this.runtime.requestRender();
|
|
1308
|
+
};
|
|
1309
|
+
const selector = createPiShellScopedModelsSelector({
|
|
1310
|
+
models: initial.models,
|
|
1311
|
+
enabledModelIds: currentEnabledIds,
|
|
1312
|
+
refreshStatus: "Refreshing model catalogs…",
|
|
1313
|
+
onChange: enabledIds => {
|
|
1314
|
+
selectionChanged = true;
|
|
1315
|
+
currentEnabledIds = enabledIds === null ? null : [...enabledIds];
|
|
1316
|
+
this.backend.updateScopedModels(currentEnabledIds);
|
|
1317
|
+
this.runtime.requestRender();
|
|
1318
|
+
},
|
|
1319
|
+
onPersist: enabledIds => {
|
|
1320
|
+
currentEnabledIds = enabledIds === null ? null : [...enabledIds];
|
|
1321
|
+
this.backend.persistScopedModels(currentEnabledIds);
|
|
1322
|
+
this.root.appendWorkflowStatus("Model selection saved to settings");
|
|
1323
|
+
this.runtime.requestRender();
|
|
1324
|
+
},
|
|
1325
|
+
onCancel: close,
|
|
1326
|
+
});
|
|
1327
|
+
const component = {
|
|
1328
|
+
...selector,
|
|
1329
|
+
dispose: () => {
|
|
1330
|
+
disposed = true;
|
|
1331
|
+
clearTimeout(timeout);
|
|
1332
|
+
controller.abort();
|
|
1333
|
+
selector.dispose?.();
|
|
1334
|
+
},
|
|
1335
|
+
};
|
|
1336
|
+
this.root.setInputSurface(component);
|
|
1337
|
+
this.runtime.requestRender();
|
|
1338
|
+
void this.backend.refreshScopedModels(controller.signal).then(refreshed => {
|
|
1339
|
+
if (disposed)
|
|
1340
|
+
return;
|
|
1341
|
+
if (!selectionChanged) {
|
|
1342
|
+
currentEnabledIds = refreshed.enabledModelIds === null ? null : [...refreshed.enabledModelIds];
|
|
1343
|
+
component.updateModels(refreshed.models, currentEnabledIds);
|
|
1344
|
+
}
|
|
1345
|
+
else {
|
|
1346
|
+
component.updateModels(refreshed.models);
|
|
1347
|
+
this.backend.updateScopedModels(currentEnabledIds);
|
|
1348
|
+
}
|
|
1349
|
+
component.setRefreshStatus(timedOut ? "Model refresh timed out; showing cached models." : refreshed.status, timedOut ? "warning" : refreshed.statusKind);
|
|
1350
|
+
this.runtime.requestRender();
|
|
1351
|
+
}).catch(error => {
|
|
1352
|
+
if (disposed)
|
|
1353
|
+
return;
|
|
1354
|
+
component.setRefreshStatus(timedOut
|
|
1355
|
+
? "Model refresh timed out; showing cached models."
|
|
1356
|
+
: `Could not refresh model catalogs: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
1357
|
+
this.runtime.requestRender();
|
|
1358
|
+
}).finally(() => clearTimeout(timeout));
|
|
1359
|
+
}
|
|
1360
|
+
#showDaxnutsForActiveModel() {
|
|
1361
|
+
const model = this.view().activeModel;
|
|
1362
|
+
if (model?.providerId === "opencode" && model.modelId.toLowerCase().includes("kimi-k2.5")) {
|
|
1363
|
+
this.root.appendDaxnuts();
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
// Invariant: pointer reporting is disabled on every path that ends the owning screen.
|
|
1367
|
+
#setPointerReporting(enabled, forceOff = false) {
|
|
1368
|
+
const effective = forceOff ? false : this.#customViewport || enabled;
|
|
1369
|
+
if (this.#pointerReporting === effective)
|
|
1370
|
+
return;
|
|
1371
|
+
this.#pointerReporting = effective;
|
|
1372
|
+
if (!this.runtime.active)
|
|
1373
|
+
return;
|
|
1374
|
+
this.runtime.writeControl(effective ? MOUSE_TRACKING_ON : MOUSE_TRACKING_OFF);
|
|
1375
|
+
}
|
|
1376
|
+
dispose() {
|
|
1377
|
+
if (this.#disposePromise !== undefined)
|
|
1378
|
+
return this.#disposePromise;
|
|
1379
|
+
if (this.#disposed)
|
|
1380
|
+
return Promise.resolve();
|
|
1381
|
+
const pending = Promise.resolve().then(() => this.#dispose());
|
|
1382
|
+
this.#disposePromise = pending;
|
|
1383
|
+
const clear = () => { if (this.#disposePromise === pending)
|
|
1384
|
+
this.#disposePromise = undefined; };
|
|
1385
|
+
void pending.then(clear, clear);
|
|
1386
|
+
return pending;
|
|
1387
|
+
}
|
|
1388
|
+
async #dispose() {
|
|
1389
|
+
this.#disposed = true;
|
|
1390
|
+
// Invariant: the outro frame is what the terminal shows now, before any cleanup writes.
|
|
1391
|
+
const outroFrame = this.#captureQuitOutroFrame();
|
|
1392
|
+
this.#responseCopy?.dispose();
|
|
1393
|
+
this.#copyExecutor?.dispose();
|
|
1394
|
+
this.#cancelWaitingImages();
|
|
1395
|
+
const failures = [];
|
|
1396
|
+
const attempt = (action) => { try {
|
|
1397
|
+
action();
|
|
1398
|
+
}
|
|
1399
|
+
catch (error) {
|
|
1400
|
+
failures.push(error);
|
|
1401
|
+
} };
|
|
1402
|
+
let pasteCleanup = Promise.resolve();
|
|
1403
|
+
let historyCleanup = Promise.resolve(true);
|
|
1404
|
+
attempt(() => { historyCleanup = this.#promptHistory?.close() ?? Promise.resolve(true); });
|
|
1405
|
+
attempt(() => { pasteCleanup = this.root.disposePendingPastes(); });
|
|
1406
|
+
attempt(() => this.root.clearViewportPointerState());
|
|
1407
|
+
attempt(() => this.#setPointerReporting(false, true));
|
|
1408
|
+
attempt(() => this.#removeViewportPreInput());
|
|
1409
|
+
attempt(() => this.#streamPresentation.dispose());
|
|
1410
|
+
attempt(() => this.#promptSuggestions?.dispose());
|
|
1411
|
+
attempt(() => this.#unsubscribePromptSuggestions());
|
|
1412
|
+
attempt(() => this.#unsubscribeSettings());
|
|
1413
|
+
let fullscreenExitText = "";
|
|
1414
|
+
attempt(() => {
|
|
1415
|
+
const exitMode = this.backend.disposed ? this.#fullscreenExitOutput : this.backend.pinnedSettingsSnapshot().fullscreenExitOutput;
|
|
1416
|
+
const resume = this.backend.currentSessionResumeMetadata();
|
|
1417
|
+
const resumeHint = resume === null ? "" : `${dim("To resume this session:")} ${formatSessionResumeCommand(resume)}`;
|
|
1418
|
+
// Invariant: bare A1 leaves only the hint behind; the pinned comparison profile still
|
|
1419
|
+
// honors fullscreenExitOutput, including the styled transcript.
|
|
1420
|
+
fullscreenExitText = this.runtime.mode !== "fullscreen" ? ""
|
|
1421
|
+
: this.#customViewport || exitMode === "resume-hint" ? resumeHint
|
|
1422
|
+
: [this.root.exitTranscript(this.runtime.viewport().columns), resumeHint].filter(Boolean).join("\n\n");
|
|
1423
|
+
});
|
|
1424
|
+
attempt(() => this.#unbindClipboardWriter());
|
|
1425
|
+
attempt(() => this.#unbindPiSettings());
|
|
1426
|
+
attempt(() => this.#unbindTerminalSettings());
|
|
1427
|
+
attempt(() => this.#unbindShutdownSettings());
|
|
1428
|
+
attempt(() => this.#unsubscribe());
|
|
1429
|
+
attempt(() => this.#dialogHandle?.hide());
|
|
1430
|
+
attempt(() => this.#extensionBridge.dispose());
|
|
1431
|
+
// Invariant: from here to the leave nothing but the outro paints. A throttled frame the
|
|
1432
|
+
// renderer still has queued would otherwise land during the stop-time input drain and
|
|
1433
|
+
// flash the prompt and footer, whether or not an effect plays.
|
|
1434
|
+
attempt(() => this.#freezeQuitPresentation());
|
|
1435
|
+
await this.#playQuitOutro(outroFrame);
|
|
1436
|
+
// Invariant: terminal restoration precedes any potentially stalled backend teardown. The
|
|
1437
|
+
// fullscreen leave preserves the screen: the pinned runtime never dumps its final document
|
|
1438
|
+
// into the parent terminal, so only the configured exit text follows the leave.
|
|
1439
|
+
await this.runtime.dispose({ preserveScreen: this.runtime.mode === "fullscreen" }).catch(error => failures.push(error));
|
|
1440
|
+
await historyCleanup.catch(() => false); // Security: background durability outcomes never enter terminal output.
|
|
1441
|
+
await boundedCleanup(() => pasteCleanup).catch(error => failures.push(error));
|
|
1442
|
+
await boundedCleanup(() => this.backend.unbindExtensionUi()).catch(error => failures.push(error));
|
|
1443
|
+
if (failures.length > 0)
|
|
1444
|
+
throw new AggregateError(failures, "Owned UI disposal failed");
|
|
1445
|
+
if (fullscreenExitText.length > 0)
|
|
1446
|
+
this.runtime.writeAfterStop(`${fullscreenExitText}\n`);
|
|
1447
|
+
}
|
|
1448
|
+
// Invariant: the snapshot is synchronous; the outro module itself loads only at quit.
|
|
1449
|
+
#captureQuitOutroFrame() {
|
|
1450
|
+
const outro = this.#quitOutro;
|
|
1451
|
+
if (outro === undefined || !outro.interactive || !this.#customViewport || this.#damageTerminal === null)
|
|
1452
|
+
return null;
|
|
1453
|
+
if (!this.runtime.active || this.runtime.mode !== "fullscreen")
|
|
1454
|
+
return null;
|
|
1455
|
+
try {
|
|
1456
|
+
const { enabled, effect, durationMs } = outro.snapshot();
|
|
1457
|
+
if (!enabled)
|
|
1458
|
+
return null;
|
|
1459
|
+
const viewport = this.runtime.viewport();
|
|
1460
|
+
return { rows: this.#damageTerminal.presentedRows(), columns: viewport.columns, height: viewport.rows, settings: { effect, durationMs } };
|
|
1461
|
+
}
|
|
1462
|
+
catch {
|
|
1463
|
+
return null;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
#freezeQuitPresentation() {
|
|
1467
|
+
if (!this.#customViewport || !this.runtime.active || this.runtime.mode !== "fullscreen")
|
|
1468
|
+
return;
|
|
1469
|
+
this.runtime.freezePresentation();
|
|
1470
|
+
}
|
|
1471
|
+
// Rationale: any failure here only skips the effect; restoration always follows.
|
|
1472
|
+
async #playQuitOutro(capture) {
|
|
1473
|
+
const outro = this.#quitOutro;
|
|
1474
|
+
if (capture === null || outro === undefined || !this.runtime.active)
|
|
1475
|
+
return;
|
|
1476
|
+
try {
|
|
1477
|
+
// Rationale: the effects stay off the startup graph; quit is the only time they load.
|
|
1478
|
+
const { captureQuitOutroFrame, playQuitOutro } = await import("./quit-outro.js");
|
|
1479
|
+
const frame = captureQuitOutroFrame(capture.rows, capture.columns, capture.height);
|
|
1480
|
+
if (frame === null || !this.runtime.active)
|
|
1481
|
+
return;
|
|
1482
|
+
await playQuitOutro(frame, capture.settings.effect, capture.settings.durationMs, {
|
|
1483
|
+
write: data => this.runtime.writeControl(data),
|
|
1484
|
+
...(outro.now === undefined ? {} : { now: outro.now }),
|
|
1485
|
+
...(outro.sleep === undefined ? {} : { sleep: outro.sleep }),
|
|
1486
|
+
...(outro.seed === undefined ? {} : { seed: outro.seed }),
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
catch {
|
|
1490
|
+
// Rationale: a failed or interrupted effect must never hold the terminal; restoration follows.
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
#settleStoppedLifecycle() {
|
|
1494
|
+
void this.dispose().then(() => this.#resolveStoppedLifecycle(), () => this.#resolveStoppedLifecycle());
|
|
1495
|
+
}
|
|
1496
|
+
#resolveStoppedLifecycle() {
|
|
1497
|
+
const resolve = this.#resolveStopped;
|
|
1498
|
+
this.#resolveStopped = undefined;
|
|
1499
|
+
resolve?.();
|
|
1500
|
+
}
|
|
1501
|
+
// Invariant: incremental block updates notify listeners with the same complete view contract.
|
|
1502
|
+
#syncBlock(block) {
|
|
1503
|
+
this.root.applyTranscriptBlock(block);
|
|
1504
|
+
if (this.#customViewport && block.status === "live" && isCoalescedStreamBlock(block.kind)) {
|
|
1505
|
+
this.#streamPresentation.request();
|
|
1506
|
+
}
|
|
1507
|
+
else if (this.#streamPresentation.pending) {
|
|
1508
|
+
this.#streamPresentation.flush();
|
|
1509
|
+
}
|
|
1510
|
+
else {
|
|
1511
|
+
this.#streamPresentation.presentImmediate();
|
|
1512
|
+
}
|
|
1513
|
+
const view = this.view();
|
|
1514
|
+
for (const listener of this.#listeners)
|
|
1515
|
+
listener(view);
|
|
1516
|
+
return view;
|
|
1517
|
+
}
|
|
1518
|
+
#syncTerminalProgress(view) {
|
|
1519
|
+
if (!this.runtime.active)
|
|
1520
|
+
return;
|
|
1521
|
+
this.runtime.setTerminalProgress(this.#terminalProgressEnabled && view.lifecycle === "busy");
|
|
1522
|
+
}
|
|
1523
|
+
#syncView() {
|
|
1524
|
+
this.#streamPresentation.noteImmediatePresentation();
|
|
1525
|
+
const view = this.view();
|
|
1526
|
+
if (this.backend.sessionGeneration !== this.#sessionGeneration) {
|
|
1527
|
+
this.#responseCopy?.reset();
|
|
1528
|
+
this.#cancelWaitingImages();
|
|
1529
|
+
this.root.resetPendingPastes();
|
|
1530
|
+
this.#promptSuggestions?.invalidate();
|
|
1531
|
+
this.#sessionGeneration = this.backend.sessionGeneration;
|
|
1532
|
+
// Invariant: delivery recovery invalidates callbacks, not same-session local recall or its draft.
|
|
1533
|
+
if (this.#sessionBindingGeneration !== this.backend.sessionBindingGeneration) {
|
|
1534
|
+
this.#sessionBindingGeneration = this.backend.sessionBindingGeneration;
|
|
1535
|
+
this.root.resetTranscript();
|
|
1536
|
+
this.#promptHistory?.reset(view.transcript.flatMap(block => block.kind === "user" ? [block.text] : []));
|
|
1537
|
+
}
|
|
1538
|
+
this.#activeLoginDialog = undefined;
|
|
1539
|
+
this.#extensionBridge.reset();
|
|
1540
|
+
// Invariant: a replaced session takes its transient viewport and owned-route state with it.
|
|
1541
|
+
this.root.resetViewport();
|
|
1542
|
+
this.#dialogHandle?.hide();
|
|
1543
|
+
this.#dialogHandle = undefined;
|
|
1544
|
+
this.#dialogId = undefined;
|
|
1545
|
+
this.#dialogSource = undefined;
|
|
1546
|
+
this.#setPointerReporting(false);
|
|
1547
|
+
this.root.setInputSurface(null);
|
|
1548
|
+
this.root.resetExtensionUi();
|
|
1549
|
+
this.root.resetWorkflowPresentation();
|
|
1550
|
+
}
|
|
1551
|
+
this.root.update(view);
|
|
1552
|
+
this.#syncDialog(view.dialog);
|
|
1553
|
+
this.runtime.requestRender();
|
|
1554
|
+
for (const listener of this.#listeners)
|
|
1555
|
+
listener(view);
|
|
1556
|
+
return view;
|
|
1557
|
+
}
|
|
1558
|
+
#openOwnedRoute(route) {
|
|
1559
|
+
const surface = this.#routeHost?.open(route) ?? null;
|
|
1560
|
+
if (surface === null)
|
|
1561
|
+
return { outcome: "failed", diagnostic: `route is unavailable: ${route}` };
|
|
1562
|
+
if (!this.runtime.active)
|
|
1563
|
+
return { outcome: "failed", diagnostic: "runtime is not active" };
|
|
1564
|
+
this.#dialogHandle?.hide();
|
|
1565
|
+
this.#dialogSource = "route";
|
|
1566
|
+
// Protocol: any-event reporting: hover and drag are what the screen is driven by, and
|
|
1567
|
+
// it also stops the terminal treating a drag as a text selection.
|
|
1568
|
+
this.#setPointerReporting(true);
|
|
1569
|
+
// Protocol: the interrupt chord is global, so it is watched on raw input rather than
|
|
1570
|
+
// through the overlay: the pinned shell handles that key before an overlay
|
|
1571
|
+
// ever sees it, which is why an owned screen must not rely on being asked.
|
|
1572
|
+
let armedAt = 0;
|
|
1573
|
+
const removeInterruptWatch = this.runtime.addInputListener(data => {
|
|
1574
|
+
if (!data.includes(INTERRUPT))
|
|
1575
|
+
return undefined;
|
|
1576
|
+
const now = Date.now();
|
|
1577
|
+
if (armedAt !== 0 && now - armedAt <= INTERRUPT_CHORD_MS) {
|
|
1578
|
+
armedAt = 0;
|
|
1579
|
+
closeSurface();
|
|
1580
|
+
void this.shutdown();
|
|
1581
|
+
return { consume: true };
|
|
1582
|
+
}
|
|
1583
|
+
armedAt = now;
|
|
1584
|
+
this.runtime.requestRender();
|
|
1585
|
+
// Invariant: the presented screen owns the chord, so the pinned shell never sees a
|
|
1586
|
+
// stray interrupt while it is up.
|
|
1587
|
+
return { consume: true };
|
|
1588
|
+
});
|
|
1589
|
+
let removeSurfacePreInput = () => { };
|
|
1590
|
+
const closeSurface = () => {
|
|
1591
|
+
removeSurfacePreInput();
|
|
1592
|
+
removeInterruptWatch();
|
|
1593
|
+
this.#setPointerReporting(false);
|
|
1594
|
+
this.#dialogHandle?.hide();
|
|
1595
|
+
this.#dialogHandle = undefined;
|
|
1596
|
+
this.#dialogId = undefined;
|
|
1597
|
+
this.#dialogSource = undefined;
|
|
1598
|
+
};
|
|
1599
|
+
// Compatibility: fullscreen Pi owns a fallback text-selection layer before focused overlay
|
|
1600
|
+
// components see pointer input. Route every mouse report to the owned screen
|
|
1601
|
+
// at the pre-input boundary so dropdowns, value hover, and numeric +/- work,
|
|
1602
|
+
// and consume even unhandled reports so settings content is never selected.
|
|
1603
|
+
removeSurfacePreInput = this.runtime.addPreInputListener(data => {
|
|
1604
|
+
const { events, rest } = parseMouseInput(data);
|
|
1605
|
+
if (events.length === 0)
|
|
1606
|
+
return undefined;
|
|
1607
|
+
for (const event of events)
|
|
1608
|
+
surface.handleMouse(event);
|
|
1609
|
+
if (surface.isClosed())
|
|
1610
|
+
closeSurface();
|
|
1611
|
+
else
|
|
1612
|
+
this.runtime.requestRender();
|
|
1613
|
+
return rest.length === 0 ? { consume: true } : { data: rest };
|
|
1614
|
+
});
|
|
1615
|
+
const rows = () => Math.max(1, this.runtime.viewport().rows);
|
|
1616
|
+
const component = {
|
|
1617
|
+
render: (width) => [...surface.render(Math.max(1, width), rows())],
|
|
1618
|
+
handleInput: (data) => {
|
|
1619
|
+
const { events, rest } = parseMouseInput(data);
|
|
1620
|
+
for (const event of events)
|
|
1621
|
+
surface.handleMouse(event);
|
|
1622
|
+
if (rest.length > 0)
|
|
1623
|
+
surface.handleInput(rest);
|
|
1624
|
+
if (surface.isClosed()) {
|
|
1625
|
+
closeSurface();
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
this.runtime.requestRender();
|
|
1629
|
+
},
|
|
1630
|
+
invalidate: () => this.runtime.requestRender(),
|
|
1631
|
+
};
|
|
1632
|
+
surface.onRenderRequested(() => this.runtime.requestRender());
|
|
1633
|
+
surface.onExitRequested(() => {
|
|
1634
|
+
closeSurface();
|
|
1635
|
+
void this.shutdown();
|
|
1636
|
+
});
|
|
1637
|
+
this.#dialogHandle = this.runtime.showOverlay(component, {
|
|
1638
|
+
width: "100%",
|
|
1639
|
+
maxHeight: "100%",
|
|
1640
|
+
anchor: "top-left",
|
|
1641
|
+
inputCoordination: "owned",
|
|
1642
|
+
});
|
|
1643
|
+
this.#dialogId = surface.id;
|
|
1644
|
+
return { outcome: "completed", diagnostic: null };
|
|
1645
|
+
}
|
|
1646
|
+
#syncDialog(dialog) {
|
|
1647
|
+
if (!this.runtime.active)
|
|
1648
|
+
return;
|
|
1649
|
+
if (dialog === null) {
|
|
1650
|
+
// Invariant: locally owned routes (notably /settings) are independent of backend
|
|
1651
|
+
// lifecycle/status events and remain open while an agent is working.
|
|
1652
|
+
if (this.#dialogSource !== "backend")
|
|
1653
|
+
return;
|
|
1654
|
+
this.#dialogHandle?.hide();
|
|
1655
|
+
this.#dialogHandle = undefined;
|
|
1656
|
+
this.#dialogId = undefined;
|
|
1657
|
+
this.#dialogSource = undefined;
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
if (this.#dialogSource === "backend" && this.#dialogId === dialog.id)
|
|
1661
|
+
return;
|
|
1662
|
+
this.#dialogHandle?.hide();
|
|
1663
|
+
this.#dialogSource = "backend";
|
|
1664
|
+
const component = createPiShellDialog(dialog, {
|
|
1665
|
+
onSelect: () => {
|
|
1666
|
+
this.#dialogHandle?.hide();
|
|
1667
|
+
this.#dialogHandle = undefined;
|
|
1668
|
+
this.#dialogId = undefined;
|
|
1669
|
+
this.#dialogSource = undefined;
|
|
1670
|
+
},
|
|
1671
|
+
onCancel: () => {
|
|
1672
|
+
this.#dialogHandle?.hide();
|
|
1673
|
+
this.#dialogHandle = undefined;
|
|
1674
|
+
this.#dialogId = undefined;
|
|
1675
|
+
this.#dialogSource = undefined;
|
|
1676
|
+
},
|
|
1677
|
+
});
|
|
1678
|
+
this.#dialogHandle = this.runtime.showOverlay(component, {
|
|
1679
|
+
width: "70%",
|
|
1680
|
+
maxHeight: "80%",
|
|
1681
|
+
anchor: "center",
|
|
1682
|
+
inputCoordination: "owned",
|
|
1683
|
+
});
|
|
1684
|
+
this.#dialogId = dialog.id;
|
|
1685
|
+
}
|
|
1686
|
+
async #slashCommand(text) {
|
|
1687
|
+
const body = text.slice(1).trim();
|
|
1688
|
+
const separator = body.search(/\s/);
|
|
1689
|
+
const name = separator < 0 ? body : body.slice(0, separator);
|
|
1690
|
+
const argument = separator < 0 ? "" : body.slice(separator + 1).trimStart();
|
|
1691
|
+
if (this.#routeHost?.claims(name))
|
|
1692
|
+
return this.#openOwnedRoute(name);
|
|
1693
|
+
if (isWorkflowRoute(name))
|
|
1694
|
+
return this.runWorkflow({ command: name, argument });
|
|
1695
|
+
// Compatibility: unknown slash input, prompt templates, skills, and extension commands remain Pi prompt input.
|
|
1696
|
+
this.#rememberInput(text, "slash");
|
|
1697
|
+
this.root.resumeViewportFollowing();
|
|
1698
|
+
return this.#execute({
|
|
1699
|
+
type: this.view().lifecycle === "busy" ? "steer" : "prompt",
|
|
1700
|
+
correlationId: this.#correlation("prompt-command"),
|
|
1701
|
+
sessionId: this.backend.sessionId,
|
|
1702
|
+
text,
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
async #completeTreeSelection(entryId, skipSummaryPrompt) {
|
|
1706
|
+
let summarize = false;
|
|
1707
|
+
let customInstructions;
|
|
1708
|
+
if (!skipSummaryPrompt) {
|
|
1709
|
+
while (true) {
|
|
1710
|
+
const choice = await this.#extensionBridge.context.select("Summarize branch?", [
|
|
1711
|
+
"No summary",
|
|
1712
|
+
"Summarize",
|
|
1713
|
+
"Summarize with custom prompt",
|
|
1714
|
+
]);
|
|
1715
|
+
if (choice === undefined) {
|
|
1716
|
+
this.showTreeSelector(entryId);
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
summarize = choice !== "No summary";
|
|
1720
|
+
if (choice === "Summarize with custom prompt") {
|
|
1721
|
+
customInstructions = await this.#extensionBridge.context.editor("Custom summarization instructions", "");
|
|
1722
|
+
if (customInstructions === undefined)
|
|
1723
|
+
continue;
|
|
1724
|
+
}
|
|
1725
|
+
break;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
const result = await this.runWorkflow({
|
|
1729
|
+
command: "tree",
|
|
1730
|
+
argument: "",
|
|
1731
|
+
selection: entryId,
|
|
1732
|
+
treeSummary: {
|
|
1733
|
+
summarize,
|
|
1734
|
+
...(customInstructions === undefined ? {} : { customInstructions }),
|
|
1735
|
+
},
|
|
1736
|
+
});
|
|
1737
|
+
if (result.diagnostic === "Branch summarization cancelled")
|
|
1738
|
+
this.showTreeSelector(entryId);
|
|
1739
|
+
}
|
|
1740
|
+
#startWorkflowLogin(request) {
|
|
1741
|
+
this.#finishWorkflowLogin();
|
|
1742
|
+
const dialog = createPiShellLoginDialog({
|
|
1743
|
+
getColumns: () => this.runtime.viewport().columns,
|
|
1744
|
+
getRows: () => this.runtime.viewport().rows,
|
|
1745
|
+
requestRender: () => this.runtime.requestRender(),
|
|
1746
|
+
}, request.providerId, success => {
|
|
1747
|
+
if (!success)
|
|
1748
|
+
this.#finishWorkflowLogin();
|
|
1749
|
+
}, request.providerName);
|
|
1750
|
+
this.#activeLoginDialog = dialog;
|
|
1751
|
+
this.root.setInputSurface(dialog);
|
|
1752
|
+
this.runtime.requestRender();
|
|
1753
|
+
}
|
|
1754
|
+
#requestWorkflowInput(request) {
|
|
1755
|
+
const dialog = this.#activeLoginDialog;
|
|
1756
|
+
if (!dialog)
|
|
1757
|
+
return Promise.resolve(null);
|
|
1758
|
+
if (request.type === "select") {
|
|
1759
|
+
return new Promise(resolve => {
|
|
1760
|
+
const options = request.options ?? [];
|
|
1761
|
+
const labels = options.map(option => option.label);
|
|
1762
|
+
const restoreDialog = () => {
|
|
1763
|
+
if (this.#activeLoginDialog === dialog)
|
|
1764
|
+
this.root.setInputSurface(dialog);
|
|
1765
|
+
this.runtime.requestRender();
|
|
1766
|
+
};
|
|
1767
|
+
const selector = createPiShellExtensionSelector(request.message, labels, label => {
|
|
1768
|
+
const id = options.find(option => option.label === label)?.id;
|
|
1769
|
+
restoreDialog();
|
|
1770
|
+
resolve(id ?? null);
|
|
1771
|
+
}, () => {
|
|
1772
|
+
restoreDialog();
|
|
1773
|
+
resolve(null);
|
|
1774
|
+
});
|
|
1775
|
+
this.root.setInputSurface(selector, false);
|
|
1776
|
+
this.runtime.requestRender();
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
const response = request.type === "manual-code"
|
|
1780
|
+
? dialog.showManualInput(request.message)
|
|
1781
|
+
: dialog.showPrompt(request.message, request.placeholder);
|
|
1782
|
+
this.runtime.requestRender();
|
|
1783
|
+
return response.then(value => value, () => null);
|
|
1784
|
+
}
|
|
1785
|
+
#notifyWorkflowLogin(event) {
|
|
1786
|
+
const dialog = this.#activeLoginDialog;
|
|
1787
|
+
if (!dialog)
|
|
1788
|
+
return;
|
|
1789
|
+
if (event.type === "auth_url")
|
|
1790
|
+
dialog.showAuth(event.url, event.instructions);
|
|
1791
|
+
else if (event.type === "device_code") {
|
|
1792
|
+
dialog.showDeviceCode(event);
|
|
1793
|
+
dialog.showWaiting("Waiting for authentication...");
|
|
1794
|
+
}
|
|
1795
|
+
else if (event.type === "info")
|
|
1796
|
+
dialog.showInfo(event.message, event.links);
|
|
1797
|
+
else if (event.type === "waiting")
|
|
1798
|
+
dialog.showWaiting(event.message);
|
|
1799
|
+
else
|
|
1800
|
+
dialog.showProgress(event.message);
|
|
1801
|
+
this.runtime.requestRender();
|
|
1802
|
+
}
|
|
1803
|
+
#finishWorkflowLogin() {
|
|
1804
|
+
if (!this.#activeLoginDialog)
|
|
1805
|
+
return;
|
|
1806
|
+
this.#activeLoginDialog = undefined;
|
|
1807
|
+
this.root.setInputSurface(null);
|
|
1808
|
+
this.runtime.requestRender();
|
|
1809
|
+
}
|
|
1810
|
+
async #execute(command, draft) {
|
|
1811
|
+
if (draft === undefined)
|
|
1812
|
+
return this.backend.execute(command);
|
|
1813
|
+
const revision = this.#editorRevision;
|
|
1814
|
+
try {
|
|
1815
|
+
assertOwnedUiCommand(command);
|
|
1816
|
+
}
|
|
1817
|
+
catch (error) {
|
|
1818
|
+
return this.#recoverSubmission(draft, revision, error);
|
|
1819
|
+
}
|
|
1820
|
+
try {
|
|
1821
|
+
const result = await this.backend.execute(command);
|
|
1822
|
+
if (result.outcome === "rejected")
|
|
1823
|
+
return this.#recoverSubmission(draft, revision);
|
|
1824
|
+
return result;
|
|
1825
|
+
}
|
|
1826
|
+
catch {
|
|
1827
|
+
// Security: dispatch might already have reached the provider. Never retry automatically.
|
|
1828
|
+
this.root.editor.addToHistory(draft);
|
|
1829
|
+
this.#promptHistory?.rememberRecovery(draft);
|
|
1830
|
+
this.#reportSubmissionError(undefined, "Submission failed; delivery is uncertain. Check the conversation before retrying. Press Up to recover the draft.");
|
|
1831
|
+
return { outcome: "failed", diagnostic: "submission delivery is uncertain" };
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
async #guardSubmission(draft, action) {
|
|
1835
|
+
const revision = this.#editorRevision;
|
|
1836
|
+
try {
|
|
1837
|
+
return await action();
|
|
1838
|
+
}
|
|
1839
|
+
catch (error) {
|
|
1840
|
+
if (error instanceof ImageAttachmentError && error.code === "image-canceled")
|
|
1841
|
+
return rejected("image submission canceled");
|
|
1842
|
+
return this.#recoverSubmission(draft, revision, error);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
#recoverSubmission(draft, revision, error) {
|
|
1846
|
+
this.root.editor.addToHistory(draft);
|
|
1847
|
+
this.#promptHistory?.rememberRecovery(draft);
|
|
1848
|
+
// Concurrency: never overwrite input typed (even typed and cleared) after this submission.
|
|
1849
|
+
if (revision === this.#editorRevision && this.root.editor.getText().length === 0)
|
|
1850
|
+
this.root.editor.setText(draft);
|
|
1851
|
+
const message = error instanceof ImageAttachmentError ? error.message : "Submission rejected. Check the prompt and attachments.";
|
|
1852
|
+
this.#reportSubmissionError(error, `${message} Press Up to recover the draft.`);
|
|
1853
|
+
return rejected(message);
|
|
1854
|
+
}
|
|
1855
|
+
#reportSubmissionError(error, message) {
|
|
1856
|
+
// Security: arbitrary provider/extension error messages can contain the entire request.
|
|
1857
|
+
try {
|
|
1858
|
+
this.root.appendWorkflowResult({ command: "debug", outcome: "failed", message: message
|
|
1859
|
+
?? (error instanceof ImageAttachmentError ? error.message : "Submission failed. Check the prompt and try again.") });
|
|
1860
|
+
this.runtime.requestRender();
|
|
1861
|
+
}
|
|
1862
|
+
catch { /* Security: error presentation cannot create another rejected submission callback. */ }
|
|
1863
|
+
}
|
|
1864
|
+
#simple(type) {
|
|
1865
|
+
return { type, correlationId: this.#correlation(type), sessionId: this.backend.sessionId };
|
|
1866
|
+
}
|
|
1867
|
+
#correlation(prefix) {
|
|
1868
|
+
this.#sequence += 1;
|
|
1869
|
+
return `pi-shell-${prefix}-${this.#sequence}`;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
function isCoalescedStreamBlock(kind) {
|
|
1873
|
+
return kind === "assistant" || kind === "thinking" || kind === "tool-call" || kind === "tool-result";
|
|
1874
|
+
}
|
|
1875
|
+
export function formatSessionResumeCommand(metadata) {
|
|
1876
|
+
const args = [PRODUCT_TEXT.commandName];
|
|
1877
|
+
if (!metadata.usesDefaultSessionDir)
|
|
1878
|
+
args.push("--session-dir", quoteCommandArgument(metadata.sessionDir));
|
|
1879
|
+
args.push("--session", metadata.sessionId);
|
|
1880
|
+
return args.join(" ");
|
|
1881
|
+
}
|
|
1882
|
+
export function quoteCommandArgument(value) {
|
|
1883
|
+
if (value.length > 0 && !/[^a-zA-Z0-9_\-./~:@]/.test(value))
|
|
1884
|
+
return value;
|
|
1885
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
1886
|
+
}
|
|
1887
|
+
function dim(value) {
|
|
1888
|
+
return `\u001b[2m${value}\u001b[22m`;
|
|
1889
|
+
}
|
|
1890
|
+
function modelReference(model) {
|
|
1891
|
+
if (typeof model !== "object" || model === null)
|
|
1892
|
+
return "";
|
|
1893
|
+
const value = model;
|
|
1894
|
+
const provider = typeof value.provider === "string" ? value.provider : "";
|
|
1895
|
+
const id = typeof value.id === "string" ? value.id : typeof value.modelId === "string" ? value.modelId : "";
|
|
1896
|
+
return provider && id ? `${provider}/${id}` : "";
|
|
1897
|
+
}
|
|
1898
|
+
function rejected(diagnostic) {
|
|
1899
|
+
return { outcome: "rejected", diagnostic };
|
|
1900
|
+
}
|
|
1901
|
+
function modelKey(view) {
|
|
1902
|
+
return view.activeModel === null ? "" : `${view.activeModel.providerId}/${view.activeModel.modelId}`;
|
|
1903
|
+
}
|
|
1904
|
+
function workflowAdapterResult(result) {
|
|
1905
|
+
if (result.outcome === "completed")
|
|
1906
|
+
return { outcome: "completed", diagnostic: null };
|
|
1907
|
+
if (result.outcome === "failed")
|
|
1908
|
+
return { outcome: "failed", diagnostic: result.message };
|
|
1909
|
+
return { outcome: "rejected", diagnostic: result.message };
|
|
1910
|
+
}
|
|
1911
|
+
const INTERRUPT = "\u0003";
|
|
1912
|
+
const INTERRUPT_CHORD_MS = 1_500;
|
|
1913
|
+
const RELOAD_SURFACE_MIN_VISIBLE_MS = 400;
|
|
1914
|
+
function isWorkflowRoute(value) {
|
|
1915
|
+
return PINNED_PI_WORKFLOW_COMMAND_NAMES.includes(value)
|
|
1916
|
+
|| PINNED_PI_HIDDEN_COMMAND_NAMES.includes(value);
|
|
1917
|
+
}
|