@cuna_labs/cli 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 +201 -0
- package/NOTICE +9 -0
- package/README.md +169 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/api/capability-evidence.d.ts +19 -0
- package/dist/api/capability-evidence.d.ts.map +1 -0
- package/dist/api/capability-evidence.js +38 -0
- package/dist/api/capability-evidence.js.map +1 -0
- package/dist/api/client.d.ts +167 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +937 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/contracts.d.ts +345 -0
- package/dist/api/contracts.d.ts.map +1 -0
- package/dist/api/contracts.js +976 -0
- package/dist/api/contracts.js.map +1 -0
- package/dist/api/execution-workspaces.d.ts +17 -0
- package/dist/api/execution-workspaces.d.ts.map +1 -0
- package/dist/api/execution-workspaces.js +46 -0
- package/dist/api/execution-workspaces.js.map +1 -0
- package/dist/api/http.d.ts +76 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +838 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/managed-executions.d.ts +37 -0
- package/dist/api/managed-executions.d.ts.map +1 -0
- package/dist/api/managed-executions.js +80 -0
- package/dist/api/managed-executions.js.map +1 -0
- package/dist/api/observer-v2-schema.d.ts +206 -0
- package/dist/api/observer-v2-schema.d.ts.map +1 -0
- package/dist/api/observer-v2-schema.js +264 -0
- package/dist/api/observer-v2-schema.js.map +1 -0
- package/dist/api/observer-v2.d.ts +33 -0
- package/dist/api/observer-v2.d.ts.map +1 -0
- package/dist/api/observer-v2.js +60 -0
- package/dist/api/observer-v2.js.map +1 -0
- package/dist/api/owner-observe-grants-v2-schema.d.ts +678 -0
- package/dist/api/owner-observe-grants-v2-schema.d.ts.map +1 -0
- package/dist/api/owner-observe-grants-v2-schema.js +887 -0
- package/dist/api/owner-observe-grants-v2-schema.js.map +1 -0
- package/dist/api/owner-observe-grants-v2.d.ts +268 -0
- package/dist/api/owner-observe-grants-v2.d.ts.map +1 -0
- package/dist/api/owner-observe-grants-v2.js +604 -0
- package/dist/api/owner-observe-grants-v2.js.map +1 -0
- package/dist/api/provider-v2-schema.d.ts +293 -0
- package/dist/api/provider-v2-schema.d.ts.map +1 -0
- package/dist/api/provider-v2-schema.js +381 -0
- package/dist/api/provider-v2-schema.js.map +1 -0
- package/dist/api/provider-v2.d.ts +55 -0
- package/dist/api/provider-v2.d.ts.map +1 -0
- package/dist/api/provider-v2.js +54 -0
- package/dist/api/provider-v2.js.map +1 -0
- package/dist/api/remote-workspace.d.ts +29 -0
- package/dist/api/remote-workspace.d.ts.map +1 -0
- package/dist/api/remote-workspace.js +62 -0
- package/dist/api/remote-workspace.js.map +1 -0
- package/dist/api/supervisor-live-update.d.ts +248 -0
- package/dist/api/supervisor-live-update.d.ts.map +1 -0
- package/dist/api/supervisor-live-update.js +434 -0
- package/dist/api/supervisor-live-update.js.map +1 -0
- package/dist/api/terminal-reason.d.ts +5 -0
- package/dist/api/terminal-reason.d.ts.map +1 -0
- package/dist/api/terminal-reason.js +12 -0
- package/dist/api/terminal-reason.js.map +1 -0
- package/dist/auth/browser-handoff.d.ts +59 -0
- package/dist/auth/browser-handoff.d.ts.map +1 -0
- package/dist/auth/browser-handoff.js +33 -0
- package/dist/auth/browser-handoff.js.map +1 -0
- package/dist/auth/browser.d.ts +11 -0
- package/dist/auth/browser.d.ts.map +1 -0
- package/dist/auth/browser.js +47 -0
- package/dist/auth/browser.js.map +1 -0
- package/dist/auth/human-client.d.ts +39 -0
- package/dist/auth/human-client.d.ts.map +1 -0
- package/dist/auth/human-client.js +66 -0
- package/dist/auth/human-client.js.map +1 -0
- package/dist/auth/human-contracts.d.ts +52 -0
- package/dist/auth/human-contracts.d.ts.map +1 -0
- package/dist/auth/human-contracts.js +229 -0
- package/dist/auth/human-contracts.js.map +1 -0
- package/dist/auth/human-session.d.ts +48 -0
- package/dist/auth/human-session.d.ts.map +1 -0
- package/dist/auth/human-session.js +902 -0
- package/dist/auth/human-session.js.map +1 -0
- package/dist/auth/onboarding-state.d.ts +31 -0
- package/dist/auth/onboarding-state.d.ts.map +1 -0
- package/dist/auth/onboarding-state.js +52 -0
- package/dist/auth/onboarding-state.js.map +1 -0
- package/dist/auth/pkce.d.ts +15 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +19 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/bin/cuna.d.ts +3 -0
- package/dist/bin/cuna.d.ts.map +1 -0
- package/dist/bin/cuna.js +4 -0
- package/dist/bin/cuna.js.map +1 -0
- package/dist/build-identity.d.ts +20 -0
- package/dist/build-identity.d.ts.map +1 -0
- package/dist/build-identity.js +77 -0
- package/dist/build-identity.js.map +1 -0
- package/dist/cli/command-help.d.ts +9 -0
- package/dist/cli/command-help.d.ts.map +1 -0
- package/dist/cli/command-help.js +324 -0
- package/dist/cli/command-help.js.map +1 -0
- package/dist/cli/help.d.ts +40 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +256 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/output.d.ts +28 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +95 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parser.d.ts +65 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +294 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/process-entrypoint.d.ts +18 -0
- package/dist/cli/process-entrypoint.d.ts.map +1 -0
- package/dist/cli/process-entrypoint.js +26 -0
- package/dist/cli/process-entrypoint.js.map +1 -0
- package/dist/cli/run.d.ts +114 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +1969 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/commands/commands.d.ts +74 -0
- package/dist/commands/commands.d.ts.map +1 -0
- package/dist/commands/commands.js +2814 -0
- package/dist/commands/commands.js.map +1 -0
- package/dist/config/config.d.ts +86 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +323 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/infra-contract-witness.d.ts +29 -0
- package/dist/config/infra-contract-witness.d.ts.map +1 -0
- package/dist/config/infra-contract-witness.js +30 -0
- package/dist/config/infra-contract-witness.js.map +1 -0
- package/dist/core/browser-url.d.ts +2 -0
- package/dist/core/browser-url.d.ts.map +1 -0
- package/dist/core/browser-url.js +20 -0
- package/dist/core/browser-url.js.map +1 -0
- package/dist/core/deployed-wire-compatibility.d.ts +15 -0
- package/dist/core/deployed-wire-compatibility.d.ts.map +1 -0
- package/dist/core/deployed-wire-compatibility.js +15 -0
- package/dist/core/deployed-wire-compatibility.js.map +1 -0
- package/dist/core/errors.d.ts +59 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +82 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/exit-codes.d.ts +68 -0
- package/dist/core/exit-codes.d.ts.map +1 -0
- package/dist/core/exit-codes.js +84 -0
- package/dist/core/exit-codes.js.map +1 -0
- package/dist/core/instant.d.ts +60 -0
- package/dist/core/instant.d.ts.map +1 -0
- package/dist/core/instant.js +90 -0
- package/dist/core/instant.js.map +1 -0
- package/dist/core/namespace.d.ts +171 -0
- package/dist/core/namespace.d.ts.map +1 -0
- package/dist/core/namespace.js +227 -0
- package/dist/core/namespace.js.map +1 -0
- package/dist/core/observation-budget.d.ts +185 -0
- package/dist/core/observation-budget.d.ts.map +1 -0
- package/dist/core/observation-budget.js +209 -0
- package/dist/core/observation-budget.js.map +1 -0
- package/dist/core/product-web.d.ts +81 -0
- package/dist/core/product-web.d.ts.map +1 -0
- package/dist/core/product-web.js +87 -0
- package/dist/core/product-web.js.map +1 -0
- package/dist/core/validation.d.ts +90 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +199 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/credentials/contracts.d.ts +82 -0
- package/dist/credentials/contracts.d.ts.map +1 -0
- package/dist/credentials/contracts.js +2 -0
- package/dist/credentials/contracts.js.map +1 -0
- package/dist/credentials/errors.d.ts +19 -0
- package/dist/credentials/errors.d.ts.map +1 -0
- package/dist/credentials/errors.js +16 -0
- package/dist/credentials/errors.js.map +1 -0
- package/dist/credentials/index.d.ts +6 -0
- package/dist/credentials/index.d.ts.map +1 -0
- package/dist/credentials/index.js +6 -0
- package/dist/credentials/index.js.map +1 -0
- package/dist/credentials/local-session.d.ts +101 -0
- package/dist/credentials/local-session.d.ts.map +1 -0
- package/dist/credentials/local-session.js +839 -0
- package/dist/credentials/local-session.js.map +1 -0
- package/dist/credentials/secret-material.d.ts +17 -0
- package/dist/credentials/secret-material.d.ts.map +1 -0
- package/dist/credentials/secret-material.js +49 -0
- package/dist/credentials/secret-material.js.map +1 -0
- package/dist/credentials/vault.d.ts +41 -0
- package/dist/credentials/vault.d.ts.map +1 -0
- package/dist/credentials/vault.js +719 -0
- package/dist/credentials/vault.js.map +1 -0
- package/dist/daemon/endpoint.d.ts +29 -0
- package/dist/daemon/endpoint.d.ts.map +1 -0
- package/dist/daemon/endpoint.js +66 -0
- package/dist/daemon/endpoint.js.map +1 -0
- package/dist/daemon/journal.d.ts +62 -0
- package/dist/daemon/journal.d.ts.map +1 -0
- package/dist/daemon/journal.js +299 -0
- package/dist/daemon/journal.js.map +1 -0
- package/dist/daemon/lease.d.ts +25 -0
- package/dist/daemon/lease.d.ts.map +1 -0
- package/dist/daemon/lease.js +94 -0
- package/dist/daemon/lease.js.map +1 -0
- package/dist/daemon/lifecycle.d.ts +14 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -0
- package/dist/daemon/lifecycle.js +29 -0
- package/dist/daemon/lifecycle.js.map +1 -0
- package/dist/daemon/protocol.d.ts +65 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +194 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon/supervisor.d.ts +29 -0
- package/dist/daemon/supervisor.d.ts.map +1 -0
- package/dist/daemon/supervisor.js +87 -0
- package/dist/daemon/supervisor.js.map +1 -0
- package/dist/daemon/views.d.ts +31 -0
- package/dist/daemon/views.d.ts.map +1 -0
- package/dist/daemon/views.js +86 -0
- package/dist/daemon/views.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/journey/api-effects.d.ts +59 -0
- package/dist/journey/api-effects.d.ts.map +1 -0
- package/dist/journey/api-effects.js +386 -0
- package/dist/journey/api-effects.js.map +1 -0
- package/dist/journey/derived-identity.d.ts +91 -0
- package/dist/journey/derived-identity.d.ts.map +1 -0
- package/dist/journey/derived-identity.js +123 -0
- package/dist/journey/derived-identity.js.map +1 -0
- package/dist/journey/index.d.ts +6 -0
- package/dist/journey/index.d.ts.map +1 -0
- package/dist/journey/index.js +6 -0
- package/dist/journey/index.js.map +1 -0
- package/dist/journey/intent.d.ts +36 -0
- package/dist/journey/intent.d.ts.map +1 -0
- package/dist/journey/intent.js +191 -0
- package/dist/journey/intent.js.map +1 -0
- package/dist/journey/orchestrator.d.ts +140 -0
- package/dist/journey/orchestrator.d.ts.map +1 -0
- package/dist/journey/orchestrator.js +415 -0
- package/dist/journey/orchestrator.js.map +1 -0
- package/dist/journey/provider-launch-intent.d.ts +12 -0
- package/dist/journey/provider-launch-intent.d.ts.map +1 -0
- package/dist/journey/provider-launch-intent.js +40 -0
- package/dist/journey/provider-launch-intent.js.map +1 -0
- package/dist/journey/remote-workspace.d.ts +34 -0
- package/dist/journey/remote-workspace.d.ts.map +1 -0
- package/dist/journey/remote-workspace.js +91 -0
- package/dist/journey/remote-workspace.js.map +1 -0
- package/dist/journey/root-entry.d.ts +56 -0
- package/dist/journey/root-entry.d.ts.map +1 -0
- package/dist/journey/root-entry.js +19 -0
- package/dist/journey/root-entry.js.map +1 -0
- package/dist/journey/selection.d.ts +165 -0
- package/dist/journey/selection.d.ts.map +1 -0
- package/dist/journey/selection.js +565 -0
- package/dist/journey/selection.js.map +1 -0
- package/dist/journey/session-failure.d.ts +4 -0
- package/dist/journey/session-failure.d.ts.map +1 -0
- package/dist/journey/session-failure.js +28 -0
- package/dist/journey/session-failure.js.map +1 -0
- package/dist/journey/workspace-effects.d.ts +30 -0
- package/dist/journey/workspace-effects.d.ts.map +1 -0
- package/dist/journey/workspace-effects.js +348 -0
- package/dist/journey/workspace-effects.js.map +1 -0
- package/dist/local-actions/broker.d.ts +32 -0
- package/dist/local-actions/broker.d.ts.map +1 -0
- package/dist/local-actions/broker.js +400 -0
- package/dist/local-actions/broker.js.map +1 -0
- package/dist/local-actions/browser-action.d.ts +78 -0
- package/dist/local-actions/browser-action.d.ts.map +1 -0
- package/dist/local-actions/browser-action.js +307 -0
- package/dist/local-actions/browser-action.js.map +1 -0
- package/dist/local-actions/callback-relay.d.ts +45 -0
- package/dist/local-actions/callback-relay.d.ts.map +1 -0
- package/dist/local-actions/callback-relay.js +265 -0
- package/dist/local-actions/callback-relay.js.map +1 -0
- package/dist/local-actions/clipboard.d.ts +3 -0
- package/dist/local-actions/clipboard.d.ts.map +1 -0
- package/dist/local-actions/clipboard.js +18 -0
- package/dist/local-actions/clipboard.js.map +1 -0
- package/dist/local-actions/contracts.d.ts +63 -0
- package/dist/local-actions/contracts.d.ts.map +1 -0
- package/dist/local-actions/contracts.js +18 -0
- package/dist/local-actions/contracts.js.map +1 -0
- package/dist/local-actions/desktop-presentation.d.ts +141 -0
- package/dist/local-actions/desktop-presentation.d.ts.map +1 -0
- package/dist/local-actions/desktop-presentation.js +253 -0
- package/dist/local-actions/desktop-presentation.js.map +1 -0
- package/dist/local-actions/device-selection.d.ts +43 -0
- package/dist/local-actions/device-selection.d.ts.map +1 -0
- package/dist/local-actions/device-selection.js +154 -0
- package/dist/local-actions/device-selection.js.map +1 -0
- package/dist/local-actions/executor.d.ts +49 -0
- package/dist/local-actions/executor.d.ts.map +1 -0
- package/dist/local-actions/executor.js +329 -0
- package/dist/local-actions/executor.js.map +1 -0
- package/dist/local-actions/file-transfers.d.ts +141 -0
- package/dist/local-actions/file-transfers.d.ts.map +1 -0
- package/dist/local-actions/file-transfers.js +446 -0
- package/dist/local-actions/file-transfers.js.map +1 -0
- package/dist/local-actions/foreground-notifications.d.ts +45 -0
- package/dist/local-actions/foreground-notifications.d.ts.map +1 -0
- package/dist/local-actions/foreground-notifications.js +163 -0
- package/dist/local-actions/foreground-notifications.js.map +1 -0
- package/dist/local-actions/git-signing.d.ts +39 -0
- package/dist/local-actions/git-signing.d.ts.map +1 -0
- package/dist/local-actions/git-signing.js +135 -0
- package/dist/local-actions/git-signing.js.map +1 -0
- package/dist/local-actions/index.d.ts +19 -0
- package/dist/local-actions/index.d.ts.map +1 -0
- package/dist/local-actions/index.js +19 -0
- package/dist/local-actions/index.js.map +1 -0
- package/dist/local-actions/local-service-actions.d.ts +87 -0
- package/dist/local-actions/local-service-actions.d.ts.map +1 -0
- package/dist/local-actions/local-service-actions.js +347 -0
- package/dist/local-actions/local-service-actions.js.map +1 -0
- package/dist/local-actions/loopback.d.ts +5 -0
- package/dist/local-actions/loopback.d.ts.map +1 -0
- package/dist/local-actions/loopback.js +15 -0
- package/dist/local-actions/loopback.js.map +1 -0
- package/dist/local-actions/policy-store.d.ts +7 -0
- package/dist/local-actions/policy-store.d.ts.map +1 -0
- package/dist/local-actions/policy-store.js +70 -0
- package/dist/local-actions/policy-store.js.map +1 -0
- package/dist/local-actions/policy.d.ts +21 -0
- package/dist/local-actions/policy.d.ts.map +1 -0
- package/dist/local-actions/policy.js +43 -0
- package/dist/local-actions/policy.js.map +1 -0
- package/dist/local-actions/private-port-forward.d.ts +36 -0
- package/dist/local-actions/private-port-forward.d.ts.map +1 -0
- package/dist/local-actions/private-port-forward.js +154 -0
- package/dist/local-actions/private-port-forward.js.map +1 -0
- package/dist/local-actions/provider-mcp-config.d.ts +101 -0
- package/dist/local-actions/provider-mcp-config.d.ts.map +1 -0
- package/dist/local-actions/provider-mcp-config.js +166 -0
- package/dist/local-actions/provider-mcp-config.js.map +1 -0
- package/dist/local-actions/providers.d.ts +12 -0
- package/dist/local-actions/providers.d.ts.map +1 -0
- package/dist/local-actions/providers.js +42 -0
- package/dist/local-actions/providers.js.map +1 -0
- package/dist/local-actions/schemas.d.ts +4 -0
- package/dist/local-actions/schemas.d.ts.map +1 -0
- package/dist/local-actions/schemas.js +314 -0
- package/dist/local-actions/schemas.js.map +1 -0
- package/dist/local-actions/sensitive-consent.d.ts +32 -0
- package/dist/local-actions/sensitive-consent.d.ts.map +1 -0
- package/dist/local-actions/sensitive-consent.js +47 -0
- package/dist/local-actions/sensitive-consent.js.map +1 -0
- package/dist/machines/command-launch.d.ts +17 -0
- package/dist/machines/command-launch.d.ts.map +1 -0
- package/dist/machines/command-launch.js +52 -0
- package/dist/machines/command-launch.js.map +1 -0
- package/dist/machines/execution-receipt.d.ts +18 -0
- package/dist/machines/execution-receipt.d.ts.map +1 -0
- package/dist/machines/execution-receipt.js +87 -0
- package/dist/machines/execution-receipt.js.map +1 -0
- package/dist/machines/executions-screen.d.ts +6 -0
- package/dist/machines/executions-screen.d.ts.map +1 -0
- package/dist/machines/executions-screen.js +410 -0
- package/dist/machines/executions-screen.js.map +1 -0
- package/dist/machines/explorer.d.ts +75 -0
- package/dist/machines/explorer.d.ts.map +1 -0
- package/dist/machines/explorer.js +1726 -0
- package/dist/machines/explorer.js.map +1 -0
- package/dist/machines/live-supervisor-update.d.ts +325 -0
- package/dist/machines/live-supervisor-update.d.ts.map +1 -0
- package/dist/machines/live-supervisor-update.js +513 -0
- package/dist/machines/live-supervisor-update.js.map +1 -0
- package/dist/machines/machine-first.d.ts +123 -0
- package/dist/machines/machine-first.d.ts.map +1 -0
- package/dist/machines/machine-first.js +119 -0
- package/dist/machines/machine-first.js.map +1 -0
- package/dist/machines/opencode-supervisor.d.ts +51 -0
- package/dist/machines/opencode-supervisor.d.ts.map +1 -0
- package/dist/machines/opencode-supervisor.js +124 -0
- package/dist/machines/opencode-supervisor.js.map +1 -0
- package/dist/machines/pagination.d.ts +4 -0
- package/dist/machines/pagination.d.ts.map +1 -0
- package/dist/machines/pagination.js +7 -0
- package/dist/machines/pagination.js.map +1 -0
- package/dist/machines/provider-availability.d.ts +42 -0
- package/dist/machines/provider-availability.d.ts.map +1 -0
- package/dist/machines/provider-availability.js +82 -0
- package/dist/machines/provider-availability.js.map +1 -0
- package/dist/machines/provider-screen.d.ts +12 -0
- package/dist/machines/provider-screen.d.ts.map +1 -0
- package/dist/machines/provider-screen.js +129 -0
- package/dist/machines/provider-screen.js.map +1 -0
- package/dist/machines/session-actionability.d.ts +86 -0
- package/dist/machines/session-actionability.d.ts.map +1 -0
- package/dist/machines/session-actionability.js +125 -0
- package/dist/machines/session-actionability.js.map +1 -0
- package/dist/machines/session-visibility.d.ts +139 -0
- package/dist/machines/session-visibility.d.ts.map +1 -0
- package/dist/machines/session-visibility.js +109 -0
- package/dist/machines/session-visibility.js.map +1 -0
- package/dist/platform/adapter.d.ts +62 -0
- package/dist/platform/adapter.d.ts.map +1 -0
- package/dist/platform/adapter.js +240 -0
- package/dist/platform/adapter.js.map +1 -0
- package/dist/platform/support.d.ts +12 -0
- package/dist/platform/support.d.ts.map +1 -0
- package/dist/platform/support.js +25 -0
- package/dist/platform/support.js.map +1 -0
- package/dist/pty/contracts.d.ts +45 -0
- package/dist/pty/contracts.d.ts.map +1 -0
- package/dist/pty/contracts.js +2 -0
- package/dist/pty/contracts.js.map +1 -0
- package/dist/pty/evidence-gate.d.ts +14 -0
- package/dist/pty/evidence-gate.d.ts.map +1 -0
- package/dist/pty/evidence-gate.js +35 -0
- package/dist/pty/evidence-gate.js.map +1 -0
- package/dist/pty/index.d.ts +5 -0
- package/dist/pty/index.d.ts.map +1 -0
- package/dist/pty/index.js +5 -0
- package/dist/pty/index.js.map +1 -0
- package/dist/pty/node-host-terminal.d.ts +14 -0
- package/dist/pty/node-host-terminal.d.ts.map +1 -0
- package/dist/pty/node-host-terminal.js +173 -0
- package/dist/pty/node-host-terminal.js.map +1 -0
- package/dist/pty/node-process.d.ts +26 -0
- package/dist/pty/node-process.d.ts.map +1 -0
- package/dist/pty/node-process.js +102 -0
- package/dist/pty/node-process.js.map +1 -0
- package/dist/runtime/api-terminal-control-plane.d.ts +7 -0
- package/dist/runtime/api-terminal-control-plane.d.ts.map +1 -0
- package/dist/runtime/api-terminal-control-plane.js +95 -0
- package/dist/runtime/api-terminal-control-plane.js.map +1 -0
- package/dist/runtime/backoff.d.ts +17 -0
- package/dist/runtime/backoff.d.ts.map +1 -0
- package/dist/runtime/backoff.js +61 -0
- package/dist/runtime/backoff.js.map +1 -0
- package/dist/runtime/boundary.d.ts +171 -0
- package/dist/runtime/boundary.d.ts.map +1 -0
- package/dist/runtime/boundary.js +1858 -0
- package/dist/runtime/boundary.js.map +1 -0
- package/dist/runtime/capability-gate.d.ts +25 -0
- package/dist/runtime/capability-gate.d.ts.map +1 -0
- package/dist/runtime/capability-gate.js +77 -0
- package/dist/runtime/capability-gate.js.map +1 -0
- package/dist/runtime/contracts.d.ts +25 -0
- package/dist/runtime/contracts.d.ts.map +1 -0
- package/dist/runtime/contracts.js +66 -0
- package/dist/runtime/contracts.js.map +1 -0
- package/dist/runtime/errors.d.ts +20 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +22 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +9 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/node-foreground-session.d.ts +50 -0
- package/dist/runtime/node-foreground-session.d.ts.map +1 -0
- package/dist/runtime/node-foreground-session.js +431 -0
- package/dist/runtime/node-foreground-session.js.map +1 -0
- package/dist/runtime/node-websocket-connector.d.ts +6 -0
- package/dist/runtime/node-websocket-connector.d.ts.map +1 -0
- package/dist/runtime/node-websocket-connector.js +344 -0
- package/dist/runtime/node-websocket-connector.js.map +1 -0
- package/dist/runtime/observer-screen.d.ts +6 -0
- package/dist/runtime/observer-screen.d.ts.map +1 -0
- package/dist/runtime/observer-screen.js +144 -0
- package/dist/runtime/observer-screen.js.map +1 -0
- package/dist/runtime/owner-grant-operations.d.ts +136 -0
- package/dist/runtime/owner-grant-operations.d.ts.map +1 -0
- package/dist/runtime/owner-grant-operations.js +216 -0
- package/dist/runtime/owner-grant-operations.js.map +1 -0
- package/dist/runtime/owner-grants-screen.d.ts +40 -0
- package/dist/runtime/owner-grants-screen.d.ts.map +1 -0
- package/dist/runtime/owner-grants-screen.js +987 -0
- package/dist/runtime/owner-grants-screen.js.map +1 -0
- package/dist/runtime/terminal-transport.d.ts +85 -0
- package/dist/runtime/terminal-transport.d.ts.map +1 -0
- package/dist/runtime/terminal-transport.js +152 -0
- package/dist/runtime/terminal-transport.js.map +1 -0
- package/dist/sync/continuous-sync-supervisor.d.ts +107 -0
- package/dist/sync/continuous-sync-supervisor.d.ts.map +1 -0
- package/dist/sync/continuous-sync-supervisor.js +1117 -0
- package/dist/sync/continuous-sync-supervisor.js.map +1 -0
- package/dist/sync/index.d.ts +9 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +9 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/journal.d.ts +57 -0
- package/dist/sync/journal.d.ts.map +1 -0
- package/dist/sync/journal.js +685 -0
- package/dist/sync/journal.js.map +1 -0
- package/dist/sync/revisions.d.ts +118 -0
- package/dist/sync/revisions.d.ts.map +1 -0
- package/dist/sync/revisions.js +364 -0
- package/dist/sync/revisions.js.map +1 -0
- package/dist/sync/supervisor.d.ts +107 -0
- package/dist/sync/supervisor.d.ts.map +1 -0
- package/dist/sync/supervisor.js +246 -0
- package/dist/sync/supervisor.js.map +1 -0
- package/dist/sync/workspace-sync-client.d.ts +18 -0
- package/dist/sync/workspace-sync-client.d.ts.map +1 -0
- package/dist/sync/workspace-sync-client.js +150 -0
- package/dist/sync/workspace-sync-client.js.map +1 -0
- package/dist/sync/workspace-sync-coordinator.d.ts +76 -0
- package/dist/sync/workspace-sync-coordinator.d.ts.map +1 -0
- package/dist/sync/workspace-sync-coordinator.js +621 -0
- package/dist/sync/workspace-sync-coordinator.js.map +1 -0
- package/dist/sync/workspace-sync-product-service.d.ts +79 -0
- package/dist/sync/workspace-sync-product-service.d.ts.map +1 -0
- package/dist/sync/workspace-sync-product-service.js +398 -0
- package/dist/sync/workspace-sync-product-service.js.map +1 -0
- package/dist/sync/workspace-sync-protocol.d.ts +145 -0
- package/dist/sync/workspace-sync-protocol.d.ts.map +1 -0
- package/dist/sync/workspace-sync-protocol.js +347 -0
- package/dist/sync/workspace-sync-protocol.js.map +1 -0
- package/dist/terminal/appbar.d.ts +40 -0
- package/dist/terminal/appbar.d.ts.map +1 -0
- package/dist/terminal/appbar.js +55 -0
- package/dist/terminal/appbar.js.map +1 -0
- package/dist/terminal/cell-width.d.ts +3 -0
- package/dist/terminal/cell-width.d.ts.map +1 -0
- package/dist/terminal/cell-width.js +53 -0
- package/dist/terminal/cell-width.js.map +1 -0
- package/dist/terminal/codec.d.ts +107 -0
- package/dist/terminal/codec.d.ts.map +1 -0
- package/dist/terminal/codec.js +538 -0
- package/dist/terminal/codec.js.map +1 -0
- package/dist/terminal/foreground.d.ts +135 -0
- package/dist/terminal/foreground.d.ts.map +1 -0
- package/dist/terminal/foreground.js +2097 -0
- package/dist/terminal/foreground.js.map +1 -0
- package/dist/terminal/generated/terminal-wire-v1.d.ts +26 -0
- package/dist/terminal/generated/terminal-wire-v1.d.ts.map +1 -0
- package/dist/terminal/generated/terminal-wire-v1.js +27 -0
- package/dist/terminal/generated/terminal-wire-v1.js.map +1 -0
- package/dist/terminal/mode.d.ts +33 -0
- package/dist/terminal/mode.d.ts.map +1 -0
- package/dist/terminal/mode.js +99 -0
- package/dist/terminal/mode.js.map +1 -0
- package/dist/terminal/passthrough.d.ts +47 -0
- package/dist/terminal/passthrough.d.ts.map +1 -0
- package/dist/terminal/passthrough.js +666 -0
- package/dist/terminal/passthrough.js.map +1 -0
- package/dist/terminal/resume.d.ts +58 -0
- package/dist/terminal/resume.d.ts.map +1 -0
- package/dist/terminal/resume.js +185 -0
- package/dist/terminal/resume.js.map +1 -0
- package/dist/terminal/viewport.d.ts +93 -0
- package/dist/terminal/viewport.d.ts.map +1 -0
- package/dist/terminal/viewport.js +266 -0
- package/dist/terminal/viewport.js.map +1 -0
- package/dist/terminal/workbench.d.ts +32 -0
- package/dist/terminal/workbench.d.ts.map +1 -0
- package/dist/terminal/workbench.js +316 -0
- package/dist/terminal/workbench.js.map +1 -0
- package/dist/terminal/xterm-vte.d.ts +49 -0
- package/dist/terminal/xterm-vte.d.ts.map +1 -0
- package/dist/terminal/xterm-vte.js +602 -0
- package/dist/terminal/xterm-vte.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace/binding-path.d.ts +17 -0
- package/dist/workspace/binding-path.d.ts.map +1 -0
- package/dist/workspace/binding-path.js +91 -0
- package/dist/workspace/binding-path.js.map +1 -0
- package/dist/workspace/binding-store.d.ts +107 -0
- package/dist/workspace/binding-store.d.ts.map +1 -0
- package/dist/workspace/binding-store.js +783 -0
- package/dist/workspace/binding-store.js.map +1 -0
- package/dist/workspace/binding.d.ts +35 -0
- package/dist/workspace/binding.d.ts.map +1 -0
- package/dist/workspace/binding.js +70 -0
- package/dist/workspace/binding.js.map +1 -0
- package/dist/workspace/errors.d.ts +4 -0
- package/dist/workspace/errors.d.ts.map +1 -0
- package/dist/workspace/errors.js +19 -0
- package/dist/workspace/errors.js.map +1 -0
- package/dist/workspace/exclusion.d.ts +21 -0
- package/dist/workspace/exclusion.d.ts.map +1 -0
- package/dist/workspace/exclusion.js +243 -0
- package/dist/workspace/exclusion.js.map +1 -0
- package/dist/workspace/index.d.ts +8 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +8 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/lifecycle.d.ts +56 -0
- package/dist/workspace/lifecycle.d.ts.map +1 -0
- package/dist/workspace/lifecycle.js +94 -0
- package/dist/workspace/lifecycle.js.map +1 -0
- package/dist/workspace/manifest.d.ts +47 -0
- package/dist/workspace/manifest.d.ts.map +1 -0
- package/dist/workspace/manifest.js +243 -0
- package/dist/workspace/manifest.js.map +1 -0
- package/dist/workspace/paths.d.ts +14 -0
- package/dist/workspace/paths.d.ts.map +1 -0
- package/dist/workspace/paths.js +67 -0
- package/dist/workspace/paths.js.map +1 -0
- package/dist/workspace/schema.d.ts +15 -0
- package/dist/workspace/schema.d.ts.map +1 -0
- package/dist/workspace/schema.js +33 -0
- package/dist/workspace/schema.js.map +1 -0
- package/dist/workspace/selection-screen.d.ts +4 -0
- package/dist/workspace/selection-screen.d.ts.map +1 -0
- package/dist/workspace/selection-screen.js +216 -0
- package/dist/workspace/selection-screen.js.map +1 -0
- package/dist/workspace/selection-service.d.ts +16 -0
- package/dist/workspace/selection-service.d.ts.map +1 -0
- package/dist/workspace/selection-service.js +65 -0
- package/dist/workspace/selection-service.js.map +1 -0
- package/node_modules/@xterm/headless/README.md +31 -0
- package/node_modules/@xterm/headless/lib-headless/xterm-headless.js +2 -0
- package/node_modules/@xterm/headless/lib-headless/xterm-headless.js.map +1 -0
- package/node_modules/@xterm/headless/lib-headless/xterm-headless.mjs +46 -0
- package/node_modules/@xterm/headless/lib-headless/xterm-headless.mjs.map +7 -0
- package/node_modules/@xterm/headless/package.json +29 -0
- package/node_modules/@xterm/headless/typings/xterm-headless.d.ts +1385 -0
- package/package.json +75 -0
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
import { runtimeFailure } from "../runtime/errors.js";
|
|
2
|
+
import { HISTORICAL_INPUT_NOTICE, MAX_FOREGROUND_PENDING_INPUT_BYTES, admitForegroundSessionIds } from "./foreground.js";
|
|
3
|
+
import { ViewportRegistry } from "./viewport.js";
|
|
4
|
+
import { XtermViewportAdapter } from "./xterm-vte.js";
|
|
5
|
+
import { renderBareViewport } from "./workbench.js";
|
|
6
|
+
const ESCAPE_PREFIX = 0x1d;
|
|
7
|
+
const INTERRUPT = 0x03;
|
|
8
|
+
const FLOW_RESUME = 0x11;
|
|
9
|
+
const FLOW_PAUSE = 0x13;
|
|
10
|
+
const REMOTE_INTERRUPT = 0x63;
|
|
11
|
+
const REMOTE_FLOW_RESUME = 0x71;
|
|
12
|
+
const REMOTE_FLOW_PAUSE = 0x73;
|
|
13
|
+
const DETACH = 0x64;
|
|
14
|
+
const RESIZE_COALESCE_MS = 50;
|
|
15
|
+
const BRACKETED_PASTE_START = Uint8Array.of(0x1b, 0x5b, 0x32, 0x30, 0x30, 0x7e);
|
|
16
|
+
const BRACKETED_PASTE_END = Uint8Array.of(0x1b, 0x5b, 0x32, 0x30, 0x31, 0x7e);
|
|
17
|
+
const BRACKETED_PASTE_DISABLE = Uint8Array.of(0x1b, 0x5b, 0x3f, 0x32, 0x30, 0x30, 0x34, 0x6c);
|
|
18
|
+
/**
|
|
19
|
+
* A single-session fallback. Ordinary writers retain byte-preserving output;
|
|
20
|
+
* observers and writers with historical input uncertainty use an isolated cell
|
|
21
|
+
* projection with bounded local notices. This mode has no Cuna appbar.
|
|
22
|
+
*/
|
|
23
|
+
export class PassthroughTerminalCoordinator {
|
|
24
|
+
#options;
|
|
25
|
+
#runtime;
|
|
26
|
+
#intent;
|
|
27
|
+
#snapshot;
|
|
28
|
+
#lease;
|
|
29
|
+
#state = "idle";
|
|
30
|
+
#removeInput;
|
|
31
|
+
#removeResize;
|
|
32
|
+
#removeAbort;
|
|
33
|
+
#resizeTimer;
|
|
34
|
+
#inputTail = Promise.resolve();
|
|
35
|
+
#outputTail = Promise.resolve();
|
|
36
|
+
#pendingInputBytes = 0;
|
|
37
|
+
#prefixPending = false;
|
|
38
|
+
#pasteActive = false;
|
|
39
|
+
#pasteStartMatch = 0;
|
|
40
|
+
#pasteEndMatch = 0;
|
|
41
|
+
#remotePasteDisableMatch = 0;
|
|
42
|
+
#detachChordTrusted = true;
|
|
43
|
+
#localDetachTabId;
|
|
44
|
+
#detachedSessions = [];
|
|
45
|
+
#failure;
|
|
46
|
+
#stopPromise;
|
|
47
|
+
#stopStarted;
|
|
48
|
+
#resolveStopStarted;
|
|
49
|
+
#initialReady;
|
|
50
|
+
#resolveInitialReady;
|
|
51
|
+
#lifetimeAbort = new AbortController();
|
|
52
|
+
#startupDetached = false;
|
|
53
|
+
#viewport;
|
|
54
|
+
constructor(options) {
|
|
55
|
+
const resizeCoalesceMs = options.resizeCoalesceMs ?? RESIZE_COALESCE_MS;
|
|
56
|
+
if (!Number.isSafeInteger(resizeCoalesceMs) || resizeCoalesceMs < 1 || resizeCoalesceMs > 1_000) {
|
|
57
|
+
throw new RangeError("Passthrough resize coalescing must be between 1 and 1000 milliseconds.");
|
|
58
|
+
}
|
|
59
|
+
this.#options = Object.freeze({ ...options, resizeCoalesceMs });
|
|
60
|
+
let resolveStopStarted = () => undefined;
|
|
61
|
+
this.#stopStarted = new Promise((resolve) => { resolveStopStarted = resolve; });
|
|
62
|
+
this.#resolveStopStarted = resolveStopStarted;
|
|
63
|
+
let resolveInitialReady = () => undefined;
|
|
64
|
+
this.#initialReady = new Promise((resolve) => { resolveInitialReady = resolve; });
|
|
65
|
+
this.#resolveInitialReady = resolveInitialReady;
|
|
66
|
+
}
|
|
67
|
+
get state() {
|
|
68
|
+
return this.#state;
|
|
69
|
+
}
|
|
70
|
+
get failure() {
|
|
71
|
+
return this.#failure;
|
|
72
|
+
}
|
|
73
|
+
/** The AgentSession the person detached from with Ctrl+] d, once the runtime confirmed it. */
|
|
74
|
+
get detachedSessions() {
|
|
75
|
+
return Object.freeze([...this.#detachedSessions]);
|
|
76
|
+
}
|
|
77
|
+
bindRuntime(runtime) {
|
|
78
|
+
if (this.#runtime !== undefined || this.#state !== "idle") {
|
|
79
|
+
throw runtimeFailure("session_conflict", "The passthrough runtime is already bound or started.");
|
|
80
|
+
}
|
|
81
|
+
this.#runtime = runtime;
|
|
82
|
+
}
|
|
83
|
+
runtimeCallbacks() {
|
|
84
|
+
return Object.freeze({
|
|
85
|
+
onTerminalReady: async (snapshot) => this.#terminalReady(snapshot),
|
|
86
|
+
onTerminalGeometry: async (event) => await this.#terminalGeometry(event.snapshot, event.signal),
|
|
87
|
+
onTerminalOutput: async (event) => await this.#queueOutput(event),
|
|
88
|
+
onTerminalState: (snapshot) => this.#terminalState(snapshot),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async start(intents, signal) {
|
|
92
|
+
if (this.#state !== "idle")
|
|
93
|
+
throw runtimeFailure("session_conflict", "The passthrough terminal already started.");
|
|
94
|
+
if (intents.length !== 1) {
|
|
95
|
+
throw runtimeFailure("capability_unsupported", "Plain passthrough mode binds exactly one AgentSession.");
|
|
96
|
+
}
|
|
97
|
+
admitForegroundSessionIds(intents.map((intent) => intent.agentSessionId));
|
|
98
|
+
const intent = intents[0];
|
|
99
|
+
if (intent === undefined)
|
|
100
|
+
throw runtimeFailure("session_unknown", "No passthrough AgentSession was selected.");
|
|
101
|
+
admitPassthroughDimensions(this.#options.host.dimensions());
|
|
102
|
+
const runtime = this.#requireRuntime();
|
|
103
|
+
this.#intent = intent;
|
|
104
|
+
this.#state = "starting";
|
|
105
|
+
try {
|
|
106
|
+
if (signal?.aborted)
|
|
107
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough terminal startup was cancelled.");
|
|
108
|
+
if (signal !== undefined) {
|
|
109
|
+
const onAbort = () => {
|
|
110
|
+
this.#failure ??= runtimeFailure("terminal_disconnected", "Passthrough terminal execution was cancelled.");
|
|
111
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
112
|
+
};
|
|
113
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
114
|
+
this.#removeAbort = () => signal.removeEventListener("abort", onAbort);
|
|
115
|
+
}
|
|
116
|
+
this.#lease = await this.#options.host.acquire("plain");
|
|
117
|
+
if (signal?.aborted || this.#state !== "starting") {
|
|
118
|
+
await this.#lease.restore();
|
|
119
|
+
this.#lease = undefined;
|
|
120
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough terminal startup was cancelled.");
|
|
121
|
+
}
|
|
122
|
+
this.#removeInput = this.#options.host.onInput((bytes) => this.#queueInput(bytes));
|
|
123
|
+
this.#removeResize = this.#options.host.onResize(() => this.#queueResize());
|
|
124
|
+
const dimensions = admitPassthroughDimensions(this.#options.host.dimensions());
|
|
125
|
+
const attachSignal = signal === undefined
|
|
126
|
+
? this.#lifetimeAbort.signal
|
|
127
|
+
: AbortSignal.any([signal, this.#lifetimeAbort.signal]);
|
|
128
|
+
const snapshot = await runtime.attach({
|
|
129
|
+
tabId: intent.tabId,
|
|
130
|
+
agentSessionId: intent.agentSessionId,
|
|
131
|
+
columns: dimensions.columns,
|
|
132
|
+
rows: dimensions.rows,
|
|
133
|
+
...(intent.attachmentAdmission === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { expectedAdmission: intent.attachmentAdmission }),
|
|
136
|
+
signal: attachSignal,
|
|
137
|
+
});
|
|
138
|
+
if (this.#startupDetached || this.#state !== "starting") {
|
|
139
|
+
await runtime.detach(snapshot.tabId);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!sameIntent(intent, snapshot)) {
|
|
143
|
+
throw runtimeFailure("grant_scope_mismatch", "Passthrough readiness targets a different AgentSession.");
|
|
144
|
+
}
|
|
145
|
+
this.#snapshot = snapshot;
|
|
146
|
+
await this.#repaintAfterReplay(snapshot, dimensions);
|
|
147
|
+
this.#state = "active";
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
const startupDetached = this.#startupDetached;
|
|
151
|
+
if (!startupDetached)
|
|
152
|
+
this.#state = "failed";
|
|
153
|
+
try {
|
|
154
|
+
await this.stop();
|
|
155
|
+
}
|
|
156
|
+
catch (cleanupError) {
|
|
157
|
+
throw new AggregateError([error, cleanupError], "Passthrough startup and cleanup both failed.");
|
|
158
|
+
}
|
|
159
|
+
if (startupDetached)
|
|
160
|
+
return;
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async stop() {
|
|
165
|
+
if (this.#stopPromise !== undefined)
|
|
166
|
+
return await this.#stopPromise;
|
|
167
|
+
this.#resolveStopStarted();
|
|
168
|
+
this.#stopPromise = this.#stopNow();
|
|
169
|
+
try {
|
|
170
|
+
return await this.#stopPromise;
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
// A failed restore retains the lease and may be retried explicitly after
|
|
174
|
+
// the host terminal becomes writable again.
|
|
175
|
+
if (this.#state === "failed")
|
|
176
|
+
this.#stopPromise = undefined;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async waitForStop() {
|
|
180
|
+
await this.#stopStarted;
|
|
181
|
+
const attempt = this.#stopPromise;
|
|
182
|
+
if (attempt === undefined)
|
|
183
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough cleanup did not start.");
|
|
184
|
+
await attempt;
|
|
185
|
+
if (this.#state !== "stopped")
|
|
186
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough cleanup did not complete.");
|
|
187
|
+
}
|
|
188
|
+
async #stopNow() {
|
|
189
|
+
if (this.#state === "stopped")
|
|
190
|
+
return;
|
|
191
|
+
this.#state = "stopping";
|
|
192
|
+
this.#lifetimeAbort.abort(new Error("Passthrough terminal detached locally."));
|
|
193
|
+
this.#removeAbort?.();
|
|
194
|
+
this.#removeAbort = undefined;
|
|
195
|
+
if (this.#resizeTimer !== undefined)
|
|
196
|
+
clearTimeout(this.#resizeTimer);
|
|
197
|
+
this.#resizeTimer = undefined;
|
|
198
|
+
this.#removeInput?.();
|
|
199
|
+
this.#removeResize?.();
|
|
200
|
+
this.#removeInput = undefined;
|
|
201
|
+
this.#removeResize = undefined;
|
|
202
|
+
// Release any input that arrived before readiness so cleanup cannot wait
|
|
203
|
+
// on a promise that only cleanup itself would otherwise resolve.
|
|
204
|
+
this.#resolveInitialReady();
|
|
205
|
+
const failures = [];
|
|
206
|
+
const snapshot = this.#snapshot;
|
|
207
|
+
if (snapshot !== undefined && snapshot.state !== "closed" && snapshot.state !== "detached") {
|
|
208
|
+
try {
|
|
209
|
+
await this.#requireRuntime().detach(snapshot.tabId);
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
failures.push(error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
await this.#outputTail;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
failures.push(error);
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
await this.#inputTail;
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
failures.push(error);
|
|
226
|
+
}
|
|
227
|
+
this.#viewport?.dispose();
|
|
228
|
+
this.#viewport = undefined;
|
|
229
|
+
if (this.#lease !== undefined) {
|
|
230
|
+
try {
|
|
231
|
+
await this.#lease.restore();
|
|
232
|
+
this.#lease = undefined;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
failures.push(error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
this.#snapshot = undefined;
|
|
239
|
+
this.#intent = undefined;
|
|
240
|
+
this.#pendingInputBytes = 0;
|
|
241
|
+
this.#state = failures.length === 0 ? "stopped" : "failed";
|
|
242
|
+
if (failures.length > 0)
|
|
243
|
+
throw new AggregateError(failures, "Passthrough terminal cleanup was incomplete.");
|
|
244
|
+
}
|
|
245
|
+
async #terminalReady(snapshot) {
|
|
246
|
+
await this.#outputTail;
|
|
247
|
+
const intent = this.#intent;
|
|
248
|
+
if (intent === undefined || !sameIntent(intent, snapshot)) {
|
|
249
|
+
throw runtimeFailure("grant_scope_mismatch", "Passthrough readiness targets an unbound AgentSession.");
|
|
250
|
+
}
|
|
251
|
+
if (this.#state !== "starting" && this.#state !== "active") {
|
|
252
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough readiness arrived after terminal ownership ended.");
|
|
253
|
+
}
|
|
254
|
+
const previous = this.#viewport?.snapshot();
|
|
255
|
+
if (previous !== undefined) {
|
|
256
|
+
const binding = { userId: snapshot.userId, machineId: snapshot.machineId,
|
|
257
|
+
agentSessionId: snapshot.agentSessionId, processEpoch: snapshot.processEpoch,
|
|
258
|
+
fencingGeneration: snapshot.fencingGeneration };
|
|
259
|
+
if (previous.binding.fencingGeneration === binding.fencingGeneration && sameEvent(snapshot, {
|
|
260
|
+
tabId: previous.tabId, agentSessionId: previous.binding.agentSessionId, binding: previous.binding,
|
|
261
|
+
})) {
|
|
262
|
+
// A repeated READY for the exact attachment cannot erase consumed cells.
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
await this.#viewport?.rebind(binding);
|
|
266
|
+
}
|
|
267
|
+
this.#snapshot = snapshot;
|
|
268
|
+
this.#resolveInitialReady();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
this.#snapshot = snapshot;
|
|
272
|
+
const dimensions = admitPassthroughDimensions(this.#options.host.dimensions());
|
|
273
|
+
this.#viewport = new XtermViewportAdapter({
|
|
274
|
+
tabId: snapshot.tabId,
|
|
275
|
+
binding: {
|
|
276
|
+
userId: snapshot.userId, machineId: snapshot.machineId,
|
|
277
|
+
agentSessionId: snapshot.agentSessionId, processEpoch: snapshot.processEpoch,
|
|
278
|
+
fencingGeneration: snapshot.fencingGeneration,
|
|
279
|
+
},
|
|
280
|
+
columns: dimensions.columns, rows: dimensions.rows,
|
|
281
|
+
registry: new ViewportRegistry(), scrollback: 0,
|
|
282
|
+
// The raw writer's physical terminal answers queries. The shadow model
|
|
283
|
+
// must never duplicate those responses or emit observer input. A writer
|
|
284
|
+
// with historical uncertainty uses projection to keep its notice visible.
|
|
285
|
+
onTerminalResponse: async (response) => {
|
|
286
|
+
if (this.#snapshot?.accessMode === "writer" && this.#snapshot.historicalInputUncertainty) {
|
|
287
|
+
await this.#requireRuntime().sendTerminalResponse(response);
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
this.#resolveInitialReady();
|
|
292
|
+
}
|
|
293
|
+
async #terminalGeometry(snapshot, signal) {
|
|
294
|
+
const operation = this.#outputTail.then(async () => {
|
|
295
|
+
const current = this.#snapshot;
|
|
296
|
+
if (current === undefined || !sameEvent(current, {
|
|
297
|
+
tabId: snapshot.tabId, agentSessionId: snapshot.agentSessionId,
|
|
298
|
+
binding: snapshot,
|
|
299
|
+
}) || current.writerEpoch !== snapshot.writerEpoch || snapshot.geometry === null) {
|
|
300
|
+
throw runtimeFailure("grant_scope_mismatch", "Plain geometry targets a different attachment or writer epoch.");
|
|
301
|
+
}
|
|
302
|
+
if (signal.aborted)
|
|
303
|
+
throw runtimeFailure("terminal_disconnected", "Plain geometry was cancelled.");
|
|
304
|
+
const viewport = this.#viewport;
|
|
305
|
+
if (viewport === undefined)
|
|
306
|
+
throw runtimeFailure("terminal_disconnected", "Plain geometry has no bound viewport.");
|
|
307
|
+
const onAbort = () => viewport.dispose();
|
|
308
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
309
|
+
try {
|
|
310
|
+
await viewport.resize(snapshot.geometry.columns, snapshot.geometry.rows);
|
|
311
|
+
if (signal.aborted)
|
|
312
|
+
throw runtimeFailure("terminal_disconnected", "Plain geometry was cancelled.");
|
|
313
|
+
this.#snapshot = snapshot;
|
|
314
|
+
if (this.#usesProjection())
|
|
315
|
+
await this.#renderObserver();
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
signal.removeEventListener("abort", onAbort);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
this.#outputTail = operation.then(() => undefined, () => undefined);
|
|
322
|
+
await operation;
|
|
323
|
+
}
|
|
324
|
+
async #renderObserver() {
|
|
325
|
+
const snapshot = this.#snapshot;
|
|
326
|
+
if (snapshot === undefined || !this.#usesProjection())
|
|
327
|
+
return;
|
|
328
|
+
const dimensions = admitPassthroughDimensions(this.#options.host.dimensions());
|
|
329
|
+
const viewport = this.#viewport;
|
|
330
|
+
if (viewport === undefined)
|
|
331
|
+
throw runtimeFailure("terminal_disconnected", "The observer viewport is unavailable.");
|
|
332
|
+
const projection = viewport.snapshotForHost(dimensions.columns, dimensions.rows);
|
|
333
|
+
const notice = [
|
|
334
|
+
...(snapshot.historicalInputUncertainty ? [HISTORICAL_INPUT_NOTICE] : []),
|
|
335
|
+
...(viewport.snapshot().columns > dimensions.columns || viewport.snapshot().rows > dimensions.rows || snapshot.historicalInputUncertainty ? ["Local view cropped."] : []),
|
|
336
|
+
].join(" · ") || undefined;
|
|
337
|
+
if (snapshot.geometry == null) {
|
|
338
|
+
// Do not display host-sized parsed cells as authoritative writer geometry.
|
|
339
|
+
const { renderRows: _renderRows, ...plain } = projection;
|
|
340
|
+
const label = "Terminal geometry unknown".slice(0, dimensions.columns);
|
|
341
|
+
await this.#options.host.write(renderBareViewport({ ...plain,
|
|
342
|
+
cells: [label], displayWidths: [label.length], modes: { ...plain.modes, cursorVisible: false },
|
|
343
|
+
}, notice));
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
await this.#options.host.write(renderBareViewport(projection, notice));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
#usesProjection() {
|
|
350
|
+
return this.#snapshot?.accessMode === "observer" || this.#snapshot?.historicalInputUncertainty === true;
|
|
351
|
+
}
|
|
352
|
+
async #queueOutput(event) {
|
|
353
|
+
const operation = this.#outputTail.then(async () => {
|
|
354
|
+
const snapshot = this.#snapshot;
|
|
355
|
+
if (snapshot === undefined || !sameEvent(snapshot, event)) {
|
|
356
|
+
throw runtimeFailure("grant_scope_mismatch", "Passthrough output targets an unbound terminal generation.");
|
|
357
|
+
}
|
|
358
|
+
if (event.signal.aborted)
|
|
359
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough output was cancelled.");
|
|
360
|
+
const viewport = this.#viewport;
|
|
361
|
+
if (viewport === undefined)
|
|
362
|
+
throw runtimeFailure("terminal_disconnected", "Plain output has no bound viewport.");
|
|
363
|
+
await viewport.write(event.bytes, event.sequence, event.sequence);
|
|
364
|
+
if (event.signal.aborted)
|
|
365
|
+
throw runtimeFailure("terminal_disconnected", "Plain output was cancelled.");
|
|
366
|
+
if (this.#usesProjection()) {
|
|
367
|
+
await this.#renderObserver();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this.#observeRemoteModeOutput(event.bytes);
|
|
371
|
+
// This is intentionally the original binary payload. No status, Unicode
|
|
372
|
+
// decoding, VTE interpretation, or trusted chrome is inserted here.
|
|
373
|
+
await this.#options.host.write(event.bytes);
|
|
374
|
+
});
|
|
375
|
+
this.#outputTail = operation.then(() => undefined, () => undefined);
|
|
376
|
+
await operation;
|
|
377
|
+
}
|
|
378
|
+
#terminalState(snapshot) {
|
|
379
|
+
const intent = this.#intent;
|
|
380
|
+
if (intent === undefined || !sameIntent(intent, snapshot))
|
|
381
|
+
return;
|
|
382
|
+
if (this.#localDetachTabId === snapshot.tabId &&
|
|
383
|
+
(snapshot.state === "failed" || snapshot.state === "interrupted")) {
|
|
384
|
+
// Closing the local attachment can synchronously surface the transport's
|
|
385
|
+
// interrupted state before detach() publishes/resolves its detached
|
|
386
|
+
// state. That teardown edge is expected and must not become a CLI error.
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const previous = this.#snapshot;
|
|
390
|
+
this.#snapshot = snapshot;
|
|
391
|
+
if (snapshot.state === "active" && this.#usesProjection() &&
|
|
392
|
+
(previous?.accessMode !== snapshot.accessMode || previous.historicalInputUncertainty !== snapshot.historicalInputUncertainty)) {
|
|
393
|
+
const operation = this.#outputTail.then(async () => await this.#renderObserver());
|
|
394
|
+
this.#outputTail = operation.catch((error) => {
|
|
395
|
+
this.#failure ??= error;
|
|
396
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
if (snapshot.state === "failed" || snapshot.state === "interrupted") {
|
|
400
|
+
this.#failure ??= runtimeFailure("terminal_disconnected", "The passthrough terminal connection ended.");
|
|
401
|
+
}
|
|
402
|
+
if (this.#state === "active" &&
|
|
403
|
+
(snapshot.state === "failed" || snapshot.state === "interrupted" || snapshot.state === "closed" || snapshot.state === "detached")) {
|
|
404
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
#queueInput(bytes) {
|
|
408
|
+
if (bytes.byteLength < 1)
|
|
409
|
+
return;
|
|
410
|
+
if (this.#state === "starting" && bytes.includes(INTERRUPT)) {
|
|
411
|
+
this.#startupDetached = true;
|
|
412
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (bytes.byteLength > MAX_FOREGROUND_PENDING_INPUT_BYTES || this.#pendingInputBytes + bytes.byteLength > MAX_FOREGROUND_PENDING_INPUT_BYTES) {
|
|
416
|
+
this.#failure ??= runtimeFailure("terminal_protocol_error", "Passthrough input exceeded its bounded queue.");
|
|
417
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const payload = bytes.slice();
|
|
421
|
+
const receiptTarget = this.#snapshot === undefined
|
|
422
|
+
? undefined
|
|
423
|
+
: Object.freeze({
|
|
424
|
+
tabId: this.#snapshot.tabId,
|
|
425
|
+
binding: Object.freeze({
|
|
426
|
+
userId: this.#snapshot.userId,
|
|
427
|
+
machineId: this.#snapshot.machineId,
|
|
428
|
+
agentSessionId: this.#snapshot.agentSessionId,
|
|
429
|
+
processEpoch: this.#snapshot.processEpoch,
|
|
430
|
+
fencingGeneration: this.#snapshot.fencingGeneration,
|
|
431
|
+
}),
|
|
432
|
+
});
|
|
433
|
+
if (payload.byteLength === 1 &&
|
|
434
|
+
payload[0] === INTERRUPT &&
|
|
435
|
+
!this.#pasteActive &&
|
|
436
|
+
!this.#prefixPending &&
|
|
437
|
+
receiptTarget !== undefined) {
|
|
438
|
+
// The user's detach decision is authoritative from input receipt, not
|
|
439
|
+
// only once its serialized input operation reaches runtime.detach(). A
|
|
440
|
+
// concurrent WebSocket close in that window is expected teardown.
|
|
441
|
+
this.#localDetachTabId = receiptTarget.tabId;
|
|
442
|
+
}
|
|
443
|
+
this.#pendingInputBytes += payload.byteLength;
|
|
444
|
+
const operation = this.#inputTail.then(async () => {
|
|
445
|
+
let admittedTarget = receiptTarget;
|
|
446
|
+
if (admittedTarget === undefined && this.#state === "starting") {
|
|
447
|
+
// Raw mode is acquired before the remote terminal can prove readiness.
|
|
448
|
+
// Input arriving in that window belongs to this one exact intent; wait
|
|
449
|
+
// for its first fenced binding instead of treating a normal early key
|
|
450
|
+
// press as a terminal failure. Once ready, later input still captures
|
|
451
|
+
// its generation at receipt time and cannot cross a reconnect fence.
|
|
452
|
+
await this.#initialReady;
|
|
453
|
+
const ready = this.#snapshot;
|
|
454
|
+
if (ready !== undefined && ready.state === "active") {
|
|
455
|
+
admittedTarget = Object.freeze({
|
|
456
|
+
tabId: ready.tabId,
|
|
457
|
+
binding: Object.freeze({
|
|
458
|
+
userId: ready.userId,
|
|
459
|
+
machineId: ready.machineId,
|
|
460
|
+
agentSessionId: ready.agentSessionId,
|
|
461
|
+
processEpoch: ready.processEpoch,
|
|
462
|
+
fencingGeneration: ready.fencingGeneration,
|
|
463
|
+
}),
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
try {
|
|
468
|
+
await this.#routeInput(payload, admittedTarget);
|
|
469
|
+
}
|
|
470
|
+
finally {
|
|
471
|
+
this.#pendingInputBytes -= payload.byteLength;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
this.#inputTail = operation.catch((error) => {
|
|
475
|
+
this.#failure ??= error;
|
|
476
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
async #routeInput(bytes, target) {
|
|
480
|
+
const snapshot = this.#snapshot;
|
|
481
|
+
if (snapshot === undefined || snapshot.state !== "active" || target === undefined) {
|
|
482
|
+
throw runtimeFailure("terminal_disconnected", "Passthrough input is withheld until the exact PTY is ready.");
|
|
483
|
+
}
|
|
484
|
+
const remote = [];
|
|
485
|
+
const flush = async () => {
|
|
486
|
+
if (remote.length === 0)
|
|
487
|
+
return;
|
|
488
|
+
if (this.#snapshot?.accessMode !== "writer") {
|
|
489
|
+
remote.length = 0;
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
await this.#requireRuntime().sendInput(Uint8Array.from(remote.splice(0)), target.tabId, target.binding);
|
|
493
|
+
};
|
|
494
|
+
for (const byte of bytes) {
|
|
495
|
+
if (this.#pasteActive) {
|
|
496
|
+
remote.push(byte);
|
|
497
|
+
const matched = advanceSequence(BRACKETED_PASTE_END, byte, this.#pasteEndMatch);
|
|
498
|
+
if (matched === BRACKETED_PASTE_END.length) {
|
|
499
|
+
this.#pasteActive = false;
|
|
500
|
+
this.#pasteEndMatch = 0;
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
this.#pasteEndMatch = matched;
|
|
504
|
+
}
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
this.#pasteStartMatch = advanceSequence(BRACKETED_PASTE_START, byte, this.#pasteStartMatch);
|
|
508
|
+
if (this.#pasteStartMatch === BRACKETED_PASTE_START.length) {
|
|
509
|
+
this.#pasteActive = true;
|
|
510
|
+
this.#pasteStartMatch = 0;
|
|
511
|
+
remote.push(byte);
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (!this.#prefixPending) {
|
|
515
|
+
if (byte === FLOW_PAUSE) {
|
|
516
|
+
remote.push(FLOW_RESUME);
|
|
517
|
+
}
|
|
518
|
+
else if (byte === INTERRUPT) {
|
|
519
|
+
await flush();
|
|
520
|
+
await this.#detachLocal(snapshot);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
else if (byte === ESCAPE_PREFIX) {
|
|
524
|
+
await flush();
|
|
525
|
+
this.#prefixPending = true;
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
remote.push(byte);
|
|
529
|
+
}
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
this.#prefixPending = false;
|
|
533
|
+
if (byte === ESCAPE_PREFIX) {
|
|
534
|
+
remote.push(ESCAPE_PREFIX);
|
|
535
|
+
}
|
|
536
|
+
else if (byte === REMOTE_INTERRUPT) {
|
|
537
|
+
remote.push(INTERRUPT);
|
|
538
|
+
}
|
|
539
|
+
else if (byte === REMOTE_FLOW_PAUSE) {
|
|
540
|
+
remote.push(FLOW_PAUSE);
|
|
541
|
+
}
|
|
542
|
+
else if (byte === REMOTE_FLOW_RESUME) {
|
|
543
|
+
remote.push(FLOW_RESUME);
|
|
544
|
+
}
|
|
545
|
+
else if (byte === DETACH && this.#detachChordTrusted) {
|
|
546
|
+
await flush();
|
|
547
|
+
await this.#detachLocal(snapshot);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
remote.push(ESCAPE_PREFIX, byte);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
await flush();
|
|
555
|
+
}
|
|
556
|
+
async #detachLocal(snapshot) {
|
|
557
|
+
this.#localDetachTabId = snapshot.tabId;
|
|
558
|
+
try {
|
|
559
|
+
await this.#requireRuntime().detach(snapshot.tabId);
|
|
560
|
+
}
|
|
561
|
+
catch (error) {
|
|
562
|
+
this.#localDetachTabId = undefined;
|
|
563
|
+
throw error;
|
|
564
|
+
}
|
|
565
|
+
if (this.#snapshot === snapshot) {
|
|
566
|
+
this.#snapshot = Object.freeze({ ...snapshot, state: "detached" });
|
|
567
|
+
}
|
|
568
|
+
this.#localDetachTabId = undefined;
|
|
569
|
+
const intent = this.#intent;
|
|
570
|
+
if (intent !== undefined && intent.tabId === snapshot.tabId) {
|
|
571
|
+
this.#detachedSessions.push(Object.freeze({ agentSessionId: intent.agentSessionId, label: intent.label }));
|
|
572
|
+
}
|
|
573
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
574
|
+
}
|
|
575
|
+
#observeRemoteModeOutput(bytes) {
|
|
576
|
+
if (!this.#detachChordTrusted)
|
|
577
|
+
return;
|
|
578
|
+
for (const byte of bytes) {
|
|
579
|
+
this.#remotePasteDisableMatch = advanceSequence(BRACKETED_PASTE_DISABLE, byte, this.#remotePasteDisableMatch);
|
|
580
|
+
if (this.#remotePasteDisableMatch === BRACKETED_PASTE_DISABLE.length) {
|
|
581
|
+
this.#detachChordTrusted = false;
|
|
582
|
+
this.#remotePasteDisableMatch = 0;
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
#queueResize() {
|
|
588
|
+
if (this.#state !== "active")
|
|
589
|
+
return;
|
|
590
|
+
const authority = this.#snapshot;
|
|
591
|
+
if (authority === undefined)
|
|
592
|
+
return;
|
|
593
|
+
if (this.#resizeTimer !== undefined)
|
|
594
|
+
clearTimeout(this.#resizeTimer);
|
|
595
|
+
this.#resizeTimer = setTimeout(() => {
|
|
596
|
+
this.#resizeTimer = undefined;
|
|
597
|
+
void this.#applyResize(authority).catch((error) => {
|
|
598
|
+
this.#failure ??= error;
|
|
599
|
+
void this.stop().catch(() => { this.#state = "failed"; });
|
|
600
|
+
});
|
|
601
|
+
}, this.#options.resizeCoalesceMs);
|
|
602
|
+
this.#resizeTimer.unref();
|
|
603
|
+
}
|
|
604
|
+
async #applyResize(authority) {
|
|
605
|
+
const snapshot = this.#snapshot;
|
|
606
|
+
if (snapshot === undefined || snapshot.state !== "active")
|
|
607
|
+
return;
|
|
608
|
+
if (snapshot.accessMode === "observer" || authority.accessMode !== "writer" ||
|
|
609
|
+
snapshot.writerEpoch !== authority.writerEpoch || !sameEvent(snapshot, {
|
|
610
|
+
tabId: authority.tabId, agentSessionId: authority.agentSessionId, binding: authority,
|
|
611
|
+
})) {
|
|
612
|
+
const operation = this.#outputTail.then(async () => await this.#renderObserver());
|
|
613
|
+
this.#outputTail = operation.then(() => undefined, () => undefined);
|
|
614
|
+
await operation;
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
if (snapshot.resizeCapability !== "live")
|
|
618
|
+
return;
|
|
619
|
+
const dimensions = admitPassthroughDimensions(this.#options.host.dimensions());
|
|
620
|
+
await this.#requireRuntime().resize(dimensions.columns, dimensions.rows, snapshot.tabId);
|
|
621
|
+
}
|
|
622
|
+
async #repaintAfterReplay(snapshot, dimensions) {
|
|
623
|
+
if (snapshot.accessMode === "observer") {
|
|
624
|
+
await this.#renderObserver();
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (snapshot.state !== "active" || snapshot.accessMode !== "writer" || snapshot.resizeCapability !== "live")
|
|
628
|
+
return;
|
|
629
|
+
// A fullscreen TUI may have painted its base frame before this client
|
|
630
|
+
// attached, leaving replay with cursor-relative deltas only. Force one
|
|
631
|
+
// real size transition and restore the admitted host size so the remote
|
|
632
|
+
// application receives SIGWINCH and emits a complete current frame.
|
|
633
|
+
const bounceColumns = dimensions.columns === 1 ? 2 : dimensions.columns - 1;
|
|
634
|
+
await this.#requireRuntime().resize(bounceColumns, dimensions.rows, snapshot.tabId);
|
|
635
|
+
await this.#requireRuntime().resize(dimensions.columns, dimensions.rows, snapshot.tabId);
|
|
636
|
+
}
|
|
637
|
+
#requireRuntime() {
|
|
638
|
+
if (this.#runtime === undefined)
|
|
639
|
+
throw runtimeFailure("control_plane_unavailable", "No passthrough runtime is bound.");
|
|
640
|
+
return this.#runtime;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
export function admitPassthroughDimensions(input) {
|
|
644
|
+
if (!Number.isSafeInteger(input.columns) || !Number.isSafeInteger(input.rows) || input.columns < 1 || input.rows < 1 || input.columns > 1_000 || input.rows > 1_000) {
|
|
645
|
+
throw new RangeError("The passthrough host terminal dimensions are outside protocol bounds.");
|
|
646
|
+
}
|
|
647
|
+
return Object.freeze({ columns: input.columns, rows: input.rows });
|
|
648
|
+
}
|
|
649
|
+
function sameIntent(intent, snapshot) {
|
|
650
|
+
return intent.tabId === snapshot.tabId && intent.agentSessionId === snapshot.agentSessionId;
|
|
651
|
+
}
|
|
652
|
+
function sameEvent(snapshot, event) {
|
|
653
|
+
return snapshot.tabId === event.tabId &&
|
|
654
|
+
snapshot.agentSessionId === event.agentSessionId &&
|
|
655
|
+
snapshot.userId === event.binding.userId &&
|
|
656
|
+
snapshot.machineId === event.binding.machineId &&
|
|
657
|
+
snapshot.agentSessionId === event.binding.agentSessionId &&
|
|
658
|
+
snapshot.processEpoch === event.binding.processEpoch &&
|
|
659
|
+
snapshot.fencingGeneration === event.binding.fencingGeneration;
|
|
660
|
+
}
|
|
661
|
+
function advanceSequence(sequence, byte, matched) {
|
|
662
|
+
if (byte === sequence[matched])
|
|
663
|
+
return matched + 1;
|
|
664
|
+
return byte === sequence[0] ? 1 : 0;
|
|
665
|
+
}
|
|
666
|
+
//# sourceMappingURL=passthrough.js.map
|