tmux-ide 2.8.0 → 2.9.0-beta.14
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 +88 -125
- package/bin/cli.js +75949 -12803
- package/package.json +74 -37
- package/packages/contracts/package.json +9 -3
- package/packages/contracts/src/__tests__/actions-contract.test.ts +119 -0
- package/packages/contracts/src/__tests__/agent-graph-overlay.test.ts +428 -0
- package/packages/contracts/src/__tests__/app-window-mutation.test.ts +51 -0
- package/packages/contracts/src/__tests__/app-window-state.test.ts +34 -0
- package/packages/contracts/src/__tests__/application-shell.test.ts +635 -0
- package/packages/contracts/src/__tests__/causal-cell.test.ts +47 -0
- package/packages/contracts/src/__tests__/client-view-state.test.ts +115 -0
- package/packages/contracts/src/__tests__/cohesion-fixture.test.ts +106 -0
- package/packages/contracts/src/__tests__/commands.test.ts +86 -0
- package/packages/contracts/src/__tests__/daemon-events.test.ts +400 -0
- package/packages/contracts/src/__tests__/daemon-resources.test.ts +143 -0
- package/packages/contracts/src/__tests__/daemon-wire.test.ts +117 -0
- package/packages/contracts/src/__tests__/desktop-host.test.ts +269 -0
- package/packages/contracts/src/__tests__/desktop-missions.test.ts +211 -0
- package/packages/contracts/src/__tests__/experience-conformance.test.ts +153 -0
- package/packages/contracts/src/__tests__/experience-kernel-boundary.test.ts +109 -0
- package/packages/contracts/src/__tests__/experience-shell.test.ts +65 -0
- package/packages/contracts/src/__tests__/fixtures/daemon-wire-v2.json +35 -0
- package/packages/contracts/src/__tests__/fleet-agent-graph.test.ts +231 -0
- package/packages/contracts/src/__tests__/fleet-catalog.test.ts +268 -0
- package/packages/contracts/src/__tests__/fleet-lifecycle.test.ts +62 -0
- package/packages/contracts/src/__tests__/focus-overlay.test.ts +110 -0
- package/packages/contracts/src/__tests__/ide-config.test.ts +18 -0
- package/packages/contracts/src/__tests__/issue-error.test.ts +78 -0
- package/packages/contracts/src/__tests__/mission-projections.test.ts +186 -0
- package/packages/contracts/src/__tests__/missions.test.ts +272 -0
- package/packages/contracts/src/__tests__/multiplexer-verbs.test.ts +240 -0
- package/packages/contracts/src/__tests__/pane-appearance.test.ts +146 -0
- package/packages/contracts/src/__tests__/pane-stream.test.ts +488 -0
- package/packages/contracts/src/__tests__/pane-widget-marker.test.ts +327 -0
- package/packages/contracts/src/__tests__/performance-metrics.test.ts +73 -0
- package/packages/contracts/src/__tests__/performance-qualification.test.ts +137 -0
- package/packages/contracts/src/__tests__/rich-card-widget.test.ts +29 -0
- package/packages/contracts/src/__tests__/session-runtime.test.ts +504 -0
- package/packages/contracts/src/__tests__/startup-readiness.test.ts +409 -0
- package/packages/contracts/src/__tests__/terminal-attachment-stream.test.ts +72 -0
- package/packages/contracts/src/__tests__/terminal-attachments.test.ts +329 -0
- package/packages/contracts/src/__tests__/terminal-delivery.test.ts +88 -0
- package/packages/contracts/src/__tests__/terminal-runtime-inventory.test.ts +68 -0
- package/packages/contracts/src/__tests__/transport-contract-loading.test.ts +91 -0
- package/packages/contracts/src/__tests__/visual-tokens.test.ts +224 -0
- package/packages/contracts/src/__tests__/workspace-changes-resource.test.ts +317 -0
- package/packages/contracts/src/__tests__/workspace-changes-view.test.ts +122 -0
- package/packages/contracts/src/__tests__/workspace-config.test.ts +294 -0
- package/packages/contracts/src/__tests__/workspace-files-resource.test.ts +261 -0
- package/packages/contracts/src/__tests__/workspace-files-tree.test.ts +147 -0
- package/packages/contracts/src/__tests__/workspace-pane-creation.test.ts +249 -0
- package/packages/contracts/src/__tests__/workspace-promotion.test.ts +94 -0
- package/packages/contracts/src/__tests__/workspace-resource-identity.test.ts +90 -0
- package/packages/contracts/src/actions-contract.ts +205 -0
- package/packages/contracts/src/actions-errors.ts +20 -0
- package/packages/contracts/src/agent-graph-overlay.ts +425 -0
- package/packages/contracts/src/app-window-mutation.ts +101 -0
- package/packages/contracts/src/app-window-state.ts +446 -0
- package/packages/contracts/src/application-shell-resource.ts +54 -0
- package/packages/contracts/src/application-shell.ts +1094 -0
- package/packages/contracts/src/causal-cell.ts +168 -0
- package/packages/contracts/src/client-view-state.ts +156 -0
- package/packages/contracts/src/cohesion-fixture.ts +647 -0
- package/packages/contracts/src/commands.ts +153 -0
- package/packages/contracts/src/daemon-events.ts +374 -0
- package/packages/contracts/src/daemon-resource-request.test.ts +192 -0
- package/packages/contracts/src/daemon-resource-request.ts +397 -0
- package/packages/contracts/src/daemon-resources.ts +108 -0
- package/packages/contracts/src/daemon-wire.ts +100 -0
- package/packages/contracts/src/desktop-daemon-capability-error.ts +31 -0
- package/packages/contracts/src/desktop-daemon-issue.ts +83 -0
- package/packages/contracts/src/desktop-host.ts +728 -0
- package/packages/contracts/src/desktop-missions.ts +159 -0
- package/packages/contracts/src/desktop-update.ts +48 -0
- package/packages/contracts/src/desktop-workspace-name.ts +18 -0
- package/packages/contracts/src/domain.ts +493 -0
- package/packages/contracts/src/experience-identifiers.ts +53 -0
- package/packages/contracts/src/experience-shell.ts +249 -0
- package/packages/contracts/src/fleet-agent-graph.ts +171 -0
- package/packages/contracts/src/fleet-catalog.ts +190 -0
- package/packages/contracts/src/fleet-lifecycle.ts +136 -0
- package/packages/contracts/src/focus-overlay.ts +175 -0
- package/packages/contracts/src/ide-config.ts +40 -20
- package/packages/contracts/src/index.ts +70 -0
- package/packages/contracts/src/interaction-receipts.ts +438 -0
- package/packages/contracts/src/issue-error.ts +107 -0
- package/packages/contracts/src/mission-projections.ts +269 -0
- package/packages/contracts/src/multiplexer-verbs.ts +447 -0
- package/packages/contracts/src/pane-appearance.ts +248 -0
- package/packages/contracts/src/pane-stream.ts +711 -0
- package/packages/contracts/src/pane-widget-descriptor.ts +62 -0
- package/packages/contracts/src/pane-widget-marker.ts +301 -0
- package/packages/contracts/src/performance-metrics.ts +128 -0
- package/packages/contracts/src/performance-qualification.ts +276 -0
- package/packages/contracts/src/rich-card-widget.ts +72 -0
- package/packages/contracts/src/saved-machines.ts +50 -0
- package/packages/contracts/src/semantic-identity.ts +39 -0
- package/packages/contracts/src/session-runtime.ts +364 -0
- package/packages/contracts/src/shared-monotonic-clock.ts +18 -0
- package/packages/contracts/src/startup-readiness.ts +432 -0
- package/packages/contracts/src/terminal-attachment-stream.ts +119 -0
- package/packages/contracts/src/terminal-attachments.ts +347 -0
- package/packages/contracts/src/terminal-delivery.ts +245 -0
- package/packages/contracts/src/terminal-replica.ts +133 -0
- package/packages/contracts/src/terminal-runtime-inventory.ts +42 -0
- package/packages/contracts/src/visual-recipes.ts +126 -0
- package/packages/contracts/src/visual-theme-presets.ts +499 -0
- package/packages/contracts/src/visual-tokens.ts +883 -0
- package/packages/contracts/src/widget-asset.ts +43 -0
- package/packages/contracts/src/workspace-catalog-resource.test.ts +146 -0
- package/packages/contracts/src/workspace-catalog-resource.ts +180 -0
- package/packages/contracts/src/workspace-changes-resource.ts +405 -0
- package/packages/contracts/src/workspace-changes-view.ts +195 -0
- package/packages/contracts/src/workspace-config.ts +303 -0
- package/packages/contracts/src/workspace-files-resource.ts +310 -0
- package/packages/contracts/src/workspace-files-tree.ts +167 -0
- package/packages/contracts/src/workspace-missions-resource.ts +32 -0
- package/packages/contracts/src/workspace-multiplexer.ts +373 -0
- package/packages/contracts/src/workspace-open-handoff.ts +99 -0
- package/packages/contracts/src/workspace-open.ts +62 -0
- package/packages/contracts/src/workspace-pane-creation.ts +221 -0
- package/packages/contracts/src/workspace-promotion.ts +107 -0
- package/packages/contracts/src/workspace-resource-identity.ts +81 -0
- package/packages/contracts/src/workspace-state.ts +530 -0
- package/packages/contracts/src/workspace.ts +14 -2
- package/packages/core/package.json +35 -0
- package/packages/core/src/agent-provisioning.test.ts +42 -0
- package/packages/core/src/agent-provisioning.ts +112 -0
- package/packages/core/src/app-window-identity.ts +33 -0
- package/packages/core/src/application-shell-session.test.ts +105 -0
- package/packages/core/src/application-shell-session.ts +195 -0
- package/packages/core/src/index.ts +17 -0
- package/packages/core/src/interaction-flow.test.ts +66 -0
- package/packages/core/src/interaction-flow.ts +159 -0
- package/packages/core/src/interaction-receipts.test.ts +361 -0
- package/packages/core/src/interaction-receipts.ts +336 -0
- package/packages/core/src/navigator.test.ts +34 -0
- package/packages/core/src/navigator.ts +74 -0
- package/packages/core/src/optimistic-projection-conformance.test.ts +75 -0
- package/packages/core/src/optimistic-projection-conformance.ts +61 -0
- package/packages/core/src/optimistic-projection-store.ts +71 -0
- package/packages/core/src/optimistic-projection.test.ts +118 -0
- package/packages/core/src/optimistic-projection.ts +194 -0
- package/packages/core/src/performance-metrics.test.ts +121 -0
- package/packages/core/src/performance-metrics.ts +241 -0
- package/packages/core/src/performance-qualification.test.ts +283 -0
- package/packages/core/src/performance-qualification.ts +360 -0
- package/packages/core/src/saved-machines.test.ts +80 -0
- package/packages/core/src/saved-machines.ts +53 -0
- package/packages/core/src/terminal-compact-capability.ts +31 -0
- package/packages/core/src/terminal-compact-cold.test.ts +87 -0
- package/packages/core/src/terminal-conformance.test.ts +48 -0
- package/packages/core/src/terminal-conformance.ts +405 -0
- package/packages/core/src/terminal-delivery-cache-lifetime.test.ts +167 -0
- package/packages/core/src/terminal-delivery-encode-cooperative.test.ts +140 -0
- package/packages/core/src/terminal-delivery.test.ts +1471 -0
- package/packages/core/src/terminal-delivery.ts +3154 -0
- package/packages/core/src/terminal-fnv64-wasm-bytes.ts +20 -0
- package/packages/core/src/terminal-fnv64-wasm.test.ts +61 -0
- package/packages/core/src/terminal-fnv64-wasm.ts +110 -0
- package/packages/core/src/terminal-replica-cold.test.ts +31 -0
- package/packages/core/src/terminal-replica-cooperative.test.ts +170 -0
- package/packages/core/src/terminal-replica-hash-cache.test.ts +283 -0
- package/packages/core/src/terminal-replica-hash-cache.ts +399 -0
- package/packages/core/src/terminal-replica.test.ts +347 -0
- package/packages/core/src/terminal-replica.ts +1149 -0
- package/packages/core/src/workspace-selection.test.ts +63 -0
- package/packages/core/src/workspace-selection.ts +97 -0
- package/packages/daemon/dist/attach.js +2 -2
- package/packages/daemon/dist/canonical.js +1 -1
- package/packages/daemon/dist/cli.js +38 -37
- package/packages/daemon/dist/command-center/actions/command-definitions.js +70 -0
- package/packages/daemon/dist/command-center/actions/dispatcher.js +228 -10
- package/packages/daemon/dist/command-center/actions/handlers/_project-context.js +3 -4
- package/packages/daemon/dist/command-center/actions/handlers/app-set-remote-access.js +6 -2
- package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.js +39 -0
- package/packages/daemon/dist/command-center/actions/handlers/config-actions.js +44 -20
- package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.js +11 -1
- package/packages/daemon/dist/command-center/actions/handlers/fleet-lifecycle.js +56 -0
- package/packages/daemon/dist/command-center/actions/handlers/project-launch.js +16 -4
- package/packages/daemon/dist/command-center/actions/handlers/workspace-multiplexer.js +55 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-open.js +89 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-pane-create.js +34 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-promote.js +34 -0
- package/packages/daemon/dist/command-center/actions/registry.js +126 -0
- package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.js +16 -0
- package/packages/daemon/dist/command-center/agent-status-watch.js +170 -0
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +395 -0
- package/packages/daemon/dist/command-center/discovery.js +262 -3
- package/packages/daemon/dist/command-center/owner-authority.js +46 -0
- package/packages/daemon/dist/command-center/pane-stream-issue.js +185 -0
- package/packages/daemon/dist/command-center/resources/agent-graph-overlay.js +234 -0
- package/packages/daemon/dist/command-center/resources/application-shell.js +641 -0
- package/packages/daemon/dist/command-center/resources/desktop-missions.js +132 -0
- package/packages/daemon/dist/command-center/resources/fleet-catalog.js +163 -0
- package/packages/daemon/dist/command-center/resources/fleet-resource-route.js +48 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness-route.js +121 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness.js +183 -0
- package/packages/daemon/dist/command-center/resources/terminal-native-backing-route.js +92 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +24 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-authority.js +451 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-git.js +222 -0
- package/packages/daemon/dist/command-center/resources/workspace-files-authority.js +493 -0
- package/packages/daemon/dist/command-center/resources/workspace-missions-route.js +75 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-ids.js +69 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-routes.js +116 -0
- package/packages/daemon/dist/command-center/server.js +540 -51
- package/packages/daemon/dist/command-center/terminal-attachment-issue.js +191 -0
- package/packages/daemon/dist/command-center/workspace-resource-observer.js +453 -0
- package/packages/daemon/dist/command-center/ws-events.js +681 -63
- package/packages/daemon/dist/config.js +31 -25
- package/packages/daemon/dist/control/lifecycle.js +12 -2
- package/packages/daemon/dist/control/server.js +3 -3
- package/packages/daemon/dist/detect.js +23 -20
- package/packages/daemon/dist/doctor.js +25 -8
- package/packages/daemon/dist/index.js +20 -1
- package/packages/daemon/dist/init.js +24 -22
- package/packages/daemon/dist/inspect.js +33 -8
- package/packages/daemon/dist/launch.js +38 -26
- package/packages/daemon/dist/lib/__tests__/fixtures/workspace-state-writer.js +58 -0
- package/packages/daemon/dist/lib/agent-kind.js +24 -0
- package/packages/daemon/dist/lib/app-config.js +29 -1
- package/packages/daemon/dist/lib/app-window-kernel.js +556 -0
- package/packages/daemon/dist/lib/app-window-mutation.js +139 -0
- package/packages/daemon/dist/lib/app-window-repository.js +368 -0
- package/packages/daemon/dist/lib/app-window-state.js +415 -0
- package/packages/daemon/dist/lib/application-shell-app-windows.js +285 -0
- package/packages/daemon/dist/lib/auth/middleware.js +7 -3
- package/packages/daemon/dist/lib/bundled-tmux.js +93 -0
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +276 -0
- package/packages/daemon/dist/lib/canonical-daemon.js +507 -70
- package/packages/daemon/dist/lib/chrome-front-door.js +13 -0
- package/packages/daemon/dist/lib/cli-action-bridge.js +112 -82
- package/packages/daemon/dist/lib/command-registry.js +107 -0
- package/packages/daemon/dist/lib/config-context.js +34 -0
- package/packages/daemon/dist/lib/daemon-embed.js +1072 -363
- package/packages/daemon/dist/lib/daemon-session-monitor.js +194 -0
- package/packages/daemon/dist/lib/daemon.js +3 -47
- package/packages/daemon/dist/lib/directory-watcher.js +118 -0
- package/packages/daemon/dist/lib/embedded-daemon-lifecycle.js +102 -0
- package/packages/daemon/dist/lib/environment-identity.js +79 -0
- package/packages/daemon/dist/lib/fleet-agent-lifecycle.js +65 -0
- package/packages/daemon/dist/lib/fleet-lifecycle-authority.js +437 -0
- package/packages/daemon/dist/lib/headless-daemon.js +353 -0
- package/packages/daemon/dist/lib/launch-plan.js +96 -1
- package/packages/daemon/dist/lib/legacy-config-adapter.js +19 -0
- package/packages/daemon/dist/lib/legacy-config-migration.js +110 -0
- package/packages/daemon/dist/lib/legacy-theme-compat.js +25 -0
- package/packages/daemon/dist/lib/mission-projections.js +615 -0
- package/packages/daemon/dist/lib/mission-repository.js +775 -0
- package/packages/daemon/dist/lib/onboarding-marker.js +51 -0
- package/packages/daemon/dist/lib/pane-chrome.js +12 -0
- package/packages/daemon/dist/lib/pane-source-credentials.js +178 -0
- package/packages/daemon/dist/lib/pane-widget.js +126 -0
- package/packages/daemon/dist/lib/project-inspect.js +4 -0
- package/packages/daemon/dist/lib/project-onboard.js +17 -21
- package/packages/daemon/dist/lib/project-probe.js +28 -22
- package/packages/daemon/dist/lib/project-readiness-probe.js +425 -0
- package/packages/daemon/dist/lib/project-readiness.js +680 -0
- package/packages/daemon/dist/lib/project-registry.js +42 -9
- package/packages/daemon/dist/lib/project-resolver.js +245 -0
- package/packages/daemon/dist/lib/project-runtime-errors.js +21 -0
- package/packages/daemon/dist/lib/project-runtime-repository.js +876 -0
- package/packages/daemon/dist/lib/remote-daemon-info.js +21 -0
- package/packages/daemon/dist/lib/resolved-config.js +318 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +136 -0
- package/packages/daemon/dist/lib/saved-machines.js +53 -0
- package/packages/daemon/dist/lib/semantic-resource-id.js +14 -0
- package/packages/daemon/dist/lib/session-monitor.js +29 -23
- package/packages/daemon/dist/lib/session-options.js +3 -10
- package/packages/daemon/dist/lib/ssh-daemon-transport.js +280 -0
- package/packages/daemon/dist/lib/state-home.js +2 -3
- package/packages/daemon/dist/lib/theme-mode.js +9 -0
- package/packages/daemon/dist/lib/tmux-authority-replacement.js +102 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +534 -0
- package/packages/daemon/dist/lib/tmux-interaction-options.js +126 -0
- package/packages/daemon/dist/lib/tmux-named-socket-fence.js +61 -0
- package/packages/daemon/dist/lib/tmux-terminal-color.js +37 -0
- package/packages/daemon/dist/lib/tui-binary.js +291 -28
- package/packages/daemon/dist/lib/unix-socket-authority.js +48 -0
- package/packages/daemon/dist/lib/widget-asset-policy.js +3 -0
- package/packages/daemon/dist/lib/widget-asset-store.js +166 -0
- package/packages/daemon/dist/lib/workspace-config-loader.js +280 -0
- package/packages/daemon/dist/lib/workspace-multiplexer-verbs.js +1138 -0
- package/packages/daemon/dist/lib/workspace-open-handoff.js +219 -0
- package/packages/daemon/dist/lib/workspace-open.js +740 -0
- package/packages/daemon/dist/lib/workspace-pane-creation.js +1137 -0
- package/packages/daemon/dist/lib/workspace-promotion.js +809 -0
- package/packages/daemon/dist/lib/workspace-registry.js +150 -23
- package/packages/daemon/dist/lib/workspace-state-repository.js +790 -0
- package/packages/daemon/dist/lib/workspace-state.js +765 -0
- package/packages/daemon/dist/lib/yaml-io.js +4 -18
- package/packages/daemon/dist/migrate.js +105 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/COPYING +13 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/lib/libevent_core-2.1.7.dylib +0 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/lib/libncursesw.6.dylib +0 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/lib/libutf8proc.3.2.3.dylib +0 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/licenses/libevent_core-2.1.7.dylib.txt +99 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/licenses/libncursesw.6.dylib.txt +29 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/licenses/libutf8proc.3.2.3.dylib.txt +93 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/manifest.json +21 -0
- package/packages/daemon/dist/native/tmux/darwin-arm64/tmux +0 -0
- package/packages/daemon/dist/restart.js +2 -2
- package/packages/daemon/dist/restore.js +10 -6
- package/packages/daemon/dist/schemas/inspect.js +9 -1
- package/packages/daemon/dist/schemas/registry.js +5 -19
- package/packages/daemon/dist/schemas/ws-events.js +4 -107
- package/packages/daemon/dist/send.js +106 -3
- package/packages/daemon/dist/server/index.js +4 -2
- package/packages/daemon/dist/server/pane-stream-upgrade.js +117 -0
- package/packages/daemon/dist/server/terminal-attachment-upgrade.js +121 -0
- package/packages/daemon/dist/status.js +11 -8
- package/packages/daemon/dist/stop.js +2 -2
- package/packages/daemon/dist/terminal/MonotonicPtyInput.js +130 -0
- package/packages/daemon/dist/terminal/NodePtyAdapter.js +37 -10
- package/packages/daemon/dist/terminal/PtyAdapter.js +18 -0
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.js +33 -6
- package/packages/daemon/dist/terminal/attachments/admission-util.js +87 -0
- package/packages/daemon/dist/terminal/attachments/agent-status-probe.js +325 -0
- package/packages/daemon/dist/terminal/attachments/direct-websocket.js +1069 -0
- package/packages/daemon/dist/terminal/attachments/grouped-tmux.js +213 -0
- package/packages/daemon/dist/terminal/attachments/lease-manager.js +655 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +1597 -0
- package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.js +607 -0
- package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.js +208 -0
- package/packages/daemon/dist/terminal/attachments/tmux-view-executor.js +825 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.js +90 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.js +147 -0
- package/packages/daemon/dist/terminal/mirror/control-channel.js +768 -0
- package/packages/daemon/dist/terminal/mirror/control-mode-ownership.js +30 -0
- package/packages/daemon/dist/terminal/mirror/flow-ledger.js +56 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +338 -0
- package/packages/daemon/dist/terminal/mirror/native-frozen-grid.js +128 -0
- package/packages/daemon/dist/terminal/mirror/native-grid-capture.js +179 -0
- package/packages/daemon/dist/terminal/mirror/native-grid-projection.js +99 -0
- package/packages/daemon/dist/terminal/mirror/native-grid-reader.js +81 -0
- package/packages/daemon/dist/terminal/mirror/native-grid-reflow.js +207 -0
- package/packages/daemon/dist/terminal/mirror/pane-feed.js +209 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +2774 -0
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +245 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +2067 -0
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +53 -0
- package/packages/daemon/dist/terminal/pane-stream/wire-ledger.js +110 -0
- package/packages/daemon/dist/terminal/protocol/chunk-bytes.js +21 -0
- package/packages/daemon/dist/terminal/protocol/control.js +111 -0
- package/packages/daemon/dist/terminal/protocol/input-coalescer.js +125 -0
- package/packages/daemon/dist/terminal/protocol/layout-parse.js +127 -0
- package/packages/daemon/dist/terminal/protocol/native-backing-client.js +44 -0
- package/packages/daemon/dist/terminal/protocol/pane-display-name.js +155 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +294 -0
- package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.js +213 -0
- package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.js +266 -0
- package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.js +278 -0
- package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.js +147 -0
- package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.js +116 -0
- package/packages/daemon/dist/terminal/session-runtime/native-seed-backing.js +41 -0
- package/packages/daemon/dist/terminal/session-runtime/registry.js +1390 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-observability.js +72 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.js +16 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.js +48 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.js +353 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-resource-changes.js +32 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +1770 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.js +9 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +582 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +568 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.js +21 -0
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +474 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +515 -0
- package/packages/daemon/dist/tui/async-disposable-slot.js +57 -0
- package/packages/daemon/dist/tui/chrome/cheatsheet.js +211 -0
- package/packages/daemon/dist/tui/chrome/chip.js +25 -0
- package/packages/daemon/dist/tui/chrome/events.js +94 -0
- package/packages/daemon/dist/tui/chrome/front-door.js +16 -0
- package/packages/daemon/dist/tui/chrome/kitty-keys.js +54 -0
- package/packages/daemon/dist/tui/chrome/menu.js +251 -0
- package/packages/daemon/dist/tui/chrome/notify-prefs.js +13 -0
- package/packages/daemon/dist/tui/chrome/notify-state.js +77 -0
- package/packages/daemon/dist/tui/chrome/notify.js +711 -0
- package/packages/daemon/dist/tui/chrome/panels.js +60 -0
- package/packages/daemon/dist/tui/chrome/sidebar.js +183 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +290 -0
- package/packages/daemon/dist/tui/chrome/statusline.js +552 -0
- package/packages/daemon/dist/tui/chrome/updater.js +651 -0
- package/packages/daemon/dist/tui/chrome/welcome.js +117 -0
- package/packages/daemon/dist/tui/compiled.js +194 -0
- package/packages/daemon/dist/tui/detect/agent-resolution.js +60 -0
- package/packages/daemon/dist/tui/detect/classify.js +184 -0
- package/packages/daemon/dist/tui/detect/manifest-loader.js +242 -0
- package/packages/daemon/dist/tui/detect/manifest.js +126 -0
- package/packages/daemon/dist/tui/detect/manifests.js +535 -0
- package/packages/daemon/dist/tui/detect/process-tree.js +194 -0
- package/packages/daemon/dist/tui/detect/session-id.js +414 -0
- package/packages/daemon/dist/tui/detect/snapshot.js +81 -0
- package/packages/daemon/dist/tui/integrations/claude.js +151 -0
- package/packages/daemon/dist/tui/integrations/offer.js +134 -0
- package/packages/daemon/dist/tui/integrations/opencode.js +117 -0
- package/packages/daemon/dist/tui/mirror/ack-writer.js +78 -0
- package/packages/daemon/dist/tui/mirror/activity-surface-view.jsx +69 -0
- package/packages/daemon/dist/tui/mirror/activity-surface.js +271 -0
- package/packages/daemon/dist/tui/mirror/agent-chip.js +84 -0
- package/packages/daemon/dist/tui/mirror/agent-lifecycle.js +372 -0
- package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.js +111 -0
- package/packages/daemon/dist/tui/mirror/agent-rows.js +126 -0
- package/packages/daemon/dist/tui/mirror/ansi-palette.js +3 -0
- package/packages/daemon/dist/tui/mirror/app-state.js +294 -0
- package/packages/daemon/dist/tui/mirror/application-keybindings.js +33 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.js +270 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.js +45 -0
- package/packages/daemon/dist/tui/mirror/attention.js +59 -0
- package/packages/daemon/dist/tui/mirror/blit.js +120 -0
- package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.js +54 -0
- package/packages/daemon/dist/tui/mirror/changes-surface-view.jsx +92 -0
- package/packages/daemon/dist/tui/mirror/changes-surface.js +210 -0
- package/packages/daemon/dist/tui/mirror/composite-layout.js +539 -0
- package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.js +134 -0
- package/packages/daemon/dist/tui/mirror/dialog-model.js +183 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack-core.js +232 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack.js +2 -0
- package/packages/daemon/dist/tui/mirror/diff-model.js +332 -0
- package/packages/daemon/dist/tui/mirror/editor-buffer.js +47 -0
- package/packages/daemon/dist/tui/mirror/editor-open-policy.js +9 -0
- package/packages/daemon/dist/tui/mirror/features/changes/controller.js +454 -0
- package/packages/daemon/dist/tui/mirror/features/changes/feature.jsx +9 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/feature.jsx +123 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/session.js +160 -0
- package/packages/daemon/dist/tui/mirror/features/files/feature.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/features/files/session.js +617 -0
- package/packages/daemon/dist/tui/mirror/features/home/feature.jsx +122 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.js +3 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.jsx +5 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/session.js +377 -0
- package/packages/daemon/dist/tui/mirror/features/palette/buffer-geometry.js +36 -0
- package/packages/daemon/dist/tui/mirror/features/palette/contract.js +9 -0
- package/packages/daemon/dist/tui/mirror/features/palette/feature.js +3 -0
- package/packages/daemon/dist/tui/mirror/features/palette/session.js +394 -0
- package/packages/daemon/dist/tui/mirror/features/palette/surface.jsx +50 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.jsx +2 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/session.js +148 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/surface.jsx +64 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/asset-loader.js +125 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.jsx +103 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/session.js +310 -0
- package/packages/daemon/dist/tui/mirror/features/settings/catalog.js +10 -0
- package/packages/daemon/dist/tui/mirror/features/settings/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/settings/feature.js +2 -0
- package/packages/daemon/dist/tui/mirror/features/settings/session.js +309 -0
- package/packages/daemon/dist/tui/mirror/file-tree.js +283 -0
- package/packages/daemon/dist/tui/mirror/files-surface-view.jsx +92 -0
- package/packages/daemon/dist/tui/mirror/files-surface.js +237 -0
- package/packages/daemon/dist/tui/mirror/focus-projection.js +80 -0
- package/packages/daemon/dist/tui/mirror/folder-picker.js +114 -0
- package/packages/daemon/dist/tui/mirror/frame-coalescer.js +74 -0
- package/packages/daemon/dist/tui/mirror/home-model.js +125 -0
- package/packages/daemon/dist/tui/mirror/home-surface-model.js +297 -0
- package/packages/daemon/dist/tui/mirror/home-surface.jsx +110 -0
- package/packages/daemon/dist/tui/mirror/hosted.js +239 -0
- package/packages/daemon/dist/tui/mirror/input-lifecycle.js +147 -0
- package/packages/daemon/dist/tui/mirror/interaction-flow.js +41 -0
- package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.js +84 -0
- package/packages/daemon/dist/tui/mirror/menu-model.js +143 -0
- package/packages/daemon/dist/tui/mirror/missions-dashboard.js +261 -0
- package/packages/daemon/dist/tui/mirror/missions-render-fixtures.js +330 -0
- package/packages/daemon/dist/tui/mirror/missions-surface-controller.js +314 -0
- package/packages/daemon/dist/tui/mirror/missions-surface.jsx +239 -0
- package/packages/daemon/dist/tui/mirror/missions-workspace.js +1399 -0
- package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.js +252 -0
- package/packages/daemon/dist/tui/mirror/open-tui-pane-stream-socket.js +32 -0
- package/packages/daemon/dist/tui/mirror/open-tui-verified-routing.js +95 -0
- package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +1182 -0
- package/packages/daemon/dist/tui/mirror/palette-surface-adapter.js +384 -0
- package/packages/daemon/dist/tui/mirror/palette.js +522 -0
- package/packages/daemon/dist/tui/mirror/pane-frame-state.js +124 -0
- package/packages/daemon/dist/tui/mirror/pane-mirror.js +1 -0
- package/packages/daemon/dist/tui/mirror/pane-surface.jsx +950 -0
- package/packages/daemon/dist/tui/mirror/panel-host-reactive.js +13 -0
- package/packages/daemon/dist/tui/mirror/panel-host.js +242 -0
- package/packages/daemon/dist/tui/mirror/perf-tap.js +32 -0
- package/packages/daemon/dist/tui/mirror/performance-events.js +46 -0
- package/packages/daemon/dist/tui/mirror/recipe-components.jsx +135 -0
- package/packages/daemon/dist/tui/mirror/recipes.js +395 -0
- package/packages/daemon/dist/tui/mirror/reference-performance-trace.js +598 -0
- package/packages/daemon/dist/tui/mirror/renderer-commands.js +250 -0
- package/packages/daemon/dist/tui/mirror/resize-model.js +105 -0
- package/packages/daemon/dist/tui/mirror/resize-transaction.js +221 -0
- package/packages/daemon/dist/tui/mirror/rich-placement-projection.js +80 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.js +176 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.js +51 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-daemon-authority-owner.js +235 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-daemon-authority.js +8 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.js +90 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +86 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-observer.js +301 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-roster.jsx +170 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-selection.js +83 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-transport.js +199 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +221 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents.js +30 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.js +104 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.js +329 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-binding.js +111 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-capability.js +25 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-presentation.js +129 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-test-control.js +242 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-input-readiness.js +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.js +297 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +61 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agents.js +158 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-authority.js +289 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-catalog.js +223 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +164 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-sidebar.jsx +215 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-startup.js +35 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-optional-features.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +132 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.js +69 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-search-owner.js +67 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-activity-owner.js +61 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-menu-owner.js +82 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.js +41 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.js +46 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pending-terminal-input.js +74 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.js +126 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-post-render-runtime.js +117 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-configuration.js +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.js +160 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-session-focus-owner.js +65 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-binding.js +313 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-home.jsx +113 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-viewport.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-frame-readiness-owner.js +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-host-focus-owner.js +25 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.js +102 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +1360 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-palette-owner.js +217 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-paste.js +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-renderer-sources.js +31 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-selection-owner.js +217 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.js +193 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.jsx +1286 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-theme-repaint.js +34 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-transient-note-owner.js +29 -0
- package/packages/daemon/dist/tui/mirror/runtime/bounded-performance-record-writer.js +67 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-client-ledger.js +281 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-input-fixture.js +43 -0
- package/packages/daemon/dist/tui/mirror/runtime/changes-deferred-identity.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.js +128 -0
- package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.js +40 -0
- package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.js +39 -0
- package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.js +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.js +30 -0
- package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.js +53 -0
- package/packages/daemon/dist/tui/mirror/runtime/generation-bound-slot.js +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/host-local-tmux-adapter.js +203 -0
- package/packages/daemon/dist/tui/mirror/runtime/hosted-tty-size-bridge.js +166 -0
- package/packages/daemon/dist/tui/mirror/runtime/latest-intent-fence.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.js +58 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.js +118 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-pointer-capture.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.js +833 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.js +178 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.js +178 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.typecheck.js +1 -0
- package/packages/daemon/dist/tui/mirror/runtime/palette-production-controller.js +126 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-scoped-terminal-surface.jsx +67 -0
- package/packages/daemon/dist/tui/mirror/runtime/product-surface-policy.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.js +7 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-frame-optimizer.js +88 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-output-transport.js +56 -0
- package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.js +91 -0
- package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.js +111 -0
- package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.js +90 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-pane-publication.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-shell-viewport-resize.js +56 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-copy-cursor.js +122 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-copy-selection.js +65 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-dimensions-owner.js +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.js +911 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.js +84 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-focus.js +347 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-frame-diagnostics.js +37 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-input-adapter.js +50 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.js +105 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-link-opener.js +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-links.js +81 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.js +83 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-row-projection-cache.js +88 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-selection-units.js +123 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.js +202 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.js +89 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.js +64 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.js +636 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.js +169 -0
- package/packages/daemon/dist/tui/mirror/runtime/viewport-fit-coordinator.js +7 -0
- package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.js +498 -0
- package/packages/daemon/dist/tui/mirror/scrollbar-model.js +64 -0
- package/packages/daemon/dist/tui/mirror/search-model.js +62 -0
- package/packages/daemon/dist/tui/mirror/selection.js +264 -0
- package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.js +581 -0
- package/packages/daemon/dist/tui/mirror/semantic-session-view.js +269 -0
- package/packages/daemon/dist/tui/mirror/settings-model.js +304 -0
- package/packages/daemon/dist/tui/mirror/shell-chrome.js +313 -0
- package/packages/daemon/dist/tui/mirror/size-truth.js +104 -0
- package/packages/daemon/dist/tui/mirror/spans.js +31 -0
- package/packages/daemon/dist/tui/mirror/status-grammar.js +29 -0
- package/packages/daemon/dist/tui/mirror/terminal-native-reflow.js +1 -0
- package/packages/daemon/dist/tui/mirror/terminal-retained-row.js +10 -0
- package/packages/daemon/dist/tui/mirror/terminal-surface.js +92 -0
- package/packages/daemon/dist/tui/mirror/terminal-text.js +52 -0
- package/packages/daemon/dist/tui/mirror/terminal-viewport.js +462 -0
- package/packages/daemon/dist/tui/mirror/theme.js +765 -0
- package/packages/daemon/dist/tui/mirror/ui/agent-badge.jsx +14 -0
- package/packages/daemon/dist/tui/mirror/ui/badge.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/ui/button.jsx +66 -0
- package/packages/daemon/dist/tui/mirror/ui/dialog.jsx +8 -0
- package/packages/daemon/dist/tui/mirror/ui/index.js +16 -0
- package/packages/daemon/dist/tui/mirror/ui/key-hint.jsx +39 -0
- package/packages/daemon/dist/tui/mirror/ui/keyboard-router.jsx +46 -0
- package/packages/daemon/dist/tui/mirror/ui/menu.jsx +24 -0
- package/packages/daemon/dist/tui/mirror/ui/navigation-row.jsx +62 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-frame.jsx +54 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-host.jsx +33 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.jsx +29 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-model.js +45 -0
- package/packages/daemon/dist/tui/mirror/ui/state.js +171 -0
- package/packages/daemon/dist/tui/mirror/ui/status-bar.jsx +102 -0
- package/packages/daemon/dist/tui/mirror/ui/surface.jsx +45 -0
- package/packages/daemon/dist/tui/mirror/ui/tabs.jsx +88 -0
- package/packages/daemon/dist/tui/mirror/widget-fallback.js +52 -0
- package/packages/daemon/dist/tui/mirror/widget-surface-model.js +145 -0
- package/packages/daemon/dist/tui/mirror/widget-surface.jsx +31 -0
- package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.js +77 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-command-description.js +44 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.js +99 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-controller.js +292 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-surface-commands.js +28 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell.js +97 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface-view.jsx +158 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface.js +353 -0
- package/packages/daemon/dist/tui/mirror/workspace/connection-feedback.js +99 -0
- package/packages/daemon/dist/tui/mirror/workspace/icons.js +43 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu-model.js +8 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-frame.js +452 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.js +555 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.jsx +159 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-scrollback.js +183 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.jsx +253 -0
- package/packages/daemon/dist/tui/mirror/workspace/text.js +27 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.js +34 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.js +286 -0
- package/packages/daemon/dist/tui/mirror/workspace-ui-state.js +885 -0
- package/packages/daemon/dist/tui/readiness.js +34 -0
- package/packages/daemon/dist/tui/team/entry.js +20 -0
- package/packages/daemon/dist/tui/team/fuzzy.js +141 -0
- package/packages/daemon/dist/tui/team/home.js +115 -0
- package/packages/daemon/dist/tui/team/input.js +21 -0
- package/packages/daemon/dist/tui/team/keymap.js +99 -0
- package/packages/daemon/dist/tui/team/mouse.js +17 -0
- package/packages/daemon/dist/tui/team/nav.js +33 -0
- package/packages/daemon/dist/tui/team/preview.js +35 -0
- package/packages/daemon/dist/tui/team/projects.js +159 -0
- package/packages/daemon/dist/tui/team/report.js +37 -0
- package/packages/daemon/dist/tui/team/sessions.js +292 -0
- package/packages/daemon/dist/tui/team/tree.js +42 -0
- package/packages/daemon/dist/tui/team/wait-receipts.js +153 -0
- package/packages/daemon/dist/tui/team/wait.js +90 -0
- package/packages/daemon/dist/validate.js +16 -10
- package/packages/daemon/dist/widgets/lib/watcher.js +5 -92
- package/packages/daemon/dist/widgets/resolve.js +12 -9
- package/packages/daemon/dist/widgets/setup/setup-model.js +7 -9
- package/packages/daemon/src/attach.ts +2 -2
- package/packages/daemon/src/canonical.ts +19 -2
- package/packages/daemon/src/cli.ts +39 -37
- package/packages/daemon/src/command-center/actions/command-definitions.ts +91 -0
- package/packages/daemon/src/command-center/actions/dispatcher.ts +291 -10
- package/packages/daemon/src/command-center/actions/errors.ts +40 -0
- package/packages/daemon/src/command-center/actions/handlers/_project-context.ts +4 -5
- package/packages/daemon/src/command-center/actions/handlers/app-set-remote-access.ts +9 -1
- package/packages/daemon/src/command-center/actions/handlers/app-window-mutate.ts +54 -0
- package/packages/daemon/src/command-center/actions/handlers/config-actions.ts +59 -29
- package/packages/daemon/src/command-center/actions/handlers/daemon-shutdown.ts +12 -0
- package/packages/daemon/src/command-center/actions/handlers/fleet-lifecycle.ts +104 -0
- package/packages/daemon/src/command-center/actions/handlers/project-launch.ts +20 -4
- package/packages/daemon/src/command-center/actions/handlers/workspace-multiplexer.ts +96 -0
- package/packages/daemon/src/command-center/actions/handlers/workspace-open.ts +141 -0
- package/packages/daemon/src/command-center/actions/handlers/workspace-pane-create.ts +48 -0
- package/packages/daemon/src/command-center/actions/handlers/workspace-promote.ts +48 -0
- package/packages/daemon/src/command-center/actions/registry.ts +200 -1
- package/packages/daemon/src/command-center/actions/semantic-multiplexer-actions.ts +26 -0
- package/packages/daemon/src/command-center/agent-status-watch.ts +222 -0
- package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +465 -0
- package/packages/daemon/src/command-center/discovery.ts +310 -5
- package/packages/daemon/src/command-center/owner-authority.ts +118 -0
- package/packages/daemon/src/command-center/pane-stream-issue.ts +247 -0
- package/packages/daemon/src/command-center/resources/agent-graph-overlay.ts +270 -0
- package/packages/daemon/src/command-center/resources/application-shell.ts +909 -0
- package/packages/daemon/src/command-center/resources/desktop-missions.ts +171 -0
- package/packages/daemon/src/command-center/resources/fleet-catalog.ts +200 -0
- package/packages/daemon/src/command-center/resources/fleet-resource-route.ts +69 -0
- package/packages/daemon/src/command-center/resources/startup-readiness-route.ts +172 -0
- package/packages/daemon/src/command-center/resources/startup-readiness.ts +250 -0
- package/packages/daemon/src/command-center/resources/terminal-native-backing-route.ts +104 -0
- package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +45 -0
- package/packages/daemon/src/command-center/resources/workspace-changes-authority.ts +594 -0
- package/packages/daemon/src/command-center/resources/workspace-changes-git.ts +278 -0
- package/packages/daemon/src/command-center/resources/workspace-files-authority.ts +583 -0
- package/packages/daemon/src/command-center/resources/workspace-missions-route.ts +125 -0
- package/packages/daemon/src/command-center/resources/workspace-resource-ids.ts +81 -0
- package/packages/daemon/src/command-center/resources/workspace-resource-routes.ts +147 -0
- package/packages/daemon/src/command-center/server.ts +732 -59
- package/packages/daemon/src/command-center/terminal-attachment-issue.ts +257 -0
- package/packages/daemon/src/command-center/workspace-resource-observer.ts +560 -0
- package/packages/daemon/src/command-center/ws-events.ts +853 -66
- package/packages/daemon/src/config.ts +35 -25
- package/packages/daemon/src/control/lifecycle.ts +14 -2
- package/packages/daemon/src/control/server.ts +3 -3
- package/packages/daemon/src/detect.ts +25 -20
- package/packages/daemon/src/doctor.ts +24 -7
- package/packages/daemon/src/index.ts +244 -2
- package/packages/daemon/src/init.ts +23 -22
- package/packages/daemon/src/inspect.ts +41 -8
- package/packages/daemon/src/launch.ts +56 -28
- package/packages/daemon/src/lib/agent-kind.ts +23 -0
- package/packages/daemon/src/lib/app-config.ts +44 -5
- package/packages/daemon/src/lib/app-window-kernel.ts +777 -0
- package/packages/daemon/src/lib/app-window-mutation.ts +178 -0
- package/packages/daemon/src/lib/app-window-repository.ts +650 -0
- package/packages/daemon/src/lib/app-window-state.ts +599 -0
- package/packages/daemon/src/lib/application-shell-app-windows.ts +357 -0
- package/packages/daemon/src/lib/auth/middleware.ts +9 -3
- package/packages/daemon/src/lib/bundled-tmux.ts +103 -0
- package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +392 -0
- package/packages/daemon/src/lib/canonical-daemon.ts +695 -73
- package/packages/daemon/src/lib/chrome-front-door.ts +17 -0
- package/packages/daemon/src/lib/cli-action-bridge.ts +127 -91
- package/packages/daemon/src/lib/command-registry.ts +152 -0
- package/packages/daemon/src/lib/config-context.ts +61 -0
- package/packages/daemon/src/lib/daemon-embed.ts +1374 -390
- package/packages/daemon/src/lib/daemon-session-monitor.ts +274 -0
- package/packages/daemon/src/lib/daemon.ts +3 -46
- package/packages/daemon/src/lib/directory-watcher.ts +166 -0
- package/packages/daemon/src/lib/embedded-daemon-lifecycle.ts +106 -0
- package/packages/daemon/src/lib/environment-identity.ts +82 -0
- package/packages/daemon/src/lib/errors.ts +7 -1
- package/packages/daemon/src/lib/fleet-agent-lifecycle.ts +74 -0
- package/packages/daemon/src/lib/fleet-lifecycle-authority.ts +535 -0
- package/packages/daemon/src/lib/headless-daemon.ts +459 -0
- package/packages/daemon/src/lib/launch-plan.ts +123 -4
- package/packages/daemon/src/lib/legacy-config-adapter.ts +28 -0
- package/packages/daemon/src/lib/legacy-config-migration.ts +145 -0
- package/packages/daemon/src/lib/legacy-theme-compat.ts +40 -0
- package/packages/daemon/src/lib/mission-projections.ts +775 -0
- package/packages/daemon/src/lib/mission-repository.ts +1311 -0
- package/packages/daemon/src/lib/onboarding-marker.ts +51 -0
- package/packages/daemon/src/lib/pane-chrome.ts +14 -0
- package/packages/daemon/src/lib/pane-source-credentials.ts +200 -0
- package/packages/daemon/src/lib/pane-widget.ts +182 -0
- package/packages/daemon/src/lib/project-inspect.ts +4 -0
- package/packages/daemon/src/lib/project-onboard.ts +19 -24
- package/packages/daemon/src/lib/project-probe.ts +38 -30
- package/packages/daemon/src/lib/project-readiness-probe.ts +578 -0
- package/packages/daemon/src/lib/project-readiness.ts +1034 -0
- package/packages/daemon/src/lib/project-registry.ts +45 -9
- package/packages/daemon/src/lib/project-resolver.ts +350 -0
- package/packages/daemon/src/lib/project-runtime-errors.ts +41 -0
- package/packages/daemon/src/lib/project-runtime-repository.ts +1194 -0
- package/packages/daemon/src/lib/remote-daemon-info.ts +42 -0
- package/packages/daemon/src/lib/resolved-config.ts +425 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +186 -0
- package/packages/daemon/src/lib/saved-machines.ts +63 -0
- package/packages/daemon/src/lib/semantic-resource-id.ts +17 -0
- package/packages/daemon/src/lib/session-monitor.ts +28 -20
- package/packages/daemon/src/lib/session-options.ts +3 -10
- package/packages/daemon/src/lib/ssh-daemon-transport.ts +303 -0
- package/packages/daemon/src/lib/state-home.ts +2 -3
- package/packages/daemon/src/lib/theme-mode.ts +11 -0
- package/packages/daemon/src/lib/tmux-authority-replacement.ts +119 -0
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +632 -0
- package/packages/daemon/src/lib/tmux-interaction-options.ts +171 -0
- package/packages/daemon/src/lib/tmux-named-socket-fence.ts +66 -0
- package/packages/daemon/src/lib/tmux-terminal-color.ts +44 -0
- package/packages/daemon/src/lib/tui-binary.ts +354 -34
- package/packages/daemon/src/lib/unix-socket-authority.ts +65 -0
- package/packages/daemon/src/lib/widget-asset-policy.ts +3 -0
- package/packages/daemon/src/lib/widget-asset-store.ts +218 -0
- package/packages/daemon/src/lib/workspace-config-loader.ts +378 -0
- package/packages/daemon/src/lib/workspace-multiplexer-verbs.ts +1362 -0
- package/packages/daemon/src/lib/workspace-open-handoff.ts +340 -0
- package/packages/daemon/src/lib/workspace-open.ts +983 -0
- package/packages/daemon/src/lib/workspace-pane-creation.ts +1434 -0
- package/packages/daemon/src/lib/workspace-promotion.ts +1035 -0
- package/packages/daemon/src/lib/workspace-registry.ts +193 -25
- package/packages/daemon/src/lib/workspace-state-repository.ts +1204 -0
- package/packages/daemon/src/lib/workspace-state.ts +960 -0
- package/packages/daemon/src/lib/yaml-io.ts +8 -17
- package/packages/daemon/src/migrate.ts +134 -0
- package/packages/daemon/src/restart.ts +2 -2
- package/packages/daemon/src/restore.ts +14 -9
- package/packages/daemon/src/schemas/inspect.ts +9 -1
- package/packages/daemon/src/schemas/registry.ts +12 -22
- package/packages/daemon/src/schemas/ws-events.ts +14 -131
- package/packages/daemon/src/send.ts +138 -3
- package/packages/daemon/src/server/README.md +1 -1
- package/packages/daemon/src/server/index.ts +6 -2
- package/packages/daemon/src/server/pane-stream-upgrade.ts +141 -0
- package/packages/daemon/src/server/terminal-attachment-upgrade.ts +153 -0
- package/packages/daemon/src/status.ts +13 -8
- package/packages/daemon/src/stop.ts +2 -2
- package/packages/daemon/src/terminal/MonotonicPtyInput.ts +153 -0
- package/packages/daemon/src/terminal/NodePtyAdapter.ts +53 -11
- package/packages/daemon/src/terminal/PtyAdapter.ts +111 -3
- package/packages/daemon/src/terminal/README.md +34 -16
- package/packages/daemon/src/terminal/attachments/admission-util.ts +97 -0
- package/packages/daemon/src/terminal/attachments/agent-status-probe.ts +474 -0
- package/packages/daemon/src/terminal/attachments/direct-websocket.ts +1482 -0
- package/packages/daemon/src/terminal/attachments/grouped-tmux.ts +293 -0
- package/packages/daemon/src/terminal/attachments/lease-manager.ts +1042 -0
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +2246 -0
- package/packages/daemon/src/terminal/attachments/pty-tmux-attachment-launcher.ts +750 -0
- package/packages/daemon/src/terminal/attachments/semantic-pane-catalog.ts +365 -0
- package/packages/daemon/src/terminal/attachments/tmux-view-executor.ts +1095 -0
- package/packages/daemon/src/terminal/mirror/control-channel.ts +1031 -0
- package/packages/daemon/src/terminal/mirror/control-mode-ownership.ts +34 -0
- package/packages/daemon/src/terminal/mirror/events.ts +164 -0
- package/packages/daemon/src/terminal/mirror/flow-ledger.ts +65 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +503 -0
- package/packages/daemon/src/terminal/mirror/native-frozen-grid.ts +154 -0
- package/packages/daemon/src/terminal/mirror/native-grid-capture.ts +235 -0
- package/packages/daemon/src/terminal/mirror/native-grid-projection.ts +125 -0
- package/packages/daemon/src/terminal/mirror/native-grid-reader.ts +109 -0
- package/packages/daemon/src/terminal/mirror/native-grid-reflow.ts +241 -0
- package/packages/daemon/src/terminal/mirror/pane-feed.ts +272 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +3378 -0
- package/packages/daemon/src/terminal/mirror/trusted-inventory.ts +29 -0
- package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +375 -0
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +2625 -0
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +78 -0
- package/packages/daemon/src/terminal/pane-stream/wire-ledger.ts +155 -0
- package/packages/daemon/src/terminal/protocol/README.md +14 -0
- package/packages/daemon/src/terminal/protocol/chunk-bytes.ts +20 -0
- package/packages/daemon/src/terminal/protocol/control.ts +130 -0
- package/packages/daemon/src/terminal/protocol/input-coalescer.ts +131 -0
- package/packages/daemon/src/terminal/protocol/native-backing-client.ts +65 -0
- package/packages/daemon/src/terminal/protocol/pane-display-name.ts +192 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +382 -0
- package/packages/daemon/src/terminal/protocol/workspace-tmux-adapter.ts +470 -0
- package/packages/daemon/src/terminal/session-runtime/authority-arbiter.ts +318 -0
- package/packages/daemon/src/terminal/session-runtime/causal-cell-ledger.ts +359 -0
- package/packages/daemon/src/terminal/session-runtime/interaction-receipt-facts.ts +173 -0
- package/packages/daemon/src/terminal/session-runtime/multiplexer-backend.ts +194 -0
- package/packages/daemon/src/terminal/session-runtime/native-seed-backing.ts +80 -0
- package/packages/daemon/src/terminal/session-runtime/registry.ts +2084 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +267 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-scheduler.ts +30 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-trace-correlator.ts +58 -0
- package/packages/daemon/src/terminal/session-runtime/semantic-mutation-executor.ts +555 -0
- package/packages/daemon/src/terminal/session-runtime/semantic-mutation-resource-changes.ts +48 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +2324 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-observation-identity.ts +18 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +78 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +765 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +698 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-shadow-projections.ts +36 -0
- package/packages/daemon/src/terminal/session-runtime/transport-binding.ts +682 -0
- package/packages/daemon/src/terminal/session-runtime/xterm-headless-provenance.json +51 -0
- package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +697 -0
- package/packages/daemon/src/tui/async-disposable-slot.ts +60 -0
- package/packages/daemon/src/tui/chrome/front-door.ts +11 -23
- package/packages/daemon/src/tui/chrome/sidebar.ts +11 -5
- package/packages/daemon/src/tui/chrome/statusline.ts +15 -6
- package/packages/daemon/src/tui/chrome/updater.ts +100 -3
- package/packages/daemon/src/tui/compiled.ts +132 -6
- package/packages/daemon/src/tui/detect/agent-resolution.ts +85 -0
- package/packages/daemon/src/tui/detect/process-tree.ts +17 -1
- package/packages/daemon/src/tui/detect/snapshot.ts +38 -3
- package/packages/daemon/src/tui/integrations/claude.ts +1 -0
- package/packages/daemon/src/tui/main.ts +56 -0
- package/packages/daemon/src/tui/mirror/RECIPES.md +59 -0
- package/packages/daemon/src/tui/mirror/SHELL_CHROME.md +39 -0
- package/packages/daemon/src/tui/mirror/THEME.md +48 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/activity-surface-renderer.test.tsx.snap +42 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/changes-terminal-surface-renderer.test.tsx.snap +267 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/home-files-surface-renderer.test.tsx.snap +267 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/missions-surface-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/recipes-gallery-renderer.test.tsx.snap +141 -0
- package/packages/daemon/src/tui/mirror/__snapshots__/shell-chrome-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/activity-surface-view.tsx +169 -0
- package/packages/daemon/src/tui/mirror/activity-surface.ts +430 -0
- package/packages/daemon/src/tui/mirror/agent-lifecycle.ts +36 -5
- package/packages/daemon/src/tui/mirror/agent-provisioning-executor.ts +175 -0
- package/packages/daemon/src/tui/mirror/agent-rows.ts +34 -0
- package/packages/daemon/src/tui/mirror/ansi-palette.ts +3 -0
- package/packages/daemon/src/tui/mirror/app-state.ts +14 -1
- package/packages/daemon/src/tui/mirror/app.tsx +2 -7047
- package/packages/daemon/src/tui/mirror/application-keybindings.ts +54 -0
- package/packages/daemon/src/tui/mirror/application-shell-daemon-connection.ts +370 -0
- package/packages/daemon/src/tui/mirror/application-shell-daemon-session.ts +74 -0
- package/packages/daemon/src/tui/mirror/canonical-workspace-routing.ts +90 -0
- package/packages/daemon/src/tui/mirror/changes-surface-view.tsx +263 -0
- package/packages/daemon/src/tui/mirror/changes-surface.ts +338 -0
- package/packages/daemon/src/tui/mirror/composite-layout.ts +710 -0
- package/packages/daemon/src/tui/mirror/configless-session-bootstrap.ts +192 -0
- package/packages/daemon/src/tui/mirror/dialog-model.ts +2 -2
- package/packages/daemon/src/tui/mirror/dialog-stack-core.ts +264 -0
- package/packages/daemon/src/tui/mirror/dialog-stack.ts +2 -367
- package/packages/daemon/src/tui/mirror/editor-buffer.ts +9 -70
- package/packages/daemon/src/tui/mirror/editor-open-policy.ts +16 -0
- package/packages/daemon/src/tui/mirror/features/changes/contract.ts +84 -0
- package/packages/daemon/src/tui/mirror/features/changes/controller.ts +470 -0
- package/packages/daemon/src/tui/mirror/features/changes/feature.tsx +19 -0
- package/packages/daemon/src/tui/mirror/features/dialogs/contract.ts +64 -0
- package/packages/daemon/src/tui/mirror/features/dialogs/feature.tsx +227 -0
- package/packages/daemon/src/tui/mirror/features/dialogs/session.ts +186 -0
- package/packages/daemon/src/tui/mirror/features/files/feature.tsx +54 -0
- package/packages/daemon/src/tui/mirror/features/files/session.ts +694 -0
- package/packages/daemon/src/tui/mirror/features/home/feature.tsx +172 -0
- package/packages/daemon/src/tui/mirror/features/missions-activity/contract.ts +106 -0
- package/packages/daemon/src/tui/mirror/features/missions-activity/feature.tsx +19 -0
- package/packages/daemon/src/tui/mirror/features/missions-activity/session.ts +470 -0
- package/packages/daemon/src/tui/mirror/features/palette/buffer-geometry.ts +46 -0
- package/packages/daemon/src/tui/mirror/features/palette/contract.ts +121 -0
- package/packages/daemon/src/tui/mirror/features/palette/feature.ts +14 -0
- package/packages/daemon/src/tui/mirror/features/palette/session.ts +443 -0
- package/packages/daemon/src/tui/mirror/features/palette/surface.tsx +133 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/contract.ts +20 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/feature.tsx +8 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/session.ts +152 -0
- package/packages/daemon/src/tui/mirror/features/performance-hud/surface.tsx +137 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/asset-loader.ts +153 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/contract.ts +94 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/feature.tsx +141 -0
- package/packages/daemon/src/tui/mirror/features/rich-preview/session.ts +387 -0
- package/packages/daemon/src/tui/mirror/features/settings/catalog.ts +26 -0
- package/packages/daemon/src/tui/mirror/features/settings/contract.ts +41 -0
- package/packages/daemon/src/tui/mirror/features/settings/feature.ts +3 -0
- package/packages/daemon/src/tui/mirror/features/settings/session.ts +375 -0
- package/packages/daemon/src/tui/mirror/files-surface-view.tsx +242 -0
- package/packages/daemon/src/tui/mirror/files-surface.ts +371 -0
- package/packages/daemon/src/tui/mirror/focus-projection.ts +113 -0
- package/packages/daemon/src/tui/mirror/frame-coalescer.ts +87 -0
- package/packages/daemon/src/tui/mirror/home-model.ts +1 -1
- package/packages/daemon/src/tui/mirror/home-surface-model.ts +440 -0
- package/packages/daemon/src/tui/mirror/home-surface.tsx +254 -0
- package/packages/daemon/src/tui/mirror/hosted.ts +87 -6
- package/packages/daemon/src/tui/mirror/input-lifecycle.ts +248 -0
- package/packages/daemon/src/tui/mirror/interaction-flow.ts +83 -0
- package/packages/daemon/src/tui/mirror/legacy/missions-workspace-loader.ts +117 -0
- package/packages/daemon/src/tui/mirror/menu-model.ts +1 -14
- package/packages/daemon/src/tui/mirror/missions-dashboard.ts +451 -0
- package/packages/daemon/src/tui/mirror/missions-render-fixtures.ts +371 -0
- package/packages/daemon/src/tui/mirror/missions-surface-controller.ts +530 -0
- package/packages/daemon/src/tui/mirror/missions-surface.tsx +434 -0
- package/packages/daemon/src/tui/mirror/missions-workspace.ts +1996 -0
- package/packages/daemon/src/tui/mirror/multiplexer-action-executor.ts +393 -0
- package/packages/daemon/src/tui/mirror/open-tui-pane-stream-socket.ts +47 -0
- package/packages/daemon/src/tui/mirror/open-tui-verified-routing.ts +152 -0
- package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +1451 -0
- package/packages/daemon/src/tui/mirror/palette-surface-adapter.ts +465 -0
- package/packages/daemon/src/tui/mirror/palette.ts +189 -28
- package/packages/daemon/src/tui/mirror/pane-frame-state.ts +209 -0
- package/packages/daemon/src/tui/mirror/pane-mirror.ts +11 -593
- package/packages/daemon/src/tui/mirror/pane-surface.tsx +858 -53
- package/packages/daemon/src/tui/mirror/panel-host-reactive.ts +17 -0
- package/packages/daemon/src/tui/mirror/panel-host.ts +384 -0
- package/packages/daemon/src/tui/mirror/perf-tap.ts +1 -148
- package/packages/daemon/src/tui/mirror/performance-events.ts +494 -0
- package/packages/daemon/src/tui/mirror/recipe-components.tsx +310 -0
- package/packages/daemon/src/tui/mirror/recipes-gallery.tsx +256 -0
- package/packages/daemon/src/tui/mirror/recipes.ts +543 -0
- package/packages/daemon/src/tui/mirror/reference-performance-trace.ts +727 -0
- package/packages/daemon/src/tui/mirror/renderer-commands.ts +344 -0
- package/packages/daemon/src/tui/mirror/resize-model.ts +74 -9
- package/packages/daemon/src/tui/mirror/resize-transaction.ts +342 -0
- package/packages/daemon/src/tui/mirror/rich-placement-projection.ts +173 -0
- package/packages/daemon/src/tui/mirror/runtime/__snapshots__/application-shell-view-renderer.test.tsx.snap +87 -0
- package/packages/daemon/src/tui/mirror/runtime/application-add-machine-dialog.tsx +88 -0
- package/packages/daemon/src/tui/mirror/runtime/application-appearance-owner.ts +229 -0
- package/packages/daemon/src/tui/mirror/runtime/application-bootstrap.ts +118 -0
- package/packages/daemon/src/tui/mirror/runtime/application-daemon-authority-owner.ts +259 -0
- package/packages/daemon/src/tui/mirror/runtime/application-daemon-authority.ts +16 -0
- package/packages/daemon/src/tui/mirror/runtime/application-entry.ts +226 -0
- package/packages/daemon/src/tui/mirror/runtime/application-generation-starter.ts +130 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +174 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-observer.ts +363 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-roster.tsx +276 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-selection.ts +99 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-transport.ts +232 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +295 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents.ts +70 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-catalog-owner.ts +130 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-catalog.ts +451 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-control-binding.ts +143 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-control-capability.ts +46 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-presentation.ts +176 -0
- package/packages/daemon/src/tui/mirror/runtime/application-host-focus-test-control.ts +313 -0
- package/packages/daemon/src/tui/mirror/runtime/application-input-readiness.ts +28 -0
- package/packages/daemon/src/tui/mirror/runtime/application-lifecycle.ts +374 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +91 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agents.ts +199 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-authority.ts +337 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-catalog.ts +256 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +177 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-sidebar.tsx +356 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-startup.ts +39 -0
- package/packages/daemon/src/tui/mirror/runtime/application-optional-features.ts +25 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +162 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-input.ts +108 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-search-owner.ts +78 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-activity-owner.ts +79 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-menu-owner.ts +95 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-input.ts +61 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-owner.ts +50 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pending-terminal-input.ts +117 -0
- package/packages/daemon/src/tui/mirror/runtime/application-performance-log.ts +166 -0
- package/packages/daemon/src/tui/mirror/runtime/application-post-render-runtime.ts +163 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-configuration.ts +47 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-renderer.ts +165 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +632 -0
- package/packages/daemon/src/tui/mirror/runtime/application-session-focus-owner.ts +80 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-binding.ts +375 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-catalog.tsx +448 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-home.tsx +252 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-overlay-stack.tsx +37 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-overlays.tsx +381 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-sidebar.tsx +188 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-view.tsx +537 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-viewport.ts +18 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-frame-readiness-owner.ts +33 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-host-focus-owner.ts +36 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-input-ingress.ts +139 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +1673 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-palette-owner.ts +302 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-paste.ts +33 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-renderer-sources.ts +33 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-selection-owner.ts +277 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace-policy.ts +311 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace.tsx +1921 -0
- package/packages/daemon/src/tui/mirror/runtime/application-theme-repaint.ts +45 -0
- package/packages/daemon/src/tui/mirror/runtime/application-transient-note-owner.ts +42 -0
- package/packages/daemon/src/tui/mirror/runtime/bounded-performance-record-writer.ts +75 -0
- package/packages/daemon/src/tui/mirror/runtime/causal-cell-client-ledger.ts +406 -0
- package/packages/daemon/src/tui/mirror/runtime/causal-cell-input-fixture.ts +55 -0
- package/packages/daemon/src/tui/mirror/runtime/changes-deferred-identity.ts +34 -0
- package/packages/daemon/src/tui/mirror/runtime/daemon-authority-rebind.ts +163 -0
- package/packages/daemon/src/tui/mirror/runtime/deferred-intent-queue.ts +45 -0
- package/packages/daemon/src/tui/mirror/runtime/editor-primitives.ts +56 -0
- package/packages/daemon/src/tui/mirror/runtime/file-content-primitives.ts +8 -0
- package/packages/daemon/src/tui/mirror/runtime/fleet-lifecycle-client.ts +67 -0
- package/packages/daemon/src/tui/mirror/runtime/focus-framebuffer-projection.ts +71 -0
- package/packages/daemon/src/tui/mirror/runtime/generation-bound-slot.ts +23 -0
- package/packages/daemon/src/tui/mirror/runtime/host-local-tmux-adapter.ts +233 -0
- package/packages/daemon/src/tui/mirror/runtime/hosted-tty-size-bridge.ts +213 -0
- package/packages/daemon/src/tui/mirror/runtime/latest-intent-fence.ts +22 -0
- package/packages/daemon/src/tui/mirror/runtime/local-view-controller.ts +95 -0
- package/packages/daemon/src/tui/mirror/runtime/modal-admission-coordinator.ts +158 -0
- package/packages/daemon/src/tui/mirror/runtime/modal-pointer-capture.ts +23 -0
- package/packages/daemon/src/tui/mirror/runtime/open-tui-generation-host.ts +1003 -0
- package/packages/daemon/src/tui/mirror/runtime/open-tui-session-owner.ts +229 -0
- package/packages/daemon/src/tui/mirror/runtime/optional-feature-registry.ts +234 -0
- package/packages/daemon/src/tui/mirror/runtime/optional-feature-registry.typecheck.ts +14 -0
- package/packages/daemon/src/tui/mirror/runtime/palette-production-controller.ts +170 -0
- package/packages/daemon/src/tui/mirror/runtime/palette-production-overlay.tsx +65 -0
- package/packages/daemon/src/tui/mirror/runtime/pane-resize-geometry.ts +29 -0
- package/packages/daemon/src/tui/mirror/runtime/pane-scoped-terminal-surface.tsx +156 -0
- package/packages/daemon/src/tui/mirror/runtime/product-surface-policy.ts +16 -0
- package/packages/daemon/src/tui/mirror/runtime/renderer-cadence.ts +7 -0
- package/packages/daemon/src/tui/mirror/runtime/renderer-frame-optimizer.ts +92 -0
- package/packages/daemon/src/tui/mirror/runtime/renderer-output-transport.ts +57 -0
- package/packages/daemon/src/tui/mirror/runtime/resize-terminal-pane.ts +134 -0
- package/packages/daemon/src/tui/mirror/runtime/rich-preview-demand.ts +26 -0
- package/packages/daemon/src/tui/mirror/runtime/rich-preview-overlay.tsx +54 -0
- package/packages/daemon/src/tui/mirror/runtime/runtime-layout-presentation.ts +119 -0
- package/packages/daemon/src/tui/mirror/runtime/select-terminal-pane.ts +127 -0
- package/packages/daemon/src/tui/mirror/runtime/semantic-pane-publication.ts +26 -0
- package/packages/daemon/src/tui/mirror/runtime/semantic-shell-viewport-resize.ts +88 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-copy-cursor.ts +169 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-copy-selection.ts +79 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-dimensions-owner.ts +20 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.ts +1085 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-frame-readiness.ts +100 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-host-focus.ts +519 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-host-frame-diagnostics.ts +47 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-input-adapter.ts +69 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-layout-projection.ts +145 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-link-opener.ts +30 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-links.ts +97 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-pane-input-router.ts +95 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-row-projection-cache.ts +115 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-selection-units.ts +128 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-selection.ts +285 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-session-handoff.ts +143 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-tool-readiness.ts +72 -0
- package/packages/daemon/src/tui/mirror/runtime/tool-resource-controller.ts +799 -0
- package/packages/daemon/src/tui/mirror/runtime/tool-resource-projection.ts +223 -0
- package/packages/daemon/src/tui/mirror/runtime/viewport-fit-coordinator.ts +12 -0
- package/packages/daemon/src/tui/mirror/runtime/workspace-terminal-fast-lane.ts +597 -0
- package/packages/daemon/src/tui/mirror/selection.ts +0 -21
- package/packages/daemon/src/tui/mirror/semantic-pane-render-source.ts +786 -0
- package/packages/daemon/src/tui/mirror/semantic-session-view.ts +366 -0
- package/packages/daemon/src/tui/mirror/settings-model.ts +24 -66
- package/packages/daemon/src/tui/mirror/shell-chrome-view.tsx +346 -0
- package/packages/daemon/src/tui/mirror/shell-chrome.ts +509 -0
- package/packages/daemon/src/tui/mirror/sidebar.tsx +138 -35
- package/packages/daemon/src/tui/mirror/size-truth.ts +1 -1
- package/packages/daemon/src/tui/mirror/terminal-native-reflow.ts +1 -0
- package/packages/daemon/src/tui/mirror/terminal-retained-row.ts +24 -0
- package/packages/daemon/src/tui/mirror/terminal-surface.ts +157 -0
- package/packages/daemon/src/tui/mirror/terminal-surface.tsx +84 -0
- package/packages/daemon/src/tui/mirror/terminal-text.ts +54 -0
- package/packages/daemon/src/tui/mirror/terminal-viewport.ts +544 -0
- package/packages/daemon/src/tui/mirror/theme.ts +1069 -33
- package/packages/daemon/src/tui/mirror/ui/agent-badge.tsx +41 -0
- package/packages/daemon/src/tui/mirror/ui/badge.tsx +42 -0
- package/packages/daemon/src/tui/mirror/ui/button.tsx +127 -0
- package/packages/daemon/src/tui/mirror/ui/dialog.tsx +45 -0
- package/packages/daemon/src/tui/mirror/ui/index.ts +59 -0
- package/packages/daemon/src/tui/mirror/ui/key-hint.tsx +63 -0
- package/packages/daemon/src/tui/mirror/ui/keyboard-router.tsx +72 -0
- package/packages/daemon/src/tui/mirror/ui/menu.tsx +86 -0
- package/packages/daemon/src/tui/mirror/ui/navigation-row.tsx +114 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-frame.tsx +117 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-host.tsx +71 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-list-row.tsx +68 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-model.ts +75 -0
- package/packages/daemon/src/tui/mirror/ui/state.ts +218 -0
- package/packages/daemon/src/tui/mirror/ui/status-bar.tsx +208 -0
- package/packages/daemon/src/tui/mirror/ui/surface.tsx +71 -0
- package/packages/daemon/src/tui/mirror/ui/tabs.tsx +168 -0
- package/packages/daemon/src/tui/mirror/widget-fallback.ts +66 -0
- package/packages/daemon/src/tui/mirror/widget-surface-model.ts +170 -0
- package/packages/daemon/src/tui/mirror/widget-surface.tsx +79 -0
- package/packages/daemon/src/tui/mirror/workspace/README.md +79 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/agent-terminal-canvas-renderer.test.tsx.snap +348 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/application-shell-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/command-palette-surface-renderer.test.tsx.snap +255 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/pane-frame-renderer.test.tsx.snap +525 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/terminal-pane-header-polish-renderer.test.tsx.snap +31 -0
- package/packages/daemon/src/tui/mirror/workspace/__snapshots__/workbench-shell-renderer.test.tsx.snap +134 -0
- package/packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas-view.tsx +61 -0
- package/packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas.ts +131 -0
- package/packages/daemon/src/tui/mirror/workspace/application-command-description.ts +77 -0
- package/packages/daemon/src/tui/mirror/workspace/application-root-controller.ts +169 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell-controller.ts +430 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell-surface-commands.ts +64 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell-view.tsx +169 -0
- package/packages/daemon/src/tui/mirror/workspace/application-shell.ts +179 -0
- package/packages/daemon/src/tui/mirror/workspace/command-palette-surface-view.tsx +356 -0
- package/packages/daemon/src/tui/mirror/workspace/command-palette-surface.ts +557 -0
- package/packages/daemon/src/tui/mirror/workspace/connection-feedback.ts +105 -0
- package/packages/daemon/src/tui/mirror/workspace/icons.ts +56 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-action-menu-model.ts +33 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-action-menu.tsx +54 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-frame.ts +675 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-frame.tsx +490 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome-view.tsx +125 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome.ts +833 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-pane-header.tsx +326 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-scrollback.ts +220 -0
- package/packages/daemon/src/tui/mirror/workspace/terminal-window-strip.tsx +466 -0
- package/packages/daemon/src/tui/mirror/workspace/text.ts +28 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-controller.ts +75 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-dock-opentui.tsx +224 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-shell.ts +486 -0
- package/packages/daemon/src/tui/mirror/workspace/workbench-shell.tsx +95 -0
- package/packages/daemon/src/tui/mirror/workspace-ui-state.ts +1278 -0
- package/packages/daemon/src/tui/readiness.ts +52 -0
- package/packages/daemon/src/tui/team/entry.ts +23 -13
- package/packages/daemon/src/tui/team/home.ts +1 -1
- package/packages/daemon/src/tui/team/index.tsx +27 -8
- package/packages/daemon/src/tui/team/projects.ts +12 -0
- package/packages/daemon/src/tui/team/sessions.ts +43 -48
- package/packages/daemon/src/tui/team/wait-receipts.ts +192 -0
- package/packages/daemon/src/ui/pane-frame/fixture.ts +43 -0
- package/packages/daemon/src/ui/workbench-dock/fixture.ts +61 -0
- package/packages/daemon/src/validate.ts +21 -9
- package/packages/daemon/src/widgets/config/README.md +1 -1
- package/packages/daemon/src/widgets/config/index.tsx +15 -115
- package/packages/daemon/src/widgets/lib/watcher.ts +3 -130
- package/packages/daemon/src/widgets/resolve.ts +18 -9
- package/packages/daemon/src/widgets/setup/footer.tsx +0 -7
- package/packages/daemon/src/widgets/setup/index.tsx +18 -20
- package/packages/daemon/src/widgets/setup/review-panel.tsx +15 -10
- package/packages/daemon/src/widgets/setup/setup-model.ts +7 -10
- package/packages/daemon-client/package.json +42 -0
- package/packages/daemon-client/src/application-shell-session.test.ts +196 -0
- package/packages/daemon-client/src/application-shell-session.ts +450 -0
- package/packages/daemon-client/src/bootstrap-coordinator.test.ts +122 -0
- package/packages/daemon-client/src/bootstrap-coordinator.ts +293 -0
- package/packages/daemon-client/src/connection-supervisor.test.ts +109 -0
- package/packages/daemon-client/src/connection-supervisor.ts +216 -0
- package/packages/daemon-client/src/direct-application-shell-transport.test.ts +939 -0
- package/packages/daemon-client/src/direct-application-shell-transport.ts +1144 -0
- package/packages/daemon-client/src/first-latest-coordinator.test.ts +175 -0
- package/packages/daemon-client/src/first-latest-coordinator.ts +82 -0
- package/packages/daemon-client/src/generation-bound-store-timers.test.ts +74 -0
- package/packages/daemon-client/src/generation-bound-store.ts +908 -0
- package/packages/daemon-client/src/index.ts +25 -0
- package/packages/daemon-client/src/owner-action-client.test.ts +180 -0
- package/packages/daemon-client/src/owner-action-client.ts +113 -0
- package/packages/daemon-client/src/pane-stream-client.test.ts +2771 -0
- package/packages/daemon-client/src/pane-stream-client.ts +1665 -0
- package/packages/daemon-client/src/pane-stream-clock-calibration.test.ts +207 -0
- package/packages/daemon-client/src/pane-stream-clock-calibration.ts +161 -0
- package/packages/daemon-client/src/pane-stream-loopback-benchmark.test.ts +51 -0
- package/packages/daemon-client/src/push-resource-session.test.ts +509 -0
- package/packages/daemon-client/src/push-resource-session.ts +797 -0
- package/packages/daemon-client/src/resource-replica.test.ts +186 -0
- package/packages/daemon-client/src/resource-replica.ts +280 -0
- package/packages/daemon-client/src/runtime-resource-ledger.test.ts +18 -0
- package/packages/daemon-client/src/runtime-resource-ledger.ts +69 -0
- package/packages/daemon-client/src/terminal-fast-lane.test.ts +817 -0
- package/packages/daemon-client/src/terminal-fast-lane.ts +817 -0
- package/packages/daemon-client/src/terminal-fast-lane.typecheck.ts +16 -0
- package/packages/daemon-client/src/workspace-catalog-v2.test.ts +109 -0
- package/packages/daemon-client/src/workspace-catalog-v2.ts +66 -0
- package/packages/daemon-client/src/workspace-client-boundaries.test.ts +59 -0
- package/packages/daemon-client/src/workspace-client-conformance.ts +67 -0
- package/packages/daemon-client/src/workspace-client-operations.test.ts +47 -0
- package/packages/daemon-client/src/workspace-client-operations.ts +220 -0
- package/packages/daemon-client/src/workspace-client-types.ts +302 -0
- package/packages/daemon-client/src/workspace-client.test.ts +2752 -0
- package/packages/daemon-client/src/workspace-client.ts +1452 -0
- package/packages/daemon-client/src/workspace-event-supervisor.test.ts +1086 -0
- package/packages/daemon-client/src/workspace-event-supervisor.ts +719 -0
- package/packages/daemon-client/src/workspace-pane-client.test.ts +80 -0
- package/packages/daemon-client/src/workspace-pane-client.ts +63 -0
- package/packages/presentation/package.json +28 -0
- package/packages/presentation/src/index.ts +2 -0
- package/packages/presentation/src/pane-frame/action-state.ts +72 -0
- package/packages/presentation/src/pane-frame/index.ts +3 -0
- package/packages/presentation/src/pane-frame/model.ts +517 -0
- package/packages/presentation/src/pane-frame/presenter.tsx +335 -0
- package/packages/presentation/src/pane-frame/web-entry.tsx +22 -0
- package/packages/presentation/src/pane-frame/web-host-unstyled.tsx +280 -0
- package/packages/presentation/src/pane-frame/web-host.css +388 -0
- package/packages/presentation/src/pane-frame/web-host.tsx +3 -0
- package/packages/presentation/src/presentation-contract.test.ts +63 -0
- package/packages/presentation/src/workbench-dock/index.ts +2 -0
- package/packages/presentation/src/workbench-dock/navigation.ts +54 -0
- package/packages/presentation/src/workbench-dock/presenter.tsx +252 -0
- package/packages/presentation/src/workbench-dock/web-entry.tsx +19 -0
- package/packages/presentation/src/workbench-dock/web-host-unstyled.tsx +198 -0
- package/packages/presentation/src/workbench-dock/web-host.css +204 -0
- package/packages/presentation/src/workbench-dock/web-host.tsx +3 -0
- package/packages/tmux-bridge/src/index.ts +9 -1
- package/packages/tmux-bridge/src/panes.ts +4 -0
- package/packages/tmux-bridge/src/runner.test.ts +72 -0
- package/packages/tmux-bridge/src/runner.ts +43 -2
- package/packages/tmux-bridge/src/sessions.ts +8 -1
- package/scripts/postinstall.js +57 -6
- package/skill/SKILL.md +27 -28
- package/templates/agent-team-monorepo.yml +28 -30
- package/templates/agent-team-nextjs.yml +24 -26
- package/templates/agent-team.yml +24 -24
- package/templates/convex.yml +24 -16
- package/templates/default.yml +26 -21
- package/templates/go.yml +21 -14
- package/templates/missions.yml +25 -40
- package/templates/nextjs.yml +24 -16
- package/templates/python.yml +21 -14
- package/templates/vite.yml +21 -14
- package/bin/cli.ts +0 -1773
- package/packages/daemon/dist/__tests__/support.d.ts +0 -7
- package/packages/daemon/dist/agent-explain.d.ts +0 -52
- package/packages/daemon/dist/attach.d.ts +0 -3
- package/packages/daemon/dist/bin.d.ts +0 -2
- package/packages/daemon/dist/canonical.d.ts +0 -2
- package/packages/daemon/dist/cli.d.ts +0 -1
- package/packages/daemon/dist/command-center/actions/contract.d.ts +0 -1
- package/packages/daemon/dist/command-center/actions/dispatcher.d.ts +0 -27
- package/packages/daemon/dist/command-center/actions/errors.d.ts +0 -38
- package/packages/daemon/dist/command-center/actions/handlers/_project-context.d.ts +0 -12
- package/packages/daemon/dist/command-center/actions/handlers/_resolve-project.d.ts +0 -42
- package/packages/daemon/dist/command-center/actions/handlers/app-set-remote-access.d.ts +0 -23
- package/packages/daemon/dist/command-center/actions/handlers/config-actions.d.ts +0 -12
- package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.d.ts +0 -6
- package/packages/daemon/dist/command-center/actions/handlers/project-activate.d.ts +0 -7
- package/packages/daemon/dist/command-center/actions/handlers/project-launch.d.ts +0 -18
- package/packages/daemon/dist/command-center/actions/handlers/project-open-terminal.d.ts +0 -32
- package/packages/daemon/dist/command-center/actions/handlers/project-restart.d.ts +0 -17
- package/packages/daemon/dist/command-center/actions/handlers/project-stop.d.ts +0 -24
- package/packages/daemon/dist/command-center/actions/handlers/terminal-respawn.d.ts +0 -24
- package/packages/daemon/dist/command-center/actions/handlers/terminal-stop.d.ts +0 -14
- package/packages/daemon/dist/command-center/actions/registry.d.ts +0 -35
- package/packages/daemon/dist/command-center/discovery.d.ts +0 -23
- package/packages/daemon/dist/command-center/index.d.ts +0 -10
- package/packages/daemon/dist/command-center/schemas.d.ts +0 -76
- package/packages/daemon/dist/command-center/server.d.ts +0 -26
- package/packages/daemon/dist/command-center/ws-events.d.ts +0 -59
- package/packages/daemon/dist/config.d.ts +0 -19
- package/packages/daemon/dist/control/client.d.ts +0 -23
- package/packages/daemon/dist/control/dispatch.d.ts +0 -34
- package/packages/daemon/dist/control/fanout.d.ts +0 -19
- package/packages/daemon/dist/control/frames.d.ts +0 -23
- package/packages/daemon/dist/control/lifecycle.d.ts +0 -45
- package/packages/daemon/dist/control/server.d.ts +0 -16
- package/packages/daemon/dist/control/verbs.d.ts +0 -11
- package/packages/daemon/dist/detect.d.ts +0 -15
- package/packages/daemon/dist/doctor.d.ts +0 -39
- package/packages/daemon/dist/embed.d.ts +0 -1
- package/packages/daemon/dist/index.d.ts +0 -3
- package/packages/daemon/dist/init.d.ts +0 -4
- package/packages/daemon/dist/inspect.d.ts +0 -54
- package/packages/daemon/dist/launch.d.ts +0 -23
- package/packages/daemon/dist/lib/active-projects.d.ts +0 -12
- package/packages/daemon/dist/lib/agent-discovery.d.ts +0 -68
- package/packages/daemon/dist/lib/app-config.d.ts +0 -253
- package/packages/daemon/dist/lib/app-settings.d.ts +0 -9
- package/packages/daemon/dist/lib/auth/auth-service.d.ts +0 -33
- package/packages/daemon/dist/lib/auth/middleware.d.ts +0 -16
- package/packages/daemon/dist/lib/auth/types.d.ts +0 -1
- package/packages/daemon/dist/lib/auth-token.d.ts +0 -1
- package/packages/daemon/dist/lib/authorship.d.ts +0 -62
- package/packages/daemon/dist/lib/canonical-daemon.d.ts +0 -21
- package/packages/daemon/dist/lib/cli-action-bridge.d.ts +0 -27
- package/packages/daemon/dist/lib/daemon-embed.d.ts +0 -31
- package/packages/daemon/dist/lib/daemon-watchdog.d.ts +0 -16
- package/packages/daemon/dist/lib/daemon.d.ts +0 -8
- package/packages/daemon/dist/lib/dot-path.d.ts +0 -2
- package/packages/daemon/dist/lib/errors.d.ts +0 -37
- package/packages/daemon/dist/lib/filesystem-browser.d.ts +0 -85
- package/packages/daemon/dist/lib/launch-plan.d.ts +0 -6
- package/packages/daemon/dist/lib/log.d.ts +0 -40
- package/packages/daemon/dist/lib/manifest-pack.d.ts +0 -79
- package/packages/daemon/dist/lib/output.d.ts +0 -9
- package/packages/daemon/dist/lib/project-init-runner.d.ts +0 -46
- package/packages/daemon/dist/lib/project-inspect.d.ts +0 -28
- package/packages/daemon/dist/lib/project-onboard.d.ts +0 -58
- package/packages/daemon/dist/lib/project-probe.d.ts +0 -35
- package/packages/daemon/dist/lib/project-registry.d.ts +0 -76
- package/packages/daemon/dist/lib/session-monitor.d.ts +0 -15
- package/packages/daemon/dist/lib/session-options.d.ts +0 -13
- package/packages/daemon/dist/lib/shell.d.ts +0 -5
- package/packages/daemon/dist/lib/sizes.d.ts +0 -16
- package/packages/daemon/dist/lib/skill-sync.d.ts +0 -60
- package/packages/daemon/dist/lib/slugify.d.ts +0 -4
- package/packages/daemon/dist/lib/state-home.d.ts +0 -2
- package/packages/daemon/dist/lib/terminals-store.d.ts +0 -27
- package/packages/daemon/dist/lib/tui-binary.d.ts +0 -57
- package/packages/daemon/dist/lib/update-check.d.ts +0 -118
- package/packages/daemon/dist/lib/update.d.ts +0 -65
- package/packages/daemon/dist/lib/workspace-registry.d.ts +0 -84
- package/packages/daemon/dist/lib/worktree.d.ts +0 -76
- package/packages/daemon/dist/lib/yaml-io.d.ts +0 -10
- package/packages/daemon/dist/ls.d.ts +0 -3
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +0 -34
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/PkgInfo +0 -1
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/AppIcon.icns +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +0 -139
- package/packages/daemon/dist/restart.d.ts +0 -4
- package/packages/daemon/dist/restore.d.ts +0 -113
- package/packages/daemon/dist/schemas/domain.d.ts +0 -1
- package/packages/daemon/dist/schemas/filesystem.d.ts +0 -29
- package/packages/daemon/dist/schemas/ide-config.d.ts +0 -1
- package/packages/daemon/dist/schemas/index.d.ts +0 -12
- package/packages/daemon/dist/schemas/inspect.d.ts +0 -53
- package/packages/daemon/dist/schemas/registry.d.ts +0 -35
- package/packages/daemon/dist/schemas/ws-events.d.ts +0 -72
- package/packages/daemon/dist/send.d.ts +0 -59
- package/packages/daemon/dist/server/index.d.ts +0 -10
- package/packages/daemon/dist/server/pty-bridge.d.ts +0 -174
- package/packages/daemon/dist/server/ws-route.d.ts +0 -74
- package/packages/daemon/dist/status.d.ts +0 -3
- package/packages/daemon/dist/stop.d.ts +0 -3
- package/packages/daemon/dist/terminal/NodePtyAdapter.d.ts +0 -44
- package/packages/daemon/dist/terminal/PtyAdapter.d.ts +0 -124
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.d.ts +0 -77
- package/packages/daemon/dist/types.d.ts +0 -2
- package/packages/daemon/dist/validate.d.ts +0 -4
- package/packages/daemon/dist/widgets/changes/index.jsx +0 -575
- package/packages/daemon/dist/widgets/config/index.d.ts +0 -1
- package/packages/daemon/dist/widgets/config/index.jsx +0 -395
- package/packages/daemon/dist/widgets/explorer/breadcrumbs.d.ts +0 -10
- package/packages/daemon/dist/widgets/explorer/breadcrumbs.jsx +0 -51
- package/packages/daemon/dist/widgets/explorer/footer.d.ts +0 -6
- package/packages/daemon/dist/widgets/explorer/footer.jsx +0 -11
- package/packages/daemon/dist/widgets/explorer/index.jsx +0 -393
- package/packages/daemon/dist/widgets/explorer/tree-model.d.ts +0 -13
- package/packages/daemon/dist/widgets/explorer/tree.d.ts +0 -13
- package/packages/daemon/dist/widgets/explorer/tree.jsx +0 -108
- package/packages/daemon/dist/widgets/lib/config-model.d.ts +0 -22
- package/packages/daemon/dist/widgets/lib/files.d.ts +0 -11
- package/packages/daemon/dist/widgets/lib/git.d.ts +0 -11
- package/packages/daemon/dist/widgets/lib/grammar.d.ts +0 -79
- package/packages/daemon/dist/widgets/lib/help-overlay.d.ts +0 -19
- package/packages/daemon/dist/widgets/lib/help-overlay.jsx +0 -69
- package/packages/daemon/dist/widgets/lib/pane-comms.d.ts +0 -28
- package/packages/daemon/dist/widgets/lib/theme.d.ts +0 -44
- package/packages/daemon/dist/widgets/lib/watcher.d.ts +0 -9
- package/packages/daemon/dist/widgets/preview/index.jsx +0 -371
- package/packages/daemon/dist/widgets/resolve.d.ts +0 -20
- package/packages/daemon/dist/widgets/setup/agent-naming.d.ts +0 -9
- package/packages/daemon/dist/widgets/setup/agent-naming.jsx +0 -81
- package/packages/daemon/dist/widgets/setup/config-tree.d.ts +0 -13
- package/packages/daemon/dist/widgets/setup/config-tree.jsx +0 -203
- package/packages/daemon/dist/widgets/setup/detect-panel.d.ts +0 -14
- package/packages/daemon/dist/widgets/setup/detect-panel.jsx +0 -48
- package/packages/daemon/dist/widgets/setup/field-editor.d.ts +0 -12
- package/packages/daemon/dist/widgets/setup/field-editor.jsx +0 -163
- package/packages/daemon/dist/widgets/setup/footer.d.ts +0 -17
- package/packages/daemon/dist/widgets/setup/footer.jsx +0 -64
- package/packages/daemon/dist/widgets/setup/index.d.ts +0 -1
- package/packages/daemon/dist/widgets/setup/index.jsx +0 -261
- package/packages/daemon/dist/widgets/setup/layout-picker.d.ts +0 -9
- package/packages/daemon/dist/widgets/setup/layout-picker.jsx +0 -69
- package/packages/daemon/dist/widgets/setup/setup-model.d.ts +0 -15
- package/packages/daemon/dist/widgets/sidebar/index.jsx +0 -462
- package/packages/daemon/src/tui/mirror/control-client.ts +0 -214
- package/packages/daemon/src/tui/mirror/control.ts +0 -97
- package/packages/daemon/src/tui/mirror/focus-border.ts +0 -57
- package/packages/daemon/src/tui/mirror/host-terminal.ts +0 -49
- package/packages/daemon/src/tui/mirror/input-coalescer.ts +0 -105
- package/packages/daemon/src/tui/mirror/session-mirror.ts +0 -724
- package/packages/daemon/src/widgets/setup/orchestrator-panel.tsx +0 -200
- package/scripts/build-cli.mjs +0 -101
- package/scripts/build-macos-notifier.mjs +0 -160
- package/scripts/build-tui.mjs +0 -65
- package/scripts/capture-codex-traffic.mjs +0 -195
- package/scripts/check-src-additions.sh +0 -74
- package/scripts/coverage-summary.mjs +0 -68
- package/scripts/install-git-hooks.js +0 -53
- package/scripts/merge-update-manifests.mjs +0 -58
- package/scripts/merge-update-manifests.test.mjs +0 -82
- package/scripts/pack-check-run.mjs +0 -83
- package/scripts/perf-mirror.mjs +0 -313
- package/scripts/prepublish-check.mjs +0 -80
- package/scripts/publish-tap.sh +0 -55
- package/scripts/stress-test.ts +0 -141
- package/scripts/verify-endpoints.sh +0 -90
- /package/packages/daemon/dist/{server/standalone.d.ts → terminal/mirror/events.js} +0 -0
- /package/packages/daemon/dist/{widgets/changes/index.d.ts → terminal/mirror/trusted-inventory.js} +0 -0
- /package/packages/daemon/dist/{widgets/explorer/index.d.ts → terminal/session-runtime/terminal-interpreter-backend.js} +0 -0
- /package/packages/daemon/dist/{widgets/preview/index.d.ts → tui/mirror/features/changes/contract.js} +0 -0
- /package/packages/daemon/dist/{widgets/sidebar/index.d.ts → tui/mirror/features/dialogs/contract.js} +0 -0
- /package/packages/daemon/src/{tui/mirror → terminal/protocol}/layout-parse.ts +0 -0
|
@@ -0,0 +1,2246 @@
|
|
|
1
|
+
import { accessSync, constants, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import type { createNamedSocketFence } from "../../lib/tmux-named-socket-fence.ts";
|
|
4
|
+
import { isAbsolute } from "node:path";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
TerminalAttachmentSemanticTargetSchemaZ,
|
|
8
|
+
TerminalAttachmentViewportSchemaZ,
|
|
9
|
+
} from "@tmux-ide/contracts";
|
|
10
|
+
import { runTmuxBinary, TmuxError } from "@tmux-ide/tmux-bridge";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
import type { WorkspaceRegistry } from "../../lib/workspace-registry.ts";
|
|
14
|
+
import type { PtyAdapter } from "../PtyAdapter.ts";
|
|
15
|
+
import type { TrustedMirrorSessionInventory } from "../mirror/trusted-inventory.ts";
|
|
16
|
+
import type {
|
|
17
|
+
SessionRuntimeRegistry,
|
|
18
|
+
TrustedSessionInventoryCandidate,
|
|
19
|
+
} from "../session-runtime/registry.ts";
|
|
20
|
+
import {
|
|
21
|
+
DISABLED_SESSION_RUNTIME_OBSERVABILITY,
|
|
22
|
+
type SessionRuntimeObservability,
|
|
23
|
+
} from "../session-runtime/runtime-observability.ts";
|
|
24
|
+
import { SessionRuntimeTransportBinder } from "../session-runtime/transport-binding.ts";
|
|
25
|
+
import {
|
|
26
|
+
captureUnixSocketIdentity,
|
|
27
|
+
revalidateUnixSocketIdentity,
|
|
28
|
+
type UnixSocketIdentity,
|
|
29
|
+
} from "../../lib/unix-socket-authority.ts";
|
|
30
|
+
import {
|
|
31
|
+
TerminalAttachmentAdmissionCoordinator,
|
|
32
|
+
type TerminalAttachmentAdmissionCoordinatorOptions,
|
|
33
|
+
type TerminalAttachmentAdmissionSnapshot,
|
|
34
|
+
type TerminalAttachmentGeometry,
|
|
35
|
+
type TerminalAttachmentGeometryClientProof,
|
|
36
|
+
} from "./direct-websocket.ts";
|
|
37
|
+
import {
|
|
38
|
+
GROUPED_TMUX_MAX_GENERATION,
|
|
39
|
+
GROUPED_TMUX_VIEW_SESSION_PREFIX,
|
|
40
|
+
GROUPED_TMUX_VIEW_MARKER_ENVIRONMENT,
|
|
41
|
+
groupedTmuxViewSessionName,
|
|
42
|
+
type TmuxArgvPlan,
|
|
43
|
+
} from "./grouped-tmux.ts";
|
|
44
|
+
import {
|
|
45
|
+
AttachmentLeaseManager,
|
|
46
|
+
type AttachmentLeaseManagerOptions,
|
|
47
|
+
type AttachmentLeaseDescriptor,
|
|
48
|
+
} from "./lease-manager.ts";
|
|
49
|
+
import {
|
|
50
|
+
PtyTmuxAttachmentLauncher,
|
|
51
|
+
type DaemonTmuxSocketSelector,
|
|
52
|
+
type PtyTmuxAttachmentLauncherOptions,
|
|
53
|
+
} from "./pty-tmux-attachment-launcher.ts";
|
|
54
|
+
import {
|
|
55
|
+
SemanticPaneCatalog,
|
|
56
|
+
analyzeTrustedSemanticPaneCatalog,
|
|
57
|
+
type TrustedSemanticPaneCatalogAnalysis,
|
|
58
|
+
type TrustedSemanticPaneSnapshot,
|
|
59
|
+
} from "./semantic-pane-catalog.ts";
|
|
60
|
+
import {
|
|
61
|
+
TmuxAttachmentOperationSerializer,
|
|
62
|
+
TmuxAttachmentViewExecutor,
|
|
63
|
+
type TmuxAttachmentCommandResult,
|
|
64
|
+
type TmuxAttachmentCommandRunner,
|
|
65
|
+
} from "./tmux-view-executor.ts";
|
|
66
|
+
import type { AgentStatusPaneFacts, AgentStatusProbe } from "./agent-status-probe.ts";
|
|
67
|
+
|
|
68
|
+
const MAX_TMUX_OUTPUT_BYTES = 128 * 1024;
|
|
69
|
+
const TERMINAL_ATTACHMENT_TMUX_COMMAND_TIMEOUT_MS = 5_000;
|
|
70
|
+
const STARTUP_ORPHAN_ENUMERATION_ATTEMPTS = 2;
|
|
71
|
+
const MAX_DISCOVERED_WORKSPACES = 128;
|
|
72
|
+
const MAX_DISCOVERED_PANES = 4_096;
|
|
73
|
+
const MAX_GEOMETRY_CLIENTS = 32;
|
|
74
|
+
const SAFE_SESSION_NAME = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/u;
|
|
75
|
+
const SAFE_TERMINAL_VALUE = /^(?:xterm|screen|tmux|rxvt|vt100|ansi)[A-Za-z0-9+._-]{0,58}$/u;
|
|
76
|
+
const SAFE_COLOR_TERMINAL_VALUE = /^(?:truecolor|24bit)$/u;
|
|
77
|
+
const SAFE_LOCALE_VALUE = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,127}$/u;
|
|
78
|
+
const INTEGER = /^(?:0|[1-9][0-9]*)$/u;
|
|
79
|
+
const VIEW_MISMATCH = "__tmux_ide_geometry_view_mismatch_v1__";
|
|
80
|
+
const SESSION_WIRE_SENTINEL = "tmux-ide-session-v2";
|
|
81
|
+
const PANE_WIRE_SENTINEL = "tmux-ide-pane-v2";
|
|
82
|
+
const WIRE_SEPARATOR = "|tmux-ide-field-v2|";
|
|
83
|
+
const RUNTIME_SESSION_ID = /^\$(?:0|[1-9][0-9]*)$/u;
|
|
84
|
+
const RUNTIME_WINDOW_ID = /^@(?:0|[1-9][0-9]*)$/u;
|
|
85
|
+
const RUNTIME_PANE_ID = /^%(?:0|[1-9][0-9]*)$/u;
|
|
86
|
+
|
|
87
|
+
export type NativeTerminalAttachmentRuntimeErrorCode =
|
|
88
|
+
| "invalid-authority"
|
|
89
|
+
| "discovery-failed"
|
|
90
|
+
| "invalid-tmux-output"
|
|
91
|
+
| "geometry-mismatch"
|
|
92
|
+
| "orphan-reconciliation-failed"
|
|
93
|
+
| "runtime-disposed";
|
|
94
|
+
|
|
95
|
+
const ERROR_MESSAGES: Readonly<Record<NativeTerminalAttachmentRuntimeErrorCode, string>> = {
|
|
96
|
+
"invalid-authority": "The daemon tmux authority is invalid.",
|
|
97
|
+
"discovery-failed": "Trusted semantic pane discovery failed.",
|
|
98
|
+
"invalid-tmux-output": "Trusted tmux discovery returned invalid output.",
|
|
99
|
+
"geometry-mismatch": "Terminal attachment geometry no longer matches its proof.",
|
|
100
|
+
"orphan-reconciliation-failed": "Daemon-owned terminal view startup reconciliation failed.",
|
|
101
|
+
"runtime-disposed": "The native terminal attachment runtime was disposed during startup.",
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export class NativeTerminalAttachmentRuntimeError extends Error {
|
|
105
|
+
readonly code: NativeTerminalAttachmentRuntimeErrorCode;
|
|
106
|
+
|
|
107
|
+
constructor(code: NativeTerminalAttachmentRuntimeErrorCode) {
|
|
108
|
+
super(ERROR_MESSAGES[code]);
|
|
109
|
+
this.name = "NativeTerminalAttachmentRuntimeError";
|
|
110
|
+
this.code = code;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let nativeTerminalAttachmentRuntimeConstructions = 0;
|
|
115
|
+
|
|
116
|
+
/** Test/diagnostic proof that normal pane-stream startup did not construct compatibility PTYs. */
|
|
117
|
+
export function getNativeTerminalAttachmentRuntimeConstructionCount(): number {
|
|
118
|
+
return nativeTerminalAttachmentRuntimeConstructions;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface NativeTerminalAttachmentTmuxAuthority {
|
|
122
|
+
/** Shared with the canonical daemon's named command runners. */
|
|
123
|
+
readonly namedSocketFence?: ReturnType<typeof createNamedSocketFence>;
|
|
124
|
+
readonly executablePath: string;
|
|
125
|
+
readonly socketSelector: DaemonTmuxSocketSelector;
|
|
126
|
+
readonly trustedCwd: string;
|
|
127
|
+
/** Captured once at factory construction; only validated presentation fields survive. */
|
|
128
|
+
readonly environment?: NodeJS.ProcessEnv;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface NativeTerminalAttachmentCommandExecutor {
|
|
132
|
+
(
|
|
133
|
+
executable: string,
|
|
134
|
+
argv: readonly string[],
|
|
135
|
+
options: {
|
|
136
|
+
readonly cwd: string;
|
|
137
|
+
readonly env: NodeJS.ProcessEnv;
|
|
138
|
+
readonly maxBuffer: number;
|
|
139
|
+
readonly timeoutMs: number;
|
|
140
|
+
},
|
|
141
|
+
): string | Buffer;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface NativeTerminalInventoryReadCommandExecutor {
|
|
145
|
+
(
|
|
146
|
+
executable: string,
|
|
147
|
+
argv: readonly string[],
|
|
148
|
+
options: {
|
|
149
|
+
readonly cwd: string;
|
|
150
|
+
readonly env: NodeJS.ProcessEnv;
|
|
151
|
+
readonly maxBuffer: number;
|
|
152
|
+
readonly timeoutMs: number;
|
|
153
|
+
readonly signal?: AbortSignal;
|
|
154
|
+
},
|
|
155
|
+
): Promise<string | Buffer>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface NativeTerminalInventoryReadRunner {
|
|
159
|
+
readonly run: (
|
|
160
|
+
command: TmuxArgvPlan,
|
|
161
|
+
signal?: AbortSignal,
|
|
162
|
+
) => Promise<TmuxAttachmentCommandResult>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface CanonicalTmuxAuthority {
|
|
166
|
+
readonly namedSocketFence: ReturnType<typeof createNamedSocketFence> | null;
|
|
167
|
+
readonly executablePath: string;
|
|
168
|
+
readonly socketSelector: DaemonTmuxSocketSelector;
|
|
169
|
+
readonly socketArgv: readonly string[];
|
|
170
|
+
readonly socketIdentity: UnixSocketIdentity | null;
|
|
171
|
+
readonly trustedCwd: string;
|
|
172
|
+
readonly environment: NodeJS.ProcessEnv;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function presentationEnvironment(source: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
|
176
|
+
const environment: NodeJS.ProcessEnv = {
|
|
177
|
+
TERM: SAFE_TERMINAL_VALUE.test(source.TERM ?? "") ? source.TERM : "xterm-256color",
|
|
178
|
+
};
|
|
179
|
+
if (SAFE_COLOR_TERMINAL_VALUE.test(source.COLORTERM ?? "")) {
|
|
180
|
+
environment.COLORTERM = source.COLORTERM;
|
|
181
|
+
}
|
|
182
|
+
for (const name of ["LANG", "LC_ALL", "LC_CTYPE"] as const) {
|
|
183
|
+
const value = source[name];
|
|
184
|
+
if (value && SAFE_LOCALE_VALUE.test(value)) environment[name] = value;
|
|
185
|
+
}
|
|
186
|
+
return environment;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function canonicalAuthority(input: NativeTerminalAttachmentTmuxAuthority): CanonicalTmuxAuthority {
|
|
190
|
+
try {
|
|
191
|
+
if (!isAbsolute(input.executablePath) || !isAbsolute(input.trustedCwd)) throw new Error();
|
|
192
|
+
const executablePath = realpathSync(input.executablePath);
|
|
193
|
+
const trustedCwd = realpathSync(input.trustedCwd);
|
|
194
|
+
accessSync(executablePath, constants.X_OK);
|
|
195
|
+
if (!statSync(executablePath).isFile() || !statSync(trustedCwd).isDirectory())
|
|
196
|
+
throw new Error();
|
|
197
|
+
let socketSelector: DaemonTmuxSocketSelector;
|
|
198
|
+
let socketArgv: readonly string[];
|
|
199
|
+
let socketIdentity: UnixSocketIdentity | null = null;
|
|
200
|
+
if (input.socketSelector.kind === "path") {
|
|
201
|
+
socketIdentity = captureUnixSocketIdentity(input.socketSelector.path);
|
|
202
|
+
const path = socketIdentity.path;
|
|
203
|
+
socketSelector = { kind: "path", path };
|
|
204
|
+
socketArgv = ["-S", path];
|
|
205
|
+
} else {
|
|
206
|
+
if (!SAFE_SESSION_NAME.test(input.socketSelector.name)) throw new Error();
|
|
207
|
+
socketSelector = { kind: "name", name: input.socketSelector.name };
|
|
208
|
+
socketArgv = ["-L", input.socketSelector.name];
|
|
209
|
+
}
|
|
210
|
+
return Object.freeze({
|
|
211
|
+
namedSocketFence: socketSelector.kind === "name" ? (input.namedSocketFence ?? null) : null,
|
|
212
|
+
executablePath,
|
|
213
|
+
socketSelector: Object.freeze(socketSelector),
|
|
214
|
+
socketArgv: Object.freeze([...socketArgv]),
|
|
215
|
+
socketIdentity,
|
|
216
|
+
trustedCwd,
|
|
217
|
+
environment: Object.freeze(presentationEnvironment(input.environment ?? process.env)),
|
|
218
|
+
});
|
|
219
|
+
} catch {
|
|
220
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-authority");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function currentSocketArgv(authority: CanonicalTmuxAuthority): readonly string[] {
|
|
225
|
+
return authority.socketIdentity
|
|
226
|
+
? ["-S", revalidateUnixSocketIdentity(authority.socketIdentity)]
|
|
227
|
+
: (authority.namedSocketFence?.resolve() ?? authority.socketArgv);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function defaultCommandExecutor(
|
|
231
|
+
executable: string,
|
|
232
|
+
argv: readonly string[],
|
|
233
|
+
options: {
|
|
234
|
+
readonly cwd: string;
|
|
235
|
+
readonly env: NodeJS.ProcessEnv;
|
|
236
|
+
readonly maxBuffer: number;
|
|
237
|
+
readonly timeoutMs: number;
|
|
238
|
+
},
|
|
239
|
+
): string | Buffer {
|
|
240
|
+
return runTmuxBinary(executable, [...argv], {
|
|
241
|
+
cwd: options.cwd,
|
|
242
|
+
encoding: "utf8",
|
|
243
|
+
env: options.env,
|
|
244
|
+
maxBuffer: options.maxBuffer,
|
|
245
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
246
|
+
timeout: options.timeoutMs,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function defaultReadCommandExecutor(
|
|
251
|
+
executable: string,
|
|
252
|
+
argv: readonly string[],
|
|
253
|
+
options: Parameters<NativeTerminalInventoryReadCommandExecutor>[2],
|
|
254
|
+
): Promise<string | Buffer> {
|
|
255
|
+
return new Promise((resolve, reject) => {
|
|
256
|
+
execFile(
|
|
257
|
+
executable,
|
|
258
|
+
[...argv],
|
|
259
|
+
{
|
|
260
|
+
cwd: options.cwd,
|
|
261
|
+
env: options.env,
|
|
262
|
+
encoding: "utf8",
|
|
263
|
+
maxBuffer: options.maxBuffer,
|
|
264
|
+
timeout: options.timeoutMs,
|
|
265
|
+
signal: options.signal,
|
|
266
|
+
windowsHide: true,
|
|
267
|
+
},
|
|
268
|
+
(error, stdout) => (error ? reject(error) : resolve(stdout)),
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function absentNamedServer(error: TmuxError): boolean {
|
|
274
|
+
const cause = error.cause as { stderr?: string | Buffer } | undefined;
|
|
275
|
+
const detail = String(cause?.stderr ?? "").toLowerCase();
|
|
276
|
+
return (
|
|
277
|
+
detail.includes("no server running") ||
|
|
278
|
+
(detail.includes("error connecting to") && detail.includes("no such file or directory"))
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function pinnedRunner(
|
|
283
|
+
authority: CanonicalTmuxAuthority,
|
|
284
|
+
execute: NativeTerminalAttachmentCommandExecutor,
|
|
285
|
+
startupPolicy: { allowUnavailableDefaultEnumeration: boolean },
|
|
286
|
+
): TmuxAttachmentCommandRunner {
|
|
287
|
+
return Object.freeze({
|
|
288
|
+
run(command: TmuxArgvPlan): TmuxAttachmentCommandResult {
|
|
289
|
+
if (command.executable !== "tmux") return { status: "failed" };
|
|
290
|
+
try {
|
|
291
|
+
const stdout = execute(
|
|
292
|
+
authority.executablePath,
|
|
293
|
+
[...currentSocketArgv(authority), ...command.argv],
|
|
294
|
+
{
|
|
295
|
+
cwd: authority.trustedCwd,
|
|
296
|
+
env: authority.environment,
|
|
297
|
+
maxBuffer: MAX_TMUX_OUTPUT_BYTES,
|
|
298
|
+
timeoutMs: TERMINAL_ATTACHMENT_TMUX_COMMAND_TIMEOUT_MS,
|
|
299
|
+
},
|
|
300
|
+
);
|
|
301
|
+
const value = String(stdout);
|
|
302
|
+
if (authority.namedSocketFence && !authority.namedSocketFence.isPinned())
|
|
303
|
+
authority.namedSocketFence.resolve();
|
|
304
|
+
if (value.includes("\0") || Buffer.byteLength(value, "utf8") > MAX_TMUX_OUTPUT_BYTES) {
|
|
305
|
+
return { status: "failed" };
|
|
306
|
+
}
|
|
307
|
+
return { status: "ok", stdout: value };
|
|
308
|
+
} catch (error) {
|
|
309
|
+
if (error instanceof TmuxError && error.code === "SESSION_NOT_FOUND") {
|
|
310
|
+
return { status: "not-found" };
|
|
311
|
+
}
|
|
312
|
+
if (
|
|
313
|
+
error instanceof TmuxError &&
|
|
314
|
+
error.code === "TMUX_UNAVAILABLE" &&
|
|
315
|
+
startupPolicy.allowUnavailableDefaultEnumeration &&
|
|
316
|
+
authority.socketSelector.kind === "name" &&
|
|
317
|
+
(authority.socketSelector.name === "default" || absentNamedServer(error)) &&
|
|
318
|
+
command.argv.length === 3 &&
|
|
319
|
+
command.argv[0] === "list-sessions" &&
|
|
320
|
+
command.argv[1] === "-F" &&
|
|
321
|
+
command.argv[2] === "#{session_name}|tmux-ide-view-field-v1|#{session_id}"
|
|
322
|
+
) {
|
|
323
|
+
// The daemon may cold-start before a named tmux server even when
|
|
324
|
+
// durable workspace intent exists. This one construction-time orphan
|
|
325
|
+
// enumeration means zero LIVE sessions; every other command and
|
|
326
|
+
// inaccessible named sockets and every explicit path remain strict.
|
|
327
|
+
return { status: "not-found" };
|
|
328
|
+
}
|
|
329
|
+
if (error instanceof TmuxError && error.code === "ENVIRONMENT_VARIABLE_NOT_FOUND") {
|
|
330
|
+
return { status: "variable-not-found" };
|
|
331
|
+
}
|
|
332
|
+
return { status: "failed" };
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function readErrorCode(error: unknown): string {
|
|
339
|
+
if (error instanceof TmuxError) return error.code;
|
|
340
|
+
const raw = (error as { stderr?: string | Buffer })?.stderr;
|
|
341
|
+
const detail = (
|
|
342
|
+
Buffer.isBuffer(raw) ? raw.toString("utf8") : (raw ?? String(error))
|
|
343
|
+
).toLowerCase();
|
|
344
|
+
if (
|
|
345
|
+
["can't find session", "can't find window", "can't find pane", "unknown target"].some((v) =>
|
|
346
|
+
detail.includes(v),
|
|
347
|
+
)
|
|
348
|
+
)
|
|
349
|
+
return "SESSION_NOT_FOUND";
|
|
350
|
+
if (detail.includes("unknown variable:")) return "ENVIRONMENT_VARIABLE_NOT_FOUND";
|
|
351
|
+
if (
|
|
352
|
+
[
|
|
353
|
+
"failed to connect to server",
|
|
354
|
+
"no server running",
|
|
355
|
+
"error connecting to",
|
|
356
|
+
"connection refused",
|
|
357
|
+
].some((v) => detail.includes(v))
|
|
358
|
+
)
|
|
359
|
+
return "TMUX_UNAVAILABLE";
|
|
360
|
+
return "TMUX_ERROR";
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function pinnedReadRunner(
|
|
364
|
+
authority: CanonicalTmuxAuthority,
|
|
365
|
+
execute: NativeTerminalInventoryReadCommandExecutor,
|
|
366
|
+
): NativeTerminalInventoryReadRunner {
|
|
367
|
+
return Object.freeze({
|
|
368
|
+
async run(command: TmuxArgvPlan, signal?: AbortSignal): Promise<TmuxAttachmentCommandResult> {
|
|
369
|
+
if (command.executable !== "tmux" || signal?.aborted) return { status: "failed" };
|
|
370
|
+
try {
|
|
371
|
+
const stdout = await execute(
|
|
372
|
+
authority.executablePath,
|
|
373
|
+
[
|
|
374
|
+
...(authority.namedSocketFence
|
|
375
|
+
? await authority.namedSocketFence.resolveAsync(signal)
|
|
376
|
+
: currentSocketArgv(authority)),
|
|
377
|
+
...command.argv,
|
|
378
|
+
],
|
|
379
|
+
{
|
|
380
|
+
cwd: authority.trustedCwd,
|
|
381
|
+
env: authority.environment,
|
|
382
|
+
maxBuffer: MAX_TMUX_OUTPUT_BYTES,
|
|
383
|
+
timeoutMs: TERMINAL_ATTACHMENT_TMUX_COMMAND_TIMEOUT_MS,
|
|
384
|
+
...(signal ? { signal } : {}),
|
|
385
|
+
},
|
|
386
|
+
);
|
|
387
|
+
const value = String(stdout);
|
|
388
|
+
if (authority.namedSocketFence && !authority.namedSocketFence.isPinned())
|
|
389
|
+
await authority.namedSocketFence.resolveAsync(signal);
|
|
390
|
+
if (value.includes("\0") || Buffer.byteLength(value, "utf8") > MAX_TMUX_OUTPUT_BYTES)
|
|
391
|
+
return { status: "failed" };
|
|
392
|
+
return { status: "ok", stdout: value };
|
|
393
|
+
} catch (error) {
|
|
394
|
+
const code = readErrorCode(error);
|
|
395
|
+
if (code === "SESSION_NOT_FOUND") return { status: "not-found" };
|
|
396
|
+
if (code === "ENVIRONMENT_VARIABLE_NOT_FOUND") return { status: "variable-not-found" };
|
|
397
|
+
return { status: "failed" };
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function strictLines(stdout: string, maximum: number): readonly string[] {
|
|
404
|
+
if (
|
|
405
|
+
typeof stdout !== "string" ||
|
|
406
|
+
stdout.includes("\0") ||
|
|
407
|
+
Buffer.byteLength(stdout, "utf8") > MAX_TMUX_OUTPUT_BYTES
|
|
408
|
+
) {
|
|
409
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
410
|
+
}
|
|
411
|
+
const normalized = stdout.replace(/(?:\r?\n)+$/u, "");
|
|
412
|
+
if (normalized === "") return [];
|
|
413
|
+
const lines = normalized.split("\n");
|
|
414
|
+
if (lines.length > maximum || lines.some((line) => line.includes("\r"))) {
|
|
415
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
416
|
+
}
|
|
417
|
+
return lines;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function positiveInteger(value: string): number {
|
|
421
|
+
if (!INTEGER.test(value)) throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
422
|
+
const parsed = Number(value);
|
|
423
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
424
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
425
|
+
}
|
|
426
|
+
return parsed;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function nonnegativeInteger(value: string): number {
|
|
430
|
+
if (!INTEGER.test(value)) throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
431
|
+
const parsed = Number(value);
|
|
432
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
433
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
434
|
+
}
|
|
435
|
+
return parsed;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function boundedWireValue(value: string, maximum: number, allowEmpty = true): string {
|
|
439
|
+
if (value.length > maximum || (!allowEmpty && value.length === 0) || /[\0\r\n\t]/u.test(value)) {
|
|
440
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
441
|
+
}
|
|
442
|
+
return value;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function viewport(cols: string, rows: string): TerminalAttachmentGeometry["sourceGrid"] {
|
|
446
|
+
try {
|
|
447
|
+
return TerminalAttachmentViewportSchemaZ.parse({
|
|
448
|
+
cols: positiveInteger(cols),
|
|
449
|
+
rows: positiveInteger(rows),
|
|
450
|
+
});
|
|
451
|
+
} catch {
|
|
452
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export type NativeTerminalInventoryCatalogIssue =
|
|
457
|
+
| "invalid-runtime-proof"
|
|
458
|
+
| "missing-semantic-stamp"
|
|
459
|
+
| "duplicate-semantic-stamp"
|
|
460
|
+
| "duplicate-runtime-pane-binding";
|
|
461
|
+
|
|
462
|
+
export interface NativeTerminalInventoryPaneSnapshot extends TrustedSemanticPaneSnapshot {
|
|
463
|
+
readonly sessionName: string;
|
|
464
|
+
readonly index: number;
|
|
465
|
+
readonly title: string;
|
|
466
|
+
readonly currentCommand: string;
|
|
467
|
+
readonly active: boolean;
|
|
468
|
+
readonly role: string | null;
|
|
469
|
+
readonly name: string | null;
|
|
470
|
+
readonly type: string | null;
|
|
471
|
+
/** Durable `@tmux_ide_mission` creation stamp, or null when unset. */
|
|
472
|
+
readonly missionStamp: string | null;
|
|
473
|
+
readonly dir: string;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export interface NativeTerminalInventorySnapshot {
|
|
477
|
+
readonly panes: readonly NativeTerminalInventoryPaneSnapshot[];
|
|
478
|
+
readonly catalog: TrustedSemanticPaneCatalogAnalysis;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export interface NativeApplicationShellSessionSnapshot {
|
|
482
|
+
readonly name: string;
|
|
483
|
+
readonly runtimeSessionId: string;
|
|
484
|
+
readonly dir: string;
|
|
485
|
+
readonly catalogIssue: NativeTerminalInventoryCatalogIssue | null;
|
|
486
|
+
readonly panes: readonly (Omit<
|
|
487
|
+
NativeTerminalInventoryPaneSnapshot,
|
|
488
|
+
"workspaceName" | "sessionName" | "sessionId" | "sessionWindowCount" | "dir"
|
|
489
|
+
> &
|
|
490
|
+
Partial<AgentStatusPaneFacts>)[];
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Agent-free topology facts used by the terminal-runtime inventory resource. */
|
|
494
|
+
export interface NativeTerminalRuntimeSessionSnapshot extends NativeApplicationShellSessionSnapshot {
|
|
495
|
+
readonly workspaceName: string;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function projectTrustedMirrorInventory(
|
|
499
|
+
trusted: TrustedMirrorSessionInventory,
|
|
500
|
+
workspaceName: string,
|
|
501
|
+
expectedSessionName: string,
|
|
502
|
+
): readonly NativeTerminalInventoryPaneSnapshot[] {
|
|
503
|
+
if (
|
|
504
|
+
typeof trusted !== "object" ||
|
|
505
|
+
trusted === null ||
|
|
506
|
+
typeof trusted.sessionName !== "string" ||
|
|
507
|
+
typeof trusted.runtimeSessionId !== "string" ||
|
|
508
|
+
!Array.isArray(trusted.panes) ||
|
|
509
|
+
trusted.sessionName !== expectedSessionName ||
|
|
510
|
+
!RUNTIME_SESSION_ID.test(trusted.runtimeSessionId) ||
|
|
511
|
+
trusted.panes.length === 0 ||
|
|
512
|
+
trusted.panes.length > MAX_DISCOVERED_PANES ||
|
|
513
|
+
Buffer.byteLength(JSON.stringify(trusted), "utf8") > MAX_TMUX_OUTPUT_BYTES
|
|
514
|
+
) {
|
|
515
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
516
|
+
}
|
|
517
|
+
const runtimePaneIds = new Set<string>();
|
|
518
|
+
const windowCounts = new Map<string, number>();
|
|
519
|
+
let activeCount = 0;
|
|
520
|
+
const panes = trusted.panes.map((pane) => {
|
|
521
|
+
if (
|
|
522
|
+
typeof pane !== "object" ||
|
|
523
|
+
pane === null ||
|
|
524
|
+
typeof pane.runtimeSessionId !== "string" ||
|
|
525
|
+
typeof pane.runtimeWindowId !== "string" ||
|
|
526
|
+
typeof pane.runtimePaneId !== "string" ||
|
|
527
|
+
typeof pane.semanticWindowId !== "string" ||
|
|
528
|
+
typeof pane.semanticPaneId !== "string" ||
|
|
529
|
+
typeof pane.title !== "string" ||
|
|
530
|
+
typeof pane.currentCommand !== "string" ||
|
|
531
|
+
typeof pane.dir !== "string" ||
|
|
532
|
+
typeof pane.active !== "boolean" ||
|
|
533
|
+
(pane.role !== null && typeof pane.role !== "string") ||
|
|
534
|
+
(pane.name !== null && typeof pane.name !== "string") ||
|
|
535
|
+
(pane.type !== null && typeof pane.type !== "string") ||
|
|
536
|
+
(pane.missionStamp !== null && typeof pane.missionStamp !== "string") ||
|
|
537
|
+
pane.runtimeSessionId !== trusted.runtimeSessionId ||
|
|
538
|
+
!RUNTIME_WINDOW_ID.test(pane.runtimeWindowId) ||
|
|
539
|
+
!RUNTIME_PANE_ID.test(pane.runtimePaneId) ||
|
|
540
|
+
runtimePaneIds.has(pane.runtimePaneId) ||
|
|
541
|
+
!Number.isSafeInteger(pane.windowPaneCount) ||
|
|
542
|
+
pane.windowPaneCount < 1 ||
|
|
543
|
+
!Number.isSafeInteger(pane.sessionWindowCount) ||
|
|
544
|
+
pane.sessionWindowCount < 1 ||
|
|
545
|
+
!Number.isSafeInteger(pane.paneIndex) ||
|
|
546
|
+
pane.paneIndex < 0
|
|
547
|
+
) {
|
|
548
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
549
|
+
}
|
|
550
|
+
runtimePaneIds.add(pane.runtimePaneId);
|
|
551
|
+
windowCounts.set(pane.runtimeWindowId, (windowCounts.get(pane.runtimeWindowId) ?? 0) + 1);
|
|
552
|
+
if (pane.active) activeCount += 1;
|
|
553
|
+
const nullable = (value: string | null): string | null =>
|
|
554
|
+
value === null ? null : boundedWireValue(value, 256);
|
|
555
|
+
return Object.freeze({
|
|
556
|
+
workspaceName,
|
|
557
|
+
semanticPaneId: nullable(pane.semanticPaneId),
|
|
558
|
+
windowStamp: nullable(pane.semanticWindowId),
|
|
559
|
+
sessionId: pane.runtimeSessionId,
|
|
560
|
+
windowId: pane.runtimeWindowId,
|
|
561
|
+
runtimePaneId: pane.runtimePaneId,
|
|
562
|
+
windowPaneCount: pane.windowPaneCount,
|
|
563
|
+
sessionWindowCount: pane.sessionWindowCount,
|
|
564
|
+
sessionName: boundedWireValue(trusted.sessionName, 160, false),
|
|
565
|
+
index: pane.paneIndex,
|
|
566
|
+
title: boundedWireValue(pane.title, 1_024),
|
|
567
|
+
currentCommand: boundedWireValue(pane.currentCommand, 512),
|
|
568
|
+
active: pane.active,
|
|
569
|
+
role: nullable(pane.role),
|
|
570
|
+
name: nullable(pane.name),
|
|
571
|
+
type: nullable(pane.type),
|
|
572
|
+
missionStamp: nullable(pane.missionStamp),
|
|
573
|
+
dir: boundedWireValue(pane.dir, 4_096),
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
if (
|
|
577
|
+
activeCount !== 1 ||
|
|
578
|
+
panes.some(
|
|
579
|
+
(pane) =>
|
|
580
|
+
pane.windowPaneCount !== windowCounts.get(pane.windowId) ||
|
|
581
|
+
pane.sessionWindowCount !== windowCounts.size,
|
|
582
|
+
)
|
|
583
|
+
) {
|
|
584
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
585
|
+
}
|
|
586
|
+
return Object.freeze(panes);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
async function awaitInventoryUnlessAborted<T>(
|
|
590
|
+
promise: Promise<T>,
|
|
591
|
+
signal: AbortSignal,
|
|
592
|
+
): Promise<T> {
|
|
593
|
+
if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
594
|
+
let rejectAbort!: (cause: unknown) => void;
|
|
595
|
+
const aborted = new Promise<never>((_resolve, reject) => {
|
|
596
|
+
rejectAbort = reject;
|
|
597
|
+
});
|
|
598
|
+
const onAbort = (): void =>
|
|
599
|
+
rejectAbort(new NativeTerminalAttachmentRuntimeError("runtime-disposed"));
|
|
600
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
601
|
+
try {
|
|
602
|
+
return await Promise.race([promise, aborted]);
|
|
603
|
+
} finally {
|
|
604
|
+
signal.removeEventListener("abort", onAbort);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
const SESSION_FORMAT = ["#{session_name}", "#{session_id}", SESSION_WIRE_SENTINEL].join(
|
|
609
|
+
WIRE_SEPARATOR,
|
|
610
|
+
);
|
|
611
|
+
const PANE_FORMAT = [
|
|
612
|
+
"#{session_name}",
|
|
613
|
+
"#{session_id}",
|
|
614
|
+
"#{window_id}",
|
|
615
|
+
"#{pane_id}",
|
|
616
|
+
"#{window_panes}",
|
|
617
|
+
"#{session_windows}",
|
|
618
|
+
"#{@tmux_ide_pane_id}",
|
|
619
|
+
"#{pane_index}",
|
|
620
|
+
"#{pane_title}",
|
|
621
|
+
"#{pane_current_command}",
|
|
622
|
+
"#{window_active}",
|
|
623
|
+
"#{pane_active}",
|
|
624
|
+
"#{@ide_role}",
|
|
625
|
+
"#{@ide_name}",
|
|
626
|
+
"#{@ide_type}",
|
|
627
|
+
"#{@tmux_ide_mission}",
|
|
628
|
+
"#{pane_current_path}",
|
|
629
|
+
// Durable window stamp (m41). It is a WINDOW option, so every pane of a
|
|
630
|
+
// window reports the same value; the catalog requires it before a multi-pane
|
|
631
|
+
// window is attachable.
|
|
632
|
+
"#{@tmux_ide_window_id}",
|
|
633
|
+
PANE_WIRE_SENTINEL,
|
|
634
|
+
].join(WIRE_SEPARATOR);
|
|
635
|
+
|
|
636
|
+
async function requiredTmuxResult(
|
|
637
|
+
runner: NativeTerminalInventoryReadRunner,
|
|
638
|
+
argv: readonly string[],
|
|
639
|
+
signal?: AbortSignal,
|
|
640
|
+
): Promise<string | null> {
|
|
641
|
+
const result = await runner.run({ executable: "tmux", argv }, signal);
|
|
642
|
+
if (result.status === "not-found") return null;
|
|
643
|
+
if (result.status !== "ok") {
|
|
644
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
645
|
+
}
|
|
646
|
+
return result.stdout;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
interface LiveSessionIdentity {
|
|
650
|
+
readonly name: string;
|
|
651
|
+
readonly id: string;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
async function liveSessionIdentities(
|
|
655
|
+
runner: NativeTerminalInventoryReadRunner,
|
|
656
|
+
signal?: AbortSignal,
|
|
657
|
+
): Promise<readonly LiveSessionIdentity[]> {
|
|
658
|
+
const stdout = await requiredTmuxResult(runner, ["list-sessions", "-F", SESSION_FORMAT], signal);
|
|
659
|
+
if (stdout === null) return [];
|
|
660
|
+
const identities: LiveSessionIdentity[] = [];
|
|
661
|
+
const names = new Set<string>();
|
|
662
|
+
const ids = new Set<string>();
|
|
663
|
+
for (const line of strictLines(stdout, MAX_DISCOVERED_WORKSPACES * 4)) {
|
|
664
|
+
const fields = line.split(WIRE_SEPARATOR);
|
|
665
|
+
if (fields.length !== 3 || fields[2] !== SESSION_WIRE_SENTINEL) {
|
|
666
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
667
|
+
}
|
|
668
|
+
const name = boundedWireValue(fields[0]!, 160, false);
|
|
669
|
+
const id = fields[1]!;
|
|
670
|
+
if (!RUNTIME_SESSION_ID.test(id) || names.has(name) || ids.has(id)) {
|
|
671
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
672
|
+
}
|
|
673
|
+
names.add(name);
|
|
674
|
+
ids.add(id);
|
|
675
|
+
identities.push({ name, id });
|
|
676
|
+
}
|
|
677
|
+
return identities;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
type LivePaneFacts = Omit<NativeTerminalInventoryPaneSnapshot, "workspaceName">;
|
|
681
|
+
|
|
682
|
+
function parsePaneSnapshot(
|
|
683
|
+
stdout: string,
|
|
684
|
+
expected: LiveSessionIdentity,
|
|
685
|
+
): readonly LivePaneFacts[] {
|
|
686
|
+
const panes: LivePaneFacts[] = [];
|
|
687
|
+
const runtimeIds = new Set<string>();
|
|
688
|
+
for (const line of strictLines(stdout, MAX_DISCOVERED_PANES)) {
|
|
689
|
+
const fields = line.split(WIRE_SEPARATOR);
|
|
690
|
+
if (fields.length !== 19 || fields[18] !== PANE_WIRE_SENTINEL) {
|
|
691
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
692
|
+
}
|
|
693
|
+
const [
|
|
694
|
+
sessionName,
|
|
695
|
+
sessionId,
|
|
696
|
+
windowId,
|
|
697
|
+
runtimePaneId,
|
|
698
|
+
paneCountValue,
|
|
699
|
+
windowCountValue,
|
|
700
|
+
stamp,
|
|
701
|
+
indexValue,
|
|
702
|
+
title,
|
|
703
|
+
currentCommand,
|
|
704
|
+
windowActive,
|
|
705
|
+
paneActive,
|
|
706
|
+
role,
|
|
707
|
+
name,
|
|
708
|
+
type,
|
|
709
|
+
missionStamp,
|
|
710
|
+
dir,
|
|
711
|
+
windowStampValue,
|
|
712
|
+
] = fields as [
|
|
713
|
+
string,
|
|
714
|
+
string,
|
|
715
|
+
string,
|
|
716
|
+
string,
|
|
717
|
+
string,
|
|
718
|
+
string,
|
|
719
|
+
string,
|
|
720
|
+
string,
|
|
721
|
+
string,
|
|
722
|
+
string,
|
|
723
|
+
string,
|
|
724
|
+
string,
|
|
725
|
+
string,
|
|
726
|
+
string,
|
|
727
|
+
string,
|
|
728
|
+
string,
|
|
729
|
+
string,
|
|
730
|
+
string,
|
|
731
|
+
string,
|
|
732
|
+
];
|
|
733
|
+
if (
|
|
734
|
+
sessionName !== expected.name ||
|
|
735
|
+
sessionId !== expected.id ||
|
|
736
|
+
!RUNTIME_WINDOW_ID.test(windowId) ||
|
|
737
|
+
!RUNTIME_PANE_ID.test(runtimePaneId) ||
|
|
738
|
+
runtimeIds.has(runtimePaneId) ||
|
|
739
|
+
!["0", "1"].includes(windowActive) ||
|
|
740
|
+
!["0", "1"].includes(paneActive)
|
|
741
|
+
) {
|
|
742
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
743
|
+
}
|
|
744
|
+
runtimeIds.add(runtimePaneId);
|
|
745
|
+
const nullable = (value: string): string | null =>
|
|
746
|
+
boundedWireValue(value, 256).length === 0 ? null : value;
|
|
747
|
+
panes.push({
|
|
748
|
+
sessionName,
|
|
749
|
+
sessionId,
|
|
750
|
+
windowId,
|
|
751
|
+
runtimePaneId,
|
|
752
|
+
windowPaneCount: positiveInteger(paneCountValue),
|
|
753
|
+
sessionWindowCount: positiveInteger(windowCountValue),
|
|
754
|
+
semanticPaneId: nullable(stamp),
|
|
755
|
+
windowStamp: nullable(windowStampValue),
|
|
756
|
+
index: nonnegativeInteger(indexValue),
|
|
757
|
+
title: boundedWireValue(title, 1_024),
|
|
758
|
+
currentCommand: boundedWireValue(currentCommand, 512),
|
|
759
|
+
active: windowActive === "1" && paneActive === "1",
|
|
760
|
+
role: nullable(role),
|
|
761
|
+
name: nullable(name),
|
|
762
|
+
type: nullable(type),
|
|
763
|
+
missionStamp: nullable(missionStamp),
|
|
764
|
+
// tmux can temporarily report an empty pane_current_path for a valid
|
|
765
|
+
// foreground pipeline after its process-group leader exits. The
|
|
766
|
+
// registered workspace remains the trusted application-shell root, so
|
|
767
|
+
// keep discovery available and carry the empty presentation value.
|
|
768
|
+
dir: boundedWireValue(dir, 4_096),
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
const counts = new Map<string, number>();
|
|
772
|
+
for (const pane of panes) counts.set(pane.windowId, (counts.get(pane.windowId) ?? 0) + 1);
|
|
773
|
+
const windows = new Set(panes.map((pane) => pane.windowId));
|
|
774
|
+
if (
|
|
775
|
+
panes.some(
|
|
776
|
+
(pane) =>
|
|
777
|
+
counts.get(pane.windowId) !== pane.windowPaneCount ||
|
|
778
|
+
windows.size !== pane.sessionWindowCount,
|
|
779
|
+
) ||
|
|
780
|
+
panes.filter((pane) => pane.active).length > 1
|
|
781
|
+
) {
|
|
782
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
783
|
+
}
|
|
784
|
+
return panes;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* One bounded, old-tmux-safe discovery path for both live attachment and the
|
|
789
|
+
* application-shell inventory. Names are resolved exactly to `$session_id`
|
|
790
|
+
* before any pane query, and a second identity/topology snapshot closes races.
|
|
791
|
+
*/
|
|
792
|
+
export async function discoverWorkspaceRegistryTerminalInventory(
|
|
793
|
+
registry: WorkspaceRegistry,
|
|
794
|
+
runner: NativeTerminalInventoryReadRunner,
|
|
795
|
+
signal?: AbortSignal,
|
|
796
|
+
): Promise<NativeTerminalInventorySnapshot> {
|
|
797
|
+
const workspaces = registry.list();
|
|
798
|
+
if (workspaces.length > MAX_DISCOVERED_WORKSPACES) {
|
|
799
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
800
|
+
}
|
|
801
|
+
if (workspaces.length === 0) {
|
|
802
|
+
const catalog = analyzeTrustedSemanticPaneCatalog([]);
|
|
803
|
+
return Object.freeze({ panes: Object.freeze([]), catalog });
|
|
804
|
+
}
|
|
805
|
+
const liveSessions = await liveSessionIdentities(runner, signal);
|
|
806
|
+
const byName = new Map(liveSessions.map((session) => [session.name, session]));
|
|
807
|
+
const uniqueSessionNames = new Set(workspaces.map((workspace) => workspace.sessionName));
|
|
808
|
+
const bySessionName = new Map<string, readonly LivePaneFacts[]>();
|
|
809
|
+
for (const sessionName of uniqueSessionNames) {
|
|
810
|
+
const identity = byName.get(sessionName);
|
|
811
|
+
if (!identity) continue;
|
|
812
|
+
const argv = ["list-panes", "-s", "-t", identity.id, "-F", PANE_FORMAT] as const;
|
|
813
|
+
const before = await requiredTmuxResult(runner, argv, signal);
|
|
814
|
+
if (before === null) continue;
|
|
815
|
+
const panes = parsePaneSnapshot(before, identity);
|
|
816
|
+
const after = await requiredTmuxResult(runner, argv, signal);
|
|
817
|
+
if (after === null) throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
818
|
+
const latest = parsePaneSnapshot(after, identity);
|
|
819
|
+
// Foreground commands, titles, focus and paths can change while the same
|
|
820
|
+
// pane remains valid. Fence binding/topology only, then publish one complete
|
|
821
|
+
// latest snapshot rather than mixing presentation values across reads.
|
|
822
|
+
const proofKeys = [
|
|
823
|
+
"sessionName",
|
|
824
|
+
"sessionId",
|
|
825
|
+
"windowId",
|
|
826
|
+
"runtimePaneId",
|
|
827
|
+
"windowPaneCount",
|
|
828
|
+
"sessionWindowCount",
|
|
829
|
+
"semanticPaneId",
|
|
830
|
+
"windowStamp",
|
|
831
|
+
"index",
|
|
832
|
+
] as const;
|
|
833
|
+
if (
|
|
834
|
+
panes.length !== latest.length ||
|
|
835
|
+
panes.some((pane, index) => proofKeys.some((key) => pane[key] !== latest[index]![key]))
|
|
836
|
+
) {
|
|
837
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
838
|
+
}
|
|
839
|
+
bySessionName.set(sessionName, latest);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
const panes: NativeTerminalInventoryPaneSnapshot[] = [];
|
|
843
|
+
for (const workspace of workspaces) {
|
|
844
|
+
for (const pane of bySessionName.get(workspace.sessionName) ?? []) {
|
|
845
|
+
panes.push({ ...pane, workspaceName: workspace.name });
|
|
846
|
+
if (panes.length > MAX_DISCOVERED_PANES) {
|
|
847
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
const catalog = analyzeTrustedSemanticPaneCatalog(
|
|
852
|
+
panes.map(
|
|
853
|
+
({
|
|
854
|
+
sessionName: _sessionName,
|
|
855
|
+
index: _index,
|
|
856
|
+
title: _title,
|
|
857
|
+
currentCommand: _currentCommand,
|
|
858
|
+
active: _active,
|
|
859
|
+
role: _role,
|
|
860
|
+
name: _name,
|
|
861
|
+
type: _type,
|
|
862
|
+
missionStamp: _missionStamp,
|
|
863
|
+
dir: _dir,
|
|
864
|
+
...row
|
|
865
|
+
}) => row,
|
|
866
|
+
),
|
|
867
|
+
);
|
|
868
|
+
return Object.freeze({ panes: Object.freeze(panes), catalog });
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** Internal raw-id discovery; callers expose only SemanticPaneCatalog resolution. */
|
|
872
|
+
export async function discoverWorkspaceRegistrySemanticPanes(
|
|
873
|
+
registry: WorkspaceRegistry,
|
|
874
|
+
runner: NativeTerminalInventoryReadRunner,
|
|
875
|
+
signal?: AbortSignal,
|
|
876
|
+
): Promise<readonly TrustedSemanticPaneSnapshot[]> {
|
|
877
|
+
const inventory = await discoverWorkspaceRegistryTerminalInventory(registry, runner, signal);
|
|
878
|
+
return inventory.panes.map(
|
|
879
|
+
({
|
|
880
|
+
sessionName: _sessionName,
|
|
881
|
+
index: _index,
|
|
882
|
+
title: _title,
|
|
883
|
+
currentCommand: _currentCommand,
|
|
884
|
+
active: _active,
|
|
885
|
+
role: _role,
|
|
886
|
+
name: _name,
|
|
887
|
+
type: _type,
|
|
888
|
+
missionStamp: _missionStamp,
|
|
889
|
+
dir: _dir,
|
|
890
|
+
...row
|
|
891
|
+
}) => row,
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function quoteArgument(value: string): string {
|
|
896
|
+
if (/\0|\r|\n/u.test(value)) {
|
|
897
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
898
|
+
}
|
|
899
|
+
return JSON.stringify(value);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
function commandString(argv: readonly string[]): string {
|
|
903
|
+
return argv.map((value) => (value === ";" ? ";" : quoteArgument(value))).join(" ");
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function geometryDescriptorIsValid(
|
|
907
|
+
descriptor: AttachmentLeaseDescriptor,
|
|
908
|
+
client: TerminalAttachmentGeometryClientProof,
|
|
909
|
+
): boolean {
|
|
910
|
+
return (
|
|
911
|
+
z.uuid().safeParse(descriptor.leaseId).success &&
|
|
912
|
+
z.uuid().safeParse(descriptor.requestId).success &&
|
|
913
|
+
TerminalAttachmentSemanticTargetSchemaZ.safeParse(descriptor.target).success &&
|
|
914
|
+
descriptor.status === "active" &&
|
|
915
|
+
Number.isSafeInteger(descriptor.bindingGeneration) &&
|
|
916
|
+
descriptor.bindingGeneration >= 0 &&
|
|
917
|
+
Number.isSafeInteger(descriptor.viewGeneration) &&
|
|
918
|
+
descriptor.viewGeneration >= 0 &&
|
|
919
|
+
descriptor.viewGeneration <= GROUPED_TMUX_MAX_GENERATION &&
|
|
920
|
+
z.uuid().safeParse(client.attemptId).success &&
|
|
921
|
+
client.attachmentId === descriptor.leaseId &&
|
|
922
|
+
client.generation === descriptor.viewGeneration &&
|
|
923
|
+
Number.isSafeInteger(client.pid) &&
|
|
924
|
+
client.pid > 0
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
export class NativeTerminalAttachmentGeometryResolver {
|
|
929
|
+
readonly #catalog: SemanticPaneCatalog;
|
|
930
|
+
readonly #runner: TmuxAttachmentCommandRunner;
|
|
931
|
+
readonly #serializer: TmuxAttachmentOperationSerializer;
|
|
932
|
+
|
|
933
|
+
constructor(options: {
|
|
934
|
+
catalog: SemanticPaneCatalog;
|
|
935
|
+
runner: TmuxAttachmentCommandRunner;
|
|
936
|
+
operationSerializer: TmuxAttachmentOperationSerializer;
|
|
937
|
+
}) {
|
|
938
|
+
this.#catalog = options.catalog;
|
|
939
|
+
this.#runner = options.runner;
|
|
940
|
+
this.#serializer = options.operationSerializer;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
resolve(
|
|
944
|
+
descriptor: AttachmentLeaseDescriptor,
|
|
945
|
+
client: TerminalAttachmentGeometryClientProof,
|
|
946
|
+
): Promise<TerminalAttachmentGeometry> {
|
|
947
|
+
return this.#serializer.run(() => this.#resolve(descriptor, client));
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
async #resolve(
|
|
951
|
+
descriptor: AttachmentLeaseDescriptor,
|
|
952
|
+
client: TerminalAttachmentGeometryClientProof,
|
|
953
|
+
): Promise<TerminalAttachmentGeometry> {
|
|
954
|
+
if (!geometryDescriptorIsValid(descriptor, client)) {
|
|
955
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
956
|
+
}
|
|
957
|
+
let resolution;
|
|
958
|
+
try {
|
|
959
|
+
resolution = await this.#catalog.resolve(descriptor.target);
|
|
960
|
+
} catch {
|
|
961
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
962
|
+
}
|
|
963
|
+
if (
|
|
964
|
+
resolution.bindingGeneration !== descriptor.bindingGeneration ||
|
|
965
|
+
resolution.target.workspaceName !== descriptor.target.workspaceName ||
|
|
966
|
+
resolution.target.semanticPaneId !== descriptor.target.semanticPaneId
|
|
967
|
+
) {
|
|
968
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
969
|
+
}
|
|
970
|
+
const source = resolution.source;
|
|
971
|
+
const viewName = groupedTmuxViewSessionName(descriptor.leaseId, descriptor.viewGeneration);
|
|
972
|
+
const marker = `v1:${descriptor.leaseId.toLowerCase()}:${descriptor.viewGeneration}`;
|
|
973
|
+
const sourceTarget = `${source.sessionId}:${source.windowId}.${source.runtimePaneId}`;
|
|
974
|
+
const viewTarget = `=${viewName}:${source.windowId}.${source.runtimePaneId}`;
|
|
975
|
+
// The `=name` target is exact. The session-local marker then proves that
|
|
976
|
+
// exact view's ownership while the linked global window id and single-window
|
|
977
|
+
// topology prove its contents. The exact target already selects the expected
|
|
978
|
+
// global pane id; tmux does not populate `pane_id` in this if-shell format
|
|
979
|
+
// context on all supported versions. m41 attach-2 drops the former
|
|
980
|
+
// `window_panes == 1` gate so a multi-pane linked window resolves; the
|
|
981
|
+
// render grid is the WHOLE window, so the payload reports window dimensions.
|
|
982
|
+
const viewGuard = `#{&&:#{==:#{window_id},${source.windowId}},#{&&:#{==:#{session_windows},1},#{==:#{${GROUPED_TMUX_VIEW_MARKER_ENVIRONMENT}},${marker}}}}`;
|
|
983
|
+
const payload = commandString([
|
|
984
|
+
"display-message",
|
|
985
|
+
"-p",
|
|
986
|
+
"-t",
|
|
987
|
+
sourceTarget,
|
|
988
|
+
"source\t#{session_id}\t#{window_id}\t#{pane_id}\t#{window_panes}\t#{window_width}\t#{window_height}",
|
|
989
|
+
";",
|
|
990
|
+
"list-clients",
|
|
991
|
+
"-t",
|
|
992
|
+
`=${viewName}`,
|
|
993
|
+
"-F",
|
|
994
|
+
"client\t#{client_pid}\t#{session_name}\t#{client_width}\t#{client_height}",
|
|
995
|
+
]);
|
|
996
|
+
const result = this.#runner.run({
|
|
997
|
+
executable: "tmux",
|
|
998
|
+
argv: [
|
|
999
|
+
"if-shell",
|
|
1000
|
+
"-F",
|
|
1001
|
+
"-t",
|
|
1002
|
+
viewTarget,
|
|
1003
|
+
viewGuard,
|
|
1004
|
+
payload,
|
|
1005
|
+
commandString(["display-message", "-p", VIEW_MISMATCH]),
|
|
1006
|
+
],
|
|
1007
|
+
});
|
|
1008
|
+
if (result.status !== "ok") {
|
|
1009
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
1010
|
+
}
|
|
1011
|
+
const lines = strictLines(result.stdout, MAX_GEOMETRY_CLIENTS + 1);
|
|
1012
|
+
if (lines.length < 2 || lines[0] === VIEW_MISMATCH) {
|
|
1013
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
1014
|
+
}
|
|
1015
|
+
const sourceFields = lines[0]!.split("\t");
|
|
1016
|
+
// `window_panes` is now bound to the resolved windowPaneCount instead of the
|
|
1017
|
+
// literal 1, so a live topology change between resolution and geometry fails
|
|
1018
|
+
// closed. `sourceGrid` is the window's dimensions (the render grid), not one
|
|
1019
|
+
// pane's; the client viewport below is already window-level.
|
|
1020
|
+
if (
|
|
1021
|
+
sourceFields.length !== 7 ||
|
|
1022
|
+
sourceFields[0] !== "source" ||
|
|
1023
|
+
sourceFields[1] !== source.sessionId ||
|
|
1024
|
+
sourceFields[2] !== source.windowId ||
|
|
1025
|
+
sourceFields[3] !== source.runtimePaneId ||
|
|
1026
|
+
sourceFields[4] !== String(source.windowPaneCount)
|
|
1027
|
+
) {
|
|
1028
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
1029
|
+
}
|
|
1030
|
+
const sourceGrid = viewport(sourceFields[5]!, sourceFields[6]!);
|
|
1031
|
+
const clients = lines.slice(1).map((line) => line.split("\t"));
|
|
1032
|
+
if (
|
|
1033
|
+
clients.length !== 1 ||
|
|
1034
|
+
clients[0]!.length !== 5 ||
|
|
1035
|
+
clients[0]![0] !== "client" ||
|
|
1036
|
+
!INTEGER.test(clients[0]![1]!) ||
|
|
1037
|
+
Number(clients[0]![1]) !== client.pid ||
|
|
1038
|
+
clients[0]![2] !== viewName
|
|
1039
|
+
) {
|
|
1040
|
+
throw new NativeTerminalAttachmentRuntimeError("geometry-mismatch");
|
|
1041
|
+
}
|
|
1042
|
+
const clientViewport = viewport(clients[0]![3]!, clients[0]![4]!);
|
|
1043
|
+
return Object.freeze({ sourceGrid, clientViewport });
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
type LeaseRuntimeOptions = Omit<
|
|
1048
|
+
AttachmentLeaseManagerOptions,
|
|
1049
|
+
"daemonInstanceId" | "catalog" | "viewExecutor"
|
|
1050
|
+
>;
|
|
1051
|
+
type LauncherRuntimeOptions = Omit<
|
|
1052
|
+
PtyTmuxAttachmentLauncherOptions,
|
|
1053
|
+
| "socketSelector"
|
|
1054
|
+
| "trustedCwd"
|
|
1055
|
+
| "tmuxExecutable"
|
|
1056
|
+
| "environment"
|
|
1057
|
+
| "ptyAdapter"
|
|
1058
|
+
| "proofRunner"
|
|
1059
|
+
| "proofCommandExecutor"
|
|
1060
|
+
>;
|
|
1061
|
+
type AdmissionRuntimeOptions = Omit<
|
|
1062
|
+
TerminalAttachmentAdmissionCoordinatorOptions,
|
|
1063
|
+
| "daemonInstanceId"
|
|
1064
|
+
| "webSocketUrl"
|
|
1065
|
+
| "leaseManager"
|
|
1066
|
+
| "launcher"
|
|
1067
|
+
| "resolveGeometry"
|
|
1068
|
+
| "startupBarrier"
|
|
1069
|
+
>;
|
|
1070
|
+
|
|
1071
|
+
export interface WorkspaceTerminalInventoryRuntimeOptions {
|
|
1072
|
+
readonly registry: WorkspaceRegistry;
|
|
1073
|
+
readonly sessionRuntimeRegistry?: SessionRuntimeRegistry;
|
|
1074
|
+
readonly tmuxAuthority: NativeTerminalAttachmentTmuxAuthority;
|
|
1075
|
+
readonly commandExecutor?: NativeTerminalAttachmentCommandExecutor;
|
|
1076
|
+
readonly readCommandExecutor?: NativeTerminalInventoryReadCommandExecutor;
|
|
1077
|
+
readonly semanticPaneCatalog?: SemanticPaneCatalog;
|
|
1078
|
+
readonly agentStatusProbe?: AgentStatusProbe;
|
|
1079
|
+
readonly agentStatusProbeFactory?: (deps: {
|
|
1080
|
+
readonly run: (argv: readonly string[], signal?: AbortSignal) => Promise<string | null>;
|
|
1081
|
+
}) => AgentStatusProbe;
|
|
1082
|
+
/** Opt-in bounded daemon qualification spans; production normally uses the disabled singleton. */
|
|
1083
|
+
readonly observability?: SessionRuntimeObservability;
|
|
1084
|
+
readonly onInventory?: (snapshot: NativeTerminalInventorySnapshot) => void;
|
|
1085
|
+
readonly onSessionInventory?: (
|
|
1086
|
+
sessionName: string,
|
|
1087
|
+
snapshot: NativeTerminalInventorySnapshot | null,
|
|
1088
|
+
) => void;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Startup enumeration is read-only and safe to repeat. A cold contender fleet
|
|
1093
|
+
* can exhaust the first synchronous tmux command's deadline while losing Node
|
|
1094
|
+
* processes are still being scheduled; one fresh read avoids publishing a
|
|
1095
|
+
* failed daemon generation without weakening the fail-closed cleanup policy.
|
|
1096
|
+
*/
|
|
1097
|
+
async function enumerateStartupMarkedViews(
|
|
1098
|
+
executor: TmuxAttachmentViewExecutor,
|
|
1099
|
+
): Promise<Awaited<ReturnType<TmuxAttachmentViewExecutor["enumerateMarkedViews"]>>> {
|
|
1100
|
+
let failure: unknown;
|
|
1101
|
+
for (let attempt = 0; attempt < STARTUP_ORPHAN_ENUMERATION_ATTEMPTS; attempt += 1) {
|
|
1102
|
+
try {
|
|
1103
|
+
return await executor.enumerateMarkedViews(
|
|
1104
|
+
GROUPED_TMUX_VIEW_SESSION_PREFIX,
|
|
1105
|
+
GROUPED_TMUX_VIEW_MARKER_ENVIRONMENT,
|
|
1106
|
+
);
|
|
1107
|
+
} catch (error) {
|
|
1108
|
+
failure = error;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
throw failure;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Daemon-owned semantic inventory authority. It deliberately has no PTY,
|
|
1116
|
+
* grouped-view, attachment lease, or admission dependency, so Web/OpenTUI
|
|
1117
|
+
* startup can discover and mirror ordinary tmux without constructing the
|
|
1118
|
+
* legacy attachment stack.
|
|
1119
|
+
*/
|
|
1120
|
+
export class WorkspaceTerminalInventoryRuntime {
|
|
1121
|
+
readonly semanticPaneCatalog: SemanticPaneCatalog;
|
|
1122
|
+
readonly runner: TmuxAttachmentCommandRunner;
|
|
1123
|
+
readonly readRunner: NativeTerminalInventoryReadRunner;
|
|
1124
|
+
readonly #registry: WorkspaceRegistry;
|
|
1125
|
+
readonly #discoverTerminalInventory: (
|
|
1126
|
+
signal?: AbortSignal,
|
|
1127
|
+
) => Promise<NativeTerminalInventorySnapshot>;
|
|
1128
|
+
readonly #agentStatusProbe: AgentStatusProbe | null;
|
|
1129
|
+
readonly #observability: SessionRuntimeObservability;
|
|
1130
|
+
readonly #onInventory: ((snapshot: NativeTerminalInventorySnapshot) => void) | null;
|
|
1131
|
+
readonly #onSessionInventory:
|
|
1132
|
+
| ((sessionName: string, snapshot: NativeTerminalInventorySnapshot | null) => void)
|
|
1133
|
+
| null;
|
|
1134
|
+
readonly #prewarmSessionRuntime:
|
|
1135
|
+
| ((sessionName: string, runtimeSessionId: string, signal: AbortSignal) => Promise<void>)
|
|
1136
|
+
| null;
|
|
1137
|
+
readonly #discoverTrustedSessionInventory:
|
|
1138
|
+
| ((sessionName: string, signal: AbortSignal) => Promise<TrustedSessionInventoryCandidate>)
|
|
1139
|
+
| null;
|
|
1140
|
+
readonly #trustedSessionInventoryCurrent:
|
|
1141
|
+
| ((sessionName: string, token: object) => boolean)
|
|
1142
|
+
| null;
|
|
1143
|
+
readonly #observeWorkspaceSession: ((workspaceName: string, sessionName: string) => void) | null;
|
|
1144
|
+
readonly #stopWorkspaceAddedObserver: (() => void) | null;
|
|
1145
|
+
readonly #stopWorkspaceRemovedObserver: (() => void) | null;
|
|
1146
|
+
readonly #orphanBarrier: Promise<void>;
|
|
1147
|
+
#inventoryEpoch = 0;
|
|
1148
|
+
#inventoryRead: {
|
|
1149
|
+
readonly epoch: number;
|
|
1150
|
+
readonly abort: AbortController;
|
|
1151
|
+
readonly promise: Promise<NativeTerminalInventorySnapshot>;
|
|
1152
|
+
} | null = null;
|
|
1153
|
+
readonly #applicationReads = new Map<
|
|
1154
|
+
string,
|
|
1155
|
+
{
|
|
1156
|
+
readonly epoch: number;
|
|
1157
|
+
readonly abort: AbortController;
|
|
1158
|
+
readonly promise: Promise<NativeApplicationShellSessionSnapshot | null>;
|
|
1159
|
+
}
|
|
1160
|
+
>();
|
|
1161
|
+
#lifecycle: "initializing" | "ready" | "failed" | "disposed" = "initializing";
|
|
1162
|
+
#disposed = false;
|
|
1163
|
+
|
|
1164
|
+
constructor(options: WorkspaceTerminalInventoryRuntimeOptions) {
|
|
1165
|
+
const authority = canonicalAuthority(options.tmuxAuthority);
|
|
1166
|
+
const execute = options.commandExecutor ?? defaultCommandExecutor;
|
|
1167
|
+
const executeRead = options.readCommandExecutor ?? defaultReadCommandExecutor;
|
|
1168
|
+
this.runner = pinnedRunner(authority, execute, {
|
|
1169
|
+
allowUnavailableDefaultEnumeration: true,
|
|
1170
|
+
});
|
|
1171
|
+
this.readRunner = pinnedReadRunner(authority, executeRead);
|
|
1172
|
+
this.#registry = options.registry;
|
|
1173
|
+
this.#observability = options.observability ?? DISABLED_SESSION_RUNTIME_OBSERVABILITY;
|
|
1174
|
+
this.#onInventory = options.onInventory ?? null;
|
|
1175
|
+
this.#onSessionInventory = options.onSessionInventory ?? null;
|
|
1176
|
+
this.#discoverTerminalInventory = (signal) => this.#readInventory(signal);
|
|
1177
|
+
this.semanticPaneCatalog =
|
|
1178
|
+
options.semanticPaneCatalog ??
|
|
1179
|
+
new SemanticPaneCatalog({
|
|
1180
|
+
discover: async () => {
|
|
1181
|
+
const inventory = await this.#discoverTerminalInventory();
|
|
1182
|
+
return inventory.panes.map(
|
|
1183
|
+
({
|
|
1184
|
+
sessionName: _sessionName,
|
|
1185
|
+
index: _index,
|
|
1186
|
+
title: _title,
|
|
1187
|
+
currentCommand: _currentCommand,
|
|
1188
|
+
active: _active,
|
|
1189
|
+
role: _role,
|
|
1190
|
+
name: _name,
|
|
1191
|
+
type: _type,
|
|
1192
|
+
missionStamp: _missionStamp,
|
|
1193
|
+
dir: _dir,
|
|
1194
|
+
...row
|
|
1195
|
+
}) => row,
|
|
1196
|
+
);
|
|
1197
|
+
},
|
|
1198
|
+
});
|
|
1199
|
+
const orphanExecutor = new TmuxAttachmentViewExecutor({ runner: this.runner });
|
|
1200
|
+
this.#orphanBarrier = enumerateStartupMarkedViews(orphanExecutor)
|
|
1201
|
+
.then(async (candidates) => {
|
|
1202
|
+
for (const candidate of candidates) {
|
|
1203
|
+
const marker = candidate.markerValue?.match(
|
|
1204
|
+
/^v1:([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}):(0|[1-9][0-9]*)$/u,
|
|
1205
|
+
);
|
|
1206
|
+
if (!marker || candidate.windowIds.length !== 1) continue;
|
|
1207
|
+
const generation = Number(marker[2]);
|
|
1208
|
+
if (
|
|
1209
|
+
!Number.isSafeInteger(generation) ||
|
|
1210
|
+
generation > GROUPED_TMUX_MAX_GENERATION ||
|
|
1211
|
+
groupedTmuxViewSessionName(marker[1]!, generation) !== candidate.viewSessionName
|
|
1212
|
+
) {
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
const result = await orphanExecutor.guardedCleanup({
|
|
1216
|
+
exactViewSessionTarget: `=${candidate.viewSessionName}`,
|
|
1217
|
+
markerEnvironment: GROUPED_TMUX_VIEW_MARKER_ENVIRONMENT,
|
|
1218
|
+
expectedMarkerValue: candidate.markerValue!,
|
|
1219
|
+
expectedWindowId: candidate.windowIds[0]!,
|
|
1220
|
+
});
|
|
1221
|
+
if (result !== "cleaned" && result !== "absent") {
|
|
1222
|
+
throw new NativeTerminalAttachmentRuntimeError("orphan-reconciliation-failed");
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
if (!this.#disposed) this.#lifecycle = "ready";
|
|
1226
|
+
})
|
|
1227
|
+
.catch((error: unknown) => {
|
|
1228
|
+
if (!this.#disposed) this.#lifecycle = "failed";
|
|
1229
|
+
if (error instanceof NativeTerminalAttachmentRuntimeError) throw error;
|
|
1230
|
+
throw new NativeTerminalAttachmentRuntimeError("orphan-reconciliation-failed");
|
|
1231
|
+
});
|
|
1232
|
+
void this.#orphanBarrier.catch(() => undefined);
|
|
1233
|
+
this.#agentStatusProbe =
|
|
1234
|
+
options.agentStatusProbe ??
|
|
1235
|
+
(options.agentStatusProbeFactory
|
|
1236
|
+
? options.agentStatusProbeFactory({
|
|
1237
|
+
run: async (argv, signal) => {
|
|
1238
|
+
const result = await this.readRunner.run({ executable: "tmux", argv }, signal);
|
|
1239
|
+
return result.status === "ok" ? result.stdout : null;
|
|
1240
|
+
},
|
|
1241
|
+
})
|
|
1242
|
+
: null);
|
|
1243
|
+
const sessionsByWorkspace = new Map(
|
|
1244
|
+
options.registry.list().map((workspace) => [workspace.name, workspace.sessionName]),
|
|
1245
|
+
);
|
|
1246
|
+
if (options.sessionRuntimeRegistry) {
|
|
1247
|
+
const sessionRuntimeRegistry = options.sessionRuntimeRegistry;
|
|
1248
|
+
this.#prewarmSessionRuntime = (sessionName, runtimeSessionId, signal) => {
|
|
1249
|
+
const qualify = sessionRuntimeRegistry.prewarmProofQualifiedSession;
|
|
1250
|
+
return (
|
|
1251
|
+
typeof qualify === "function"
|
|
1252
|
+
? qualify.call(sessionRuntimeRegistry, sessionName, runtimeSessionId, signal)
|
|
1253
|
+
: sessionRuntimeRegistry.prewarmSession(sessionName, signal)
|
|
1254
|
+
).then(() => undefined);
|
|
1255
|
+
};
|
|
1256
|
+
this.#discoverTrustedSessionInventory =
|
|
1257
|
+
typeof sessionRuntimeRegistry.describeTrustedSessionInventoryCandidate === "function"
|
|
1258
|
+
? (sessionName, signal) =>
|
|
1259
|
+
sessionRuntimeRegistry.describeTrustedSessionInventoryCandidate(sessionName, signal)
|
|
1260
|
+
: typeof sessionRuntimeRegistry.describeTrustedSessionInventory === "function"
|
|
1261
|
+
? (sessionName, signal) =>
|
|
1262
|
+
sessionRuntimeRegistry
|
|
1263
|
+
.describeTrustedSessionInventory(sessionName, signal)
|
|
1264
|
+
.then((inventory) => ({ inventory, token: Object.freeze({}) }))
|
|
1265
|
+
: null;
|
|
1266
|
+
this.#trustedSessionInventoryCurrent =
|
|
1267
|
+
typeof sessionRuntimeRegistry.isTrustedSessionInventoryCandidateCurrent === "function"
|
|
1268
|
+
? (sessionName, token) =>
|
|
1269
|
+
sessionRuntimeRegistry.isTrustedSessionInventoryCandidateCurrent(sessionName, token)
|
|
1270
|
+
: typeof sessionRuntimeRegistry.hasProofQualifiedInventory === "function"
|
|
1271
|
+
? (sessionName) => sessionRuntimeRegistry.hasProofQualifiedInventory(sessionName)
|
|
1272
|
+
: null;
|
|
1273
|
+
this.#observeWorkspaceSession = (workspaceName, sessionName) => {
|
|
1274
|
+
const previousSessionName = sessionsByWorkspace.get(workspaceName);
|
|
1275
|
+
sessionsByWorkspace.set(workspaceName, sessionName);
|
|
1276
|
+
if (
|
|
1277
|
+
previousSessionName &&
|
|
1278
|
+
previousSessionName !== sessionName &&
|
|
1279
|
+
![...sessionsByWorkspace.values()].some((candidate) => candidate === previousSessionName)
|
|
1280
|
+
) {
|
|
1281
|
+
void sessionRuntimeRegistry.retireSession(previousSessionName).catch(() => undefined);
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
} else {
|
|
1285
|
+
this.#prewarmSessionRuntime = null;
|
|
1286
|
+
this.#discoverTrustedSessionInventory = null;
|
|
1287
|
+
this.#trustedSessionInventoryCurrent = null;
|
|
1288
|
+
this.#observeWorkspaceSession = null;
|
|
1289
|
+
}
|
|
1290
|
+
this.#stopWorkspaceAddedObserver = options.registry.on("workspace.added", (workspace) => {
|
|
1291
|
+
this.invalidate();
|
|
1292
|
+
this.#observeWorkspaceSession?.(workspace.name, workspace.sessionName);
|
|
1293
|
+
});
|
|
1294
|
+
this.#stopWorkspaceRemovedObserver = options.registry.on("workspace.removed", (name) => {
|
|
1295
|
+
this.invalidate();
|
|
1296
|
+
if (!options.sessionRuntimeRegistry) return;
|
|
1297
|
+
const sessionName = sessionsByWorkspace.get(name);
|
|
1298
|
+
sessionsByWorkspace.delete(name);
|
|
1299
|
+
if (
|
|
1300
|
+
sessionName &&
|
|
1301
|
+
![...sessionsByWorkspace.values()].some((candidate) => candidate === sessionName)
|
|
1302
|
+
) {
|
|
1303
|
+
void options.sessionRuntimeRegistry.retireSession(sessionName).catch(() => undefined);
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
discoverTerminalInventory(signal?: AbortSignal): Promise<NativeTerminalInventorySnapshot> {
|
|
1309
|
+
return this.#discoverTerminalInventory(signal);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
lifecycleState(): "initializing" | "ready" | "failed" | "disposed" {
|
|
1313
|
+
return this.#disposed ? "disposed" : this.#lifecycle;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
whenReady(): Promise<void> {
|
|
1317
|
+
return this.#orphanBarrier;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
recordTerminalRuntimeResourceMark(
|
|
1321
|
+
operation: "terminal-resource-handler-admitted" | "terminal-resource-response-projection",
|
|
1322
|
+
): void {
|
|
1323
|
+
if (!this.#observability.enabled) return;
|
|
1324
|
+
try {
|
|
1325
|
+
const atMicros = this.#observability.nowMicros();
|
|
1326
|
+
this.#observability.recordSpan("transport", operation, atMicros, atMicros);
|
|
1327
|
+
} catch {
|
|
1328
|
+
// Diagnostics never own native runtime lifecycle.
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
#observeAttempt<Value>(operation: string, run: () => Promise<Value>): Promise<Value> {
|
|
1333
|
+
if (!this.#observability.enabled) return run();
|
|
1334
|
+
let startedAtMicros: number;
|
|
1335
|
+
try {
|
|
1336
|
+
startedAtMicros = this.#observability.nowMicros();
|
|
1337
|
+
} catch {
|
|
1338
|
+
return run();
|
|
1339
|
+
}
|
|
1340
|
+
const finish = (): void => {
|
|
1341
|
+
try {
|
|
1342
|
+
this.#observability.recordSpan(
|
|
1343
|
+
"transport",
|
|
1344
|
+
operation,
|
|
1345
|
+
startedAtMicros,
|
|
1346
|
+
this.#observability.nowMicros(),
|
|
1347
|
+
);
|
|
1348
|
+
} catch {
|
|
1349
|
+
// Diagnostics never change discovery or enrichment results.
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
try {
|
|
1353
|
+
return run().finally(finish);
|
|
1354
|
+
} catch (error) {
|
|
1355
|
+
finish();
|
|
1356
|
+
throw error;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/** Retires the exact read generation; concurrent readers share its replacement. */
|
|
1361
|
+
invalidate(): void {
|
|
1362
|
+
this.#inventoryEpoch += 1;
|
|
1363
|
+
this.#inventoryRead?.abort.abort();
|
|
1364
|
+
this.#inventoryRead = null;
|
|
1365
|
+
for (const read of this.#applicationReads.values()) read.abort.abort();
|
|
1366
|
+
this.#applicationReads.clear();
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
#readInventoryAttempt(signal: AbortSignal): Promise<NativeTerminalInventorySnapshot> {
|
|
1370
|
+
return this.#observeAttempt("terminal-inventory-discovery", () =>
|
|
1371
|
+
discoverWorkspaceRegistryTerminalInventory(this.#registry, this.readRunner, signal),
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
#publishInventory(snapshot: NativeTerminalInventorySnapshot): NativeTerminalInventorySnapshot {
|
|
1376
|
+
try {
|
|
1377
|
+
this.#onInventory?.(snapshot);
|
|
1378
|
+
} catch {
|
|
1379
|
+
// Cache adoption is an optimization/readiness fence, never inventory authority.
|
|
1380
|
+
}
|
|
1381
|
+
return snapshot;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
async #readInventory(
|
|
1385
|
+
signal?: AbortSignal,
|
|
1386
|
+
staleRetry = 0,
|
|
1387
|
+
): Promise<NativeTerminalInventorySnapshot> {
|
|
1388
|
+
if (this.#disposed) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1389
|
+
const epoch = this.#inventoryEpoch;
|
|
1390
|
+
if (signal) {
|
|
1391
|
+
if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1392
|
+
let snapshot: NativeTerminalInventorySnapshot;
|
|
1393
|
+
try {
|
|
1394
|
+
snapshot = await this.#readInventoryAttempt(signal);
|
|
1395
|
+
} catch (error) {
|
|
1396
|
+
if (this.#inventoryEpoch !== epoch) {
|
|
1397
|
+
if (staleRetry < 1) return this.#readInventory(signal, staleRetry + 1);
|
|
1398
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
1399
|
+
}
|
|
1400
|
+
throw error;
|
|
1401
|
+
}
|
|
1402
|
+
if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1403
|
+
if (this.#inventoryEpoch !== epoch) {
|
|
1404
|
+
if (staleRetry < 1) return this.#readInventory(signal, staleRetry + 1);
|
|
1405
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
1406
|
+
}
|
|
1407
|
+
return this.#publishInventory(snapshot);
|
|
1408
|
+
}
|
|
1409
|
+
if (this.#inventoryRead?.epoch === epoch) return this.#inventoryRead.promise;
|
|
1410
|
+
const abort = new AbortController();
|
|
1411
|
+
const promise = (async () => {
|
|
1412
|
+
let value: NativeTerminalInventorySnapshot;
|
|
1413
|
+
try {
|
|
1414
|
+
value = await this.#readInventoryAttempt(abort.signal);
|
|
1415
|
+
} catch (error) {
|
|
1416
|
+
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) {
|
|
1417
|
+
if (staleRetry < 1) return this.#readInventory(undefined, staleRetry + 1);
|
|
1418
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
1419
|
+
}
|
|
1420
|
+
throw error;
|
|
1421
|
+
}
|
|
1422
|
+
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) {
|
|
1423
|
+
if (staleRetry < 1) return this.#readInventory(undefined, staleRetry + 1);
|
|
1424
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
1425
|
+
}
|
|
1426
|
+
return this.#publishInventory(value);
|
|
1427
|
+
})().finally(() => {
|
|
1428
|
+
if (this.#inventoryRead?.promise === promise) this.#inventoryRead = null;
|
|
1429
|
+
});
|
|
1430
|
+
this.#inventoryRead = { epoch, abort, promise };
|
|
1431
|
+
return promise;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
discoverApplicationShellSession(
|
|
1435
|
+
requestedSessionName: string,
|
|
1436
|
+
): Promise<NativeApplicationShellSessionSnapshot | null> {
|
|
1437
|
+
if (this.#disposed)
|
|
1438
|
+
return Promise.reject(new NativeTerminalAttachmentRuntimeError("runtime-disposed"));
|
|
1439
|
+
const epoch = this.#inventoryEpoch;
|
|
1440
|
+
const current = this.#applicationReads.get(requestedSessionName);
|
|
1441
|
+
if (current?.epoch === epoch) return current.promise;
|
|
1442
|
+
const abort = new AbortController();
|
|
1443
|
+
const promise = this.#discoverApplicationShellSession(requestedSessionName, abort.signal)
|
|
1444
|
+
.then((value) =>
|
|
1445
|
+
abort.signal.aborted || this.#inventoryEpoch !== epoch
|
|
1446
|
+
? this.discoverApplicationShellSession(requestedSessionName)
|
|
1447
|
+
: value,
|
|
1448
|
+
)
|
|
1449
|
+
.catch((error: unknown) => {
|
|
1450
|
+
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) {
|
|
1451
|
+
return this.discoverApplicationShellSession(requestedSessionName);
|
|
1452
|
+
}
|
|
1453
|
+
throw error;
|
|
1454
|
+
})
|
|
1455
|
+
.finally(() => {
|
|
1456
|
+
if (this.#applicationReads.get(requestedSessionName)?.promise === promise) {
|
|
1457
|
+
this.#applicationReads.delete(requestedSessionName);
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
this.#applicationReads.set(requestedSessionName, { epoch, abort, promise });
|
|
1461
|
+
return promise;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Fresh agent-free session projection for the terminal runtime authority.
|
|
1466
|
+
* This deliberately does not join the application-shell enrichment flight.
|
|
1467
|
+
*/
|
|
1468
|
+
discoverTerminalRuntimeSession(
|
|
1469
|
+
requestedSessionName: string,
|
|
1470
|
+
signal: AbortSignal = new AbortController().signal,
|
|
1471
|
+
): Promise<NativeTerminalRuntimeSessionSnapshot | null> {
|
|
1472
|
+
if (this.#disposed)
|
|
1473
|
+
return Promise.reject(new NativeTerminalAttachmentRuntimeError("runtime-disposed"));
|
|
1474
|
+
return this.#discoverTerminalRuntimeSession(requestedSessionName, signal);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
async #discoverTerminalRuntimeSession(
|
|
1478
|
+
requestedSessionName: string,
|
|
1479
|
+
signal: AbortSignal,
|
|
1480
|
+
staleRetry = 0,
|
|
1481
|
+
): Promise<NativeTerminalRuntimeSessionSnapshot | null> {
|
|
1482
|
+
const epoch = this.#inventoryEpoch;
|
|
1483
|
+
const assertLive = (): void => {
|
|
1484
|
+
if (signal.aborted || this.#disposed) {
|
|
1485
|
+
throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
const retryIfReplaced = (): Promise<NativeTerminalRuntimeSessionSnapshot | null> | null => {
|
|
1489
|
+
assertLive();
|
|
1490
|
+
if (this.#inventoryEpoch === epoch) return null;
|
|
1491
|
+
if (staleRetry < 1)
|
|
1492
|
+
return this.#discoverTerminalRuntimeSession(requestedSessionName, signal, staleRetry + 1);
|
|
1493
|
+
return Promise.reject(new NativeTerminalAttachmentRuntimeError("discovery-failed"));
|
|
1494
|
+
};
|
|
1495
|
+
assertLive();
|
|
1496
|
+
const memberships = this.#registry
|
|
1497
|
+
.list()
|
|
1498
|
+
.filter((workspace) => workspace.sessionName === requestedSessionName);
|
|
1499
|
+
if (memberships.length === 0) return null;
|
|
1500
|
+
if (memberships.length !== 1)
|
|
1501
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
1502
|
+
const workspace = memberships[0]!;
|
|
1503
|
+
let inventory: NativeTerminalInventorySnapshot;
|
|
1504
|
+
let trustedInventory = false;
|
|
1505
|
+
let trustedInventoryToken: object | null = null;
|
|
1506
|
+
if (this.#discoverTrustedSessionInventory) {
|
|
1507
|
+
const trusted = await awaitInventoryUnlessAborted(
|
|
1508
|
+
this.#discoverTrustedSessionInventory(workspace.sessionName, signal),
|
|
1509
|
+
signal,
|
|
1510
|
+
).catch(() => null);
|
|
1511
|
+
const trustedRetry = retryIfReplaced();
|
|
1512
|
+
if (trustedRetry) return trustedRetry;
|
|
1513
|
+
if (trusted) {
|
|
1514
|
+
try {
|
|
1515
|
+
const panes = projectTrustedMirrorInventory(
|
|
1516
|
+
trusted.inventory,
|
|
1517
|
+
workspace.name,
|
|
1518
|
+
workspace.sessionName,
|
|
1519
|
+
);
|
|
1520
|
+
const catalog = analyzeTrustedSemanticPaneCatalog(
|
|
1521
|
+
panes.map(
|
|
1522
|
+
({
|
|
1523
|
+
sessionName: _sessionName,
|
|
1524
|
+
index: _index,
|
|
1525
|
+
title: _title,
|
|
1526
|
+
currentCommand: _currentCommand,
|
|
1527
|
+
active: _active,
|
|
1528
|
+
role: _role,
|
|
1529
|
+
name: _name,
|
|
1530
|
+
type: _type,
|
|
1531
|
+
missionStamp: _missionStamp,
|
|
1532
|
+
dir: _dir,
|
|
1533
|
+
...row
|
|
1534
|
+
}) => row,
|
|
1535
|
+
),
|
|
1536
|
+
);
|
|
1537
|
+
if (
|
|
1538
|
+
catalog.invalidRuntimeProof ||
|
|
1539
|
+
catalog.missingSemanticStamp ||
|
|
1540
|
+
catalog.duplicateSemanticStamp ||
|
|
1541
|
+
catalog.duplicateRuntimePaneBinding
|
|
1542
|
+
) {
|
|
1543
|
+
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
1544
|
+
}
|
|
1545
|
+
inventory = Object.freeze({ panes, catalog });
|
|
1546
|
+
trustedInventory = true;
|
|
1547
|
+
trustedInventoryToken = trusted.token;
|
|
1548
|
+
} catch {
|
|
1549
|
+
assertLive();
|
|
1550
|
+
inventory = await awaitInventoryUnlessAborted(
|
|
1551
|
+
this.#discoverTerminalInventory(signal),
|
|
1552
|
+
signal,
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
} else {
|
|
1556
|
+
inventory = await awaitInventoryUnlessAborted(
|
|
1557
|
+
this.#discoverTerminalInventory(signal),
|
|
1558
|
+
signal,
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
} else {
|
|
1562
|
+
inventory = await awaitInventoryUnlessAborted(
|
|
1563
|
+
this.#discoverTerminalInventory(signal),
|
|
1564
|
+
signal,
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
const inventoryRetry = retryIfReplaced();
|
|
1568
|
+
if (inventoryRetry) return inventoryRetry;
|
|
1569
|
+
const panes = inventory.panes.filter(
|
|
1570
|
+
(pane) => pane.workspaceName === workspace.name && pane.sessionName === workspace.sessionName,
|
|
1571
|
+
);
|
|
1572
|
+
if (panes.length === 0) return null;
|
|
1573
|
+
const active = panes.find((pane) => pane.active) ?? panes[0]!;
|
|
1574
|
+
const sessionCatalog = analyzeTrustedSemanticPaneCatalog(
|
|
1575
|
+
panes.map(
|
|
1576
|
+
({
|
|
1577
|
+
sessionName: _sessionName,
|
|
1578
|
+
index: _index,
|
|
1579
|
+
title: _title,
|
|
1580
|
+
currentCommand: _currentCommand,
|
|
1581
|
+
active: _active,
|
|
1582
|
+
role: _role,
|
|
1583
|
+
name: _name,
|
|
1584
|
+
type: _type,
|
|
1585
|
+
missionStamp: _missionStamp,
|
|
1586
|
+
dir: _dir,
|
|
1587
|
+
...row
|
|
1588
|
+
}) => row,
|
|
1589
|
+
),
|
|
1590
|
+
);
|
|
1591
|
+
const windowStamps = new Map<string, string>();
|
|
1592
|
+
let windowIdentityReady = true;
|
|
1593
|
+
for (const pane of sessionCatalog.rows) {
|
|
1594
|
+
const stamp = pane.windowStamp ?? null;
|
|
1595
|
+
const previous = windowStamps.get(pane.windowId);
|
|
1596
|
+
if (stamp === null || (previous !== undefined && previous !== stamp)) {
|
|
1597
|
+
windowIdentityReady = false;
|
|
1598
|
+
break;
|
|
1599
|
+
}
|
|
1600
|
+
windowStamps.set(pane.windowId, stamp);
|
|
1601
|
+
}
|
|
1602
|
+
if (new Set(windowStamps.values()).size !== windowStamps.size) windowIdentityReady = false;
|
|
1603
|
+
const shouldPrewarm =
|
|
1604
|
+
!sessionCatalog.invalidRuntimeProof &&
|
|
1605
|
+
!sessionCatalog.missingSemanticStamp &&
|
|
1606
|
+
!sessionCatalog.duplicateSemanticStamp &&
|
|
1607
|
+
!sessionCatalog.duplicateRuntimePaneBinding &&
|
|
1608
|
+
windowIdentityReady;
|
|
1609
|
+
const catalogIssue: NativeTerminalInventoryCatalogIssue | null = inventory.catalog
|
|
1610
|
+
.invalidRuntimeProof
|
|
1611
|
+
? "invalid-runtime-proof"
|
|
1612
|
+
: inventory.catalog.missingSemanticStamp
|
|
1613
|
+
? "missing-semantic-stamp"
|
|
1614
|
+
: inventory.catalog.duplicateSemanticStamp
|
|
1615
|
+
? "duplicate-semantic-stamp"
|
|
1616
|
+
: inventory.catalog.duplicateRuntimePaneBinding
|
|
1617
|
+
? "duplicate-runtime-pane-binding"
|
|
1618
|
+
: null;
|
|
1619
|
+
if (shouldPrewarm && this.#prewarmSessionRuntime) {
|
|
1620
|
+
await awaitInventoryUnlessAborted(
|
|
1621
|
+
this.#prewarmSessionRuntime(workspace.sessionName, active.sessionId, signal),
|
|
1622
|
+
signal,
|
|
1623
|
+
).catch(() => undefined);
|
|
1624
|
+
const prewarmRetry = retryIfReplaced();
|
|
1625
|
+
if (prewarmRetry) return prewarmRetry;
|
|
1626
|
+
}
|
|
1627
|
+
const finalRetry = retryIfReplaced();
|
|
1628
|
+
if (finalRetry) return finalRetry;
|
|
1629
|
+
if (trustedInventory) {
|
|
1630
|
+
if (
|
|
1631
|
+
trustedInventoryToken === null ||
|
|
1632
|
+
this.#trustedSessionInventoryCurrent?.(workspace.sessionName, trustedInventoryToken) !==
|
|
1633
|
+
true
|
|
1634
|
+
) {
|
|
1635
|
+
if (staleRetry < 1)
|
|
1636
|
+
return this.#discoverTerminalRuntimeSession(requestedSessionName, signal, staleRetry + 1);
|
|
1637
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
1638
|
+
}
|
|
1639
|
+
try {
|
|
1640
|
+
this.#onSessionInventory?.(workspace.sessionName, shouldPrewarm ? inventory : null);
|
|
1641
|
+
} catch {
|
|
1642
|
+
// A cache consumer cannot own terminal inventory discovery.
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
this.#observeWorkspaceSession?.(workspace.name, workspace.sessionName);
|
|
1646
|
+
return Object.freeze({
|
|
1647
|
+
workspaceName: workspace.name,
|
|
1648
|
+
name: workspace.sessionName,
|
|
1649
|
+
runtimeSessionId: active.sessionId,
|
|
1650
|
+
dir: workspace.projectDir,
|
|
1651
|
+
catalogIssue,
|
|
1652
|
+
panes: Object.freeze(
|
|
1653
|
+
panes.map(
|
|
1654
|
+
({
|
|
1655
|
+
workspaceName: _workspaceName,
|
|
1656
|
+
sessionName: _sessionName,
|
|
1657
|
+
sessionId: _sessionId,
|
|
1658
|
+
sessionWindowCount: _sessionWindowCount,
|
|
1659
|
+
dir: _dir,
|
|
1660
|
+
...pane
|
|
1661
|
+
}) => Object.freeze({ ...pane }),
|
|
1662
|
+
),
|
|
1663
|
+
),
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
async #discoverApplicationShellSession(
|
|
1668
|
+
requestedSessionName: string,
|
|
1669
|
+
signal: AbortSignal,
|
|
1670
|
+
): Promise<NativeApplicationShellSessionSnapshot | null> {
|
|
1671
|
+
const session = await this.#discoverTerminalRuntimeSession(requestedSessionName, signal);
|
|
1672
|
+
if (session === null) return null;
|
|
1673
|
+
const assertLive = (): void => {
|
|
1674
|
+
if (signal.aborted || this.#disposed) {
|
|
1675
|
+
throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
let agentFacts: ReadonlyMap<string, AgentStatusPaneFacts> = new Map();
|
|
1679
|
+
if (this.#agentStatusProbe) {
|
|
1680
|
+
try {
|
|
1681
|
+
agentFacts = await this.#observeAttempt("terminal-agent-enrichment", () =>
|
|
1682
|
+
this.#agentStatusProbe!.probe(
|
|
1683
|
+
{
|
|
1684
|
+
sessionId: session.runtimeSessionId,
|
|
1685
|
+
nowSec: Math.floor(Date.now() / 1000),
|
|
1686
|
+
panes: session.panes.map((pane) => ({
|
|
1687
|
+
runtimePaneId: pane.runtimePaneId,
|
|
1688
|
+
currentCommand: pane.currentCommand,
|
|
1689
|
+
title: pane.title,
|
|
1690
|
+
})),
|
|
1691
|
+
},
|
|
1692
|
+
signal,
|
|
1693
|
+
),
|
|
1694
|
+
);
|
|
1695
|
+
} catch {
|
|
1696
|
+
assertLive();
|
|
1697
|
+
agentFacts = new Map();
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
assertLive();
|
|
1701
|
+
return Object.freeze({
|
|
1702
|
+
...session,
|
|
1703
|
+
panes: Object.freeze(
|
|
1704
|
+
session.panes.map((pane) =>
|
|
1705
|
+
Object.freeze({ ...pane, ...(agentFacts.get(pane.runtimePaneId) ?? {}) }),
|
|
1706
|
+
),
|
|
1707
|
+
),
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
dispose(): void {
|
|
1712
|
+
if (this.#disposed) return;
|
|
1713
|
+
this.#disposed = true;
|
|
1714
|
+
this.#lifecycle = "disposed";
|
|
1715
|
+
this.invalidate();
|
|
1716
|
+
this.#stopWorkspaceAddedObserver?.();
|
|
1717
|
+
this.#stopWorkspaceRemovedObserver?.();
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
export interface NativeTerminalAttachmentRuntimeOptions {
|
|
1722
|
+
readonly daemonInstanceId: string;
|
|
1723
|
+
readonly webSocketUrl: string;
|
|
1724
|
+
readonly registry: WorkspaceRegistry;
|
|
1725
|
+
/** Neutral catalog authority shared with pane-stream and application-shell. */
|
|
1726
|
+
readonly inventoryRuntime?: WorkspaceTerminalInventoryRuntime;
|
|
1727
|
+
/** Canonical daemon-generation client/control authority. */
|
|
1728
|
+
readonly sessionRuntimeRegistry?: SessionRuntimeRegistry;
|
|
1729
|
+
readonly tmuxAuthority: NativeTerminalAttachmentTmuxAuthority;
|
|
1730
|
+
readonly ptyAdapter?: PtyAdapter;
|
|
1731
|
+
readonly commandExecutor?: NativeTerminalAttachmentCommandExecutor;
|
|
1732
|
+
readonly readCommandExecutor?: NativeTerminalInventoryReadCommandExecutor;
|
|
1733
|
+
/** Narrow deterministic seam; production omits it and uses registry-backed discovery. */
|
|
1734
|
+
readonly semanticPaneCatalog?: SemanticPaneCatalog;
|
|
1735
|
+
readonly lease?: LeaseRuntimeOptions;
|
|
1736
|
+
readonly launcher?: LauncherRuntimeOptions;
|
|
1737
|
+
readonly admission?: AdmissionRuntimeOptions;
|
|
1738
|
+
/**
|
|
1739
|
+
* Ground-truth agent-status probe for the application-shell inventory. When
|
|
1740
|
+
* omitted (e.g. unit tests, catalog-only runtimes) the projection falls back
|
|
1741
|
+
* to its legacy shell-vs-active heuristic. A directly-injected probe wins;
|
|
1742
|
+
* otherwise {@link agentStatusProbeFactory} is built from the runtime's own
|
|
1743
|
+
* pinned runner so option/capture IO shares the attachment socket authority.
|
|
1744
|
+
*/
|
|
1745
|
+
readonly agentStatusProbe?: AgentStatusProbe;
|
|
1746
|
+
/**
|
|
1747
|
+
* Build the probe from the runtime's pinned tmux runner (production wiring in
|
|
1748
|
+
* daemon-embed). Ignored when {@link agentStatusProbe} is provided directly.
|
|
1749
|
+
*/
|
|
1750
|
+
readonly agentStatusProbeFactory?: (deps: {
|
|
1751
|
+
readonly run: (argv: readonly string[], signal?: AbortSignal) => Promise<string | null>;
|
|
1752
|
+
}) => AgentStatusProbe;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
/** One daemon-generation owner for catalog, grouped view, PTY, lease and admission state. */
|
|
1756
|
+
export class NativeTerminalAttachmentRuntime {
|
|
1757
|
+
readonly admission: TerminalAttachmentAdmissionCoordinator;
|
|
1758
|
+
readonly semanticPaneCatalog: SemanticPaneCatalog;
|
|
1759
|
+
readonly #launcher: PtyTmuxAttachmentLauncher;
|
|
1760
|
+
readonly #startupBarrier: Promise<void>;
|
|
1761
|
+
readonly #serializer: TmuxAttachmentOperationSerializer;
|
|
1762
|
+
readonly #registry: WorkspaceRegistry;
|
|
1763
|
+
readonly #inventoryRuntime: WorkspaceTerminalInventoryRuntime | null;
|
|
1764
|
+
readonly #discoverTerminalInventory: () => Promise<NativeTerminalInventorySnapshot>;
|
|
1765
|
+
readonly #readRunner: NativeTerminalInventoryReadRunner;
|
|
1766
|
+
readonly #agentStatusProbe: AgentStatusProbe | null;
|
|
1767
|
+
readonly #prewarmSessionRuntime: ((sessionName: string) => void) | null;
|
|
1768
|
+
readonly #observeWorkspaceSession: ((workspaceName: string, sessionName: string) => void) | null;
|
|
1769
|
+
readonly #stopWorkspaceAddedObserver: (() => void) | null;
|
|
1770
|
+
readonly #stopWorkspaceRemovedObserver: (() => void) | null;
|
|
1771
|
+
#inventoryEpoch = 0;
|
|
1772
|
+
#inventoryRead: {
|
|
1773
|
+
readonly epoch: number;
|
|
1774
|
+
readonly abort: AbortController;
|
|
1775
|
+
readonly promise: Promise<NativeTerminalInventorySnapshot>;
|
|
1776
|
+
} | null = null;
|
|
1777
|
+
readonly #applicationReads = new Map<
|
|
1778
|
+
string,
|
|
1779
|
+
{
|
|
1780
|
+
readonly epoch: number;
|
|
1781
|
+
readonly abort: AbortController;
|
|
1782
|
+
readonly promise: Promise<NativeApplicationShellSessionSnapshot | null>;
|
|
1783
|
+
}
|
|
1784
|
+
>();
|
|
1785
|
+
#lifecycle: "initializing" | "ready" | "failed" | "disposing" | "disposed" = "initializing";
|
|
1786
|
+
#disposePromise: Promise<void> | null = null;
|
|
1787
|
+
|
|
1788
|
+
constructor(options: NativeTerminalAttachmentRuntimeOptions) {
|
|
1789
|
+
nativeTerminalAttachmentRuntimeConstructions += 1;
|
|
1790
|
+
const authority = canonicalAuthority(options.tmuxAuthority);
|
|
1791
|
+
const execute = options.commandExecutor ?? defaultCommandExecutor;
|
|
1792
|
+
const executeRead = options.readCommandExecutor ?? defaultReadCommandExecutor;
|
|
1793
|
+
const startupPolicy = {
|
|
1794
|
+
allowUnavailableDefaultEnumeration: authority.socketSelector.kind === "name",
|
|
1795
|
+
};
|
|
1796
|
+
const runner =
|
|
1797
|
+
options.inventoryRuntime?.runner ?? pinnedRunner(authority, execute, startupPolicy);
|
|
1798
|
+
const readRunner =
|
|
1799
|
+
options.inventoryRuntime?.readRunner ?? pinnedReadRunner(authority, executeRead);
|
|
1800
|
+
const discoverTerminalInventory = () =>
|
|
1801
|
+
options.inventoryRuntime?.discoverTerminalInventory() ?? this.#readInventory();
|
|
1802
|
+
const serializer = new TmuxAttachmentOperationSerializer();
|
|
1803
|
+
const catalog =
|
|
1804
|
+
options.inventoryRuntime?.semanticPaneCatalog ??
|
|
1805
|
+
options.semanticPaneCatalog ??
|
|
1806
|
+
new SemanticPaneCatalog({
|
|
1807
|
+
discover: async () => {
|
|
1808
|
+
const inventory = await discoverTerminalInventory();
|
|
1809
|
+
return inventory.panes.map(
|
|
1810
|
+
({
|
|
1811
|
+
sessionName: _sessionName,
|
|
1812
|
+
index: _index,
|
|
1813
|
+
title: _title,
|
|
1814
|
+
currentCommand: _currentCommand,
|
|
1815
|
+
active: _active,
|
|
1816
|
+
role: _role,
|
|
1817
|
+
name: _name,
|
|
1818
|
+
type: _type,
|
|
1819
|
+
missionStamp: _missionStamp,
|
|
1820
|
+
dir: _dir,
|
|
1821
|
+
...row
|
|
1822
|
+
}) => row,
|
|
1823
|
+
);
|
|
1824
|
+
},
|
|
1825
|
+
});
|
|
1826
|
+
const launcher = new PtyTmuxAttachmentLauncher({
|
|
1827
|
+
...options.launcher,
|
|
1828
|
+
socketSelector: authority.socketSelector,
|
|
1829
|
+
trustedCwd: authority.trustedCwd,
|
|
1830
|
+
tmuxExecutable: authority.executablePath,
|
|
1831
|
+
environment: authority.environment,
|
|
1832
|
+
ptyAdapter: options.ptyAdapter,
|
|
1833
|
+
proofCommandExecutor: (executable, argv, executionOptions) =>
|
|
1834
|
+
execute(executable, argv, {
|
|
1835
|
+
cwd: executionOptions.cwd,
|
|
1836
|
+
env: executionOptions.env,
|
|
1837
|
+
maxBuffer: MAX_TMUX_OUTPUT_BYTES,
|
|
1838
|
+
timeoutMs: executionOptions.timeoutMs,
|
|
1839
|
+
}),
|
|
1840
|
+
});
|
|
1841
|
+
const viewExecutor = new TmuxAttachmentViewExecutor({
|
|
1842
|
+
runner,
|
|
1843
|
+
clientTransport: launcher,
|
|
1844
|
+
operationSerializer: serializer,
|
|
1845
|
+
now: options.lease?.now,
|
|
1846
|
+
});
|
|
1847
|
+
const leaseManager = new AttachmentLeaseManager({
|
|
1848
|
+
...options.lease,
|
|
1849
|
+
daemonInstanceId: options.daemonInstanceId,
|
|
1850
|
+
catalog,
|
|
1851
|
+
viewExecutor,
|
|
1852
|
+
});
|
|
1853
|
+
const geometry = new NativeTerminalAttachmentGeometryResolver({
|
|
1854
|
+
catalog,
|
|
1855
|
+
runner,
|
|
1856
|
+
operationSerializer: serializer,
|
|
1857
|
+
});
|
|
1858
|
+
this.#startupBarrier = leaseManager
|
|
1859
|
+
.reconcileOrphanViews()
|
|
1860
|
+
.then((result) => {
|
|
1861
|
+
startupPolicy.allowUnavailableDefaultEnumeration = false;
|
|
1862
|
+
if (result.failed.length > 0) {
|
|
1863
|
+
throw new NativeTerminalAttachmentRuntimeError("orphan-reconciliation-failed");
|
|
1864
|
+
}
|
|
1865
|
+
if (this.#lifecycle !== "initializing") {
|
|
1866
|
+
throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1867
|
+
}
|
|
1868
|
+
this.#lifecycle = "ready";
|
|
1869
|
+
})
|
|
1870
|
+
.catch((error: unknown) => {
|
|
1871
|
+
startupPolicy.allowUnavailableDefaultEnumeration = false;
|
|
1872
|
+
if (this.#lifecycle === "initializing") this.#lifecycle = "failed";
|
|
1873
|
+
if (error instanceof NativeTerminalAttachmentRuntimeError) throw error;
|
|
1874
|
+
throw new NativeTerminalAttachmentRuntimeError("orphan-reconciliation-failed");
|
|
1875
|
+
});
|
|
1876
|
+
// Startup begins at construction so no caller can expose admission before
|
|
1877
|
+
// reconciliation starts. The rejection remains observable via whenReady()
|
|
1878
|
+
// and admission.issue(); this prevents an unawaited runtime from emitting
|
|
1879
|
+
// a process-level unhandled rejection first.
|
|
1880
|
+
void this.#startupBarrier.catch(() => undefined);
|
|
1881
|
+
this.admission = new TerminalAttachmentAdmissionCoordinator({
|
|
1882
|
+
...options.admission,
|
|
1883
|
+
daemonInstanceId: options.daemonInstanceId,
|
|
1884
|
+
webSocketUrl: options.webSocketUrl,
|
|
1885
|
+
leaseManager,
|
|
1886
|
+
launcher,
|
|
1887
|
+
startupBarrier: this.#startupBarrier,
|
|
1888
|
+
resolveGeometry: (descriptor, client) => geometry.resolve(descriptor, client),
|
|
1889
|
+
...(options.sessionRuntimeRegistry
|
|
1890
|
+
? {
|
|
1891
|
+
bindSessionRuntime: (descriptor: AttachmentLeaseDescriptor) => {
|
|
1892
|
+
const workspace = options.registry.get(descriptor.target.workspaceName);
|
|
1893
|
+
if (!workspace) throw new Error("Terminal attachment workspace is unavailable");
|
|
1894
|
+
if (!descriptor.hostClientId) {
|
|
1895
|
+
throw new Error("Interactive terminal attachment lacks trusted host identity");
|
|
1896
|
+
}
|
|
1897
|
+
return new SessionRuntimeTransportBinder(options.sessionRuntimeRegistry!).bind({
|
|
1898
|
+
transport: "terminal-attachment",
|
|
1899
|
+
transportLeaseId: descriptor.leaseId,
|
|
1900
|
+
session: workspace.sessionName,
|
|
1901
|
+
hostClientId: descriptor.hostClientId,
|
|
1902
|
+
allowedSourcePaneIds: [descriptor.target.semanticPaneId],
|
|
1903
|
+
interactive: descriptor.viewerMode === "interactive",
|
|
1904
|
+
});
|
|
1905
|
+
},
|
|
1906
|
+
}
|
|
1907
|
+
: {}),
|
|
1908
|
+
});
|
|
1909
|
+
this.#launcher = launcher;
|
|
1910
|
+
this.semanticPaneCatalog = catalog;
|
|
1911
|
+
this.#serializer = serializer;
|
|
1912
|
+
this.#registry = options.registry;
|
|
1913
|
+
this.#inventoryRuntime = options.inventoryRuntime ?? null;
|
|
1914
|
+
this.#readRunner = readRunner;
|
|
1915
|
+
this.#discoverTerminalInventory = discoverTerminalInventory;
|
|
1916
|
+
this.#agentStatusProbe = options.inventoryRuntime
|
|
1917
|
+
? null
|
|
1918
|
+
: (options.agentStatusProbe ??
|
|
1919
|
+
(options.agentStatusProbeFactory
|
|
1920
|
+
? options.agentStatusProbeFactory({
|
|
1921
|
+
run: async (argv, signal) => {
|
|
1922
|
+
const result = await readRunner.run({ executable: "tmux", argv }, signal);
|
|
1923
|
+
return result.status === "ok" ? result.stdout : null;
|
|
1924
|
+
},
|
|
1925
|
+
})
|
|
1926
|
+
: null));
|
|
1927
|
+
const sessionsByWorkspace = new Map(
|
|
1928
|
+
options.registry.list().map((workspace) => [workspace.name, workspace.sessionName]),
|
|
1929
|
+
);
|
|
1930
|
+
if (options.sessionRuntimeRegistry && !options.inventoryRuntime) {
|
|
1931
|
+
const sessionRuntimeRegistry = options.sessionRuntimeRegistry;
|
|
1932
|
+
this.#prewarmSessionRuntime = (sessionName) => {
|
|
1933
|
+
// Inventory must remain responsive even if tmux control-mode startup
|
|
1934
|
+
// fails. Admission will retry through the same runtime on demand.
|
|
1935
|
+
void sessionRuntimeRegistry.prewarmSession(sessionName).catch(() => undefined);
|
|
1936
|
+
};
|
|
1937
|
+
this.#observeWorkspaceSession = (workspaceName, sessionName) => {
|
|
1938
|
+
const previousSessionName = sessionsByWorkspace.get(workspaceName);
|
|
1939
|
+
sessionsByWorkspace.set(workspaceName, sessionName);
|
|
1940
|
+
if (
|
|
1941
|
+
previousSessionName &&
|
|
1942
|
+
previousSessionName !== sessionName &&
|
|
1943
|
+
![...sessionsByWorkspace.values()].some((candidate) => candidate === previousSessionName)
|
|
1944
|
+
) {
|
|
1945
|
+
void sessionRuntimeRegistry.retireSession(previousSessionName).catch(() => undefined);
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
} else {
|
|
1949
|
+
this.#prewarmSessionRuntime = null;
|
|
1950
|
+
this.#observeWorkspaceSession = null;
|
|
1951
|
+
}
|
|
1952
|
+
if (!options.inventoryRuntime) {
|
|
1953
|
+
this.#stopWorkspaceAddedObserver = options.registry.on("workspace.added", (workspace) => {
|
|
1954
|
+
this.#invalidateReads();
|
|
1955
|
+
this.#observeWorkspaceSession?.(workspace.name, workspace.sessionName);
|
|
1956
|
+
});
|
|
1957
|
+
this.#stopWorkspaceRemovedObserver = options.registry.on("workspace.removed", (name) => {
|
|
1958
|
+
this.#invalidateReads();
|
|
1959
|
+
if (!options.sessionRuntimeRegistry) return;
|
|
1960
|
+
const sessionName = sessionsByWorkspace.get(name);
|
|
1961
|
+
sessionsByWorkspace.delete(name);
|
|
1962
|
+
if (
|
|
1963
|
+
sessionName &&
|
|
1964
|
+
![...sessionsByWorkspace.values()].some((candidate) => candidate === sessionName)
|
|
1965
|
+
) {
|
|
1966
|
+
void options.sessionRuntimeRegistry.retireSession(sessionName).catch(() => undefined);
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
} else {
|
|
1970
|
+
this.#stopWorkspaceAddedObserver = null;
|
|
1971
|
+
this.#stopWorkspaceRemovedObserver = null;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Exact registry-session inventory for ApplicationShell V2. The runtime and
|
|
1977
|
+
* attachment catalog intentionally share the same pinned runner, socket and
|
|
1978
|
+
* global trust analyzer.
|
|
1979
|
+
*/
|
|
1980
|
+
#readsClosed(): boolean {
|
|
1981
|
+
return this.#lifecycle === "disposing" || this.#lifecycle === "disposed";
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
#invalidateReads(): void {
|
|
1985
|
+
this.#inventoryEpoch += 1;
|
|
1986
|
+
this.#inventoryRead?.abort.abort();
|
|
1987
|
+
this.#inventoryRead = null;
|
|
1988
|
+
for (const read of this.#applicationReads.values()) read.abort.abort();
|
|
1989
|
+
this.#applicationReads.clear();
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
async #readInventory(): Promise<NativeTerminalInventorySnapshot> {
|
|
1993
|
+
if (this.#readsClosed()) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
1994
|
+
const epoch = this.#inventoryEpoch;
|
|
1995
|
+
if (this.#inventoryRead?.epoch === epoch) return this.#inventoryRead.promise;
|
|
1996
|
+
const abort = new AbortController();
|
|
1997
|
+
const promise = discoverWorkspaceRegistryTerminalInventory(
|
|
1998
|
+
this.#registry,
|
|
1999
|
+
this.#readRunner,
|
|
2000
|
+
abort.signal,
|
|
2001
|
+
)
|
|
2002
|
+
.then((value) =>
|
|
2003
|
+
abort.signal.aborted || this.#inventoryEpoch !== epoch ? this.#readInventory() : value,
|
|
2004
|
+
)
|
|
2005
|
+
.catch((error: unknown) => {
|
|
2006
|
+
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) return this.#readInventory();
|
|
2007
|
+
throw error;
|
|
2008
|
+
})
|
|
2009
|
+
.finally(() => {
|
|
2010
|
+
if (this.#inventoryRead?.promise === promise) this.#inventoryRead = null;
|
|
2011
|
+
});
|
|
2012
|
+
this.#inventoryRead = { epoch, abort, promise };
|
|
2013
|
+
return promise;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
discoverApplicationShellSession(
|
|
2017
|
+
requestedSessionName: string,
|
|
2018
|
+
): Promise<NativeApplicationShellSessionSnapshot | null> {
|
|
2019
|
+
if (this.#inventoryRuntime) {
|
|
2020
|
+
return this.#inventoryRuntime.discoverApplicationShellSession(requestedSessionName);
|
|
2021
|
+
}
|
|
2022
|
+
if (this.#readsClosed())
|
|
2023
|
+
return Promise.reject(new NativeTerminalAttachmentRuntimeError("runtime-disposed"));
|
|
2024
|
+
const epoch = this.#inventoryEpoch;
|
|
2025
|
+
const current = this.#applicationReads.get(requestedSessionName);
|
|
2026
|
+
if (current?.epoch === epoch) return current.promise;
|
|
2027
|
+
const abort = new AbortController();
|
|
2028
|
+
const promise = this.#discoverApplicationShellSession(requestedSessionName, abort.signal)
|
|
2029
|
+
.then((value) =>
|
|
2030
|
+
abort.signal.aborted || this.#inventoryEpoch !== epoch
|
|
2031
|
+
? this.discoverApplicationShellSession(requestedSessionName)
|
|
2032
|
+
: value,
|
|
2033
|
+
)
|
|
2034
|
+
.catch((error: unknown) => {
|
|
2035
|
+
if (abort.signal.aborted || this.#inventoryEpoch !== epoch) {
|
|
2036
|
+
return this.discoverApplicationShellSession(requestedSessionName);
|
|
2037
|
+
}
|
|
2038
|
+
throw error;
|
|
2039
|
+
})
|
|
2040
|
+
.finally(() => {
|
|
2041
|
+
if (this.#applicationReads.get(requestedSessionName)?.promise === promise) {
|
|
2042
|
+
this.#applicationReads.delete(requestedSessionName);
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
this.#applicationReads.set(requestedSessionName, { epoch, abort, promise });
|
|
2046
|
+
return promise;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
async #discoverApplicationShellSession(
|
|
2050
|
+
requestedSessionName: string,
|
|
2051
|
+
signal: AbortSignal,
|
|
2052
|
+
): Promise<NativeApplicationShellSessionSnapshot | null> {
|
|
2053
|
+
const assertLive = (): void => {
|
|
2054
|
+
if (signal.aborted || this.#readsClosed()) {
|
|
2055
|
+
throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
assertLive();
|
|
2059
|
+
const memberships = this.#registry
|
|
2060
|
+
.list()
|
|
2061
|
+
.filter((workspace) => workspace.sessionName === requestedSessionName);
|
|
2062
|
+
if (memberships.length === 0) return null;
|
|
2063
|
+
if (memberships.length !== 1) {
|
|
2064
|
+
throw new NativeTerminalAttachmentRuntimeError("discovery-failed");
|
|
2065
|
+
}
|
|
2066
|
+
const workspace = memberships[0]!;
|
|
2067
|
+
// Reconcile a stable workspace name that now resolves to a replacement
|
|
2068
|
+
// tmux session only after authoritative discovery is requested. This keeps
|
|
2069
|
+
// an in-flight rename mutation alive through its own completion while
|
|
2070
|
+
// ensuring the old prewarm cannot survive the next shell generation.
|
|
2071
|
+
this.#observeWorkspaceSession?.(workspace.name, workspace.sessionName);
|
|
2072
|
+
const inventory = await this.#discoverTerminalInventory();
|
|
2073
|
+
assertLive();
|
|
2074
|
+
const panes = inventory.panes.filter(
|
|
2075
|
+
(pane) => pane.workspaceName === workspace.name && pane.sessionName === workspace.sessionName,
|
|
2076
|
+
);
|
|
2077
|
+
if (panes.length === 0) return null;
|
|
2078
|
+
const active = panes.find((pane) => pane.active) ?? panes[0]!;
|
|
2079
|
+
const sessionCatalog = analyzeTrustedSemanticPaneCatalog(
|
|
2080
|
+
panes.map(
|
|
2081
|
+
({
|
|
2082
|
+
sessionName: _sessionName,
|
|
2083
|
+
index: _index,
|
|
2084
|
+
title: _title,
|
|
2085
|
+
currentCommand: _currentCommand,
|
|
2086
|
+
active: _active,
|
|
2087
|
+
role: _role,
|
|
2088
|
+
name: _name,
|
|
2089
|
+
type: _type,
|
|
2090
|
+
missionStamp: _missionStamp,
|
|
2091
|
+
dir: _dir,
|
|
2092
|
+
...row
|
|
2093
|
+
}) => row,
|
|
2094
|
+
),
|
|
2095
|
+
);
|
|
2096
|
+
const windowStamps = new Map<string, string>();
|
|
2097
|
+
let windowIdentityReady = true;
|
|
2098
|
+
for (const pane of sessionCatalog.rows) {
|
|
2099
|
+
const stamp = pane.windowStamp ?? null;
|
|
2100
|
+
const previous = windowStamps.get(pane.windowId);
|
|
2101
|
+
if (stamp === null || (previous !== undefined && previous !== stamp)) {
|
|
2102
|
+
windowIdentityReady = false;
|
|
2103
|
+
break;
|
|
2104
|
+
}
|
|
2105
|
+
windowStamps.set(pane.windowId, stamp);
|
|
2106
|
+
}
|
|
2107
|
+
if (new Set(windowStamps.values()).size !== windowStamps.size) windowIdentityReady = false;
|
|
2108
|
+
const shouldPrewarm =
|
|
2109
|
+
!sessionCatalog.invalidRuntimeProof &&
|
|
2110
|
+
!sessionCatalog.missingSemanticStamp &&
|
|
2111
|
+
!sessionCatalog.duplicateSemanticStamp &&
|
|
2112
|
+
!sessionCatalog.duplicateRuntimePaneBinding &&
|
|
2113
|
+
windowIdentityReady;
|
|
2114
|
+
const catalogIssue: NativeTerminalInventoryCatalogIssue | null = inventory.catalog
|
|
2115
|
+
.invalidRuntimeProof
|
|
2116
|
+
? "invalid-runtime-proof"
|
|
2117
|
+
: inventory.catalog.missingSemanticStamp
|
|
2118
|
+
? "missing-semantic-stamp"
|
|
2119
|
+
: inventory.catalog.duplicateSemanticStamp
|
|
2120
|
+
? "duplicate-semantic-stamp"
|
|
2121
|
+
: inventory.catalog.duplicateRuntimePaneBinding
|
|
2122
|
+
? "duplicate-runtime-pane-binding"
|
|
2123
|
+
: null;
|
|
2124
|
+
// Ground-truth agent facts (authority + scrape fallback). All IO stays here;
|
|
2125
|
+
// the resource projector composes them purely. Absent probe → no facts →
|
|
2126
|
+
// the projector keeps its legacy heuristic. Never fail discovery over this.
|
|
2127
|
+
let agentFacts: ReadonlyMap<string, AgentStatusPaneFacts> = new Map();
|
|
2128
|
+
if (this.#agentStatusProbe) {
|
|
2129
|
+
try {
|
|
2130
|
+
agentFacts = await this.#agentStatusProbe.probe(
|
|
2131
|
+
{
|
|
2132
|
+
sessionId: active.sessionId,
|
|
2133
|
+
nowSec: Math.floor(Date.now() / 1000),
|
|
2134
|
+
panes: panes.map((pane) => ({
|
|
2135
|
+
runtimePaneId: pane.runtimePaneId,
|
|
2136
|
+
currentCommand: pane.currentCommand,
|
|
2137
|
+
title: pane.title,
|
|
2138
|
+
})),
|
|
2139
|
+
},
|
|
2140
|
+
signal,
|
|
2141
|
+
);
|
|
2142
|
+
} catch {
|
|
2143
|
+
assertLive();
|
|
2144
|
+
agentFacts = new Map();
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
assertLive();
|
|
2148
|
+
// Only a fully stamped daemon-authored inventory may start MirrorService.
|
|
2149
|
+
// Promotion owns first identity assignment; warming earlier would let the
|
|
2150
|
+
// mirror race it and mint `window.mirror.*` instead of promoted identity.
|
|
2151
|
+
// Defer the side effect until enrichment commits the current read epoch.
|
|
2152
|
+
if (shouldPrewarm) this.#prewarmSessionRuntime?.(workspace.sessionName);
|
|
2153
|
+
return Object.freeze({
|
|
2154
|
+
name: workspace.sessionName,
|
|
2155
|
+
runtimeSessionId: active.sessionId,
|
|
2156
|
+
// Application-owned resources belong to the registered workspace, not
|
|
2157
|
+
// whichever cwd happens to be active inside one tmux pane. Pane cwd may
|
|
2158
|
+
// be outside the project (or move during a shell session), while the
|
|
2159
|
+
// registry projectDir is the durable workspace identity boundary.
|
|
2160
|
+
dir: workspace.projectDir,
|
|
2161
|
+
catalogIssue,
|
|
2162
|
+
panes: Object.freeze(
|
|
2163
|
+
panes.map(
|
|
2164
|
+
({
|
|
2165
|
+
workspaceName: _workspaceName,
|
|
2166
|
+
sessionName: _sessionName,
|
|
2167
|
+
sessionId: _sessionId,
|
|
2168
|
+
sessionWindowCount: _sessionWindowCount,
|
|
2169
|
+
dir: _dir,
|
|
2170
|
+
...pane
|
|
2171
|
+
}) => Object.freeze({ ...pane, ...(agentFacts.get(pane.runtimePaneId) ?? {}) }),
|
|
2172
|
+
),
|
|
2173
|
+
),
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* The live inventory pass, taken through the same pinned runner and socket
|
|
2179
|
+
* the attachment catalog resolves against. Read by the startup readiness
|
|
2180
|
+
* ladder so its catalog rung reports what an actual attach would find rather
|
|
2181
|
+
* than a second, drifting view of tmux.
|
|
2182
|
+
*/
|
|
2183
|
+
discoverTerminalInventory(): Promise<NativeTerminalInventorySnapshot> {
|
|
2184
|
+
return this.#discoverTerminalInventory();
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* The startup-barrier state, observed WITHOUT awaiting it — a readiness read
|
|
2189
|
+
* must never block on the barrier it is reporting on.
|
|
2190
|
+
*/
|
|
2191
|
+
lifecycleState(): "initializing" | "ready" | "failed" | "disposing" | "disposed" {
|
|
2192
|
+
return this.#lifecycle;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
snapshot(): TerminalAttachmentAdmissionSnapshot {
|
|
2196
|
+
return this.admission.snapshot();
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
toJSON(): TerminalAttachmentAdmissionSnapshot {
|
|
2200
|
+
return this.snapshot();
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
/** A2 must await this barrier before exposing HTTP or WebSocket listeners. */
|
|
2204
|
+
whenReady(): Promise<void> {
|
|
2205
|
+
return this.#startupBarrier;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
dispose(): Promise<void> {
|
|
2209
|
+
if (!this.#disposePromise) {
|
|
2210
|
+
this.#lifecycle = "disposing";
|
|
2211
|
+
const readBarriers = [
|
|
2212
|
+
...(this.#inventoryRead ? [this.#inventoryRead.promise] : []),
|
|
2213
|
+
...[...this.#applicationReads.values()].map((read) => read.promise),
|
|
2214
|
+
];
|
|
2215
|
+
this.#invalidateReads();
|
|
2216
|
+
this.#disposePromise = this.#finishDispose(readBarriers);
|
|
2217
|
+
}
|
|
2218
|
+
return this.#disposePromise;
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
async #finishDispose(readBarriers: readonly Promise<unknown>[]): Promise<void> {
|
|
2222
|
+
try {
|
|
2223
|
+
this.#stopWorkspaceAddedObserver?.();
|
|
2224
|
+
this.#stopWorkspaceRemovedObserver?.();
|
|
2225
|
+
const admissionBarrier = this.admission.shutdown();
|
|
2226
|
+
// Cancel an attach readiness wait immediately; the coordinator barrier
|
|
2227
|
+
// then retires the associated lease/view before this method resolves.
|
|
2228
|
+
this.#launcher.disposeAll();
|
|
2229
|
+
await Promise.all([
|
|
2230
|
+
admissionBarrier,
|
|
2231
|
+
this.#startupBarrier.catch(() => undefined),
|
|
2232
|
+
...readBarriers.map((read) => read.catch(() => undefined)),
|
|
2233
|
+
]);
|
|
2234
|
+
this.#launcher.disposeAll();
|
|
2235
|
+
await this.#serializer.barrier();
|
|
2236
|
+
} finally {
|
|
2237
|
+
this.#lifecycle = "disposed";
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
export function createNativeTerminalAttachmentRuntime(
|
|
2243
|
+
options: NativeTerminalAttachmentRuntimeOptions,
|
|
2244
|
+
): NativeTerminalAttachmentRuntime {
|
|
2245
|
+
return new NativeTerminalAttachmentRuntime(options);
|
|
2246
|
+
}
|