@timurproko/a1 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -0
- package/bin/addone-supervisor.js +7 -0
- package/bin/addone-ui.js +20 -0
- package/bin/addone.js +26 -0
- package/dist/src/cli/dispatch.d.ts +26 -0
- package/dist/src/cli/dispatch.d.ts.map +1 -0
- package/dist/src/cli/dispatch.js +35 -0
- package/dist/src/cli/dispatch.js.map +1 -0
- package/dist/src/cli/index.d.ts +4 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +4 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/version-stats.d.ts +17 -0
- package/dist/src/cli/version-stats.d.ts.map +1 -0
- package/dist/src/cli/version-stats.js +68 -0
- package/dist/src/cli/version-stats.js.map +1 -0
- package/dist/src/cli/version.d.ts +3 -0
- package/dist/src/cli/version.d.ts.map +1 -0
- package/dist/src/cli/version.js +23 -0
- package/dist/src/cli/version.js.map +1 -0
- package/dist/src/features/launch/development-launch.d.ts +9 -0
- package/dist/src/features/launch/development-launch.d.ts.map +1 -0
- package/dist/src/features/launch/development-launch.js +27 -0
- package/dist/src/features/launch/development-launch.js.map +1 -0
- package/dist/src/features/launch/index.d.ts +8 -0
- package/dist/src/features/launch/index.d.ts.map +1 -0
- package/dist/src/features/launch/index.js +8 -0
- package/dist/src/features/launch/index.js.map +1 -0
- package/dist/src/features/launch/initialize-profile.d.ts +7 -0
- package/dist/src/features/launch/initialize-profile.d.ts.map +1 -0
- package/dist/src/features/launch/initialize-profile.js +59 -0
- package/dist/src/features/launch/initialize-profile.js.map +1 -0
- package/dist/src/features/launch/intent.d.ts +8 -0
- package/dist/src/features/launch/intent.d.ts.map +1 -0
- package/dist/src/features/launch/intent.js +5 -0
- package/dist/src/features/launch/intent.js.map +1 -0
- package/dist/src/features/launch/prepare-launch.d.ts +14 -0
- package/dist/src/features/launch/prepare-launch.d.ts.map +1 -0
- package/dist/src/features/launch/prepare-launch.js +22 -0
- package/dist/src/features/launch/prepare-launch.js.map +1 -0
- package/dist/src/features/launch/profile-paths.d.ts +16 -0
- package/dist/src/features/launch/profile-paths.d.ts.map +1 -0
- package/dist/src/features/launch/profile-paths.js +30 -0
- package/dist/src/features/launch/profile-paths.js.map +1 -0
- package/dist/src/features/launch/profiles.d.ts +13 -0
- package/dist/src/features/launch/profiles.d.ts.map +1 -0
- package/dist/src/features/launch/profiles.js +27 -0
- package/dist/src/features/launch/profiles.js.map +1 -0
- package/dist/src/features/launch/runtime-selection.d.ts +15 -0
- package/dist/src/features/launch/runtime-selection.d.ts.map +1 -0
- package/dist/src/features/launch/runtime-selection.js +14 -0
- package/dist/src/features/launch/runtime-selection.js.map +1 -0
- package/dist/src/features/owned-ui/customization.d.ts +36 -0
- package/dist/src/features/owned-ui/customization.d.ts.map +1 -0
- package/dist/src/features/owned-ui/customization.js +110 -0
- package/dist/src/features/owned-ui/customization.js.map +1 -0
- package/dist/src/features/owned-ui/diagnostics.d.ts +34 -0
- package/dist/src/features/owned-ui/diagnostics.d.ts.map +1 -0
- package/dist/src/features/owned-ui/diagnostics.js +95 -0
- package/dist/src/features/owned-ui/diagnostics.js.map +1 -0
- package/dist/src/features/owned-ui/index.d.ts +5 -0
- package/dist/src/features/owned-ui/index.d.ts.map +1 -0
- package/dist/src/features/owned-ui/index.js +5 -0
- package/dist/src/features/owned-ui/index.js.map +1 -0
- package/dist/src/features/owned-ui/pi-session-shell.d.ts +97 -0
- package/dist/src/features/owned-ui/pi-session-shell.d.ts.map +1 -0
- package/dist/src/features/owned-ui/pi-session-shell.js +1437 -0
- package/dist/src/features/owned-ui/pi-session-shell.js.map +1 -0
- package/dist/src/features/owned-ui/run.d.ts +9 -0
- package/dist/src/features/owned-ui/run.d.ts.map +1 -0
- package/dist/src/features/owned-ui/run.js +21 -0
- package/dist/src/features/owned-ui/run.js.map +1 -0
- package/dist/src/features/workspace/capabilities.d.ts +32 -0
- package/dist/src/features/workspace/capabilities.d.ts.map +1 -0
- package/dist/src/features/workspace/capabilities.js +76 -0
- package/dist/src/features/workspace/capabilities.js.map +1 -0
- package/dist/src/features/workspace/index.d.ts +7 -0
- package/dist/src/features/workspace/index.d.ts.map +1 -0
- package/dist/src/features/workspace/index.js +7 -0
- package/dist/src/features/workspace/index.js.map +1 -0
- package/dist/src/features/workspace/presentation.d.ts +31 -0
- package/dist/src/features/workspace/presentation.d.ts.map +1 -0
- package/dist/src/features/workspace/presentation.js +69 -0
- package/dist/src/features/workspace/presentation.js.map +1 -0
- package/dist/src/features/workspace/reconciliation.d.ts +16 -0
- package/dist/src/features/workspace/reconciliation.d.ts.map +1 -0
- package/dist/src/features/workspace/reconciliation.js +83 -0
- package/dist/src/features/workspace/reconciliation.js.map +1 -0
- package/dist/src/features/workspace/reducer.d.ts +43 -0
- package/dist/src/features/workspace/reducer.d.ts.map +1 -0
- package/dist/src/features/workspace/reducer.js +214 -0
- package/dist/src/features/workspace/reducer.js.map +1 -0
- package/dist/src/features/workspace/router.d.ts +32 -0
- package/dist/src/features/workspace/router.d.ts.map +1 -0
- package/dist/src/features/workspace/router.js +125 -0
- package/dist/src/features/workspace/router.js.map +1 -0
- package/dist/src/features/workspace/store.d.ts +18 -0
- package/dist/src/features/workspace/store.d.ts.map +1 -0
- package/dist/src/features/workspace/store.js +55 -0
- package/dist/src/features/workspace/store.js.map +1 -0
- package/dist/src/foundation/lifecycle/index.d.ts +3 -0
- package/dist/src/foundation/lifecycle/index.d.ts.map +1 -0
- package/dist/src/foundation/lifecycle/index.js +3 -0
- package/dist/src/foundation/lifecycle/index.js.map +1 -0
- package/dist/src/foundation/lifecycle/model.d.ts +101 -0
- package/dist/src/foundation/lifecycle/model.d.ts.map +1 -0
- package/dist/src/foundation/lifecycle/model.js +40 -0
- package/dist/src/foundation/lifecycle/model.js.map +1 -0
- package/dist/src/foundation/lifecycle/paths.d.ts +11 -0
- package/dist/src/foundation/lifecycle/paths.d.ts.map +1 -0
- package/dist/src/foundation/lifecycle/paths.js +26 -0
- package/dist/src/foundation/lifecycle/paths.js.map +1 -0
- package/dist/src/foundation/native-host-protocol/codec.d.ts +12 -0
- package/dist/src/foundation/native-host-protocol/codec.d.ts.map +1 -0
- package/dist/src/foundation/native-host-protocol/codec.js +57 -0
- package/dist/src/foundation/native-host-protocol/codec.js.map +1 -0
- package/dist/src/foundation/native-host-protocol/evidence.d.ts +68 -0
- package/dist/src/foundation/native-host-protocol/evidence.d.ts.map +1 -0
- package/dist/src/foundation/native-host-protocol/evidence.js +141 -0
- package/dist/src/foundation/native-host-protocol/evidence.js.map +1 -0
- package/dist/src/foundation/native-host-protocol/index.d.ts +5 -0
- package/dist/src/foundation/native-host-protocol/index.d.ts.map +1 -0
- package/dist/src/foundation/native-host-protocol/index.js +5 -0
- package/dist/src/foundation/native-host-protocol/index.js.map +1 -0
- package/dist/src/foundation/native-host-protocol/messages.d.ts +57 -0
- package/dist/src/foundation/native-host-protocol/messages.d.ts.map +1 -0
- package/dist/src/foundation/native-host-protocol/messages.js +149 -0
- package/dist/src/foundation/native-host-protocol/messages.js.map +1 -0
- package/dist/src/foundation/native-host-protocol/proof-gate.d.ts +14 -0
- package/dist/src/foundation/native-host-protocol/proof-gate.d.ts.map +1 -0
- package/dist/src/foundation/native-host-protocol/proof-gate.js +34 -0
- package/dist/src/foundation/native-host-protocol/proof-gate.js.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/extension-ui.d.ts +303 -0
- package/dist/src/foundation/owned-ui-contracts/extension-ui.d.ts.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/extension-ui.js +69 -0
- package/dist/src/foundation/owned-ui-contracts/extension-ui.js.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/index.d.ts +4 -0
- package/dist/src/foundation/owned-ui-contracts/index.d.ts.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/index.js +4 -0
- package/dist/src/foundation/owned-ui-contracts/index.js.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/model.d.ts +242 -0
- package/dist/src/foundation/owned-ui-contracts/model.d.ts.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/model.js +2 -0
- package/dist/src/foundation/owned-ui-contracts/model.js.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/validation.d.ts +12 -0
- package/dist/src/foundation/owned-ui-contracts/validation.d.ts.map +1 -0
- package/dist/src/foundation/owned-ui-contracts/validation.js +396 -0
- package/dist/src/foundation/owned-ui-contracts/validation.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/components.d.ts +5 -0
- package/dist/src/foundation/pi-component-adapter/components.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/components.js +65 -0
- package/dist/src/foundation/pi-component-adapter/components.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/conformance.d.ts +17 -0
- package/dist/src/foundation/pi-component-adapter/conformance.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/conformance.js +63 -0
- package/dist/src/foundation/pi-component-adapter/conformance.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/index.d.ts +13 -0
- package/dist/src/foundation/pi-component-adapter/index.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/index.js +13 -0
- package/dist/src/foundation/pi-component-adapter/index.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-components.d.ts +7 -0
- package/dist/src/foundation/pi-component-adapter/shell-components.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-components.js +7 -0
- package/dist/src/foundation/pi-component-adapter/shell-components.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.d.ts +12 -0
- package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.js +165 -0
- package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-extension-ui.d.ts +36 -0
- package/dist/src/foundation/pi-component-adapter/shell-extension-ui.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-extension-ui.js +280 -0
- package/dist/src/foundation/pi-component-adapter/shell-extension-ui.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-footer-status.d.ts +8 -0
- package/dist/src/foundation/pi-component-adapter/shell-footer-status.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-footer-status.js +246 -0
- package/dist/src/foundation/pi-component-adapter/shell-footer-status.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts +43 -0
- package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.js +397 -0
- package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.d.ts +106 -0
- package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.js +234 -0
- package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-shared-facade.d.ts +117 -0
- package/dist/src/foundation/pi-component-adapter/shell-shared-facade.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/shell-shared-facade.js +88 -0
- package/dist/src/foundation/pi-component-adapter/shell-shared-facade.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/theme.d.ts +2 -0
- package/dist/src/foundation/pi-component-adapter/theme.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/theme.js +2 -0
- package/dist/src/foundation/pi-component-adapter/theme.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.d.ts +423 -0
- package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.js +297 -0
- package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.d.ts +11 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.js +30 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.d.ts +18 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.js +52 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.d.ts +23 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.js +143 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.d.ts +5 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.js +43 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.d.ts +18 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.js +82 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.d.ts +25 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.js +106 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.d.ts +3 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.js +19 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.d.ts +10 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.js +78 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.d.ts +56 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.js +343 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.d.ts +23 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.js +160 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.d.ts +96 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.js +890 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.d.ts +20 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.js +45 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.d.ts +31 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.js +60 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.d.ts +99 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.js +1273 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.d.ts +34 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.js +77 -0
- package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/external-editor.d.ts +10 -0
- package/dist/src/foundation/pi-component-adapter/upstream/external-editor.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/external-editor.js +40 -0
- package/dist/src/foundation/pi-component-adapter/upstream/external-editor.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/model-search.d.ts +16 -0
- package/dist/src/foundation/pi-component-adapter/upstream/model-search.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/model-search.js +15 -0
- package/dist/src/foundation/pi-component-adapter/upstream/model-search.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.d.ts +26 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.js +118 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.js.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.d.ts +54 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.d.ts.map +1 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.js +311 -0
- package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.js.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/adapter.d.ts +343 -0
- package/dist/src/foundation/pi-engine-adapter/adapter.d.ts.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/adapter.js +2365 -0
- package/dist/src/foundation/pi-engine-adapter/adapter.js.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/conformance.d.ts +14 -0
- package/dist/src/foundation/pi-engine-adapter/conformance.d.ts.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/conformance.js +85 -0
- package/dist/src/foundation/pi-engine-adapter/conformance.js.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/index.d.ts +4 -0
- package/dist/src/foundation/pi-engine-adapter/index.d.ts.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/index.js +4 -0
- package/dist/src/foundation/pi-engine-adapter/index.js.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/workflows.d.ts +165 -0
- package/dist/src/foundation/pi-engine-adapter/workflows.d.ts.map +1 -0
- package/dist/src/foundation/pi-engine-adapter/workflows.js +61 -0
- package/dist/src/foundation/pi-engine-adapter/workflows.js.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/adapter.d.ts +34 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/adapter.d.ts.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/adapter.js +485 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/adapter.js.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/conformance.d.ts +14 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/conformance.d.ts.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/conformance.js +132 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/conformance.js.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/contracts.d.ts +122 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/contracts.d.ts.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/contracts.js +2 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/contracts.js.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/index.d.ts +4 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/index.d.ts.map +1 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/index.js +4 -0
- package/dist/src/foundation/pi-tui-runtime-adapter/index.js.map +1 -0
- package/dist/src/foundation/protocol/client.d.ts +17 -0
- package/dist/src/foundation/protocol/client.d.ts.map +1 -0
- package/dist/src/foundation/protocol/client.js +127 -0
- package/dist/src/foundation/protocol/client.js.map +1 -0
- package/dist/src/foundation/protocol/index.d.ts +3 -0
- package/dist/src/foundation/protocol/index.d.ts.map +1 -0
- package/dist/src/foundation/protocol/index.js +3 -0
- package/dist/src/foundation/protocol/index.js.map +1 -0
- package/dist/src/foundation/protocol/messages.d.ts +90 -0
- package/dist/src/foundation/protocol/messages.d.ts.map +1 -0
- package/dist/src/foundation/protocol/messages.js +99 -0
- package/dist/src/foundation/protocol/messages.js.map +1 -0
- package/dist/src/foundation/release/bootstrap.d.ts +30 -0
- package/dist/src/foundation/release/bootstrap.d.ts.map +1 -0
- package/dist/src/foundation/release/bootstrap.js +283 -0
- package/dist/src/foundation/release/bootstrap.js.map +1 -0
- package/dist/src/foundation/release/cohort-selection.d.ts +40 -0
- package/dist/src/foundation/release/cohort-selection.d.ts.map +1 -0
- package/dist/src/foundation/release/cohort-selection.js +76 -0
- package/dist/src/foundation/release/cohort-selection.js.map +1 -0
- package/dist/src/foundation/release/cohort-state.d.ts +68 -0
- package/dist/src/foundation/release/cohort-state.d.ts.map +1 -0
- package/dist/src/foundation/release/cohort-state.js +201 -0
- package/dist/src/foundation/release/cohort-state.js.map +1 -0
- package/dist/src/foundation/release/development-preview-release.d.ts +49 -0
- package/dist/src/foundation/release/development-preview-release.d.ts.map +1 -0
- package/dist/src/foundation/release/development-preview-release.js +113 -0
- package/dist/src/foundation/release/development-preview-release.js.map +1 -0
- package/dist/src/foundation/release/index.d.ts +12 -0
- package/dist/src/foundation/release/index.d.ts.map +1 -0
- package/dist/src/foundation/release/index.js +12 -0
- package/dist/src/foundation/release/index.js.map +1 -0
- package/dist/src/foundation/release/process-cleanup.d.ts +15 -0
- package/dist/src/foundation/release/process-cleanup.d.ts.map +1 -0
- package/dist/src/foundation/release/process-cleanup.js +67 -0
- package/dist/src/foundation/release/process-cleanup.js.map +1 -0
- package/dist/src/foundation/release/release-gc.d.ts +6 -0
- package/dist/src/foundation/release/release-gc.d.ts.map +1 -0
- package/dist/src/foundation/release/release-gc.js +17 -0
- package/dist/src/foundation/release/release-gc.js.map +1 -0
- package/dist/src/foundation/release/release-store.d.ts +11 -0
- package/dist/src/foundation/release/release-store.d.ts.map +1 -0
- package/dist/src/foundation/release/release-store.js +115 -0
- package/dist/src/foundation/release/release-store.js.map +1 -0
- package/dist/src/foundation/release/release.d.ts +24 -0
- package/dist/src/foundation/release/release.d.ts.map +1 -0
- package/dist/src/foundation/release/release.js +151 -0
- package/dist/src/foundation/release/release.js.map +1 -0
- package/dist/src/foundation/release/stable-release.d.ts +30 -0
- package/dist/src/foundation/release/stable-release.d.ts.map +1 -0
- package/dist/src/foundation/release/stable-release.js +38 -0
- package/dist/src/foundation/release/stable-release.js.map +1 -0
- package/dist/src/foundation/release/update-transaction.d.ts +31 -0
- package/dist/src/foundation/release/update-transaction.d.ts.map +1 -0
- package/dist/src/foundation/release/update-transaction.js +88 -0
- package/dist/src/foundation/release/update-transaction.js.map +1 -0
- package/dist/src/foundation/release/update.d.ts +55 -0
- package/dist/src/foundation/release/update.d.ts.map +1 -0
- package/dist/src/foundation/release/update.js +316 -0
- package/dist/src/foundation/release/update.js.map +1 -0
- package/dist/src/foundation/storage/control-store.d.ts +61 -0
- package/dist/src/foundation/storage/control-store.d.ts.map +1 -0
- package/dist/src/foundation/storage/control-store.js +459 -0
- package/dist/src/foundation/storage/control-store.js.map +1 -0
- package/dist/src/foundation/storage/index.d.ts +2 -0
- package/dist/src/foundation/storage/index.d.ts.map +1 -0
- package/dist/src/foundation/storage/index.js +2 -0
- package/dist/src/foundation/storage/index.js.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/backpressure.d.ts +47 -0
- package/dist/src/foundation/structured-agent-runtime/backpressure.d.ts.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/backpressure.js +119 -0
- package/dist/src/foundation/structured-agent-runtime/backpressure.js.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/commands.d.ts +53 -0
- package/dist/src/foundation/structured-agent-runtime/commands.d.ts.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/commands.js +165 -0
- package/dist/src/foundation/structured-agent-runtime/commands.js.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/handshake.d.ts +42 -0
- package/dist/src/foundation/structured-agent-runtime/handshake.d.ts.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/handshake.js +151 -0
- package/dist/src/foundation/structured-agent-runtime/handshake.js.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/index.d.ts +6 -0
- package/dist/src/foundation/structured-agent-runtime/index.d.ts.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/index.js +6 -0
- package/dist/src/foundation/structured-agent-runtime/index.js.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/reconnection.d.ts +38 -0
- package/dist/src/foundation/structured-agent-runtime/reconnection.d.ts.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/reconnection.js +130 -0
- package/dist/src/foundation/structured-agent-runtime/reconnection.js.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/state.d.ts +57 -0
- package/dist/src/foundation/structured-agent-runtime/state.d.ts.map +1 -0
- package/dist/src/foundation/structured-agent-runtime/state.js +119 -0
- package/dist/src/foundation/structured-agent-runtime/state.js.map +1 -0
- package/dist/src/foundation/supervision/index.d.ts +4 -0
- package/dist/src/foundation/supervision/index.d.ts.map +1 -0
- package/dist/src/foundation/supervision/index.js +4 -0
- package/dist/src/foundation/supervision/index.js.map +1 -0
- package/dist/src/foundation/supervision/main.d.ts +2 -0
- package/dist/src/foundation/supervision/main.d.ts.map +1 -0
- package/dist/src/foundation/supervision/main.js +40 -0
- package/dist/src/foundation/supervision/main.js.map +1 -0
- package/dist/src/foundation/supervision/paths.d.ts +2 -0
- package/dist/src/foundation/supervision/paths.d.ts.map +1 -0
- package/dist/src/foundation/supervision/paths.js +2 -0
- package/dist/src/foundation/supervision/paths.js.map +1 -0
- package/dist/src/foundation/supervision/server.d.ts +21 -0
- package/dist/src/foundation/supervision/server.d.ts.map +1 -0
- package/dist/src/foundation/supervision/server.js +283 -0
- package/dist/src/foundation/supervision/server.js.map +1 -0
- package/dist/src/foundation/transparent-terminal/command-resolution.d.ts +14 -0
- package/dist/src/foundation/transparent-terminal/command-resolution.d.ts.map +1 -0
- package/dist/src/foundation/transparent-terminal/command-resolution.js +70 -0
- package/dist/src/foundation/transparent-terminal/command-resolution.js.map +1 -0
- package/dist/src/foundation/transparent-terminal/foreground-broker.d.ts +33 -0
- package/dist/src/foundation/transparent-terminal/foreground-broker.d.ts.map +1 -0
- package/dist/src/foundation/transparent-terminal/foreground-broker.js +88 -0
- package/dist/src/foundation/transparent-terminal/foreground-broker.js.map +1 -0
- package/dist/src/foundation/transparent-terminal/index.d.ts +4 -0
- package/dist/src/foundation/transparent-terminal/index.d.ts.map +1 -0
- package/dist/src/foundation/transparent-terminal/index.js +4 -0
- package/dist/src/foundation/transparent-terminal/index.js.map +1 -0
- package/dist/src/foundation/transparent-terminal/main.d.ts +10 -0
- package/dist/src/foundation/transparent-terminal/main.d.ts.map +1 -0
- package/dist/src/foundation/transparent-terminal/main.js +107 -0
- package/dist/src/foundation/transparent-terminal/main.js.map +1 -0
- package/dist/src/foundation/transparent-terminal/native-launcher.d.ts +26 -0
- package/dist/src/foundation/transparent-terminal/native-launcher.d.ts.map +1 -0
- package/dist/src/foundation/transparent-terminal/native-launcher.js +147 -0
- package/dist/src/foundation/transparent-terminal/native-launcher.js.map +1 -0
- package/dist/src/foundation/workspace-contracts/index.d.ts +3 -0
- package/dist/src/foundation/workspace-contracts/index.d.ts.map +1 -0
- package/dist/src/foundation/workspace-contracts/index.js +3 -0
- package/dist/src/foundation/workspace-contracts/index.js.map +1 -0
- package/dist/src/foundation/workspace-contracts/model.d.ts +249 -0
- package/dist/src/foundation/workspace-contracts/model.d.ts.map +1 -0
- package/dist/src/foundation/workspace-contracts/model.js +3 -0
- package/dist/src/foundation/workspace-contracts/model.js.map +1 -0
- package/dist/src/foundation/workspace-contracts/validation.d.ts +14 -0
- package/dist/src/foundation/workspace-contracts/validation.d.ts.map +1 -0
- package/dist/src/foundation/workspace-contracts/validation.js +336 -0
- package/dist/src/foundation/workspace-contracts/validation.js.map +1 -0
- package/docs/architecture/boundaries.md +46 -0
- package/docs/architecture/project-structure.md +81 -0
- package/docs/architecture/resource-and-data-policy.md +55 -0
- package/docs/architecture/terminal-host-proof-gate.md +32 -0
- package/docs/architecture/terminal-host-provenance.md +69 -0
- package/docs/architecture/terminal-host-spike-evidence.md +39 -0
- package/docs/architecture/toolchain.md +66 -0
- package/docs/features/launch-profiles.md +50 -0
- package/docs/manual-transparent-checkpoint.md +53 -0
- package/package.json +73 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { createConnection, createServer } from "node:net";
|
|
4
|
+
import { platform } from "node:os";
|
|
5
|
+
import { assertNativeProcessIdentity, assertTransparentTerminalLaunchProfile, } from "../lifecycle/index.js";
|
|
6
|
+
import { encodeFrame, isCommandMessage, isControlHello, LineFrameDecoder, localControlHello, MAX_CONTROL_FRAME_BYTES, negotiateControlFeatures } from "../protocol/index.js";
|
|
7
|
+
import { ControlStore } from "../storage/index.js";
|
|
8
|
+
import { resolveAddOnePaths } from "./paths.js";
|
|
9
|
+
export class SupervisorServer {
|
|
10
|
+
store;
|
|
11
|
+
release;
|
|
12
|
+
terminateProcess;
|
|
13
|
+
id = randomUUID();
|
|
14
|
+
bootNonce;
|
|
15
|
+
pidStartIdentity = `${process.pid}:${Math.floor(Date.now() - process.uptime() * 1_000)}`;
|
|
16
|
+
startedAt = new Date().toISOString();
|
|
17
|
+
paths;
|
|
18
|
+
#server = null;
|
|
19
|
+
#foregroundLease;
|
|
20
|
+
#revision = 0;
|
|
21
|
+
#clients = new Set();
|
|
22
|
+
#results = new Map();
|
|
23
|
+
#metadataWrites = Promise.resolve();
|
|
24
|
+
constructor(store, paths = resolveAddOnePaths(), release, bootNonce = randomUUID(), terminateProcess = code => process.exit(code)) {
|
|
25
|
+
this.store = store;
|
|
26
|
+
this.release = release;
|
|
27
|
+
this.terminateProcess = terminateProcess;
|
|
28
|
+
this.bootNonce = bootNonce;
|
|
29
|
+
this.paths = paths;
|
|
30
|
+
this.#foregroundLease = store.loadLiveForegroundTerminalLease();
|
|
31
|
+
}
|
|
32
|
+
snapshot() {
|
|
33
|
+
return { revision: this.#revision };
|
|
34
|
+
}
|
|
35
|
+
async listen() {
|
|
36
|
+
if (this.#server)
|
|
37
|
+
throw new Error("supervisor is already listening");
|
|
38
|
+
await mkdir(this.paths.runtimeDir, { recursive: true, mode: 0o700 });
|
|
39
|
+
if (platform() !== "win32") {
|
|
40
|
+
if (await endpointIsLive(this.paths.endpoint))
|
|
41
|
+
throw new Error(`an AddOne supervisor already owns ${this.paths.endpoint}`);
|
|
42
|
+
await rm(this.paths.endpoint, { force: true });
|
|
43
|
+
}
|
|
44
|
+
const server = createServer(socket => this.#attach(socket));
|
|
45
|
+
this.#server = server;
|
|
46
|
+
await new Promise((resolve, reject) => {
|
|
47
|
+
server.once("error", reject);
|
|
48
|
+
server.listen(this.paths.endpoint, () => {
|
|
49
|
+
server.off("error", reject);
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
await this.#writeEndpointMetadata();
|
|
54
|
+
}
|
|
55
|
+
async close(stopAgents = false) {
|
|
56
|
+
if (stopAgents && this.#foregroundLease)
|
|
57
|
+
this.#releaseForegroundLeaseForUpdate();
|
|
58
|
+
for (const client of this.#clients)
|
|
59
|
+
client.destroy();
|
|
60
|
+
if (this.#server)
|
|
61
|
+
await new Promise(resolve => this.#server?.close(() => resolve()));
|
|
62
|
+
this.#server = null;
|
|
63
|
+
this.store.close();
|
|
64
|
+
await this.#metadataWrites;
|
|
65
|
+
await rm(this.paths.endpointMetadataPath, { force: true });
|
|
66
|
+
if (platform() !== "win32")
|
|
67
|
+
await rm(this.paths.endpoint, { force: true });
|
|
68
|
+
}
|
|
69
|
+
async closeForReleaseReplacement(stopAgents) {
|
|
70
|
+
await this.close(stopAgents);
|
|
71
|
+
this.terminateProcess(0);
|
|
72
|
+
}
|
|
73
|
+
#attach(socket) {
|
|
74
|
+
socket.setNoDelay(true);
|
|
75
|
+
const decoder = new LineFrameDecoder();
|
|
76
|
+
let welcomed = false;
|
|
77
|
+
socket.on("data", chunk => {
|
|
78
|
+
try {
|
|
79
|
+
for (const value of decoder.push(chunk)) {
|
|
80
|
+
if (!welcomed) {
|
|
81
|
+
if (isMessageType(value, "identity-probe")) {
|
|
82
|
+
this.#send(socket, { type: "identity", supervisorId: this.id, bootNonce: this.bootNonce, pidStartIdentity: this.pidStartIdentity, releaseId: this.release.releaseId });
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (isMessageType(value, "release-idle-ownership")) {
|
|
86
|
+
const request = value;
|
|
87
|
+
const identityMatches = request.bootNonce === this.bootNonce && typeof request.candidateReleaseId === "string";
|
|
88
|
+
const released = identityMatches && this.#foregroundLease === null;
|
|
89
|
+
this.#send(socket, {
|
|
90
|
+
type: "release-ownership-result",
|
|
91
|
+
released,
|
|
92
|
+
reason: released ? "idle cohort released ownership"
|
|
93
|
+
: identityMatches ? "foreground terminal lease is still live" : "boot nonce or candidate release mismatch",
|
|
94
|
+
liveGenerationIds: this.#liveGenerationIds(),
|
|
95
|
+
});
|
|
96
|
+
if (released)
|
|
97
|
+
setTimeout(() => void this.closeForReleaseReplacement(false), 25);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (isMessageType(value, "release-update-ownership")) {
|
|
101
|
+
const request = value;
|
|
102
|
+
const accepted = request.bootNonce === this.bootNonce && typeof request.targetVersion === "string";
|
|
103
|
+
this.#send(socket, {
|
|
104
|
+
type: "release-update-result",
|
|
105
|
+
accepted,
|
|
106
|
+
reason: accepted ? "verified AddOne owner accepted immediate update shutdown" : "boot nonce or target version mismatch",
|
|
107
|
+
liveGenerationIds: this.#liveGenerationIds(),
|
|
108
|
+
});
|
|
109
|
+
if (accepted)
|
|
110
|
+
setTimeout(() => void this.closeForReleaseReplacement(true), 25);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (!isControlHello(value)) {
|
|
114
|
+
this.#send(socket, { type: "protocol-error", code: "invalid-control-handshake", message: "the first message must be a valid AddOne control feature handshake", diagnostics: { received: value } });
|
|
115
|
+
socket.destroy();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const serverHello = localControlHello();
|
|
119
|
+
const negotiation = negotiateControlFeatures(value, serverHello);
|
|
120
|
+
if (!negotiation.ok) {
|
|
121
|
+
this.#send(socket, { type: "protocol-error", code: "incompatible-control-features", message: negotiation.diagnostic, diagnostics: negotiation });
|
|
122
|
+
socket.destroy();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
welcomed = true;
|
|
126
|
+
this.#clients.add(socket);
|
|
127
|
+
this.#send(socket, { type: "server-hello", ...serverHello, releaseId: this.release.releaseId, supervisorId: this.id, bootNonce: this.bootNonce, pidStartIdentity: this.pidStartIdentity, negotiatedFeatures: negotiation.negotiatedFeatures, snapshot: this.snapshot() });
|
|
128
|
+
}
|
|
129
|
+
else if (isCommandMessage(value)) {
|
|
130
|
+
void this.#execute(value.command, socket);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
this.#send(socket, { type: "protocol-error", code: "framing-error", message: error instanceof Error ? error.message : String(error) });
|
|
136
|
+
socket.destroy();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
socket.on("close", () => this.#clients.delete(socket));
|
|
140
|
+
socket.on("error", () => this.#clients.delete(socket));
|
|
141
|
+
}
|
|
142
|
+
async #execute(command, socket) {
|
|
143
|
+
const recorded = this.#results.get(command.requestId);
|
|
144
|
+
if (recorded) {
|
|
145
|
+
this.#send(socket, { type: "command-result", result: recorded });
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
let result;
|
|
149
|
+
try {
|
|
150
|
+
if (command.type === "acquire-foreground-terminal-lease")
|
|
151
|
+
this.#acquireForegroundLease(command);
|
|
152
|
+
if (command.type === "activate-foreground-terminal-lease")
|
|
153
|
+
this.#activateForegroundLease(command);
|
|
154
|
+
if (command.type === "heartbeat-foreground-terminal-lease")
|
|
155
|
+
this.#heartbeatForegroundLease(command);
|
|
156
|
+
if (command.type === "release-foreground-terminal-lease")
|
|
157
|
+
this.#releaseForegroundLease(command);
|
|
158
|
+
if (command.type === "resynchronize")
|
|
159
|
+
this.#send(socket, { type: "snapshot", snapshot: this.snapshot() });
|
|
160
|
+
await this.#metadataWrites;
|
|
161
|
+
result = { requestId: command.requestId, ok: true, revision: this.#revision };
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
165
|
+
const code = /not found/i.test(message) ? "not-found" : "driver-error";
|
|
166
|
+
result = { requestId: command.requestId, ok: false, revision: this.#revision, error: { code, message } };
|
|
167
|
+
}
|
|
168
|
+
this.#results.set(command.requestId, result);
|
|
169
|
+
this.#send(socket, { type: "command-result", result });
|
|
170
|
+
}
|
|
171
|
+
#acquireForegroundLease(command) {
|
|
172
|
+
if (!command.leaseId || !command.ownerId)
|
|
173
|
+
throw new Error("foreground lease and owner identities are required");
|
|
174
|
+
assertTransparentTerminalLaunchProfile(command.profile);
|
|
175
|
+
const lease = {
|
|
176
|
+
id: command.leaseId,
|
|
177
|
+
ownerId: command.ownerId,
|
|
178
|
+
profile: command.profile,
|
|
179
|
+
state: "requested",
|
|
180
|
+
generationId: null,
|
|
181
|
+
processIdentity: null,
|
|
182
|
+
acquiredAt: new Date().toISOString(),
|
|
183
|
+
heartbeatAt: null,
|
|
184
|
+
releasedAt: null,
|
|
185
|
+
outcome: null,
|
|
186
|
+
};
|
|
187
|
+
this.store.acquireForegroundTerminalLease(lease);
|
|
188
|
+
this.#foregroundLease = lease;
|
|
189
|
+
void this.#writeEndpointMetadata();
|
|
190
|
+
}
|
|
191
|
+
#activateForegroundLease(command) {
|
|
192
|
+
assertNativeProcessIdentity(command.processIdentity);
|
|
193
|
+
if (!this.#foregroundLease || this.#foregroundLease.id !== command.leaseId || this.#foregroundLease.state !== "requested")
|
|
194
|
+
throw new Error("foreground terminal lease not found or is not requested");
|
|
195
|
+
const heartbeatAt = new Date().toISOString();
|
|
196
|
+
if (!this.store.activateForegroundTerminalLease(command.leaseId, command.generationId, command.processIdentity, heartbeatAt))
|
|
197
|
+
throw new Error("foreground terminal lease activation was rejected");
|
|
198
|
+
this.#foregroundLease = { ...this.#foregroundLease, state: "active", generationId: command.generationId, processIdentity: command.processIdentity, heartbeatAt };
|
|
199
|
+
void this.#writeEndpointMetadata();
|
|
200
|
+
}
|
|
201
|
+
#heartbeatForegroundLease(command) {
|
|
202
|
+
assertNativeProcessIdentity(command.processIdentity);
|
|
203
|
+
if (!this.#foregroundLease || this.#foregroundLease.id !== command.leaseId || this.#foregroundLease.state !== "active")
|
|
204
|
+
throw new Error("active foreground terminal lease not found");
|
|
205
|
+
const heartbeatAt = new Date().toISOString();
|
|
206
|
+
if (!this.store.heartbeatForegroundTerminalLease(command.leaseId, command.processIdentity, heartbeatAt))
|
|
207
|
+
throw new Error("foreground terminal lease ownership mismatch");
|
|
208
|
+
this.#foregroundLease = { ...this.#foregroundLease, heartbeatAt };
|
|
209
|
+
}
|
|
210
|
+
#releaseForegroundLease(command) {
|
|
211
|
+
if (command.processIdentity)
|
|
212
|
+
assertNativeProcessIdentity(command.processIdentity);
|
|
213
|
+
if (!this.#foregroundLease || this.#foregroundLease.id !== command.leaseId)
|
|
214
|
+
throw new Error("foreground terminal lease not found");
|
|
215
|
+
const releasedAt = new Date().toISOString();
|
|
216
|
+
if (!this.store.releaseForegroundTerminalLease(command.leaseId, command.processIdentity, command.outcome, releasedAt))
|
|
217
|
+
throw new Error("foreground terminal lease ownership mismatch");
|
|
218
|
+
this.#foregroundLease = null;
|
|
219
|
+
void this.#writeEndpointMetadata();
|
|
220
|
+
}
|
|
221
|
+
#releaseForegroundLeaseForUpdate() {
|
|
222
|
+
const lease = this.#foregroundLease;
|
|
223
|
+
if (!lease)
|
|
224
|
+
return;
|
|
225
|
+
const outcome = { kind: "stopped", reason: "update" };
|
|
226
|
+
if (!this.store.releaseForegroundTerminalLease(lease.id, lease.processIdentity, outcome, new Date().toISOString()))
|
|
227
|
+
throw new Error("foreground terminal lease update shutdown was rejected");
|
|
228
|
+
this.#foregroundLease = null;
|
|
229
|
+
}
|
|
230
|
+
#liveGenerationIds() {
|
|
231
|
+
return this.#foregroundLease?.generationId ? [this.#foregroundLease.generationId] : [];
|
|
232
|
+
}
|
|
233
|
+
#writeEndpointMetadata() {
|
|
234
|
+
const metadata = {
|
|
235
|
+
...localControlHello(this.release.releaseId),
|
|
236
|
+
supervisorId: this.id,
|
|
237
|
+
pid: process.pid,
|
|
238
|
+
pidStartIdentity: this.pidStartIdentity,
|
|
239
|
+
bootNonce: this.bootNonce,
|
|
240
|
+
endpoint: this.paths.endpoint,
|
|
241
|
+
databasePath: this.paths.databasePath,
|
|
242
|
+
startedAt: this.startedAt,
|
|
243
|
+
releaseId: this.release.releaseId,
|
|
244
|
+
releaseRoot: this.release.releaseRoot,
|
|
245
|
+
contentDigest: this.release.contentDigest,
|
|
246
|
+
ownership: {
|
|
247
|
+
state: this.#foregroundLease ? "busy" : "idle",
|
|
248
|
+
liveGenerationIds: this.#liveGenerationIds(),
|
|
249
|
+
nonResumableGenerationIds: this.#liveGenerationIds(),
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
const temporary = `${this.paths.endpointMetadataPath}.${process.pid}.tmp`;
|
|
253
|
+
this.#metadataWrites = this.#metadataWrites.then(async () => {
|
|
254
|
+
await writeFile(temporary, JSON.stringify(metadata, null, 2), { mode: 0o600 });
|
|
255
|
+
await rename(temporary, this.paths.endpointMetadataPath);
|
|
256
|
+
});
|
|
257
|
+
return this.#metadataWrites;
|
|
258
|
+
}
|
|
259
|
+
#send(socket, message) {
|
|
260
|
+
if (socket.destroyed)
|
|
261
|
+
return;
|
|
262
|
+
const frame = encodeFrame(message);
|
|
263
|
+
const bytes = Buffer.byteLength(frame, "utf8");
|
|
264
|
+
if (bytes > MAX_CONTROL_FRAME_BYTES || socket.writableLength + bytes > MAX_CONTROL_FRAME_BYTES * 2) {
|
|
265
|
+
socket.destroy(new Error("slow client exceeded the bounded control/output queue"));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
socket.write(frame);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function isMessageType(value, type) {
|
|
272
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === type;
|
|
273
|
+
}
|
|
274
|
+
async function endpointIsLive(endpoint) {
|
|
275
|
+
return await new Promise(resolve => {
|
|
276
|
+
const socket = createConnection(endpoint);
|
|
277
|
+
const done = (live) => { socket.destroy(); resolve(live); };
|
|
278
|
+
socket.once("connect", () => done(true));
|
|
279
|
+
socket.once("error", () => done(false));
|
|
280
|
+
setTimeout(() => done(false), 250).unref();
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/foundation/supervision/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAA4B,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,GAKvC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,wBAAwB,EAAsB,MAAM,sBAAsB,CAAC;AAEjM,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,YAAY,CAAC;AAElE,MAAM,OAAO,gBAAgB;IAchB;IAEA;IAEA;IAjBF,EAAE,GAAG,UAAU,EAAE,CAAC;IAClB,SAAS,CAAS;IAClB,gBAAgB,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IACzF,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,KAAK,CAAc;IAC5B,OAAO,GAAkB,IAAI,CAAC;IAC9B,gBAAgB,CAAiC;IACjD,SAAS,GAAG,CAAC,CAAC;IACd,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7B,QAAQ,GAAG,IAAI,GAAG,EAAy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AAc,CAAC,QAAgB;IAC5C,OAAO,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QACjC,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,CAAC,IAAa,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ResolvedTransparentCommand {
|
|
2
|
+
readonly executable: string;
|
|
3
|
+
readonly arguments: readonly string[];
|
|
4
|
+
readonly source: "exact" | "path" | "npm-windows-shim";
|
|
5
|
+
}
|
|
6
|
+
export interface TransparentCommandResolutionOptions {
|
|
7
|
+
readonly platform?: NodeJS.Platform;
|
|
8
|
+
readonly cwd: string;
|
|
9
|
+
readonly environment: Readonly<Record<string, string>>;
|
|
10
|
+
readonly nodeExecutable?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Resolve a command without invoking a command interpreter. */
|
|
13
|
+
export declare function resolveTransparentCommand(executable: string, arguments_: readonly string[], options: TransparentCommandResolutionOptions): Promise<ResolvedTransparentCommand>;
|
|
14
|
+
//# sourceMappingURL=command-resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-resolution.d.ts","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/command-resolution.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,kBAAkB,CAAC;CACxD;AAED,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,gEAAgE;AAChE,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,0BAA0B,CAAC,CAKrC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import { delimiter, extname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
/** Resolve a command without invoking a command interpreter. */
|
|
4
|
+
export async function resolveTransparentCommand(executable, arguments_, options) {
|
|
5
|
+
const platform = options.platform ?? process.platform;
|
|
6
|
+
return platform === "win32"
|
|
7
|
+
? await resolveWindowsCommand(executable, arguments_, options)
|
|
8
|
+
: { executable, arguments: [...arguments_], source: "exact" };
|
|
9
|
+
}
|
|
10
|
+
async function resolveWindowsCommand(command, commandArguments, options) {
|
|
11
|
+
const resolved = await resolveWindowsPathCommand(command, options.cwd, options.environment);
|
|
12
|
+
const selected = resolved ?? throwCommandNotFound(command);
|
|
13
|
+
if (extname(selected).toLowerCase() !== ".cmd") {
|
|
14
|
+
return { executable: selected, arguments: [...commandArguments], source: "path" };
|
|
15
|
+
}
|
|
16
|
+
return await unwrapNpmWindowsShim(selected, commandArguments, options.nodeExecutable ?? process.execPath);
|
|
17
|
+
}
|
|
18
|
+
async function resolveWindowsPathCommand(executable, cwd, environment) {
|
|
19
|
+
const hasPath = isAbsolute(executable) || executable.includes("/") || executable.includes("\\");
|
|
20
|
+
const roots = hasPath ? [cwd] : windowsPath(environment).split(delimiter).filter(Boolean);
|
|
21
|
+
const extension = extname(executable);
|
|
22
|
+
const extensions = extension ? [""] : windowsExecutableExtensions(environment);
|
|
23
|
+
for (const root of roots) {
|
|
24
|
+
const base = hasPath ? resolve(cwd, executable) : resolve(root.replace(/^"|"$/g, ""), executable);
|
|
25
|
+
for (const suffix of extensions) {
|
|
26
|
+
const candidate = `${base}${suffix}`;
|
|
27
|
+
if (await isFile(candidate))
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
async function unwrapNpmWindowsShim(shimPath, arguments_, fallbackNodeExecutable) {
|
|
34
|
+
const source = (await readFile(shimPath, "utf8")).replace(/^\uFEFF/, "");
|
|
35
|
+
const targetMatch = source.match(/"%_prog%"\s+"%dp0%\\([^"\r\n]+)"\s+%\*/i);
|
|
36
|
+
if (!targetMatch?.[1]) {
|
|
37
|
+
throw Object.assign(new Error(`transparent launch refuses arbitrary Windows command script ${shimPath}; configure an executable binary instead`), { code: "UNSUPPORTED_WINDOWS_COMMAND_SHIM" });
|
|
38
|
+
}
|
|
39
|
+
const shimRoot = resolve(shimPath, "..");
|
|
40
|
+
const target = resolve(shimRoot, targetMatch[1].replaceAll("\\", "/"));
|
|
41
|
+
if (!await isFile(target))
|
|
42
|
+
throw Object.assign(new Error(`npm command shim target is missing: ${target}`), { code: "ENOENT" });
|
|
43
|
+
const localNode = resolve(shimRoot, "node.exe");
|
|
44
|
+
const nodeExecutable = await isFile(localNode) ? localNode : fallbackNodeExecutable;
|
|
45
|
+
return {
|
|
46
|
+
executable: nodeExecutable,
|
|
47
|
+
arguments: [target, ...arguments_],
|
|
48
|
+
source: "npm-windows-shim",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function throwCommandNotFound(command) {
|
|
52
|
+
throw Object.assign(new Error(`spawn ${command} ENOENT`), { code: "ENOENT" });
|
|
53
|
+
}
|
|
54
|
+
function windowsPath(environment) {
|
|
55
|
+
return environment.Path ?? environment.PATH ?? "";
|
|
56
|
+
}
|
|
57
|
+
function windowsExecutableExtensions(environment) {
|
|
58
|
+
const source = environment.PATHEXT ?? ".COM;.EXE;.BAT;.CMD";
|
|
59
|
+
return source.split(";").filter(Boolean).map(value => value.startsWith(".") ? value : `.${value}`);
|
|
60
|
+
}
|
|
61
|
+
async function isFile(path) {
|
|
62
|
+
try {
|
|
63
|
+
await access(path);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=command-resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-resolution.js","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/command-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepE,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,UAAkB,EAClB,UAA6B,EAC7B,OAA4C;IAE5C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IACtD,OAAO,QAAQ,KAAK,OAAO;QACzB,CAAC,CAAC,MAAM,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC;QAC9D,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,U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CommandResult, ForegroundTerminalLeaseId, GenerationId, NativeProcessIdentity, RequestId, SupervisorCommand, TransparentTerminalLaunchProfile, TransparentTerminalLifecycleOutcome } from "../lifecycle/index.js";
|
|
2
|
+
export interface ForegroundLeaseControl {
|
|
3
|
+
command(command: SupervisorCommand): Promise<CommandResult>;
|
|
4
|
+
}
|
|
5
|
+
export type TransparentStopReason = "owner-disconnect" | "user-request" | "update";
|
|
6
|
+
export interface TransparentChildHandle {
|
|
7
|
+
readonly processIdentity: NativeProcessIdentity;
|
|
8
|
+
readonly outcome: Promise<TransparentTerminalLifecycleOutcome>;
|
|
9
|
+
stop(reason: TransparentStopReason): Promise<TransparentTerminalLifecycleOutcome>;
|
|
10
|
+
}
|
|
11
|
+
export interface TransparentNativeLauncher {
|
|
12
|
+
launch(profile: TransparentTerminalLaunchProfile): Promise<TransparentChildHandle>;
|
|
13
|
+
}
|
|
14
|
+
export interface ForegroundBrokerRequest {
|
|
15
|
+
readonly leaseId: ForegroundTerminalLeaseId;
|
|
16
|
+
readonly generationId: GenerationId;
|
|
17
|
+
readonly ownerId: string;
|
|
18
|
+
readonly profile: TransparentTerminalLaunchProfile;
|
|
19
|
+
readonly stopRequested?: Promise<TransparentStopReason>;
|
|
20
|
+
}
|
|
21
|
+
export interface ForegroundBrokerResult {
|
|
22
|
+
readonly leaseId: ForegroundTerminalLeaseId;
|
|
23
|
+
readonly generationId: GenerationId;
|
|
24
|
+
readonly processIdentity: NativeProcessIdentity | null;
|
|
25
|
+
readonly outcome: TransparentTerminalLifecycleOutcome;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Coordinates ownership around one natively attached child. Ordinary terminal
|
|
29
|
+
* data never enters this object: the launcher owns native attachment and this
|
|
30
|
+
* broker observes only process identity and the final lifecycle outcome.
|
|
31
|
+
*/
|
|
32
|
+
export declare function runForegroundBroker(request: ForegroundBrokerRequest, control: ForegroundLeaseControl, launcher: TransparentNativeLauncher, createRequestId: () => RequestId): Promise<ForegroundBrokerResult>;
|
|
33
|
+
//# sourceMappingURL=foreground-broker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreground-broker.d.ts","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/foreground-broker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEnF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC/D,IAAI,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;CACnF;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,gCAAgC,CAAC;IACnD,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACvD,QAAQ,CAAC,OAAO,EAAE,mCAAmC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,yBAAyB,EACnC,eAAe,EAAE,MAAM,SAAS,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAgEjC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { assertNativeProcessIdentity, assertTransparentTerminalLaunchProfile } from "../lifecycle/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Coordinates ownership around one natively attached child. Ordinary terminal
|
|
4
|
+
* data never enters this object: the launcher owns native attachment and this
|
|
5
|
+
* broker observes only process identity and the final lifecycle outcome.
|
|
6
|
+
*/
|
|
7
|
+
export async function runForegroundBroker(request, control, launcher, createRequestId) {
|
|
8
|
+
assertRequest(request);
|
|
9
|
+
await requireAccepted(control, {
|
|
10
|
+
type: "acquire-foreground-terminal-lease",
|
|
11
|
+
requestId: createRequestId(),
|
|
12
|
+
leaseId: request.leaseId,
|
|
13
|
+
ownerId: request.ownerId,
|
|
14
|
+
profile: request.profile,
|
|
15
|
+
});
|
|
16
|
+
let handle;
|
|
17
|
+
try {
|
|
18
|
+
handle = await launcher.launch(request.profile);
|
|
19
|
+
assertNativeProcessIdentity(handle.processIdentity);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const outcome = {
|
|
23
|
+
kind: "spawn-error",
|
|
24
|
+
message: errorMessage(error),
|
|
25
|
+
code: errorCode(error),
|
|
26
|
+
};
|
|
27
|
+
await requireAccepted(control, {
|
|
28
|
+
type: "release-foreground-terminal-lease",
|
|
29
|
+
requestId: createRequestId(),
|
|
30
|
+
leaseId: request.leaseId,
|
|
31
|
+
processIdentity: null,
|
|
32
|
+
outcome,
|
|
33
|
+
});
|
|
34
|
+
return { leaseId: request.leaseId, generationId: request.generationId, processIdentity: null, outcome };
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
await requireAccepted(control, {
|
|
38
|
+
type: "activate-foreground-terminal-lease",
|
|
39
|
+
requestId: createRequestId(),
|
|
40
|
+
leaseId: request.leaseId,
|
|
41
|
+
generationId: request.generationId,
|
|
42
|
+
processIdentity: handle.processIdentity,
|
|
43
|
+
});
|
|
44
|
+
const outcome = request.stopRequested
|
|
45
|
+
? await Promise.race([handle.outcome, request.stopRequested.then(async (reason) => await handle.stop(reason))])
|
|
46
|
+
: await handle.outcome;
|
|
47
|
+
await requireAccepted(control, {
|
|
48
|
+
type: "release-foreground-terminal-lease",
|
|
49
|
+
requestId: createRequestId(),
|
|
50
|
+
leaseId: request.leaseId,
|
|
51
|
+
processIdentity: handle.processIdentity,
|
|
52
|
+
outcome,
|
|
53
|
+
});
|
|
54
|
+
return { leaseId: request.leaseId, generationId: request.generationId, processIdentity: handle.processIdentity, outcome };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const outcome = {
|
|
58
|
+
kind: "broker-error",
|
|
59
|
+
message: errorMessage(error),
|
|
60
|
+
code: errorCode(error),
|
|
61
|
+
};
|
|
62
|
+
await control.command({
|
|
63
|
+
type: "release-foreground-terminal-lease",
|
|
64
|
+
requestId: createRequestId(),
|
|
65
|
+
leaseId: request.leaseId,
|
|
66
|
+
processIdentity: handle.processIdentity,
|
|
67
|
+
outcome,
|
|
68
|
+
}).catch(() => undefined);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function assertRequest(request) {
|
|
73
|
+
if (!request.leaseId || !request.generationId || !request.ownerId)
|
|
74
|
+
throw new TypeError("foreground broker identities are required");
|
|
75
|
+
assertTransparentTerminalLaunchProfile(request.profile);
|
|
76
|
+
}
|
|
77
|
+
async function requireAccepted(control, command) {
|
|
78
|
+
const result = await control.command(command);
|
|
79
|
+
if (!result.ok)
|
|
80
|
+
throw new Error(result.error?.message ?? `supervisor rejected ${command.type}`);
|
|
81
|
+
}
|
|
82
|
+
function errorMessage(error) {
|
|
83
|
+
return error instanceof Error ? error.message : String(error);
|
|
84
|
+
}
|
|
85
|
+
function errorCode(error) {
|
|
86
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : null;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=foreground-broker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foreground-broker.js","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/foreground-broker.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,2BAA2B,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAiC5G;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAgC,EAChC,OAA+B,EAC/B,QAAmC,EACnC,eAAgC;IAEhC,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,eAAe,CAAC,OAAO,EAAE;QAC7B,IAAI,EAAE,mCAAmC;QACzC,SAAS,EAAE,eAAe,EAAE;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,IAAI,MAA8B,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChD,2BAA2B,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAwC;YACnD,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;YAC5B,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC;SACvB,CAAC;QACF,MAAM,eAAe,CAAC,OAAO,EAAE;YAC7B,IAAI,EAAE,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IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type LaunchProfileId } from "../lifecycle/index.js";
|
|
2
|
+
export interface TransparentForegroundOptions {
|
|
3
|
+
readonly environment?: NodeJS.ProcessEnv;
|
|
4
|
+
readonly profileId?: LaunchProfileId;
|
|
5
|
+
readonly cwd?: string;
|
|
6
|
+
readonly executable?: string;
|
|
7
|
+
readonly arguments?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function runTransparentForeground(options?: TransparentForegroundOptions): Promise<number>;
|
|
10
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/foundation/transparent-terminal/main.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,eAAe,EAAyC,MAAM,uBAAuB,CAAC;AAM3H,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED,wBAAsB,wBAAwB,CAAC,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAAC,MAAM,CAAC,CAyB1G"}
|