windows-development-sandbox 1.5.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/README.md +1 -0
- package/config.example.json +27 -1
- 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} +4 -0
- package/dist/{cli/menu/settings/categories.js → app/features/settings/categories.def.js} +40 -46
- 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/{cli/menu/settings → app/kernel}/schema-node.d.ts +9 -0
- package/dist/{cli/menu/settings → app/kernel}/schema-node.js +26 -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 +18 -2
- package/dist/cli/args.js +101 -24
- package/dist/cli/commands/accounts.js +45 -17
- package/dist/cli/commands/context.d.ts +2 -0
- package/dist/cli/commands/context.js +9 -2
- package/dist/cli/commands/data/clean.js +32 -9
- package/dist/cli/commands/engine.d.ts +2 -0
- package/dist/cli/commands/engine.js +60 -0
- package/dist/cli/commands/index.d.ts +2 -1
- package/dist/cli/commands/index.js +2 -1
- package/dist/cli/commands/launch/add-root.d.ts +3 -2
- package/dist/cli/commands/launch/add-root.js +11 -10
- package/dist/cli/commands/launch/launch.js +102 -9
- package/dist/cli/commands/launch/prepare.js +6 -4
- package/dist/cli/commands/launch/running.js +2 -1
- package/dist/cli/commands/launch/summary.d.ts +2 -0
- package/dist/cli/commands/maintenance/audit.js +1 -1
- package/dist/cli/commands/maintenance/clean.d.ts +1 -1
- package/dist/cli/commands/maintenance/clean.js +17 -3
- 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.d.ts +1 -1
- package/dist/cli/commands/maintenance/config.js +38 -10
- package/dist/cli/commands/maintenance/doctor.d.ts +1 -1
- package/dist/cli/commands/maintenance/doctor.js +2 -4
- package/dist/cli/commands/maintenance/logs.js +14 -0
- package/dist/cli/commands/maintenance/migrate.d.ts +2 -1
- package/dist/cli/commands/maintenance/migrate.js +19 -4
- package/dist/cli/commands/maintenance/sync.js +2 -0
- package/dist/cli/commands/maintenance/update.d.ts +2 -0
- package/dist/cli/commands/maintenance/update.js +27 -4
- package/dist/cli/commands/projects/here.js +12 -7
- package/dist/cli/commands/projects/projects.js +26 -17
- package/dist/cli/commands/registry.js +10 -7
- package/dist/cli/commands/repair/checks/agents.d.ts +2 -0
- package/dist/cli/commands/repair/checks/agents.js +70 -0
- package/dist/cli/commands/repair/checks/common.d.ts +8 -0
- package/dist/cli/commands/repair/checks/common.js +22 -0
- 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/data.d.ts +2 -0
- package/dist/cli/commands/repair/checks/data.js +241 -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.d.ts +2 -0
- package/dist/cli/commands/repair/checks/index.js +24 -0
- package/dist/cli/commands/repair/checks/install.d.ts +5 -0
- package/dist/cli/commands/repair/checks/install.js +318 -0
- package/dist/cli/commands/repair/checks/machine.d.ts +2 -0
- package/dist/cli/commands/repair/checks/machine.js +232 -0
- package/dist/cli/commands/repair/checks/network.d.ts +6 -0
- package/dist/cli/commands/repair/checks/network.js +60 -0
- package/dist/cli/commands/repair/checks/pc.d.ts +4 -0
- package/dist/cli/commands/repair/checks/pc.js +86 -0
- package/dist/cli/commands/repair/checks/sandbox.d.ts +2 -0
- package/dist/cli/commands/repair/checks/sandbox.js +282 -0
- package/dist/cli/commands/repair/checks/settings.d.ts +2 -0
- package/dist/cli/commands/repair/checks/settings.js +169 -0
- package/dist/cli/commands/repair/checks/vpn.d.ts +2 -0
- package/dist/cli/commands/repair/checks/vpn.js +78 -0
- package/dist/cli/commands/repair/engine.d.ts +32 -0
- package/dist/cli/commands/repair/engine.js +127 -0
- package/dist/cli/commands/repair/env.d.ts +7 -0
- package/dist/cli/commands/repair/env.js +50 -0
- package/dist/cli/commands/repair/index.d.ts +1 -9
- package/dist/cli/commands/repair/index.js +2 -54
- package/dist/cli/commands/repair/log.d.ts +17 -0
- package/dist/cli/commands/repair/log.js +82 -0
- package/dist/cli/commands/repair/printer.d.ts +32 -0
- package/dist/cli/commands/repair/printer.js +132 -0
- package/dist/cli/commands/repair/run.d.ts +33 -0
- package/dist/cli/commands/repair/run.js +133 -0
- package/dist/cli/commands/repair/types.d.ts +97 -9
- package/dist/cli/commands/repair/types.js +11 -7
- package/dist/cli/commands/resume.js +2 -2
- package/dist/cli/commands/sessions/index.d.ts +0 -4
- package/dist/cli/commands/sessions/index.js +3 -7
- package/dist/cli/commands/setup/index.d.ts +5 -0
- package/dist/cli/commands/setup/index.js +25 -1
- 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/index.d.ts +2 -0
- package/dist/cli/commands/storage/index.js +2 -0
- package/dist/cli/commands/storage/offer.d.ts +3 -0
- package/dist/cli/commands/storage/offer.js +91 -0
- package/dist/cli/commands/storage/storage.d.ts +8 -0
- package/dist/cli/commands/storage/storage.js +179 -0
- package/dist/cli/commands/user-config.js +2 -2
- package/dist/cli/commands/vpn.d.ts +4 -0
- package/dist/cli/commands/vpn.js +91 -0
- package/dist/cli/commands/web.d.ts +4 -0
- package/dist/cli/commands/web.js +97 -0
- package/dist/cli/history.js +1 -1
- package/dist/cli/index.js +48 -4
- package/dist/cli/manifest.d.ts +339 -97
- package/dist/cli/manifest.js +222 -67
- package/dist/cli/menu/add-agent.d.ts +47 -0
- package/dist/cli/menu/add-agent.js +168 -0
- package/dist/cli/menu/apps.d.ts +38 -3
- package/dist/cli/menu/apps.js +80 -5
- package/dist/cli/menu/command-fields.d.ts +18 -0
- package/dist/cli/menu/command-fields.js +61 -0
- package/dist/cli/menu/command-form.d.ts +22 -0
- package/dist/cli/menu/command-form.js +169 -46
- package/dist/cli/menu/data-folder.d.ts +18 -0
- package/dist/cli/menu/data-folder.js +99 -0
- 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 +11 -2
- package/dist/cli/menu/menu.js +36 -15
- package/dist/cli/menu/pages/accounts-page.js +55 -24
- package/dist/cli/menu/pages/agents-page.d.ts +68 -0
- package/dist/cli/menu/pages/agents-page.js +345 -0
- package/dist/cli/menu/pages/apps-page.d.ts +3 -1
- package/dist/cli/menu/pages/apps-page.js +20 -4
- package/dist/cli/menu/pages/list-page.d.ts +43 -3
- package/dist/cli/menu/pages/list-page.js +146 -12
- package/dist/cli/menu/pages/maintenance-page.d.ts +9 -5
- package/dist/cli/menu/pages/maintenance-page.js +172 -85
- package/dist/cli/menu/pages/sandbox-page.d.ts +7 -6
- package/dist/cli/menu/pages/sandbox-page.js +117 -120
- package/dist/cli/menu/pages/scopes.d.ts +1 -1
- package/dist/cli/menu/pages/sessions-page.d.ts +6 -8
- package/dist/cli/menu/pages/sessions-page.js +22 -75
- package/dist/cli/menu/pages/settings-page.d.ts +10 -14
- package/dist/cli/menu/pages/settings-page.js +95 -102
- package/dist/cli/menu/render-view.d.ts +28 -0
- package/dist/cli/menu/render-view.js +112 -0
- package/dist/cli/menu/settings/ask-path.d.ts +14 -0
- package/dist/cli/menu/settings/ask-path.js +14 -0
- package/dist/cli/menu/settings/collections/collection-editor.d.ts +8 -2
- package/dist/cli/menu/settings/collections/collection-editor.js +12 -8
- package/dist/cli/menu/settings/collections/map-editor.js +5 -1
- package/dist/cli/menu/settings/collections/object-list-editor.js +2 -2
- package/dist/cli/menu/settings/collections/object-map-editor.js +2 -2
- package/dist/cli/menu/settings/collections/string-list-editor.d.ts +10 -1
- package/dist/cli/menu/settings/collections/string-list-editor.js +23 -0
- 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 +6 -2
- package/dist/cli/menu/settings/object-editor.js +15 -4
- 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 +10 -1
- package/dist/cli/menu/settings/value-editor.js +99 -63
- package/dist/cli/menu/several.js +7 -5
- 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 +53 -10
- package/dist/cli/menu/shell.js +115 -10
- package/dist/cli/menu/views.d.ts +7 -0
- package/dist/cli/menu/views.js +11 -0
- package/dist/cli/menu/vpn-login.d.ts +16 -0
- package/dist/cli/menu/vpn-login.js +74 -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 +5 -1
- package/dist/cli/output/print.js +15 -4
- 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/accounts-service.d.ts +2 -0
- package/dist/cli/services/accounts-service.js +2 -2
- 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/health-service.d.ts +0 -6
- package/dist/cli/services/health-service.js +5 -42
- package/dist/cli/services/index.d.ts +3 -1
- package/dist/cli/services/index.js +3 -1
- package/dist/cli/services/logs-service.js +4 -3
- package/dist/cli/services/migrate-service.js +1 -1
- package/dist/cli/services/update-service.d.ts +2 -0
- package/dist/cli/services/update-service.js +13 -6
- package/dist/cli/services/vpn-service.d.ts +28 -0
- package/dist/cli/services/vpn-service.js +46 -0
- package/dist/cli/services/web-service.d.ts +22 -0
- package/dist/cli/services/web-service.js +111 -0
- package/dist/cli/tui/app.d.ts +12 -4
- package/dist/cli/tui/app.js +38 -9
- package/dist/cli/tui/dialogs/path-listing.d.ts +43 -0
- package/dist/cli/tui/dialogs/path-listing.js +127 -0
- package/dist/cli/tui/dialogs/path-picker.d.ts +67 -0
- package/dist/cli/tui/dialogs/path-picker.js +423 -0
- package/dist/cli/tui/dialogs/text-screen.d.ts +6 -0
- package/dist/cli/tui/dialogs/text-screen.js +10 -3
- package/dist/cli/tui/frame.d.ts +7 -10
- package/dist/cli/tui/frame.js +19 -10
- package/dist/cli/tui/index.d.ts +4 -3
- package/dist/cli/tui/index.js +2 -1
- package/dist/cli/tui/list/list-screen.d.ts +28 -2
- package/dist/cli/tui/list/list-screen.js +130 -66
- package/dist/cli/tui/list/list-types.d.ts +10 -4
- package/dist/cli/tui/nav.d.ts +29 -0
- package/dist/cli/tui/nav.js +67 -0
- package/dist/cli/tui/terminal.d.ts +7 -0
- package/dist/cli/tui/terminal.js +30 -10
- package/dist/cli/validate.d.ts +1 -1
- package/dist/cli/validate.js +3 -3
- package/dist/cli/version.d.ts +2 -0
- package/dist/cli/version.js +11 -0
- package/dist/core/config/defaults.js +13 -1
- package/dist/core/config/loader.js +12 -2
- package/dist/core/local-config/overrides.js +1 -0
- package/dist/core/prompt.d.ts +19 -0
- package/dist/core/prompt.js +43 -3
- package/dist/core/schema/common.d.ts +6 -0
- package/dist/core/schema/common.js +8 -0
- package/dist/core/schema/config.d.ts +36 -0
- package/dist/core/schema/config.js +26 -2
- package/dist/core/schema/harness.d.ts +2 -0
- package/dist/core/schema/harness.js +13 -2
- package/dist/core/schema/index.d.ts +3 -1
- package/dist/core/schema/index.js +3 -1
- package/dist/core/schema/profile.d.ts +1 -0
- package/dist/core/schema/profile.js +3 -0
- package/dist/core/schema/redact.d.ts +13 -0
- package/dist/core/schema/redact.js +75 -0
- package/dist/core/schema/sandbox.d.ts +6 -0
- package/dist/core/schema/sandbox.js +21 -3
- package/dist/core/schema/vpn.d.ts +18 -0
- package/dist/core/schema/vpn.js +22 -0
- package/dist/core/schema/web.d.ts +6 -0
- package/dist/core/schema/web.js +14 -0
- package/dist/core/types.d.ts +44 -0
- 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 +54 -0
- package/dist/guest/agents/agent-files.js +67 -0
- package/dist/guest/agents/agent-installer.js +2 -9
- package/dist/guest/agents/local-state.d.ts +14 -0
- package/dist/guest/agents/local-state.js +218 -0
- package/dist/guest/agents/sbx-agent.d.ts +2 -0
- package/dist/guest/agents/sbx-agent.js +35 -0
- package/dist/guest/boot/boot.d.ts +4 -0
- package/dist/guest/boot/boot.js +51 -11
- package/dist/guest/daemon/daemon.js +8 -1
- package/dist/guest/daemon/exec.js +2 -1
- package/dist/guest/daemon/idle-shutdown.js +2 -0
- package/dist/guest/daemon/sessions.d.ts +5 -0
- package/dist/guest/daemon/sessions.js +20 -3
- package/dist/guest/entries/agent.d.ts +1 -0
- package/dist/guest/entries/agent.js +10 -0
- package/dist/guest/entries/daemon.js +5 -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 +2 -0
- package/dist/guest/runtime/csc.js +2 -0
- package/dist/guest/runtime/secrets.d.ts +12 -0
- package/dist/guest/runtime/secrets.js +63 -0
- package/dist/guest/sessions/viewer.js +3 -1
- package/dist/guest/setup/claude-profile.d.ts +2 -1
- package/dist/guest/setup/claude-profile.js +12 -1
- package/dist/guest/setup/environment.d.ts +6 -0
- package/dist/guest/setup/environment.js +56 -6
- package/dist/guest/setup/path-plan.d.ts +32 -0
- package/dist/guest/setup/path-plan.js +67 -0
- package/dist/guest/setup/shell-path.d.ts +1 -0
- package/dist/guest/setup/shell-path.js +22 -0
- package/dist/guest/toolchains/languages/python.js +1 -1
- package/dist/guest/toolchains/native/rust-extras.js +4 -2
- package/dist/guest/toolchains/runtimes.js +2 -2
- package/dist/guest/vpn/index.d.ts +1 -0
- package/dist/guest/vpn/index.js +1 -0
- package/dist/guest/vpn/openvpn.d.ts +9 -0
- package/dist/guest/vpn/openvpn.js +47 -0
- package/dist/guest/vpn/tunnel.d.ts +17 -0
- package/dist/guest/vpn/tunnel.js +78 -0
- package/dist/guest/vpn/vpn.d.ts +6 -0
- package/dist/guest/vpn/vpn.js +174 -0
- 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 +6 -2
- package/dist/host/channel/attach.js +6 -3
- package/dist/host/channel/channel.d.ts +9 -0
- package/dist/host/channel/channel.js +30 -2
- 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/health/acl-read.d.ts +17 -0
- package/dist/host/health/acl-read.js +45 -0
- package/dist/host/health/config-backup.d.ts +11 -0
- package/dist/host/health/config-backup.js +73 -0
- package/dist/host/health/index.d.ts +6 -0
- package/dist/host/health/index.js +7 -0
- package/dist/host/health/install-state.d.ts +33 -0
- package/dist/host/health/install-state.js +110 -0
- package/dist/host/health/path-copies.d.ts +32 -0
- package/dist/host/health/path-copies.js +82 -0
- package/dist/host/health/stale.d.ts +45 -0
- package/dist/host/health/stale.js +120 -0
- package/dist/host/health/system.d.ts +37 -0
- package/dist/host/health/system.js +87 -0
- package/dist/host/install/copies.d.ts +13 -0
- package/dist/host/install/copies.js +63 -0
- package/dist/host/install/index.d.ts +1 -0
- package/dist/host/install/index.js +1 -0
- package/dist/host/launch/generate.d.ts +5 -1
- package/dist/host/launch/generate.js +73 -7
- 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 +11 -2
- package/dist/host/launch/stage.js +1 -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/migrate/backup.js +3 -0
- package/dist/host/migrate/migrations/config-file.d.ts +2 -0
- package/dist/host/migrate/migrations/config-file.js +7 -0
- package/dist/host/migrate/migrations/follow-machine-storage.js +9 -1
- package/dist/host/migrate/migrations/pin-storage-root.d.ts +4 -0
- package/dist/host/migrate/migrations/pin-storage-root.js +46 -0
- package/dist/host/migrate/migrations/unpin-config-defaults.js +4 -1
- package/dist/host/migrate/registry.js +2 -1
- package/dist/host/native.d.ts +3 -2
- package/dist/host/native.js +22 -3
- package/dist/host/profile/accounts.d.ts +25 -1
- package/dist/host/profile/accounts.js +96 -13
- package/dist/host/profile/agent-accounts.d.ts +5 -1
- package/dist/host/profile/agent-accounts.js +35 -5
- package/dist/host/profile/claude-login.js +3 -2
- package/dist/host/profile/index.d.ts +2 -1
- package/dist/host/profile/index.js +1 -0
- package/dist/host/profile/plugin-share.d.ts +26 -0
- package/dist/host/profile/plugin-share.js +146 -0
- package/dist/host/projects/join.d.ts +7 -1
- package/dist/host/projects/join.js +21 -4
- package/dist/host/projects/registry.d.ts +16 -10
- package/dist/host/projects/registry.js +74 -6
- 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 +4 -0
- package/dist/host/sandbox/platform.js +23 -4
- package/dist/host/sandbox/tasklist.d.ts +13 -0
- package/dist/host/sandbox/tasklist.js +47 -0
- package/dist/host/secrets/index.d.ts +2 -0
- package/dist/host/secrets/index.js +2 -0
- package/dist/host/secrets/launch-secrets.d.ts +17 -0
- package/dist/host/secrets/launch-secrets.js +94 -0
- package/dist/host/secrets/secret-store.d.ts +25 -0
- package/dist/host/secrets/secret-store.js +89 -0
- package/dist/host/sharing/acl.d.ts +16 -2
- package/dist/host/sharing/acl.js +35 -10
- package/dist/host/sharing/current.js +8 -3
- package/dist/host/sharing/doctor.d.ts +2 -0
- package/dist/host/sharing/doctor.js +44 -0
- package/dist/host/sharing/group-access.d.ts +6 -0
- package/dist/host/sharing/group-access.js +24 -0
- package/dist/host/sharing/index.d.ts +2 -1
- package/dist/host/sharing/index.js +2 -1
- package/dist/host/sharing/lifecycle.d.ts +8 -2
- package/dist/host/sharing/lifecycle.js +16 -7
- package/dist/host/storage/cleanup.d.ts +2 -0
- package/dist/host/storage/cleanup.js +2 -1
- 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/history.d.ts +21 -0
- package/dist/host/storage/history.js +49 -0
- package/dist/host/storage/index.d.ts +6 -0
- package/dist/host/storage/index.js +6 -0
- package/dist/host/storage/move.d.ts +95 -0
- package/dist/host/storage/move.js +384 -0
- package/dist/host/storage/offer.d.ts +11 -0
- package/dist/host/storage/offer.js +36 -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/storage/root.d.ts +18 -0
- package/dist/host/storage/root.js +77 -0
- package/dist/host/tools/conpty.js +3 -2
- package/dist/host/tools/windows-terminal.d.ts +2 -0
- package/dist/host/tools/windows-terminal.js +31 -12
- package/dist/host/update/index.d.ts +1 -1
- package/dist/host/update/index.js +1 -1
- package/dist/host/update/notice.d.ts +2 -0
- package/dist/host/update/notice.js +13 -1
- package/dist/host/update/update-state.d.ts +6 -0
- package/dist/host/update/update-state.js +2 -0
- package/dist/host/update/updater.d.ts +19 -0
- package/dist/host/update/updater.js +88 -12
- package/dist/host/vpn/index.d.ts +4 -0
- package/dist/host/vpn/index.js +4 -0
- package/dist/host/vpn/login.d.ts +24 -0
- package/dist/host/vpn/login.js +79 -0
- package/dist/host/vpn/nordvpn.d.ts +21 -0
- package/dist/host/vpn/nordvpn.js +77 -0
- package/dist/host/vpn/prepare.d.ts +19 -0
- package/dist/host/vpn/prepare.js +138 -0
- package/dist/host/vpn/status.d.ts +12 -0
- package/dist/host/vpn/status.js +53 -0
- package/dist/host/web/auth.d.ts +38 -0
- package/dist/host/web/auth.js +96 -0
- package/dist/host/web/backend.d.ts +14 -0
- package/dist/host/web/backend.js +1 -0
- package/dist/host/web/bridge.d.ts +27 -0
- package/dist/host/web/bridge.js +144 -0
- package/dist/host/web/browser.d.ts +3 -0
- package/dist/host/web/browser.js +23 -0
- package/dist/host/web/control.d.ts +17 -0
- package/dist/host/web/control.js +67 -0
- package/dist/host/web/index.d.ts +10 -0
- package/dist/host/web/index.js +9 -0
- package/dist/host/web/rpc.d.ts +24 -0
- package/dist/host/web/rpc.js +149 -0
- package/dist/host/web/runner.d.ts +16 -0
- package/dist/host/web/runner.js +44 -0
- package/dist/host/web/server.d.ts +47 -0
- package/dist/host/web/server.js +238 -0
- package/dist/host/web/state.d.ts +20 -0
- package/dist/host/web/state.js +41 -0
- package/dist/host/web/static-files.d.ts +13 -0
- package/dist/host/web/static-files.js +57 -0
- package/dist/runtime/agent.js +27675 -0
- package/dist/runtime/daemon.js +1950 -1122
- package/dist/runtime/db.js +302 -111
- package/dist/runtime/main.js +1560 -275
- package/dist/runtime/netproxy.js +168 -8
- package/dist/runtime/view.js +186 -13
- package/dist/selftest/accounts.test.js +40 -0
- package/dist/selftest/agent-paths.test.d.ts +2 -0
- package/dist/selftest/agent-paths.test.js +125 -0
- package/dist/selftest/app.test.d.ts +2 -0
- package/dist/selftest/app.test.js +324 -0
- package/dist/selftest/channel.test.js +18 -0
- package/dist/selftest/cli.test.js +35 -4
- 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.d.ts +2 -0
- package/dist/selftest/credentials.test.js +198 -0
- package/dist/selftest/engine.test.d.ts +2 -0
- package/dist/selftest/engine.test.js +127 -0
- package/dist/selftest/generate.test.js +1 -1
- package/dist/selftest/hcs.test.d.ts +2 -0
- package/dist/selftest/hcs.test.js +482 -0
- package/dist/selftest/health.test.d.ts +2 -0
- package/dist/selftest/health.test.js +470 -0
- package/dist/selftest/heavy-load.test.d.ts +2 -0
- package/dist/selftest/heavy-load.test.js +329 -0
- package/dist/selftest/host-sim.test.js +2 -0
- package/dist/selftest/index.js +31 -0
- package/dist/selftest/layout.test.js +14 -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.d.ts +7 -0
- package/dist/selftest/menu-screens.js +68 -17
- package/dist/selftest/menu.test.js +603 -22
- package/dist/selftest/migrate.test.js +1 -1
- package/dist/selftest/personalization.test.js +3 -1
- package/dist/selftest/projects.test.js +39 -1
- package/dist/selftest/shared-use.test.js +64 -2
- package/dist/selftest/sharing.test.js +50 -1
- package/dist/selftest/storage.test.d.ts +2 -0
- package/dist/selftest/storage.test.js +363 -0
- 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 +20 -0
- package/dist/selftest/support/hcs-probes.d.ts +17 -0
- package/dist/selftest/support/hcs-probes.js +41 -0
- package/dist/selftest/support/releases.js +1 -1
- package/dist/selftest/toolchains.test.js +21 -0
- package/dist/selftest/update-service.test.js +87 -3
- package/dist/selftest/vpn.test.d.ts +2 -0
- package/dist/selftest/vpn.test.js +412 -0
- package/dist/selftest/web.test.d.ts +2 -0
- package/dist/selftest/web.test.js +402 -0
- package/dist/shared/apps/catalogue.js +31 -0
- package/dist/shared/channel/index.d.ts +1 -0
- package/dist/shared/channel/index.js +1 -0
- package/dist/shared/channel/run-dir.d.ts +9 -1
- package/dist/shared/channel/run-dir.js +18 -1
- package/dist/shared/channel/schema.d.ts +53 -0
- package/dist/shared/channel/schema.js +38 -0
- package/dist/shared/channel/secrets.d.ts +29 -0
- package/dist/shared/channel/secrets.js +50 -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 +29 -0
- package/dist/shared/vpn/download.js +30 -0
- package/dist/shared/vpn/kill-switch.d.ts +18 -0
- package/dist/shared/vpn/kill-switch.js +81 -0
- package/dist/shared/vpn/ovpn.d.ts +23 -0
- package/dist/shared/vpn/ovpn.js +244 -0
- package/dist/shared/vpn/wireguard.d.ts +51 -0
- package/dist/shared/vpn/wireguard.js +227 -0
- package/dist/shared/web/index.d.ts +1 -0
- package/dist/shared/web/index.js +1 -0
- package/dist/shared/web/protocol.d.ts +61 -0
- package/dist/shared/web/protocol.js +35 -0
- package/dist/sync/sync-cycle.js +9 -5
- package/dist/sync/sync-state.d.ts +1 -0
- package/dist/sync/sync-state.js +1 -0
- package/dist/sync/watcher.d.ts +13 -0
- package/dist/sync/watcher.js +102 -3
- package/dist/web/index.html +14 -0
- package/dist/web/main-NRRS5O6Z.js +157 -0
- package/dist/web/main-T5DMCHYV.css +1 -0
- package/native/csharp/FolderSecurity.cs +29 -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/protect-data.ps1 +29 -0
- package/native/scripts/read-folder-sddl.ps1 +10 -0
- package/native/scripts/run-elevated.ps1 +17 -4
- package/native/scripts/set-folder-access.ps1 +49 -7
- package/native/scripts/stop-events.ps1 +23 -8
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +607 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1421 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +22 -5
- package/sandbox/csharp/EnvBroadcast.cs +33 -0
- package/sandbox/csharp/MemGov.cs +398 -0
- package/sandbox/csharp/PathSync.cs +90 -0
- package/sandbox/csharp/PtyHost.cs +111 -5
- package/sandbox/scripts/install-shell-path.ps1 +73 -0
- package/sandbox/scripts/set-machine-environment.ps1 +37 -4
- package/schemas/config.schema.json +136 -7
- package/schemas/sandbox-config.schema.json +17 -4
- package/dist/cli/commands/repair/checks.d.ts +0 -2
- package/dist/cli/commands/repair/checks.js +0 -246
- 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 -45
- package/dist/cli/commands/sessions/status.d.ts +0 -2
- package/dist/cli/commands/sessions/status.js +0 -93
- package/dist/cli/commands/sessions/window.d.ts +0 -3
- package/dist/cli/commands/sessions/window.js +0 -18
- package/dist/cli/menu/pages/start-page.d.ts +0 -43
- package/dist/cli/menu/pages/start-page.js +0 -192
- package/dist/cli/tui/tab-bar.d.ts +0 -9
- package/dist/cli/tui/tab-bar.js +0 -33
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The web UI settings (sandbox web): not part of LocalOverrides, a repo never turns a way into your agents on.
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const WEB_DEFAULT_PORT = 47800;
|
|
4
|
+
export const WebSchema = z.strictObject({
|
|
5
|
+
enabled: z
|
|
6
|
+
.boolean()
|
|
7
|
+
.describe('(Beta) Allow the web UI: your sandbox sessions in a browser on this PC. Off by default, and nothing starts it by itself yet: sandbox web start works either way and runs it until sandbox web stop (or a restart of the PC).'),
|
|
8
|
+
port: z
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.min(1024)
|
|
12
|
+
.max(65535)
|
|
13
|
+
.describe('Port of the web UI on 127.0.0.1 (this PC only). Pick another when it is taken.'),
|
|
14
|
+
});
|
package/dist/core/types.d.ts
CHANGED
|
@@ -102,6 +102,19 @@ export interface DatabasePlan {
|
|
|
102
102
|
port: number;
|
|
103
103
|
adminPort?: number;
|
|
104
104
|
}
|
|
105
|
+
/** The VPN decided at launch (host/vpn/prepare.ts): its checked profile, and the login for the one-shot file. */
|
|
106
|
+
export interface PreparedVpn {
|
|
107
|
+
session: GuestVpn;
|
|
108
|
+
/** openvpn: the profile text, already checked (goes in the launch folder). */
|
|
109
|
+
profile?: string;
|
|
110
|
+
/** openvpn: the login (one-shot file). */
|
|
111
|
+
credentials?: {
|
|
112
|
+
username: string;
|
|
113
|
+
password: string;
|
|
114
|
+
};
|
|
115
|
+
/** wireguard-file: the checked config; holds the private key (one-shot file only). */
|
|
116
|
+
wireguardConfig?: string;
|
|
117
|
+
}
|
|
105
118
|
/** databases / pcLanguages: use these instead of scanning (tests). */
|
|
106
119
|
export interface GenerateOptions {
|
|
107
120
|
packageRoot: string;
|
|
@@ -109,6 +122,8 @@ export interface GenerateOptions {
|
|
|
109
122
|
harnessArgs: string[];
|
|
110
123
|
probe: HostProbe;
|
|
111
124
|
freeMemoryBytes?: number;
|
|
125
|
+
/** This PC's unused commit (RAM plus paging file) in MB from HostTools memory-status; omitted = not checked. */
|
|
126
|
+
commitAvailableMb?: number | null;
|
|
112
127
|
databases?: DatabasePlan[];
|
|
113
128
|
pcLanguages?: AutoToolchain[];
|
|
114
129
|
/**
|
|
@@ -124,6 +139,10 @@ export interface GenerateOptions {
|
|
|
124
139
|
projects: BootWant[];
|
|
125
140
|
keepOff: string[];
|
|
126
141
|
};
|
|
142
|
+
/** The VPN for this launch (vpn.enabled); its profile goes in the launch folder, its login in the one-shot file. */
|
|
143
|
+
vpn?: PreparedVpn;
|
|
144
|
+
/** The data set's mappings from a storage provider (contained storage); else the data folder is one mapping. */
|
|
145
|
+
dataMappings?: ResolvedMapping[];
|
|
127
146
|
}
|
|
128
147
|
export interface Generated {
|
|
129
148
|
wsbPath: string;
|
|
@@ -131,6 +150,8 @@ export interface Generated {
|
|
|
131
150
|
launchId: string;
|
|
132
151
|
sessionPath: string;
|
|
133
152
|
memoryMb: number;
|
|
153
|
+
/** Plain words when the PC's commit made the memory much smaller than free RAM allowed. */
|
|
154
|
+
memoryNote: string | null;
|
|
134
155
|
/** The config the sandbox boots with: the launch folder's plus what the other projects mapped at boot want. */
|
|
135
156
|
bootConfig: Config;
|
|
136
157
|
/** Boot settings turned on for another project (setting -> project). */
|
|
@@ -162,6 +183,16 @@ export interface ProfileResult {
|
|
|
162
183
|
credentials: boolean;
|
|
163
184
|
secretsRemoved: string[];
|
|
164
185
|
}
|
|
186
|
+
/** The VPN of one launch: what the guest needs besides the login (which comes in the one-shot secrets file). */
|
|
187
|
+
export interface GuestVpn {
|
|
188
|
+
provider: Config['vpn']['provider'];
|
|
189
|
+
protocol: Config['vpn']['protocol'];
|
|
190
|
+
killSwitch: boolean;
|
|
191
|
+
/** The server's name, for messages. */
|
|
192
|
+
server: string;
|
|
193
|
+
/** openvpn: the checked profile, relative to the launch folder (none for wireguard-file: its config is a secret). */
|
|
194
|
+
profile?: string;
|
|
195
|
+
}
|
|
165
196
|
/** Written by the host to C:\AgentLaunch\session.json (read-only for the guest): everything the guest needs to know. */
|
|
166
197
|
export interface GuestSession {
|
|
167
198
|
launchId: string;
|
|
@@ -196,6 +227,8 @@ export interface GuestSession {
|
|
|
196
227
|
attach: Config['attach'];
|
|
197
228
|
hooks: Config['hooks'];
|
|
198
229
|
downloads: Config['downloads'];
|
|
230
|
+
/** Set when the VPN is on for this launch (older launch folders lack it). */
|
|
231
|
+
vpn?: GuestVpn;
|
|
199
232
|
/** nodeVersion: this PC's Node (e.g. 22.11.0), found under nvm\v<version> when nvm is mapped, else under node. */
|
|
200
233
|
/** volta / pyenv: this PC uses them (their "auto" settings turn them on in the sandbox too). */
|
|
201
234
|
hostTools: {
|
|
@@ -229,6 +262,15 @@ export interface GuestSession {
|
|
|
229
262
|
cpuLimitPercent?: number | null;
|
|
230
263
|
/** sandbox.pageFileMb (0 = Windows' own); sandbox\scripts\set-page-file.ps1 applies it at logon. */
|
|
231
264
|
pageFileMb?: number;
|
|
265
|
+
/**
|
|
266
|
+
* sandbox.agentMemoryHeadroomMb as a limit: the most memory (MB) everything the agents start may use together
|
|
267
|
+
* (the sandbox's memory minus the headroom); null = no limit. ptyhost puts each agent in a job object with it.
|
|
268
|
+
*/
|
|
269
|
+
agentMemoryLimitMb?: number | null;
|
|
270
|
+
/** "gentle" when vGPU is on: the governor and the watchdog act earlier, compilers run below normal. */
|
|
271
|
+
loadProfile?: 'normal' | 'gentle';
|
|
272
|
+
/** sandbox.pressureResponse: the daemon slows builds down when memory runs low. */
|
|
273
|
+
pressureResponse?: boolean;
|
|
232
274
|
/** Apps to install (catalogue ids and your own programs); missing in launch folders of older versions. */
|
|
233
275
|
apps?: Config['apps'];
|
|
234
276
|
/** audit.enabled and audit.processes: the sandbox reports the programs it starts (host keeps the log). */
|
|
@@ -237,4 +279,6 @@ export interface GuestSession {
|
|
|
237
279
|
agentHomes?: Record<string, string>;
|
|
238
280
|
/** Per agent: folders of the user profile (.qwen ...) linked into the persistent state at boot. */
|
|
239
281
|
agentProfileDirs?: Record<string, string[]>;
|
|
282
|
+
/** Every configured agent (without its environment): a terminal command each; older launch folders lack it. */
|
|
283
|
+
agents?: Record<string, Harness>;
|
|
240
284
|
}
|
package/dist/core/util/fs.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function ensureDir(p: string): void;
|
|
2
2
|
export declare function dirExists(p: string): boolean;
|
|
3
3
|
export declare function fileExists(p: string): boolean;
|
|
4
|
+
/** fileExists without blocking the program (the menu looks for programs while it stays responsive). */
|
|
5
|
+
export declare function fileExistsAsync(p: string): Promise<boolean>;
|
|
4
6
|
export declare function readJson<T>(p: string): T;
|
|
5
7
|
export declare function tryReadJson<T>(p: string): T | null;
|
|
6
8
|
/** Atomic (a crash or a second command never leaves half a file); refused outside temp during the self-test. */
|
package/dist/core/util/fs.js
CHANGED
|
@@ -19,6 +19,15 @@ export function fileExists(p) {
|
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
/** fileExists without blocking the program (the menu looks for programs while it stays responsive). */
|
|
23
|
+
export async function fileExistsAsync(p) {
|
|
24
|
+
try {
|
|
25
|
+
return (await fs.promises.stat(p)).isFile();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
22
31
|
export function readJson(p) {
|
|
23
32
|
return JSON.parse(fs.readFileSync(p, 'utf8').replace(/^\uFEFF/, ''));
|
|
24
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { isWin, sleep, captureOutput } from './process.js';
|
|
2
2
|
export { UserError, fail, errMsg } from './errors.js';
|
|
3
3
|
export { parseJsonc, readJsonc } from './jsonc.js';
|
|
4
|
-
export { ensureDir, dirExists, fileExists, readJson, tryReadJson, writeJson, realPath } from './fs.js';
|
|
4
|
+
export { ensureDir, dirExists, fileExists, fileExistsAsync, readJson, tryReadJson, writeJson, realPath } from './fs.js';
|
|
5
5
|
export { xmlEscape, safeText, plainText } from './text.js';
|
|
6
6
|
export { homeDir, expandPath, expandVariables, isRootPath, isUserProfile, isInsideOrEqual, findOnPath, } from './paths.js';
|
|
7
7
|
export { isLink, removeLink, assertNoLinks } from './links.js';
|
package/dist/core/util/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { isWin, sleep, captureOutput } from './process.js';
|
|
2
2
|
export { UserError, fail, errMsg } from './errors.js';
|
|
3
3
|
export { parseJsonc, readJsonc } from './jsonc.js';
|
|
4
|
-
export { ensureDir, dirExists, fileExists, readJson, tryReadJson, writeJson, realPath } from './fs.js';
|
|
4
|
+
export { ensureDir, dirExists, fileExists, fileExistsAsync, readJson, tryReadJson, writeJson, realPath } from './fs.js';
|
|
5
5
|
export { xmlEscape, safeText, plainText } from './text.js';
|
|
6
6
|
export { homeDir, expandPath, expandVariables, isRootPath, isUserProfile, isInsideOrEqual, findOnPath, } from './paths.js';
|
|
7
7
|
export { isLink, removeLink, assertNoLinks } from './links.js';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Harness } from '../../core/types.js';
|
|
2
|
+
/** Where an agent lives in persistent storage: its folder, and the program (an .exe, or an npm .cmd) in it. */
|
|
3
|
+
export interface AgentPaths {
|
|
4
|
+
readonly dir: string;
|
|
5
|
+
readonly exe: string | null;
|
|
6
|
+
readonly cmd: string | null;
|
|
7
|
+
}
|
|
8
|
+
export declare function agentPaths(toolsDir: string, name: string, harness: Harness): AgentPaths;
|
|
9
|
+
/** The word a user types for this agent (`claude`, `codex` ...). */
|
|
10
|
+
export declare function agentCommand(name: string, harness: Harness): string;
|
|
11
|
+
/** What a terminal needs to run the agent by name: the command, and the program it runs once installed. */
|
|
12
|
+
export interface AgentShim {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly command: string;
|
|
15
|
+
readonly target: string;
|
|
16
|
+
}
|
|
17
|
+
/** One shim per configured agent that can be installed here (a name that is not a plain command word is skipped). */
|
|
18
|
+
export declare function agentShims(toolsDir: string, agents: Readonly<Record<string, Harness>>): AgentShim[];
|
|
19
|
+
/**
|
|
20
|
+
* The text of `<command>.cmd`: runs the installed agent, or installs it first (`install` = node + installer script).
|
|
21
|
+
* The agent's own arguments pass through %* untouched.
|
|
22
|
+
*/
|
|
23
|
+
export declare function shimText(shim: AgentShim, install: {
|
|
24
|
+
node: string;
|
|
25
|
+
script: string;
|
|
26
|
+
}): string;
|
|
27
|
+
/** The `sbx-agent` command: `sbx-agent install <agent>` / `sbx-agent list`. */
|
|
28
|
+
export declare function sbxAgentText(install: {
|
|
29
|
+
node: string;
|
|
30
|
+
script: string;
|
|
31
|
+
}): string;
|
|
32
|
+
/** A SQLite folder an agent runs from the sandbox's disk: the variable that points to `local`, and its saved copy. */
|
|
33
|
+
export interface LocalState {
|
|
34
|
+
readonly agent: string;
|
|
35
|
+
readonly env: string;
|
|
36
|
+
/** The saved copy in persistent storage (state\<agent>\<folder>). */
|
|
37
|
+
readonly store: string;
|
|
38
|
+
/** The working copy on the sandbox's own disk. */
|
|
39
|
+
readonly local: string;
|
|
40
|
+
/** Image names of the programs that hold the databases open while they run. */
|
|
41
|
+
readonly processes: readonly string[];
|
|
42
|
+
/** Where the agent kept the databases before this existed (its state folder itself). */
|
|
43
|
+
readonly legacy: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function localStateEntries(agents: Readonly<Record<string, Harness>>, stateDir: string, localRoot: string): LocalState[];
|
|
46
|
+
/** Every agent's bootReset paths, absolute below its state folder (the schema allows only plain relative paths). */
|
|
47
|
+
export declare function bootResetPaths(agents: Readonly<Record<string, Harness>>, stateDir: string): {
|
|
48
|
+
agent: string;
|
|
49
|
+
path: string;
|
|
50
|
+
}[];
|
|
51
|
+
/** A SQLite database file or one of its -wal / -shm siblings. */
|
|
52
|
+
export declare const isDatabaseFile: (name: string) => boolean;
|
|
53
|
+
/** Files that make a consistent copy: the databases and their -wal (the -shm is rebuilt by SQLite). */
|
|
54
|
+
export declare const isCopyableDatabaseFile: (name: string) => boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Pure parts of the agents' files: where an agent is installed, the command that starts it in a terminal tab, and the
|
|
2
|
+
// SQLite folders it runs from the sandbox's own disk. No side effects: the self-test imports this file.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export function agentPaths(toolsDir, name, harness) {
|
|
5
|
+
const dir = path.join(toolsDir, 'agents', name);
|
|
6
|
+
const exe = harness.hostExecutable ?? (harness.uvBin ? harness.uvBin + '.exe' : null);
|
|
7
|
+
return {
|
|
8
|
+
dir,
|
|
9
|
+
exe: exe ? path.join(dir, exe) : null,
|
|
10
|
+
cmd: harness.npmBin ? path.join(dir, harness.npmBin + '.cmd') : null,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** The word a user types for this agent (`claude`, `codex` ...). */
|
|
14
|
+
export function agentCommand(name, harness) {
|
|
15
|
+
return harness.npmBin ?? harness.uvBin ?? (harness.hostExecutable ?? name).replace(/\.exe$/i, '');
|
|
16
|
+
}
|
|
17
|
+
/** One shim per configured agent that can be installed here (a name that is not a plain command word is skipped). */
|
|
18
|
+
export function agentShims(toolsDir, agents) {
|
|
19
|
+
return Object.entries(agents).flatMap(([name, harness]) => {
|
|
20
|
+
const p = agentPaths(toolsDir, name, harness);
|
|
21
|
+
const target = p.exe ?? p.cmd;
|
|
22
|
+
const command = agentCommand(name, harness);
|
|
23
|
+
return target && /^[A-Za-z0-9_-]+$/.test(command) && /^[A-Za-z0-9_-]+$/.test(name)
|
|
24
|
+
? [{ name, command, target }]
|
|
25
|
+
: [];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The text of `<command>.cmd`: runs the installed agent, or installs it first (`install` = node + installer script).
|
|
30
|
+
* The agent's own arguments pass through %* untouched.
|
|
31
|
+
*/
|
|
32
|
+
export function shimText(shim, install) {
|
|
33
|
+
return [
|
|
34
|
+
'@echo off',
|
|
35
|
+
'setlocal',
|
|
36
|
+
'set "SBX_REAL=' + shim.target + '"',
|
|
37
|
+
'if exist "%SBX_REAL%" goto run',
|
|
38
|
+
'echo ' + shim.command + ' is not installed in this sandbox yet. Installing it now (one time)...',
|
|
39
|
+
'"' + install.node + '" "' + install.script + '" install ' + shim.name,
|
|
40
|
+
'if errorlevel 1 exit /b 1',
|
|
41
|
+
':run',
|
|
42
|
+
'endlocal & "%SBX_REAL%" %*',
|
|
43
|
+
'',
|
|
44
|
+
].join('\r\n');
|
|
45
|
+
}
|
|
46
|
+
/** The `sbx-agent` command: `sbx-agent install <agent>` / `sbx-agent list`. */
|
|
47
|
+
export function sbxAgentText(install) {
|
|
48
|
+
return '@"' + install.node + '" "' + install.script + '" %*\r\n';
|
|
49
|
+
}
|
|
50
|
+
export function localStateEntries(agents, stateDir, localRoot) {
|
|
51
|
+
return Object.entries(agents).flatMap(([agent, harness]) => Object.entries(harness.localState ?? {}).map(([env, folder]) => ({
|
|
52
|
+
agent,
|
|
53
|
+
env,
|
|
54
|
+
store: path.join(stateDir, agent, folder),
|
|
55
|
+
local: path.join(localRoot, agent, folder),
|
|
56
|
+
processes: [agentCommand(agent, harness) + '.exe'],
|
|
57
|
+
legacy: path.join(stateDir, agent),
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
/** Every agent's bootReset paths, absolute below its state folder (the schema allows only plain relative paths). */
|
|
61
|
+
export function bootResetPaths(agents, stateDir) {
|
|
62
|
+
return Object.entries(agents).flatMap(([agent, harness]) => (harness.bootReset ?? []).map((rel) => ({ agent, path: path.join(stateDir, agent, rel) })));
|
|
63
|
+
}
|
|
64
|
+
/** A SQLite database file or one of its -wal / -shm siblings. */
|
|
65
|
+
export const isDatabaseFile = (name) => /\.(sqlite3?|db)(-wal|-shm)?$/i.test(name);
|
|
66
|
+
/** Files that make a consistent copy: the databases and their -wal (the -shm is rebuilt by SQLite). */
|
|
67
|
+
export const isCopyableDatabaseFile = (name) => isDatabaseFile(name) && !/-shm$/i.test(name);
|
|
@@ -11,16 +11,9 @@ import { exists, mkdirp } from '../runtime/fs.js';
|
|
|
11
11
|
import { log, warn } from '../runtime/log.js';
|
|
12
12
|
import { session } from '../runtime/session.js';
|
|
13
13
|
import { addMachineEnvironment } from '../setup/environment.js';
|
|
14
|
+
import { agentPaths as paths } from './agent-files.js';
|
|
14
15
|
import { linkHarnessProfile } from './profile-links.js';
|
|
15
|
-
|
|
16
|
-
const dir = path.join(toolsDir, 'agents', name);
|
|
17
|
-
const exe = harness.hostExecutable ?? (harness.uvBin ? harness.uvBin + '.exe' : null);
|
|
18
|
-
return {
|
|
19
|
-
dir,
|
|
20
|
-
exe: exe ? path.join(dir, exe) : null,
|
|
21
|
-
cmd: harness.npmBin ? path.join(dir, harness.npmBin + '.cmd') : null,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
16
|
+
const agentPaths = (name, harness) => paths(toolsDir, name, harness);
|
|
24
17
|
/** npm install with the runner's own npm into tools\agents\<name> (no global state outside persistent storage). */
|
|
25
18
|
async function installViaNpm(name, harness, dir, env) {
|
|
26
19
|
if (!harness.npmPackage)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type LocalState } from './agent-files.js';
|
|
2
|
+
/** Every SQLite folder of every configured agent (none in launch folders that predate the agents list). */
|
|
3
|
+
export declare function agentLocalStates(): LocalState[];
|
|
4
|
+
/** Variable -> working folder, for the agent environment (and the machine environment of new terminal tabs). */
|
|
5
|
+
export declare function localStateVars(): Record<string, string>;
|
|
6
|
+
/** Boot: what an agent sealed to the last sandbox (bootReset) is deleted, so it sets it up again. Links are left. */
|
|
7
|
+
export declare function resetMachineBound(): void;
|
|
8
|
+
/** Boot: the saved databases of every configured agent are copied to the sandbox's disk, where the agent runs them. */
|
|
9
|
+
export declare function restoreLocalState(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Copies the working databases back to persistent storage (staging folder + swap). While the agent runs they are
|
|
12
|
+
* snapshotted with SQLite's online backup instead (see snapshotWhileRunning); nothing is done when nothing changed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function saveLocalState(): void;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// Agents that keep SQLite databases (codex ...): SQLite cannot map its shared memory in a mapped folder (error 8714,
|
|
2
|
+
// "disk I/O error"), so they run from a copy on the sandbox's own disk. The copy comes from persistent storage at boot
|
|
3
|
+
// and goes back when no agent process holds the files, so the data lives on between sandboxes.
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { SYSTEM } from '../../shared/system.js';
|
|
7
|
+
import { dryRun, isWin, localDir } from '../runtime/paths.js';
|
|
8
|
+
import { exists, mkdirp } from '../runtime/fs.js';
|
|
9
|
+
import { execOutput } from '../runtime/process.js';
|
|
10
|
+
import { log, warn } from '../runtime/log.js';
|
|
11
|
+
import { session, stateDir } from '../runtime/session.js';
|
|
12
|
+
import { errMsg } from '../../core/util/errors.js';
|
|
13
|
+
import { bootResetPaths, isCopyableDatabaseFile, isDatabaseFile, localStateEntries, } from './agent-files.js';
|
|
14
|
+
const SQLITE_HEADER = 'SQLite format 3\0';
|
|
15
|
+
/** The sandbox-disk folder that holds the working copies. */
|
|
16
|
+
const localRoot = () => path.join(localDir, 'agent-state');
|
|
17
|
+
/** Every SQLite folder of every configured agent (none in launch folders that predate the agents list). */
|
|
18
|
+
export function agentLocalStates() {
|
|
19
|
+
return localStateEntries(session.agents ?? {}, stateDir, localRoot());
|
|
20
|
+
}
|
|
21
|
+
/** Variable -> working folder, for the agent environment (and the machine environment of new terminal tabs). */
|
|
22
|
+
export function localStateVars() {
|
|
23
|
+
return Object.fromEntries(agentLocalStates().map((s) => [s.env, s.local]));
|
|
24
|
+
}
|
|
25
|
+
const databaseFiles = (dir, keep) => exists(dir)
|
|
26
|
+
? fs.readdirSync(dir, { withFileTypes: true }).flatMap((e) => (e.isFile() && keep(e.name) ? [e.name] : []))
|
|
27
|
+
: [];
|
|
28
|
+
/** A database file that starts like SQLite (an empty or cut-off file must never replace a saved copy). */
|
|
29
|
+
const looksLikeSqlite = (file) => {
|
|
30
|
+
const fd = fs.openSync(file, 'r');
|
|
31
|
+
try {
|
|
32
|
+
const head = Buffer.alloc(16);
|
|
33
|
+
return fs.readSync(fd, head, 0, 16, 0) === 16 && head.toString('latin1') === SQLITE_HEADER;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
fs.closeSync(fd);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const copyFiles = (from, to, names) => {
|
|
40
|
+
fs.rmSync(to, { recursive: true, force: true });
|
|
41
|
+
mkdirp(to);
|
|
42
|
+
for (const name of names)
|
|
43
|
+
fs.copyFileSync(path.join(from, name), path.join(to, name));
|
|
44
|
+
};
|
|
45
|
+
/** Replaces the folder `store` with the staged `incoming` folder; the old one is only removed once the new is in. */
|
|
46
|
+
const swapIn = (incoming, store) => {
|
|
47
|
+
const previous = store + '.previous';
|
|
48
|
+
fs.rmSync(previous, { recursive: true, force: true });
|
|
49
|
+
if (exists(store))
|
|
50
|
+
fs.renameSync(store, previous);
|
|
51
|
+
try {
|
|
52
|
+
fs.renameSync(incoming, store);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (exists(previous))
|
|
56
|
+
fs.renameSync(previous, store);
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
59
|
+
fs.rmSync(previous, { recursive: true, force: true });
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Databases an agent kept in its state folder before (codex: state_5.sqlite ...) move into the saved copy. The
|
|
63
|
+
* originals
|
|
64
|
+
* go only after the copy is in place and has the same sizes.
|
|
65
|
+
*/
|
|
66
|
+
function adoptLegacy(s) {
|
|
67
|
+
if (exists(s.store))
|
|
68
|
+
return;
|
|
69
|
+
const names = databaseFiles(s.legacy, isDatabaseFile);
|
|
70
|
+
if (!names.length)
|
|
71
|
+
return;
|
|
72
|
+
const copyable = names.filter(isCopyableDatabaseFile);
|
|
73
|
+
const incoming = s.store + '.incoming';
|
|
74
|
+
copyFiles(s.legacy, incoming, copyable);
|
|
75
|
+
swapIn(incoming, s.store);
|
|
76
|
+
const same = copyable.every((n) => fs.statSync(path.join(s.store, n)).size === fs.statSync(path.join(s.legacy, n)).size);
|
|
77
|
+
if (!same) {
|
|
78
|
+
warn(s.agent + ': the copied databases differ in size from the originals; the originals were kept.');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
for (const n of names)
|
|
82
|
+
fs.rmSync(path.join(s.legacy, n), { force: true });
|
|
83
|
+
log(s.agent + ': moved ' + copyable.length + ' database file(s) to ' + s.store + '.');
|
|
84
|
+
}
|
|
85
|
+
/** Boot: what an agent sealed to the last sandbox (bootReset) is deleted, so it sets it up again. Links are left. */
|
|
86
|
+
export function resetMachineBound() {
|
|
87
|
+
if (dryRun)
|
|
88
|
+
return;
|
|
89
|
+
for (const { agent, path: target } of bootResetPaths(session.agents ?? {}, stateDir)) {
|
|
90
|
+
try {
|
|
91
|
+
const stat = fs.lstatSync(target, { throwIfNoEntry: false });
|
|
92
|
+
if (!stat || stat.isSymbolicLink())
|
|
93
|
+
continue;
|
|
94
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
95
|
+
log(agent +
|
|
96
|
+
': removed ' +
|
|
97
|
+
path.relative(path.join(stateDir, agent), target) +
|
|
98
|
+
' (it only worked in the last sandbox).');
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
warn(agent + ': could not remove ' + target + ' (' + errMsg(e) + ').');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Boot: the saved databases of every configured agent are copied to the sandbox's disk, where the agent runs them. */
|
|
106
|
+
export function restoreLocalState() {
|
|
107
|
+
if (dryRun)
|
|
108
|
+
return;
|
|
109
|
+
for (const s of agentLocalStates()) {
|
|
110
|
+
try {
|
|
111
|
+
adoptLegacy(s);
|
|
112
|
+
mkdirp(s.local);
|
|
113
|
+
const names = databaseFiles(s.store, isCopyableDatabaseFile);
|
|
114
|
+
for (const n of names)
|
|
115
|
+
fs.copyFileSync(path.join(s.store, n), path.join(s.local, n));
|
|
116
|
+
if (names.length)
|
|
117
|
+
log(s.agent + ': databases restored to ' + s.local + '.');
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
warn(s.agent + ': could not restore its databases (' + errMsg(e) + '); it starts with empty ones.');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** True while one of the programs that open the databases runs. */
|
|
125
|
+
function held(s) {
|
|
126
|
+
if (!isWin)
|
|
127
|
+
return false;
|
|
128
|
+
return s.processes.some((image) => execOutput(SYSTEM.tasklist(), ['/FI', 'IMAGENAME eq ' + image, '/NH', '/FO', 'CSV'])
|
|
129
|
+
.toLowerCase()
|
|
130
|
+
.includes(image.toLowerCase()));
|
|
131
|
+
}
|
|
132
|
+
const fingerprint = (dir) => databaseFiles(dir, isCopyableDatabaseFile)
|
|
133
|
+
.sort()
|
|
134
|
+
.map((n) => {
|
|
135
|
+
const st = fs.statSync(path.join(dir, n));
|
|
136
|
+
return n + ':' + st.size + ':' + st.mtimeMs;
|
|
137
|
+
})
|
|
138
|
+
.join('|');
|
|
139
|
+
/** The working copies as of the last save by this process. */
|
|
140
|
+
const saved = new Map();
|
|
141
|
+
/** Snapshots in progress (one per working folder) and whether the missing online backup was said already. */
|
|
142
|
+
const snapshotting = new Set();
|
|
143
|
+
let saidNoBackup = false;
|
|
144
|
+
/**
|
|
145
|
+
* While the agent runs its databases are never copied as files (the -wal and the database would not match): SQLite's
|
|
146
|
+
* online backup writes a consistent snapshot into the staging folder, which is then swapped in. Needs node:sqlite
|
|
147
|
+
* (newer Node); without it the save waits until the agent has exited.
|
|
148
|
+
*/
|
|
149
|
+
function snapshotWhileRunning(s, print) {
|
|
150
|
+
if (snapshotting.has(s.local))
|
|
151
|
+
return;
|
|
152
|
+
snapshotting.add(s.local);
|
|
153
|
+
void (async () => {
|
|
154
|
+
try {
|
|
155
|
+
const sqlite = await import('node:sqlite').catch(() => null);
|
|
156
|
+
if (!sqlite || typeof sqlite.backup !== 'function') {
|
|
157
|
+
if (!saidNoBackup)
|
|
158
|
+
log(s.agent + ': this Node has no SQLite online backup; its databases are saved when it exits.');
|
|
159
|
+
saidNoBackup = true;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const incoming = s.store + '.incoming';
|
|
163
|
+
fs.rmSync(incoming, { recursive: true, force: true });
|
|
164
|
+
mkdirp(incoming);
|
|
165
|
+
for (const name of databaseFiles(s.local, (n) => isCopyableDatabaseFile(n) && !/-wal$/i.test(n))) {
|
|
166
|
+
const db = new sqlite.DatabaseSync(path.join(s.local, name), { readOnly: true });
|
|
167
|
+
try {
|
|
168
|
+
await sqlite.backup(db, path.join(incoming, name));
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
db.close();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
swapIn(incoming, s.store);
|
|
175
|
+
saved.set(s.local, print);
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
warn(s.agent + ': could not snapshot its running databases: ' + errMsg(e));
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
snapshotting.delete(s.local);
|
|
182
|
+
}
|
|
183
|
+
})();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Copies the working databases back to persistent storage (staging folder + swap). While the agent runs they are
|
|
187
|
+
* snapshotted with SQLite's online backup instead (see snapshotWhileRunning); nothing is done when nothing changed.
|
|
188
|
+
*/
|
|
189
|
+
export function saveLocalState() {
|
|
190
|
+
if (dryRun)
|
|
191
|
+
return;
|
|
192
|
+
for (const s of agentLocalStates()) {
|
|
193
|
+
try {
|
|
194
|
+
if (!exists(s.local))
|
|
195
|
+
continue;
|
|
196
|
+
const print = fingerprint(s.local);
|
|
197
|
+
if (!print || (saved.get(s.local) === print && exists(s.store)))
|
|
198
|
+
continue;
|
|
199
|
+
if (held(s)) {
|
|
200
|
+
snapshotWhileRunning(s, print);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const names = databaseFiles(s.local, isCopyableDatabaseFile);
|
|
204
|
+
const bad = names.filter((n) => !/-wal$/i.test(n) && !looksLikeSqlite(path.join(s.local, n)));
|
|
205
|
+
if (bad.length) {
|
|
206
|
+
warn(s.agent + ': ' + bad.join(', ') + ' do not look like SQLite databases, so they were not saved.');
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
const incoming = s.store + '.incoming';
|
|
210
|
+
copyFiles(s.local, incoming, names);
|
|
211
|
+
swapIn(incoming, s.store);
|
|
212
|
+
saved.set(s.local, print);
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
warn(s.agent + ': could not save its databases: ' + errMsg(e));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// `sbx-agent`: install a configured agent from a terminal inside the sandbox (the agent commands call it the first
|
|
2
|
+
// time). Usage: sbx-agent list | sbx-agent install <agent>
|
|
3
|
+
import { agents } from './agent-installer.js';
|
|
4
|
+
import { agentCommand, agentPaths } from './agent-files.js';
|
|
5
|
+
import { toolsDir } from '../runtime/paths.js';
|
|
6
|
+
import { exists } from '../runtime/fs.js';
|
|
7
|
+
import { session } from '../runtime/session.js';
|
|
8
|
+
/** Runs one sbx-agent command; returns the exit code. Prints, as the command line tool it is. */
|
|
9
|
+
export async function runSbxAgent(argv) {
|
|
10
|
+
const known = session.agents ?? {};
|
|
11
|
+
const [verb, name] = argv;
|
|
12
|
+
if (verb === 'list' || verb === undefined) {
|
|
13
|
+
for (const [agent, harness] of Object.entries(known)) {
|
|
14
|
+
const p = agentPaths(toolsDir, agent, harness);
|
|
15
|
+
const installed = (p.exe !== null && exists(p.exe)) || (p.cmd !== null && exists(p.cmd));
|
|
16
|
+
console.log(agentCommand(agent, harness).padEnd(14) + (installed ? 'installed' : 'not installed yet'));
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
const harness = verb === 'install' && name ? known[name] : undefined;
|
|
21
|
+
if (!harness) {
|
|
22
|
+
console.error(verb === 'install' && name
|
|
23
|
+
? 'Unknown agent "' + name + '". Configured agents: ' + Object.keys(known).join(', ')
|
|
24
|
+
: 'Usage: sbx-agent list | sbx-agent install <agent>');
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await agents.provision(name, harness, process.env, false);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.error('Could not install ' + name + ': ' + (e instanceof Error ? e.message : String(e)));
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
@@ -3,11 +3,15 @@ export declare class Boot {
|
|
|
3
3
|
private ptyHost;
|
|
4
4
|
private lan;
|
|
5
5
|
private readonly gitAccess;
|
|
6
|
+
/** What the host handed over in its one-shot file (read and deleted at the start of run()). */
|
|
7
|
+
private secrets;
|
|
6
8
|
run(): Promise<void>;
|
|
7
9
|
private networkAndSessionHost;
|
|
8
10
|
private hooksAndDesktop;
|
|
9
11
|
/** Toolchains, databases, apps, the network proxy and VS Code; then the agent environment, saved machine-wide. */
|
|
10
12
|
private developerTools;
|
|
13
|
+
/** vpn.enabled: the tunnel and its kill switch, before anything else uses the network (git, the agent). */
|
|
14
|
+
private vpn;
|
|
11
15
|
private gitIdentity;
|
|
12
16
|
private claude;
|
|
13
17
|
private agent;
|