windows-development-sandbox 1.7.0 → 1.9.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/config.example.json +10 -0
- package/dist/app/context.d.ts +8 -0
- package/dist/app/context.js +12 -0
- package/dist/app/features/defs.d.ts +322 -0
- package/dist/app/features/defs.js +28 -0
- package/dist/app/features/sandbox/index.d.ts +2 -0
- package/dist/app/features/sandbox/index.js +3 -0
- package/dist/app/features/sandbox/sandbox.def.d.ts +193 -0
- package/dist/app/features/sandbox/sandbox.def.js +245 -0
- package/dist/app/features/sandbox/sandbox.run.d.ts +72 -0
- package/dist/app/features/sandbox/sandbox.run.js +98 -0
- package/dist/app/features/sessions/index.d.ts +2 -0
- package/dist/app/features/sessions/index.js +3 -0
- package/dist/app/features/sessions/sessions.def.d.ts +141 -0
- package/dist/app/features/sessions/sessions.def.js +176 -0
- package/dist/app/features/sessions/sessions.run.d.ts +39 -0
- package/dist/app/features/sessions/sessions.run.js +58 -0
- package/dist/{cli/menu/settings/categories.d.ts → app/features/settings/categories.def.d.ts} +2 -0
- package/dist/{cli/menu/settings/categories.js → app/features/settings/categories.def.js} +24 -5
- package/dist/app/features/settings/index.d.ts +5 -0
- package/dist/app/features/settings/index.js +6 -0
- package/dist/{cli/menu/settings/config-file.d.ts → app/features/settings/settings-file.d.ts} +1 -1
- package/dist/{cli/menu/settings/config-file.js → app/features/settings/settings-file.js} +1 -1
- package/dist/app/features/settings/settings-rows.d.ts +35 -0
- package/dist/app/features/settings/settings-rows.js +94 -0
- package/dist/app/features/settings/settings.def.d.ts +157 -0
- package/dist/app/features/settings/settings.def.js +179 -0
- package/dist/app/features/settings/settings.run.d.ts +67 -0
- package/dist/app/features/settings/settings.run.js +84 -0
- package/dist/app/kernel/define.d.ts +143 -0
- package/dist/app/kernel/define.js +42 -0
- package/dist/app/kernel/errors.d.ts +34 -0
- package/dist/app/kernel/errors.js +45 -0
- package/dist/app/kernel/fields.d.ts +70 -0
- package/dist/app/kernel/fields.js +243 -0
- package/dist/app/kernel/index.d.ts +8 -0
- package/dist/app/kernel/index.js +10 -0
- package/dist/app/kernel/io.d.ts +193 -0
- package/dist/app/kernel/io.js +126 -0
- package/dist/app/kernel/rpc.d.ts +156 -0
- package/dist/app/kernel/rpc.js +47 -0
- package/dist/app/kernel/text.d.ts +6 -0
- package/dist/app/kernel/text.js +57 -0
- package/dist/app/kernel/view.d.ts +146 -0
- package/dist/app/kernel/view.js +28 -0
- package/dist/app/registry.d.ts +10 -0
- package/dist/app/registry.js +50 -0
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.js +6 -0
- package/dist/cli/commands/engine.d.ts +2 -0
- package/dist/cli/commands/engine.js +60 -0
- package/dist/cli/commands/index.d.ts +1 -1
- package/dist/cli/commands/index.js +1 -1
- package/dist/cli/commands/launch/launch.js +47 -7
- package/dist/cli/commands/launch/prepare.js +3 -3
- package/dist/cli/commands/launch/running.js +2 -1
- package/dist/cli/commands/launch/summary.d.ts +2 -0
- package/dist/cli/commands/maintenance/config-share.d.ts +12 -0
- package/dist/cli/commands/maintenance/config-share.js +80 -0
- package/dist/cli/commands/maintenance/config.js +8 -82
- package/dist/cli/commands/maintenance/logs.js +14 -0
- package/dist/cli/commands/registry.js +3 -7
- package/dist/cli/commands/repair/checks/contained.d.ts +2 -0
- package/dist/cli/commands/repair/checks/contained.js +139 -0
- package/dist/cli/commands/repair/checks/hcs.d.ts +7 -0
- package/dist/cli/commands/repair/checks/hcs.js +28 -0
- package/dist/cli/commands/repair/checks/index.js +4 -0
- package/dist/cli/commands/repair/checks/pc.js +32 -1
- package/dist/cli/commands/repair/checks/sandbox.js +16 -1
- package/dist/cli/commands/repair/checks/vpn.js +34 -9
- package/dist/cli/commands/repair/env.js +2 -1
- package/dist/cli/commands/sessions/index.d.ts +0 -4
- package/dist/cli/commands/sessions/index.js +3 -7
- package/dist/cli/commands/shared-use.d.ts +5 -2
- package/dist/cli/commands/shared-use.js +11 -8
- package/dist/cli/commands/storage/contained.d.ts +3 -0
- package/dist/cli/commands/storage/contained.js +179 -0
- package/dist/cli/commands/storage/offer.js +7 -1
- package/dist/cli/commands/storage/storage.js +10 -2
- package/dist/cli/commands/user-config.js +1 -1
- package/dist/cli/commands/vpn.js +19 -3
- package/dist/cli/commands/web.js +2 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/manifest.d.ts +72 -104
- package/dist/cli/manifest.js +64 -39
- package/dist/cli/menu/add-agent.d.ts +1 -1
- package/dist/cli/menu/add-agent.js +1 -1
- package/dist/cli/menu/apps.d.ts +7 -1
- package/dist/cli/menu/apps.js +36 -0
- package/dist/cli/menu/command-fields.d.ts +1 -1
- package/dist/cli/menu/command-form.js +2 -2
- package/dist/cli/menu/io-menu.d.ts +29 -0
- package/dist/cli/menu/io-menu.js +126 -0
- package/dist/cli/menu/live.d.ts +27 -0
- package/dist/cli/menu/live.js +69 -0
- package/dist/cli/menu/memory.d.ts +19 -0
- package/dist/cli/menu/memory.js +53 -0
- package/dist/cli/menu/menu.d.ts +10 -1
- package/dist/cli/menu/menu.js +27 -9
- package/dist/cli/menu/pages/agents-page.d.ts +3 -1
- package/dist/cli/menu/pages/agents-page.js +12 -5
- package/dist/cli/menu/pages/apps-page.d.ts +3 -1
- package/dist/cli/menu/pages/apps-page.js +19 -2
- package/dist/cli/menu/pages/list-page.d.ts +27 -0
- package/dist/cli/menu/pages/list-page.js +109 -7
- package/dist/cli/menu/pages/maintenance-page.d.ts +0 -5
- package/dist/cli/menu/pages/maintenance-page.js +17 -19
- package/dist/cli/menu/pages/sandbox-page.d.ts +4 -6
- package/dist/cli/menu/pages/sandbox-page.js +26 -118
- package/dist/cli/menu/pages/scopes.d.ts +1 -1
- package/dist/cli/menu/pages/sessions-page.d.ts +5 -11
- package/dist/cli/menu/pages/sessions-page.js +19 -88
- package/dist/cli/menu/pages/settings-page.d.ts +2 -10
- package/dist/cli/menu/pages/settings-page.js +64 -94
- package/dist/cli/menu/render-view.d.ts +28 -0
- package/dist/cli/menu/render-view.js +112 -0
- package/dist/cli/menu/settings/{path-kind.d.ts → ask-path.d.ts} +1 -7
- package/dist/cli/menu/settings/ask-path.js +14 -0
- package/dist/cli/menu/settings/collections/collection-editor.d.ts +1 -1
- package/dist/cli/menu/settings/collections/string-list-editor.d.ts +1 -2
- package/dist/cli/menu/settings/collections/string-list-editor.js +1 -1
- package/dist/cli/menu/settings/draft.d.ts +1 -1
- package/dist/cli/menu/settings/format.d.ts +1 -3
- package/dist/cli/menu/settings/format.js +6 -36
- package/dist/cli/menu/settings/index.d.ts +1 -3
- package/dist/cli/menu/settings/index.js +3 -3
- package/dist/cli/menu/settings/object-editor.d.ts +1 -1
- package/dist/cli/menu/settings/share.d.ts +36 -0
- package/dist/cli/menu/settings/share.js +131 -0
- package/dist/cli/menu/settings/value-editor.d.ts +5 -1
- package/dist/cli/menu/settings/value-editor.js +57 -54
- package/dist/cli/menu/several.js +1 -1
- package/dist/cli/menu/share-settings.d.ts +21 -0
- package/dist/cli/menu/share-settings.js +112 -0
- package/dist/cli/menu/shell.d.ts +21 -5
- package/dist/cli/menu/shell.js +31 -6
- package/dist/cli/menu/views.d.ts +7 -0
- package/dist/cli/menu/views.js +11 -0
- package/dist/cli/menu/vpn-login.js +8 -0
- package/dist/cli/operations/handler.d.ts +6 -0
- package/dist/cli/operations/handler.js +61 -0
- package/dist/cli/operations/index.d.ts +4 -0
- package/dist/cli/operations/index.js +5 -0
- package/dist/cli/operations/input.d.ts +6 -0
- package/dist/cli/operations/input.js +37 -0
- package/dist/cli/operations/io-cli.d.ts +7 -0
- package/dist/cli/operations/io-cli.js +62 -0
- package/dist/cli/operations/spec.d.ts +18 -0
- package/dist/cli/operations/spec.js +108 -0
- package/dist/cli/output/colors.d.ts +2 -2
- package/dist/cli/output/colors.js +2 -11
- package/dist/cli/output/index.d.ts +1 -0
- package/dist/cli/output/index.js +1 -0
- package/dist/cli/output/print.d.ts +3 -1
- package/dist/cli/output/print.js +7 -3
- package/dist/cli/output/progress.d.ts +15 -0
- package/dist/cli/output/progress.js +44 -0
- package/dist/cli/output/render-view.d.ts +4 -0
- package/dist/cli/output/render-view.js +63 -0
- package/dist/cli/services/agent-commands-service.d.ts +2 -0
- package/dist/cli/services/agent-commands-service.js +11 -2
- package/dist/cli/services/logs-service.js +4 -3
- package/dist/cli/tui/app.d.ts +6 -1
- package/dist/cli/tui/app.js +26 -4
- package/dist/cli/tui/list/list-screen.d.ts +14 -0
- package/dist/cli/tui/list/list-screen.js +64 -36
- package/dist/cli/tui/list/list-types.d.ts +2 -0
- package/dist/cli/tui/terminal.d.ts +7 -0
- package/dist/cli/tui/terminal.js +30 -10
- package/dist/core/config/defaults.js +8 -0
- package/dist/core/schema/config.d.ts +13 -0
- package/dist/core/schema/config.js +16 -1
- package/dist/core/schema/harness.d.ts +1 -0
- package/dist/core/schema/harness.js +5 -0
- package/dist/core/schema/sandbox.d.ts +6 -0
- package/dist/core/schema/sandbox.js +20 -3
- package/dist/core/schema/vpn.d.ts +2 -1
- package/dist/core/schema/vpn.js +3 -3
- package/dist/core/types.d.ts +23 -5
- package/dist/core/util/fs.d.ts +2 -0
- package/dist/core/util/fs.js +9 -0
- package/dist/core/util/index.d.ts +1 -1
- package/dist/core/util/index.js +1 -1
- package/dist/guest/agents/agent-files.d.ts +5 -0
- package/dist/guest/agents/agent-files.js +4 -0
- package/dist/guest/agents/local-state.d.ts +2 -0
- package/dist/guest/agents/local-state.js +21 -1
- package/dist/guest/boot/boot.js +2 -1
- package/dist/guest/daemon/daemon.js +4 -0
- package/dist/guest/daemon/sessions.d.ts +5 -0
- package/dist/guest/daemon/sessions.js +17 -3
- package/dist/guest/entries/daemon.js +3 -0
- package/dist/guest/governor/decide.d.ts +61 -0
- package/dist/guest/governor/decide.js +182 -0
- package/dist/guest/governor/governor.d.ts +42 -0
- package/dist/guest/governor/governor.js +214 -0
- package/dist/guest/governor/index.d.ts +2 -0
- package/dist/guest/governor/index.js +2 -0
- package/dist/guest/runtime/csc.d.ts +1 -0
- package/dist/guest/runtime/csc.js +1 -0
- package/dist/guest/sessions/viewer.js +3 -1
- package/dist/guest/toolchains/native/rust-extras.js +4 -2
- package/dist/guest/vpn/vpn.js +69 -21
- package/dist/guest/vpn/wireguard.d.ts +32 -0
- package/dist/guest/vpn/wireguard.js +132 -0
- package/dist/host/agent-commands/commands.d.ts +4 -0
- package/dist/host/agent-commands/commands.js +31 -7
- package/dist/host/audit/log.d.ts +1 -1
- package/dist/host/channel/attach.d.ts +3 -1
- package/dist/host/channel/attach.js +5 -2
- package/dist/host/channel/channel.d.ts +2 -0
- package/dist/host/channel/channel.js +4 -0
- package/dist/host/engines/engine.d.ts +12 -0
- package/dist/host/engines/engine.js +1 -0
- package/dist/host/engines/hcs/check.d.ts +25 -0
- package/dist/host/engines/hcs/check.js +95 -0
- package/dist/host/engines/hcs/documents.d.ts +44 -0
- package/dist/host/engines/hcs/documents.js +155 -0
- package/dist/host/engines/hcs/engine.d.ts +39 -0
- package/dist/host/engines/hcs/engine.js +171 -0
- package/dist/host/engines/hcs/helper.d.ts +43 -0
- package/dist/host/engines/hcs/helper.js +173 -0
- package/dist/host/engines/hcs/images.d.ts +37 -0
- package/dist/host/engines/hcs/images.js +152 -0
- package/dist/host/engines/index.d.ts +7 -0
- package/dist/host/engines/index.js +5 -0
- package/dist/host/engines/registry.d.ts +16 -0
- package/dist/host/engines/registry.js +30 -0
- package/dist/host/engines/types.d.ts +58 -0
- package/dist/host/engines/types.js +1 -0
- package/dist/host/engines/windows-sandbox/engine.d.ts +16 -0
- package/dist/host/engines/windows-sandbox/engine.js +63 -0
- package/dist/host/engines/windows-sandbox/wsb-text.d.ts +2 -0
- package/dist/host/engines/windows-sandbox/wsb-text.js +29 -0
- package/dist/host/launch/generate.d.ts +5 -1
- package/dist/host/launch/generate.js +50 -8
- package/dist/host/launch/index.d.ts +3 -1
- package/dist/host/launch/index.js +3 -1
- package/dist/host/launch/launch-plan.d.ts +13 -0
- package/dist/host/launch/launch-plan.js +26 -0
- package/dist/host/launch/mappings.js +2 -1
- package/dist/host/launch/risk-notes.d.ts +10 -0
- package/dist/host/launch/risk-notes.js +18 -0
- package/dist/host/launch/session-file.d.ts +2 -0
- package/dist/host/launch/session-file.js +7 -1
- package/dist/host/launch/wsb-file.d.ts +28 -4
- package/dist/host/launch/wsb-file.js +61 -42
- package/dist/host/life/crash-report.d.ts +27 -1
- package/dist/host/life/crash-report.js +173 -7
- package/dist/host/life/host-memory.d.ts +40 -0
- package/dist/host/life/host-memory.js +137 -0
- package/dist/host/life/index.d.ts +2 -0
- package/dist/host/life/index.js +2 -0
- package/dist/host/life/stop-events.d.ts +2 -0
- package/dist/host/life/stop-events.js +20 -3
- package/dist/host/life/stop-warning.js +1 -1
- package/dist/host/life/watchdog.d.ts +54 -0
- package/dist/host/life/watchdog.js +108 -0
- package/dist/host/native.d.ts +3 -2
- package/dist/host/native.js +22 -3
- package/dist/host/profile/claude-login.js +3 -2
- package/dist/host/sandbox/contained-deps.d.ts +2 -0
- package/dist/host/sandbox/contained-deps.js +17 -0
- package/dist/host/sandbox/index.d.ts +2 -0
- package/dist/host/sandbox/index.js +2 -0
- package/dist/host/sandbox/platform.d.ts +2 -0
- package/dist/host/sandbox/platform.js +7 -7
- package/dist/host/sandbox/tasklist.d.ts +13 -0
- package/dist/host/sandbox/tasklist.js +47 -0
- package/dist/host/secrets/launch-secrets.js +2 -1
- package/dist/host/sharing/current.js +2 -6
- package/dist/host/storage/contained/check.d.ts +9 -0
- package/dist/host/storage/contained/check.js +37 -0
- package/dist/host/storage/contained/contained-storage.d.ts +66 -0
- package/dist/host/storage/contained/contained-storage.js +168 -0
- package/dist/host/storage/contained/disk-port.d.ts +43 -0
- package/dist/host/storage/contained/disk-port.js +122 -0
- package/dist/host/storage/contained/index.d.ts +9 -0
- package/dist/host/storage/contained/index.js +8 -0
- package/dist/host/storage/contained/layout.d.ts +28 -0
- package/dist/host/storage/contained/layout.js +45 -0
- package/dist/host/storage/contained/resolve.d.ts +4 -0
- package/dist/host/storage/contained/resolve.js +30 -0
- package/dist/host/storage/contained/setting.d.ts +1 -0
- package/dist/host/storage/contained/setting.js +5 -0
- package/dist/host/storage/contained/state.d.ts +89 -0
- package/dist/host/storage/contained/state.js +166 -0
- package/dist/host/storage/contained/transfer.d.ts +24 -0
- package/dist/host/storage/contained/transfer.js +121 -0
- package/dist/host/storage/index.d.ts +2 -0
- package/dist/host/storage/index.js +2 -0
- package/dist/host/storage/providers/contained.d.ts +15 -0
- package/dist/host/storage/providers/contained.js +39 -0
- package/dist/host/storage/providers/folder.d.ts +12 -0
- package/dist/host/storage/providers/folder.js +20 -0
- package/dist/host/storage/providers/index.d.ts +4 -0
- package/dist/host/storage/providers/index.js +3 -0
- package/dist/host/storage/providers/registry.d.ts +9 -0
- package/dist/host/storage/providers/registry.js +14 -0
- package/dist/host/storage/providers/types.d.ts +33 -0
- package/dist/host/storage/providers/types.js +1 -0
- package/dist/host/tools/conpty.js +3 -2
- package/dist/host/tools/windows-terminal.js +8 -7
- package/dist/host/vpn/index.d.ts +1 -1
- package/dist/host/vpn/index.js +1 -1
- package/dist/host/vpn/prepare.d.ts +2 -0
- package/dist/host/vpn/prepare.js +63 -2
- package/dist/host/web/browser.d.ts +2 -0
- package/dist/host/web/browser.js +14 -1
- package/dist/host/web/index.d.ts +3 -2
- package/dist/host/web/index.js +3 -2
- package/dist/host/web/rpc.d.ts +24 -0
- package/dist/host/web/rpc.js +149 -0
- package/dist/host/web/runner.d.ts +2 -0
- package/dist/host/web/runner.js +1 -2
- package/dist/host/web/server.d.ts +7 -0
- package/dist/host/web/server.js +23 -3
- package/dist/runtime/agent.js +69 -8
- package/dist/runtime/daemon.js +1058 -624
- package/dist/runtime/db.js +69 -8
- package/dist/runtime/main.js +624 -182
- package/dist/runtime/netproxy.js +69 -8
- package/dist/runtime/view.js +87 -13
- package/dist/selftest/agent-paths.test.js +11 -1
- package/dist/selftest/app.test.d.ts +2 -0
- package/dist/selftest/app.test.js +324 -0
- package/dist/selftest/channel.test.js +13 -0
- package/dist/selftest/cli.test.js +2 -1
- package/dist/selftest/config.test.js +59 -0
- package/dist/selftest/contained.test.d.ts +2 -0
- package/dist/selftest/contained.test.js +544 -0
- package/dist/selftest/credentials.test.js +1 -1
- package/dist/selftest/engine.test.d.ts +2 -0
- package/dist/selftest/engine.test.js +127 -0
- package/dist/selftest/hcs.test.d.ts +2 -0
- package/dist/selftest/hcs.test.js +482 -0
- package/dist/selftest/heavy-load.test.d.ts +2 -0
- package/dist/selftest/heavy-load.test.js +329 -0
- package/dist/selftest/index.js +12 -0
- package/dist/selftest/layout.test.js +12 -0
- package/dist/selftest/menu-perf.test.d.ts +2 -0
- package/dist/selftest/menu-perf.test.js +248 -0
- package/dist/selftest/menu-screens.js +4 -2
- package/dist/selftest/menu.test.js +36 -8
- package/dist/selftest/support/engine-cases.d.ts +8 -0
- package/dist/selftest/support/engine-cases.js +65 -0
- package/dist/selftest/support/engine-golden.d.ts +3 -0
- package/dist/selftest/support/engine-golden.js +66 -0
- package/dist/selftest/support/fixtures.d.ts +7 -1
- package/dist/selftest/support/hcs-probes.d.ts +17 -0
- package/dist/selftest/support/hcs-probes.js +41 -0
- package/dist/selftest/vpn.test.js +136 -3
- package/dist/selftest/web.test.js +101 -3
- package/dist/shared/channel/run-dir.d.ts +4 -1
- package/dist/shared/channel/run-dir.js +7 -1
- package/dist/shared/channel/schema.d.ts +35 -1
- package/dist/shared/channel/schema.js +27 -0
- package/dist/shared/channel/secrets.d.ts +1 -0
- package/dist/shared/channel/secrets.js +6 -0
- package/dist/shared/memory/index.d.ts +1 -0
- package/dist/shared/memory/index.js +1 -0
- package/dist/shared/memory/policy.d.ts +33 -0
- package/dist/shared/memory/policy.js +55 -0
- package/dist/shared/pty/output-filter.d.ts +14 -1
- package/dist/shared/pty/output-filter.js +22 -4
- package/dist/shared/pty/terminal.d.ts +4 -1
- package/dist/shared/pty/terminal.js +4 -2
- package/dist/shared/system.d.ts +1 -0
- package/dist/shared/system.js +1 -0
- package/dist/shared/vpn/download.d.ts +16 -0
- package/dist/shared/vpn/download.js +16 -0
- package/dist/shared/vpn/wireguard.d.ts +51 -0
- package/dist/shared/vpn/wireguard.js +227 -0
- package/dist/sync/sync-cycle.js +5 -5
- package/dist/sync/watcher.d.ts +13 -0
- package/dist/sync/watcher.js +92 -3
- package/dist/web/index.html +4 -3
- package/dist/web/main-NRRS5O6Z.js +157 -0
- package/dist/web/main-T5DMCHYV.css +1 -0
- package/native/csharp/HcsHost/AssemblyInfo.cs +14 -0
- package/native/csharp/HcsHost/Guard.cs +100 -0
- package/native/csharp/HcsHost/Hcs.cs +256 -0
- package/native/csharp/HcsHost/Json.cs +78 -0
- package/native/csharp/HcsHost/Program.cs +185 -0
- package/native/csharp/HcsHost/VirtualDisk.cs +95 -0
- package/native/csharp/HostTools/AssemblyInfo.cs +14 -0
- package/native/csharp/HostTools/MemoryStatus.cs +107 -0
- package/native/csharp/HostTools/Program.cs +58 -17
- package/native/scripts/check-contained.ps1 +28 -0
- package/native/scripts/contained-common.ps1 +241 -0
- package/native/scripts/dismount-contained.ps1 +66 -0
- package/native/scripts/memory-status.ps1 +34 -0
- package/native/scripts/mount-contained.ps1 +139 -0
- package/native/scripts/run-elevated.ps1 +17 -4
- package/native/scripts/stop-events.ps1 +23 -8
- package/package.json +9 -2
- package/sandbox/csharp/MemGov.cs +398 -0
- package/sandbox/csharp/PtyHost.cs +111 -5
- package/schemas/config.schema.json +60 -6
- package/schemas/sandbox-config.schema.json +3 -3
- package/dist/cli/commands/sessions/control.d.ts +0 -4
- package/dist/cli/commands/sessions/control.js +0 -66
- package/dist/cli/commands/sessions/list.d.ts +0 -2
- package/dist/cli/commands/sessions/list.js +0 -48
- package/dist/cli/commands/sessions/status.d.ts +0 -4
- package/dist/cli/commands/sessions/status.js +0 -114
- package/dist/cli/commands/sessions/window.d.ts +0 -3
- package/dist/cli/commands/sessions/window.js +0 -18
- package/dist/cli/menu/settings/path-kind.js +0 -44
- package/dist/web/main-CXESL347.js +0 -45
- package/dist/web/main-VLR7DVQ4.css +0 -1
- /package/dist/{cli/menu/settings → app/kernel}/schema-node.d.ts +0 -0
- /package/dist/{cli/menu/settings → app/kernel}/schema-node.js +0 -0
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
|
+
import os from 'node:os';
|
|
6
7
|
import { widenForProjects } from '../../core/local-config/index.js';
|
|
7
8
|
import { dirExists, ensureDir, fail, writeJson } from '../../core/util/index.js';
|
|
9
|
+
import { engineFor } from '../engines/index.js';
|
|
8
10
|
import { capturePersonalization, stageClaudeProfile } from '../profile/index.js';
|
|
9
11
|
import { clearSecrets, writeSecrets } from '../secrets/index.js';
|
|
12
|
+
import { folderAttachment } from '../storage/providers/index.js';
|
|
10
13
|
import { assertTestWritable } from '../test-guard.js';
|
|
14
|
+
import { writeLoadSettings } from '../life/watchdog.js';
|
|
15
|
+
import { loadProfileOf } from './risk-notes.js';
|
|
11
16
|
import { planBootProjects } from './boot-projects.js';
|
|
12
17
|
import { planDatabases } from './database-plan.js';
|
|
13
18
|
import { collectMappings } from './mappings.js';
|
|
14
19
|
import { guestSession, logonEnv } from './session-file.js';
|
|
15
20
|
import { copyRuntime, stageGitIdentity, stageHooks } from './stage.js';
|
|
16
21
|
import { decideProjectToolchains } from './toolchains.js';
|
|
17
|
-
import {
|
|
22
|
+
import { buildLaunchPlan } from './launch-plan.js';
|
|
23
|
+
import { decideMemory, GUEST, memoryNote, resolveMemoryMb } from './wsb-file.js';
|
|
18
24
|
const NO_PROFILE = { hostDir: null, staged: [], skipped: [], credentials: false, secretsRemoved: [] };
|
|
19
25
|
/** Moves the staged copy of this PC's Claude login out of the launch folder; its text goes in the one-shot file. */
|
|
20
26
|
function takeStagedCredentials(launchPath) {
|
|
@@ -25,7 +31,9 @@ function takeStagedCredentials(launchPath) {
|
|
|
25
31
|
fs.rmSync(file, { force: true });
|
|
26
32
|
return text;
|
|
27
33
|
}
|
|
28
|
-
export function generateSandbox(given
|
|
34
|
+
export function generateSandbox(given,
|
|
35
|
+
/** The engine launch.ts opened (hcs needs a look at this PC first); Windows Sandbox when left out. */
|
|
36
|
+
opened) {
|
|
29
37
|
// Several projects at boot: the sandbox also gets what the others want and you allowed (core/local-config).
|
|
30
38
|
const others = given.bootWants?.projects ?? [];
|
|
31
39
|
const boot = planBootProjects({
|
|
@@ -43,10 +51,15 @@ export function generateSandbox(given) {
|
|
|
43
51
|
fail('Unknown agent: ' + harnessName, 'Configured agents: ' + Object.keys(config.harnesses).join(', ')));
|
|
44
52
|
if (!dirExists(workspaceHost))
|
|
45
53
|
fail('The workspace folder does not exist: ' + workspaceHost, 'cd into the project first.');
|
|
54
|
+
// An engine or storage kind that cannot work yet stops the launch here, before anything is written.
|
|
55
|
+
const engine = opened ?? engineFor(config);
|
|
56
|
+
if (config.storage.contained !== 'off' && !o.dataMappings)
|
|
57
|
+
fail('Contained storage was not prepared for this launch.', 'Launch with sandbox launch (it mounts the image first).');
|
|
46
58
|
assertTestWritable(storageRoot);
|
|
47
59
|
assertTestWritable(dataPath);
|
|
48
60
|
// Checked before anything is written, so a refusal leaves nothing behind.
|
|
49
|
-
const
|
|
61
|
+
const commitAvailableMb = o.commitAvailableMb ?? null;
|
|
62
|
+
const memoryMb = Math.max(resolveMemoryMb(config.sandbox, o.freeMemoryBytes, undefined, commitAvailableMb), ...others.map((p) => (typeof p.config.sandbox.memoryMb === 'number' ? p.config.sandbox.memoryMb : 0)));
|
|
50
63
|
const launchId = Date.now() + '-' + crypto.randomBytes(3).toString('hex');
|
|
51
64
|
const launchPath = path.join(storageRoot, 'launches', launchId);
|
|
52
65
|
// Whatever must stay secret goes in a one-shot file in the data folder, never into the launch folder (the sandbox
|
|
@@ -65,29 +78,58 @@ export function generateSandbox(given) {
|
|
|
65
78
|
const personalization = config.personalization.enabled ? capturePersonalization(launchPath) : 'disabled';
|
|
66
79
|
const databases = o.databases ?? planDatabases(config.databases, workspaceHost);
|
|
67
80
|
const toolchains = decideProjectToolchains(o);
|
|
68
|
-
if (o.vpn) {
|
|
81
|
+
if (o.vpn?.profile) {
|
|
69
82
|
ensureDir(path.join(launchPath, 'vpn'));
|
|
70
83
|
fs.writeFileSync(path.join(launchPath, 'vpn', 'server.ovpn'), o.vpn.profile, 'utf8');
|
|
71
84
|
}
|
|
72
|
-
const session = guestSession(o, {
|
|
85
|
+
const session = guestSession(o, {
|
|
86
|
+
launchId,
|
|
87
|
+
launchPath,
|
|
88
|
+
harness,
|
|
89
|
+
boot,
|
|
90
|
+
mappings,
|
|
91
|
+
profile,
|
|
92
|
+
databases,
|
|
93
|
+
toolchains,
|
|
94
|
+
memoryMb,
|
|
95
|
+
});
|
|
73
96
|
const sessionPath = path.join(launchPath, 'session.json');
|
|
74
97
|
writeJson(sessionPath, session);
|
|
98
|
+
writeLoadSettings(storageRoot, dataPath, {
|
|
99
|
+
profile: loadProfileOf(config),
|
|
100
|
+
reserveHostMb: config.sandbox.reserveHostMb,
|
|
101
|
+
});
|
|
75
102
|
writeSecrets(dataPath, launchId, {
|
|
76
103
|
...(harness && Object.keys(harness.environment).length ? { harnessEnvironment: harness.environment } : {}),
|
|
77
104
|
...(claudeCredentials ? { claudeCredentials } : {}),
|
|
78
|
-
...(o.vpn ? { vpn: o.vpn.credentials } : {}),
|
|
105
|
+
...(o.vpn?.credentials ? { vpn: o.vpn.credentials } : {}),
|
|
106
|
+
...(o.vpn?.wireguardConfig ? { wireguardConfig: o.vpn.wireguardConfig } : {}),
|
|
79
107
|
});
|
|
80
108
|
fs.writeFileSync(path.join(launchPath, 'env.cmd'), logonEnv(session.workspace), 'utf8');
|
|
81
109
|
copyRuntime(o.packageRoot, launchPath);
|
|
82
110
|
stageHooks(o.packageRoot, launchPath, o.run.scripts);
|
|
83
|
-
const
|
|
84
|
-
|
|
111
|
+
const enginePlan = engine.plan(buildLaunchPlan({
|
|
112
|
+
config,
|
|
113
|
+
memoryMb,
|
|
114
|
+
mappings,
|
|
115
|
+
launchPath,
|
|
116
|
+
storage: o.dataMappings
|
|
117
|
+
? o.dataMappings.map((m) => ({ kind: 'folder', host: m.host, guest: m.guest, readOnly: m.readOnly }))
|
|
118
|
+
: [folderAttachment({ dataPath, guest: GUEST.data })],
|
|
119
|
+
}));
|
|
120
|
+
for (const file of enginePlan.files)
|
|
121
|
+
fs.writeFileSync(file.path, file.text, 'utf8');
|
|
122
|
+
const wsbPath = enginePlan.entry;
|
|
85
123
|
return {
|
|
86
124
|
wsbPath,
|
|
125
|
+
enginePlan,
|
|
87
126
|
launchPath,
|
|
88
127
|
launchId,
|
|
89
128
|
sessionPath,
|
|
90
129
|
memoryMb,
|
|
130
|
+
memoryNote: config.sandbox.memoryMb === 'auto'
|
|
131
|
+
? memoryNote(decideMemory(config.sandbox, Math.floor((o.freeMemoryBytes ?? os.freemem()) / 1048576), Math.floor(os.totalmem() / 1048576), commitAvailableMb))
|
|
132
|
+
: null,
|
|
91
133
|
bootConfig: config,
|
|
92
134
|
widened: wide.widened,
|
|
93
135
|
mappings,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { generateSandbox } from './generate.js';
|
|
2
2
|
export { decideProjectToolchains } from './toolchains.js';
|
|
3
3
|
export { hostToolsOf, logonEnv } from './session-file.js';
|
|
4
|
-
export { GUEST,
|
|
4
|
+
export { agentMemoryLimitMb, decideMemory, GUEST, memoryNote, resolveMemoryMb } from './wsb-file.js';
|
|
5
|
+
export { GENTLE_NOTE, vgpuSource, vgpuWarning } from './risk-notes.js';
|
|
6
|
+
export { buildLaunchPlan, buildWsb } from './launch-plan.js';
|
|
5
7
|
export { MAX_BOOT_PROJECTS, planBootProjects, shownByRoot, type BootProjects } from './boot-projects.js';
|
|
6
8
|
export { databaseCatalog, planDatabases } from './database-plan.js';
|
|
7
9
|
export { msvcHint, projectEntries, readProjectFiles, uvHint } from './project-scan.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { generateSandbox } from './generate.js';
|
|
2
2
|
export { decideProjectToolchains } from './toolchains.js';
|
|
3
3
|
export { hostToolsOf, logonEnv } from './session-file.js';
|
|
4
|
-
export { GUEST,
|
|
4
|
+
export { agentMemoryLimitMb, decideMemory, GUEST, memoryNote, resolveMemoryMb } from './wsb-file.js';
|
|
5
|
+
export { GENTLE_NOTE, vgpuSource, vgpuWarning } from './risk-notes.js';
|
|
6
|
+
export { buildLaunchPlan, buildWsb } from './launch-plan.js';
|
|
5
7
|
export { MAX_BOOT_PROJECTS, planBootProjects, shownByRoot } from './boot-projects.js';
|
|
6
8
|
export { databaseCatalog, planDatabases } from './database-plan.js';
|
|
7
9
|
export { msvcHint, projectEntries, readProjectFiles, uvHint } from './project-scan.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Config, ResolvedMapping } from '../../core/types.js';
|
|
2
|
+
import { type LaunchPlan } from '../engines/index.js';
|
|
3
|
+
import type { StorageAttachment } from '../storage/providers/index.js';
|
|
4
|
+
export interface LaunchPlanInput {
|
|
5
|
+
readonly config: Config;
|
|
6
|
+
readonly memoryMb: number;
|
|
7
|
+
readonly mappings: readonly ResolvedMapping[];
|
|
8
|
+
readonly launchPath: string;
|
|
9
|
+
readonly storage: readonly StorageAttachment[];
|
|
10
|
+
}
|
|
11
|
+
export declare function buildLaunchPlan(input: LaunchPlanInput): LaunchPlan;
|
|
12
|
+
/** The .wsb text for these settings (the Windows Sandbox engine's file, without writing it). */
|
|
13
|
+
export declare function buildWsb(config: Config, memoryMb: number, mappings: readonly ResolvedMapping[]): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { wsbText } from '../engines/index.js';
|
|
2
|
+
import { GUEST } from './wsb-file.js';
|
|
3
|
+
export function buildLaunchPlan(input) {
|
|
4
|
+
const s = input.config.sandbox;
|
|
5
|
+
return {
|
|
6
|
+
launchPath: input.launchPath,
|
|
7
|
+
memoryMb: input.memoryMb,
|
|
8
|
+
cpuLimit: s.cpuLimit,
|
|
9
|
+
networking: s.networking,
|
|
10
|
+
devices: {
|
|
11
|
+
gpu: s.vGpu,
|
|
12
|
+
clipboard: s.clipboard,
|
|
13
|
+
audioInput: s.audioInput,
|
|
14
|
+
videoInput: s.videoInput,
|
|
15
|
+
printers: s.printerRedirection,
|
|
16
|
+
protectedClient: s.protectedClient,
|
|
17
|
+
},
|
|
18
|
+
mappings: input.mappings,
|
|
19
|
+
logonCommand: GUEST.launch + '\\sandbox\\boot\\logon.cmd',
|
|
20
|
+
storage: input.storage,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** The .wsb text for these settings (the Windows Sandbox engine's file, without writing it). */
|
|
24
|
+
export function buildWsb(config, memoryMb, mappings) {
|
|
25
|
+
return wsbText(buildLaunchPlan({ config, memoryMb, mappings, launchPath: GUEST.launch, storage: [] }));
|
|
26
|
+
}
|
|
@@ -6,6 +6,7 @@ import { assertSafeMapping } from '../../core/safe-paths.js';
|
|
|
6
6
|
import { dirExists, errMsg, fail, isInsideOrEqual, UserError } from '../../core/util/index.js';
|
|
7
7
|
import { shownByRoot } from './boot-projects.js';
|
|
8
8
|
import { deriveGuest, isValidGuestPath, guestConflict, guestFix, PROJECTS_GUEST, sandboxFolder, tidyGuestPath, } from '../../shared/paths/index.js';
|
|
9
|
+
import { dataMapping } from '../storage/providers/index.js';
|
|
9
10
|
import { GUEST } from './wsb-file.js';
|
|
10
11
|
import { guestGitDir, planView } from '../workspace-view/index.js';
|
|
11
12
|
/**
|
|
@@ -23,7 +24,7 @@ export function collectMappings(o, launchPath, boot = { roots: [], projects: [],
|
|
|
23
24
|
const inRoot = !view && shownByRoot(boot.roots, workspaceHost, config.guestWorkspace);
|
|
24
25
|
const mappings = [
|
|
25
26
|
{ host: launchPath, guest: GUEST.launch, readOnly: true },
|
|
26
|
-
{
|
|
27
|
+
...(o.dataMappings ?? [dataMapping({ dataPath, guest: GUEST.data })]),
|
|
27
28
|
...(inRoot
|
|
28
29
|
? []
|
|
29
30
|
: [{ host: view ? view.options.view : workspaceHost, guest: config.guestWorkspace, readOnly: config.readOnly }]),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config } from '../../core/types.js';
|
|
2
|
+
import type { LoadProfile } from '../../shared/memory/index.js';
|
|
3
|
+
/** The stricter load profile applies whenever vGPU is on, from any source. */
|
|
4
|
+
export declare function loadProfileOf(config: Config): LoadProfile;
|
|
5
|
+
/** Where vGpu being on comes from, for the sentence below: your own settings, or a project file you allowed. */
|
|
6
|
+
export declare function vgpuSource(yourSettingOn: boolean): string;
|
|
7
|
+
/** The vGPU warning (pure). `source` is vgpuSource(...) or "your settings". */
|
|
8
|
+
export declare function vgpuWarning(source: string): string;
|
|
9
|
+
/** The launch note that goes with the vGPU warning: what the tool does about it by itself. */
|
|
10
|
+
export declare const GENTLE_NOTE = "vGPU is on: the sandbox runs gentler so this PC stays responsive.";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Plain-words warnings about settings that can take the whole PC down, shown at launch, by doctor and in crash reports.
|
|
2
|
+
/** The stricter load profile applies whenever vGPU is on, from any source. */
|
|
3
|
+
export function loadProfileOf(config) {
|
|
4
|
+
return config.sandbox.vGpu ? 'gentle' : 'normal';
|
|
5
|
+
}
|
|
6
|
+
/** Where vGpu being on comes from, for the sentence below: your own settings, or a project file you allowed. */
|
|
7
|
+
export function vgpuSource(yourSettingOn) {
|
|
8
|
+
return yourSettingOn ? 'your settings' : "this project's .sandbox-config.json, which you allowed";
|
|
9
|
+
}
|
|
10
|
+
/** The vGPU warning (pure). `source` is vgpuSource(...) or "your settings". */
|
|
11
|
+
export function vgpuWarning(source) {
|
|
12
|
+
return ('vGPU is on (from ' +
|
|
13
|
+
source +
|
|
14
|
+
"): the sandbox uses this PC's graphics card. With some graphics drivers, heavy use can freeze the whole PC. " +
|
|
15
|
+
'Turn it off unless a program in the sandbox needs the GPU (the mesa toolchain gives software OpenGL without it).');
|
|
16
|
+
}
|
|
17
|
+
/** The launch note that goes with the vGPU warning: what the tool does about it by itself. */
|
|
18
|
+
export const GENTLE_NOTE = 'vGPU is on: the sandbox runs gentler so this PC stays responsive.';
|
|
@@ -10,6 +10,8 @@ export interface SessionParts {
|
|
|
10
10
|
readonly profile: ProfileResult;
|
|
11
11
|
readonly databases: DatabasePlan[];
|
|
12
12
|
readonly toolchains: Generated['toolchains'];
|
|
13
|
+
/** The sandbox's memory (MB), for the agents' memory limit. */
|
|
14
|
+
readonly memoryMb: number;
|
|
13
15
|
}
|
|
14
16
|
/** What was found on this PC to copy instead of download. */
|
|
15
17
|
export declare function hostToolsOf(probe: HostProbe): GuestSession['hostTools'];
|
|
@@ -5,6 +5,9 @@ import { resolveToolchains } from '../../core/detect/index.js';
|
|
|
5
5
|
import { hubName, PROJECTS_GUEST, substDrives } from '../../shared/paths/index.js';
|
|
6
6
|
import { hostClaudeDir } from '../profile/index.js';
|
|
7
7
|
import { databaseCatalog } from './database-plan.js';
|
|
8
|
+
import { agentMemoryLimitMb } from './wsb-file.js';
|
|
9
|
+
import { effectiveCpuLimit } from '../../shared/memory/index.js';
|
|
10
|
+
import { loadProfileOf } from './risk-notes.js';
|
|
8
11
|
/** What was found on this PC to copy instead of download. */
|
|
9
12
|
export function hostToolsOf(probe) {
|
|
10
13
|
return {
|
|
@@ -59,8 +62,11 @@ export function guestSession(o, parts) {
|
|
|
59
62
|
},
|
|
60
63
|
personalization: fs.existsSync(path.join(parts.launchPath, 'personalize', 'personalize.reg')),
|
|
61
64
|
substDrives: substDrives(parts.mappings.map((m) => m.guest)),
|
|
62
|
-
cpuLimitPercent: config.sandbox.cpuLimit
|
|
65
|
+
cpuLimitPercent: effectiveCpuLimit(config.sandbox.cpuLimit, loadProfileOf(config)),
|
|
66
|
+
loadProfile: loadProfileOf(config),
|
|
63
67
|
pageFileMb: config.sandbox.pageFileMb,
|
|
68
|
+
agentMemoryLimitMb: agentMemoryLimitMb(parts.memoryMb, config.sandbox.agentMemoryHeadroomMb),
|
|
69
|
+
pressureResponse: config.sandbox.pressureResponse,
|
|
64
70
|
apps: config.apps,
|
|
65
71
|
auditProcesses: config.audit.enabled && config.audit.processes,
|
|
66
72
|
agentHomes: Object.assign({}, ...Object.values(config.harnesses).map((h) => h.home?.env ?? {})),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config
|
|
1
|
+
import type { Config } from '../../core/types.js';
|
|
2
2
|
export declare const GUEST: {
|
|
3
3
|
readonly launch: "C:\\AgentLaunch";
|
|
4
4
|
readonly data: "C:\\AgentData";
|
|
@@ -6,7 +6,31 @@ export declare const GUEST: {
|
|
|
6
6
|
readonly mirror: "C:\\Mirror";
|
|
7
7
|
};
|
|
8
8
|
type SandboxSettings = Config['sandbox'];
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
9
|
+
export type MemoryLimit = 'free' | 'share' | 'max' | 'commit';
|
|
10
|
+
export interface MemoryDecision {
|
|
11
|
+
readonly mb: number;
|
|
12
|
+
/** What set the size. */
|
|
13
|
+
readonly limitedBy: MemoryLimit;
|
|
14
|
+
/** What it would have been without looking at the commit (the old rule). */
|
|
15
|
+
readonly withoutCommitMb: number;
|
|
16
|
+
/** The inputs of the refusal, when mb is below the minimum. */
|
|
17
|
+
readonly freeMb: number;
|
|
18
|
+
readonly commitAvailableMb: number | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* "auto" (pure): free RAM minus the reserve, never more than maxMemoryMb or maxMemoryPercent of the PC's total RAM,
|
|
22
|
+
* and, when the PC's available commit (RAM plus paging file, what the sandbox's memory is charged against) is known,
|
|
23
|
+
* never more than that minus the reserve either.
|
|
24
|
+
*/
|
|
25
|
+
export declare function decideMemory(sandbox: SandboxSettings, freeMb: number, totalMb: number, commitAvailableMb: number | null): MemoryDecision;
|
|
26
|
+
/**
|
|
27
|
+
* The most memory everything the agents start may use together (pure): the sandbox's memory minus the headroom
|
|
28
|
+
* ("auto" =
|
|
29
|
+
* the larger of 2048 MB and 10 %), at least half of it so a tiny sandbox still works; null = no limit ("none").
|
|
30
|
+
*/
|
|
31
|
+
export declare function agentMemoryLimitMb(memoryMb: number, headroom: SandboxSettings['agentMemoryHeadroomMb']): number | null;
|
|
32
|
+
/** A plain-words note when the commit made the sandbox's memory much smaller (2 GB or more) than free RAM allowed. */
|
|
33
|
+
export declare function memoryNote(decision: MemoryDecision): string | null;
|
|
34
|
+
/** "auto": see decideMemory. commitAvailableMb: from HostTools memory-status (omitted = not checked). */
|
|
35
|
+
export declare function resolveMemoryMb(sandbox: SandboxSettings, freeMemoryBytes?: number, totalMemoryBytes?: number, commitAvailableMb?: number | null): number;
|
|
12
36
|
export {};
|
|
@@ -1,56 +1,75 @@
|
|
|
1
|
-
// The
|
|
1
|
+
// The guest's fixed folders, and how much memory the sandbox gets.
|
|
2
2
|
import os from 'node:os';
|
|
3
|
-
import { fail
|
|
4
|
-
import { MIRROR_ROOT
|
|
3
|
+
import { fail } from '../../core/util/index.js';
|
|
4
|
+
import { MIRROR_ROOT } from '../../shared/paths/index.js';
|
|
5
5
|
export const GUEST = {
|
|
6
6
|
launch: 'C:\\AgentLaunch',
|
|
7
7
|
data: 'C:\\AgentData',
|
|
8
8
|
hostTools: 'C:\\HostTools',
|
|
9
9
|
mirror: MIRROR_ROOT,
|
|
10
10
|
};
|
|
11
|
-
/** The .wsb elements switched on or off by a sandbox setting, in the order Windows Sandbox expects them. */
|
|
12
|
-
const DEVICES = [
|
|
13
|
-
['vGPU', 'vGpu'],
|
|
14
|
-
['Networking', 'networking'],
|
|
15
|
-
['ClipboardRedirection', 'clipboard'],
|
|
16
|
-
['AudioInput', 'audioInput'],
|
|
17
|
-
['VideoInput', 'videoInput'],
|
|
18
|
-
['PrinterRedirection', 'printerRedirection'],
|
|
19
|
-
['ProtectedClient', 'protectedClient'],
|
|
20
|
-
];
|
|
21
11
|
const MB = 1048576;
|
|
22
12
|
const MIN_AUTO_MEMORY_MB = 4096;
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const roundDown = (mb) => Math.floor(mb / 1024) * 1024;
|
|
14
|
+
/**
|
|
15
|
+
* "auto" (pure): free RAM minus the reserve, never more than maxMemoryMb or maxMemoryPercent of the PC's total RAM,
|
|
16
|
+
* and, when the PC's available commit (RAM plus paging file, what the sandbox's memory is charged against) is known,
|
|
17
|
+
* never more than that minus the reserve either.
|
|
18
|
+
*/
|
|
19
|
+
export function decideMemory(sandbox, freeMb, totalMb, commitAvailableMb) {
|
|
20
|
+
const shareMb = Math.floor((totalMb * sandbox.maxMemoryPercent) / 100);
|
|
21
|
+
const byFree = freeMb - sandbox.reserveHostMb;
|
|
22
|
+
const byCommit = commitAvailableMb === null ? Infinity : commitAvailableMb - sandbox.reserveHostMb;
|
|
23
|
+
const candidates = [
|
|
24
|
+
['max', sandbox.maxMemoryMb],
|
|
25
|
+
['share', shareMb],
|
|
26
|
+
['free', byFree],
|
|
27
|
+
['commit', byCommit],
|
|
28
|
+
];
|
|
29
|
+
const lowest = candidates.reduce((a, b) => (b[1] < a[1] ? b : a));
|
|
30
|
+
const withoutCommit = roundDown(Math.min(sandbox.maxMemoryMb, shareMb, byFree));
|
|
31
|
+
return { mb: roundDown(lowest[1]), limitedBy: lowest[0], withoutCommitMb: withoutCommit, freeMb, commitAvailableMb };
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The most memory everything the agents start may use together (pure): the sandbox's memory minus the headroom
|
|
35
|
+
* ("auto" =
|
|
36
|
+
* the larger of 2048 MB and 10 %), at least half of it so a tiny sandbox still works; null = no limit ("none").
|
|
37
|
+
*/
|
|
38
|
+
export function agentMemoryLimitMb(memoryMb, headroom) {
|
|
39
|
+
if (headroom === 'none')
|
|
40
|
+
return null;
|
|
41
|
+
const keep = headroom === 'auto' ? Math.max(2048, Math.floor(memoryMb / 10)) : headroom;
|
|
42
|
+
return Math.max(Math.floor(memoryMb / 2), memoryMb - keep);
|
|
28
43
|
}
|
|
29
|
-
/**
|
|
30
|
-
export function
|
|
44
|
+
/** A plain-words note when the commit made the sandbox's memory much smaller (2 GB or more) than free RAM allowed. */
|
|
45
|
+
export function memoryNote(decision) {
|
|
46
|
+
if (decision.limitedBy !== 'commit' || decision.withoutCommitMb - decision.mb < 2048)
|
|
47
|
+
return null;
|
|
48
|
+
return ('The sandbox gets ' +
|
|
49
|
+
decision.mb / 1024 +
|
|
50
|
+
' GB of memory instead of ' +
|
|
51
|
+
decision.withoutCommitMb / 1024 +
|
|
52
|
+
' GB: this PC has only ' +
|
|
53
|
+
Math.floor((decision.commitAvailableMb ?? 0) / 1024) +
|
|
54
|
+
' GB of memory (RAM plus paging file) left to hand out, and if it runs out Windows closes the sandbox. ' +
|
|
55
|
+
'A bigger Windows paging file, or closing other programs, gives it more.');
|
|
56
|
+
}
|
|
57
|
+
/** "auto": see decideMemory. commitAvailableMb: from HostTools memory-status (omitted = not checked). */
|
|
58
|
+
export function resolveMemoryMb(sandbox, freeMemoryBytes = os.freemem(), totalMemoryBytes = os.totalmem(), commitAvailableMb = null) {
|
|
31
59
|
if (sandbox.memoryMb !== 'auto')
|
|
32
60
|
return sandbox.memoryMb;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const folders = mappings
|
|
48
|
-
.map((m) => element('MappedFolder', element('HostFolder', xmlEscape(m.host)) +
|
|
49
|
-
element('SandboxFolder', xmlEscape(sandboxFolder(m.guest))) +
|
|
50
|
-
element('ReadOnly', String(m.readOnly))))
|
|
51
|
-
.join('');
|
|
52
|
-
return element('Configuration', element('MemoryInMB', String(memoryMb)) +
|
|
53
|
-
DEVICES.map(([name, setting]) => element(name, toggle(s[setting]))).join('') +
|
|
54
|
-
element('MappedFolders', folders) +
|
|
55
|
-
element('LogonCommand', element('Command', xmlEscape(GUEST.launch + '\\sandbox\\boot\\logon.cmd'))));
|
|
61
|
+
const decision = decideMemory(sandbox, Math.floor(freeMemoryBytes / MB), Math.floor(totalMemoryBytes / MB), commitAvailableMb);
|
|
62
|
+
if (decision.mb < MIN_AUTO_MEMORY_MB)
|
|
63
|
+
fail(decision.limitedBy === 'commit'
|
|
64
|
+
? 'Not enough memory left on this PC for the sandbox (' +
|
|
65
|
+
decision.commitAvailableMb +
|
|
66
|
+
' MB of RAM plus paging file left, ' +
|
|
67
|
+
sandbox.reserveHostMb +
|
|
68
|
+
' MB kept for this PC).'
|
|
69
|
+
: 'Not enough free RAM for the sandbox (' +
|
|
70
|
+
decision.freeMb +
|
|
71
|
+
' MB free, ' +
|
|
72
|
+
sandbox.reserveHostMb +
|
|
73
|
+
' MB kept for this PC).', 'Close some apps, enlarge the Windows paging file, lower sandbox.reserveHostMb, or set sandbox.memoryMb to a fixed value (>= 4096).');
|
|
74
|
+
return decision.mb;
|
|
56
75
|
}
|
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import { type StopCause, type StopEvent } from './stop-events.js';
|
|
2
|
+
/** A crash dump Windows left (name and time only; never read). */
|
|
3
|
+
export interface DumpFile {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly at: string;
|
|
6
|
+
}
|
|
7
|
+
/** Extra evidence for the report (all optional): this PC's own memory log lines and the dumps found. */
|
|
8
|
+
export interface CrashExtra {
|
|
9
|
+
readonly hostMemoryLog?: string;
|
|
10
|
+
readonly dumps?: readonly DumpFile[];
|
|
11
|
+
readonly hostMemoryNow?: string;
|
|
12
|
+
/** The frozen sandbox's launch had vGPU on (read from its .wsb). */
|
|
13
|
+
readonly vgpu?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** "This PC stopped responding at X and was restarted at Y (n minutes later)", or null when there was no long gap. */
|
|
16
|
+
export declare function freezeLine(cause: StopCause, lastSeen: string): string | null;
|
|
17
|
+
/** What each kind of event usually means, one line per kind that appears (pure). */
|
|
18
|
+
export declare function findingLines(events: readonly StopEvent[]): string[];
|
|
19
|
+
/** Crash dumps in these folders newer than `since`: names and times only. */
|
|
20
|
+
export declare function findDumps(dirs: readonly string[], since: Date): DumpFile[];
|
|
21
|
+
/** Whether the newest launch started at or before `lastSeen` had vGPU on (host-only .wsb in <storage>\launches). */
|
|
22
|
+
export declare function launchHadVgpu(storageRoot: string, lastSeen: string): boolean;
|
|
2
23
|
/**
|
|
3
24
|
* The report text (pure): what happened (the sandbox's or this PC's stop code, where the dump is) and the memory log's
|
|
4
25
|
* last lines. `memoryLog` is the sandbox's own file, so it is shown through safeText.
|
|
5
26
|
*/
|
|
6
|
-
export declare function crashReportText(cause: StopCause, events: readonly StopEvent[], memoryLog: string, lastSeen: string): string;
|
|
27
|
+
export declare function crashReportText(cause: StopCause, events: readonly StopEvent[], memoryLog: string, lastSeen: string, extra?: CrashExtra): string;
|
|
28
|
+
/** The newest crash report in <storage>\logs\crashes (at most 64 KB of it), or null. */
|
|
29
|
+
export declare function newestCrashReport(storageRoot: string): {
|
|
30
|
+
file: string;
|
|
31
|
+
text: string;
|
|
32
|
+
} | null;
|
|
7
33
|
/**
|
|
8
34
|
* When the sandbox ended in a crash (its own, this PC's, power, low memory): writes the report and returns its path.
|
|
9
35
|
*/
|