@quenty/studio-bridge 0.7.0 → 0.8.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/CHANGELOG.md +15 -39
- package/README.md +166 -115
- package/dist/src/bridge/bridge-connection-remote.test.d.ts +7 -0
- package/dist/src/bridge/bridge-connection-remote.test.d.ts.map +1 -0
- package/dist/src/bridge/bridge-connection-remote.test.js +144 -0
- package/dist/src/bridge/bridge-connection-remote.test.js.map +1 -0
- package/dist/src/bridge/bridge-connection.d.ts +112 -0
- package/dist/src/bridge/bridge-connection.d.ts.map +1 -0
- package/dist/src/bridge/bridge-connection.js +528 -0
- package/dist/src/bridge/bridge-connection.js.map +1 -0
- package/dist/src/bridge/bridge-connection.test.d.ts +6 -0
- package/dist/src/bridge/bridge-connection.test.d.ts.map +1 -0
- package/dist/src/bridge/bridge-connection.test.js +773 -0
- package/dist/src/bridge/bridge-connection.test.js.map +1 -0
- package/dist/src/bridge/bridge-session.d.ts +38 -0
- package/dist/src/bridge/bridge-session.d.ts.map +1 -0
- package/dist/src/bridge/bridge-session.js +259 -0
- package/dist/src/bridge/bridge-session.js.map +1 -0
- package/dist/src/bridge/bridge-session.test.d.ts +6 -0
- package/dist/src/bridge/bridge-session.test.d.ts.map +1 -0
- package/dist/src/bridge/bridge-session.test.js +264 -0
- package/dist/src/bridge/bridge-session.test.js.map +1 -0
- package/dist/src/bridge/index.d.ts +13 -0
- package/dist/src/bridge/index.d.ts.map +1 -0
- package/dist/src/bridge/index.js +13 -0
- package/dist/src/bridge/index.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.d.ts +9 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.js +159 -0
- package/dist/src/bridge/internal/__tests__/failover-crash.test.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.d.ts +9 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.js +218 -0
- package/dist/src/bridge/internal/__tests__/failover-graceful.test.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.d.ts +9 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.js +246 -0
- package/dist/src/bridge/internal/__tests__/failover-inflight.test.js.map +1 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.d.ts +10 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.js +298 -0
- package/dist/src/bridge/internal/__tests__/host-client-integration.test.js.map +1 -0
- package/dist/src/bridge/internal/bridge-client.d.ts +70 -0
- package/dist/src/bridge/internal/bridge-client.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-client.js +344 -0
- package/dist/src/bridge/internal/bridge-client.js.map +1 -0
- package/dist/src/bridge/internal/bridge-client.test.d.ts +7 -0
- package/dist/src/bridge/internal/bridge-client.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-client.test.js +301 -0
- package/dist/src/bridge/internal/bridge-client.test.js.map +1 -0
- package/dist/src/bridge/internal/bridge-host.d.ts +78 -0
- package/dist/src/bridge/internal/bridge-host.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-host.js +383 -0
- package/dist/src/bridge/internal/bridge-host.js.map +1 -0
- package/dist/src/bridge/internal/bridge-host.test.d.ts +7 -0
- package/dist/src/bridge/internal/bridge-host.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/bridge-host.test.js +377 -0
- package/dist/src/bridge/internal/bridge-host.test.js.map +1 -0
- package/dist/src/bridge/internal/environment-detection.d.ts +44 -0
- package/dist/src/bridge/internal/environment-detection.d.ts.map +1 -0
- package/dist/src/bridge/internal/environment-detection.js +91 -0
- package/dist/src/bridge/internal/environment-detection.js.map +1 -0
- package/dist/src/bridge/internal/environment-detection.test.d.ts +7 -0
- package/dist/src/bridge/internal/environment-detection.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/environment-detection.test.js +150 -0
- package/dist/src/bridge/internal/environment-detection.test.js.map +1 -0
- package/dist/src/bridge/internal/hand-off.d.ts +69 -0
- package/dist/src/bridge/internal/hand-off.d.ts.map +1 -0
- package/dist/src/bridge/internal/hand-off.js +178 -0
- package/dist/src/bridge/internal/hand-off.js.map +1 -0
- package/dist/src/bridge/internal/hand-off.test.d.ts +7 -0
- package/dist/src/bridge/internal/hand-off.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/hand-off.test.js +325 -0
- package/dist/src/bridge/internal/hand-off.test.js.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.d.ts +32 -0
- package/dist/src/bridge/internal/health-endpoint.d.ts.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.js +73 -0
- package/dist/src/bridge/internal/health-endpoint.js.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.test.d.ts +6 -0
- package/dist/src/bridge/internal/health-endpoint.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/health-endpoint.test.js +122 -0
- package/dist/src/bridge/internal/health-endpoint.test.js.map +1 -0
- package/dist/src/bridge/internal/host-protocol.d.ts +60 -0
- package/dist/src/bridge/internal/host-protocol.d.ts.map +1 -0
- package/dist/src/bridge/internal/host-protocol.js +184 -0
- package/dist/src/bridge/internal/host-protocol.js.map +1 -0
- package/dist/src/bridge/internal/host-protocol.test.d.ts +6 -0
- package/dist/src/bridge/internal/host-protocol.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/host-protocol.test.js +307 -0
- package/dist/src/bridge/internal/host-protocol.test.js.map +1 -0
- package/dist/src/bridge/internal/session-tracker.d.ts +67 -0
- package/dist/src/bridge/internal/session-tracker.d.ts.map +1 -0
- package/dist/src/bridge/internal/session-tracker.js +138 -0
- package/dist/src/bridge/internal/session-tracker.js.map +1 -0
- package/dist/src/bridge/internal/session-tracker.test.d.ts +6 -0
- package/dist/src/bridge/internal/session-tracker.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/session-tracker.test.js +342 -0
- package/dist/src/bridge/internal/session-tracker.test.js.map +1 -0
- package/dist/src/bridge/internal/transport-client.d.ts +43 -0
- package/dist/src/bridge/internal/transport-client.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-client.js +146 -0
- package/dist/src/bridge/internal/transport-client.js.map +1 -0
- package/dist/src/bridge/internal/transport-client.test.d.ts +6 -0
- package/dist/src/bridge/internal/transport-client.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-client.test.js +176 -0
- package/dist/src/bridge/internal/transport-client.test.js.map +1 -0
- package/dist/src/bridge/internal/transport-server.d.ts +59 -0
- package/dist/src/bridge/internal/transport-server.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-server.js +189 -0
- package/dist/src/bridge/internal/transport-server.js.map +1 -0
- package/dist/src/bridge/internal/transport-server.test.d.ts +6 -0
- package/dist/src/bridge/internal/transport-server.test.d.ts.map +1 -0
- package/dist/src/bridge/internal/transport-server.test.js +171 -0
- package/dist/src/bridge/internal/transport-server.test.js.map +1 -0
- package/dist/src/bridge/types.d.ts +117 -0
- package/dist/src/bridge/types.d.ts.map +1 -0
- package/dist/src/bridge/types.js +68 -0
- package/dist/src/bridge/types.js.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.d.ts +6 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.js +260 -0
- package/dist/src/cli/adapters/cli-command-adapter-handler.test.js.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.d.ts +39 -0
- package/dist/src/cli/adapters/cli-command-adapter.d.ts.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.js +241 -0
- package/dist/src/cli/adapters/cli-command-adapter.js.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.d.ts +5 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.js +188 -0
- package/dist/src/cli/adapters/cli-command-adapter.test.js.map +1 -0
- package/dist/src/cli/adapters/group-builder.d.ts +29 -0
- package/dist/src/cli/adapters/group-builder.d.ts.map +1 -0
- package/dist/src/cli/adapters/group-builder.js +54 -0
- package/dist/src/cli/adapters/group-builder.js.map +1 -0
- package/dist/src/cli/adapters/group-builder.test.d.ts +5 -0
- package/dist/src/cli/adapters/group-builder.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/group-builder.test.js +108 -0
- package/dist/src/cli/adapters/group-builder.test.js.map +1 -0
- package/dist/src/cli/adapters/help-formatter.d.ts +11 -0
- package/dist/src/cli/adapters/help-formatter.d.ts.map +1 -0
- package/dist/src/cli/adapters/help-formatter.js +78 -0
- package/dist/src/cli/adapters/help-formatter.js.map +1 -0
- package/dist/src/cli/adapters/help-formatter.test.d.ts +5 -0
- package/dist/src/cli/adapters/help-formatter.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/help-formatter.test.js +79 -0
- package/dist/src/cli/adapters/help-formatter.test.js.map +1 -0
- package/dist/src/cli/adapters/target-resolver.d.ts +54 -0
- package/dist/src/cli/adapters/target-resolver.d.ts.map +1 -0
- package/dist/src/cli/adapters/target-resolver.js +90 -0
- package/dist/src/cli/adapters/target-resolver.js.map +1 -0
- package/dist/src/cli/adapters/target-resolver.test.d.ts +5 -0
- package/dist/src/cli/adapters/target-resolver.test.d.ts.map +1 -0
- package/dist/src/cli/adapters/target-resolver.test.js +169 -0
- package/dist/src/cli/adapters/target-resolver.test.js.map +1 -0
- package/dist/src/cli/args/global-args.d.ts +2 -0
- package/dist/src/cli/args/global-args.d.ts.map +1 -1
- package/dist/src/cli/cli.d.ts +6 -3
- package/dist/src/cli/cli.d.ts.map +1 -1
- package/dist/src/cli/cli.js +82 -20
- package/dist/src/cli/cli.js.map +1 -1
- package/dist/src/cli/resolve-script-content.d.ts +19 -0
- package/dist/src/cli/resolve-script-content.d.ts.map +1 -0
- package/dist/src/cli/resolve-script-content.js +22 -0
- package/dist/src/cli/resolve-script-content.js.map +1 -0
- package/dist/src/cli/resolve-session.d.ts +21 -0
- package/dist/src/cli/resolve-session.d.ts.map +1 -0
- package/dist/src/cli/resolve-session.js +40 -0
- package/dist/src/cli/resolve-session.js.map +1 -0
- package/dist/src/cli/resolve-session.test.d.ts +5 -0
- package/dist/src/cli/resolve-session.test.d.ts.map +1 -0
- package/dist/src/cli/resolve-session.test.js +112 -0
- package/dist/src/cli/resolve-session.test.js.map +1 -0
- package/dist/src/cli/script-executor.d.ts +1 -0
- package/dist/src/cli/script-executor.d.ts.map +1 -1
- package/dist/src/cli/script-executor.js +7 -1
- package/dist/src/cli/script-executor.js.map +1 -1
- package/dist/src/cli/types.d.ts +11 -0
- package/dist/src/cli/types.d.ts.map +1 -0
- package/dist/src/cli/types.js +5 -0
- package/dist/src/cli/types.js.map +1 -0
- package/dist/src/commands/connect.d.ts +16 -0
- package/dist/src/commands/connect.d.ts.map +1 -0
- package/dist/src/commands/connect.js +15 -0
- package/dist/src/commands/connect.js.map +1 -0
- package/dist/src/commands/connect.test.d.ts +5 -0
- package/dist/src/commands/connect.test.d.ts.map +1 -0
- package/dist/src/commands/connect.test.js +46 -0
- package/dist/src/commands/connect.test.js.map +1 -0
- package/dist/src/commands/console/exec/exec.d.ts +43 -0
- package/dist/src/commands/console/exec/exec.d.ts.map +1 -0
- package/dist/src/commands/console/exec/exec.js +79 -0
- package/dist/src/commands/console/exec/exec.js.map +1 -0
- package/dist/src/commands/console/exec/exec.test.d.ts +5 -0
- package/dist/src/commands/console/exec/exec.test.d.ts.map +1 -0
- package/dist/src/commands/console/exec/exec.test.js +191 -0
- package/dist/src/commands/console/exec/exec.test.js.map +1 -0
- package/dist/src/commands/console/logs/logs.d.ts +23 -0
- package/dist/src/commands/console/logs/logs.d.ts.map +1 -0
- package/dist/src/commands/console/logs/logs.js +80 -0
- package/dist/src/commands/console/logs/logs.js.map +1 -0
- package/dist/src/commands/console/logs/logs.test.d.ts +5 -0
- package/dist/src/commands/console/logs/logs.test.d.ts.map +1 -0
- package/dist/src/commands/console/logs/logs.test.js +111 -0
- package/dist/src/commands/console/logs/logs.test.js.map +1 -0
- package/dist/src/commands/disconnect.d.ts +9 -0
- package/dist/src/commands/disconnect.d.ts.map +1 -0
- package/dist/src/commands/disconnect.js +8 -0
- package/dist/src/commands/disconnect.js.map +1 -0
- package/dist/src/commands/disconnect.test.d.ts +5 -0
- package/dist/src/commands/disconnect.test.d.ts.map +1 -0
- package/dist/src/commands/disconnect.test.js +17 -0
- package/dist/src/commands/disconnect.test.js.map +1 -0
- package/dist/src/commands/explorer/query/query.d.ts +31 -0
- package/dist/src/commands/explorer/query/query.d.ts.map +1 -0
- package/dist/src/commands/explorer/query/query.js +106 -0
- package/dist/src/commands/explorer/query/query.js.map +1 -0
- package/dist/src/commands/explorer/query/query.test.d.ts +5 -0
- package/dist/src/commands/explorer/query/query.test.d.ts.map +1 -0
- package/dist/src/commands/explorer/query/query.test.js +228 -0
- package/dist/src/commands/explorer/query/query.test.js.map +1 -0
- package/dist/src/commands/formatters.test.d.ts +6 -0
- package/dist/src/commands/formatters.test.d.ts.map +1 -0
- package/dist/src/commands/formatters.test.js +211 -0
- package/dist/src/commands/formatters.test.js.map +1 -0
- package/dist/src/commands/framework/action-loader.d.ts +25 -0
- package/dist/src/commands/framework/action-loader.d.ts.map +1 -0
- package/dist/src/commands/framework/action-loader.js +46 -0
- package/dist/src/commands/framework/action-loader.js.map +1 -0
- package/dist/src/commands/framework/action-loader.test.d.ts +5 -0
- package/dist/src/commands/framework/action-loader.test.d.ts.map +1 -0
- package/dist/src/commands/framework/action-loader.test.js +89 -0
- package/dist/src/commands/framework/action-loader.test.js.map +1 -0
- package/dist/src/commands/framework/arg-builder.d.ts +92 -0
- package/dist/src/commands/framework/arg-builder.d.ts.map +1 -0
- package/dist/src/commands/framework/arg-builder.js +137 -0
- package/dist/src/commands/framework/arg-builder.js.map +1 -0
- package/dist/src/commands/framework/arg-builder.test.d.ts +5 -0
- package/dist/src/commands/framework/arg-builder.test.d.ts.map +1 -0
- package/dist/src/commands/framework/arg-builder.test.js +246 -0
- package/dist/src/commands/framework/arg-builder.test.js.map +1 -0
- package/dist/src/commands/framework/command-registry.d.ts +23 -0
- package/dist/src/commands/framework/command-registry.d.ts.map +1 -0
- package/dist/src/commands/framework/command-registry.js +42 -0
- package/dist/src/commands/framework/command-registry.js.map +1 -0
- package/dist/src/commands/framework/command-registry.test.d.ts +5 -0
- package/dist/src/commands/framework/command-registry.test.d.ts.map +1 -0
- package/dist/src/commands/framework/command-registry.test.js +158 -0
- package/dist/src/commands/framework/command-registry.test.js.map +1 -0
- package/dist/src/commands/framework/define-command.d.ts +76 -0
- package/dist/src/commands/framework/define-command.d.ts.map +1 -0
- package/dist/src/commands/framework/define-command.js +28 -0
- package/dist/src/commands/framework/define-command.js.map +1 -0
- package/dist/src/commands/framework/define-command.test.d.ts +5 -0
- package/dist/src/commands/framework/define-command.test.d.ts.map +1 -0
- package/dist/src/commands/framework/define-command.test.js +135 -0
- package/dist/src/commands/framework/define-command.test.js.map +1 -0
- package/dist/src/commands/framework/index.d.ts +8 -0
- package/dist/src/commands/framework/index.d.ts.map +1 -0
- package/dist/src/commands/framework/index.js +8 -0
- package/dist/src/commands/framework/index.js.map +1 -0
- package/dist/src/commands/index.d.ts +20 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +20 -0
- package/dist/src/commands/index.js.map +1 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.d.ts +15 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.d.ts.map +1 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.js +88 -0
- package/dist/src/commands/linux/inject-credentials/inject-credentials.js.map +1 -0
- package/dist/src/commands/linux/setup/setup.d.ts +19 -0
- package/dist/src/commands/linux/setup/setup.d.ts.map +1 -0
- package/dist/src/commands/linux/setup/setup.js +107 -0
- package/dist/src/commands/linux/setup/setup.js.map +1 -0
- package/dist/src/commands/linux/status/status.d.ts +34 -0
- package/dist/src/commands/linux/status/status.d.ts.map +1 -0
- package/dist/src/commands/linux/status/status.js +134 -0
- package/dist/src/commands/linux/status/status.js.map +1 -0
- package/dist/src/commands/plugin/install/install.d.ts +10 -0
- package/dist/src/commands/plugin/install/install.d.ts.map +1 -0
- package/dist/src/commands/plugin/install/install.js +23 -0
- package/dist/src/commands/plugin/install/install.js.map +1 -0
- package/dist/src/commands/plugin/uninstall/uninstall.d.ts +9 -0
- package/dist/src/commands/plugin/uninstall/uninstall.d.ts.map +1 -0
- package/dist/src/commands/plugin/uninstall/uninstall.js +41 -0
- package/dist/src/commands/plugin/uninstall/uninstall.js.map +1 -0
- package/dist/src/commands/process/close/close.d.ts +22 -0
- package/dist/src/commands/process/close/close.d.ts.map +1 -0
- package/dist/src/commands/process/close/close.js +34 -0
- package/dist/src/commands/process/close/close.js.map +1 -0
- package/dist/src/commands/process/format-state.d.ts +7 -0
- package/dist/src/commands/process/format-state.d.ts.map +1 -0
- package/dist/src/commands/process/format-state.js +19 -0
- package/dist/src/commands/process/format-state.js.map +1 -0
- package/dist/src/commands/process/info/info.d.ts +17 -0
- package/dist/src/commands/process/info/info.d.ts.map +1 -0
- package/dist/src/commands/process/info/info.js +38 -0
- package/dist/src/commands/process/info/info.js.map +1 -0
- package/dist/src/commands/process/info/info.test.d.ts +5 -0
- package/dist/src/commands/process/info/info.test.d.ts.map +1 -0
- package/dist/src/commands/process/info/info.test.js +58 -0
- package/dist/src/commands/process/info/info.test.js.map +1 -0
- package/dist/src/commands/process/launch/launch.d.ts +17 -0
- package/dist/src/commands/process/launch/launch.d.ts.map +1 -0
- package/dist/src/commands/process/launch/launch.js +26 -0
- package/dist/src/commands/process/launch/launch.js.map +1 -0
- package/dist/src/commands/process/launch/launch.test.d.ts +5 -0
- package/dist/src/commands/process/launch/launch.test.d.ts.map +1 -0
- package/dist/src/commands/process/launch/launch.test.js +49 -0
- package/dist/src/commands/process/launch/launch.test.js.map +1 -0
- package/dist/src/commands/process/list/list.d.ts +16 -0
- package/dist/src/commands/process/list/list.d.ts.map +1 -0
- package/dist/src/commands/process/list/list.js +56 -0
- package/dist/src/commands/process/list/list.js.map +1 -0
- package/dist/src/commands/process/list/list.test.d.ts +5 -0
- package/dist/src/commands/process/list/list.test.d.ts.map +1 -0
- package/dist/src/commands/process/list/list.test.js +71 -0
- package/dist/src/commands/process/list/list.test.js.map +1 -0
- package/dist/src/commands/process/run/run.d.ts +31 -0
- package/dist/src/commands/process/run/run.d.ts.map +1 -0
- package/dist/src/commands/process/run/run.js +63 -0
- package/dist/src/commands/process/run/run.js.map +1 -0
- package/dist/src/commands/rgba-to-png.d.ts +17 -0
- package/dist/src/commands/rgba-to-png.d.ts.map +1 -0
- package/dist/src/commands/rgba-to-png.js +85 -0
- package/dist/src/commands/rgba-to-png.js.map +1 -0
- package/dist/src/commands/serve/serve.d.ts +17 -0
- package/dist/src/commands/serve/serve.d.ts.map +1 -0
- package/dist/src/commands/serve/serve.js +128 -0
- package/dist/src/commands/serve/serve.js.map +1 -0
- package/dist/src/commands/serve/serve.test.d.ts +5 -0
- package/dist/src/commands/serve/serve.test.d.ts.map +1 -0
- package/dist/src/commands/serve/serve.test.js +100 -0
- package/dist/src/commands/serve/serve.test.js.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.d.ts +17 -0
- package/dist/src/commands/viewport/screenshot/screenshot.d.ts.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.js +45 -0
- package/dist/src/commands/viewport/screenshot/screenshot.js.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.d.ts +5 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.d.ts.map +1 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.js +143 -0
- package/dist/src/commands/viewport/screenshot/screenshot.test.js.map +1 -0
- package/dist/src/docker/docker-delegator.d.ts +30 -0
- package/dist/src/docker/docker-delegator.d.ts.map +1 -0
- package/dist/src/docker/docker-delegator.js +201 -0
- package/dist/src/docker/docker-delegator.js.map +1 -0
- package/dist/src/docker/docker-delegator.test.d.ts +2 -0
- package/dist/src/docker/docker-delegator.test.d.ts.map +1 -0
- package/dist/src/docker/docker-delegator.test.js +132 -0
- package/dist/src/docker/docker-delegator.test.js.map +1 -0
- package/dist/src/index.d.ts +9 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.test.d.ts +2 -0
- package/dist/src/index.test.d.ts.map +1 -0
- package/dist/src/index.test.js +51 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/linux/index.d.ts +12 -0
- package/dist/src/linux/index.d.ts.map +1 -0
- package/dist/src/linux/index.js +11 -0
- package/dist/src/linux/index.js.map +1 -0
- package/dist/src/linux/linux-config.d.ts +37 -0
- package/dist/src/linux/linux-config.d.ts.map +1 -0
- package/dist/src/linux/linux-config.js +70 -0
- package/dist/src/linux/linux-config.js.map +1 -0
- package/dist/src/linux/linux-config.test.d.ts +2 -0
- package/dist/src/linux/linux-config.test.d.ts.map +1 -0
- package/dist/src/linux/linux-config.test.js +54 -0
- package/dist/src/linux/linux-config.test.js.map +1 -0
- package/dist/src/linux/linux-credential-writer.d.ts +35 -0
- package/dist/src/linux/linux-credential-writer.d.ts.map +1 -0
- package/dist/src/linux/linux-credential-writer.js +300 -0
- package/dist/src/linux/linux-credential-writer.js.map +1 -0
- package/dist/src/linux/linux-display-manager.d.ts +24 -0
- package/dist/src/linux/linux-display-manager.d.ts.map +1 -0
- package/dist/src/linux/linux-display-manager.js +92 -0
- package/dist/src/linux/linux-display-manager.js.map +1 -0
- package/dist/src/linux/linux-env-guard.d.ts +13 -0
- package/dist/src/linux/linux-env-guard.d.ts.map +1 -0
- package/dist/src/linux/linux-env-guard.js +31 -0
- package/dist/src/linux/linux-env-guard.js.map +1 -0
- package/dist/src/linux/linux-env-guard.test.d.ts +2 -0
- package/dist/src/linux/linux-env-guard.test.d.ts.map +1 -0
- package/dist/src/linux/linux-env-guard.test.js +48 -0
- package/dist/src/linux/linux-env-guard.test.js.map +1 -0
- package/dist/src/linux/linux-fflags.d.ts +17 -0
- package/dist/src/linux/linux-fflags.d.ts.map +1 -0
- package/dist/src/linux/linux-fflags.js +33 -0
- package/dist/src/linux/linux-fflags.js.map +1 -0
- package/dist/src/linux/linux-fflags.test.d.ts +2 -0
- package/dist/src/linux/linux-fflags.test.d.ts.map +1 -0
- package/dist/src/linux/linux-fflags.test.js +55 -0
- package/dist/src/linux/linux-fflags.test.js.map +1 -0
- package/dist/src/linux/linux-prerequisites.d.ts +24 -0
- package/dist/src/linux/linux-prerequisites.d.ts.map +1 -0
- package/dist/src/linux/linux-prerequisites.js +118 -0
- package/dist/src/linux/linux-prerequisites.js.map +1 -0
- package/dist/src/linux/linux-shader-patcher.d.ts +17 -0
- package/dist/src/linux/linux-shader-patcher.d.ts.map +1 -0
- package/dist/src/linux/linux-shader-patcher.js +48 -0
- package/dist/src/linux/linux-shader-patcher.js.map +1 -0
- package/dist/src/linux/linux-shader-patcher.test.d.ts +2 -0
- package/dist/src/linux/linux-shader-patcher.test.d.ts.map +1 -0
- package/dist/src/linux/linux-shader-patcher.test.js +55 -0
- package/dist/src/linux/linux-shader-patcher.test.js.map +1 -0
- package/dist/src/linux/linux-studio-installer.d.ts +10 -0
- package/dist/src/linux/linux-studio-installer.d.ts.map +1 -0
- package/dist/src/linux/linux-studio-installer.js +79 -0
- package/dist/src/linux/linux-studio-installer.js.map +1 -0
- package/dist/src/linux/linux-studio-launcher.d.ts +10 -0
- package/dist/src/linux/linux-studio-launcher.d.ts.map +1 -0
- package/dist/src/linux/linux-studio-launcher.js +73 -0
- package/dist/src/linux/linux-studio-launcher.js.map +1 -0
- package/dist/src/linux/linux-version-resolver.d.ts +18 -0
- package/dist/src/linux/linux-version-resolver.d.ts.map +1 -0
- package/dist/src/linux/linux-version-resolver.js +49 -0
- package/dist/src/linux/linux-version-resolver.js.map +1 -0
- package/dist/src/linux/linux-wine-env.d.ts +11 -0
- package/dist/src/linux/linux-wine-env.d.ts.map +1 -0
- package/dist/src/linux/linux-wine-env.js +33 -0
- package/dist/src/linux/linux-wine-env.js.map +1 -0
- package/dist/src/linux/linux-wine-env.test.d.ts +2 -0
- package/dist/src/linux/linux-wine-env.test.d.ts.map +1 -0
- package/dist/src/linux/linux-wine-env.test.js +47 -0
- package/dist/src/linux/linux-wine-env.test.js.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.d.ts +21 -0
- package/dist/src/plugin/persistent-plugin-installer.d.ts.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.js +69 -0
- package/dist/src/plugin/persistent-plugin-installer.js.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.test.d.ts +5 -0
- package/dist/src/plugin/persistent-plugin-installer.test.d.ts.map +1 -0
- package/dist/src/plugin/persistent-plugin-installer.test.js +109 -0
- package/dist/src/plugin/persistent-plugin-installer.test.js.map +1 -0
- package/dist/src/plugin/plugin-discovery.d.ts +7 -0
- package/dist/src/plugin/plugin-discovery.d.ts.map +1 -0
- package/dist/src/plugin/plugin-discovery.js +18 -0
- package/dist/src/plugin/plugin-discovery.js.map +1 -0
- package/dist/src/plugin/plugin-discovery.test.d.ts +5 -0
- package/dist/src/plugin/plugin-discovery.test.d.ts.map +1 -0
- package/dist/src/plugin/plugin-discovery.test.js +55 -0
- package/dist/src/plugin/plugin-discovery.test.js.map +1 -0
- package/dist/src/plugin/plugin-injector.js +1 -1
- package/dist/src/plugin/plugin-injector.js.map +1 -1
- package/dist/src/process/studio-process-manager.d.ts +7 -3
- package/dist/src/process/studio-process-manager.d.ts.map +1 -1
- package/dist/src/process/studio-process-manager.js +38 -11
- package/dist/src/process/studio-process-manager.js.map +1 -1
- package/dist/src/process/studio-process-manager.test.js +18 -1
- package/dist/src/process/studio-process-manager.test.js.map +1 -1
- package/dist/src/server/action-dispatcher.d.ts +35 -0
- package/dist/src/server/action-dispatcher.d.ts.map +1 -0
- package/dist/src/server/action-dispatcher.js +67 -0
- package/dist/src/server/action-dispatcher.js.map +1 -0
- package/dist/src/server/action-dispatcher.test.d.ts +6 -0
- package/dist/src/server/action-dispatcher.test.d.ts.map +1 -0
- package/dist/src/server/action-dispatcher.test.js +173 -0
- package/dist/src/server/action-dispatcher.test.js.map +1 -0
- package/dist/src/server/index.d.ts +1 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/pending-request-map.d.ts +33 -0
- package/dist/src/server/pending-request-map.d.ts.map +1 -0
- package/dist/src/server/pending-request-map.js +69 -0
- package/dist/src/server/pending-request-map.js.map +1 -0
- package/dist/src/server/pending-request-map.test.d.ts +2 -0
- package/dist/src/server/pending-request-map.test.d.ts.map +1 -0
- package/dist/src/server/pending-request-map.test.js +192 -0
- package/dist/src/server/pending-request-map.test.js.map +1 -0
- package/dist/src/server/plugin-detection.test.d.ts +7 -0
- package/dist/src/server/plugin-detection.test.d.ts.map +1 -0
- package/dist/src/server/plugin-detection.test.js +154 -0
- package/dist/src/server/plugin-detection.test.js.map +1 -0
- package/dist/src/server/studio-bridge-server.d.ts +44 -7
- package/dist/src/server/studio-bridge-server.d.ts.map +1 -1
- package/dist/src/server/studio-bridge-server.js +341 -91
- package/dist/src/server/studio-bridge-server.js.map +1 -1
- package/dist/src/server/studio-bridge-server.test.js +231 -207
- package/dist/src/server/studio-bridge-server.test.js.map +1 -1
- package/dist/src/server/web-socket-protocol-basic.test.d.ts +2 -0
- package/dist/src/server/web-socket-protocol-basic.test.d.ts.map +1 -0
- package/dist/src/server/web-socket-protocol-basic.test.js +98 -0
- package/dist/src/server/web-socket-protocol-basic.test.js.map +1 -0
- package/dist/src/server/web-socket-protocol.d.ts +218 -20
- package/dist/src/server/web-socket-protocol.d.ts.map +1 -1
- package/dist/src/server/web-socket-protocol.js +346 -20
- package/dist/src/server/web-socket-protocol.js.map +1 -1
- package/dist/src/server/web-socket-protocol.test.js +572 -146
- package/dist/src/server/web-socket-protocol.test.js.map +1 -1
- package/dist/src/test/e2e/hand-off.test.d.ts +9 -0
- package/dist/src/test/e2e/hand-off.test.d.ts.map +1 -0
- package/dist/src/test/e2e/hand-off.test.js +274 -0
- package/dist/src/test/e2e/hand-off.test.js.map +1 -0
- package/dist/src/test/e2e/persistent-session.test.d.ts +11 -0
- package/dist/src/test/e2e/persistent-session.test.d.ts.map +1 -0
- package/dist/src/test/e2e/persistent-session.test.js +367 -0
- package/dist/src/test/e2e/persistent-session.test.js.map +1 -0
- package/dist/src/test/e2e/split-server.test.d.ts +14 -0
- package/dist/src/test/e2e/split-server.test.d.ts.map +1 -0
- package/dist/src/test/e2e/split-server.test.js +230 -0
- package/dist/src/test/e2e/split-server.test.js.map +1 -0
- package/dist/src/test/helpers/mock-plugin-client.d.ts +69 -0
- package/dist/src/test/helpers/mock-plugin-client.d.ts.map +1 -0
- package/dist/src/test/helpers/mock-plugin-client.js +213 -0
- package/dist/src/test/helpers/mock-plugin-client.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docker/.dockerignore +2 -0
- package/docker/Dockerfile +113 -0
- package/docker/docker-compose.yml +20 -0
- package/docker/entrypoint.sh +19 -0
- package/package.json +8 -6
- package/src/bridge/bridge-connection-remote.test.ts +189 -0
- package/src/bridge/bridge-connection.test.ts +1076 -0
- package/src/bridge/bridge-connection.ts +718 -0
- package/src/bridge/bridge-session.test.ts +336 -0
- package/src/bridge/bridge-session.ts +365 -0
- package/src/bridge/index.ts +42 -0
- package/src/bridge/internal/__tests__/failover-crash.test.ts +191 -0
- package/src/bridge/internal/__tests__/failover-graceful.test.ts +268 -0
- package/src/bridge/internal/__tests__/failover-inflight.test.ts +329 -0
- package/src/bridge/internal/__tests__/host-client-integration.test.ts +387 -0
- package/src/bridge/internal/bridge-client.test.ts +399 -0
- package/src/bridge/internal/bridge-client.ts +434 -0
- package/src/bridge/internal/bridge-host.test.ts +501 -0
- package/src/bridge/internal/bridge-host.ts +531 -0
- package/src/bridge/internal/environment-detection.test.ts +180 -0
- package/src/bridge/internal/environment-detection.ts +119 -0
- package/src/bridge/internal/hand-off.test.ts +408 -0
- package/src/bridge/internal/hand-off.ts +275 -0
- package/src/bridge/internal/health-endpoint.test.ts +147 -0
- package/src/bridge/internal/health-endpoint.ts +100 -0
- package/src/bridge/internal/host-protocol.test.ts +415 -0
- package/src/bridge/internal/host-protocol.ts +255 -0
- package/src/bridge/internal/session-tracker.test.ts +535 -0
- package/src/bridge/internal/session-tracker.ts +198 -0
- package/src/bridge/internal/transport-client.test.ts +241 -0
- package/src/bridge/internal/transport-client.ts +194 -0
- package/src/bridge/internal/transport-server.test.ts +220 -0
- package/src/bridge/internal/transport-server.ts +242 -0
- package/src/bridge/types.ts +161 -0
- package/src/cli/adapters/cli-command-adapter-handler.test.ts +318 -0
- package/src/cli/adapters/cli-command-adapter.test.ts +221 -0
- package/src/cli/adapters/cli-command-adapter.ts +342 -0
- package/src/cli/adapters/group-builder.test.ts +146 -0
- package/src/cli/adapters/group-builder.ts +81 -0
- package/src/cli/adapters/help-formatter.test.ts +97 -0
- package/src/cli/adapters/help-formatter.ts +86 -0
- package/src/cli/adapters/target-resolver.test.ts +222 -0
- package/src/cli/adapters/target-resolver.ts +144 -0
- package/src/cli/args/global-args.ts +2 -0
- package/src/cli/cli.ts +100 -21
- package/src/cli/resolve-script-content.ts +36 -0
- package/src/cli/resolve-session.test.ts +141 -0
- package/src/cli/resolve-session.ts +66 -0
- package/src/cli/script-executor.ts +22 -4
- package/src/cli/types.ts +11 -0
- package/src/commands/connect.test.ts +61 -0
- package/src/commands/connect.ts +32 -0
- package/src/commands/console/exec/exec.test.ts +258 -0
- package/src/commands/console/exec/exec.ts +130 -0
- package/src/commands/console/exec/execute.luau +202 -0
- package/src/commands/console/logs/logs.test.ts +138 -0
- package/src/commands/console/logs/logs.ts +115 -0
- package/src/commands/console/logs/query-logs.luau +76 -0
- package/src/commands/disconnect.test.ts +21 -0
- package/src/commands/disconnect.ts +12 -0
- package/src/commands/explorer/query/query-data-model.luau +206 -0
- package/src/commands/explorer/query/query.test.ts +297 -0
- package/src/commands/explorer/query/query.ts +157 -0
- package/src/commands/formatters.test.ts +237 -0
- package/src/commands/framework/action-loader.test.ts +118 -0
- package/src/commands/framework/action-loader.ts +65 -0
- package/src/commands/framework/arg-builder.test.ts +298 -0
- package/src/commands/framework/arg-builder.ts +203 -0
- package/src/commands/framework/command-registry.test.ts +204 -0
- package/src/commands/framework/command-registry.ts +51 -0
- package/src/commands/framework/define-command.test.ts +161 -0
- package/src/commands/framework/define-command.ts +114 -0
- package/src/commands/framework/index.ts +33 -0
- package/src/commands/index.ts +72 -0
- package/src/commands/linux/inject-credentials/inject-credentials.ts +118 -0
- package/src/commands/linux/setup/setup.ts +145 -0
- package/src/commands/linux/status/status.ts +180 -0
- package/src/commands/plugin/install/install.ts +31 -0
- package/src/commands/plugin/uninstall/uninstall.ts +54 -0
- package/src/commands/process/close/close.ts +52 -0
- package/src/commands/process/format-state.ts +21 -0
- package/src/commands/process/info/info.test.ts +76 -0
- package/src/commands/process/info/info.ts +54 -0
- package/src/commands/process/info/query-state.luau +48 -0
- package/src/commands/process/launch/launch.test.ts +65 -0
- package/src/commands/process/launch/launch.ts +45 -0
- package/src/commands/process/list/list.test.ts +82 -0
- package/src/commands/process/list/list.ts +75 -0
- package/src/commands/process/run/run.ts +98 -0
- package/src/commands/rgba-to-png.ts +98 -0
- package/src/commands/serve/serve.test.ts +139 -0
- package/src/commands/serve/serve.ts +161 -0
- package/src/commands/viewport/screenshot/capture-screenshot.luau +247 -0
- package/src/commands/viewport/screenshot/screenshot.test.ts +181 -0
- package/src/commands/viewport/screenshot/screenshot.ts +71 -0
- package/src/docker/docker-delegator.test.ts +159 -0
- package/src/docker/docker-delegator.ts +240 -0
- package/src/index.test.ts +58 -0
- package/src/index.ts +104 -3
- package/src/linux/README.md +130 -0
- package/src/linux/index.ts +25 -0
- package/src/linux/linux-config.test.ts +66 -0
- package/src/linux/linux-config.ts +102 -0
- package/src/linux/linux-credential-writer.ts +421 -0
- package/src/linux/linux-display-manager.ts +106 -0
- package/src/linux/linux-env-guard.test.ts +62 -0
- package/src/linux/linux-env-guard.ts +38 -0
- package/src/linux/linux-fflags.test.ts +78 -0
- package/src/linux/linux-fflags.ts +48 -0
- package/src/linux/linux-prerequisites.ts +152 -0
- package/src/linux/linux-shader-patcher.test.ts +76 -0
- package/src/linux/linux-shader-patcher.ts +56 -0
- package/src/linux/linux-studio-installer.ts +113 -0
- package/src/linux/linux-studio-launcher.ts +90 -0
- package/src/linux/linux-version-resolver.ts +74 -0
- package/src/linux/linux-wine-env.test.ts +56 -0
- package/src/linux/linux-wine-env.ts +38 -0
- package/src/linux/write-cred.c +48 -0
- package/src/plugin/persistent-plugin-installer.test.ts +168 -0
- package/src/plugin/persistent-plugin-installer.ts +90 -0
- package/src/plugin/plugin-discovery.test.ts +70 -0
- package/src/plugin/plugin-discovery.ts +21 -0
- package/src/plugin/plugin-injector.ts +1 -1
- package/src/process/studio-process-manager.test.ts +22 -1
- package/src/process/studio-process-manager.ts +57 -18
- package/src/server/action-dispatcher.test.ts +240 -0
- package/src/server/action-dispatcher.ts +89 -0
- package/src/server/index.ts +0 -3
- package/src/server/pending-request-map.test.ts +261 -0
- package/src/server/pending-request-map.ts +87 -0
- package/src/server/plugin-detection.test.ts +195 -0
- package/src/server/studio-bridge-server.test.ts +321 -283
- package/src/server/studio-bridge-server.ts +469 -111
- package/src/server/web-socket-protocol-basic.test.ts +131 -0
- package/src/server/web-socket-protocol.test.ts +658 -159
- package/src/server/web-socket-protocol.ts +668 -58
- package/src/test/e2e/hand-off.test.ts +338 -0
- package/src/test/e2e/persistent-session.test.ts +442 -0
- package/src/test/e2e/split-server.test.ts +290 -0
- package/src/test/helpers/mock-plugin-client.ts +276 -0
- package/templates/studio-bridge-plugin/src/Shared/ActionRouter.luau +245 -0
- package/templates/studio-bridge-plugin/src/Shared/DiscoveryStateMachine.luau +203 -0
- package/templates/studio-bridge-plugin/src/Shared/MessageBuffer.luau +144 -0
- package/templates/studio-bridge-plugin/src/Shared/Protocol.luau +132 -0
- package/templates/studio-bridge-plugin/src/StudioBridgePlugin.server.lua +364 -133
- package/templates/studio-bridge-plugin/src/Vendor/png.luau +1247 -0
- package/templates/studio-bridge-plugin-test/test/actions.test.luau +580 -0
- package/templates/studio-bridge-plugin-test/test/discovery.test.luau +622 -0
- package/templates/studio-bridge-plugin-test/test/execute-handler.test.luau +406 -0
- package/templates/studio-bridge-plugin-test/test/hash-lifecycle.test.luau +814 -0
- package/templates/studio-bridge-plugin-test/test/integration.test.luau +1020 -0
- package/templates/studio-bridge-plugin-test/test/new-actions.test.luau +339 -0
- package/templates/studio-bridge-plugin-test/test/plugin-entry.test.luau +493 -0
- package/templates/studio-bridge-plugin-test/test/protocol.test.luau +506 -0
- package/templates/studio-bridge-plugin-test/test/roblox-mocks.luau +108 -0
- package/templates/studio-bridge-plugin-test/test/test-runner.luau +112 -0
- package/dist/src/cli/commands/exec-command.d.ts +0 -15
- package/dist/src/cli/commands/exec-command.d.ts.map +0 -1
- package/dist/src/cli/commands/exec-command.js +0 -35
- package/dist/src/cli/commands/exec-command.js.map +0 -1
- package/dist/src/cli/commands/run-command.d.ts +0 -15
- package/dist/src/cli/commands/run-command.d.ts.map +0 -1
- package/dist/src/cli/commands/run-command.js +0 -47
- package/dist/src/cli/commands/run-command.js.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-command.d.ts +0 -17
- package/dist/src/cli/commands/terminal/terminal-command.d.ts.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-command.js +0 -41
- package/dist/src/cli/commands/terminal/terminal-command.js.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-editor.d.ts +0 -43
- package/dist/src/cli/commands/terminal/terminal-editor.d.ts.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-editor.js +0 -430
- package/dist/src/cli/commands/terminal/terminal-editor.js.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-mode.d.ts +0 -13
- package/dist/src/cli/commands/terminal/terminal-mode.d.ts.map +0 -1
- package/dist/src/cli/commands/terminal/terminal-mode.js +0 -141
- package/dist/src/cli/commands/terminal/terminal-mode.js.map +0 -1
- package/dist/src/server/web-socket-protocol.smoke.test.d.ts +0 -6
- package/dist/src/server/web-socket-protocol.smoke.test.d.ts.map +0 -1
- package/dist/src/server/web-socket-protocol.smoke.test.js +0 -196
- package/dist/src/server/web-socket-protocol.smoke.test.js.map +0 -1
- package/src/cli/commands/exec-command.ts +0 -48
- package/src/cli/commands/run-command.ts +0 -63
- package/src/cli/commands/terminal/terminal-command.ts +0 -54
- package/src/cli/commands/terminal/terminal-editor.ts +0 -500
- package/src/cli/commands/terminal/terminal-mode.ts +0 -184
- package/src/server/web-socket-protocol.smoke.test.ts +0 -255
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for host-protocol -- validates encode/decode round-trip
|
|
3
|
+
* for all envelope message types.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect } from 'vitest';
|
|
7
|
+
import {
|
|
8
|
+
encodeHostMessage,
|
|
9
|
+
decodeHostMessage,
|
|
10
|
+
type HostEnvelope,
|
|
11
|
+
type ListSessionsRequest,
|
|
12
|
+
type ListInstancesRequest,
|
|
13
|
+
type HostResponse,
|
|
14
|
+
type ListSessionsResponse,
|
|
15
|
+
type ListInstancesResponse,
|
|
16
|
+
type SessionEvent,
|
|
17
|
+
type HostProtocolMessage,
|
|
18
|
+
} from './host-protocol.js';
|
|
19
|
+
import type { SessionInfo, InstanceInfo } from '../types.js';
|
|
20
|
+
|
|
21
|
+
function roundTrip(msg: HostProtocolMessage): HostProtocolMessage | null {
|
|
22
|
+
return decodeHostMessage(encodeHostMessage(msg));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createSessionInfo(overrides: Partial<SessionInfo> = {}): SessionInfo {
|
|
26
|
+
return {
|
|
27
|
+
sessionId: 'session-1',
|
|
28
|
+
placeName: 'TestPlace',
|
|
29
|
+
state: 'Edit',
|
|
30
|
+
pluginVersion: '1.0.0',
|
|
31
|
+
capabilities: ['execute'],
|
|
32
|
+
connectedAt: new Date('2024-01-01'),
|
|
33
|
+
origin: 'user',
|
|
34
|
+
context: 'edit',
|
|
35
|
+
instanceId: 'inst-1',
|
|
36
|
+
placeId: 100,
|
|
37
|
+
gameId: 200,
|
|
38
|
+
...overrides,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('host-protocol', () => {
|
|
43
|
+
describe('HostEnvelope', () => {
|
|
44
|
+
it('round-trips correctly', () => {
|
|
45
|
+
const msg: HostEnvelope = {
|
|
46
|
+
type: 'host-envelope',
|
|
47
|
+
requestId: 'req-1',
|
|
48
|
+
targetSessionId: 'session-1',
|
|
49
|
+
action: {
|
|
50
|
+
type: 'execute',
|
|
51
|
+
sessionId: 'session-1',
|
|
52
|
+
payload: { script: 'print("hi")' },
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const decoded = roundTrip(msg);
|
|
57
|
+
|
|
58
|
+
expect(decoded).not.toBeNull();
|
|
59
|
+
expect(decoded!.type).toBe('host-envelope');
|
|
60
|
+
const envelope = decoded as HostEnvelope;
|
|
61
|
+
expect(envelope.requestId).toBe('req-1');
|
|
62
|
+
expect(envelope.targetSessionId).toBe('session-1');
|
|
63
|
+
expect(envelope.action.type).toBe('execute');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('ListSessionsRequest', () => {
|
|
68
|
+
it('round-trips correctly', () => {
|
|
69
|
+
const msg: ListSessionsRequest = {
|
|
70
|
+
type: 'list-sessions',
|
|
71
|
+
requestId: 'req-2',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const decoded = roundTrip(msg);
|
|
75
|
+
|
|
76
|
+
expect(decoded).not.toBeNull();
|
|
77
|
+
expect(decoded!.type).toBe('list-sessions');
|
|
78
|
+
expect((decoded as ListSessionsRequest).requestId).toBe('req-2');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('ListInstancesRequest', () => {
|
|
83
|
+
it('round-trips correctly', () => {
|
|
84
|
+
const msg: ListInstancesRequest = {
|
|
85
|
+
type: 'list-instances',
|
|
86
|
+
requestId: 'req-3',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const decoded = roundTrip(msg);
|
|
90
|
+
|
|
91
|
+
expect(decoded).not.toBeNull();
|
|
92
|
+
expect(decoded!.type).toBe('list-instances');
|
|
93
|
+
expect((decoded as ListInstancesRequest).requestId).toBe('req-3');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('HostResponse', () => {
|
|
98
|
+
it('round-trips correctly', () => {
|
|
99
|
+
const msg: HostResponse = {
|
|
100
|
+
type: 'host-response',
|
|
101
|
+
requestId: 'req-4',
|
|
102
|
+
result: {
|
|
103
|
+
type: 'stateResult',
|
|
104
|
+
sessionId: 'session-1',
|
|
105
|
+
requestId: 'req-4',
|
|
106
|
+
payload: {
|
|
107
|
+
state: 'Edit',
|
|
108
|
+
placeId: 100,
|
|
109
|
+
placeName: 'Test',
|
|
110
|
+
gameId: 200,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const decoded = roundTrip(msg);
|
|
116
|
+
|
|
117
|
+
expect(decoded).not.toBeNull();
|
|
118
|
+
expect(decoded!.type).toBe('host-response');
|
|
119
|
+
const response = decoded as HostResponse;
|
|
120
|
+
expect(response.requestId).toBe('req-4');
|
|
121
|
+
expect(response.result.type).toBe('stateResult');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('ListSessionsResponse', () => {
|
|
126
|
+
it('round-trips correctly', () => {
|
|
127
|
+
const msg: ListSessionsResponse = {
|
|
128
|
+
type: 'list-sessions-response',
|
|
129
|
+
requestId: 'req-5',
|
|
130
|
+
sessions: [createSessionInfo()],
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const decoded = roundTrip(msg);
|
|
134
|
+
|
|
135
|
+
expect(decoded).not.toBeNull();
|
|
136
|
+
expect(decoded!.type).toBe('list-sessions-response');
|
|
137
|
+
const response = decoded as ListSessionsResponse;
|
|
138
|
+
expect(response.requestId).toBe('req-5');
|
|
139
|
+
expect(response.sessions).toHaveLength(1);
|
|
140
|
+
expect(response.sessions[0].sessionId).toBe('session-1');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('handles empty session list', () => {
|
|
144
|
+
const msg: ListSessionsResponse = {
|
|
145
|
+
type: 'list-sessions-response',
|
|
146
|
+
requestId: 'req-6',
|
|
147
|
+
sessions: [],
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const decoded = roundTrip(msg);
|
|
151
|
+
|
|
152
|
+
expect(decoded).not.toBeNull();
|
|
153
|
+
expect((decoded as ListSessionsResponse).sessions).toHaveLength(0);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('ListInstancesResponse', () => {
|
|
158
|
+
it('round-trips correctly', () => {
|
|
159
|
+
const instance: InstanceInfo = {
|
|
160
|
+
instanceId: 'inst-1',
|
|
161
|
+
placeName: 'TestPlace',
|
|
162
|
+
placeId: 100,
|
|
163
|
+
gameId: 200,
|
|
164
|
+
contexts: ['edit', 'server'],
|
|
165
|
+
origin: 'user',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const msg: ListInstancesResponse = {
|
|
169
|
+
type: 'list-instances-response',
|
|
170
|
+
requestId: 'req-7',
|
|
171
|
+
instances: [instance],
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const decoded = roundTrip(msg);
|
|
175
|
+
|
|
176
|
+
expect(decoded).not.toBeNull();
|
|
177
|
+
expect(decoded!.type).toBe('list-instances-response');
|
|
178
|
+
const response = decoded as ListInstancesResponse;
|
|
179
|
+
expect(response.instances).toHaveLength(1);
|
|
180
|
+
expect(response.instances[0].instanceId).toBe('inst-1');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('SessionEvent', () => {
|
|
185
|
+
it('round-trips connected event', () => {
|
|
186
|
+
const msg: SessionEvent = {
|
|
187
|
+
type: 'session-event',
|
|
188
|
+
event: 'connected',
|
|
189
|
+
session: createSessionInfo(),
|
|
190
|
+
sessionId: 'session-1',
|
|
191
|
+
context: 'edit',
|
|
192
|
+
instanceId: 'inst-1',
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const decoded = roundTrip(msg);
|
|
196
|
+
|
|
197
|
+
expect(decoded).not.toBeNull();
|
|
198
|
+
expect(decoded!.type).toBe('session-event');
|
|
199
|
+
const event = decoded as SessionEvent;
|
|
200
|
+
expect(event.event).toBe('connected');
|
|
201
|
+
expect(event.session).toBeDefined();
|
|
202
|
+
expect(event.sessionId).toBe('session-1');
|
|
203
|
+
expect(event.context).toBe('edit');
|
|
204
|
+
expect(event.instanceId).toBe('inst-1');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('round-trips disconnected event (no session)', () => {
|
|
208
|
+
const msg: SessionEvent = {
|
|
209
|
+
type: 'session-event',
|
|
210
|
+
event: 'disconnected',
|
|
211
|
+
sessionId: 'session-1',
|
|
212
|
+
context: 'edit',
|
|
213
|
+
instanceId: 'inst-1',
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const decoded = roundTrip(msg);
|
|
217
|
+
|
|
218
|
+
expect(decoded).not.toBeNull();
|
|
219
|
+
const event = decoded as SessionEvent;
|
|
220
|
+
expect(event.event).toBe('disconnected');
|
|
221
|
+
expect(event.session).toBeUndefined();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('round-trips state-changed event', () => {
|
|
225
|
+
const msg: SessionEvent = {
|
|
226
|
+
type: 'session-event',
|
|
227
|
+
event: 'state-changed',
|
|
228
|
+
session: createSessionInfo({ state: 'Play' }),
|
|
229
|
+
sessionId: 'session-1',
|
|
230
|
+
context: 'edit',
|
|
231
|
+
instanceId: 'inst-1',
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const decoded = roundTrip(msg);
|
|
235
|
+
|
|
236
|
+
expect(decoded).not.toBeNull();
|
|
237
|
+
expect((decoded as SessionEvent).event).toBe('state-changed');
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('error handling', () => {
|
|
242
|
+
it('returns null for invalid JSON', () => {
|
|
243
|
+
expect(decodeHostMessage('not json')).toBeNull();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('returns null for non-object values', () => {
|
|
247
|
+
expect(decodeHostMessage('"hello"')).toBeNull();
|
|
248
|
+
expect(decodeHostMessage('42')).toBeNull();
|
|
249
|
+
expect(decodeHostMessage('null')).toBeNull();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('returns null for missing type', () => {
|
|
253
|
+
expect(
|
|
254
|
+
decodeHostMessage(JSON.stringify({ requestId: 'r-1' }))
|
|
255
|
+
).toBeNull();
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('returns null for unknown type', () => {
|
|
259
|
+
expect(decodeHostMessage(JSON.stringify({ type: 'unknown' }))).toBeNull();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('returns null for host-envelope with missing fields', () => {
|
|
263
|
+
expect(
|
|
264
|
+
decodeHostMessage(
|
|
265
|
+
JSON.stringify({
|
|
266
|
+
type: 'host-envelope',
|
|
267
|
+
requestId: 'r-1',
|
|
268
|
+
// missing targetSessionId and action
|
|
269
|
+
})
|
|
270
|
+
)
|
|
271
|
+
).toBeNull();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('returns null for list-sessions with missing requestId', () => {
|
|
275
|
+
expect(
|
|
276
|
+
decodeHostMessage(
|
|
277
|
+
JSON.stringify({
|
|
278
|
+
type: 'list-sessions',
|
|
279
|
+
})
|
|
280
|
+
)
|
|
281
|
+
).toBeNull();
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('returns null for session-event with invalid event value', () => {
|
|
285
|
+
expect(
|
|
286
|
+
decodeHostMessage(
|
|
287
|
+
JSON.stringify({
|
|
288
|
+
type: 'session-event',
|
|
289
|
+
event: 'invalid',
|
|
290
|
+
sessionId: 's-1',
|
|
291
|
+
context: 'edit',
|
|
292
|
+
instanceId: 'i-1',
|
|
293
|
+
})
|
|
294
|
+
)
|
|
295
|
+
).toBeNull();
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
describe('HostEnvelope action validation', () => {
|
|
300
|
+
function envelope(action: unknown): string {
|
|
301
|
+
return JSON.stringify({
|
|
302
|
+
type: 'host-envelope',
|
|
303
|
+
requestId: 'r-1',
|
|
304
|
+
targetSessionId: 's-1',
|
|
305
|
+
action,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
it('returns null when action.type is missing', () => {
|
|
310
|
+
expect(
|
|
311
|
+
decodeHostMessage(
|
|
312
|
+
envelope({ sessionId: 's-1', payload: { script: 'x' } })
|
|
313
|
+
)
|
|
314
|
+
).toBeNull();
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('returns null when action.type is unknown', () => {
|
|
318
|
+
expect(
|
|
319
|
+
decodeHostMessage(
|
|
320
|
+
envelope({
|
|
321
|
+
type: 'totally-fake',
|
|
322
|
+
sessionId: 's-1',
|
|
323
|
+
payload: {},
|
|
324
|
+
})
|
|
325
|
+
)
|
|
326
|
+
).toBeNull();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('returns null when execute action is missing payload.script', () => {
|
|
330
|
+
expect(
|
|
331
|
+
decodeHostMessage(
|
|
332
|
+
envelope({ type: 'execute', sessionId: 's-1', payload: {} })
|
|
333
|
+
)
|
|
334
|
+
).toBeNull();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('returns null when execute action has wrong script type', () => {
|
|
338
|
+
expect(
|
|
339
|
+
decodeHostMessage(
|
|
340
|
+
envelope({
|
|
341
|
+
type: 'execute',
|
|
342
|
+
sessionId: 's-1',
|
|
343
|
+
payload: { script: 42 },
|
|
344
|
+
})
|
|
345
|
+
)
|
|
346
|
+
).toBeNull();
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('returns null when queryDataModel action is missing payload.path', () => {
|
|
350
|
+
expect(
|
|
351
|
+
decodeHostMessage(
|
|
352
|
+
envelope({
|
|
353
|
+
type: 'queryDataModel',
|
|
354
|
+
sessionId: 's-1',
|
|
355
|
+
requestId: 'a',
|
|
356
|
+
payload: {},
|
|
357
|
+
})
|
|
358
|
+
)
|
|
359
|
+
).toBeNull();
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('returns null when error action has unknown error code', () => {
|
|
363
|
+
expect(
|
|
364
|
+
decodeHostMessage(
|
|
365
|
+
envelope({
|
|
366
|
+
type: 'error',
|
|
367
|
+
sessionId: 's-1',
|
|
368
|
+
payload: { code: 'NOT_A_REAL_CODE', message: 'oops' },
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
).toBeNull();
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it('returns null when sessionId is missing on action', () => {
|
|
375
|
+
expect(
|
|
376
|
+
decodeHostMessage(
|
|
377
|
+
envelope({ type: 'execute', payload: { script: 'x' } })
|
|
378
|
+
)
|
|
379
|
+
).toBeNull();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('accepts a well-formed execute action', () => {
|
|
383
|
+
const decoded = decodeHostMessage(
|
|
384
|
+
envelope({
|
|
385
|
+
type: 'execute',
|
|
386
|
+
sessionId: 's-1',
|
|
387
|
+
payload: { script: 'print("ok")' },
|
|
388
|
+
})
|
|
389
|
+
);
|
|
390
|
+
expect(decoded).not.toBeNull();
|
|
391
|
+
expect(decoded!.type).toBe('host-envelope');
|
|
392
|
+
expect((decoded as HostEnvelope).action.type).toBe('execute');
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('accepts a well-formed queryDataModel action with all fields', () => {
|
|
396
|
+
const decoded = decodeHostMessage(
|
|
397
|
+
envelope({
|
|
398
|
+
type: 'queryDataModel',
|
|
399
|
+
sessionId: 's-1',
|
|
400
|
+
requestId: 'q-1',
|
|
401
|
+
payload: {
|
|
402
|
+
path: 'workspace',
|
|
403
|
+
depth: 2,
|
|
404
|
+
properties: ['Name', 'ClassName'],
|
|
405
|
+
includeAttributes: true,
|
|
406
|
+
find: { name: 'Camera', recursive: false },
|
|
407
|
+
listServices: false,
|
|
408
|
+
},
|
|
409
|
+
})
|
|
410
|
+
);
|
|
411
|
+
expect(decoded).not.toBeNull();
|
|
412
|
+
expect(decoded!.type).toBe('host-envelope');
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Envelope protocol for client-to-host communication. When a bridge client
|
|
3
|
+
* needs to send an action to a plugin session, it wraps the action in a
|
|
4
|
+
* HostEnvelope and sends it to the host. The host unwraps the envelope,
|
|
5
|
+
* forwards the action to the plugin, wraps the response in a HostResponse,
|
|
6
|
+
* and sends it back to the client.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import type {
|
|
11
|
+
ServerMessage,
|
|
12
|
+
PluginMessage,
|
|
13
|
+
} from '../../server/web-socket-protocol.js';
|
|
14
|
+
import type { SessionInfo, SessionContext, InstanceInfo } from '../types.js';
|
|
15
|
+
|
|
16
|
+
export interface HostEnvelope {
|
|
17
|
+
type: 'host-envelope';
|
|
18
|
+
requestId: string;
|
|
19
|
+
targetSessionId: string;
|
|
20
|
+
action: ServerMessage;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ListSessionsRequest {
|
|
24
|
+
type: 'list-sessions';
|
|
25
|
+
requestId: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ListInstancesRequest {
|
|
29
|
+
type: 'list-instances';
|
|
30
|
+
requestId: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HostResponse {
|
|
34
|
+
type: 'host-response';
|
|
35
|
+
requestId: string;
|
|
36
|
+
result: PluginMessage;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ListSessionsResponse {
|
|
40
|
+
type: 'list-sessions-response';
|
|
41
|
+
requestId: string;
|
|
42
|
+
sessions: SessionInfo[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ListInstancesResponse {
|
|
46
|
+
type: 'list-instances-response';
|
|
47
|
+
requestId: string;
|
|
48
|
+
instances: InstanceInfo[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface SessionEvent {
|
|
52
|
+
type: 'session-event';
|
|
53
|
+
event: 'connected' | 'disconnected' | 'state-changed';
|
|
54
|
+
session?: SessionInfo;
|
|
55
|
+
sessionId: string;
|
|
56
|
+
context: SessionContext;
|
|
57
|
+
instanceId: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface HostTransferNotice {
|
|
61
|
+
type: 'host-transfer';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type HostProtocolMessage =
|
|
65
|
+
| HostEnvelope
|
|
66
|
+
| ListSessionsRequest
|
|
67
|
+
| ListInstancesRequest
|
|
68
|
+
| HostResponse
|
|
69
|
+
| ListSessionsResponse
|
|
70
|
+
| ListInstancesResponse
|
|
71
|
+
| SessionEvent
|
|
72
|
+
| HostTransferNotice;
|
|
73
|
+
|
|
74
|
+
// --- Runtime validation schemas ---
|
|
75
|
+
//
|
|
76
|
+
// `ServerMessageSchema` is the load-bearing one: it validates the `action`
|
|
77
|
+
// payload that /client connections forward to plugins. Without it, a buggy
|
|
78
|
+
// or hostile CLI client could ship malformed actions and crash the plugin.
|
|
79
|
+
// Container fields like `result`, `sessions`, `instances`, and `session` are
|
|
80
|
+
// validated only as objects/arrays — their interior shapes flow through to
|
|
81
|
+
// callers that already know how to handle the typed contracts.
|
|
82
|
+
|
|
83
|
+
const ErrorCodeSchema = z.enum([
|
|
84
|
+
'UNKNOWN_REQUEST',
|
|
85
|
+
'INVALID_PAYLOAD',
|
|
86
|
+
'TIMEOUT',
|
|
87
|
+
'CAPABILITY_NOT_SUPPORTED',
|
|
88
|
+
'INSTANCE_NOT_FOUND',
|
|
89
|
+
'PROPERTY_NOT_FOUND',
|
|
90
|
+
'SCREENSHOT_FAILED',
|
|
91
|
+
'SCRIPT_LOAD_ERROR',
|
|
92
|
+
'SCRIPT_RUNTIME_ERROR',
|
|
93
|
+
'BUSY',
|
|
94
|
+
'SESSION_MISMATCH',
|
|
95
|
+
'INTERNAL_ERROR',
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
const OutputLevelSchema = z.enum(['Print', 'Info', 'Warning', 'Error']);
|
|
99
|
+
|
|
100
|
+
const ServerMessageSchema = z.discriminatedUnion('type', [
|
|
101
|
+
z.object({
|
|
102
|
+
type: z.literal('execute'),
|
|
103
|
+
sessionId: z.string(),
|
|
104
|
+
requestId: z.string().optional(),
|
|
105
|
+
payload: z.object({ script: z.string() }),
|
|
106
|
+
}),
|
|
107
|
+
z.object({
|
|
108
|
+
type: z.literal('shutdown'),
|
|
109
|
+
sessionId: z.string(),
|
|
110
|
+
payload: z.object({}).loose(),
|
|
111
|
+
}),
|
|
112
|
+
z.object({
|
|
113
|
+
type: z.literal('queryState'),
|
|
114
|
+
sessionId: z.string(),
|
|
115
|
+
requestId: z.string(),
|
|
116
|
+
payload: z.object({}).loose(),
|
|
117
|
+
}),
|
|
118
|
+
z.object({
|
|
119
|
+
type: z.literal('captureScreenshot'),
|
|
120
|
+
sessionId: z.string(),
|
|
121
|
+
requestId: z.string(),
|
|
122
|
+
payload: z.object({
|
|
123
|
+
format: z.literal('png').optional(),
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
126
|
+
z.object({
|
|
127
|
+
type: z.literal('queryDataModel'),
|
|
128
|
+
sessionId: z.string(),
|
|
129
|
+
requestId: z.string(),
|
|
130
|
+
payload: z.object({
|
|
131
|
+
path: z.string(),
|
|
132
|
+
depth: z.number().optional(),
|
|
133
|
+
properties: z.array(z.string()).optional(),
|
|
134
|
+
includeAttributes: z.boolean().optional(),
|
|
135
|
+
find: z
|
|
136
|
+
.object({
|
|
137
|
+
name: z.string(),
|
|
138
|
+
recursive: z.boolean().optional(),
|
|
139
|
+
})
|
|
140
|
+
.optional(),
|
|
141
|
+
listServices: z.boolean().optional(),
|
|
142
|
+
}),
|
|
143
|
+
}),
|
|
144
|
+
z.object({
|
|
145
|
+
type: z.literal('queryLogs'),
|
|
146
|
+
sessionId: z.string(),
|
|
147
|
+
requestId: z.string(),
|
|
148
|
+
payload: z.object({
|
|
149
|
+
count: z.number().optional(),
|
|
150
|
+
direction: z.enum(['head', 'tail']).optional(),
|
|
151
|
+
levels: z.array(OutputLevelSchema).optional(),
|
|
152
|
+
includeInternal: z.boolean().optional(),
|
|
153
|
+
}),
|
|
154
|
+
}),
|
|
155
|
+
z.object({
|
|
156
|
+
type: z.literal('registerAction'),
|
|
157
|
+
sessionId: z.string(),
|
|
158
|
+
requestId: z.string(),
|
|
159
|
+
payload: z.object({
|
|
160
|
+
name: z.string(),
|
|
161
|
+
source: z.string(),
|
|
162
|
+
hash: z.string().optional(),
|
|
163
|
+
responseType: z.string().optional(),
|
|
164
|
+
}),
|
|
165
|
+
}),
|
|
166
|
+
z.object({
|
|
167
|
+
type: z.literal('syncActions'),
|
|
168
|
+
sessionId: z.string(),
|
|
169
|
+
requestId: z.string(),
|
|
170
|
+
payload: z.object({
|
|
171
|
+
actions: z.record(z.string(), z.string()),
|
|
172
|
+
}),
|
|
173
|
+
}),
|
|
174
|
+
z.object({
|
|
175
|
+
type: z.literal('error'),
|
|
176
|
+
sessionId: z.string(),
|
|
177
|
+
requestId: z.string().optional(),
|
|
178
|
+
payload: z.object({
|
|
179
|
+
code: ErrorCodeSchema,
|
|
180
|
+
message: z.string(),
|
|
181
|
+
details: z.unknown().optional(),
|
|
182
|
+
}),
|
|
183
|
+
}),
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
const LooseObjectSchema = z.record(z.string(), z.unknown());
|
|
187
|
+
|
|
188
|
+
const HostProtocolMessageSchema = z.discriminatedUnion('type', [
|
|
189
|
+
z.object({
|
|
190
|
+
type: z.literal('host-envelope'),
|
|
191
|
+
requestId: z.string(),
|
|
192
|
+
targetSessionId: z.string(),
|
|
193
|
+
action: ServerMessageSchema,
|
|
194
|
+
}),
|
|
195
|
+
z.object({
|
|
196
|
+
type: z.literal('list-sessions'),
|
|
197
|
+
requestId: z.string(),
|
|
198
|
+
}),
|
|
199
|
+
z.object({
|
|
200
|
+
type: z.literal('list-instances'),
|
|
201
|
+
requestId: z.string(),
|
|
202
|
+
}),
|
|
203
|
+
z.object({
|
|
204
|
+
type: z.literal('host-response'),
|
|
205
|
+
requestId: z.string(),
|
|
206
|
+
result: LooseObjectSchema,
|
|
207
|
+
}),
|
|
208
|
+
z.object({
|
|
209
|
+
type: z.literal('list-sessions-response'),
|
|
210
|
+
requestId: z.string(),
|
|
211
|
+
sessions: z.array(LooseObjectSchema),
|
|
212
|
+
}),
|
|
213
|
+
z.object({
|
|
214
|
+
type: z.literal('list-instances-response'),
|
|
215
|
+
requestId: z.string(),
|
|
216
|
+
instances: z.array(LooseObjectSchema),
|
|
217
|
+
}),
|
|
218
|
+
z.object({
|
|
219
|
+
type: z.literal('session-event'),
|
|
220
|
+
event: z.enum(['connected', 'disconnected', 'state-changed']),
|
|
221
|
+
session: LooseObjectSchema.optional(),
|
|
222
|
+
sessionId: z.string(),
|
|
223
|
+
context: z.enum(['edit', 'client', 'server']),
|
|
224
|
+
instanceId: z.string(),
|
|
225
|
+
}),
|
|
226
|
+
z.object({
|
|
227
|
+
type: z.literal('host-transfer'),
|
|
228
|
+
}),
|
|
229
|
+
]);
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Encode a host protocol message to a JSON string.
|
|
233
|
+
*/
|
|
234
|
+
export function encodeHostMessage(msg: HostProtocolMessage): string {
|
|
235
|
+
return JSON.stringify(msg);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Decode a host protocol message from a JSON string.
|
|
240
|
+
* Returns null if the message is malformed or has an unknown type.
|
|
241
|
+
*/
|
|
242
|
+
export function decodeHostMessage(raw: string): HostProtocolMessage | null {
|
|
243
|
+
let parsed: unknown;
|
|
244
|
+
try {
|
|
245
|
+
parsed = JSON.parse(raw);
|
|
246
|
+
} catch {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const result = HostProtocolMessageSchema.safeParse(parsed);
|
|
251
|
+
if (!result.success) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return result.data as HostProtocolMessage;
|
|
255
|
+
}
|