windows-development-sandbox 1.10.0 → 1.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -17
- package/config.example.json +5 -1
- package/dist/app/features/accounts/accounts.def.d.ts +122 -0
- package/dist/app/features/accounts/accounts.def.js +243 -0
- package/dist/app/features/accounts/accounts.run.d.ts +51 -0
- package/dist/app/features/accounts/accounts.run.js +125 -0
- package/dist/app/features/accounts/index.d.ts +2 -0
- package/dist/app/features/accounts/index.js +3 -0
- package/dist/app/features/agents/agent-entry.d.ts +17 -0
- package/dist/app/features/agents/agent-entry.js +50 -0
- package/dist/app/features/agents/agents.def.d.ts +65 -0
- package/dist/app/features/agents/agents.def.js +142 -0
- package/dist/app/features/agents/agents.run.d.ts +31 -0
- package/dist/app/features/agents/agents.run.js +189 -0
- package/dist/app/features/agents/index.d.ts +3 -0
- package/dist/app/features/agents/index.js +4 -0
- package/dist/app/features/apps/apps-rows.d.ts +31 -0
- package/dist/app/features/apps/apps-rows.js +73 -0
- package/dist/app/features/apps/apps.def.d.ts +181 -0
- package/dist/app/features/apps/apps.def.js +264 -0
- package/dist/app/features/apps/apps.run.d.ts +58 -0
- package/dist/app/features/apps/apps.run.js +76 -0
- package/dist/app/features/apps/index.d.ts +3 -0
- package/dist/app/features/apps/index.js +4 -0
- package/dist/app/features/data/data.def.d.ts +154 -0
- package/dist/app/features/data/data.def.js +194 -0
- package/dist/app/features/data/data.run.d.ts +46 -0
- package/dist/app/features/data/data.run.js +141 -0
- package/dist/app/features/data/index.d.ts +2 -0
- package/dist/app/features/data/index.js +3 -0
- package/dist/app/features/defs.d.ts +959 -4
- package/dist/app/features/defs.js +151 -10
- package/dist/app/features/engine/engine.def.d.ts +228 -0
- package/dist/app/features/engine/engine.def.js +194 -0
- package/dist/app/features/engine/engine.run.d.ts +72 -0
- package/dist/app/features/engine/engine.run.js +77 -0
- package/dist/app/features/engine/index.d.ts +2 -0
- package/dist/app/features/engine/index.js +4 -0
- package/dist/app/features/files/files.def.d.ts +51 -0
- package/dist/app/features/files/files.def.js +38 -0
- package/dist/app/features/files/files.run.d.ts +20 -0
- package/dist/app/features/files/files.run.js +59 -0
- package/dist/app/features/files/index.d.ts +2 -0
- package/dist/app/features/files/index.js +3 -0
- package/dist/app/features/github/github.def.d.ts +80 -0
- package/dist/app/features/github/github.def.js +142 -0
- package/dist/app/features/github/github.run.d.ts +36 -0
- package/dist/app/features/github/github.run.js +59 -0
- package/dist/app/features/github/index.d.ts +2 -0
- package/dist/app/features/github/index.js +3 -0
- package/dist/app/features/health/health.def.d.ts +275 -0
- package/dist/app/features/health/health.def.js +297 -0
- package/dist/app/features/health/health.run.d.ts +125 -0
- package/dist/app/features/health/health.run.js +204 -0
- package/dist/app/features/health/index.d.ts +2 -0
- package/dist/app/features/health/index.js +3 -0
- package/dist/app/features/logs/index.d.ts +2 -0
- package/dist/app/features/logs/index.js +3 -0
- package/dist/app/features/logs/logs.def.d.ts +78 -0
- package/dist/app/features/logs/logs.def.js +115 -0
- package/dist/app/features/logs/logs.run.d.ts +20 -0
- package/dist/app/features/logs/logs.run.js +42 -0
- package/dist/app/features/projects/index.d.ts +2 -0
- package/dist/app/features/projects/index.js +3 -0
- package/dist/app/features/projects/projects.def.d.ts +101 -0
- package/dist/app/features/projects/projects.def.js +208 -0
- package/dist/app/features/projects/projects.run.d.ts +56 -0
- package/dist/app/features/projects/projects.run.js +155 -0
- package/dist/app/features/sandbox/sandbox.def.js +11 -5
- package/dist/app/features/sessions/sessions.def.js +3 -0
- package/dist/app/features/settings/categories.def.js +3 -2
- package/dist/{cli/menu/settings/share.d.ts → app/features/settings/settings-share.d.ts} +1 -1
- package/dist/{cli/menu/settings/share.js → app/features/settings/settings-share.js} +3 -2
- package/dist/app/features/settings/settings.def.d.ts +22 -5
- package/dist/app/features/settings/settings.def.js +81 -6
- package/dist/app/features/settings/settings.run.d.ts +17 -0
- package/dist/app/features/settings/settings.run.js +89 -4
- package/dist/app/features/storage/index.d.ts +2 -0
- package/dist/app/features/storage/index.js +3 -0
- package/dist/app/features/storage/storage.def.d.ts +133 -0
- package/dist/app/features/storage/storage.def.js +220 -0
- package/dist/app/features/storage/storage.run.d.ts +62 -0
- package/dist/app/features/storage/storage.run.js +370 -0
- package/dist/app/features/updates/index.d.ts +3 -0
- package/dist/app/features/updates/index.js +4 -0
- package/dist/app/features/updates/update-lines.d.ts +13 -0
- package/dist/app/features/updates/update-lines.js +61 -0
- package/dist/app/features/updates/updates.def.d.ts +89 -0
- package/dist/app/features/updates/updates.def.js +224 -0
- package/dist/app/features/updates/updates.run.d.ts +48 -0
- package/dist/app/features/updates/updates.run.js +154 -0
- package/dist/app/features/vpn/index.d.ts +2 -0
- package/dist/app/features/vpn/index.js +3 -0
- package/dist/app/features/vpn/vpn.def.d.ts +112 -0
- package/dist/app/features/vpn/vpn.def.js +174 -0
- package/dist/app/features/vpn/vpn.run.d.ts +37 -0
- package/dist/app/features/vpn/vpn.run.js +54 -0
- package/dist/app/features/web/index.d.ts +2 -0
- package/dist/app/features/web/index.js +3 -0
- package/dist/app/features/web/web.def.d.ts +33 -0
- package/dist/app/features/web/web.def.js +90 -0
- package/dist/app/features/web/web.run.d.ts +24 -0
- package/dist/app/features/web/web.run.js +93 -0
- package/dist/app/kernel/define.d.ts +10 -1
- package/dist/app/kernel/io.d.ts +34 -0
- package/dist/app/kernel/io.js +9 -0
- package/dist/app/kernel/rpc.d.ts +17 -0
- package/dist/app/kernel/text.d.ts +2 -0
- package/dist/app/kernel/text.js +7 -0
- package/dist/app/kernel/view.d.ts +24 -1
- package/dist/app/kernel/view.js +1 -1
- package/dist/app/registry.js +74 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/commands/context.d.ts +7 -0
- package/dist/cli/commands/context.js +29 -2
- package/dist/cli/commands/engine.js +5 -58
- package/dist/cli/commands/github.d.ts +2 -0
- package/dist/cli/commands/github.js +11 -0
- package/dist/cli/commands/index.d.ts +3 -5
- package/dist/cli/commands/index.js +3 -5
- package/dist/cli/commands/launch/launch.js +21 -4
- package/dist/cli/commands/launch/running.js +4 -1
- package/dist/cli/commands/maintenance/config.js +1 -6
- package/dist/cli/commands/maintenance/index.d.ts +0 -1
- package/dist/cli/commands/maintenance/index.js +1 -2
- package/dist/cli/commands/maintenance/logs.js +27 -32
- package/dist/cli/commands/maintenance/migrate.d.ts +0 -8
- package/dist/cli/commands/maintenance/migrate.js +2 -44
- package/dist/cli/commands/maintenance/update.d.ts +0 -19
- package/dist/cli/commands/maintenance/update.js +1 -99
- package/dist/cli/commands/projects/index.d.ts +0 -1
- package/dist/cli/commands/projects/index.js +0 -1
- package/dist/cli/commands/registry.d.ts +1 -1
- package/dist/cli/commands/registry.js +29 -11
- package/dist/cli/commands/repair/checks/data.js +1 -1
- package/dist/cli/commands/repair/checks/hcs.js +28 -1
- package/dist/cli/commands/repair/checks/sandbox.js +1 -1
- package/dist/cli/commands/repair/health-run.d.ts +30 -0
- package/dist/cli/commands/repair/health-run.js +32 -0
- package/dist/cli/commands/repair/printer.d.ts +2 -2
- package/dist/cli/commands/repair/printer.js +2 -11
- package/dist/cli/commands/repair/run.d.ts +1 -21
- package/dist/cli/commands/repair/run.js +13 -70
- package/dist/cli/commands/storage/index.d.ts +0 -1
- package/dist/cli/commands/storage/index.js +0 -1
- package/dist/cli/commands/storage/offer.js +6 -2
- package/dist/cli/commands/vpn.d.ts +1 -3
- package/dist/cli/commands/vpn.js +8 -89
- package/dist/cli/commands/web.d.ts +2 -1
- package/dist/cli/commands/web.js +14 -78
- package/dist/cli/index.js +3 -2
- package/dist/cli/manifest.d.ts +16 -153
- package/dist/cli/manifest.js +20 -50
- package/dist/cli/menu/command-form.js +1 -2
- package/dist/cli/menu/io-menu.d.ts +2 -2
- package/dist/cli/menu/io-menu.js +6 -4
- package/dist/cli/menu/menu.js +1 -1
- package/dist/cli/menu/pages/accounts-page.d.ts +5 -17
- package/dist/cli/menu/pages/accounts-page.js +28 -170
- package/dist/cli/menu/pages/agents-page.d.ts +17 -18
- package/dist/cli/menu/pages/agents-page.js +67 -124
- package/dist/cli/menu/pages/apps-page.d.ts +15 -8
- package/dist/cli/menu/pages/apps-page.js +121 -29
- package/dist/cli/menu/pages/list-page.js +10 -1
- package/dist/cli/menu/pages/maintenance-page.d.ts +51 -52
- package/dist/cli/menu/pages/maintenance-page.js +246 -427
- package/dist/cli/menu/pages/sandbox-page.d.ts +3 -5
- package/dist/cli/menu/pages/sandbox-page.js +34 -112
- package/dist/cli/menu/pages/settings-page.d.ts +21 -3
- package/dist/cli/menu/pages/settings-page.js +89 -17
- package/dist/cli/menu/render-view.js +2 -1
- package/dist/cli/menu/settings/index.d.ts +0 -1
- package/dist/cli/menu/settings/index.js +3 -3
- package/dist/cli/menu/views.js +28 -0
- package/dist/cli/operations/handler.js +7 -3
- package/dist/cli/operations/input.d.ts +1 -1
- package/dist/cli/operations/input.js +29 -5
- package/dist/cli/operations/io-cli.js +9 -1
- package/dist/cli/operations/spec.js +8 -2
- package/dist/cli/output/render-view.js +2 -0
- package/dist/cli/{commands/data/collect.js → services/data-collect.js} +2 -2
- package/dist/cli/{commands/data/remove.js → services/data-remove.js} +2 -2
- package/dist/cli/services/data-service.d.ts +1 -1
- package/dist/cli/services/data-service.js +2 -2
- package/dist/cli/services/databases-service.d.ts +5 -0
- package/dist/cli/services/databases-service.js +15 -0
- package/dist/cli/services/health-service.d.ts +8 -4
- package/dist/cli/services/health-service.js +10 -8
- package/dist/cli/services/index.d.ts +4 -1
- package/dist/cli/services/index.js +4 -1
- package/dist/cli/services/logs-service.d.ts +7 -0
- package/dist/cli/services/logs-service.js +13 -0
- package/dist/cli/services/storage-service.d.ts +19 -0
- package/dist/cli/services/storage-service.js +71 -0
- package/dist/cli/services/vpn-service.d.ts +6 -4
- package/dist/cli/services/vpn-service.js +5 -11
- package/dist/cli/services/web-service.d.ts +4 -3
- package/dist/cli/services/web-service.js +12 -32
- package/dist/core/config/defaults.js +2 -1
- package/dist/core/schema/config.d.ts +5 -0
- package/dist/core/schema/config.js +2 -0
- package/dist/core/schema/github.d.ts +4 -0
- package/dist/core/schema/github.js +7 -0
- package/dist/core/schema/index.d.ts +1 -0
- package/dist/core/schema/index.js +1 -0
- package/dist/core/schema/profile.d.ts +1 -0
- package/dist/core/schema/profile.js +3 -0
- package/dist/core/schema/sandbox.js +3 -3
- package/dist/core/schema/toolchains.js +2 -2
- package/dist/core/types.d.ts +6 -3
- package/dist/guest/boot/boot.js +8 -0
- package/dist/guest/daemon/daemon.js +1 -1
- package/dist/guest/daemon/sessions.d.ts +3 -2
- package/dist/guest/daemon/sessions.js +38 -7
- package/dist/guest/governor/core.d.ts +44 -0
- package/dist/guest/governor/core.js +124 -0
- package/dist/guest/governor/decide.d.ts +46 -18
- package/dist/guest/governor/decide.js +136 -82
- package/dist/guest/governor/governor.d.ts +2 -38
- package/dist/guest/governor/governor.js +33 -113
- package/dist/guest/governor/index.d.ts +1 -0
- package/dist/guest/governor/index.js +1 -0
- package/dist/guest/network/firewall.d.ts +2 -0
- package/dist/guest/network/firewall.js +3 -3
- package/dist/guest/sessions/viewer.js +5 -1
- package/dist/guest/setup/github-token.d.ts +7 -0
- package/dist/guest/setup/github-token.js +65 -0
- package/dist/guest/toolchains/languages/node.js +11 -1
- package/dist/guest/toolchains/native/rust-extras.js +2 -2
- package/dist/guest/toolchains/tools/cli.d.ts +8 -0
- package/dist/guest/toolchains/tools/cli.js +35 -2
- package/dist/guest/vpn/openvpn.d.ts +5 -0
- package/dist/guest/vpn/openvpn.js +14 -1
- package/dist/guest/vpn/vpn.js +55 -16
- package/dist/guest/vpn/wireguard.js +2 -0
- package/dist/host/channel/attach.d.ts +1 -0
- package/dist/host/channel/attach.js +1 -0
- package/dist/host/channel/channel.d.ts +1 -1
- package/dist/host/channel/channel.js +2 -2
- package/dist/host/engines/hcs/check.d.ts +1 -0
- package/dist/host/engines/hcs/check.js +1 -1
- package/dist/host/engines/hcs/engine.d.ts +1 -1
- package/dist/host/engines/hcs/engine.js +6 -4
- package/dist/host/engines/hcs/helper.d.ts +11 -0
- package/dist/host/engines/hcs/helper.js +31 -2
- package/dist/host/engines/hcs/leftovers.d.ts +42 -0
- package/dist/host/engines/hcs/leftovers.js +101 -0
- package/dist/host/engines/index.d.ts +1 -0
- package/dist/host/engines/index.js +1 -0
- package/dist/host/github/deliver.d.ts +13 -0
- package/dist/host/github/deliver.js +51 -0
- package/dist/host/github/index.d.ts +2 -0
- package/dist/host/github/index.js +3 -0
- package/dist/host/github/token.d.ts +21 -0
- package/dist/host/github/token.js +74 -0
- package/dist/host/launch/generate.js +11 -5
- package/dist/host/launch/index.d.ts +1 -1
- package/dist/host/launch/index.js +1 -1
- package/dist/host/launch/session-file.js +1 -2
- package/dist/host/launch/wsb-file.d.ts +11 -7
- package/dist/host/launch/wsb-file.js +30 -12
- package/dist/host/life/host-memory.d.ts +18 -0
- package/dist/host/life/host-memory.js +66 -0
- package/dist/host/life/watchdog.d.ts +9 -0
- package/dist/host/life/watchdog.js +17 -1
- package/dist/host/sandbox/tasklist.d.ts +6 -0
- package/dist/host/sandbox/tasklist.js +37 -0
- package/dist/host/secrets/launch-secrets.d.ts +2 -1
- package/dist/host/secrets/launch-secrets.js +4 -2
- package/dist/host/vpn/status.js +13 -3
- package/dist/host/web/backend.d.ts +1 -3
- package/dist/host/web/index.d.ts +2 -1
- package/dist/host/web/index.js +2 -1
- package/dist/host/web/live.d.ts +23 -0
- package/dist/host/web/live.js +107 -0
- package/dist/host/web/rpc.d.ts +6 -1
- package/dist/host/web/rpc.js +23 -31
- package/dist/host/web/runner.d.ts +4 -0
- package/dist/host/web/runner.js +12 -1
- package/dist/host/web/server.d.ts +30 -2
- package/dist/host/web/server.js +87 -29
- package/dist/host/web/state.d.ts +1 -0
- package/dist/host/web/state.js +2 -0
- package/dist/runtime/agent.js +30 -6
- package/dist/runtime/daemon.js +337 -177
- package/dist/runtime/db.js +30 -6
- package/dist/runtime/main.js +389 -77
- package/dist/runtime/netproxy.js +30 -6
- package/dist/runtime/view.js +495 -146
- package/dist/selftest/app.test.js +632 -12
- package/dist/selftest/channel.test.js +18 -1
- package/dist/selftest/cli.test.js +1 -1
- package/dist/selftest/config.test.js +1 -1
- package/dist/selftest/contained.test.js +1 -1
- package/dist/selftest/data.test.js +1 -2
- package/dist/selftest/engine.test.js +3 -1
- package/dist/selftest/github.test.d.ts +2 -0
- package/dist/selftest/github.test.js +243 -0
- package/dist/selftest/hcs.test.js +105 -8
- package/dist/selftest/health.test.js +71 -0
- package/dist/selftest/heavy-load.test.js +132 -72
- package/dist/selftest/index.js +4 -0
- package/dist/selftest/layout.test.js +8 -0
- package/dist/selftest/live-terminal.test.js +74 -0
- package/dist/selftest/menu-screens.js +171 -56
- package/dist/selftest/menu.test.js +54 -37
- package/dist/selftest/migrate.test.js +14 -12
- package/dist/selftest/powershell-variables.test.d.ts +2 -0
- package/dist/selftest/powershell-variables.test.js +61 -0
- package/dist/selftest/support/engine-golden.js +1 -0
- package/dist/selftest/support/fixtures.d.ts +4 -0
- package/dist/selftest/support/web-preview.d.ts +1 -0
- package/dist/selftest/support/web-preview.js +856 -0
- package/dist/selftest/update-service.test.js +15 -8
- package/dist/selftest/vpn.test.js +86 -2
- package/dist/selftest/web.test.js +58 -11
- package/dist/shared/channel/run-dir.d.ts +2 -0
- package/dist/shared/channel/run-dir.js +3 -0
- package/dist/shared/channel/schema.d.ts +7 -0
- package/dist/shared/channel/schema.js +9 -1
- package/dist/shared/channel/secrets.d.ts +1 -0
- package/dist/shared/channel/secrets.js +3 -0
- package/dist/shared/github/index.d.ts +1 -0
- package/dist/shared/github/index.js +2 -0
- package/dist/shared/github/token.d.ts +29 -0
- package/dist/shared/github/token.js +89 -0
- package/dist/shared/memory/policy.d.ts +33 -12
- package/dist/shared/memory/policy.js +50 -19
- package/dist/shared/pty/ctrl-c.d.ts +18 -0
- package/dist/shared/pty/ctrl-c.js +36 -0
- package/dist/shared/pty/index.d.ts +1 -0
- package/dist/shared/pty/index.js +1 -0
- package/dist/shared/pty/terminal.d.ts +2 -0
- package/dist/shared/pty/terminal.js +21 -2
- package/dist/shared/vpn/kill-switch.d.ts +13 -2
- package/dist/shared/vpn/kill-switch.js +88 -8
- package/dist/shared/web/protocol.d.ts +0 -4
- package/dist/sync/watcher.d.ts +2 -0
- package/dist/sync/watcher.js +8 -3
- package/dist/web/index.html +2 -2
- package/dist/web/{main-T5DMCHYV.css → main-MU5XWZMS.css} +1 -1
- package/dist/web/main-SLQNJRXD.js +219 -0
- package/native/csharp/HcsHost/AssemblyInfo.cs +3 -3
- package/native/csharp/HostTools/AssemblyInfo.cs +3 -3
- package/native/csharp/HostTools/MemoryStatus.cs +58 -2
- package/native/csharp/HostTools/Program.cs +7 -1
- package/package.json +10 -3
- package/sandbox/csharp/MemGov.cs +240 -38
- package/sandbox/csharp/PtyHost.cs +104 -15
- package/sandbox/csharp/SandboxTools/CpuCap.cs +50 -1
- package/sandbox/csharp/SandboxTools/Program.cs +1 -1
- package/sandbox/scripts/repair-wmi-services.ps1 +26 -0
- package/schemas/config.schema.json +19 -5
- package/schemas/sandbox-config.schema.json +7 -3
- package/dist/cli/commands/accounts.d.ts +0 -2
- package/dist/cli/commands/accounts.js +0 -96
- package/dist/cli/commands/data/clean.d.ts +0 -3
- package/dist/cli/commands/data/clean.js +0 -60
- package/dist/cli/commands/data/index.d.ts +0 -4
- package/dist/cli/commands/data/index.js +0 -62
- package/dist/cli/commands/maintenance/clean.d.ts +0 -2
- package/dist/cli/commands/maintenance/clean.js +0 -24
- package/dist/cli/commands/maintenance/config-share.d.ts +0 -12
- package/dist/cli/commands/maintenance/config-share.js +0 -80
- package/dist/cli/commands/projects/projects.d.ts +0 -2
- package/dist/cli/commands/projects/projects.js +0 -162
- package/dist/cli/commands/storage/contained.d.ts +0 -3
- package/dist/cli/commands/storage/contained.js +0 -179
- package/dist/cli/commands/storage/storage.d.ts +0 -8
- package/dist/cli/commands/storage/storage.js +0 -179
- package/dist/cli/menu/add-agent.d.ts +0 -47
- package/dist/cli/menu/add-agent.js +0 -168
- package/dist/cli/menu/apps.d.ts +0 -69
- package/dist/cli/menu/apps.js +0 -214
- package/dist/cli/menu/data-folder.d.ts +0 -18
- package/dist/cli/menu/data-folder.js +0 -99
- package/dist/cli/menu/share-settings.d.ts +0 -21
- package/dist/cli/menu/share-settings.js +0 -112
- package/dist/cli/menu/vpn-login.d.ts +0 -16
- package/dist/cli/menu/vpn-login.js +0 -74
- package/dist/web/main-NRRS5O6Z.js +0 -157
- /package/dist/cli/{commands/data/collect.d.ts → services/data-collect.d.ts} +0 -0
- /package/dist/cli/{commands/data/remove.d.ts → services/data-remove.d.ts} +0 -0
package/dist/host/web/server.js
CHANGED
|
@@ -5,9 +5,10 @@ import fs from 'node:fs';
|
|
|
5
5
|
import http from 'node:http';
|
|
6
6
|
import { WebSocketServer } from 'ws';
|
|
7
7
|
import { UserError, safeText } from '../../core/util/index.js';
|
|
8
|
-
import { MAX_CLIENT_MESSAGE_BYTES, MAX_COLS, MAX_ROWS, MIN_COLS, MIN_ROWS
|
|
8
|
+
import { MAX_CLIENT_MESSAGE_BYTES, MAX_COLS, MAX_ROWS, MIN_COLS, MIN_ROWS } from '../../shared/web/index.js';
|
|
9
9
|
import { cookieHeader, csrfOk, hostAllowed, originAllowed, WebAuth } from './auth.js';
|
|
10
10
|
import { TerminalBridge } from './bridge.js';
|
|
11
|
+
import { LiveHub } from './live.js';
|
|
11
12
|
import { RpcSession } from './rpc.js';
|
|
12
13
|
import { StaticFiles } from './static-files.js';
|
|
13
14
|
/** No inline script: the page and its script are files from this server. Inline styles are what xterm.js needs. */
|
|
@@ -16,6 +17,10 @@ export const CONTENT_SECURITY_POLICY = "default-src 'self'; script-src 'self'; s
|
|
|
16
17
|
const MAX_BODY_BYTES = 16 * 1024;
|
|
17
18
|
const MAX_TERMINALS = 16;
|
|
18
19
|
const MAX_RPC_SOCKETS = 8;
|
|
20
|
+
/** Every socket is pinged this often; one that has not answered the last ping by the next is dropped. */
|
|
21
|
+
const HEARTBEAT_MS = 20_000;
|
|
22
|
+
/** The server ends after this long with no request, no socket and no sandbox running (it starts again with one). */
|
|
23
|
+
export const IDLE_EXIT_MS = 30 * 60_000;
|
|
19
24
|
const SESSION_PATH = /^\/api\/sessions\/([A-Za-z0-9_-]{1,64})\/terminal$/;
|
|
20
25
|
export const RPC_PATH = '/api/rpc';
|
|
21
26
|
class HttpFailure extends Error {
|
|
@@ -35,15 +40,23 @@ export class WebServer {
|
|
|
35
40
|
});
|
|
36
41
|
auth;
|
|
37
42
|
files;
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
tracked = new Map();
|
|
44
|
+
/** One poll per live query for all browsers together. */
|
|
45
|
+
live;
|
|
40
46
|
actualPort = 0;
|
|
47
|
+
lastUsed = Date.now();
|
|
48
|
+
heartbeat;
|
|
49
|
+
idleCheck;
|
|
41
50
|
constructor(options) {
|
|
42
51
|
this.options = options;
|
|
43
52
|
this.auth = new WebAuth(options.token);
|
|
44
53
|
this.files = new StaticFiles(options.staticRoot);
|
|
54
|
+
this.live = options.rpc ? new LiveHub(options.rpc) : undefined;
|
|
45
55
|
this.server = http.createServer((req, res) => void this.handle(req, res));
|
|
46
|
-
this.server.on('upgrade', (req, socket, head) =>
|
|
56
|
+
this.server.on('upgrade', (req, socket, head) => {
|
|
57
|
+
this.lastUsed = Date.now();
|
|
58
|
+
this.upgrade(req, socket, head);
|
|
59
|
+
});
|
|
47
60
|
this.server.headersTimeout = 15000;
|
|
48
61
|
this.server.requestTimeout = 0; // creating a session waits for the agent to start
|
|
49
62
|
}
|
|
@@ -56,11 +69,75 @@ export class WebServer {
|
|
|
56
69
|
this.server.listen(this.options.port, '127.0.0.1', () => {
|
|
57
70
|
this.server.off('error', reject);
|
|
58
71
|
this.actualPort = this.server.address().port;
|
|
72
|
+
this.heartbeat = setInterval(() => this.beat(), this.options.heartbeatMs ?? HEARTBEAT_MS);
|
|
73
|
+
this.heartbeat.unref();
|
|
74
|
+
if (this.options.idleExitMs) {
|
|
75
|
+
this.idleCheck = setInterval(() => void this.checkIdle(), Math.min(60_000, this.options.idleExitMs));
|
|
76
|
+
this.idleCheck.unref();
|
|
77
|
+
}
|
|
59
78
|
resolve();
|
|
60
79
|
});
|
|
61
80
|
});
|
|
62
81
|
}
|
|
82
|
+
/** How many browser sockets are open, by kind. */
|
|
83
|
+
openSockets(kind) {
|
|
84
|
+
return [...this.tracked.values()].filter((t) => t.kind === kind).length;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Drops sockets that did not answer the last ping (a tab that went away without closing: sleep, a killed browser),
|
|
88
|
+
* so they never hold a slot or a session connection.
|
|
89
|
+
*/
|
|
90
|
+
beat() {
|
|
91
|
+
for (const [ws, t] of this.tracked) {
|
|
92
|
+
if (!t.alive) {
|
|
93
|
+
ws.terminate();
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
t.alive = false;
|
|
97
|
+
try {
|
|
98
|
+
ws.ping();
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
ws.terminate(); // the socket broke between the check and the ping
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Nothing has used the server for a while and no sandbox runs: it ends (the next launch starts it again). */
|
|
106
|
+
async checkIdle() {
|
|
107
|
+
const limit = this.options.idleExitMs ?? 0;
|
|
108
|
+
if (!limit || this.tracked.size > 0 || Date.now() - this.lastUsed < limit)
|
|
109
|
+
return;
|
|
110
|
+
try {
|
|
111
|
+
if ((await this.options.backend.info()).sandbox === 'running')
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return; // cannot tell: keep running
|
|
116
|
+
}
|
|
117
|
+
this.options.onStop?.();
|
|
118
|
+
}
|
|
119
|
+
/** Counts a new socket; at the limit, the oldest of its kind makes room (a new tab always works). */
|
|
120
|
+
track(ws, kind, limit) {
|
|
121
|
+
const same = [...this.tracked.entries()]
|
|
122
|
+
.filter(([, t]) => t.kind === kind)
|
|
123
|
+
.sort((a, b) => a[1].opened - b[1].opened);
|
|
124
|
+
for (const [old] of same.slice(0, Math.max(0, same.length - limit + 1)))
|
|
125
|
+
old.close(4000, 'replaced by a newer page');
|
|
126
|
+
this.tracked.set(ws, { kind, opened: Date.now(), alive: true });
|
|
127
|
+
ws.on('pong', () => {
|
|
128
|
+
const t = this.tracked.get(ws);
|
|
129
|
+
if (t)
|
|
130
|
+
t.alive = true;
|
|
131
|
+
});
|
|
132
|
+
ws.on('message', () => (this.lastUsed = Date.now()));
|
|
133
|
+
ws.on('close', () => {
|
|
134
|
+
this.tracked.delete(ws);
|
|
135
|
+
this.lastUsed = Date.now();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
63
138
|
stop() {
|
|
139
|
+
clearInterval(this.heartbeat);
|
|
140
|
+
clearInterval(this.idleCheck);
|
|
64
141
|
for (const client of this.sockets.clients)
|
|
65
142
|
client.close(1001, 'server stopping');
|
|
66
143
|
this.server.closeAllConnections();
|
|
@@ -82,6 +159,7 @@ export class WebServer {
|
|
|
82
159
|
res.end(JSON.stringify(body));
|
|
83
160
|
}
|
|
84
161
|
async handle(req, res) {
|
|
162
|
+
this.lastUsed = Date.now();
|
|
85
163
|
try {
|
|
86
164
|
if (!hostAllowed(req.headers.host, this.actualPort))
|
|
87
165
|
throw new HttpFailure(421, 'Wrong host name.');
|
|
@@ -141,13 +219,6 @@ export class WebServer {
|
|
|
141
219
|
return this.json(res, 200, await backend.info());
|
|
142
220
|
if (pathname === '/api/sessions' && method === 'GET')
|
|
143
221
|
return this.json(res, 200, await backend.sessions());
|
|
144
|
-
if (pathname === '/api/sessions' && method === 'POST') {
|
|
145
|
-
this.requireSameSite(req);
|
|
146
|
-
const request = newSessionRequest(await this.body(req));
|
|
147
|
-
if (!request)
|
|
148
|
-
throw new HttpFailure(400, 'Choose an agent and a project.');
|
|
149
|
-
return this.json(res, 201, await backend.create(request));
|
|
150
|
-
}
|
|
151
222
|
if (pathname === '/api/stop' && method === 'POST') {
|
|
152
223
|
this.requireSameSite(req);
|
|
153
224
|
this.json(res, 200, { ok: true });
|
|
@@ -198,30 +269,24 @@ export class WebServer {
|
|
|
198
269
|
if (!this.auth.signedIn(req.headers.cookie))
|
|
199
270
|
return refuse('401 Unauthorized');
|
|
200
271
|
if (rpc)
|
|
201
|
-
return this.upgradeRpc(req, socket, head, rpc
|
|
272
|
+
return this.upgradeRpc(req, socket, head, rpc);
|
|
202
273
|
if (!match)
|
|
203
274
|
return refuse('404 Not Found');
|
|
204
|
-
if (this.terminals >= MAX_TERMINALS)
|
|
205
|
-
return refuse('503 Service Unavailable');
|
|
206
275
|
const endpoint = this.options.backend.endpoint(match[1]);
|
|
207
276
|
if (!endpoint)
|
|
208
277
|
return refuse('404 Not Found');
|
|
209
278
|
const cols = bounded(url.searchParams.get('cols'), MIN_COLS, MAX_COLS, 120);
|
|
210
279
|
const rows = bounded(url.searchParams.get('rows'), MIN_ROWS, MAX_ROWS, 30);
|
|
211
280
|
this.sockets.handleUpgrade(req, socket, head, (ws) => {
|
|
212
|
-
this.
|
|
213
|
-
ws.on('close', () => this.terminals--);
|
|
281
|
+
this.track(ws, 'terminal', MAX_TERMINALS);
|
|
214
282
|
void new TerminalBridge(ws, endpoint, cols, rows, this.options.dial).start();
|
|
215
283
|
});
|
|
216
284
|
}
|
|
217
285
|
/** The RPC socket (after the same Origin and cookie checks as a terminal). */
|
|
218
|
-
upgradeRpc(req, socket, head, rpc
|
|
219
|
-
if (this.rpcSockets >= MAX_RPC_SOCKETS)
|
|
220
|
-
return refuse('503 Service Unavailable');
|
|
286
|
+
upgradeRpc(req, socket, head, rpc) {
|
|
221
287
|
this.sockets.handleUpgrade(req, socket, head, (ws) => {
|
|
222
|
-
this.
|
|
223
|
-
ws
|
|
224
|
-
new RpcSession(ws, rpc).start();
|
|
288
|
+
this.track(ws, 'rpc', MAX_RPC_SOCKETS);
|
|
289
|
+
new RpcSession(ws, rpc, this.live).start();
|
|
225
290
|
});
|
|
226
291
|
}
|
|
227
292
|
}
|
|
@@ -229,10 +294,3 @@ function bounded(text, min, max, fallback) {
|
|
|
229
294
|
const n = Number(text);
|
|
230
295
|
return text !== null && Number.isInteger(n) && n >= min && n <= max ? n : fallback;
|
|
231
296
|
}
|
|
232
|
-
function newSessionRequest(body) {
|
|
233
|
-
if (typeof body !== 'object' || body === null)
|
|
234
|
-
return null;
|
|
235
|
-
const { harness, project } = body;
|
|
236
|
-
const ok = (v) => typeof v === 'string' && /^[A-Za-z0-9_.-]{1,64}$/.test(v);
|
|
237
|
-
return ok(harness) && ok(project) ? { harness, project } : null;
|
|
238
|
-
}
|
package/dist/host/web/state.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const WebStateSchema: z.ZodObject<{
|
|
|
4
4
|
port: z.ZodNumber;
|
|
5
5
|
token: z.ZodString;
|
|
6
6
|
startedAt: z.ZodString;
|
|
7
|
+
version: z.ZodOptional<z.ZodString>;
|
|
7
8
|
}, z.core.$strict>;
|
|
8
9
|
export type WebState = z.output<typeof WebStateSchema>;
|
|
9
10
|
export declare class WebStore {
|
package/dist/host/web/state.js
CHANGED
|
@@ -10,6 +10,8 @@ export const WebStateSchema = z.strictObject({
|
|
|
10
10
|
port: z.number().int().min(1).max(65535),
|
|
11
11
|
token: z.string().regex(/^[0-9a-f]{64}$/),
|
|
12
12
|
startedAt: z.string().max(64),
|
|
13
|
+
/** The version that started it (missing: an older one). Another version is replaced, never reused. */
|
|
14
|
+
version: z.string().max(64).optional(),
|
|
13
15
|
});
|
|
14
16
|
export class WebStore {
|
|
15
17
|
storageRoot;
|
package/dist/runtime/agent.js
CHANGED
|
@@ -25418,6 +25418,9 @@ var AttachSchema = external_exports.strictObject({
|
|
|
25418
25418
|
),
|
|
25419
25419
|
autoHide: external_exports.boolean().describe(
|
|
25420
25420
|
"Hide the Windows Sandbox window whenever this terminal attaches; it keeps running (sandbox show brings it back)."
|
|
25421
|
+
),
|
|
25422
|
+
confirmCtrlC: external_exports.boolean().describe(
|
|
25423
|
+
'In an attached terminal and the sandbox window, a single Ctrl+C is held back (the title says so) and only a second one within 1.5 seconds reaches the agent: a Ctrl+C meant as "copy" no longer stops it. Esc still stops an agent.'
|
|
25421
25424
|
)
|
|
25422
25425
|
});
|
|
25423
25426
|
var AgentCommandsSchema = external_exports.strictObject({
|
|
@@ -25462,7 +25465,9 @@ var SandboxSchema = external_exports.strictObject({
|
|
|
25462
25465
|
engine: external_exports.enum(["windows-sandbox", "hcs"]).describe(
|
|
25463
25466
|
'(alpha) What runs the sandbox. "windows-sandbox" = Windows Sandbox (the default: desktop, Windows Terminal, GPU, clipboard, audio, printers). "hcs" = a headless Hyper-V isolated Server Core container for agents (no desktop, GPU or clipboard); it needs Windows features and an image on this PC (sandbox engine check hcs lists what is missing), and starting it is not enabled yet in this alpha. sandbox engine shows what each engine can do. Yours only: a project file (.sandbox-config.json) cannot set it.'
|
|
25464
25467
|
),
|
|
25465
|
-
memoryMb: external_exports.union([external_exports.literal("auto"), external_exports.number().int().min(2048)]).describe(
|
|
25468
|
+
memoryMb: external_exports.union([external_exports.literal("auto"), external_exports.number().int().min(2048)]).describe(
|
|
25469
|
+
'Sandbox RAM in MB (>= 2048), or "auto": free RAM minus reserveHostMb, capped at maxMemoryMb. Never more than this PC can keep in RAM for it (its RAM minus the larger of reserveHostMb and 25 %, 2 GB more with vGPU): a bigger value is lowered.'
|
|
25470
|
+
),
|
|
25466
25471
|
maxMemoryMb: external_exports.number().int().positive().describe('Upper limit for memoryMb "auto".'),
|
|
25467
25472
|
maxMemoryPercent: external_exports.number().int().min(10).max(100).describe(`memoryMb "auto" never takes more than this share of this PC's total RAM (percent).`),
|
|
25468
25473
|
cpuLimit: external_exports.union([external_exports.literal("none"), external_exports.number().int().min(5).max(100)]).describe(
|
|
@@ -25475,10 +25480,10 @@ var SandboxSchema = external_exports.strictObject({
|
|
|
25475
25480
|
'Memory always left for this PC when memoryMb is "auto": the sandbox gets at most (free RAM, and RAM plus paging file still unused) minus this.'
|
|
25476
25481
|
),
|
|
25477
25482
|
agentMemoryHeadroomMb: external_exports.union([external_exports.literal("auto"), external_exports.literal("none"), external_exports.number().int().min(0)]).describe(
|
|
25478
|
-
'
|
|
25483
|
+
'The last resort that keeps the sandbox up, in MB below its commit limit (RAM plus paging file): builds are slowed down long before (sandbox.pressureResponse); only if everything the agents start together would take the sandbox to the very edge of its memory, where Windows inside it would start failing, is a build refused memory instead of Windows. "auto" = the larger of 1536 MB and 3 % of the commit limit; "none" = no backstop. Yours only: a project file cannot change it.'
|
|
25479
25484
|
),
|
|
25480
25485
|
pressureResponse: external_exports.boolean().describe(
|
|
25481
|
-
"When the sandbox (or this PC) runs low on memory, slow
|
|
25486
|
+
"When the sandbox (or this PC) runs low on memory, slow builds down in steps, like a PC that gets slower instead of failing: build programs get lower CPU and memory priority, then less CPU, then compilers take turns (the waiting ones briefly suspended and trimmed to the paging file). Nothing is stopped or killed, and the agents themselves are never touched. Yours only: a project file cannot change it."
|
|
25482
25487
|
),
|
|
25483
25488
|
vGpu: external_exports.boolean().describe(
|
|
25484
25489
|
"Virtual GPU. Off by default: Microsoft notes it widens the sandbox attack surface. The sandbox then uses this PC's graphics card, and with some graphics drivers heavy use can freeze the whole PC: turn it on only when a program in the sandbox needs the GPU (the mesa toolchain gives software OpenGL without it)."
|
|
@@ -25624,7 +25629,7 @@ var ToolchainsSchema = external_exports.strictObject({
|
|
|
25624
25629
|
`GNU host: "lld" links with Rust's own lld through MinGW's gcc (much less memory than GNU ld), "gnu" with GNU ld.`
|
|
25625
25630
|
),
|
|
25626
25631
|
linkSlots: external_exports.union([external_exports.literal("auto"), external_exports.number().int().min(1).max(32)]).describe(
|
|
25627
|
-
'GNU host: how many programs may link at the same time in the whole sandbox (other links wait). "auto" = one per
|
|
25632
|
+
'GNU host: how many programs may link at the same time in the whole sandbox (other links wait). "auto" = one per 3 GB of sandbox memory after 6 GB, 2 to 8 (the memory governor slows links down too when memory runs short).'
|
|
25628
25633
|
)
|
|
25629
25634
|
}),
|
|
25630
25635
|
msvc: external_exports.strictObject({
|
|
@@ -25699,7 +25704,7 @@ var ToolchainsSchema = external_exports.strictObject({
|
|
|
25699
25704
|
}),
|
|
25700
25705
|
cli: external_exports.strictObject({
|
|
25701
25706
|
gh: EnabledSchema.describe(
|
|
25702
|
-
'GitHub CLI (gh). Only with provisioning.git.access "full": gh can push and merge through the GitHub API, past a read-only git. Your PC\'s gh login is never copied; `gh auth login` inside persists (GH_CONFIG_DIR). "auto" = when the project has a .github folder.'
|
|
25707
|
+
'GitHub CLI (gh). Only with provisioning.git.access "full": gh can push and merge through the GitHub API, past a read-only git. Your PC\'s gh login is never copied; `gh auth login` inside persists (GH_CONFIG_DIR), unless a token you saved for sandboxes is handed over (github.shareToken). "auto" = when the project has a .github folder.'
|
|
25703
25708
|
),
|
|
25704
25709
|
zstd: EnabledSchema.describe('Zstandard (zstd). "auto" = off; set true to get it.'),
|
|
25705
25710
|
openssl: EnabledSchema.describe(
|
|
@@ -26587,6 +26592,13 @@ var VpnSchema = external_exports.strictObject({
|
|
|
26587
26592
|
)
|
|
26588
26593
|
});
|
|
26589
26594
|
|
|
26595
|
+
// src/core/schema/github.ts
|
|
26596
|
+
var GithubSchema = external_exports.strictObject({
|
|
26597
|
+
shareToken: external_exports.boolean().describe(
|
|
26598
|
+
'Give each sandbox the GitHub token you saved with `sandbox github login` (best a fine-grained token limited to some repositories and permissions), so gh and https git work there without logging in. Only with provisioning.git.access "full". The agent in the sandbox can read the token and use it for whatever it allows. A project file (.sandbox-config.json) cannot turn this on.'
|
|
26599
|
+
)
|
|
26600
|
+
});
|
|
26601
|
+
|
|
26590
26602
|
// src/core/schema/config.ts
|
|
26591
26603
|
var ConfigSchema = external_exports.strictObject({
|
|
26592
26604
|
$schema: SchemaRefSchema.optional(),
|
|
@@ -26617,6 +26629,7 @@ var ConfigSchema = external_exports.strictObject({
|
|
|
26617
26629
|
}),
|
|
26618
26630
|
network: NetworkSchema,
|
|
26619
26631
|
vpn: VpnSchema,
|
|
26632
|
+
github: GithubSchema,
|
|
26620
26633
|
provisioning: ProvisioningSchema,
|
|
26621
26634
|
downloads: DownloadsSchema,
|
|
26622
26635
|
toolchains: ToolchainsSchema,
|
|
@@ -26779,19 +26792,25 @@ var GuestRequestSchema = external_exports.discriminatedUnion("kind", [
|
|
|
26779
26792
|
id: IdSchema,
|
|
26780
26793
|
reason: Text(300),
|
|
26781
26794
|
seconds: external_exports.number().int().min(10).max(300),
|
|
26795
|
+
/** "severe": the PC is nearly out of memory; builds go to the governor's last step at once. */
|
|
26796
|
+
level: external_exports.enum(["slow", "severe"]).optional(),
|
|
26782
26797
|
createdAt: TimeSchema
|
|
26783
26798
|
})
|
|
26784
26799
|
]);
|
|
26785
26800
|
var PressureStatusSchema = external_exports.object({
|
|
26786
26801
|
level: external_exports.enum(["ok", "throttled", "suspending"]),
|
|
26802
|
+
/** The governor's dial, 0 (nothing wrong) to 4 (one compiler at a time). */
|
|
26803
|
+
step: external_exports.number().int().min(0).max(4).optional(),
|
|
26787
26804
|
profile: external_exports.enum(["normal", "gentle"]),
|
|
26788
26805
|
/** Share of the sandbox's RAM still free and of its commit limit in use (percent). */
|
|
26789
26806
|
ramFreePercent: external_exports.number().int().min(0).max(100),
|
|
26790
26807
|
commitPercent: external_exports.number().int().min(0).max(100),
|
|
26791
26808
|
/** Programs running at lower priority because of it. */
|
|
26792
26809
|
lowered: external_exports.number().int().min(0).max(1024),
|
|
26793
|
-
/**
|
|
26810
|
+
/** Compilers waiting their turn right now (name, process id, seconds until they may go on). */
|
|
26794
26811
|
paused: external_exports.array(external_exports.object({ name: Text(64), pid: external_exports.number().int(), seconds: external_exports.number().int().min(0).max(60) })).max(8),
|
|
26812
|
+
/** The CPU share the compilers get together (percent; 100 = no cap). */
|
|
26813
|
+
cpuPercent: external_exports.number().int().min(0).max(100).optional(),
|
|
26795
26814
|
/** The PC itself asked for slowing down (its memory or CPU is low). */
|
|
26796
26815
|
pcLow: external_exports.boolean(),
|
|
26797
26816
|
lastAction: Text(300),
|
|
@@ -26835,6 +26854,8 @@ var VpnStatusSchema = external_exports.object({
|
|
|
26835
26854
|
state: external_exports.enum(["off", "starting", "up", "failed"]),
|
|
26836
26855
|
message: Text(2e3),
|
|
26837
26856
|
killSwitch: external_exports.boolean(),
|
|
26857
|
+
/** A direct connection was tried after the kill switch was applied: false = it still got out. */
|
|
26858
|
+
killSwitchHeld: external_exports.boolean().optional(),
|
|
26838
26859
|
/** The server's name, e.g. uk2201.nordvpn.com. */
|
|
26839
26860
|
server: Text(128).optional(),
|
|
26840
26861
|
/** What the sandbox's traffic looks like from outside, once the tunnel is up. */
|
|
@@ -26978,6 +26999,8 @@ var RunDir = class {
|
|
|
26978
26999
|
vpnFile;
|
|
26979
27000
|
/** What the memory governor in the sandbox is doing (pressure.json). */
|
|
26980
27001
|
pressureFile;
|
|
27002
|
+
/** What the sandbox's programs may really use (budget.json): processors, memory, build jobs, link slots. */
|
|
27003
|
+
budgetFile;
|
|
26981
27004
|
requestsDir;
|
|
26982
27005
|
responsesDir;
|
|
26983
27006
|
sessionsDir;
|
|
@@ -26991,6 +27014,7 @@ var RunDir = class {
|
|
|
26991
27014
|
this.sandboxFile = path5.join(this.root, "sandbox.json");
|
|
26992
27015
|
this.vpnFile = path5.join(this.root, "vpn.json");
|
|
26993
27016
|
this.pressureFile = path5.join(this.root, "pressure.json");
|
|
27017
|
+
this.budgetFile = path5.join(this.root, "budget.json");
|
|
26994
27018
|
this.requestsDir = path5.join(this.root, "requests");
|
|
26995
27019
|
this.responsesDir = path5.join(this.root, "responses");
|
|
26996
27020
|
this.sessionsDir = path5.join(this.root, "sessions");
|