tmux-ide 2.7.0 → 2.9.0-beta.5
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 +95 -115
- package/bin/cli.js +69987 -11819
- package/bin/cli.ts +772 -114
- package/package.json +64 -30
- package/packages/contracts/package.json +3 -2
- 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__/control.test.ts +154 -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 +466 -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 +490 -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__/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 +103 -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/control.ts +217 -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-issue.ts +83 -0
- package/packages/contracts/src/desktop-host.ts +746 -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 +60 -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 +709 -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/semantic-identity.ts +39 -0
- package/packages/contracts/src/session-runtime.ts +351 -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-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 +64 -0
- package/packages/contracts/src/workspace-pane-creation.ts +223 -0
- package/packages/contracts/src/workspace-promotion.ts +109 -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 +15 -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 +335 -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/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.test.ts +1196 -0
- package/packages/core/src/terminal-delivery.ts +2918 -0
- package/packages/core/src/terminal-replica-cold.test.ts +31 -0
- package/packages/core/src/terminal-replica-hash-cache.test.ts +201 -0
- package/packages/core/src/terminal-replica-hash-cache.ts +367 -0
- package/packages/core/src/terminal-replica.test.ts +282 -0
- package/packages/core/src/terminal-replica.ts +943 -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.d.ts +2 -2
- package/packages/daemon/dist/canonical.js +1 -1
- package/packages/daemon/dist/cli.js +37 -36
- package/packages/daemon/dist/command-center/actions/command-definitions.d.ts +4 -0
- package/packages/daemon/dist/command-center/actions/command-definitions.js +70 -0
- package/packages/daemon/dist/command-center/actions/dispatcher.d.ts +29 -0
- package/packages/daemon/dist/command-center/actions/dispatcher.js +228 -10
- package/packages/daemon/dist/command-center/actions/errors.d.ts +1 -1
- package/packages/daemon/dist/command-center/actions/handlers/_project-context.d.ts +1 -1
- package/packages/daemon/dist/command-center/actions/handlers/_project-context.js +3 -4
- package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.d.ts +8 -0
- package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.js +39 -0
- package/packages/daemon/dist/command-center/actions/handlers/config-actions.d.ts +6 -6
- package/packages/daemon/dist/command-center/actions/handlers/config-actions.js +44 -20
- package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.d.ts +2 -1
- package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.js +11 -1
- package/packages/daemon/dist/command-center/actions/handlers/fleet-lifecycle.d.ts +10 -0
- 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.d.ts +186 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-multiplexer.js +55 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-open.d.ts +16 -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.d.ts +8 -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.d.ts +8 -0
- package/packages/daemon/dist/command-center/actions/handlers/workspace-promote.js +34 -0
- package/packages/daemon/dist/command-center/actions/registry.d.ts +33 -2
- package/packages/daemon/dist/command-center/actions/registry.js +126 -0
- package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.d.ts +3 -0
- package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.js +16 -0
- package/packages/daemon/dist/command-center/agent-status-watch.d.ts +100 -0
- package/packages/daemon/dist/command-center/agent-status-watch.js +170 -0
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.d.ts +57 -0
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +395 -0
- package/packages/daemon/dist/command-center/discovery.d.ts +98 -1
- package/packages/daemon/dist/command-center/discovery.js +262 -3
- package/packages/daemon/dist/command-center/owner-authority.d.ts +71 -0
- package/packages/daemon/dist/command-center/owner-authority.js +46 -0
- package/packages/daemon/dist/command-center/pane-stream-issue.d.ts +26 -0
- package/packages/daemon/dist/command-center/pane-stream-issue.js +185 -0
- package/packages/daemon/dist/command-center/resources/agent-graph-overlay.d.ts +45 -0
- package/packages/daemon/dist/command-center/resources/agent-graph-overlay.js +234 -0
- package/packages/daemon/dist/command-center/resources/application-shell.d.ts +201 -0
- package/packages/daemon/dist/command-center/resources/application-shell.js +641 -0
- package/packages/daemon/dist/command-center/resources/desktop-missions.d.ts +10 -0
- package/packages/daemon/dist/command-center/resources/desktop-missions.js +132 -0
- package/packages/daemon/dist/command-center/resources/fleet-catalog.d.ts +25 -0
- package/packages/daemon/dist/command-center/resources/fleet-catalog.js +163 -0
- package/packages/daemon/dist/command-center/resources/fleet-resource-route.d.ts +25 -0
- package/packages/daemon/dist/command-center/resources/fleet-resource-route.js +46 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness-route.d.ts +38 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness-route.js +121 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness.d.ts +57 -0
- package/packages/daemon/dist/command-center/resources/startup-readiness.js +183 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.d.ts +5 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +24 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-authority.d.ts +39 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-authority.js +451 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-git.d.ts +63 -0
- package/packages/daemon/dist/command-center/resources/workspace-changes-git.js +222 -0
- package/packages/daemon/dist/command-center/resources/workspace-files-authority.d.ts +44 -0
- package/packages/daemon/dist/command-center/resources/workspace-files-authority.js +493 -0
- package/packages/daemon/dist/command-center/resources/workspace-missions-route.d.ts +22 -0
- package/packages/daemon/dist/command-center/resources/workspace-missions-route.js +75 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-ids.d.ts +24 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-ids.js +69 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-routes.d.ts +17 -0
- package/packages/daemon/dist/command-center/resources/workspace-resource-routes.js +116 -0
- package/packages/daemon/dist/command-center/schemas.d.ts +1 -1
- package/packages/daemon/dist/command-center/server.d.ts +57 -1
- package/packages/daemon/dist/command-center/server.js +540 -51
- package/packages/daemon/dist/command-center/terminal-attachment-issue.d.ts +22 -0
- package/packages/daemon/dist/command-center/terminal-attachment-issue.js +191 -0
- package/packages/daemon/dist/command-center/workspace-resource-observer.d.ts +50 -0
- package/packages/daemon/dist/command-center/workspace-resource-observer.js +453 -0
- package/packages/daemon/dist/command-center/ws-events.d.ts +82 -7
- package/packages/daemon/dist/command-center/ws-events.js +681 -63
- package/packages/daemon/dist/config.js +31 -25
- package/packages/daemon/dist/control/client.d.ts +23 -0
- package/packages/daemon/dist/control/client.js +105 -0
- package/packages/daemon/dist/control/dispatch.d.ts +34 -0
- package/packages/daemon/dist/control/dispatch.js +83 -0
- package/packages/daemon/dist/control/fanout.d.ts +19 -0
- package/packages/daemon/dist/control/fanout.js +37 -0
- package/packages/daemon/dist/control/frames.d.ts +23 -0
- package/packages/daemon/dist/control/frames.js +37 -0
- package/packages/daemon/dist/control/lifecycle.d.ts +45 -0
- package/packages/daemon/dist/control/lifecycle.js +124 -0
- package/packages/daemon/dist/control/server.d.ts +16 -0
- package/packages/daemon/dist/control/server.js +214 -0
- package/packages/daemon/dist/control/verbs.d.ts +11 -0
- package/packages/daemon/dist/control/verbs.js +91 -0
- package/packages/daemon/dist/detect.js +23 -20
- package/packages/daemon/dist/doctor.d.ts +18 -0
- package/packages/daemon/dist/doctor.js +127 -21
- package/packages/daemon/dist/index.d.ts +21 -2
- package/packages/daemon/dist/index.js +20 -1
- package/packages/daemon/dist/init.js +24 -22
- package/packages/daemon/dist/inspect.d.ts +7 -1
- package/packages/daemon/dist/inspect.js +33 -8
- package/packages/daemon/dist/launch.d.ts +2 -0
- 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-discovery.d.ts +27 -2
- package/packages/daemon/dist/lib/agent-discovery.js +29 -14
- package/packages/daemon/dist/lib/agent-kind.d.ts +7 -0
- package/packages/daemon/dist/lib/agent-kind.js +24 -0
- package/packages/daemon/dist/lib/app-config.d.ts +111 -0
- package/packages/daemon/dist/lib/app-config.js +130 -5
- package/packages/daemon/dist/lib/app-window-kernel.d.ts +64 -0
- package/packages/daemon/dist/lib/app-window-kernel.js +556 -0
- package/packages/daemon/dist/lib/app-window-mutation.d.ts +28 -0
- package/packages/daemon/dist/lib/app-window-mutation.js +139 -0
- package/packages/daemon/dist/lib/app-window-repository.d.ts +81 -0
- package/packages/daemon/dist/lib/app-window-repository.js +368 -0
- package/packages/daemon/dist/lib/app-window-state.d.ts +57 -0
- package/packages/daemon/dist/lib/app-window-state.js +415 -0
- package/packages/daemon/dist/lib/application-shell-app-windows.d.ts +16 -0
- package/packages/daemon/dist/lib/application-shell-app-windows.js +285 -0
- package/packages/daemon/dist/lib/auth/middleware.d.ts +1 -1
- package/packages/daemon/dist/lib/auth/middleware.js +7 -3
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.d.ts +25 -0
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +174 -0
- package/packages/daemon/dist/lib/canonical-daemon.d.ts +80 -14
- package/packages/daemon/dist/lib/canonical-daemon.js +507 -70
- package/packages/daemon/dist/lib/chrome-front-door.d.ts +7 -0
- package/packages/daemon/dist/lib/chrome-front-door.js +13 -0
- package/packages/daemon/dist/lib/cli-action-bridge.d.ts +8 -3
- package/packages/daemon/dist/lib/cli-action-bridge.js +112 -82
- package/packages/daemon/dist/lib/command-registry.d.ts +37 -0
- package/packages/daemon/dist/lib/command-registry.js +107 -0
- package/packages/daemon/dist/lib/config-context.d.ts +18 -0
- package/packages/daemon/dist/lib/config-context.js +34 -0
- package/packages/daemon/dist/lib/daemon-embed.d.ts +30 -0
- package/packages/daemon/dist/lib/daemon-embed.js +1060 -356
- package/packages/daemon/dist/lib/daemon-session-monitor.d.ts +50 -0
- 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.d.ts +12 -0
- package/packages/daemon/dist/lib/directory-watcher.js +118 -0
- package/packages/daemon/dist/lib/environment-identity.d.ts +9 -0
- package/packages/daemon/dist/lib/environment-identity.js +79 -0
- package/packages/daemon/dist/lib/errors.d.ts +1 -1
- package/packages/daemon/dist/lib/fleet-agent-lifecycle.d.ts +8 -0
- package/packages/daemon/dist/lib/fleet-agent-lifecycle.js +65 -0
- package/packages/daemon/dist/lib/fleet-lifecycle-authority.d.ts +21 -0
- package/packages/daemon/dist/lib/fleet-lifecycle-authority.js +437 -0
- package/packages/daemon/dist/lib/headless-daemon.d.ts +33 -0
- package/packages/daemon/dist/lib/headless-daemon.js +306 -0
- package/packages/daemon/dist/lib/launch-plan.d.ts +20 -1
- package/packages/daemon/dist/lib/launch-plan.js +96 -1
- package/packages/daemon/dist/lib/legacy-config-adapter.d.ts +12 -0
- package/packages/daemon/dist/lib/legacy-config-adapter.js +19 -0
- package/packages/daemon/dist/lib/legacy-config-migration.d.ts +15 -0
- package/packages/daemon/dist/lib/legacy-config-migration.js +110 -0
- package/packages/daemon/dist/lib/legacy-theme-compat.d.ts +14 -0
- package/packages/daemon/dist/lib/legacy-theme-compat.js +25 -0
- package/packages/daemon/dist/lib/manifest-pack.d.ts +79 -0
- package/packages/daemon/dist/lib/manifest-pack.js +232 -0
- package/packages/daemon/dist/lib/mission-projections.d.ts +24 -0
- package/packages/daemon/dist/lib/mission-projections.js +615 -0
- package/packages/daemon/dist/lib/mission-repository.d.ts +941 -0
- package/packages/daemon/dist/lib/mission-repository.js +775 -0
- package/packages/daemon/dist/lib/onboarding-marker.d.ts +13 -0
- package/packages/daemon/dist/lib/onboarding-marker.js +51 -0
- package/packages/daemon/dist/lib/pane-chrome.d.ts +12 -0
- package/packages/daemon/dist/lib/pane-chrome.js +12 -0
- package/packages/daemon/dist/lib/pane-source-credentials.d.ts +32 -0
- package/packages/daemon/dist/lib/pane-source-credentials.js +178 -0
- package/packages/daemon/dist/lib/pane-widget.d.ts +61 -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.d.ts +5 -5
- package/packages/daemon/dist/lib/project-onboard.js +17 -21
- package/packages/daemon/dist/lib/project-probe.d.ts +9 -3
- package/packages/daemon/dist/lib/project-probe.js +28 -22
- package/packages/daemon/dist/lib/project-readiness-probe.d.ts +60 -0
- package/packages/daemon/dist/lib/project-readiness-probe.js +425 -0
- package/packages/daemon/dist/lib/project-readiness.d.ts +157 -0
- package/packages/daemon/dist/lib/project-readiness.js +680 -0
- package/packages/daemon/dist/lib/project-registry.d.ts +8 -0
- package/packages/daemon/dist/lib/project-registry.js +42 -9
- package/packages/daemon/dist/lib/project-resolver.d.ts +77 -0
- package/packages/daemon/dist/lib/project-resolver.js +245 -0
- package/packages/daemon/dist/lib/project-runtime-errors.d.ts +13 -0
- package/packages/daemon/dist/lib/project-runtime-errors.js +21 -0
- package/packages/daemon/dist/lib/project-runtime-repository.d.ts +193 -0
- package/packages/daemon/dist/lib/project-runtime-repository.js +876 -0
- package/packages/daemon/dist/lib/resolved-config.d.ts +48 -0
- package/packages/daemon/dist/lib/resolved-config.js +318 -0
- package/packages/daemon/dist/lib/runtime-namespace.d.ts +34 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +136 -0
- package/packages/daemon/dist/lib/semantic-resource-id.d.ts +7 -0
- package/packages/daemon/dist/lib/semantic-resource-id.js +14 -0
- package/packages/daemon/dist/lib/session-monitor.d.ts +2 -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/state-home.d.ts +2 -0
- package/packages/daemon/dist/lib/state-home.js +11 -0
- package/packages/daemon/dist/lib/theme-mode.d.ts +10 -0
- package/packages/daemon/dist/lib/theme-mode.js +9 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.d.ts +88 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +534 -0
- package/packages/daemon/dist/lib/tmux-interaction-options.d.ts +34 -0
- package/packages/daemon/dist/lib/tmux-interaction-options.js +126 -0
- package/packages/daemon/dist/lib/tmux-terminal-color.d.ts +18 -0
- package/packages/daemon/dist/lib/tmux-terminal-color.js +37 -0
- package/packages/daemon/dist/lib/tui-binary.d.ts +30 -5
- package/packages/daemon/dist/lib/tui-binary.js +291 -28
- package/packages/daemon/dist/lib/unix-socket-authority.d.ts +9 -0
- package/packages/daemon/dist/lib/unix-socket-authority.js +48 -0
- package/packages/daemon/dist/lib/update-check.js +5 -0
- package/packages/daemon/dist/lib/widget-asset-policy.d.ts +3 -0
- package/packages/daemon/dist/lib/widget-asset-policy.js +3 -0
- package/packages/daemon/dist/lib/widget-asset-store.d.ts +22 -0
- package/packages/daemon/dist/lib/widget-asset-store.js +166 -0
- package/packages/daemon/dist/lib/workspace-config-loader.d.ts +68 -0
- package/packages/daemon/dist/lib/workspace-config-loader.js +280 -0
- package/packages/daemon/dist/lib/workspace-multiplexer-verbs.d.ts +109 -0
- package/packages/daemon/dist/lib/workspace-multiplexer-verbs.js +1138 -0
- package/packages/daemon/dist/lib/workspace-open-handoff.d.ts +41 -0
- package/packages/daemon/dist/lib/workspace-open-handoff.js +219 -0
- package/packages/daemon/dist/lib/workspace-open.d.ts +44 -0
- package/packages/daemon/dist/lib/workspace-open.js +740 -0
- package/packages/daemon/dist/lib/workspace-pane-creation.d.ts +64 -0
- package/packages/daemon/dist/lib/workspace-pane-creation.js +1107 -0
- package/packages/daemon/dist/lib/workspace-promotion.d.ts +41 -0
- package/packages/daemon/dist/lib/workspace-promotion.js +804 -0
- package/packages/daemon/dist/lib/workspace-registry.d.ts +49 -2
- package/packages/daemon/dist/lib/workspace-registry.js +150 -23
- package/packages/daemon/dist/lib/workspace-state-repository.d.ts +139 -0
- package/packages/daemon/dist/lib/workspace-state-repository.js +790 -0
- package/packages/daemon/dist/lib/workspace-state.d.ts +37 -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.d.ts +11 -0
- package/packages/daemon/dist/migrate.js +105 -0
- package/packages/daemon/dist/restart.js +2 -2
- package/packages/daemon/dist/restore.d.ts +40 -13
- package/packages/daemon/dist/restore.js +62 -21
- package/packages/daemon/dist/schemas/inspect.d.ts +8 -0
- package/packages/daemon/dist/schemas/inspect.js +9 -1
- package/packages/daemon/dist/schemas/registry.d.ts +18 -4
- package/packages/daemon/dist/schemas/registry.js +5 -19
- package/packages/daemon/dist/schemas/ws-events.d.ts +5 -69
- package/packages/daemon/dist/schemas/ws-events.js +4 -107
- package/packages/daemon/dist/send.d.ts +41 -1
- package/packages/daemon/dist/send.js +136 -20
- package/packages/daemon/dist/server/pane-stream-upgrade.d.ts +12 -0
- package/packages/daemon/dist/server/pane-stream-upgrade.js +117 -0
- package/packages/daemon/dist/server/terminal-attachment-upgrade.d.ts +11 -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.d.ts +30 -0
- package/packages/daemon/dist/terminal/MonotonicPtyInput.js +130 -0
- package/packages/daemon/dist/terminal/NodePtyAdapter.d.ts +9 -3
- package/packages/daemon/dist/terminal/NodePtyAdapter.js +37 -10
- package/packages/daemon/dist/terminal/PtyAdapter.d.ts +93 -3
- package/packages/daemon/dist/terminal/PtyAdapter.js +18 -0
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.d.ts +14 -4
- package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.js +33 -6
- package/packages/daemon/dist/terminal/attachments/admission-util.d.ts +14 -0
- package/packages/daemon/dist/terminal/attachments/admission-util.js +87 -0
- package/packages/daemon/dist/terminal/attachments/agent-status-probe.d.ts +102 -0
- package/packages/daemon/dist/terminal/attachments/agent-status-probe.js +325 -0
- package/packages/daemon/dist/terminal/attachments/direct-websocket.d.ts +141 -0
- package/packages/daemon/dist/terminal/attachments/direct-websocket.js +1069 -0
- package/packages/daemon/dist/terminal/attachments/grouped-tmux.d.ts +106 -0
- package/packages/daemon/dist/terminal/attachments/grouped-tmux.js +213 -0
- package/packages/daemon/dist/terminal/attachments/lease-manager.d.ts +188 -0
- package/packages/daemon/dist/terminal/attachments/lease-manager.js +655 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.d.ts +196 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +1564 -0
- package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.d.ts +66 -0
- package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.js +607 -0
- package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.d.ts +81 -0
- package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.js +208 -0
- package/packages/daemon/dist/terminal/attachments/tmux-view-executor.d.ts +111 -0
- package/packages/daemon/dist/terminal/attachments/tmux-view-executor.js +825 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.d.ts +25 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.js +80 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.d.ts +66 -0
- package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.js +133 -0
- package/packages/daemon/dist/terminal/mirror/control-channel.d.ts +188 -0
- package/packages/daemon/dist/terminal/mirror/control-channel.js +624 -0
- package/packages/daemon/dist/terminal/mirror/control-mode-ownership.d.ts +14 -0
- package/packages/daemon/dist/terminal/mirror/control-mode-ownership.js +30 -0
- package/packages/daemon/dist/terminal/mirror/events.d.ts +115 -0
- package/packages/daemon/dist/terminal/mirror/events.js +18 -0
- package/packages/daemon/dist/terminal/mirror/flow-ledger.d.ts +40 -0
- package/packages/daemon/dist/terminal/mirror/flow-ledger.js +56 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.d.ts +137 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +329 -0
- package/packages/daemon/dist/terminal/mirror/pane-feed.d.ts +90 -0
- package/packages/daemon/dist/terminal/mirror/pane-feed.js +140 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.d.ts +216 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +2301 -0
- package/packages/daemon/dist/terminal/mirror/trusted-inventory.d.ts +28 -0
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.d.ts +72 -0
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +245 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.d.ts +208 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +2058 -0
- package/packages/daemon/dist/terminal/pane-stream/runtime.d.ts +26 -0
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +53 -0
- package/packages/daemon/dist/terminal/pane-stream/wire-ledger.d.ts +59 -0
- package/packages/daemon/dist/terminal/pane-stream/wire-ledger.js +110 -0
- package/packages/daemon/dist/terminal/protocol/chunk-bytes.d.ts +3 -0
- package/packages/daemon/dist/terminal/protocol/chunk-bytes.js +21 -0
- package/packages/daemon/dist/terminal/protocol/control.d.ts +66 -0
- package/packages/daemon/dist/terminal/protocol/control.js +111 -0
- package/packages/daemon/dist/terminal/protocol/input-coalescer.d.ts +55 -0
- package/packages/daemon/dist/terminal/protocol/input-coalescer.js +111 -0
- package/packages/daemon/dist/terminal/protocol/layout-parse.d.ts +68 -0
- package/packages/daemon/dist/terminal/protocol/layout-parse.js +127 -0
- package/packages/daemon/dist/terminal/protocol/pane-display-name.d.ts +16 -0
- package/packages/daemon/dist/terminal/protocol/pane-display-name.js +153 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.d.ts +78 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +294 -0
- package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.d.ts +90 -0
- package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.js +213 -0
- package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.d.ts +36 -0
- package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.js +260 -0
- package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.d.ts +29 -0
- package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.js +278 -0
- package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.d.ts +12 -0
- package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.js +147 -0
- package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.d.ts +16 -0
- package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.js +116 -0
- package/packages/daemon/dist/terminal/session-runtime/registry.d.ts +148 -0
- package/packages/daemon/dist/terminal/session-runtime/registry.js +1368 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-observability.d.ts +118 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-observability.js +72 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.d.ts +11 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.js +10 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.d.ts +18 -0
- package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.js +48 -0
- package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.d.ts +69 -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.d.ts +8 -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.d.ts +91 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +1362 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.d.ts +3 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.js +9 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-interpreter-backend.d.ts +55 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.d.ts +91 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +528 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.d.ts +50 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +387 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.d.ts +37 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.js +21 -0
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.d.ts +75 -0
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +474 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.d.ts +26 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +276 -0
- package/packages/daemon/dist/tui/async-disposable-slot.d.ts +18 -0
- package/packages/daemon/dist/tui/async-disposable-slot.js +57 -0
- package/packages/daemon/dist/tui/chrome/cheatsheet.d.ts +59 -0
- package/packages/daemon/dist/tui/chrome/cheatsheet.js +211 -0
- package/packages/daemon/dist/tui/chrome/chip.d.ts +21 -0
- package/packages/daemon/dist/tui/chrome/chip.js +25 -0
- package/packages/daemon/dist/tui/chrome/events.d.ts +51 -0
- package/packages/daemon/dist/tui/chrome/events.js +94 -0
- package/packages/daemon/dist/tui/chrome/front-door.d.ts +16 -0
- package/packages/daemon/dist/tui/chrome/front-door.js +16 -0
- package/packages/daemon/dist/tui/chrome/kitty-keys.d.ts +41 -0
- package/packages/daemon/dist/tui/chrome/kitty-keys.js +54 -0
- package/packages/daemon/dist/tui/chrome/menu.d.ts +92 -0
- package/packages/daemon/dist/tui/chrome/menu.js +251 -0
- package/packages/daemon/dist/tui/chrome/notify-prefs.d.ts +47 -0
- package/packages/daemon/dist/tui/chrome/notify-prefs.js +13 -0
- package/packages/daemon/dist/tui/chrome/notify-state.d.ts +13 -0
- package/packages/daemon/dist/tui/chrome/notify-state.js +77 -0
- package/packages/daemon/dist/tui/chrome/notify.d.ts +361 -0
- package/packages/daemon/dist/tui/chrome/notify.js +711 -0
- package/packages/daemon/dist/tui/chrome/panels.d.ts +72 -0
- package/packages/daemon/dist/tui/chrome/panels.js +60 -0
- package/packages/daemon/dist/tui/chrome/sidebar.d.ts +77 -0
- package/packages/daemon/dist/tui/chrome/sidebar.js +183 -0
- package/packages/daemon/dist/tui/chrome/snapshot.d.ts +110 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +290 -0
- package/packages/daemon/dist/tui/chrome/statusline.d.ts +237 -0
- package/packages/daemon/dist/tui/chrome/statusline.js +552 -0
- package/packages/daemon/dist/tui/chrome/updater.d.ts +230 -0
- package/packages/daemon/dist/tui/chrome/updater.js +651 -0
- package/packages/daemon/dist/tui/chrome/welcome.d.ts +41 -0
- package/packages/daemon/dist/tui/chrome/welcome.js +117 -0
- package/packages/daemon/dist/tui/compiled.d.ts +86 -0
- package/packages/daemon/dist/tui/compiled.js +165 -0
- package/packages/daemon/dist/tui/detect/agent-resolution.d.ts +56 -0
- package/packages/daemon/dist/tui/detect/agent-resolution.js +60 -0
- package/packages/daemon/dist/tui/detect/classify.d.ts +107 -0
- package/packages/daemon/dist/tui/detect/classify.js +184 -0
- package/packages/daemon/dist/tui/detect/manifest-loader.d.ts +54 -0
- package/packages/daemon/dist/tui/detect/manifest-loader.js +242 -0
- package/packages/daemon/dist/tui/detect/manifest.d.ts +111 -0
- package/packages/daemon/dist/tui/detect/manifest.js +126 -0
- package/packages/daemon/dist/tui/detect/manifests.d.ts +40 -0
- package/packages/daemon/dist/tui/detect/manifests.js +535 -0
- package/packages/daemon/dist/tui/detect/process-tree.d.ts +96 -0
- package/packages/daemon/dist/tui/detect/process-tree.js +194 -0
- package/packages/daemon/dist/tui/detect/session-id.d.ts +110 -0
- package/packages/daemon/dist/tui/detect/session-id.js +414 -0
- package/packages/daemon/dist/tui/detect/snapshot.d.ts +27 -0
- package/packages/daemon/dist/tui/detect/snapshot.js +81 -0
- package/packages/daemon/dist/tui/integrations/claude.d.ts +65 -0
- package/packages/daemon/dist/tui/integrations/claude.js +151 -0
- package/packages/daemon/dist/tui/integrations/offer.d.ts +47 -0
- package/packages/daemon/dist/tui/integrations/offer.js +134 -0
- package/packages/daemon/dist/tui/integrations/opencode.d.ts +37 -0
- package/packages/daemon/dist/tui/integrations/opencode.js +117 -0
- package/packages/daemon/dist/tui/mirror/ack-writer.d.ts +36 -0
- package/packages/daemon/dist/tui/mirror/ack-writer.js +78 -0
- package/packages/daemon/dist/tui/mirror/activity-surface-view.d.ts +8 -0
- package/packages/daemon/dist/tui/mirror/activity-surface-view.jsx +69 -0
- package/packages/daemon/dist/tui/mirror/activity-surface.d.ts +103 -0
- package/packages/daemon/dist/tui/mirror/activity-surface.js +271 -0
- package/packages/daemon/dist/tui/mirror/agent-chip.d.ts +76 -0
- package/packages/daemon/dist/tui/mirror/agent-chip.js +84 -0
- package/packages/daemon/dist/tui/mirror/agent-lifecycle.d.ts +217 -0
- package/packages/daemon/dist/tui/mirror/agent-lifecycle.js +372 -0
- package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.d.ts +42 -0
- package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.js +86 -0
- package/packages/daemon/dist/tui/mirror/agent-rows.d.ts +119 -0
- package/packages/daemon/dist/tui/mirror/agent-rows.js +126 -0
- package/packages/daemon/dist/tui/mirror/ansi-palette.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/ansi-palette.js +3 -0
- package/packages/daemon/dist/tui/mirror/app-state.d.ts +114 -0
- package/packages/daemon/dist/tui/mirror/app-state.js +294 -0
- package/packages/daemon/dist/tui/mirror/application-keybindings.d.ts +18 -0
- package/packages/daemon/dist/tui/mirror/application-keybindings.js +33 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.d.ts +53 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.js +253 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.js +45 -0
- package/packages/daemon/dist/tui/mirror/attention.d.ts +63 -0
- package/packages/daemon/dist/tui/mirror/attention.js +59 -0
- package/packages/daemon/dist/tui/mirror/blit.d.ts +82 -0
- package/packages/daemon/dist/tui/mirror/blit.js +120 -0
- package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.js +45 -0
- package/packages/daemon/dist/tui/mirror/changes-surface-view.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/changes-surface-view.jsx +92 -0
- package/packages/daemon/dist/tui/mirror/changes-surface.d.ts +115 -0
- package/packages/daemon/dist/tui/mirror/changes-surface.js +210 -0
- package/packages/daemon/dist/tui/mirror/composite-layout.d.ts +91 -0
- package/packages/daemon/dist/tui/mirror/composite-layout.js +539 -0
- package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.d.ts +39 -0
- package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.js +133 -0
- package/packages/daemon/dist/tui/mirror/dialog-model.d.ts +154 -0
- package/packages/daemon/dist/tui/mirror/dialog-model.js +183 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack-core.d.ts +45 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack-core.js +232 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack.d.ts +2 -0
- package/packages/daemon/dist/tui/mirror/dialog-stack.js +2 -0
- package/packages/daemon/dist/tui/mirror/diff-model.d.ts +169 -0
- package/packages/daemon/dist/tui/mirror/diff-model.js +332 -0
- package/packages/daemon/dist/tui/mirror/editor-buffer.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/editor-buffer.js +47 -0
- package/packages/daemon/dist/tui/mirror/editor-open-policy.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/editor-open-policy.js +9 -0
- package/packages/daemon/dist/tui/mirror/features/changes/contract.d.ts +75 -0
- package/packages/daemon/dist/tui/mirror/features/changes/controller.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/features/changes/controller.js +454 -0
- package/packages/daemon/dist/tui/mirror/features/changes/feature.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/features/changes/feature.jsx +9 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/contract.d.ts +47 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/feature.d.ts +12 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/feature.jsx +123 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/session.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/features/dialogs/session.js +160 -0
- package/packages/daemon/dist/tui/mirror/features/files/feature.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/features/files/feature.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/features/files/session.d.ts +133 -0
- package/packages/daemon/dist/tui/mirror/features/files/session.js +617 -0
- package/packages/daemon/dist/tui/mirror/features/home/feature.d.ts +28 -0
- package/packages/daemon/dist/tui/mirror/features/home/feature.jsx +122 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.d.ts +84 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.js +3 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.d.ts +6 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.jsx +5 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/session.d.ts +5 -0
- package/packages/daemon/dist/tui/mirror/features/missions-activity/session.js +377 -0
- package/packages/daemon/dist/tui/mirror/features/palette/contract.d.ts +116 -0
- package/packages/daemon/dist/tui/mirror/features/palette/contract.js +9 -0
- package/packages/daemon/dist/tui/mirror/features/palette/feature.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/features/palette/feature.js +3 -0
- package/packages/daemon/dist/tui/mirror/features/palette/session.d.ts +2 -0
- package/packages/daemon/dist/tui/mirror/features/palette/session.js +393 -0
- package/packages/daemon/dist/tui/mirror/features/palette/surface.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/features/palette/surface.jsx +48 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.jsx +2 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/session.d.ts +8 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/session.js +148 -0
- package/packages/daemon/dist/tui/mirror/features/performance-hud/surface.d.ts +17 -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.d.ts +9 -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.d.ts +71 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.jsx +103 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/session.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/features/rich-preview/session.js +310 -0
- package/packages/daemon/dist/tui/mirror/features/settings/catalog.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/features/settings/catalog.js +10 -0
- package/packages/daemon/dist/tui/mirror/features/settings/contract.d.ts +35 -0
- package/packages/daemon/dist/tui/mirror/features/settings/contract.js +1 -0
- package/packages/daemon/dist/tui/mirror/features/settings/feature.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/features/settings/feature.js +2 -0
- package/packages/daemon/dist/tui/mirror/features/settings/session.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/features/settings/session.js +309 -0
- package/packages/daemon/dist/tui/mirror/file-tree.d.ts +142 -0
- package/packages/daemon/dist/tui/mirror/file-tree.js +283 -0
- package/packages/daemon/dist/tui/mirror/files-surface-view.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/files-surface-view.jsx +92 -0
- package/packages/daemon/dist/tui/mirror/files-surface.d.ts +123 -0
- package/packages/daemon/dist/tui/mirror/files-surface.js +237 -0
- package/packages/daemon/dist/tui/mirror/focus-projection.d.ts +20 -0
- package/packages/daemon/dist/tui/mirror/focus-projection.js +80 -0
- package/packages/daemon/dist/tui/mirror/folder-picker.d.ts +38 -0
- package/packages/daemon/dist/tui/mirror/folder-picker.js +114 -0
- package/packages/daemon/dist/tui/mirror/frame-coalescer.d.ts +29 -0
- package/packages/daemon/dist/tui/mirror/frame-coalescer.js +74 -0
- package/packages/daemon/dist/tui/mirror/home-model.d.ts +81 -0
- package/packages/daemon/dist/tui/mirror/home-model.js +125 -0
- package/packages/daemon/dist/tui/mirror/home-surface-model.d.ts +113 -0
- package/packages/daemon/dist/tui/mirror/home-surface-model.js +297 -0
- package/packages/daemon/dist/tui/mirror/home-surface.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/home-surface.jsx +110 -0
- package/packages/daemon/dist/tui/mirror/host-terminal.d.ts +28 -0
- package/packages/daemon/dist/tui/mirror/host-terminal.js +33 -0
- package/packages/daemon/dist/tui/mirror/hosted.d.ts +179 -0
- package/packages/daemon/dist/tui/mirror/hosted.js +239 -0
- package/packages/daemon/dist/tui/mirror/input-lifecycle.d.ts +140 -0
- package/packages/daemon/dist/tui/mirror/input-lifecycle.js +147 -0
- package/packages/daemon/dist/tui/mirror/interaction-flow.d.ts +30 -0
- package/packages/daemon/dist/tui/mirror/interaction-flow.js +41 -0
- package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.js +84 -0
- package/packages/daemon/dist/tui/mirror/menu-model.d.ts +89 -0
- package/packages/daemon/dist/tui/mirror/menu-model.js +143 -0
- package/packages/daemon/dist/tui/mirror/missions-dashboard.d.ts +68 -0
- package/packages/daemon/dist/tui/mirror/missions-dashboard.js +261 -0
- package/packages/daemon/dist/tui/mirror/missions-render-fixtures.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/missions-render-fixtures.js +330 -0
- package/packages/daemon/dist/tui/mirror/missions-surface-controller.d.ts +84 -0
- package/packages/daemon/dist/tui/mirror/missions-surface-controller.js +314 -0
- package/packages/daemon/dist/tui/mirror/missions-surface.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/missions-surface.jsx +239 -0
- package/packages/daemon/dist/tui/mirror/missions-workspace.d.ts +341 -0
- package/packages/daemon/dist/tui/mirror/missions-workspace.js +1399 -0
- package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.d.ts +71 -0
- package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.js +233 -0
- package/packages/daemon/dist/tui/mirror/open-tui-pane-stream-socket.d.ts +16 -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.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/open-tui-verified-routing.js +45 -0
- package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.d.ts +36 -0
- package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +1069 -0
- package/packages/daemon/dist/tui/mirror/palette-surface-adapter.d.ts +58 -0
- package/packages/daemon/dist/tui/mirror/palette-surface-adapter.js +384 -0
- package/packages/daemon/dist/tui/mirror/palette.d.ts +315 -0
- package/packages/daemon/dist/tui/mirror/palette.js +522 -0
- package/packages/daemon/dist/tui/mirror/pane-frame-state.d.ts +68 -0
- package/packages/daemon/dist/tui/mirror/pane-frame-state.js +124 -0
- package/packages/daemon/dist/tui/mirror/pane-mirror.d.ts +205 -0
- package/packages/daemon/dist/tui/mirror/pane-mirror.js +584 -0
- package/packages/daemon/dist/tui/mirror/pane-surface.d.ts +257 -0
- package/packages/daemon/dist/tui/mirror/pane-surface.jsx +855 -0
- package/packages/daemon/dist/tui/mirror/panel-host-reactive.d.ts +7 -0
- package/packages/daemon/dist/tui/mirror/panel-host-reactive.js +13 -0
- package/packages/daemon/dist/tui/mirror/panel-host.d.ts +69 -0
- package/packages/daemon/dist/tui/mirror/panel-host.js +242 -0
- package/packages/daemon/dist/tui/mirror/perf-tap.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/perf-tap.js +32 -0
- package/packages/daemon/dist/tui/mirror/performance-events.d.ts +404 -0
- package/packages/daemon/dist/tui/mirror/performance-events.js +46 -0
- package/packages/daemon/dist/tui/mirror/recipe-components.d.ts +93 -0
- package/packages/daemon/dist/tui/mirror/recipe-components.jsx +135 -0
- package/packages/daemon/dist/tui/mirror/recipes.d.ts +90 -0
- package/packages/daemon/dist/tui/mirror/recipes.js +395 -0
- package/packages/daemon/dist/tui/mirror/reference-performance-trace.d.ts +80 -0
- package/packages/daemon/dist/tui/mirror/reference-performance-trace.js +597 -0
- package/packages/daemon/dist/tui/mirror/renderer-commands.d.ts +60 -0
- package/packages/daemon/dist/tui/mirror/renderer-commands.js +250 -0
- package/packages/daemon/dist/tui/mirror/resize-model.d.ts +76 -0
- package/packages/daemon/dist/tui/mirror/resize-model.js +105 -0
- package/packages/daemon/dist/tui/mirror/resize-transaction.d.ts +102 -0
- package/packages/daemon/dist/tui/mirror/resize-transaction.js +221 -0
- package/packages/daemon/dist/tui/mirror/rich-placement-projection.d.ts +64 -0
- package/packages/daemon/dist/tui/mirror/rich-placement-projection.js +80 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.js +79 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.d.ts +61 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.js +51 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.js +80 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.d.ts +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.js +88 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.d.ts +60 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.js +320 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-binding.d.ts +28 -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.d.ts +16 -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.d.ts +38 -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.d.ts +43 -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.d.ts +5 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-input-readiness.js +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.d.ts +72 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.js +297 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-optional-features.d.ts +14 -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.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +61 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.d.ts +31 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.js +60 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.js +30 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.js +38 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-pending-terminal-input.d.ts +53 -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.d.ts +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.js +81 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-post-render-runtime.d.ts +37 -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.d.ts +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-configuration.js +21 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.js +27 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-session-focus-owner.d.ts +14 -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.d.ts +34 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-binding.js +307 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-shell-viewport.d.ts +8 -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.d.ts +6 -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.d.ts +3 -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.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.js +96 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.d.ts +65 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +1326 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-palette-owner.d.ts +65 -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.d.ts +4 -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.d.ts +15 -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.d.ts +47 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-selection-owner.js +161 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.d.ts +44 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.js +177 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.d.ts +103 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.jsx +720 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-theme-repaint.d.ts +24 -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.d.ts +15 -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.d.ts +17 -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.d.ts +64 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-client-ledger.js +271 -0
- package/packages/daemon/dist/tui/mirror/runtime/causal-cell-input-fixture.d.ts +12 -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.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/changes-deferred-identity.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.d.ts +29 -0
- package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.js +128 -0
- package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.d.ts +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.js +40 -0
- package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.js +39 -0
- package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.d.ts +3 -0
- package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.js +9 -0
- package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.js +27 -0
- package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.js +53 -0
- package/packages/daemon/dist/tui/mirror/runtime/generation-bound-slot.d.ts +7 -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.d.ts +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/host-local-tmux-adapter.js +90 -0
- package/packages/daemon/dist/tui/mirror/runtime/hosted-tty-size-bridge.d.ts +55 -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.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/latest-intent-fence.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.d.ts +30 -0
- package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.js +58 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.d.ts +44 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.js +118 -0
- package/packages/daemon/dist/tui/mirror/runtime/modal-pointer-capture.d.ts +13 -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.d.ts +68 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.js +834 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.js +146 -0
- package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.d.ts +45 -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.d.ts +11 -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.d.ts +55 -0
- package/packages/daemon/dist/tui/mirror/runtime/palette-production-controller.js +126 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.js +13 -0
- package/packages/daemon/dist/tui/mirror/runtime/pane-scoped-terminal-surface.d.ts +42 -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.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/runtime/product-surface-policy.js +12 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.d.ts +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.js +4 -0
- package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.d.ts +35 -0
- package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.js +91 -0
- package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.js +14 -0
- package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.d.ts +20 -0
- package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.js +111 -0
- package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.d.ts +25 -0
- package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.js +90 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-pane-publication.d.ts +10 -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.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/runtime/semantic-shell-viewport-resize.js +56 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-dimensions-owner.d.ts +9 -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.d.ts +52 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.js +610 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.js +84 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-host-focus.d.ts +41 -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.d.ts +3 -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.d.ts +10 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-input-adapter.js +50 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.js +28 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.js +82 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.d.ts +66 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.js +141 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.d.ts +50 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.js +89 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.d.ts +31 -0
- package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.js +64 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.d.ts +92 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.js +636 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.d.ts +59 -0
- package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.js +169 -0
- package/packages/daemon/dist/tui/mirror/runtime/viewport-fit-coordinator.d.ts +8 -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.d.ts +22 -0
- package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.js +498 -0
- package/packages/daemon/dist/tui/mirror/scrollbar-model.d.ts +35 -0
- package/packages/daemon/dist/tui/mirror/scrollbar-model.js +64 -0
- package/packages/daemon/dist/tui/mirror/search-model.d.ts +41 -0
- package/packages/daemon/dist/tui/mirror/search-model.js +62 -0
- package/packages/daemon/dist/tui/mirror/selection.d.ts +175 -0
- package/packages/daemon/dist/tui/mirror/selection.js +264 -0
- package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.d.ts +147 -0
- package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.js +562 -0
- package/packages/daemon/dist/tui/mirror/semantic-session-view.d.ts +86 -0
- package/packages/daemon/dist/tui/mirror/semantic-session-view.js +269 -0
- package/packages/daemon/dist/tui/mirror/settings-model.d.ts +108 -0
- package/packages/daemon/dist/tui/mirror/settings-model.js +304 -0
- package/packages/daemon/dist/tui/mirror/shell-chrome.d.ts +151 -0
- package/packages/daemon/dist/tui/mirror/shell-chrome.js +313 -0
- package/packages/daemon/dist/tui/mirror/size-truth.d.ts +92 -0
- package/packages/daemon/dist/tui/mirror/size-truth.js +104 -0
- package/packages/daemon/dist/tui/mirror/spans.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/spans.js +31 -0
- package/packages/daemon/dist/tui/mirror/status-grammar.d.ts +18 -0
- package/packages/daemon/dist/tui/mirror/status-grammar.js +29 -0
- package/packages/daemon/dist/tui/mirror/terminal-surface.d.ts +55 -0
- package/packages/daemon/dist/tui/mirror/terminal-surface.js +92 -0
- package/packages/daemon/dist/tui/mirror/terminal-text.d.ts +9 -0
- package/packages/daemon/dist/tui/mirror/terminal-text.js +38 -0
- package/packages/daemon/dist/tui/mirror/theme.d.ts +207 -0
- package/packages/daemon/dist/tui/mirror/theme.js +744 -0
- package/packages/daemon/dist/tui/mirror/ui/agent-badge.d.ts +11 -0
- package/packages/daemon/dist/tui/mirror/ui/agent-badge.jsx +14 -0
- package/packages/daemon/dist/tui/mirror/ui/badge.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/ui/badge.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/ui/button.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/ui/button.jsx +66 -0
- package/packages/daemon/dist/tui/mirror/ui/dialog.d.ts +19 -0
- package/packages/daemon/dist/tui/mirror/ui/dialog.jsx +8 -0
- package/packages/daemon/dist/tui/mirror/ui/index.d.ts +16 -0
- package/packages/daemon/dist/tui/mirror/ui/index.js +16 -0
- package/packages/daemon/dist/tui/mirror/ui/key-hint.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/ui/key-hint.jsx +39 -0
- package/packages/daemon/dist/tui/mirror/ui/keyboard-router.d.ts +25 -0
- package/packages/daemon/dist/tui/mirror/ui/keyboard-router.jsx +46 -0
- package/packages/daemon/dist/tui/mirror/ui/menu.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/ui/menu.jsx +15 -0
- package/packages/daemon/dist/tui/mirror/ui/navigation-row.d.ts +21 -0
- package/packages/daemon/dist/tui/mirror/ui/navigation-row.jsx +62 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-frame.d.ts +25 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-frame.jsx +52 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-host.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-host.jsx +33 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.jsx +23 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-model.d.ts +29 -0
- package/packages/daemon/dist/tui/mirror/ui/overlay-model.js +45 -0
- package/packages/daemon/dist/tui/mirror/ui/state.d.ts +27 -0
- package/packages/daemon/dist/tui/mirror/ui/state.js +171 -0
- package/packages/daemon/dist/tui/mirror/ui/status-bar.d.ts +43 -0
- package/packages/daemon/dist/tui/mirror/ui/status-bar.jsx +102 -0
- package/packages/daemon/dist/tui/mirror/ui/surface.d.ts +14 -0
- package/packages/daemon/dist/tui/mirror/ui/surface.jsx +45 -0
- package/packages/daemon/dist/tui/mirror/ui/tabs.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/ui/tabs.jsx +88 -0
- package/packages/daemon/dist/tui/mirror/widget-fallback.d.ts +15 -0
- package/packages/daemon/dist/tui/mirror/widget-fallback.js +52 -0
- package/packages/daemon/dist/tui/mirror/widget-surface-model.d.ts +26 -0
- package/packages/daemon/dist/tui/mirror/widget-surface-model.js +145 -0
- package/packages/daemon/dist/tui/mirror/widget-surface.d.ts +13 -0
- package/packages/daemon/dist/tui/mirror/widget-surface.jsx +31 -0
- package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.d.ts +53 -0
- package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.js +77 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.d.ts +266 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.js +99 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-controller.d.ts +83 -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.d.ts +5 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell-surface-commands.js +28 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell.d.ts +49 -0
- package/packages/daemon/dist/tui/mirror/workspace/application-shell.js +97 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface-view.d.ts +11 -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.d.ts +128 -0
- package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface.js +342 -0
- package/packages/daemon/dist/tui/mirror/workspace/icons.d.ts +154 -0
- package/packages/daemon/dist/tui/mirror/workspace/icons.js +43 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.d.ts +24 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.jsx +20 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-frame.d.ts +143 -0
- package/packages/daemon/dist/tui/mirror/workspace/pane-frame.js +452 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.d.ts +152 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.js +555 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.d.ts +58 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.jsx +93 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.d.ts +75 -0
- package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.jsx +253 -0
- package/packages/daemon/dist/tui/mirror/workspace/text.d.ts +2 -0
- package/packages/daemon/dist/tui/mirror/workspace/text.js +27 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.d.ts +23 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.js +34 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.d.ts +123 -0
- package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.js +286 -0
- package/packages/daemon/dist/tui/mirror/workspace-ui-state.d.ts +174 -0
- package/packages/daemon/dist/tui/mirror/workspace-ui-state.js +885 -0
- package/packages/daemon/dist/tui/readiness.d.ts +22 -0
- package/packages/daemon/dist/tui/readiness.js +34 -0
- package/packages/daemon/dist/tui/team/entry.d.ts +37 -0
- package/packages/daemon/dist/tui/team/entry.js +20 -0
- package/packages/daemon/dist/tui/team/fuzzy.d.ts +38 -0
- package/packages/daemon/dist/tui/team/fuzzy.js +141 -0
- package/packages/daemon/dist/tui/team/home.d.ts +94 -0
- package/packages/daemon/dist/tui/team/home.js +115 -0
- package/packages/daemon/dist/tui/team/input.d.ts +22 -0
- package/packages/daemon/dist/tui/team/input.js +21 -0
- package/packages/daemon/dist/tui/team/keymap.d.ts +33 -0
- package/packages/daemon/dist/tui/team/keymap.js +99 -0
- package/packages/daemon/dist/tui/team/mouse.d.ts +18 -0
- package/packages/daemon/dist/tui/team/mouse.js +17 -0
- package/packages/daemon/dist/tui/team/nav.d.ts +21 -0
- package/packages/daemon/dist/tui/team/nav.js +33 -0
- package/packages/daemon/dist/tui/team/preview.d.ts +19 -0
- package/packages/daemon/dist/tui/team/preview.js +35 -0
- package/packages/daemon/dist/tui/team/projects.d.ts +52 -0
- package/packages/daemon/dist/tui/team/projects.js +159 -0
- package/packages/daemon/dist/tui/team/report.d.ts +51 -0
- package/packages/daemon/dist/tui/team/report.js +37 -0
- package/packages/daemon/dist/tui/team/sessions.d.ts +235 -0
- package/packages/daemon/dist/tui/team/sessions.js +292 -0
- package/packages/daemon/dist/tui/team/tree.d.ts +41 -0
- package/packages/daemon/dist/tui/team/tree.js +42 -0
- package/packages/daemon/dist/tui/team/wait-receipts.d.ts +60 -0
- package/packages/daemon/dist/tui/team/wait-receipts.js +153 -0
- package/packages/daemon/dist/tui/team/wait.d.ts +62 -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.d.ts +5 -9
- package/packages/daemon/dist/widgets/lib/watcher.js +5 -92
- package/packages/daemon/dist/widgets/resolve.js +10 -7
- 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 +38 -36
- 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-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 +61 -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-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/client.ts +128 -0
- package/packages/daemon/src/control/dispatch.ts +107 -0
- package/packages/daemon/src/control/fanout.ts +44 -0
- package/packages/daemon/src/control/frames.ts +40 -0
- package/packages/daemon/src/control/lifecycle.ts +163 -0
- package/packages/daemon/src/control/server.ts +237 -0
- package/packages/daemon/src/control/verbs.ts +118 -0
- package/packages/daemon/src/detect.ts +25 -20
- package/packages/daemon/src/doctor.ts +133 -33
- 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-discovery.ts +53 -13
- package/packages/daemon/src/lib/agent-kind.ts +23 -0
- package/packages/daemon/src/lib/app-config.ts +143 -9
- 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/canonical-daemon-bootstrap.ts +266 -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 +1347 -387
- 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/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 +406 -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/manifest-pack.ts +255 -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/resolved-config.ts +425 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +186 -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/state-home.ts +12 -0
- package/packages/daemon/src/lib/theme-mode.ts +11 -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-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/update-check.ts +5 -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 +1406 -0
- package/packages/daemon/src/lib/workspace-promotion.ts +1031 -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 +67 -24
- 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 +191 -22
- 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 +2206 -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 +827 -0
- package/packages/daemon/src/terminal/mirror/control-mode-ownership.ts +34 -0
- package/packages/daemon/src/terminal/mirror/events.ts +128 -0
- package/packages/daemon/src/terminal/mirror/flow-ledger.ts +65 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +480 -0
- package/packages/daemon/src/terminal/mirror/pane-feed.ts +193 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +2820 -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 +2612 -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/{tui/mirror → terminal/protocol}/control.ts +39 -6
- package/packages/daemon/src/{tui/mirror → terminal/protocol}/input-coalescer.ts +18 -7
- package/packages/daemon/src/terminal/protocol/layout-parse.ts +154 -0
- package/packages/daemon/src/terminal/protocol/pane-display-name.ts +185 -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 +312 -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/registry.ts +2047 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +267 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-scheduler.ts +22 -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 +1806 -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 +64 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +690 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +498 -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 +25 -0
- package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +379 -0
- package/packages/daemon/src/tui/async-disposable-slot.ts +60 -0
- package/packages/daemon/src/tui/chrome/events.ts +4 -4
- package/packages/daemon/src/tui/chrome/front-door.ts +27 -0
- package/packages/daemon/src/tui/chrome/notify-prefs.ts +58 -0
- package/packages/daemon/src/tui/chrome/notify-state.ts +76 -0
- package/packages/daemon/src/tui/chrome/notify.ts +582 -84
- package/packages/daemon/src/tui/chrome/sidebar.ts +9 -4
- package/packages/daemon/src/tui/chrome/statusline.ts +15 -6
- package/packages/daemon/src/tui/chrome/updater.ts +367 -64
- package/packages/daemon/src/tui/compiled.ts +102 -6
- package/packages/daemon/src/tui/detect/agent-resolution.ts +85 -0
- package/packages/daemon/src/tui/detect/classify.ts +34 -0
- package/packages/daemon/src/tui/detect/manifest-loader.ts +54 -5
- package/packages/daemon/src/tui/detect/manifest.ts +24 -3
- package/packages/daemon/src/tui/detect/manifests.ts +240 -6
- package/packages/daemon/src/tui/detect/process-tree.ts +30 -4
- package/packages/daemon/src/tui/detect/session-id.ts +503 -0
- 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/integrations/opencode.ts +121 -0
- package/packages/daemon/src/tui/main.ts +53 -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-chip.ts +40 -11
- package/packages/daemon/src/tui/mirror/agent-lifecycle.ts +468 -0
- package/packages/daemon/src/tui/mirror/agent-provisioning-executor.ts +151 -0
- package/packages/daemon/src/tui/mirror/agent-rows.ts +61 -5
- package/packages/daemon/src/tui/mirror/ansi-palette.ts +3 -0
- package/packages/daemon/src/tui/mirror/app-state.ts +185 -9
- package/packages/daemon/src/tui/mirror/app.tsx +2 -5264
- package/packages/daemon/src/tui/mirror/application-keybindings.ts +54 -0
- package/packages/daemon/src/tui/mirror/application-shell-daemon-connection.ts +344 -0
- package/packages/daemon/src/tui/mirror/application-shell-daemon-session.ts +74 -0
- package/packages/daemon/src/tui/mirror/attention.ts +110 -0
- package/packages/daemon/src/tui/mirror/canonical-workspace-routing.ts +63 -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 -354
- package/packages/daemon/src/tui/mirror/diff-model.ts +279 -4
- 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/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 +427 -0
- package/packages/daemon/src/tui/mirror/features/palette/surface.tsx +92 -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/file-tree.ts +231 -6
- 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/host-terminal.ts +49 -0
- package/packages/daemon/src/tui/mirror/hosted.ts +286 -0
- 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 +28 -18
- 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 +379 -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 +83 -0
- package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +1314 -0
- package/packages/daemon/src/tui/mirror/palette-surface-adapter.ts +465 -0
- package/packages/daemon/src/tui/mirror/palette.ts +485 -34
- package/packages/daemon/src/tui/mirror/pane-frame-state.ts +209 -0
- package/packages/daemon/src/tui/mirror/pane-mirror.ts +215 -50
- package/packages/daemon/src/tui/mirror/pane-surface.tsx +720 -51
- 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 -122
- package/packages/daemon/src/tui/mirror/performance-events.ts +488 -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 +726 -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-appearance-owner.ts +121 -0
- package/packages/daemon/src/tui/mirror/runtime/application-bootstrap.ts +118 -0
- package/packages/daemon/src/tui/mirror/runtime/application-entry.ts +194 -0
- package/packages/daemon/src/tui/mirror/runtime/application-generation-starter.ts +116 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-catalog-owner.ts +112 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-catalog.ts +440 -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-optional-features.ts +25 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +87 -0
- package/packages/daemon/src/tui/mirror/runtime/application-palette-input.ts +105 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-input.ts +43 -0
- package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-owner.ts +43 -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 +110 -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 +32 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +506 -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 +365 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-catalog.tsx +372 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-home.tsx +161 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-overlay-stack.tsx +42 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-overlays.tsx +154 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-sidebar.tsx +140 -0
- package/packages/daemon/src/tui/mirror/runtime/application-shell-view.tsx +425 -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 +133 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +1630 -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 +218 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace-policy.ts +285 -0
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace.tsx +1150 -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 +394 -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 +61 -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 +105 -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 +996 -0
- package/packages/daemon/src/tui/mirror/runtime/open-tui-session-owner.ts +195 -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 +22 -0
- package/packages/daemon/src/tui/mirror/runtime/pane-scoped-terminal-surface.tsx +146 -0
- package/packages/daemon/src/tui/mirror/runtime/product-surface-policy.ts +16 -0
- package/packages/daemon/src/tui/mirror/runtime/renderer-cadence.ts +4 -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 +78 -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 +719 -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 +45 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-pane-input-router.ts +94 -0
- package/packages/daemon/src/tui/mirror/runtime/terminal-selection.ts +218 -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 +122 -29
- package/packages/daemon/src/tui/mirror/semantic-pane-render-source.ts +767 -0
- package/packages/daemon/src/tui/mirror/semantic-session-view.ts +366 -0
- package/packages/daemon/src/tui/mirror/settings-model.ts +95 -57
- package/packages/daemon/src/tui/mirror/shell-chrome-view.tsx +346 -0
- package/packages/daemon/src/tui/mirror/shell-chrome.ts +508 -0
- package/packages/daemon/src/tui/mirror/sidebar.tsx +321 -0
- package/packages/daemon/src/tui/mirror/size-truth.ts +53 -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 +42 -0
- package/packages/daemon/src/tui/mirror/theme.ts +1059 -0
- 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 +68 -0
- package/packages/daemon/src/tui/mirror/ui/navigation-row.tsx +114 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-frame.tsx +115 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-host.tsx +71 -0
- package/packages/daemon/src/tui/mirror/ui/overlay-list-row.tsx +59 -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__/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-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 +544 -0
- package/packages/daemon/src/tui/mirror/workspace/icons.ts +56 -0
- package/packages/daemon/src/tui/mirror/workspace/pane-action-menu.tsx +68 -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 +225 -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/fuzzy.ts +20 -0
- 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 +119 -46
- package/packages/daemon/src/tui/team/wait-receipts.ts +192 -0
- package/packages/daemon/src/tui/team/wait.ts +144 -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 +15 -7
- 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 +2754 -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.ts +203 -0
- package/packages/daemon-client/src/workspace-client-types.ts +302 -0
- package/packages/daemon-client/src/workspace-client.test.ts +2626 -0
- package/packages/daemon-client/src/workspace-client.ts +1421 -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/architecture-debt-budget.json +10 -0
- package/scripts/architecture-debt-inventory.mjs +98 -0
- package/scripts/build-cli.mjs +22 -1
- package/scripts/build-macos-notifier.mjs +160 -0
- package/scripts/build-tui.mjs +59 -3
- package/scripts/check-control-bytes.mjs +70 -0
- package/scripts/dev-web.mjs +66 -0
- package/scripts/lib/bounded-child-command.mjs +59 -0
- package/scripts/lib/bounded-child-command.test.mjs +148 -0
- package/scripts/lib/bounded-diagnostic-tail.mjs +82 -0
- package/scripts/lib/bounded-diagnostic-tail.test.mjs +97 -0
- package/scripts/lib/npm-release-tag.mjs +27 -0
- package/scripts/lib/npm-release-tag.test.mjs +116 -0
- package/scripts/lib/packed-opentui-frame.mjs +18 -0
- package/scripts/lib/packed-opentui-frame.test.mjs +40 -0
- package/scripts/lib/performance-reference-budgets.mjs +36 -0
- package/scripts/lib/performance-reference-report.mjs +157 -0
- package/scripts/lib/performance-reference-report.test.mjs +62 -0
- package/scripts/lib/portable-performance-evidence.mjs +210 -0
- package/scripts/lib/portable-performance-evidence.test.mjs +208 -0
- package/scripts/lib/product-ansi-cursor-alt-screen-fixture.mjs +132 -0
- package/scripts/lib/product-ansi-cursor-alt-screen.mjs +4618 -0
- package/scripts/lib/product-ansi-cursor-alt-screen.test.mjs +4120 -0
- package/scripts/lib/product-ansi-tmux-precondition.mjs +159 -0
- package/scripts/lib/product-ansi-tmux-precondition.test.mjs +147 -0
- package/scripts/lib/product-card5-host-topology.mjs +873 -0
- package/scripts/lib/product-card5-host-topology.test.mjs +1070 -0
- package/scripts/lib/product-card5-production-host-owner.mjs +4864 -0
- package/scripts/lib/product-card5-production-host-owner.test.mjs +5051 -0
- package/scripts/lib/product-configless-owner.mjs +1578 -0
- package/scripts/lib/product-configless-owner.test.mjs +2169 -0
- package/scripts/lib/product-cross-client-handoff.mjs +1165 -0
- package/scripts/lib/product-cross-client-handoff.test.mjs +1062 -0
- package/scripts/lib/product-cross-client-host-evidence.mjs +4780 -0
- package/scripts/lib/product-cross-client-host-evidence.test.mjs +3897 -0
- package/scripts/lib/product-first-input.mjs +1546 -0
- package/scripts/lib/product-first-input.test.mjs +1731 -0
- package/scripts/lib/product-focus-tmux.mjs +46 -0
- package/scripts/lib/product-focus.mjs +1198 -0
- package/scripts/lib/product-focus.test.mjs +1504 -0
- package/scripts/lib/product-idle-process-proof.mjs +270 -0
- package/scripts/lib/product-idle-process-proof.test.mjs +210 -0
- package/scripts/lib/product-keyboard-pointer-resize.mjs +471 -0
- package/scripts/lib/product-keyboard-pointer-resize.test.mjs +363 -0
- package/scripts/lib/product-rig-causal-cell-fixture.mjs +91 -0
- package/scripts/lib/product-rig-causal-fixture-geometry.mjs +27 -0
- package/scripts/lib/product-rig-causal-fixture-geometry.test.mjs +45 -0
- package/scripts/lib/product-rig-sleep-assertion.mjs +179 -0
- package/scripts/lib/product-selection-copy-app-mouse.mjs +1585 -0
- package/scripts/lib/product-selection-copy-app-mouse.test.mjs +1602 -0
- package/scripts/lib/product-tui-host-readiness.mjs +133 -0
- package/scripts/lib/product-tui-host-readiness.test.mjs +258 -0
- package/scripts/lib/product-window-lifecycle.mjs +1351 -0
- package/scripts/lib/product-window-lifecycle.test.mjs +1305 -0
- package/scripts/lib/release-source-state.mjs +28 -0
- package/scripts/lib/release-source-state.test.mjs +26 -0
- package/scripts/lib/tui-diagnostics.mjs +159 -0
- package/scripts/lib/tui-host-publication.mjs +38 -0
- package/scripts/lib/tui-testdrive-clipboard-hook.mjs +543 -0
- package/scripts/lib/tui-testdrive-clipboard-hook.test.mjs +626 -0
- package/scripts/lib/tui-testdrive-input.mjs +1940 -0
- package/scripts/lib/tui-testdrive-input.test.mjs +3434 -0
- package/scripts/lib/tui-testdrive-launch.mjs +180 -0
- package/scripts/lib/tui-testdrive-launch.test.mjs +294 -0
- package/scripts/opentui-release-check.mjs +209 -0
- package/scripts/pack-check-run.mjs +1779 -30
- package/scripts/pack-tui-check.mjs +73 -0
- package/scripts/pack-web-check.mjs +19 -0
- package/scripts/performance-portable-evidence.mjs +419 -0
- package/scripts/performance-qualification.mjs +456 -0
- package/scripts/performance-reference-memory.ts +177 -0
- package/scripts/performance-reference-pane-stream.ts +74 -0
- package/scripts/performance-reference.mjs +681 -0
- package/scripts/postinstall.js +14 -6
- package/scripts/prepublish-check.mjs +37 -1
- package/scripts/prepublish-opentui-check.mjs +24 -0
- package/scripts/product-test-rig-journeys.mjs +2700 -0
- package/scripts/product-test-rig-journeys.test.mjs +3959 -0
- package/scripts/product-test-rig-lib.mjs +2359 -0
- package/scripts/product-test-rig-multiclient.ts +434 -0
- package/scripts/product-test-rig-native-client.mjs +45 -0
- package/scripts/product-test-rig.mjs +20260 -0
- package/scripts/product-test-rig.test.mjs +3634 -0
- package/scripts/publish-tap.sh +55 -0
- package/scripts/smoke-tui-missions.mjs +329 -0
- package/scripts/tui-diagnose.mjs +258 -0
- package/scripts/tui-diagnose.test.mjs +200 -0
- package/scripts/tui-testdrive-capture.test.mjs +161 -0
- package/scripts/tui-testdrive.mjs +1955 -0
- package/skill/SKILL.md +115 -30
- 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/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.d.ts +0 -13
- package/packages/daemon/dist/widgets/explorer/tree.jsx +0 -108
- 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/preview/index.jsx +0 -371
- 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/sidebar/index.jsx +0 -462
- package/packages/daemon/src/tui/mirror/control-client.ts +0 -214
- package/packages/daemon/src/tui/mirror/focus-border.ts +0 -57
- package/packages/daemon/src/tui/mirror/session-mirror.ts +0 -443
- package/packages/daemon/src/widgets/setup/orchestrator-panel.tsx +0 -200
- package/scripts/perf-mirror.mjs +0 -313
- package/scripts/verify-endpoints.sh +0 -90
- /package/packages/daemon/dist/{widgets/changes/index.d.ts → lib/__tests__/fixtures/workspace-state-writer.d.ts} +0 -0
- /package/packages/daemon/dist/{widgets/explorer/index.d.ts → terminal/mirror/trusted-inventory.js} +0 -0
- /package/packages/daemon/dist/{widgets/preview/index.d.ts → terminal/session-runtime/terminal-interpreter-backend.js} +0 -0
- /package/packages/daemon/dist/{widgets/sidebar/index.d.ts → tui/mirror/features/changes/contract.js} +0 -0
|
@@ -0,0 +1,2612 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
PANE_STREAM_MAX_HELD_DELTAS,
|
|
4
|
+
PANE_STREAM_MAX_OUTPUT_BYTES,
|
|
5
|
+
PANE_STREAM_MAX_PANES,
|
|
6
|
+
PANE_STREAM_MAX_SEED_BYTES,
|
|
7
|
+
PANE_STREAM_PROTOCOL_VERSION,
|
|
8
|
+
PANE_STREAM_REDEEM_PATH,
|
|
9
|
+
PANE_STREAM_WEBSOCKET_SUBPROTOCOL,
|
|
10
|
+
PaneStreamClientFrameSchemaZ,
|
|
11
|
+
PaneStreamLoopbackWebSocketUrlSchemaZ,
|
|
12
|
+
PaneStreamRedeemFrameSchemaZ,
|
|
13
|
+
PaneStreamServerFrameSchemaZ,
|
|
14
|
+
sharedMonotonicMicros,
|
|
15
|
+
type PaneStreamErrorFrameCode,
|
|
16
|
+
type PaneStreamServerFrame,
|
|
17
|
+
type PaneStreamLeaseRequest,
|
|
18
|
+
type PaneStreamRedeemFrame,
|
|
19
|
+
type PaneStreamViewerMode,
|
|
20
|
+
type PaneStreamDiagnosticCapability,
|
|
21
|
+
type SessionRuntimeSemanticIntent,
|
|
22
|
+
type SessionRuntimeTerminalInput,
|
|
23
|
+
type CausalCellProbeV1,
|
|
24
|
+
type SessionRuntimeActivityKind,
|
|
25
|
+
type SessionRuntimeAuthorityKind,
|
|
26
|
+
type SessionRuntimeAuthorityLease,
|
|
27
|
+
type SessionRuntimeAuthoritySnapshot,
|
|
28
|
+
type SessionRuntimePresenceState,
|
|
29
|
+
type TerminalDeliveryAck,
|
|
30
|
+
type TerminalDeliveryNack,
|
|
31
|
+
type TerminalDeliveryOffer,
|
|
32
|
+
type TerminalDeliveryNegotiationResult,
|
|
33
|
+
type TerminalDeliveryServerMessage,
|
|
34
|
+
type TerminalDeliveryVisibility,
|
|
35
|
+
type WorkspaceMultiplexerMutationResult,
|
|
36
|
+
} from "@tmux-ide/contracts";
|
|
37
|
+
import type {
|
|
38
|
+
MirrorLayoutAuthoritySnapshot,
|
|
39
|
+
MirrorLayoutEvent,
|
|
40
|
+
MirrorPaneEvent,
|
|
41
|
+
MirrorSessionDescription,
|
|
42
|
+
} from "../mirror/events.ts";
|
|
43
|
+
import type {
|
|
44
|
+
MirrorLayoutSubscription,
|
|
45
|
+
MirrorSubscribeRequest,
|
|
46
|
+
MirrorSubscription,
|
|
47
|
+
} from "../mirror/mirror-service.ts";
|
|
48
|
+
import type { CausalCellLedgerResult } from "../session-runtime/causal-cell-ledger.ts";
|
|
49
|
+
import {
|
|
50
|
+
canonicalOriginOrNull,
|
|
51
|
+
digestSecret,
|
|
52
|
+
digestsEqual,
|
|
53
|
+
rawDataByteLength,
|
|
54
|
+
rawDataToBuffer,
|
|
55
|
+
safeCloseSocket,
|
|
56
|
+
strictJsonParse,
|
|
57
|
+
} from "../attachments/admission-util.ts";
|
|
58
|
+
import type { DirectTerminalSocket } from "../attachments/direct-websocket.ts";
|
|
59
|
+
import type { SessionRuntimeObservability } from "../session-runtime/runtime-observability.ts";
|
|
60
|
+
import { SessionRuntimeControllerLeaseError } from "../session-runtime/registry.ts";
|
|
61
|
+
import { terminalDeliveryObservationOrdinal } from "../session-runtime/terminal-delivery-observation-identity.ts";
|
|
62
|
+
import {
|
|
63
|
+
PaneStreamLeaseError,
|
|
64
|
+
type IssuedPaneStreamLease,
|
|
65
|
+
type PaneStreamLeaseBinding,
|
|
66
|
+
type PaneStreamLeaseDescriptor,
|
|
67
|
+
} from "./lease-manager.ts";
|
|
68
|
+
import {
|
|
69
|
+
DEFAULT_PANE_STREAM_FLOW_BUDGETS,
|
|
70
|
+
PaneStreamWireLedger,
|
|
71
|
+
type PaneStreamFlowBudgets,
|
|
72
|
+
} from "./wire-ledger.ts";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The pane-stream WebSocket endpoint (m43 card 2): redeems a one-time `ps1_`
|
|
76
|
+
* ticket and bridges MirrorService subscriptions to wire frames. Admission is
|
|
77
|
+
* the direct-websocket discipline verbatim — Origin-gated upgrade reservation,
|
|
78
|
+
* digest-only pending tickets, one text redemption frame, delivery-bound TTL —
|
|
79
|
+
* applied to a session-scoped lease whose pane set was enumerated at issue.
|
|
80
|
+
*
|
|
81
|
+
* Flow control at the wire is a LEDGER per (client x pane x owner): a stalled
|
|
82
|
+
* client freezes ONLY its own MirrorService subscription for the exhausted
|
|
83
|
+
* pane (siblings and other clients keep flowing; the upstream control-mode
|
|
84
|
+
* pause engages only when every subscriber of a pane is parked, which the
|
|
85
|
+
* session channel already models), tickets force-return on WS close within
|
|
86
|
+
* one tick, and thaw rides the service's atomic reseed.
|
|
87
|
+
*/
|
|
88
|
+
export { PANE_STREAM_REDEEM_PATH, PANE_STREAM_WEBSOCKET_SUBPROTOCOL };
|
|
89
|
+
export const PANE_STREAM_MAX_REDEMPTION_BYTES = 4 * 1024;
|
|
90
|
+
export const PANE_STREAM_MAX_CONTROL_BYTES = 4 * 1024;
|
|
91
|
+
export const PANE_STREAM_MAX_REDEMPTION_MS = 1_000;
|
|
92
|
+
|
|
93
|
+
const WS_OPEN = 1;
|
|
94
|
+
const CANONICAL_KEY_INPUT_FRAME_PREFIX = Buffer.from('{"kind":"key",', "utf8");
|
|
95
|
+
const CANONICAL_TEXT_INPUT_FRAME_PREFIX = Buffer.from('{"kind":"text",', "utf8");
|
|
96
|
+
const SEMANTIC_BACKEND_REFUSALS = new Set([
|
|
97
|
+
"pane_inventory_not_ready",
|
|
98
|
+
"pane_identity_changed_before_select",
|
|
99
|
+
"pane_not_active",
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
function semanticBackendRefusal(error: unknown): string | null {
|
|
103
|
+
let candidate = error;
|
|
104
|
+
for (let depth = 0; depth < 3; depth += 1) {
|
|
105
|
+
if (!candidate || typeof candidate !== "object") return null;
|
|
106
|
+
const context = "context" in candidate ? candidate.context : null;
|
|
107
|
+
const reason =
|
|
108
|
+
context && typeof context === "object" && "reason" in context ? context.reason : null;
|
|
109
|
+
if (typeof reason === "string" && SEMANTIC_BACKEND_REFUSALS.has(reason)) return reason;
|
|
110
|
+
candidate = "cause" in candidate ? candidate.cause : null;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const TYPE_FIRST_INPUT_FRAME_PREFIX = Buffer.from('{"type":"input",', "utf8");
|
|
115
|
+
|
|
116
|
+
function startsWithBuffer(raw: Buffer, prefix: Buffer): boolean {
|
|
117
|
+
return (
|
|
118
|
+
raw.length >= prefix.length && raw.compare(prefix, 0, prefix.length, 0, prefix.length) === 0
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function hasCanonicalInputFramePrefix(raw: Buffer): boolean {
|
|
123
|
+
return (
|
|
124
|
+
startsWithBuffer(raw, CANONICAL_KEY_INPUT_FRAME_PREFIX) ||
|
|
125
|
+
startsWithBuffer(raw, CANONICAL_TEXT_INPUT_FRAME_PREFIX) ||
|
|
126
|
+
startsWithBuffer(raw, TYPE_FIRST_INPUT_FRAME_PREFIX)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const TicketPattern = /^ps1_[A-Za-z0-9_-]{43}$/u;
|
|
130
|
+
const BindingIdSchemaZ = z
|
|
131
|
+
.string()
|
|
132
|
+
.min(1)
|
|
133
|
+
.max(4096)
|
|
134
|
+
.refine((value) => !value.includes("\0"));
|
|
135
|
+
|
|
136
|
+
/** The mirror surface the endpoint consumes (MirrorService satisfies it). */
|
|
137
|
+
export interface PaneStreamMirror {
|
|
138
|
+
describeSession(session: string): Promise<MirrorSessionDescription>;
|
|
139
|
+
describeSessionAuthority?(
|
|
140
|
+
session: string,
|
|
141
|
+
): Promise<{ readonly description: MirrorSessionDescription; readonly runtimeSessionId: string }>;
|
|
142
|
+
subscribe(request: MirrorSubscribeRequest): Promise<MirrorSubscription>;
|
|
143
|
+
subscribeLayout?(
|
|
144
|
+
session: string,
|
|
145
|
+
onLayout: (event: MirrorLayoutEvent) => void,
|
|
146
|
+
authority?: {
|
|
147
|
+
readonly expectedSemanticPaneIds: readonly string[];
|
|
148
|
+
readonly expectedRuntimeSessionId: string;
|
|
149
|
+
readonly onAuthority?: (snapshot: MirrorLayoutAuthoritySnapshot) => void;
|
|
150
|
+
},
|
|
151
|
+
): Promise<MirrorLayoutSubscription>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface PaneStreamLeaseAuthority {
|
|
155
|
+
issue(
|
|
156
|
+
request: PaneStreamLeaseRequest,
|
|
157
|
+
context: { requestId: string; projectIdentity: string; sessionName: string },
|
|
158
|
+
): Promise<IssuedPaneStreamLease>;
|
|
159
|
+
redeem(
|
|
160
|
+
ticket: string,
|
|
161
|
+
binding: PaneStreamLeaseBinding,
|
|
162
|
+
receivedAt?: number,
|
|
163
|
+
): Promise<{ descriptor: PaneStreamLeaseDescriptor }>;
|
|
164
|
+
release(leaseId: string, binding: PaneStreamLeaseBinding): Promise<{ released: boolean }>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type PaneStreamAdmissionErrorCode =
|
|
168
|
+
| "daemon-shutting-down"
|
|
169
|
+
| "invalid-origin"
|
|
170
|
+
| "origin-rejected"
|
|
171
|
+
| "invalid-path"
|
|
172
|
+
| "invalid-subprotocol"
|
|
173
|
+
| "pending-capacity-exhausted"
|
|
174
|
+
| "preauth-capacity-exhausted"
|
|
175
|
+
| "live-capacity-exhausted"
|
|
176
|
+
| "pane-not-found"
|
|
177
|
+
| "redemption-rejected"
|
|
178
|
+
| "stream-unavailable";
|
|
179
|
+
|
|
180
|
+
export class PaneStreamAdmissionError extends Error {
|
|
181
|
+
readonly code: PaneStreamAdmissionErrorCode;
|
|
182
|
+
|
|
183
|
+
constructor(code: PaneStreamAdmissionErrorCode, message: string) {
|
|
184
|
+
super(message);
|
|
185
|
+
this.name = "PaneStreamAdmissionError";
|
|
186
|
+
this.code = code;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface PaneStreamIssueContext {
|
|
191
|
+
readonly requestId: string;
|
|
192
|
+
readonly projectIdentity: string;
|
|
193
|
+
readonly sessionName: string;
|
|
194
|
+
/** Canonical trusted renderer Origin supplied by the host, never the renderer body. */
|
|
195
|
+
readonly rendererOrigin: string;
|
|
196
|
+
/** Stable identity injected by the trusted host boundary, never renderer JSON. */
|
|
197
|
+
readonly hostClientId?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface PaneStreamDescriptor {
|
|
201
|
+
readonly protocolVersion: typeof PANE_STREAM_PROTOCOL_VERSION;
|
|
202
|
+
readonly webSocketUrl: string;
|
|
203
|
+
readonly redemptionTicket: string;
|
|
204
|
+
readonly daemonInstanceId: string;
|
|
205
|
+
readonly requestId: string;
|
|
206
|
+
readonly expiresAt: number;
|
|
207
|
+
readonly panes: readonly string[];
|
|
208
|
+
readonly effectiveViewerMode: PaneStreamViewerMode;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type PaneStreamUpgradeDecision =
|
|
212
|
+
| { readonly accepted: true; readonly admission: PaneStreamPreAuthAdmission }
|
|
213
|
+
| {
|
|
214
|
+
readonly accepted: false;
|
|
215
|
+
readonly code: PaneStreamAdmissionErrorCode;
|
|
216
|
+
readonly httpStatus: 403 | 404 | 426 | 503;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export interface PaneStreamPreAuthAdmission {
|
|
220
|
+
bind(socket: DirectTerminalSocket): void;
|
|
221
|
+
cancelBeforeBind(): void;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface PaneStreamAdmissionSnapshot {
|
|
225
|
+
readonly pendingTickets: number;
|
|
226
|
+
readonly preAuthSockets: number;
|
|
227
|
+
readonly liveConnections: number;
|
|
228
|
+
readonly shuttingDown: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface PaneStreamAdmissionCoordinatorOptions {
|
|
232
|
+
readonly daemonInstanceId: string;
|
|
233
|
+
readonly webSocketUrl: string;
|
|
234
|
+
readonly leaseManager: PaneStreamLeaseAuthority;
|
|
235
|
+
readonly mirror: PaneStreamMirror;
|
|
236
|
+
/** Trusted redemption boundary into the generation's SessionRuntime owner. */
|
|
237
|
+
readonly bindSessionRuntime?: (
|
|
238
|
+
descriptor: PaneStreamLeaseDescriptor,
|
|
239
|
+
) => SessionRuntimePaneStreamTransportBinding;
|
|
240
|
+
readonly maxPendingTickets?: number;
|
|
241
|
+
readonly maxPreAuthSockets?: number;
|
|
242
|
+
readonly maxLiveConnections?: number;
|
|
243
|
+
readonly redemptionTimeoutMs?: number;
|
|
244
|
+
readonly flowBudgets?: PaneStreamFlowBudgets;
|
|
245
|
+
/** Cadence of the send-buffer drain check while frames are in flight. */
|
|
246
|
+
readonly drainTickMs?: number;
|
|
247
|
+
/** Hard whole-socket ceiling; the ledger should stall panes far earlier. */
|
|
248
|
+
readonly maxSocketBufferedBytes?: number;
|
|
249
|
+
/** Input flood budget for one rolling admission window, never a lifetime quota. */
|
|
250
|
+
readonly maxInputFramesPerWindow?: number;
|
|
251
|
+
readonly maxInputBytesPerWindow?: number;
|
|
252
|
+
readonly inputRateWindowMs?: number;
|
|
253
|
+
readonly now?: () => number;
|
|
254
|
+
readonly schedule?: (callback: () => void, delayMs: number) => () => void;
|
|
255
|
+
/** Opt-in daemon-local timing observer; disabled in normal production. */
|
|
256
|
+
readonly observability?: SessionRuntimeObservability;
|
|
257
|
+
/** Test seam consulted only for a negotiated clock-bounds capability. */
|
|
258
|
+
readonly diagnosticSharedNowMicros?: () => number;
|
|
259
|
+
/** Test-only parse-delay seam; consulted only with clock diagnostics. */
|
|
260
|
+
readonly diagnosticAfterFrameParse?: () => void;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface SessionRuntimePaneStreamTransportBinding {
|
|
264
|
+
readonly generation: string;
|
|
265
|
+
readonly session: string;
|
|
266
|
+
readonly clientId: string;
|
|
267
|
+
readonly surface?: string;
|
|
268
|
+
readonly explicitAuthority?: boolean;
|
|
269
|
+
readonly deliveryLaneId?: string;
|
|
270
|
+
readonly deliveryRequestId?: string;
|
|
271
|
+
/** Optional only for the bounded v1 transport adapter. New clients require these methods. */
|
|
272
|
+
authoritySnapshot?(): SessionRuntimeAuthoritySnapshot;
|
|
273
|
+
activateLegacyAuthority?(geometry: boolean): SessionRuntimeAuthoritySnapshot;
|
|
274
|
+
onAuthoritySnapshot?(listener: (snapshot: SessionRuntimeAuthoritySnapshot) => void): () => void;
|
|
275
|
+
updatePresence?(state: SessionRuntimePresenceState): SessionRuntimeAuthoritySnapshot;
|
|
276
|
+
noteActivity?(activity: SessionRuntimeActivityKind): SessionRuntimeAuthoritySnapshot;
|
|
277
|
+
requestAuthority?(authority: SessionRuntimeAuthorityKind): SessionRuntimeAuthorityLease | null;
|
|
278
|
+
releaseAuthority?(authority: SessionRuntimeAuthorityKind): SessionRuntimeAuthoritySnapshot;
|
|
279
|
+
assertController(semanticPaneId?: string): void;
|
|
280
|
+
openTerminalDelivery(
|
|
281
|
+
semanticPaneId: string,
|
|
282
|
+
offer: TerminalDeliveryOffer,
|
|
283
|
+
onMessage: (message: TerminalDeliveryServerMessage) => void | Promise<void>,
|
|
284
|
+
): Promise<SessionRuntimeTerminalDeliveryConnection>;
|
|
285
|
+
submitIntent(
|
|
286
|
+
operationId: string,
|
|
287
|
+
intent: SessionRuntimeSemanticIntent,
|
|
288
|
+
): Promise<WorkspaceMultiplexerMutationResult | void>;
|
|
289
|
+
sendInput(
|
|
290
|
+
semanticPaneId: string,
|
|
291
|
+
input: SessionRuntimeTerminalInput,
|
|
292
|
+
performanceTraceId?: string,
|
|
293
|
+
causalProbe?: CausalCellProbeV1,
|
|
294
|
+
onCausalResult?: (result: CausalCellLedgerResult) => void,
|
|
295
|
+
): void;
|
|
296
|
+
fitViewport(lease: SessionRuntimeAuthorityLease, cols: number, rows: number): void;
|
|
297
|
+
close(): Promise<void>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface SessionRuntimeTerminalDeliveryConnection {
|
|
301
|
+
readonly negotiation: TerminalDeliveryNegotiationResult;
|
|
302
|
+
ack(ack: TerminalDeliveryAck): void;
|
|
303
|
+
nack(nack: TerminalDeliveryNack): void;
|
|
304
|
+
setVisibility(visibility: TerminalDeliveryVisibility): void;
|
|
305
|
+
close(): Promise<void>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
interface PendingTicket {
|
|
309
|
+
readonly leaseId: string;
|
|
310
|
+
readonly requestId: string;
|
|
311
|
+
readonly projectIdentity: string;
|
|
312
|
+
readonly origin: string;
|
|
313
|
+
readonly ticketDigest: Buffer;
|
|
314
|
+
readonly descriptor: PaneStreamLeaseDescriptor;
|
|
315
|
+
cancelExpiry: (() => void) | null;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function defaultSchedule(callback: () => void, delayMs: number): () => void {
|
|
319
|
+
const timer = setTimeout(callback, delayMs);
|
|
320
|
+
timer.unref?.();
|
|
321
|
+
return () => clearTimeout(timer);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function boundedInteger(value: number | undefined, fallback: number, maximum: number): number {
|
|
325
|
+
const selected = value ?? fallback;
|
|
326
|
+
if (!Number.isSafeInteger(selected) || selected <= 0 || selected > maximum) {
|
|
327
|
+
throw new TypeError("Pane-stream admission limit is invalid.");
|
|
328
|
+
}
|
|
329
|
+
return selected;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function sendControl(socket: DirectTerminalSocket, frame: Readonly<Record<string, unknown>>): void {
|
|
333
|
+
if (socket.readyState !== WS_OPEN) return;
|
|
334
|
+
const encoded = JSON.stringify(frame);
|
|
335
|
+
if (Buffer.byteLength(encoded, "utf8") > PANE_STREAM_MAX_CONTROL_BYTES) {
|
|
336
|
+
throw new TypeError("Pane-stream control frame exceeded its bound.");
|
|
337
|
+
}
|
|
338
|
+
socket.send(encoded, { binary: false });
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function errorFrameCode(error: unknown): PaneStreamErrorFrameCode {
|
|
342
|
+
if (error instanceof PaneStreamLeaseError && error.code === "ticket-expired") {
|
|
343
|
+
return "ticket-expired";
|
|
344
|
+
}
|
|
345
|
+
if (error instanceof PaneStreamAdmissionError) {
|
|
346
|
+
switch (error.code) {
|
|
347
|
+
case "live-capacity-exhausted":
|
|
348
|
+
return "live-capacity-exhausted";
|
|
349
|
+
case "pane-not-found":
|
|
350
|
+
case "stream-unavailable":
|
|
351
|
+
return "stream-unavailable";
|
|
352
|
+
default:
|
|
353
|
+
return "redemption-rejected";
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return "stream-unavailable";
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* In-memory admission authority for one daemon instance. It retains only
|
|
361
|
+
* ticket digests; a daemon restart makes every prior descriptor inert.
|
|
362
|
+
*/
|
|
363
|
+
export class PaneStreamAdmissionCoordinator {
|
|
364
|
+
readonly #instanceId: string;
|
|
365
|
+
readonly #webSocketUrl: string;
|
|
366
|
+
readonly #leaseManager: PaneStreamLeaseAuthority;
|
|
367
|
+
readonly #mirror: PaneStreamMirror;
|
|
368
|
+
readonly #bindSessionRuntime:
|
|
369
|
+
| PaneStreamAdmissionCoordinatorOptions["bindSessionRuntime"]
|
|
370
|
+
| undefined;
|
|
371
|
+
readonly #maxPending: number;
|
|
372
|
+
readonly #maxPreAuth: number;
|
|
373
|
+
readonly #maxLive: number;
|
|
374
|
+
readonly #redemptionTimeoutMs: number;
|
|
375
|
+
readonly #flowBudgets: PaneStreamFlowBudgets;
|
|
376
|
+
readonly #drainTickMs: number;
|
|
377
|
+
readonly #maxSocketBufferedBytes: number;
|
|
378
|
+
readonly #maxInputFrames: number;
|
|
379
|
+
readonly #maxInputBytes: number;
|
|
380
|
+
readonly #inputRateWindowMs: number;
|
|
381
|
+
readonly #now: () => number;
|
|
382
|
+
readonly #schedule: (callback: () => void, delayMs: number) => () => void;
|
|
383
|
+
readonly #observability: SessionRuntimeObservability | undefined;
|
|
384
|
+
readonly #diagnosticSharedNowMicros: (() => number) | undefined;
|
|
385
|
+
readonly #diagnosticAfterFrameParse: (() => void) | undefined;
|
|
386
|
+
readonly #ledger: PaneStreamWireLedger;
|
|
387
|
+
readonly #pending = new Map<string, PendingTicket>();
|
|
388
|
+
readonly #preAuth = new Set<PreAuthAdmission>();
|
|
389
|
+
readonly #live = new Set<PaneStreamLiveConnection>();
|
|
390
|
+
readonly #retiringReleases = new Set<Promise<void>>();
|
|
391
|
+
#clientCounter = 0;
|
|
392
|
+
#operationTail: Promise<void> = Promise.resolve();
|
|
393
|
+
#shuttingDown = false;
|
|
394
|
+
#shutdownPromise: Promise<void> | null = null;
|
|
395
|
+
|
|
396
|
+
constructor(options: PaneStreamAdmissionCoordinatorOptions) {
|
|
397
|
+
this.#instanceId = BindingIdSchemaZ.parse(options.daemonInstanceId);
|
|
398
|
+
this.#webSocketUrl = PaneStreamLoopbackWebSocketUrlSchemaZ.parse(options.webSocketUrl);
|
|
399
|
+
this.#leaseManager = options.leaseManager;
|
|
400
|
+
this.#mirror = options.mirror;
|
|
401
|
+
this.#bindSessionRuntime = options.bindSessionRuntime;
|
|
402
|
+
this.#maxPending = boundedInteger(options.maxPendingTickets, 32, 1_024);
|
|
403
|
+
this.#maxPreAuth = boundedInteger(options.maxPreAuthSockets, 16, 1_024);
|
|
404
|
+
this.#maxLive = boundedInteger(options.maxLiveConnections, 16, 1_024);
|
|
405
|
+
this.#redemptionTimeoutMs = boundedInteger(
|
|
406
|
+
options.redemptionTimeoutMs,
|
|
407
|
+
PANE_STREAM_MAX_REDEMPTION_MS,
|
|
408
|
+
PANE_STREAM_MAX_REDEMPTION_MS,
|
|
409
|
+
);
|
|
410
|
+
this.#flowBudgets = options.flowBudgets ?? DEFAULT_PANE_STREAM_FLOW_BUDGETS;
|
|
411
|
+
this.#ledger = new PaneStreamWireLedger(this.#flowBudgets);
|
|
412
|
+
this.#drainTickMs = boundedInteger(options.drainTickMs, 15, 1_000);
|
|
413
|
+
this.#maxSocketBufferedBytes = boundedInteger(
|
|
414
|
+
options.maxSocketBufferedBytes,
|
|
415
|
+
32 << 20,
|
|
416
|
+
256 << 20,
|
|
417
|
+
);
|
|
418
|
+
this.#maxInputFrames = boundedInteger(options.maxInputFramesPerWindow, 16_384, 1 << 20);
|
|
419
|
+
this.#maxInputBytes = boundedInteger(options.maxInputBytesPerWindow, 4 << 20, 64 << 20);
|
|
420
|
+
this.#inputRateWindowMs = boundedInteger(options.inputRateWindowMs, 1_000, 60_000);
|
|
421
|
+
this.#now = options.now ?? Date.now;
|
|
422
|
+
this.#schedule = options.schedule ?? defaultSchedule;
|
|
423
|
+
this.#observability = options.observability;
|
|
424
|
+
this.#diagnosticSharedNowMicros = options.diagnosticSharedNowMicros;
|
|
425
|
+
this.#diagnosticAfterFrameParse = options.diagnosticAfterFrameParse;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
issue(
|
|
429
|
+
request: PaneStreamLeaseRequest,
|
|
430
|
+
context: PaneStreamIssueContext,
|
|
431
|
+
): Promise<PaneStreamDescriptor> {
|
|
432
|
+
const trace = this.#observability?.beginTrace(
|
|
433
|
+
"pane-stream-connect",
|
|
434
|
+
{ generation: this.#instanceId, incarnation: null },
|
|
435
|
+
context.requestId,
|
|
436
|
+
);
|
|
437
|
+
const queuedAtMicros = trace ? this.#observability!.nowMicros() : 0;
|
|
438
|
+
return this.#exclusive(async () => {
|
|
439
|
+
const admittedAtMicros = trace ? this.#observability!.nowMicros() : 0;
|
|
440
|
+
if (trace)
|
|
441
|
+
this.#observability!.recordSpan(
|
|
442
|
+
"transport",
|
|
443
|
+
"pane-stream-issue-queue",
|
|
444
|
+
queuedAtMicros,
|
|
445
|
+
admittedAtMicros,
|
|
446
|
+
trace,
|
|
447
|
+
);
|
|
448
|
+
if (this.#shuttingDown) {
|
|
449
|
+
throw new PaneStreamAdmissionError(
|
|
450
|
+
"daemon-shutting-down",
|
|
451
|
+
"Pane-stream admission is shutting down.",
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
const origin = canonicalOriginOrNull(context.rendererOrigin);
|
|
455
|
+
if (origin === null) {
|
|
456
|
+
throw new PaneStreamAdmissionError("invalid-origin", "Renderer Origin is invalid.");
|
|
457
|
+
}
|
|
458
|
+
const requestId = z.uuid().parse(context.requestId);
|
|
459
|
+
const projectIdentity = BindingIdSchemaZ.parse(context.projectIdentity);
|
|
460
|
+
if (this.#pending.size >= this.#maxPending) {
|
|
461
|
+
throw new PaneStreamAdmissionError(
|
|
462
|
+
"pending-capacity-exhausted",
|
|
463
|
+
"Pane-stream ticket capacity is exhausted.",
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// The pane set is enumerated at issue: every requested pane must exist
|
|
468
|
+
// under verified semantic identity NOW. A describe failure is a probe
|
|
469
|
+
// failure and never reads as absence.
|
|
470
|
+
let described: MirrorSessionDescription;
|
|
471
|
+
let runtimeSessionId: string | null = null;
|
|
472
|
+
try {
|
|
473
|
+
const describeStartedAtMicros = trace ? this.#observability!.nowMicros() : 0;
|
|
474
|
+
if (this.#mirror.describeSessionAuthority) {
|
|
475
|
+
const authority = await this.#mirror.describeSessionAuthority(context.sessionName);
|
|
476
|
+
described = authority.description;
|
|
477
|
+
runtimeSessionId = authority.runtimeSessionId;
|
|
478
|
+
} else {
|
|
479
|
+
described = await this.#mirror.describeSession(context.sessionName);
|
|
480
|
+
}
|
|
481
|
+
if (trace)
|
|
482
|
+
this.#observability!.recordSpan(
|
|
483
|
+
"transport",
|
|
484
|
+
"pane-stream-describe-session",
|
|
485
|
+
describeStartedAtMicros,
|
|
486
|
+
this.#observability!.nowMicros(),
|
|
487
|
+
trace,
|
|
488
|
+
);
|
|
489
|
+
} catch {
|
|
490
|
+
throw new PaneStreamAdmissionError(
|
|
491
|
+
"stream-unavailable",
|
|
492
|
+
"The workspace session could not be described.",
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
const known = new Set(described.panes.map((pane) => pane.semanticPaneId));
|
|
496
|
+
for (const pane of request.panes) {
|
|
497
|
+
if (!known.has(pane)) {
|
|
498
|
+
throw new PaneStreamAdmissionError(
|
|
499
|
+
"pane-not-found",
|
|
500
|
+
`The pane ${pane} is not present in the workspace session.`,
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
const issued = await this.#leaseManager.issue(request, {
|
|
506
|
+
requestId,
|
|
507
|
+
projectIdentity,
|
|
508
|
+
sessionName: context.sessionName,
|
|
509
|
+
...(runtimeSessionId ? { runtimeSessionId } : {}),
|
|
510
|
+
...(context.hostClientId ? { hostClientId: context.hostClientId } : {}),
|
|
511
|
+
});
|
|
512
|
+
const descriptor = issued.descriptor;
|
|
513
|
+
const ticket = issued.redemptionTicket;
|
|
514
|
+
const valid =
|
|
515
|
+
TicketPattern.test(ticket) &&
|
|
516
|
+
z.uuid().safeParse(descriptor.leaseId).success &&
|
|
517
|
+
descriptor.requestId === requestId &&
|
|
518
|
+
(this.#mirror.describeSessionAuthority === undefined ||
|
|
519
|
+
descriptor.runtimeSessionId === runtimeSessionId) &&
|
|
520
|
+
descriptor.status === "awaiting-redemption" &&
|
|
521
|
+
descriptor.viewerMode === request.viewerMode &&
|
|
522
|
+
descriptor.workspaceName === request.workspaceName &&
|
|
523
|
+
descriptor.panes.length === request.panes.length &&
|
|
524
|
+
descriptor.panes.every((pane, index) => pane === request.panes[index]) &&
|
|
525
|
+
descriptor.expiresAt > this.#now();
|
|
526
|
+
const ticketDigest = digestSecret(ticket);
|
|
527
|
+
const duplicate = [...this.#pending.values()].some((pending) =>
|
|
528
|
+
digestsEqual(pending.ticketDigest, ticketDigest),
|
|
529
|
+
);
|
|
530
|
+
if (!valid || duplicate) {
|
|
531
|
+
ticketDigest.fill(0);
|
|
532
|
+
await this.#releaseLease(descriptor.leaseId, {
|
|
533
|
+
daemonInstanceId: this.#instanceId,
|
|
534
|
+
requestId,
|
|
535
|
+
projectIdentity,
|
|
536
|
+
});
|
|
537
|
+
throw new PaneStreamAdmissionError(
|
|
538
|
+
"stream-unavailable",
|
|
539
|
+
"Pane-stream ticket generation failed.",
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
const pending: PendingTicket = {
|
|
543
|
+
leaseId: descriptor.leaseId,
|
|
544
|
+
requestId,
|
|
545
|
+
projectIdentity,
|
|
546
|
+
origin,
|
|
547
|
+
ticketDigest,
|
|
548
|
+
descriptor: structuredClone(descriptor),
|
|
549
|
+
cancelExpiry: null,
|
|
550
|
+
};
|
|
551
|
+
pending.cancelExpiry = this.#schedule(
|
|
552
|
+
() => {
|
|
553
|
+
void this.#exclusive(() => this.#retirePending(pending));
|
|
554
|
+
},
|
|
555
|
+
Math.max(1, descriptor.expiresAt - this.#now()),
|
|
556
|
+
);
|
|
557
|
+
this.#pending.set(pending.leaseId, pending);
|
|
558
|
+
if (trace)
|
|
559
|
+
this.#observability!.recordSpan(
|
|
560
|
+
"transport",
|
|
561
|
+
"pane-stream-issue-total",
|
|
562
|
+
admittedAtMicros,
|
|
563
|
+
this.#observability!.nowMicros(),
|
|
564
|
+
trace,
|
|
565
|
+
);
|
|
566
|
+
return Object.freeze({
|
|
567
|
+
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
568
|
+
webSocketUrl: this.#webSocketUrl,
|
|
569
|
+
redemptionTicket: ticket,
|
|
570
|
+
daemonInstanceId: this.#instanceId,
|
|
571
|
+
requestId,
|
|
572
|
+
expiresAt: descriptor.expiresAt,
|
|
573
|
+
panes: [...descriptor.panes],
|
|
574
|
+
effectiveViewerMode: descriptor.viewerMode,
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
reserveUpgrade(input: {
|
|
580
|
+
readonly path: string;
|
|
581
|
+
readonly protocols: readonly string[];
|
|
582
|
+
readonly origin: string | null | undefined;
|
|
583
|
+
readonly hostClientId?: string | undefined;
|
|
584
|
+
readonly requestId?: string | undefined;
|
|
585
|
+
}): PaneStreamUpgradeDecision {
|
|
586
|
+
if (this.#shuttingDown) {
|
|
587
|
+
return { accepted: false, code: "daemon-shutting-down", httpStatus: 503 };
|
|
588
|
+
}
|
|
589
|
+
if (input.path !== PANE_STREAM_REDEEM_PATH) {
|
|
590
|
+
return { accepted: false, code: "invalid-path", httpStatus: 404 };
|
|
591
|
+
}
|
|
592
|
+
if (input.protocols.length !== 1 || input.protocols[0] !== PANE_STREAM_WEBSOCKET_SUBPROTOCOL) {
|
|
593
|
+
return { accepted: false, code: "invalid-subprotocol", httpStatus: 426 };
|
|
594
|
+
}
|
|
595
|
+
const origin = canonicalOriginOrNull(input.origin ?? "");
|
|
596
|
+
if (origin === null) {
|
|
597
|
+
return { accepted: false, code: "invalid-origin", httpStatus: 403 };
|
|
598
|
+
}
|
|
599
|
+
const hostClientId = input.hostClientId
|
|
600
|
+
? BindingIdSchemaZ.safeParse(input.hostClientId).data
|
|
601
|
+
: undefined;
|
|
602
|
+
if (input.hostClientId && !hostClientId) {
|
|
603
|
+
return { accepted: false, code: "origin-rejected", httpStatus: 403 };
|
|
604
|
+
}
|
|
605
|
+
const requestId = input.requestId ? z.uuid().safeParse(input.requestId).data : undefined;
|
|
606
|
+
if (input.requestId && !requestId) {
|
|
607
|
+
return { accepted: false, code: "origin-rejected", httpStatus: 403 };
|
|
608
|
+
}
|
|
609
|
+
if (
|
|
610
|
+
![...this.#pending.values()].some(
|
|
611
|
+
(pending) =>
|
|
612
|
+
pending.origin === origin &&
|
|
613
|
+
(!requestId || pending.requestId === requestId) &&
|
|
614
|
+
(!hostClientId || pending.descriptor.hostClientId === hostClientId),
|
|
615
|
+
)
|
|
616
|
+
) {
|
|
617
|
+
return { accepted: false, code: "origin-rejected", httpStatus: 403 };
|
|
618
|
+
}
|
|
619
|
+
if (requestId && this.#observability?.enabled) {
|
|
620
|
+
const trace = this.#observability.beginTrace(
|
|
621
|
+
"pane-stream-connect",
|
|
622
|
+
{ generation: this.#instanceId, incarnation: null },
|
|
623
|
+
requestId,
|
|
624
|
+
);
|
|
625
|
+
const atMicros = this.#observability.nowMicros();
|
|
626
|
+
this.#observability.recordSpan(
|
|
627
|
+
"transport",
|
|
628
|
+
"pane-stream-upgrade-arrival",
|
|
629
|
+
atMicros,
|
|
630
|
+
atMicros,
|
|
631
|
+
trace,
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
if (this.#preAuth.size >= this.#maxPreAuth) {
|
|
635
|
+
return { accepted: false, code: "preauth-capacity-exhausted", httpStatus: 503 };
|
|
636
|
+
}
|
|
637
|
+
const admission = new PreAuthAdmission({
|
|
638
|
+
origin,
|
|
639
|
+
hostClientId: hostClientId ?? null,
|
|
640
|
+
timeoutMs: this.#redemptionTimeoutMs,
|
|
641
|
+
schedule: this.#schedule,
|
|
642
|
+
onRelease: (released) => this.#preAuth.delete(released),
|
|
643
|
+
onRedeem: (active, frame, socket) => this.#redeem(active, frame, socket),
|
|
644
|
+
});
|
|
645
|
+
this.#preAuth.add(admission);
|
|
646
|
+
return { accepted: true, admission };
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
snapshot(): PaneStreamAdmissionSnapshot {
|
|
650
|
+
return Object.freeze({
|
|
651
|
+
pendingTickets: this.#pending.size,
|
|
652
|
+
preAuthSockets: this.#preAuth.size,
|
|
653
|
+
liveConnections: this.#live.size,
|
|
654
|
+
shuttingDown: this.#shuttingDown,
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/** Detached (client x pane x owner) outstanding-ticket snapshot. */
|
|
659
|
+
flowSnapshot(): ReturnType<PaneStreamWireLedger["snapshot"]> {
|
|
660
|
+
return this.#ledger.snapshot();
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
shutdown(): Promise<void> {
|
|
664
|
+
if (this.#shutdownPromise) return this.#shutdownPromise;
|
|
665
|
+
this.#shuttingDown = true;
|
|
666
|
+
this.#shutdownPromise = this.#finishShutdown();
|
|
667
|
+
return this.#shutdownPromise;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
async #finishShutdown(): Promise<void> {
|
|
671
|
+
for (const admission of [...this.#preAuth]) admission.close(1001, "daemon-shutdown");
|
|
672
|
+
await this.#exclusive(async () => {
|
|
673
|
+
for (const connection of [...this.#live]) connection.close(1001, "daemon-shutdown");
|
|
674
|
+
for (const pending of [...this.#pending.values()]) await this.#retirePending(pending);
|
|
675
|
+
});
|
|
676
|
+
await Promise.all([...this.#retiringReleases]);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
#redeem(
|
|
680
|
+
admission: PreAuthAdmission,
|
|
681
|
+
frame: PaneStreamRedeemFrame,
|
|
682
|
+
socket: DirectTerminalSocket,
|
|
683
|
+
): Promise<PaneStreamLiveConnection> {
|
|
684
|
+
// Stamp authenticated frame arrival BEFORE queueing: a queue wait must not
|
|
685
|
+
// consume the ticket's delivery TTL (execution has its own budget).
|
|
686
|
+
const receivedAt = this.#now();
|
|
687
|
+
return this.#exclusive(async () => {
|
|
688
|
+
if (this.#shuttingDown || frame.daemonInstanceId !== this.#instanceId) {
|
|
689
|
+
throw new PaneStreamAdmissionError(
|
|
690
|
+
"redemption-rejected",
|
|
691
|
+
"Pane-stream redemption was rejected.",
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
const candidateDigest = digestSecret(frame.ticket);
|
|
695
|
+
let pending: PendingTicket | undefined;
|
|
696
|
+
for (const entry of this.#pending.values()) {
|
|
697
|
+
if (digestsEqual(entry.ticketDigest, candidateDigest)) pending = entry;
|
|
698
|
+
}
|
|
699
|
+
candidateDigest.fill(0);
|
|
700
|
+
if (
|
|
701
|
+
!pending ||
|
|
702
|
+
pending.origin !== admission.origin ||
|
|
703
|
+
(admission.hostClientId !== null &&
|
|
704
|
+
pending.descriptor.hostClientId !== admission.hostClientId) ||
|
|
705
|
+
pending.requestId !== frame.requestId
|
|
706
|
+
) {
|
|
707
|
+
throw new PaneStreamAdmissionError(
|
|
708
|
+
"redemption-rejected",
|
|
709
|
+
"Pane-stream redemption was rejected.",
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
const binding: PaneStreamLeaseBinding = {
|
|
713
|
+
daemonInstanceId: this.#instanceId,
|
|
714
|
+
requestId: pending.requestId,
|
|
715
|
+
projectIdentity: pending.projectIdentity,
|
|
716
|
+
};
|
|
717
|
+
if (!admission.isOpen()) {
|
|
718
|
+
this.#removePending(pending);
|
|
719
|
+
await this.#releaseLease(pending.leaseId, binding);
|
|
720
|
+
throw new PaneStreamAdmissionError(
|
|
721
|
+
"redemption-rejected",
|
|
722
|
+
"Pane-stream redemption was rejected.",
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
this.#removePending(pending);
|
|
726
|
+
if (this.#live.size >= this.#maxLive) {
|
|
727
|
+
await this.#releaseLease(pending.leaseId, binding);
|
|
728
|
+
throw new PaneStreamAdmissionError(
|
|
729
|
+
"live-capacity-exhausted",
|
|
730
|
+
"Pane-stream live capacity is exhausted.",
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
try {
|
|
734
|
+
const redeemed = await this.#leaseManager.redeem(frame.ticket, binding, receivedAt);
|
|
735
|
+
const descriptor = redeemed.descriptor;
|
|
736
|
+
if (descriptor.terminalDelivery && frame.deliveryAcks === true) {
|
|
737
|
+
throw new PaneStreamAdmissionError(
|
|
738
|
+
"stream-unavailable",
|
|
739
|
+
"Semantic terminal delivery owns its ACK lifecycle; legacy renderer ACKs are invalid.",
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
if (
|
|
743
|
+
descriptor.leaseId !== pending.leaseId ||
|
|
744
|
+
descriptor.requestId !== pending.requestId ||
|
|
745
|
+
descriptor.status !== "active" ||
|
|
746
|
+
descriptor.viewerMode !== pending.descriptor.viewerMode ||
|
|
747
|
+
descriptor.panes.length !== pending.descriptor.panes.length
|
|
748
|
+
) {
|
|
749
|
+
throw new PaneStreamAdmissionError(
|
|
750
|
+
"stream-unavailable",
|
|
751
|
+
"Pane-stream lease identity was unavailable.",
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
if (!admission.isOpen()) {
|
|
755
|
+
throw new PaneStreamAdmissionError(
|
|
756
|
+
"redemption-rejected",
|
|
757
|
+
"Pane-stream redemption was rejected.",
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
this.#clientCounter += 1;
|
|
761
|
+
const sessionRuntimeBinding = this.#bindSessionRuntime?.(descriptor) ?? null;
|
|
762
|
+
let live: PaneStreamLiveConnection;
|
|
763
|
+
try {
|
|
764
|
+
live = new PaneStreamLiveConnection({
|
|
765
|
+
clientId: `psc-${this.#clientCounter}`,
|
|
766
|
+
socket,
|
|
767
|
+
descriptor: structuredClone(descriptor),
|
|
768
|
+
sessionRuntimeBinding,
|
|
769
|
+
binding,
|
|
770
|
+
deliveryAcks: frame.deliveryAcks === true,
|
|
771
|
+
diagnosticCapabilities: frame.diagnosticCapabilities ?? [],
|
|
772
|
+
causalCellCapability:
|
|
773
|
+
descriptor.terminalDelivery !== null &&
|
|
774
|
+
descriptor.viewerMode === "interactive" &&
|
|
775
|
+
frame.diagnosticCapabilities?.includes("causal-cell-v1") === true,
|
|
776
|
+
mirror: this.#mirror,
|
|
777
|
+
leaseManager: this.#leaseManager,
|
|
778
|
+
ledger: this.#ledger,
|
|
779
|
+
drainTickMs: this.#drainTickMs,
|
|
780
|
+
maxSocketBufferedBytes: this.#maxSocketBufferedBytes,
|
|
781
|
+
maxInputFrames: this.#maxInputFrames,
|
|
782
|
+
maxInputBytes: this.#maxInputBytes,
|
|
783
|
+
inputRateWindowMs: this.#inputRateWindowMs,
|
|
784
|
+
now: this.#now,
|
|
785
|
+
schedule: this.#schedule,
|
|
786
|
+
observability: this.#observability,
|
|
787
|
+
diagnosticSharedNowMicros: this.#diagnosticSharedNowMicros,
|
|
788
|
+
diagnosticAfterFrameParse: this.#diagnosticAfterFrameParse,
|
|
789
|
+
onRetire: (connection) => this.#trackRetiringRelease(connection),
|
|
790
|
+
});
|
|
791
|
+
} catch (error) {
|
|
792
|
+
await sessionRuntimeBinding?.close();
|
|
793
|
+
throw error;
|
|
794
|
+
}
|
|
795
|
+
this.#live.add(live);
|
|
796
|
+
admission.promote();
|
|
797
|
+
live.start();
|
|
798
|
+
return live;
|
|
799
|
+
} catch (error) {
|
|
800
|
+
await this.#releaseLease(pending.leaseId, binding);
|
|
801
|
+
throw error;
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
#removePending(pending: PendingTicket): void {
|
|
807
|
+
if (this.#pending.get(pending.leaseId) !== pending) return;
|
|
808
|
+
this.#pending.delete(pending.leaseId);
|
|
809
|
+
pending.cancelExpiry?.();
|
|
810
|
+
pending.cancelExpiry = null;
|
|
811
|
+
pending.ticketDigest.fill(0);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
async #retirePending(pending: PendingTicket): Promise<void> {
|
|
815
|
+
if (this.#pending.get(pending.leaseId) !== pending) return;
|
|
816
|
+
const binding: PaneStreamLeaseBinding = {
|
|
817
|
+
daemonInstanceId: this.#instanceId,
|
|
818
|
+
requestId: pending.requestId,
|
|
819
|
+
projectIdentity: pending.projectIdentity,
|
|
820
|
+
};
|
|
821
|
+
this.#removePending(pending);
|
|
822
|
+
await this.#releaseLease(pending.leaseId, binding);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
async #releaseLease(leaseId: string, binding: PaneStreamLeaseBinding): Promise<void> {
|
|
826
|
+
try {
|
|
827
|
+
await this.#leaseManager.release(leaseId, binding);
|
|
828
|
+
} catch {
|
|
829
|
+
// The lease manager may already have retired the one-use lease.
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
#trackRetiringRelease(connection: PaneStreamLiveConnection): void {
|
|
834
|
+
this.#live.delete(connection);
|
|
835
|
+
const release = connection.waitForRelease();
|
|
836
|
+
this.#retiringReleases.add(release);
|
|
837
|
+
void release.then(
|
|
838
|
+
() => this.#retiringReleases.delete(release),
|
|
839
|
+
() => this.#retiringReleases.delete(release),
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
#exclusive<T>(operation: () => Promise<T>): Promise<T> {
|
|
844
|
+
const run = this.#operationTail.then(operation, operation);
|
|
845
|
+
this.#operationTail = run.then(
|
|
846
|
+
() => undefined,
|
|
847
|
+
() => undefined,
|
|
848
|
+
);
|
|
849
|
+
return run;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
interface PreAuthAdmissionOptions {
|
|
854
|
+
readonly origin: string;
|
|
855
|
+
readonly hostClientId: string | null;
|
|
856
|
+
readonly timeoutMs: number;
|
|
857
|
+
readonly schedule: (callback: () => void, delayMs: number) => () => void;
|
|
858
|
+
readonly onRelease: (admission: PreAuthAdmission) => void;
|
|
859
|
+
readonly onRedeem: (
|
|
860
|
+
admission: PreAuthAdmission,
|
|
861
|
+
frame: PaneStreamRedeemFrame,
|
|
862
|
+
socket: DirectTerminalSocket,
|
|
863
|
+
) => Promise<PaneStreamLiveConnection>;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
class PreAuthAdmission implements PaneStreamPreAuthAdmission {
|
|
867
|
+
readonly origin: string;
|
|
868
|
+
readonly hostClientId: string | null;
|
|
869
|
+
readonly #onRelease: PreAuthAdmissionOptions["onRelease"];
|
|
870
|
+
readonly #onRedeem: PreAuthAdmissionOptions["onRedeem"];
|
|
871
|
+
readonly #cancelDeadline: () => void;
|
|
872
|
+
#socket: DirectTerminalSocket | null = null;
|
|
873
|
+
#frameReceived = false;
|
|
874
|
+
#open = true;
|
|
875
|
+
#promoted = false;
|
|
876
|
+
|
|
877
|
+
constructor(options: PreAuthAdmissionOptions) {
|
|
878
|
+
this.origin = options.origin;
|
|
879
|
+
this.hostClientId = options.hostClientId;
|
|
880
|
+
this.#onRelease = options.onRelease;
|
|
881
|
+
this.#onRedeem = options.onRedeem;
|
|
882
|
+
this.#cancelDeadline = options.schedule(
|
|
883
|
+
() => this.close(1008, "redemption-timeout"),
|
|
884
|
+
options.timeoutMs,
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
isOpen(): boolean {
|
|
889
|
+
return this.#open && !this.#promoted;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
bind(socket: DirectTerminalSocket): void {
|
|
893
|
+
if (!this.#open || this.#socket) {
|
|
894
|
+
safeCloseSocket(socket, 1008, "redemption-rejected");
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
this.#socket = socket;
|
|
898
|
+
socket.on("message", this.#onMessage);
|
|
899
|
+
socket.on("close", this.#onClose);
|
|
900
|
+
socket.on("error", this.#onClose);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
cancelBeforeBind(): void {
|
|
904
|
+
this.close(1008, "upgrade-rejected");
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
promote(): void {
|
|
908
|
+
if (!this.#open) return;
|
|
909
|
+
this.#promoted = true;
|
|
910
|
+
this.#open = false;
|
|
911
|
+
this.#cancelDeadline();
|
|
912
|
+
this.#detach();
|
|
913
|
+
this.#onRelease(this);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
close(code = 1008, reason = "redemption-rejected"): void {
|
|
917
|
+
if (!this.#open) return;
|
|
918
|
+
this.#open = false;
|
|
919
|
+
this.#cancelDeadline();
|
|
920
|
+
const socket = this.#socket;
|
|
921
|
+
this.#detach();
|
|
922
|
+
this.#onRelease(this);
|
|
923
|
+
if (socket) safeCloseSocket(socket, code, reason);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
readonly #onMessage = (
|
|
927
|
+
data: string | Buffer | ArrayBuffer | readonly Buffer[],
|
|
928
|
+
isBinary: boolean,
|
|
929
|
+
): void => {
|
|
930
|
+
if (!this.#open || this.#frameReceived) {
|
|
931
|
+
this.close(1008, "redemption-frame-rejected");
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
this.#frameReceived = true;
|
|
935
|
+
const byteLength = rawDataByteLength(data, PANE_STREAM_MAX_REDEMPTION_BYTES);
|
|
936
|
+
if (isBinary || byteLength === 0 || byteLength > PANE_STREAM_MAX_REDEMPTION_BYTES) {
|
|
937
|
+
this.close(1009, "redemption-frame-rejected");
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
let frame: PaneStreamRedeemFrame;
|
|
941
|
+
try {
|
|
942
|
+
frame = PaneStreamRedeemFrameSchemaZ.parse(strictJsonParse(rawDataToBuffer(data)));
|
|
943
|
+
} catch {
|
|
944
|
+
this.close(1008, "redemption-frame-rejected");
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
const socket = this.#socket;
|
|
948
|
+
if (!socket) {
|
|
949
|
+
this.close(1008, "redemption-rejected");
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
this.#cancelDeadline();
|
|
953
|
+
void this.#onRedeem(this, frame, socket).catch((error: unknown) => {
|
|
954
|
+
if (!this.#open) return;
|
|
955
|
+
const code = errorFrameCode(error);
|
|
956
|
+
try {
|
|
957
|
+
sendControl(socket, {
|
|
958
|
+
type: "error",
|
|
959
|
+
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
960
|
+
code,
|
|
961
|
+
retryable: code === "live-capacity-exhausted" || code === "ticket-expired",
|
|
962
|
+
});
|
|
963
|
+
} catch {
|
|
964
|
+
// Closing below is the fail-closed response.
|
|
965
|
+
}
|
|
966
|
+
this.close(code === "live-capacity-exhausted" ? 1013 : 1008, "redemption-rejected");
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
readonly #onClose = (): void => this.close(1008, "redemption-rejected");
|
|
971
|
+
|
|
972
|
+
#detach(): void {
|
|
973
|
+
const socket = this.#socket;
|
|
974
|
+
this.#socket = null;
|
|
975
|
+
if (!socket) return;
|
|
976
|
+
socket.off("message", this.#onMessage);
|
|
977
|
+
socket.off("close", this.#onClose);
|
|
978
|
+
socket.off("error", this.#onClose);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
interface LiveConnectionOptions {
|
|
983
|
+
readonly clientId: string;
|
|
984
|
+
readonly socket: DirectTerminalSocket;
|
|
985
|
+
readonly descriptor: PaneStreamLeaseDescriptor;
|
|
986
|
+
readonly sessionRuntimeBinding: SessionRuntimePaneStreamTransportBinding | null;
|
|
987
|
+
readonly binding: PaneStreamLeaseBinding;
|
|
988
|
+
readonly deliveryAcks: boolean;
|
|
989
|
+
readonly causalCellCapability: boolean;
|
|
990
|
+
readonly diagnosticCapabilities: readonly PaneStreamDiagnosticCapability[];
|
|
991
|
+
readonly mirror: PaneStreamMirror;
|
|
992
|
+
readonly leaseManager: PaneStreamLeaseAuthority;
|
|
993
|
+
readonly ledger: PaneStreamWireLedger;
|
|
994
|
+
readonly drainTickMs: number;
|
|
995
|
+
readonly maxSocketBufferedBytes: number;
|
|
996
|
+
readonly maxInputFrames: number;
|
|
997
|
+
readonly maxInputBytes: number;
|
|
998
|
+
readonly inputRateWindowMs: number;
|
|
999
|
+
readonly now: () => number;
|
|
1000
|
+
readonly schedule: (callback: () => void, delayMs: number) => () => void;
|
|
1001
|
+
readonly observability?: SessionRuntimeObservability;
|
|
1002
|
+
readonly diagnosticSharedNowMicros?: () => number;
|
|
1003
|
+
readonly diagnosticAfterFrameParse?: () => void;
|
|
1004
|
+
readonly onRetire: (connection: PaneStreamLiveConnection) => void;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
interface SeedBatch {
|
|
1008
|
+
reset: { cols: number; rows: number } | null;
|
|
1009
|
+
seed: Uint8Array | null;
|
|
1010
|
+
held: Uint8Array[];
|
|
1011
|
+
guardArmed: boolean;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
interface PaneChannel {
|
|
1015
|
+
readonly semanticPaneId: string;
|
|
1016
|
+
sub: MirrorSubscription | null;
|
|
1017
|
+
delivery: SessionRuntimeTerminalDeliveryConnection | null;
|
|
1018
|
+
deliveryAddress: {
|
|
1019
|
+
workspaceName: string;
|
|
1020
|
+
generation: string;
|
|
1021
|
+
incarnation: string | null;
|
|
1022
|
+
deliveryNonce: string;
|
|
1023
|
+
} | null;
|
|
1024
|
+
serverSeq: number;
|
|
1025
|
+
sentPaneFrames: number;
|
|
1026
|
+
consumedSeq: number;
|
|
1027
|
+
nextInputSeq: number;
|
|
1028
|
+
frozenByWire: boolean;
|
|
1029
|
+
closed: boolean;
|
|
1030
|
+
batch: SeedBatch | null;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
interface QueuedSend {
|
|
1034
|
+
readonly pane: string | null;
|
|
1035
|
+
remaining: number;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
export class PaneStreamLiveConnection {
|
|
1039
|
+
readonly #clientId: string;
|
|
1040
|
+
readonly #socket: DirectTerminalSocket;
|
|
1041
|
+
readonly #descriptor: PaneStreamLeaseDescriptor;
|
|
1042
|
+
readonly #binding: PaneStreamLeaseBinding;
|
|
1043
|
+
readonly #sessionRuntimeBinding: SessionRuntimePaneStreamTransportBinding | null;
|
|
1044
|
+
readonly #deliveryAcks: boolean;
|
|
1045
|
+
readonly #causalCellCapability: boolean;
|
|
1046
|
+
readonly #diagnosticCapabilities: readonly PaneStreamDiagnosticCapability[];
|
|
1047
|
+
readonly #mirror: PaneStreamMirror;
|
|
1048
|
+
readonly #leaseManager: PaneStreamLeaseAuthority;
|
|
1049
|
+
readonly #ledger: PaneStreamWireLedger;
|
|
1050
|
+
readonly #drainTickMs: number;
|
|
1051
|
+
readonly #maxSocketBufferedBytes: number;
|
|
1052
|
+
readonly #maxInputFrames: number;
|
|
1053
|
+
readonly #maxInputBytes: number;
|
|
1054
|
+
readonly #inputRateWindowMs: number;
|
|
1055
|
+
readonly #now: () => number;
|
|
1056
|
+
readonly #schedule: (callback: () => void, delayMs: number) => () => void;
|
|
1057
|
+
readonly #observability: SessionRuntimeObservability | undefined;
|
|
1058
|
+
readonly #diagnosticSharedRawMicros: (() => number) | undefined;
|
|
1059
|
+
readonly #diagnosticAfterFrameParse: (() => void) | undefined;
|
|
1060
|
+
readonly #onRetire: (connection: PaneStreamLiveConnection) => void;
|
|
1061
|
+
readonly #panes = new Map<string, PaneChannel>();
|
|
1062
|
+
readonly #semanticLayouts = new Map<string, MirrorLayoutEvent>();
|
|
1063
|
+
#semanticExpectedPaneIds: readonly string[] | null = null;
|
|
1064
|
+
#semanticRuntimeSessionId: string | null = null;
|
|
1065
|
+
#semanticTopologyEpoch = -1;
|
|
1066
|
+
readonly #sendQueue: QueuedSend[] = [];
|
|
1067
|
+
readonly #semanticDrainWaiters = new Map<string, Array<() => void>>();
|
|
1068
|
+
#layoutSubscription: MirrorLayoutSubscription | null = null;
|
|
1069
|
+
#sentBytesTotal = 0;
|
|
1070
|
+
#drainedBytesTotal = 0;
|
|
1071
|
+
#cancelDrainTick: (() => void) | null = null;
|
|
1072
|
+
#inputWindowStartedAt: number;
|
|
1073
|
+
#inputWindowFrames = 0;
|
|
1074
|
+
#inputWindowBytes = 0;
|
|
1075
|
+
#nextViewportSeq = 1;
|
|
1076
|
+
#nextClockProbe = 1;
|
|
1077
|
+
readonly #requestedAuthorities = new Set<SessionRuntimeAuthorityKind>();
|
|
1078
|
+
#usesExplicitAuthority = false;
|
|
1079
|
+
#legacyInputActivated = false;
|
|
1080
|
+
#legacyGeometryActivated = false;
|
|
1081
|
+
#closed = false;
|
|
1082
|
+
#releasePromise: Promise<unknown> | null = null;
|
|
1083
|
+
#stopAuthoritySnapshots: (() => void) | null = null;
|
|
1084
|
+
#sharedClockOriginMicros: number | null = null;
|
|
1085
|
+
#diagnosticFirstSeedObserved = false;
|
|
1086
|
+
readonly #diagnosticLifecycleStages: Set<string> | null;
|
|
1087
|
+
|
|
1088
|
+
#recordDiagnosticLifecycle(
|
|
1089
|
+
operation:
|
|
1090
|
+
| "pane-stream-server-ready"
|
|
1091
|
+
| "pane-stream-layout-staged"
|
|
1092
|
+
| "pane-stream-layout-validated"
|
|
1093
|
+
| "pane-stream-delivery-open"
|
|
1094
|
+
| "pane-stream-first-seed"
|
|
1095
|
+
| "pane-stream-terminal",
|
|
1096
|
+
closeCode?: number,
|
|
1097
|
+
closeReason?: string,
|
|
1098
|
+
): void {
|
|
1099
|
+
if (!this.#observability?.enabled || !this.#diagnosticLifecycleStages) return;
|
|
1100
|
+
if (this.#diagnosticLifecycleStages.has(operation)) return;
|
|
1101
|
+
this.#diagnosticLifecycleStages.add(operation);
|
|
1102
|
+
const trace = this.#observability.beginTrace(
|
|
1103
|
+
"pane-stream-connect",
|
|
1104
|
+
{ generation: this.#binding.daemonInstanceId, incarnation: null },
|
|
1105
|
+
this.#binding.requestId,
|
|
1106
|
+
);
|
|
1107
|
+
const atMicros = this.#observability.nowMicros();
|
|
1108
|
+
const legalReason = (
|
|
1109
|
+
new Set([
|
|
1110
|
+
"stream-retired",
|
|
1111
|
+
"stream-unavailable",
|
|
1112
|
+
"stream-closed",
|
|
1113
|
+
"topology-changed",
|
|
1114
|
+
"output-backpressure",
|
|
1115
|
+
"panes-closed",
|
|
1116
|
+
"peer-closed",
|
|
1117
|
+
"daemon-shutdown",
|
|
1118
|
+
"redemption-rejected",
|
|
1119
|
+
"unknown",
|
|
1120
|
+
]).has(closeReason ?? "")
|
|
1121
|
+
? closeReason!
|
|
1122
|
+
: closeReason
|
|
1123
|
+
? "unknown"
|
|
1124
|
+
: "none"
|
|
1125
|
+
) as
|
|
1126
|
+
| "none"
|
|
1127
|
+
| "stream-retired"
|
|
1128
|
+
| "stream-unavailable"
|
|
1129
|
+
| "stream-closed"
|
|
1130
|
+
| "topology-changed"
|
|
1131
|
+
| "output-backpressure"
|
|
1132
|
+
| "panes-closed"
|
|
1133
|
+
| "peer-closed"
|
|
1134
|
+
| "daemon-shutdown"
|
|
1135
|
+
| "redemption-rejected"
|
|
1136
|
+
| "unknown";
|
|
1137
|
+
this.#observability.recordSpan(
|
|
1138
|
+
"transport",
|
|
1139
|
+
operation,
|
|
1140
|
+
atMicros,
|
|
1141
|
+
atMicros,
|
|
1142
|
+
trace,
|
|
1143
|
+
undefined,
|
|
1144
|
+
Object.freeze({
|
|
1145
|
+
paneStreamCloseCode:
|
|
1146
|
+
Number.isInteger(closeCode) && closeCode! >= 1000 && closeCode! <= 4999 ? closeCode! : 0,
|
|
1147
|
+
paneStreamCloseReason: legalReason,
|
|
1148
|
+
}),
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
#sharedMicros(): number {
|
|
1153
|
+
const raw = this.#diagnosticSharedRawMicros!();
|
|
1154
|
+
this.#sharedClockOriginMicros ??= raw;
|
|
1155
|
+
const elapsed = raw - this.#sharedClockOriginMicros;
|
|
1156
|
+
if (!Number.isSafeInteger(elapsed) || elapsed < 0)
|
|
1157
|
+
throw new Error("Daemon shared monotonic clock regressed");
|
|
1158
|
+
return elapsed;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
constructor(options: LiveConnectionOptions) {
|
|
1162
|
+
this.#clientId = options.clientId;
|
|
1163
|
+
this.#socket = options.socket;
|
|
1164
|
+
this.#descriptor = options.descriptor;
|
|
1165
|
+
this.#binding = options.binding;
|
|
1166
|
+
this.#sessionRuntimeBinding = options.sessionRuntimeBinding;
|
|
1167
|
+
this.#usesExplicitAuthority = options.sessionRuntimeBinding?.explicitAuthority === true;
|
|
1168
|
+
if (this.#descriptor.viewerMode === "interactive" && !this.#sessionRuntimeBinding) {
|
|
1169
|
+
throw new Error("Interactive pane stream requires SessionRuntime authority");
|
|
1170
|
+
}
|
|
1171
|
+
this.#deliveryAcks = options.deliveryAcks;
|
|
1172
|
+
this.#causalCellCapability = options.causalCellCapability;
|
|
1173
|
+
this.#diagnosticCapabilities = options.diagnosticCapabilities;
|
|
1174
|
+
this.#mirror = options.mirror;
|
|
1175
|
+
this.#leaseManager = options.leaseManager;
|
|
1176
|
+
this.#ledger = options.ledger;
|
|
1177
|
+
this.#drainTickMs = options.drainTickMs;
|
|
1178
|
+
this.#maxSocketBufferedBytes = options.maxSocketBufferedBytes;
|
|
1179
|
+
this.#maxInputFrames = options.maxInputFrames;
|
|
1180
|
+
this.#maxInputBytes = options.maxInputBytes;
|
|
1181
|
+
this.#inputRateWindowMs = options.inputRateWindowMs;
|
|
1182
|
+
this.#now = options.now;
|
|
1183
|
+
this.#inputWindowStartedAt = this.#now();
|
|
1184
|
+
this.#schedule = options.schedule;
|
|
1185
|
+
this.#observability = options.observability;
|
|
1186
|
+
this.#diagnosticLifecycleStages = options.observability?.enabled ? new Set() : null;
|
|
1187
|
+
this.#diagnosticSharedRawMicros = this.#diagnosticCapabilities.includes("clock-bounds-v1")
|
|
1188
|
+
? (options.diagnosticSharedNowMicros ?? sharedMonotonicMicros)
|
|
1189
|
+
: undefined;
|
|
1190
|
+
this.#diagnosticAfterFrameParse = options.diagnosticAfterFrameParse;
|
|
1191
|
+
this.#onRetire = options.onRetire;
|
|
1192
|
+
for (const pane of options.descriptor.panes) {
|
|
1193
|
+
this.#panes.set(pane, {
|
|
1194
|
+
semanticPaneId: pane,
|
|
1195
|
+
sub: null,
|
|
1196
|
+
delivery: null,
|
|
1197
|
+
deliveryAddress: null,
|
|
1198
|
+
serverSeq: 0,
|
|
1199
|
+
sentPaneFrames: 0,
|
|
1200
|
+
consumedSeq: 0,
|
|
1201
|
+
nextInputSeq: 1,
|
|
1202
|
+
frozenByWire: false,
|
|
1203
|
+
closed: false,
|
|
1204
|
+
batch: null,
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
get clientId(): string {
|
|
1210
|
+
return this.#clientId;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
start(): void {
|
|
1214
|
+
if (this.#closed || this.#socket.readyState !== WS_OPEN) {
|
|
1215
|
+
this.close(1008, "stream-retired");
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
this.#socket.on("message", this.#onMessage);
|
|
1219
|
+
this.#socket.on("close", this.#onSocketClose);
|
|
1220
|
+
this.#socket.on("error", this.#onSocketClose);
|
|
1221
|
+
try {
|
|
1222
|
+
sendControl(this.#socket, {
|
|
1223
|
+
type: "ready",
|
|
1224
|
+
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
1225
|
+
daemonInstanceId: this.#binding.daemonInstanceId,
|
|
1226
|
+
requestId: this.#binding.requestId,
|
|
1227
|
+
...(this.#sessionRuntimeBinding
|
|
1228
|
+
? { connectionClientId: this.#sessionRuntimeBinding.clientId }
|
|
1229
|
+
: {}),
|
|
1230
|
+
panes: [...this.#descriptor.panes],
|
|
1231
|
+
effectiveViewerMode: this.#descriptor.viewerMode,
|
|
1232
|
+
...(this.#diagnosticCapabilities.length > 0
|
|
1233
|
+
? { diagnosticCapabilities: [...this.#diagnosticCapabilities] }
|
|
1234
|
+
: {}),
|
|
1235
|
+
});
|
|
1236
|
+
this.#recordDiagnosticLifecycle("pane-stream-server-ready");
|
|
1237
|
+
} catch {
|
|
1238
|
+
this.close(1011, "stream-unavailable-describe");
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
this.#stopAuthoritySnapshots =
|
|
1242
|
+
this.#sessionRuntimeBinding?.onAuthoritySnapshot?.((snapshot) =>
|
|
1243
|
+
this.#usesExplicitAuthority ? this.#sendAuthoritySnapshot(snapshot) : undefined,
|
|
1244
|
+
) ?? null;
|
|
1245
|
+
void this.#subscribeAll();
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
close(code = 1000, reason = "stream-closed"): void {
|
|
1249
|
+
if (this.#closed) return;
|
|
1250
|
+
this.#recordDiagnosticLifecycle("pane-stream-terminal", code, reason);
|
|
1251
|
+
this.#closed = true;
|
|
1252
|
+
this.#cancelDrainTick?.();
|
|
1253
|
+
this.#cancelDrainTick = null;
|
|
1254
|
+
// Departure force-returns every ticket within this same tick.
|
|
1255
|
+
this.#ledger.forceReturnClient(this.#clientId);
|
|
1256
|
+
this.#sendQueue.length = 0;
|
|
1257
|
+
for (const waiters of this.#semanticDrainWaiters.values())
|
|
1258
|
+
for (const resolve of waiters) resolve();
|
|
1259
|
+
this.#semanticDrainWaiters.clear();
|
|
1260
|
+
this.#socket.off("message", this.#onMessage);
|
|
1261
|
+
this.#socket.off("close", this.#onSocketClose);
|
|
1262
|
+
this.#socket.off("error", this.#onSocketClose);
|
|
1263
|
+
this.#stopAuthoritySnapshots?.();
|
|
1264
|
+
this.#stopAuthoritySnapshots = null;
|
|
1265
|
+
const closures: Promise<unknown>[] = [];
|
|
1266
|
+
const layoutSubscription = this.#layoutSubscription;
|
|
1267
|
+
this.#layoutSubscription = null;
|
|
1268
|
+
if (layoutSubscription) closures.push(layoutSubscription.close().catch(() => undefined));
|
|
1269
|
+
for (const channel of this.#panes.values()) {
|
|
1270
|
+
const sub = channel.sub;
|
|
1271
|
+
channel.sub = null;
|
|
1272
|
+
const delivery = channel.delivery;
|
|
1273
|
+
channel.delivery = null;
|
|
1274
|
+
channel.closed = true;
|
|
1275
|
+
if (sub) closures.push(sub.close().catch(() => undefined));
|
|
1276
|
+
if (delivery) closures.push(delivery.close().catch(() => undefined));
|
|
1277
|
+
}
|
|
1278
|
+
this.#releasePromise = Promise.allSettled([
|
|
1279
|
+
...closures,
|
|
1280
|
+
this.#leaseManager.release(this.#descriptor.leaseId, this.#binding).catch(() => undefined),
|
|
1281
|
+
this.#sessionRuntimeBinding?.close() ?? Promise.resolve(),
|
|
1282
|
+
]);
|
|
1283
|
+
this.#onRetire(this);
|
|
1284
|
+
safeCloseSocket(this.#socket, code, reason);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
async waitForRelease(): Promise<void> {
|
|
1288
|
+
await this.#releasePromise;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
/** TESTS ONLY — run one drain evaluation without waiting for the tick. */
|
|
1292
|
+
drainNowForTest(): void {
|
|
1293
|
+
this.#drainNow();
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
async #subscribeAll(): Promise<void> {
|
|
1297
|
+
// Fresh truth once for the whole set: a pane listed at issue but gone by
|
|
1298
|
+
// redeem gets an honest `closed` frame (a successful describe omitting it
|
|
1299
|
+
// is absence; a describe FAILURE is not and fails the connection).
|
|
1300
|
+
let described: MirrorSessionDescription;
|
|
1301
|
+
try {
|
|
1302
|
+
described = await this.#mirror.describeSession(this.#descriptor.sessionName);
|
|
1303
|
+
} catch {
|
|
1304
|
+
this.close(1011, "stream-unavailable");
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
if (this.#closed) return;
|
|
1308
|
+
const known = new Set(described.panes.map((pane) => pane.semanticPaneId));
|
|
1309
|
+
if (this.#descriptor.terminalDelivery) {
|
|
1310
|
+
await this.#subscribeSemantic(known);
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
if (this.#mirror.subscribeLayout) {
|
|
1314
|
+
try {
|
|
1315
|
+
const layoutSubscription = await this.#mirror.subscribeLayout(
|
|
1316
|
+
this.#descriptor.sessionName,
|
|
1317
|
+
(event) => this.#onLayout(event),
|
|
1318
|
+
);
|
|
1319
|
+
if (this.#closed) {
|
|
1320
|
+
await layoutSubscription.close().catch(() => undefined);
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
this.#layoutSubscription = layoutSubscription;
|
|
1324
|
+
} catch {
|
|
1325
|
+
this.close(1011, "stream-unavailable");
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
let layoutAttached = this.#layoutSubscription !== null;
|
|
1330
|
+
for (const channel of this.#panes.values()) {
|
|
1331
|
+
if (this.#closed) return;
|
|
1332
|
+
if (!known.has(channel.semanticPaneId)) {
|
|
1333
|
+
this.#emitClosed(channel);
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
try {
|
|
1337
|
+
const sub = await this.#mirror.subscribe({
|
|
1338
|
+
session: this.#descriptor.sessionName,
|
|
1339
|
+
semanticPaneId: channel.semanticPaneId,
|
|
1340
|
+
onEvent: (event) => this.#onPaneEvent(channel, event),
|
|
1341
|
+
...(layoutAttached ? {} : { onLayout: (event) => this.#onLayout(event) }),
|
|
1342
|
+
});
|
|
1343
|
+
layoutAttached = true;
|
|
1344
|
+
if (this.#closed || channel.closed) {
|
|
1345
|
+
void sub.close().catch(() => undefined);
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1348
|
+
channel.sub = sub;
|
|
1349
|
+
} catch {
|
|
1350
|
+
this.close(1011, "stream-unavailable");
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
this.#closeIfAllPanesGone();
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
async #subscribeSemantic(known: ReadonlySet<string>): Promise<void> {
|
|
1358
|
+
const binding = this.#sessionRuntimeBinding;
|
|
1359
|
+
const offer = this.#descriptor.terminalDelivery;
|
|
1360
|
+
if (!binding || !offer) {
|
|
1361
|
+
this.close(1011, "stream-unavailable");
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
const expectedPaneIds = [...this.#descriptor.panes].sort();
|
|
1365
|
+
if (expectedPaneIds.some((pane) => !known.has(pane))) {
|
|
1366
|
+
this.#failTopologyChanged();
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
const channels = [...this.#panes.values()];
|
|
1370
|
+
if (this.#closed || channels.length === 0) return;
|
|
1371
|
+
let stagedAuthority: MirrorLayoutAuthoritySnapshot | null = null;
|
|
1372
|
+
let authorityMalformed = false;
|
|
1373
|
+
let layoutActivated = false;
|
|
1374
|
+
// Establish the single session layout observer first. MirrorService owns
|
|
1375
|
+
// this lifecycle and may share native control state with delivery setup;
|
|
1376
|
+
// only the independent pane delivery opens below are parallelized.
|
|
1377
|
+
try {
|
|
1378
|
+
if (!this.#mirror.subscribeLayout) throw new Error("authoritative layout is unavailable");
|
|
1379
|
+
const subscription = await this.#mirror.subscribeLayout(
|
|
1380
|
+
this.#descriptor.sessionName,
|
|
1381
|
+
() => undefined,
|
|
1382
|
+
{
|
|
1383
|
+
expectedSemanticPaneIds: expectedPaneIds,
|
|
1384
|
+
expectedRuntimeSessionId: this.#descriptor.runtimeSessionId!,
|
|
1385
|
+
onAuthority: (snapshot) => {
|
|
1386
|
+
this.#recordDiagnosticLifecycle("pane-stream-layout-staged");
|
|
1387
|
+
if (snapshot.layouts.length > PANE_STREAM_MAX_PANES) authorityMalformed = true;
|
|
1388
|
+
else if (!layoutActivated) stagedAuthority = snapshot;
|
|
1389
|
+
else this.#onLayoutAuthority(snapshot);
|
|
1390
|
+
},
|
|
1391
|
+
},
|
|
1392
|
+
);
|
|
1393
|
+
if (this.#closed) {
|
|
1394
|
+
await subscription.close().catch(() => undefined);
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
const authority = stagedAuthority as MirrorLayoutAuthoritySnapshot | null;
|
|
1398
|
+
const stagedInitialFrames =
|
|
1399
|
+
authorityMalformed ||
|
|
1400
|
+
authority === null ||
|
|
1401
|
+
authority.session !== this.#descriptor.sessionName ||
|
|
1402
|
+
this.#descriptor.runtimeSessionId === null ||
|
|
1403
|
+
authority.runtimeSessionId !== this.#descriptor.runtimeSessionId ||
|
|
1404
|
+
authority.topologyEpoch < 0
|
|
1405
|
+
? null
|
|
1406
|
+
: this.#validateInitialLayout(authority.layouts, expectedPaneIds);
|
|
1407
|
+
if (!stagedInitialFrames) {
|
|
1408
|
+
await subscription.close().catch(() => undefined);
|
|
1409
|
+
this.#failTopologyChanged();
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
this.#layoutSubscription = subscription;
|
|
1413
|
+
} catch (cause) {
|
|
1414
|
+
if (cause instanceof Error && cause.name === "MirrorTopologyChangedError") {
|
|
1415
|
+
this.#failTopologyChanged();
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
this.close(1011, "stream-unavailable");
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// Delivery owners are pane-scoped and independent. Open them concurrently,
|
|
1423
|
+
// then publish in descriptor order only after every pane is coherent. This
|
|
1424
|
+
// removes N x attachment latency without allowing a fast pane to make the
|
|
1425
|
+
// session look ready while a sibling is still missing. allSettled is
|
|
1426
|
+
// deliberate: partial success is always closed before the socket retires.
|
|
1427
|
+
const openings = channels.map(async (channel) => {
|
|
1428
|
+
const pending: TerminalDeliveryServerMessage[] = [];
|
|
1429
|
+
let ready = false;
|
|
1430
|
+
const delivery = await binding.openTerminalDelivery(
|
|
1431
|
+
channel.semanticPaneId,
|
|
1432
|
+
offer,
|
|
1433
|
+
(message) => {
|
|
1434
|
+
if (!ready) pending.push(message);
|
|
1435
|
+
else return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
1436
|
+
},
|
|
1437
|
+
);
|
|
1438
|
+
return {
|
|
1439
|
+
channel,
|
|
1440
|
+
delivery,
|
|
1441
|
+
pending,
|
|
1442
|
+
markReady: () => {
|
|
1443
|
+
ready = true;
|
|
1444
|
+
},
|
|
1445
|
+
};
|
|
1446
|
+
});
|
|
1447
|
+
const settled = await Promise.allSettled(openings);
|
|
1448
|
+
const opened = settled.flatMap((result) =>
|
|
1449
|
+
result.status === "fulfilled" ? [result.value] : [],
|
|
1450
|
+
);
|
|
1451
|
+
if (
|
|
1452
|
+
this.#closed ||
|
|
1453
|
+
settled.some(
|
|
1454
|
+
(result) => result.status === "rejected" || !result.value.delivery.negotiation.accepted,
|
|
1455
|
+
)
|
|
1456
|
+
) {
|
|
1457
|
+
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => undefined)));
|
|
1458
|
+
if (!this.#closed) this.close(1011, "stream-unavailable");
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
const deliveryIdentityChanged = opened.some(({ channel, delivery, pending }) => {
|
|
1463
|
+
if (!delivery.negotiation.accepted) return true;
|
|
1464
|
+
const negotiated = delivery.negotiation.negotiated;
|
|
1465
|
+
if (negotiated.generation !== this.#binding.daemonInstanceId) return true;
|
|
1466
|
+
let incarnation: string | null = null;
|
|
1467
|
+
for (const message of pending) {
|
|
1468
|
+
if (message.type !== "terminal.delivery") continue;
|
|
1469
|
+
if (
|
|
1470
|
+
message.workspaceName !== this.#descriptor.sessionName ||
|
|
1471
|
+
message.semanticPaneId !== channel.semanticPaneId ||
|
|
1472
|
+
message.generation !== negotiated.generation ||
|
|
1473
|
+
message.deliveryNonce !== negotiated.deliveryNonce ||
|
|
1474
|
+
(incarnation !== null && message.incarnation !== incarnation)
|
|
1475
|
+
)
|
|
1476
|
+
return true;
|
|
1477
|
+
incarnation = message.incarnation;
|
|
1478
|
+
}
|
|
1479
|
+
return false;
|
|
1480
|
+
});
|
|
1481
|
+
if (deliveryIdentityChanged) {
|
|
1482
|
+
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => undefined)));
|
|
1483
|
+
this.#failTopologyChanged();
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
const authority = stagedAuthority as MirrorLayoutAuthoritySnapshot | null;
|
|
1488
|
+
const initialFrames =
|
|
1489
|
+
authorityMalformed ||
|
|
1490
|
+
authority === null ||
|
|
1491
|
+
authority.session !== this.#descriptor.sessionName ||
|
|
1492
|
+
this.#descriptor.runtimeSessionId === null ||
|
|
1493
|
+
authority.runtimeSessionId !== this.#descriptor.runtimeSessionId ||
|
|
1494
|
+
authority.topologyEpoch < 0
|
|
1495
|
+
? null
|
|
1496
|
+
: this.#validateInitialLayout(authority.layouts, expectedPaneIds);
|
|
1497
|
+
if (!initialFrames) {
|
|
1498
|
+
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => undefined)));
|
|
1499
|
+
this.#failTopologyChanged();
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
this.#recordDiagnosticLifecycle("pane-stream-layout-validated");
|
|
1503
|
+
this.#semanticExpectedPaneIds = expectedPaneIds;
|
|
1504
|
+
this.#semanticRuntimeSessionId = authority!.runtimeSessionId;
|
|
1505
|
+
this.#semanticTopologyEpoch = authority!.topologyEpoch;
|
|
1506
|
+
this.#semanticLayouts.clear();
|
|
1507
|
+
for (const event of authority!.layouts)
|
|
1508
|
+
this.#semanticLayouts.set(event.semanticWindowId as string, event);
|
|
1509
|
+
this.#sendFrame(null, {
|
|
1510
|
+
type: "layout-snapshot",
|
|
1511
|
+
topologyEpoch: authority!.topologyEpoch,
|
|
1512
|
+
layouts: initialFrames,
|
|
1513
|
+
});
|
|
1514
|
+
layoutActivated = true;
|
|
1515
|
+
this.#recordDiagnosticLifecycle("pane-stream-delivery-open");
|
|
1516
|
+
|
|
1517
|
+
for (const { channel, delivery, pending, markReady } of opened) {
|
|
1518
|
+
if (this.#closed || channel.closed) {
|
|
1519
|
+
await delivery.close();
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
// The rejected case was eliminated above; retain this narrowing at the
|
|
1523
|
+
// publication boundary so an invalid negotiation cannot leak a nonce.
|
|
1524
|
+
if (!delivery.negotiation.accepted) continue;
|
|
1525
|
+
channel.delivery = delivery;
|
|
1526
|
+
channel.deliveryAddress = {
|
|
1527
|
+
workspaceName: this.#descriptor.workspaceName,
|
|
1528
|
+
generation: delivery.negotiation.negotiated.generation,
|
|
1529
|
+
incarnation: null,
|
|
1530
|
+
deliveryNonce: delivery.negotiation.negotiated.deliveryNonce,
|
|
1531
|
+
};
|
|
1532
|
+
this.#sendFrame(null, {
|
|
1533
|
+
type: "terminal-delivery-ready",
|
|
1534
|
+
pane: channel.semanticPaneId,
|
|
1535
|
+
negotiation: delivery.negotiation,
|
|
1536
|
+
});
|
|
1537
|
+
markReady();
|
|
1538
|
+
for (const message of pending)
|
|
1539
|
+
await this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
1540
|
+
}
|
|
1541
|
+
this.#closeIfAllPanesGone();
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
async #sendTerminalDelivery(pane: string, message: TerminalDeliveryServerMessage): Promise<void> {
|
|
1545
|
+
if (message.type === "terminal.delivery") {
|
|
1546
|
+
if (!this.#diagnosticFirstSeedObserved) {
|
|
1547
|
+
this.#diagnosticFirstSeedObserved = true;
|
|
1548
|
+
this.#recordDiagnosticLifecycle("pane-stream-first-seed");
|
|
1549
|
+
}
|
|
1550
|
+
const channel = this.#panes.get(pane);
|
|
1551
|
+
if (channel?.deliveryAddress) channel.deliveryAddress.incarnation = message.incarnation;
|
|
1552
|
+
// SessionRuntime keys canonical replicas by the tmux session, while the
|
|
1553
|
+
// public pane-stream lease is keyed by its workspace identity. Translate
|
|
1554
|
+
// at this boundary so the renderer has one coherent address vocabulary.
|
|
1555
|
+
const detailedDeliveryObservation = this.#observability?.enabled === true;
|
|
1556
|
+
const trace =
|
|
1557
|
+
message.performanceTraceId && detailedDeliveryObservation
|
|
1558
|
+
? this.#observability!.beginTrace(
|
|
1559
|
+
"terminal-input-to-paint",
|
|
1560
|
+
{ generation: message.generation, incarnation: message.incarnation },
|
|
1561
|
+
message.performanceTraceId,
|
|
1562
|
+
)
|
|
1563
|
+
: null;
|
|
1564
|
+
let startedAtMicros: number | null = null;
|
|
1565
|
+
if (detailedDeliveryObservation)
|
|
1566
|
+
try {
|
|
1567
|
+
startedAtMicros = this.#observability!.nowMicros();
|
|
1568
|
+
} catch {
|
|
1569
|
+
// Detailed delivery timing cannot alter socket delivery.
|
|
1570
|
+
}
|
|
1571
|
+
let startedAtSharedMicros: number | null = null;
|
|
1572
|
+
if (startedAtMicros !== null && this.#diagnosticSharedRawMicros) {
|
|
1573
|
+
try {
|
|
1574
|
+
startedAtSharedMicros = this.#sharedMicros();
|
|
1575
|
+
} catch {
|
|
1576
|
+
// Shared-clock diagnostics cannot alter terminal delivery.
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
this.#sendFrame(pane, {
|
|
1580
|
+
type: "terminal-delivery-envelope",
|
|
1581
|
+
pane,
|
|
1582
|
+
envelope: { ...message, workspaceName: this.#descriptor.workspaceName },
|
|
1583
|
+
});
|
|
1584
|
+
if (startedAtMicros !== null) {
|
|
1585
|
+
let endedAtMicros: number;
|
|
1586
|
+
try {
|
|
1587
|
+
endedAtMicros = this.#observability!.nowMicros();
|
|
1588
|
+
} catch {
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
let endedAtSharedMicros: number | null = null;
|
|
1592
|
+
if (startedAtSharedMicros !== null) {
|
|
1593
|
+
try {
|
|
1594
|
+
endedAtSharedMicros = this.#sharedMicros();
|
|
1595
|
+
} catch {
|
|
1596
|
+
// Preserve the process-local span when shared sampling fails.
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
try {
|
|
1600
|
+
this.#observability!.recordSpan(
|
|
1601
|
+
"transport",
|
|
1602
|
+
"pane-stream-socket-send",
|
|
1603
|
+
startedAtMicros,
|
|
1604
|
+
endedAtMicros,
|
|
1605
|
+
trace,
|
|
1606
|
+
startedAtSharedMicros === null || endedAtSharedMicros === null
|
|
1607
|
+
? undefined
|
|
1608
|
+
: {
|
|
1609
|
+
startedAtMicros: startedAtSharedMicros,
|
|
1610
|
+
endedAtMicros: endedAtSharedMicros,
|
|
1611
|
+
},
|
|
1612
|
+
Object.freeze({
|
|
1613
|
+
workspaceName: message.workspaceName,
|
|
1614
|
+
semanticPaneId: message.semanticPaneId,
|
|
1615
|
+
canonicalGeneration: message.generation,
|
|
1616
|
+
canonicalIncarnation: message.incarnation,
|
|
1617
|
+
canonicalRevision: message.canonicalRevision,
|
|
1618
|
+
canonicalStateHash: message.canonicalStateHash,
|
|
1619
|
+
transactionId: message.transactionId,
|
|
1620
|
+
...(terminalDeliveryObservationOrdinal(message) === null
|
|
1621
|
+
? {}
|
|
1622
|
+
: { deliveryOrdinal: terminalDeliveryObservationOrdinal(message)! }),
|
|
1623
|
+
deliveryClientId: this.#sessionRuntimeBinding?.clientId ?? this.#clientId,
|
|
1624
|
+
deliverySurface: this.#sessionRuntimeBinding?.surface ?? "unknown",
|
|
1625
|
+
deliveryLaneId: this.#sessionRuntimeBinding?.deliveryLaneId ?? this.#clientId,
|
|
1626
|
+
deliveryRequestId: this.#sessionRuntimeBinding?.deliveryRequestId ?? this.#clientId,
|
|
1627
|
+
deliveryNonce: message.deliveryNonce,
|
|
1628
|
+
}),
|
|
1629
|
+
);
|
|
1630
|
+
} catch {
|
|
1631
|
+
// Diagnostics cannot alter terminal delivery.
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
} else if (message.type === "terminal.delivery.chunk") {
|
|
1635
|
+
this.#sendFrame(pane, {
|
|
1636
|
+
type: "terminal-delivery-chunk",
|
|
1637
|
+
pane,
|
|
1638
|
+
transactionId: message.transactionId,
|
|
1639
|
+
index: message.index,
|
|
1640
|
+
data: Buffer.from(message.bytes).toString("base64"),
|
|
1641
|
+
});
|
|
1642
|
+
} else {
|
|
1643
|
+
this.#sendFrame(pane, { type: "terminal-delivery-fault", pane, fault: message });
|
|
1644
|
+
// Lifecycle/control truth must never queue behind bulk terminal bytes.
|
|
1645
|
+
// The hard socket-wide ceiling still closes a genuinely wedged client in
|
|
1646
|
+
// #drainNow; a source-close frame itself is small and immediately useful.
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
await this.#awaitSemanticCredit(pane);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
#awaitSemanticCredit(pane: string): Promise<void> {
|
|
1653
|
+
// Backpressure is pane-local. Aggregate pressure is guarded by the hard
|
|
1654
|
+
// socket ceiling in #drainNow, but must not let a noisy sibling prevent a
|
|
1655
|
+
// pane-close (or any other pane's next semantic delivery) from surfacing.
|
|
1656
|
+
if (!this.#ledger.isStalled(this.#clientId, pane)) return Promise.resolve();
|
|
1657
|
+
return new Promise((resolve) => {
|
|
1658
|
+
const waiters = this.#semanticDrainWaiters.get(pane) ?? [];
|
|
1659
|
+
waiters.push(resolve);
|
|
1660
|
+
this.#semanticDrainWaiters.set(pane, waiters);
|
|
1661
|
+
this.#ensureDrainTick();
|
|
1662
|
+
});
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// ── Mirror events → frames ────────────────────────────────────────────────
|
|
1666
|
+
|
|
1667
|
+
#onPaneEvent(channel: PaneChannel, event: MirrorPaneEvent): void {
|
|
1668
|
+
if (this.#closed || channel.closed) return;
|
|
1669
|
+
switch (event.type) {
|
|
1670
|
+
case "reset": {
|
|
1671
|
+
channel.batch = {
|
|
1672
|
+
reset: { cols: event.cols, rows: event.rows },
|
|
1673
|
+
seed: null,
|
|
1674
|
+
held: [],
|
|
1675
|
+
guardArmed: false,
|
|
1676
|
+
};
|
|
1677
|
+
this.#armBatchGuard(channel);
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
case "seed": {
|
|
1681
|
+
if (channel.batch) channel.batch.seed = event.data;
|
|
1682
|
+
else {
|
|
1683
|
+
channel.batch = { reset: null, seed: event.data, held: [], guardArmed: false };
|
|
1684
|
+
this.#armBatchGuard(channel);
|
|
1685
|
+
}
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
case "delta": {
|
|
1689
|
+
const batch = channel.batch;
|
|
1690
|
+
if (batch && batch.seed !== null) {
|
|
1691
|
+
batch.held.push(event.data);
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
if (batch) {
|
|
1695
|
+
// A delta cannot precede the capture of an armed reseed (the feed
|
|
1696
|
+
// discards those); treat an impossible ordering as live output.
|
|
1697
|
+
this.#flushBatch(channel, null);
|
|
1698
|
+
}
|
|
1699
|
+
this.#emitOutput(channel, event.data);
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
case "cursor": {
|
|
1703
|
+
if (channel.batch) {
|
|
1704
|
+
this.#flushBatch(channel, { x: event.x, y: event.y });
|
|
1705
|
+
return;
|
|
1706
|
+
}
|
|
1707
|
+
this.#sendPaneFrame(channel, {
|
|
1708
|
+
type: "cursor",
|
|
1709
|
+
pane: channel.semanticPaneId,
|
|
1710
|
+
seq: this.#nextSeq(channel),
|
|
1711
|
+
x: event.x,
|
|
1712
|
+
y: event.y,
|
|
1713
|
+
});
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
case "flow": {
|
|
1717
|
+
if (channel.batch) this.#flushBatch(channel, null);
|
|
1718
|
+
this.#sendPaneFrame(channel, {
|
|
1719
|
+
type: "flow",
|
|
1720
|
+
pane: channel.semanticPaneId,
|
|
1721
|
+
seq: this.#nextSeq(channel),
|
|
1722
|
+
state: event.state,
|
|
1723
|
+
reason: event.reason,
|
|
1724
|
+
});
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
case "closed": {
|
|
1728
|
+
if (channel.batch) this.#flushBatch(channel, null);
|
|
1729
|
+
this.#emitClosed(channel);
|
|
1730
|
+
this.#closeIfAllPanesGone();
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/** The atomic batch arrives in ONE synchronous callback burst; a microtask
|
|
1737
|
+
* guard flushes the degraded no-cursor path without reordering anything. */
|
|
1738
|
+
#armBatchGuard(channel: PaneChannel): void {
|
|
1739
|
+
const batch = channel.batch;
|
|
1740
|
+
if (!batch || batch.guardArmed) return;
|
|
1741
|
+
batch.guardArmed = true;
|
|
1742
|
+
queueMicrotask(() => {
|
|
1743
|
+
if (channel.batch === batch) this.#flushBatch(channel, null);
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
#flushBatch(channel: PaneChannel, cursor: { x: number; y: number } | null): void {
|
|
1748
|
+
const batch = channel.batch;
|
|
1749
|
+
channel.batch = null;
|
|
1750
|
+
if (!batch || this.#closed || channel.closed) return;
|
|
1751
|
+
let seed = batch.seed ?? new Uint8Array(0);
|
|
1752
|
+
if (seed.byteLength > PANE_STREAM_MAX_SEED_BYTES) {
|
|
1753
|
+
// Pathological guard: keep the tail, resynchronizing at a line seam.
|
|
1754
|
+
let start = seed.byteLength - PANE_STREAM_MAX_SEED_BYTES;
|
|
1755
|
+
while (start < seed.byteLength && seed[start] !== 0x0a) start += 1;
|
|
1756
|
+
seed = seed.subarray(Math.min(start + 1, seed.byteLength));
|
|
1757
|
+
}
|
|
1758
|
+
const held = chunkBytes(concatBytes(batch.held), PANE_STREAM_MAX_OUTPUT_BYTES).slice(
|
|
1759
|
+
0,
|
|
1760
|
+
PANE_STREAM_MAX_HELD_DELTAS,
|
|
1761
|
+
);
|
|
1762
|
+
this.#sendPaneFrame(channel, {
|
|
1763
|
+
type: "seed-batch",
|
|
1764
|
+
pane: channel.semanticPaneId,
|
|
1765
|
+
seq: this.#nextSeq(channel),
|
|
1766
|
+
reset: batch.reset,
|
|
1767
|
+
seed: Buffer.from(seed).toString("base64"),
|
|
1768
|
+
held: held.map((chunk) => Buffer.from(chunk).toString("base64")),
|
|
1769
|
+
cursor,
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
#emitOutput(channel: PaneChannel, data: Uint8Array): void {
|
|
1774
|
+
for (const chunk of chunkBytes(data, PANE_STREAM_MAX_OUTPUT_BYTES)) {
|
|
1775
|
+
this.#sendPaneFrame(channel, {
|
|
1776
|
+
type: "output",
|
|
1777
|
+
pane: channel.semanticPaneId,
|
|
1778
|
+
seq: this.#nextSeq(channel),
|
|
1779
|
+
data: Buffer.from(chunk).toString("base64"),
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
#emitClosed(channel: PaneChannel): void {
|
|
1785
|
+
if (channel.closed) return;
|
|
1786
|
+
channel.closed = true;
|
|
1787
|
+
const sub = channel.sub;
|
|
1788
|
+
channel.sub = null;
|
|
1789
|
+
if (sub) void sub.close().catch(() => undefined);
|
|
1790
|
+
this.#sendPaneFrame(channel, {
|
|
1791
|
+
type: "closed",
|
|
1792
|
+
pane: channel.semanticPaneId,
|
|
1793
|
+
seq: this.#nextSeq(channel),
|
|
1794
|
+
});
|
|
1795
|
+
this.#ledger.forgetPane(this.#clientId, channel.semanticPaneId);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
#onLayoutAuthority(snapshot: MirrorLayoutAuthoritySnapshot): void {
|
|
1799
|
+
if (this.#closed || !this.#semanticExpectedPaneIds || !this.#semanticRuntimeSessionId) return;
|
|
1800
|
+
if (
|
|
1801
|
+
snapshot.session !== this.#descriptor.sessionName ||
|
|
1802
|
+
snapshot.runtimeSessionId !== this.#semanticRuntimeSessionId ||
|
|
1803
|
+
snapshot.topologyEpoch <= this.#semanticTopologyEpoch ||
|
|
1804
|
+
snapshot.layouts.length > PANE_STREAM_MAX_PANES
|
|
1805
|
+
) {
|
|
1806
|
+
this.#failTopologyChanged();
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
const frames = this.#validateInitialLayout(snapshot.layouts, this.#semanticExpectedPaneIds);
|
|
1810
|
+
if (!frames) {
|
|
1811
|
+
this.#failTopologyChanged();
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
this.#semanticTopologyEpoch = snapshot.topologyEpoch;
|
|
1815
|
+
this.#semanticLayouts.clear();
|
|
1816
|
+
for (const event of snapshot.layouts)
|
|
1817
|
+
this.#semanticLayouts.set(event.semanticWindowId as string, event);
|
|
1818
|
+
this.#sendFrame(null, {
|
|
1819
|
+
type: "layout-snapshot",
|
|
1820
|
+
topologyEpoch: snapshot.topologyEpoch,
|
|
1821
|
+
layouts: frames,
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
#onLayout(event: MirrorLayoutEvent): void {
|
|
1826
|
+
if (this.#closed) return;
|
|
1827
|
+
/*
|
|
1828
|
+
* Every window of the session, not only the leased panes' own.
|
|
1829
|
+
*
|
|
1830
|
+
* The lease is SESSION-scoped by design — one socket for one workspace —
|
|
1831
|
+
* and layout is that session's geometry rather than a per-pane stream. A
|
|
1832
|
+
* client that saw only its leased window could not render a window LIST at
|
|
1833
|
+
* all, which is what the layout-faithful view is built from (m50), and it
|
|
1834
|
+
* would have to lease every pane in the session to get one.
|
|
1835
|
+
*
|
|
1836
|
+
* Nothing new crosses the boundary: the frame carries semantic pane ids and
|
|
1837
|
+
* cell rectangles, and the same renderer is already told every pane's
|
|
1838
|
+
* semantic identity by the application-shell inventory. No runtime tmux id,
|
|
1839
|
+
* command, cwd or credential appears here.
|
|
1840
|
+
*/
|
|
1841
|
+
const frame = this.#layoutFrame(event);
|
|
1842
|
+
if (!frame) {
|
|
1843
|
+
this.#failTopologyChanged();
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
this.#sendFrame(null, frame);
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
#layoutFrame(event: MirrorLayoutEvent): PaneStreamServerFrame | null {
|
|
1850
|
+
const frame = {
|
|
1851
|
+
type: "layout",
|
|
1852
|
+
semanticWindowId: event.semanticWindowId,
|
|
1853
|
+
windowName: event.windowName === null ? null : event.windowName.slice(0, 256),
|
|
1854
|
+
currentWindow: event.currentWindow,
|
|
1855
|
+
cols: event.cols,
|
|
1856
|
+
rows: event.rows,
|
|
1857
|
+
zoomed: event.zoomed,
|
|
1858
|
+
paneBorderStatus: event.paneBorderStatus,
|
|
1859
|
+
panes: event.panes.map((pane) => ({
|
|
1860
|
+
pane: pane.semanticPaneId,
|
|
1861
|
+
displayName: pane.displayName,
|
|
1862
|
+
displayNameSource: pane.displayNameSource,
|
|
1863
|
+
left: pane.left,
|
|
1864
|
+
top: pane.top,
|
|
1865
|
+
width: pane.width,
|
|
1866
|
+
height: pane.height,
|
|
1867
|
+
active: pane.active,
|
|
1868
|
+
})),
|
|
1869
|
+
};
|
|
1870
|
+
// Layout carries user-authored names and unbounded tmux geometry; gate it
|
|
1871
|
+
// through the schema and skip rather than ever sending an invalid frame.
|
|
1872
|
+
const parsed = PaneStreamServerFrameSchemaZ.safeParse(frame);
|
|
1873
|
+
return parsed.success ? parsed.data : null;
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
#validateInitialLayout(
|
|
1877
|
+
events: readonly MirrorLayoutEvent[],
|
|
1878
|
+
expectedPaneIds: readonly string[],
|
|
1879
|
+
): PaneStreamServerFrame[] | null {
|
|
1880
|
+
if (events.length === 0) return null;
|
|
1881
|
+
const windows = new Set<string>();
|
|
1882
|
+
const panes: string[] = [];
|
|
1883
|
+
const frames: PaneStreamServerFrame[] = [];
|
|
1884
|
+
let currentWindows = 0;
|
|
1885
|
+
for (const event of events) {
|
|
1886
|
+
if (
|
|
1887
|
+
event.session !== this.#descriptor.sessionName ||
|
|
1888
|
+
typeof event.semanticWindowId !== "string" ||
|
|
1889
|
+
windows.has(event.semanticWindowId)
|
|
1890
|
+
)
|
|
1891
|
+
return null;
|
|
1892
|
+
windows.add(event.semanticWindowId);
|
|
1893
|
+
if (event.currentWindow) currentWindows += 1;
|
|
1894
|
+
const frame = this.#layoutFrame(event);
|
|
1895
|
+
if (!frame || frame.type !== "layout") return null;
|
|
1896
|
+
frames.push(frame);
|
|
1897
|
+
for (const pane of event.panes) {
|
|
1898
|
+
if (typeof pane.semanticPaneId !== "string") return null;
|
|
1899
|
+
panes.push(pane.semanticPaneId);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
panes.sort();
|
|
1903
|
+
if (
|
|
1904
|
+
currentWindows !== 1 ||
|
|
1905
|
+
new Set(panes).size !== panes.length ||
|
|
1906
|
+
panes.length !== expectedPaneIds.length ||
|
|
1907
|
+
panes.some((pane, index) => pane !== expectedPaneIds[index])
|
|
1908
|
+
)
|
|
1909
|
+
return null;
|
|
1910
|
+
return frames;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
#failTopologyChanged(): void {
|
|
1914
|
+
if (this.#closed) return;
|
|
1915
|
+
this.#sendFrame(null, {
|
|
1916
|
+
type: "error",
|
|
1917
|
+
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
1918
|
+
code: "topology-changed",
|
|
1919
|
+
retryable: true,
|
|
1920
|
+
});
|
|
1921
|
+
this.close(1012, "topology-changed");
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
// ── Send path + flow ledger ───────────────────────────────────────────────
|
|
1925
|
+
|
|
1926
|
+
#nextSeq(channel: PaneChannel): number {
|
|
1927
|
+
channel.serverSeq += 1;
|
|
1928
|
+
return channel.serverSeq;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
#sendPaneFrame(channel: PaneChannel, frame: Record<string, unknown>): void {
|
|
1932
|
+
channel.sentPaneFrames += 1;
|
|
1933
|
+
this.#sendFrame(channel.semanticPaneId, frame);
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
#sendFrame(pane: string | null, frame: Record<string, unknown>): void {
|
|
1937
|
+
if (this.#closed || this.#socket.readyState !== WS_OPEN) return;
|
|
1938
|
+
const encoded = JSON.stringify(frame);
|
|
1939
|
+
const bytes = Buffer.byteLength(encoded, "utf8");
|
|
1940
|
+
if (pane !== null) {
|
|
1941
|
+
this.#ledger.take(this.#clientId, pane, "ws-send-buffer", bytes);
|
|
1942
|
+
if (this.#deliveryAcks) this.#ledger.take(this.#clientId, pane, "renderer-backlog", 1);
|
|
1943
|
+
}
|
|
1944
|
+
this.#sendQueue.push({ pane, remaining: bytes });
|
|
1945
|
+
this.#sentBytesTotal += bytes;
|
|
1946
|
+
try {
|
|
1947
|
+
this.#socket.send(encoded, { binary: false });
|
|
1948
|
+
} catch {
|
|
1949
|
+
this.close(1011, "stream-unavailable");
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
// Stall is judged on the drain tick, never synchronously at send: the
|
|
1953
|
+
// socket must get its chance to drain first, or a single seed batch
|
|
1954
|
+
// larger than the budget would park even a healthy client.
|
|
1955
|
+
this.#ensureDrainTick();
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
#evaluateStall(pane: string): void {
|
|
1959
|
+
const channel = this.#panes.get(pane);
|
|
1960
|
+
if (!channel || channel.closed || channel.frozenByWire || !channel.sub) return;
|
|
1961
|
+
if (this.#ledger.isStalled(this.#clientId, pane)) {
|
|
1962
|
+
// Park exactly this subscriber: siblings and other clients keep flowing;
|
|
1963
|
+
// upstream %pause only engages when every subscriber of the pane parks.
|
|
1964
|
+
channel.frozenByWire = true;
|
|
1965
|
+
channel.sub.freeze();
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
#evaluateResume(pane: string): void {
|
|
1970
|
+
const channel = this.#panes.get(pane);
|
|
1971
|
+
if (!channel || channel.closed || !channel.frozenByWire || !channel.sub) return;
|
|
1972
|
+
if (this.#ledger.shouldResume(this.#clientId, pane)) {
|
|
1973
|
+
channel.frozenByWire = false;
|
|
1974
|
+
channel.sub.thaw();
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
#ensureDrainTick(): void {
|
|
1979
|
+
if (this.#cancelDrainTick || this.#closed || this.#sendQueue.length === 0) return;
|
|
1980
|
+
this.#cancelDrainTick = this.#schedule(() => {
|
|
1981
|
+
this.#cancelDrainTick = null;
|
|
1982
|
+
this.#drainNow();
|
|
1983
|
+
this.#ensureDrainTick();
|
|
1984
|
+
}, this.#drainTickMs);
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
#drainNow(): void {
|
|
1988
|
+
if (this.#closed) return;
|
|
1989
|
+
const buffered = this.#socket.bufferedAmount ?? 0;
|
|
1990
|
+
if (!Number.isSafeInteger(buffered) || buffered < 0) {
|
|
1991
|
+
this.close(1011, "stream-unavailable");
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
if (buffered > this.#maxSocketBufferedBytes) {
|
|
1995
|
+
this.close(1013, "output-backpressure");
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
let newlyDrained = this.#sentBytesTotal - buffered - this.#drainedBytesTotal;
|
|
1999
|
+
while (newlyDrained > 0 && this.#sendQueue.length > 0) {
|
|
2000
|
+
const head = this.#sendQueue[0]!;
|
|
2001
|
+
const applied = Math.min(newlyDrained, head.remaining);
|
|
2002
|
+
head.remaining -= applied;
|
|
2003
|
+
newlyDrained -= applied;
|
|
2004
|
+
this.#drainedBytesTotal += applied;
|
|
2005
|
+
if (head.pane !== null) {
|
|
2006
|
+
this.#ledger.give(this.#clientId, head.pane, "ws-send-buffer", applied);
|
|
2007
|
+
}
|
|
2008
|
+
if (head.remaining === 0) this.#sendQueue.shift();
|
|
2009
|
+
}
|
|
2010
|
+
for (const [pane, channel] of this.#panes) {
|
|
2011
|
+
if (channel.frozenByWire) this.#evaluateResume(pane);
|
|
2012
|
+
else this.#evaluateStall(pane);
|
|
2013
|
+
const waiters = this.#semanticDrainWaiters.get(pane);
|
|
2014
|
+
if (waiters && this.#ledger.shouldResume(this.#clientId, pane)) {
|
|
2015
|
+
this.#semanticDrainWaiters.delete(pane);
|
|
2016
|
+
for (const resolve of waiters) resolve();
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
// ── Client frames ─────────────────────────────────────────────────────────
|
|
2022
|
+
|
|
2023
|
+
readonly #onMessage = (
|
|
2024
|
+
data: string | Buffer | ArrayBuffer | readonly Buffer[],
|
|
2025
|
+
isBinary: boolean,
|
|
2026
|
+
): void => {
|
|
2027
|
+
if (this.#closed) return;
|
|
2028
|
+
let callbackAtSharedMicros: number | null = null;
|
|
2029
|
+
let ingressAtSharedMicros: number | null = null;
|
|
2030
|
+
let ingressAtMicros: number | null = null;
|
|
2031
|
+
if (this.#observability?.enabled) {
|
|
2032
|
+
try {
|
|
2033
|
+
ingressAtMicros = this.#observability.nowMicros();
|
|
2034
|
+
} catch {
|
|
2035
|
+
// Diagnostics cannot alter protocol truth.
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
const byteLength = rawDataByteLength(data, PANE_STREAM_MAX_CONTROL_BYTES);
|
|
2039
|
+
if (isBinary || byteLength === 0 || byteLength > PANE_STREAM_MAX_CONTROL_BYTES) {
|
|
2040
|
+
this.#failProtocol("protocol-error");
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
const raw = rawDataToBuffer(data);
|
|
2044
|
+
if (this.#diagnosticSharedRawMicros && hasCanonicalInputFramePrefix(raw)) {
|
|
2045
|
+
try {
|
|
2046
|
+
callbackAtSharedMicros = this.#sharedMicros();
|
|
2047
|
+
} catch {
|
|
2048
|
+
// Preserve the process-local callback timestamp and product traffic.
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
let frame: z.infer<typeof PaneStreamClientFrameSchemaZ>;
|
|
2052
|
+
try {
|
|
2053
|
+
frame = PaneStreamClientFrameSchemaZ.parse(strictJsonParse(raw));
|
|
2054
|
+
} catch {
|
|
2055
|
+
this.#failProtocol("protocol-error");
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
if (this.#diagnosticSharedRawMicros) {
|
|
2059
|
+
try {
|
|
2060
|
+
this.#diagnosticAfterFrameParse?.();
|
|
2061
|
+
} catch {
|
|
2062
|
+
// Test-only diagnostics cannot alter protocol truth.
|
|
2063
|
+
}
|
|
2064
|
+
if (frame.type === "input") {
|
|
2065
|
+
try {
|
|
2066
|
+
ingressAtSharedMicros = this.#sharedMicros();
|
|
2067
|
+
} catch {
|
|
2068
|
+
// Preserve callback timing and product traffic without a parse-complete sample.
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
if (frame.type === "clock-probe") {
|
|
2073
|
+
if (
|
|
2074
|
+
!this.#diagnosticCapabilities.includes("clock-bounds-v1") ||
|
|
2075
|
+
frame.requestId !== this.#binding.requestId ||
|
|
2076
|
+
frame.probe !== this.#nextClockProbe
|
|
2077
|
+
)
|
|
2078
|
+
return this.#failProtocol("protocol-error");
|
|
2079
|
+
this.#nextClockProbe += 1;
|
|
2080
|
+
try {
|
|
2081
|
+
ingressAtSharedMicros = this.#sharedMicros();
|
|
2082
|
+
} catch {
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
try {
|
|
2086
|
+
const daemonSendMicros = this.#sharedMicros();
|
|
2087
|
+
this.#sendFrame(null, {
|
|
2088
|
+
type: "clock-probe-ack",
|
|
2089
|
+
requestId: this.#binding.requestId,
|
|
2090
|
+
daemonInstanceId: this.#binding.daemonInstanceId,
|
|
2091
|
+
probe: frame.probe,
|
|
2092
|
+
clientSendMicros: frame.clientSendMicros,
|
|
2093
|
+
daemonReceiveMicros: ingressAtSharedMicros,
|
|
2094
|
+
daemonSendMicros,
|
|
2095
|
+
});
|
|
2096
|
+
} catch {
|
|
2097
|
+
// Client timeout reports calibration unavailable; product traffic continues.
|
|
2098
|
+
}
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
if (frame.type === "consumed") {
|
|
2102
|
+
this.#acceptConsumed(frame.pane, frame.seq);
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
if (frame.type === "presence") {
|
|
2106
|
+
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
2107
|
+
this.#usesExplicitAuthority = true;
|
|
2108
|
+
if (!this.#sessionRuntimeBinding?.updatePresence) return this.#failProtocol("protocol-error");
|
|
2109
|
+
const snapshot = this.#sessionRuntimeBinding.updatePresence(frame.state);
|
|
2110
|
+
if (!this.#sessionRuntimeBinding.onAuthoritySnapshot) this.#sendAuthoritySnapshot(snapshot);
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
if (frame.type === "activity") {
|
|
2114
|
+
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
2115
|
+
this.#usesExplicitAuthority = true;
|
|
2116
|
+
if (!this.#sessionRuntimeBinding?.noteActivity) return this.#failProtocol("protocol-error");
|
|
2117
|
+
const snapshot = this.#sessionRuntimeBinding.noteActivity(frame.activity);
|
|
2118
|
+
if (!this.#sessionRuntimeBinding.onAuthoritySnapshot) this.#sendAuthoritySnapshot(snapshot);
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
if (frame.type === "authority-request") {
|
|
2122
|
+
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
2123
|
+
this.#usesExplicitAuthority = true;
|
|
2124
|
+
if (
|
|
2125
|
+
!this.#sessionRuntimeBinding?.requestAuthority ||
|
|
2126
|
+
!this.#sessionRuntimeBinding.authoritySnapshot
|
|
2127
|
+
)
|
|
2128
|
+
return this.#failProtocol("protocol-error");
|
|
2129
|
+
const lease = this.#sessionRuntimeBinding.requestAuthority(frame.authority);
|
|
2130
|
+
if (lease) this.#requestedAuthorities.add(frame.authority);
|
|
2131
|
+
this.#sendFrame(null, {
|
|
2132
|
+
type: "authority-receipt",
|
|
2133
|
+
requestId: frame.requestId,
|
|
2134
|
+
authority: frame.authority,
|
|
2135
|
+
status: lease ? "granted" : "rejected",
|
|
2136
|
+
lease,
|
|
2137
|
+
snapshot: this.#sessionRuntimeBinding.authoritySnapshot(),
|
|
2138
|
+
});
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
if (frame.type === "authority-release") {
|
|
2142
|
+
if (!this.#acceptAuthorityGeneration(frame.generation)) return;
|
|
2143
|
+
this.#usesExplicitAuthority = true;
|
|
2144
|
+
this.#requestedAuthorities.delete(frame.authority);
|
|
2145
|
+
if (!this.#sessionRuntimeBinding?.releaseAuthority)
|
|
2146
|
+
return this.#failProtocol("protocol-error");
|
|
2147
|
+
const snapshot = this.#sessionRuntimeBinding.releaseAuthority(frame.authority);
|
|
2148
|
+
this.#sendFrame(null, {
|
|
2149
|
+
type: "authority-receipt",
|
|
2150
|
+
requestId: frame.requestId,
|
|
2151
|
+
authority: frame.authority,
|
|
2152
|
+
status: "released",
|
|
2153
|
+
lease: null,
|
|
2154
|
+
snapshot,
|
|
2155
|
+
});
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
if (frame.type === "terminal-delivery-ack") {
|
|
2159
|
+
const channel = this.#deliveryChannel(frame.ack);
|
|
2160
|
+
if (!channel) return;
|
|
2161
|
+
channel.delivery!.ack({ ...frame.ack, workspaceName: this.#descriptor.sessionName });
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
if (frame.type === "terminal-delivery-nack") {
|
|
2165
|
+
const channel = this.#deliveryChannel(frame.nack);
|
|
2166
|
+
if (!channel) return;
|
|
2167
|
+
channel.delivery!.nack({ ...frame.nack, workspaceName: this.#descriptor.sessionName });
|
|
2168
|
+
return;
|
|
2169
|
+
}
|
|
2170
|
+
if (frame.type === "terminal-delivery-visibility") {
|
|
2171
|
+
const channel = this.#deliveryChannel({
|
|
2172
|
+
workspaceName: frame.workspaceName,
|
|
2173
|
+
semanticPaneId: frame.pane,
|
|
2174
|
+
generation: frame.generation,
|
|
2175
|
+
incarnation: frame.incarnation,
|
|
2176
|
+
deliveryNonce: frame.deliveryNonce,
|
|
2177
|
+
});
|
|
2178
|
+
if (!channel) return;
|
|
2179
|
+
channel.delivery!.setVisibility(frame.visibility);
|
|
2180
|
+
return;
|
|
2181
|
+
}
|
|
2182
|
+
if (frame.type === "semantic-intent") {
|
|
2183
|
+
this.#acceptSemanticIntent(frame.operationId, frame.intent);
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
if (frame.type === "viewport") {
|
|
2187
|
+
if (
|
|
2188
|
+
!this.#descriptor.terminalDelivery ||
|
|
2189
|
+
this.#descriptor.viewerMode !== "interactive" ||
|
|
2190
|
+
frame.seq !== this.#nextViewportSeq ||
|
|
2191
|
+
(this.#usesExplicitAuthority && !this.#requestedAuthorities.has("geometry"))
|
|
2192
|
+
) {
|
|
2193
|
+
this.#failProtocol("input-rejected");
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
if (!this.#prepareInputAuthority(true)) return;
|
|
2197
|
+
this.#nextViewportSeq += 1;
|
|
2198
|
+
try {
|
|
2199
|
+
this.#sessionRuntimeBinding!.fitViewport(frame.authorityLease, frame.cols, frame.rows);
|
|
2200
|
+
this.#sendFrame(null, {
|
|
2201
|
+
type: "viewport-ack",
|
|
2202
|
+
seq: frame.seq,
|
|
2203
|
+
cols: frame.cols,
|
|
2204
|
+
rows: frame.rows,
|
|
2205
|
+
outcome: "ok",
|
|
2206
|
+
authorityLease: frame.authorityLease,
|
|
2207
|
+
});
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
if (
|
|
2210
|
+
error instanceof SessionRuntimeControllerLeaseError &&
|
|
2211
|
+
(error.code === "invalid-client-capability" || error.code === "stale-controller-lease")
|
|
2212
|
+
) {
|
|
2213
|
+
this.#sendFrame(null, {
|
|
2214
|
+
type: "viewport-ack",
|
|
2215
|
+
seq: frame.seq,
|
|
2216
|
+
cols: frame.cols,
|
|
2217
|
+
rows: frame.rows,
|
|
2218
|
+
outcome: "geometry-authority-conflict",
|
|
2219
|
+
authorityLease: frame.authorityLease,
|
|
2220
|
+
});
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
this.#failProtocol("input-rejected");
|
|
2224
|
+
}
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
this.#acceptInput(
|
|
2228
|
+
frame.pane,
|
|
2229
|
+
frame.seq,
|
|
2230
|
+
frame.kind,
|
|
2231
|
+
frame.data,
|
|
2232
|
+
byteLength,
|
|
2233
|
+
frame.performanceTraceId,
|
|
2234
|
+
frame.causalProbe,
|
|
2235
|
+
ingressAtMicros,
|
|
2236
|
+
callbackAtSharedMicros,
|
|
2237
|
+
ingressAtSharedMicros,
|
|
2238
|
+
);
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2241
|
+
#acceptAuthorityGeneration(generation: string): boolean {
|
|
2242
|
+
if (!this.#sessionRuntimeBinding || generation !== this.#sessionRuntimeBinding.generation) {
|
|
2243
|
+
this.#failProtocol("protocol-error");
|
|
2244
|
+
return false;
|
|
2245
|
+
}
|
|
2246
|
+
return true;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
#sendAuthoritySnapshot(snapshot: SessionRuntimeAuthoritySnapshot): void {
|
|
2250
|
+
this.#sendFrame(null, { type: "authority-snapshot", snapshot });
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
#prepareInputAuthority(geometry: boolean): boolean {
|
|
2254
|
+
if (this.#usesExplicitAuthority) {
|
|
2255
|
+
const required = geometry ? "geometry" : "input";
|
|
2256
|
+
if (!this.#requestedAuthorities.has(required)) {
|
|
2257
|
+
this.#failProtocol("input-rejected");
|
|
2258
|
+
return false;
|
|
2259
|
+
}
|
|
2260
|
+
return true;
|
|
2261
|
+
}
|
|
2262
|
+
if (this.#legacyInputActivated && (!geometry || this.#legacyGeometryActivated)) return true;
|
|
2263
|
+
try {
|
|
2264
|
+
// A genuine old binding acquired at admission and has no adapter method.
|
|
2265
|
+
// New deferred bindings activate only here, before explicit mode exists.
|
|
2266
|
+
this.#sessionRuntimeBinding?.activateLegacyAuthority?.(geometry);
|
|
2267
|
+
this.#legacyInputActivated = true;
|
|
2268
|
+
if (geometry) this.#legacyGeometryActivated = true;
|
|
2269
|
+
return true;
|
|
2270
|
+
} catch {
|
|
2271
|
+
this.#failProtocol("input-rejected");
|
|
2272
|
+
return false;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
#deliveryChannel(address: {
|
|
2277
|
+
workspaceName: string;
|
|
2278
|
+
semanticPaneId: string;
|
|
2279
|
+
generation: string;
|
|
2280
|
+
incarnation: string;
|
|
2281
|
+
deliveryNonce: string;
|
|
2282
|
+
}): PaneChannel | null {
|
|
2283
|
+
const channel = this.#panes.get(address.semanticPaneId);
|
|
2284
|
+
const expected = channel?.deliveryAddress;
|
|
2285
|
+
if (
|
|
2286
|
+
!channel?.delivery ||
|
|
2287
|
+
!expected ||
|
|
2288
|
+
expected.workspaceName !== address.workspaceName ||
|
|
2289
|
+
expected.generation !== address.generation ||
|
|
2290
|
+
expected.deliveryNonce !== address.deliveryNonce ||
|
|
2291
|
+
expected.incarnation === null
|
|
2292
|
+
) {
|
|
2293
|
+
this.#failProtocol("protocol-error");
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2296
|
+
// More than one canonical delivery can legitimately be in flight. The
|
|
2297
|
+
// cached address records only the newest incarnation, so comparing an ACK
|
|
2298
|
+
// against that single value rejects an earlier valid delivery during a
|
|
2299
|
+
// reseed/reconnect burst. Generation + one-use delivery nonce identify the
|
|
2300
|
+
// channel here; the retained delivery owner validates incarnation,
|
|
2301
|
+
// transaction and revision ordering authoritatively below.
|
|
2302
|
+
return channel;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
#acceptSemanticIntent(operationId: string, intent: SessionRuntimeSemanticIntent): void {
|
|
2306
|
+
if (!this.#descriptor.terminalDelivery || this.#descriptor.viewerMode !== "interactive") {
|
|
2307
|
+
this.#failProtocol("input-rejected");
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (!this.#prepareInputAuthority(false)) return;
|
|
2311
|
+
void this.#sessionRuntimeBinding!.submitIntent(operationId, intent)
|
|
2312
|
+
.then((result) => {
|
|
2313
|
+
this.#sendFrame(null, {
|
|
2314
|
+
type: "semantic-intent-ack",
|
|
2315
|
+
operationId,
|
|
2316
|
+
outcome: { status: "applied", result: result ?? null },
|
|
2317
|
+
});
|
|
2318
|
+
})
|
|
2319
|
+
.catch((error: unknown) => {
|
|
2320
|
+
const backendRefusal = semanticBackendRefusal(error);
|
|
2321
|
+
const rawCode =
|
|
2322
|
+
backendRefusal ??
|
|
2323
|
+
(error && typeof error === "object" && "code" in error
|
|
2324
|
+
? String(error.code)
|
|
2325
|
+
: error && typeof error === "object" && "outcome" in error
|
|
2326
|
+
? `intent-${String(error.outcome)}`
|
|
2327
|
+
: "stream-unavailable");
|
|
2328
|
+
const code = [
|
|
2329
|
+
"controller-conflict",
|
|
2330
|
+
"controller-target-unavailable",
|
|
2331
|
+
"stale-controller-lease",
|
|
2332
|
+
"invalid-client-capability",
|
|
2333
|
+
"invalid-source-pane-binding",
|
|
2334
|
+
"intent-session-mismatch",
|
|
2335
|
+
"intent-rejected",
|
|
2336
|
+
"intent-timed-out",
|
|
2337
|
+
"pane_inventory_not_ready",
|
|
2338
|
+
"pane_identity_changed_before_select",
|
|
2339
|
+
"pane_not_active",
|
|
2340
|
+
].includes(rawCode)
|
|
2341
|
+
? rawCode
|
|
2342
|
+
: "stream-unavailable";
|
|
2343
|
+
this.#sendFrame(null, {
|
|
2344
|
+
type: "semantic-intent-ack",
|
|
2345
|
+
operationId,
|
|
2346
|
+
outcome: {
|
|
2347
|
+
status: "rejected",
|
|
2348
|
+
code,
|
|
2349
|
+
message:
|
|
2350
|
+
error instanceof Error ? error.message.slice(0, 512) : "Semantic intent failed",
|
|
2351
|
+
},
|
|
2352
|
+
});
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
#acceptConsumed(pane: string, seq: number): void {
|
|
2357
|
+
const channel = this.#panes.get(pane);
|
|
2358
|
+
if (
|
|
2359
|
+
!this.#deliveryAcks ||
|
|
2360
|
+
!channel ||
|
|
2361
|
+
seq <= channel.consumedSeq ||
|
|
2362
|
+
seq > channel.sentPaneFrames
|
|
2363
|
+
) {
|
|
2364
|
+
this.#failProtocol("protocol-error");
|
|
2365
|
+
return;
|
|
2366
|
+
}
|
|
2367
|
+
const returned = seq - channel.consumedSeq;
|
|
2368
|
+
channel.consumedSeq = seq;
|
|
2369
|
+
this.#ledger.give(this.#clientId, pane, "renderer-backlog", returned);
|
|
2370
|
+
this.#evaluateResume(pane);
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
#acceptInput(
|
|
2374
|
+
pane: string,
|
|
2375
|
+
seq: number,
|
|
2376
|
+
kind: "text" | "key",
|
|
2377
|
+
data: string,
|
|
2378
|
+
frameBytes: number,
|
|
2379
|
+
performanceTraceId?: string,
|
|
2380
|
+
causalProbe?: CausalCellProbeV1,
|
|
2381
|
+
ingressAtMicros: number | null = null,
|
|
2382
|
+
callbackAtSharedMicros: number | null = null,
|
|
2383
|
+
ingressAtSharedMicros: number | null = null,
|
|
2384
|
+
): void {
|
|
2385
|
+
if (this.#descriptor.viewerMode !== "interactive") {
|
|
2386
|
+
this.#failProtocol("input-rejected");
|
|
2387
|
+
return;
|
|
2388
|
+
}
|
|
2389
|
+
const channel = this.#panes.get(pane);
|
|
2390
|
+
const semanticDelivery = this.#descriptor.terminalDelivery !== null;
|
|
2391
|
+
if (
|
|
2392
|
+
!channel ||
|
|
2393
|
+
channel.closed ||
|
|
2394
|
+
(semanticDelivery ? !channel.delivery : !channel.sub) ||
|
|
2395
|
+
seq !== channel.nextInputSeq
|
|
2396
|
+
) {
|
|
2397
|
+
this.#failProtocol("input-rejected");
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2400
|
+
if (causalProbe) {
|
|
2401
|
+
const address = channel.deliveryAddress;
|
|
2402
|
+
if (
|
|
2403
|
+
!this.#causalCellCapability ||
|
|
2404
|
+
!address ||
|
|
2405
|
+
causalProbe.clientId !== this.#sessionRuntimeBinding?.clientId ||
|
|
2406
|
+
causalProbe.transportNonce !== this.#binding.requestId ||
|
|
2407
|
+
causalProbe.deliveryNonce !== address.deliveryNonce ||
|
|
2408
|
+
causalProbe.inputSequence !== seq ||
|
|
2409
|
+
causalProbe.semanticPaneId !== pane ||
|
|
2410
|
+
causalProbe.generation !== address.generation ||
|
|
2411
|
+
causalProbe.incarnation !== address.incarnation
|
|
2412
|
+
) {
|
|
2413
|
+
this.#failProtocol("input-rejected");
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
const now = this.#now();
|
|
2418
|
+
if (
|
|
2419
|
+
now < this.#inputWindowStartedAt ||
|
|
2420
|
+
now - this.#inputWindowStartedAt >= this.#inputRateWindowMs
|
|
2421
|
+
) {
|
|
2422
|
+
this.#inputWindowStartedAt = now;
|
|
2423
|
+
this.#inputWindowFrames = 0;
|
|
2424
|
+
this.#inputWindowBytes = 0;
|
|
2425
|
+
}
|
|
2426
|
+
if (
|
|
2427
|
+
this.#inputWindowFrames + 1 > this.#maxInputFrames ||
|
|
2428
|
+
this.#inputWindowBytes + frameBytes > this.#maxInputBytes
|
|
2429
|
+
) {
|
|
2430
|
+
this.#failProtocol("input-rejected");
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2433
|
+
if (!this.#prepareInputAuthority(false)) return;
|
|
2434
|
+
let trace: ReturnType<SessionRuntimeObservability["beginTrace"]> = null;
|
|
2435
|
+
if (performanceTraceId && this.#observability?.enabled) {
|
|
2436
|
+
try {
|
|
2437
|
+
trace = this.#observability.beginTrace(
|
|
2438
|
+
"terminal-input-to-paint",
|
|
2439
|
+
{
|
|
2440
|
+
generation: this.#sessionRuntimeBinding!.generation,
|
|
2441
|
+
incarnation: causalProbe?.incarnation ?? channel.deliveryAddress?.incarnation ?? null,
|
|
2442
|
+
},
|
|
2443
|
+
performanceTraceId,
|
|
2444
|
+
);
|
|
2445
|
+
if (trace && ingressAtMicros !== null) {
|
|
2446
|
+
this.#observability.recordSpan(
|
|
2447
|
+
"transport",
|
|
2448
|
+
"pane-stream-socket-message-callback-entry",
|
|
2449
|
+
ingressAtMicros,
|
|
2450
|
+
ingressAtMicros,
|
|
2451
|
+
trace,
|
|
2452
|
+
callbackAtSharedMicros === null
|
|
2453
|
+
? undefined
|
|
2454
|
+
: {
|
|
2455
|
+
startedAtMicros: callbackAtSharedMicros,
|
|
2456
|
+
endedAtMicros: callbackAtSharedMicros,
|
|
2457
|
+
},
|
|
2458
|
+
);
|
|
2459
|
+
this.#observability.recordSpan(
|
|
2460
|
+
"transport",
|
|
2461
|
+
"pane-stream-input-frame-ingress",
|
|
2462
|
+
ingressAtMicros,
|
|
2463
|
+
ingressAtMicros,
|
|
2464
|
+
trace,
|
|
2465
|
+
ingressAtSharedMicros === null
|
|
2466
|
+
? undefined
|
|
2467
|
+
: { startedAtMicros: ingressAtSharedMicros, endedAtMicros: ingressAtSharedMicros },
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
} catch {
|
|
2471
|
+
trace = null;
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
this.#inputWindowFrames += 1;
|
|
2475
|
+
this.#inputWindowBytes += frameBytes;
|
|
2476
|
+
channel.nextInputSeq += 1;
|
|
2477
|
+
try {
|
|
2478
|
+
this.#sessionRuntimeBinding!.assertController(pane);
|
|
2479
|
+
if (semanticDelivery)
|
|
2480
|
+
this.#sessionRuntimeBinding!.sendInput(
|
|
2481
|
+
pane,
|
|
2482
|
+
{ kind, data },
|
|
2483
|
+
performanceTraceId,
|
|
2484
|
+
causalProbe,
|
|
2485
|
+
causalProbe
|
|
2486
|
+
? (result) => {
|
|
2487
|
+
if (this.#closed) return;
|
|
2488
|
+
if (result.status === "proved") {
|
|
2489
|
+
this.#sendFrame(null, { type: "causal-cell-proof", proof: result.proof });
|
|
2490
|
+
} else {
|
|
2491
|
+
this.#sendFrame(null, {
|
|
2492
|
+
type: "causal-cell-failure",
|
|
2493
|
+
failure: {
|
|
2494
|
+
version: 1,
|
|
2495
|
+
capability: "causal-cell-v1",
|
|
2496
|
+
traceId: result.traceId,
|
|
2497
|
+
reason: result.reason,
|
|
2498
|
+
...(result.diagnostic ? { diagnostic: result.diagnostic } : {}),
|
|
2499
|
+
},
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
: undefined,
|
|
2504
|
+
);
|
|
2505
|
+
else if (kind === "text") channel.sub!.sendText(data);
|
|
2506
|
+
else channel.sub!.sendKey(data);
|
|
2507
|
+
let ackStartedAtMicros: number | null = null;
|
|
2508
|
+
let ackStartedAtSharedMicros: number | null = null;
|
|
2509
|
+
if (trace) {
|
|
2510
|
+
try {
|
|
2511
|
+
ackStartedAtMicros = this.#observability!.nowMicros();
|
|
2512
|
+
} catch {
|
|
2513
|
+
// Diagnostics cannot alter protocol truth.
|
|
2514
|
+
}
|
|
2515
|
+
if (this.#diagnosticSharedRawMicros) {
|
|
2516
|
+
try {
|
|
2517
|
+
ackStartedAtSharedMicros = this.#sharedMicros();
|
|
2518
|
+
} catch {
|
|
2519
|
+
// Preserve process-local ACK diagnostics.
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
sendControl(this.#socket, { type: "input-ack", pane, seq });
|
|
2524
|
+
if (trace && ackStartedAtMicros !== null) {
|
|
2525
|
+
let ackEndedAtMicros: number | null = null;
|
|
2526
|
+
try {
|
|
2527
|
+
ackEndedAtMicros = this.#observability!.nowMicros();
|
|
2528
|
+
} catch {
|
|
2529
|
+
// Diagnostics cannot alter protocol truth.
|
|
2530
|
+
}
|
|
2531
|
+
let ackEndedAtSharedMicros: number | null = null;
|
|
2532
|
+
if (ackStartedAtSharedMicros !== null) {
|
|
2533
|
+
try {
|
|
2534
|
+
ackEndedAtSharedMicros = this.#sharedMicros();
|
|
2535
|
+
} catch {
|
|
2536
|
+
// Preserve process-local ACK diagnostics.
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
if (ackEndedAtMicros !== null) {
|
|
2540
|
+
try {
|
|
2541
|
+
this.#observability!.recordSpan(
|
|
2542
|
+
"transport",
|
|
2543
|
+
"pane-stream-input-ack-socket-send",
|
|
2544
|
+
ackStartedAtMicros,
|
|
2545
|
+
ackEndedAtMicros,
|
|
2546
|
+
trace,
|
|
2547
|
+
ackStartedAtSharedMicros === null || ackEndedAtSharedMicros === null
|
|
2548
|
+
? undefined
|
|
2549
|
+
: {
|
|
2550
|
+
startedAtMicros: ackStartedAtSharedMicros,
|
|
2551
|
+
endedAtMicros: ackEndedAtSharedMicros,
|
|
2552
|
+
},
|
|
2553
|
+
);
|
|
2554
|
+
} catch {
|
|
2555
|
+
// Diagnostics cannot alter protocol truth.
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
} catch {
|
|
2560
|
+
this.close(1011, "stream-unavailable");
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
#failProtocol(code: PaneStreamErrorFrameCode): void {
|
|
2565
|
+
try {
|
|
2566
|
+
sendControl(this.#socket, {
|
|
2567
|
+
type: "error",
|
|
2568
|
+
protocolVersion: PANE_STREAM_PROTOCOL_VERSION,
|
|
2569
|
+
code,
|
|
2570
|
+
retryable: false,
|
|
2571
|
+
});
|
|
2572
|
+
} catch {
|
|
2573
|
+
this.close(1011, "stream-unavailable");
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
this.close(1008, code);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
#closeIfAllPanesGone(): void {
|
|
2580
|
+
if (this.#closed) return;
|
|
2581
|
+
for (const channel of this.#panes.values()) {
|
|
2582
|
+
if (!channel.closed) return;
|
|
2583
|
+
}
|
|
2584
|
+
this.close(1000, "panes-closed");
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
readonly #onSocketClose = (): void => this.close(1000, "peer-closed");
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
function concatBytes(chunks: readonly Uint8Array[]): Uint8Array {
|
|
2591
|
+
if (chunks.length === 0) return new Uint8Array(0);
|
|
2592
|
+
if (chunks.length === 1) return chunks[0]!;
|
|
2593
|
+
let total = 0;
|
|
2594
|
+
for (const chunk of chunks) total += chunk.byteLength;
|
|
2595
|
+
const merged = new Uint8Array(total);
|
|
2596
|
+
let offset = 0;
|
|
2597
|
+
for (const chunk of chunks) {
|
|
2598
|
+
merged.set(chunk, offset);
|
|
2599
|
+
offset += chunk.byteLength;
|
|
2600
|
+
}
|
|
2601
|
+
return merged;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
function chunkBytes(data: Uint8Array, maxChunk: number): Uint8Array[] {
|
|
2605
|
+
if (data.byteLength === 0) return [];
|
|
2606
|
+
if (data.byteLength <= maxChunk) return [data];
|
|
2607
|
+
const chunks: Uint8Array[] = [];
|
|
2608
|
+
for (let offset = 0; offset < data.byteLength; offset += maxChunk) {
|
|
2609
|
+
chunks.push(data.subarray(offset, Math.min(offset + maxChunk, data.byteLength)));
|
|
2610
|
+
}
|
|
2611
|
+
return chunks;
|
|
2612
|
+
}
|