windows-development-sandbox 1.0.5 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +25 -8
- package/config.example.json +55 -5
- package/dist/api.js +2 -1
- package/dist/cli/args.d.ts +23 -0
- package/dist/cli/args.js +38 -4
- package/dist/cli/colors.d.ts +24 -0
- package/dist/cli/colors.js +42 -0
- package/dist/cli/commands/accounts.js +2 -2
- package/dist/cli/commands/agent-commands.d.ts +6 -0
- package/dist/cli/commands/agent-commands.js +61 -0
- package/dist/cli/commands/context.d.ts +2 -0
- package/dist/cli/commands/context.js +5 -1
- package/dist/cli/commands/data/clean.d.ts +15 -0
- package/dist/cli/commands/data/clean.js +106 -0
- package/dist/cli/commands/data/collect.d.ts +11 -0
- package/dist/cli/commands/data/collect.js +54 -0
- package/dist/cli/commands/data/index.d.ts +4 -0
- package/dist/cli/commands/data/index.js +45 -0
- package/dist/cli/commands/data/remove.d.ts +2 -0
- package/dist/cli/commands/data/remove.js +30 -0
- package/dist/cli/commands/index.d.ts +6 -4
- package/dist/cli/commands/index.js +6 -4
- package/dist/cli/commands/launch.d.ts +26 -2
- package/dist/cli/commands/launch.js +256 -42
- package/dist/cli/commands/maintenance.d.ts +2 -0
- package/dist/cli/commands/maintenance.js +67 -5
- package/dist/cli/commands/project.d.ts +29 -0
- package/dist/cli/commands/project.js +63 -0
- package/dist/cli/commands/projects.d.ts +14 -0
- package/dist/cli/commands/projects.js +146 -0
- package/dist/cli/commands/repair/checks.d.ts +2 -0
- package/dist/cli/commands/{repair.js → repair/checks.js} +19 -181
- package/dist/cli/commands/{repair.d.ts → repair/finders.d.ts} +0 -29
- package/dist/cli/commands/repair/finders.js +108 -0
- package/dist/cli/commands/repair/index.d.ts +12 -0
- package/dist/cli/commands/repair/index.js +61 -0
- package/dist/cli/commands/repair/types.d.ts +26 -0
- package/dist/cli/commands/repair/types.js +3 -0
- package/dist/cli/commands/restart.d.ts +6 -0
- package/dist/cli/commands/restart.js +85 -0
- package/dist/cli/commands/sessions.d.ts +2 -1
- package/dist/cli/commands/sessions.js +189 -45
- package/dist/cli/commands/setup/checks.d.ts +13 -0
- package/dist/cli/commands/setup/checks.js +71 -0
- package/dist/cli/commands/{setup.d.ts → setup/facts.d.ts} +1 -15
- package/dist/cli/commands/setup/facts.js +60 -0
- package/dist/cli/commands/setup/index.d.ts +2 -0
- package/dist/cli/commands/setup/index.js +43 -0
- package/dist/cli/commands/user-config.d.ts +8 -0
- package/dist/cli/commands/user-config.js +41 -0
- package/dist/cli/history.d.ts +11 -0
- package/dist/cli/history.js +21 -0
- package/dist/cli/index.d.ts +7 -1
- package/dist/cli/index.js +42 -15
- package/dist/cli/manifest.d.ts +8 -0
- package/dist/cli/manifest.js +40 -15
- package/dist/cli/menu/apps.d.ts +21 -0
- package/dist/cli/menu/apps.js +122 -0
- package/dist/cli/menu/command-form.d.ts +28 -0
- package/dist/cli/menu/command-form.js +219 -0
- package/dist/cli/menu/index.d.ts +26 -0
- package/dist/cli/menu/index.js +180 -0
- package/dist/cli/menu/settings/categories.d.ts +9 -0
- package/dist/cli/menu/settings/categories.js +28 -0
- package/dist/cli/menu/settings/config-file.d.ts +40 -0
- package/dist/cli/menu/settings/config-file.js +71 -0
- package/dist/cli/menu/settings/editors.d.ts +30 -0
- package/dist/cli/menu/settings/editors.js +305 -0
- package/dist/cli/menu/settings/index.d.ts +32 -0
- package/dist/cli/menu/settings/index.js +136 -0
- package/dist/cli/menu/settings/schema-node.d.ts +62 -0
- package/dist/cli/menu/settings/schema-node.js +104 -0
- package/dist/cli/menu/several.d.ts +20 -0
- package/dist/cli/menu/several.js +102 -0
- package/dist/cli/progress.d.ts +9 -0
- package/dist/cli/progress.js +49 -0
- package/dist/cli/tui/app.d.ts +39 -0
- package/dist/cli/tui/app.js +52 -0
- package/dist/cli/tui/dialogs.d.ts +57 -0
- package/dist/cli/tui/dialogs.js +162 -0
- package/dist/cli/tui/frame.d.ts +18 -0
- package/dist/cli/tui/frame.js +27 -0
- package/dist/cli/tui/index.d.ts +7 -0
- package/dist/cli/tui/index.js +8 -0
- package/dist/cli/tui/list-screen.d.ts +101 -0
- package/dist/cli/tui/list-screen.js +299 -0
- package/dist/cli/tui/terminal.d.ts +37 -0
- package/dist/cli/tui/terminal.js +89 -0
- package/dist/cli/tui/text.d.ts +20 -0
- package/dist/cli/tui/text.js +105 -0
- package/dist/cli/tui/theme.d.ts +45 -0
- package/dist/cli/tui/theme.js +30 -0
- package/dist/cli/validate.d.ts +17 -0
- package/dist/cli/validate.js +89 -0
- package/dist/core/config.js +12 -6
- package/dist/core/disk.d.ts +16 -0
- package/dist/core/disk.js +55 -0
- package/dist/core/local-config.d.ts +23 -0
- package/dist/core/local-config.js +79 -7
- package/dist/core/project-policy.d.ts +15 -0
- package/dist/core/project-policy.js +35 -0
- package/dist/core/prompt.d.ts +4 -0
- package/dist/core/prompt.js +15 -0
- package/dist/core/safe-paths.d.ts +4 -0
- package/dist/core/safe-paths.js +37 -0
- package/dist/core/schema/apps.d.ts +40 -0
- package/dist/core/schema/apps.js +27 -0
- package/dist/core/schema/common.d.ts +17 -0
- package/dist/core/schema/common.js +15 -0
- package/dist/core/schema/config.d.ts +659 -0
- package/dist/core/schema/config.js +75 -0
- package/dist/core/schema/databases.d.ts +33 -0
- package/dist/core/schema/databases.js +35 -0
- package/dist/core/schema/harness.d.ts +12 -0
- package/dist/core/schema/harness.js +17 -0
- package/dist/core/schema/json-schema.d.ts +5 -0
- package/dist/core/schema/json-schema.js +25 -0
- package/dist/core/schema/profile.d.ts +32 -0
- package/dist/core/schema/profile.js +31 -0
- package/dist/core/schema/projects.d.ts +9 -0
- package/dist/core/schema/projects.js +11 -0
- package/dist/core/schema/sandbox.d.ts +78 -0
- package/dist/core/schema/sandbox.js +64 -0
- package/dist/core/schema/toolchains.d.ts +96 -0
- package/dist/core/schema/toolchains.js +88 -0
- package/dist/core/schema.d.ts +6 -604
- package/dist/core/schema.js +8 -264
- package/dist/core/types.d.ts +35 -1
- package/dist/core/util.d.ts +9 -0
- package/dist/core/util.js +14 -3
- package/dist/core/workspace.d.ts +0 -5
- package/dist/core/workspace.js +33 -50
- package/dist/guest/apps/index.d.ts +10 -0
- package/dist/guest/apps/index.js +206 -0
- package/dist/guest/apps/resolvers.d.ts +8 -0
- package/dist/guest/apps/resolvers.js +90 -0
- package/dist/guest/audit-parse.d.ts +7 -0
- package/dist/guest/audit-parse.js +24 -0
- package/dist/guest/audit.d.ts +4 -0
- package/dist/guest/audit.js +47 -0
- package/dist/guest/boot-env.d.ts +4 -0
- package/dist/guest/boot-env.js +25 -0
- package/dist/guest/cmdline.d.ts +12 -0
- package/dist/guest/cmdline.js +23 -0
- package/dist/guest/daemon/exec.d.ts +5 -0
- package/dist/guest/daemon/exec.js +32 -0
- package/dist/guest/daemon/project.d.ts +14 -0
- package/dist/guest/daemon/project.js +132 -0
- package/dist/guest/daemon/relays.d.ts +1 -0
- package/dist/guest/daemon/relays.js +18 -0
- package/dist/guest/daemon/session.d.ts +13 -0
- package/dist/guest/daemon/session.js +139 -0
- package/dist/guest/daemon/shutdown.d.ts +1 -0
- package/dist/guest/daemon/shutdown.js +21 -0
- package/dist/guest/daemon/state.d.ts +17 -0
- package/dist/guest/daemon/state.js +31 -0
- package/dist/guest/daemon.js +12 -141
- package/dist/guest/db.js +18 -3
- package/dist/guest/env.d.ts +3 -0
- package/dist/guest/env.js +7 -3
- package/dist/guest/guide.d.ts +6 -2
- package/dist/guest/guide.js +5 -4
- package/dist/guest/helpers.d.ts +3 -0
- package/dist/guest/helpers.js +26 -0
- package/dist/guest/main.js +31 -8
- package/dist/guest/netproxy.d.ts +1 -0
- package/dist/guest/netproxy.js +100 -0
- package/dist/guest/ports.d.ts +6 -0
- package/dist/guest/ports.js +22 -0
- package/dist/guest/project-context.d.ts +7 -0
- package/dist/guest/project-context.js +10 -0
- package/dist/guest/project-env.d.ts +20 -0
- package/dist/guest/project-env.js +20 -0
- package/dist/guest/project-status.d.ts +5 -0
- package/dist/guest/project-status.js +17 -0
- package/dist/guest/ptyhost.d.ts +0 -18
- package/dist/guest/ptyhost.js +17 -65
- package/dist/guest/setup/agents.d.ts +5 -2
- package/dist/guest/setup/agents.js +22 -8
- package/dist/guest/setup/claude.d.ts +0 -4
- package/dist/guest/setup/claude.js +59 -5
- package/dist/guest/setup/environment.d.ts +13 -3
- package/dist/guest/setup/environment.js +14 -10
- package/dist/guest/setup/hooks.d.ts +9 -1
- package/dist/guest/setup/hooks.js +28 -14
- package/dist/guest/setup/network.d.ts +9 -0
- package/dist/guest/setup/network.js +97 -4
- package/dist/guest/setup/user.js +4 -0
- package/dist/guest/toolchains/catalogue.d.ts +4 -0
- package/dist/guest/toolchains/catalogue.js +2 -2
- package/dist/guest/toolchains/cli.js +25 -17
- package/dist/guest/toolchains/common.d.ts +18 -1
- package/dist/guest/toolchains/common.js +34 -11
- package/dist/guest/toolchains/databases/dynamodb.d.ts +8 -0
- package/dist/guest/toolchains/databases/dynamodb.js +52 -0
- package/dist/guest/toolchains/{databases.d.ts → databases/index.d.ts} +2 -3
- package/dist/guest/toolchains/databases/index.js +62 -0
- package/dist/guest/toolchains/databases/mongodb.d.ts +3 -0
- package/dist/guest/toolchains/databases/mongodb.js +31 -0
- package/dist/guest/toolchains/databases/mysql.d.ts +3 -0
- package/dist/guest/toolchains/databases/mysql.js +38 -0
- package/dist/guest/toolchains/databases/postgres.d.ts +5 -0
- package/dist/guest/toolchains/databases/postgres.js +38 -0
- package/dist/guest/toolchains/databases/redis.d.ts +3 -0
- package/dist/guest/toolchains/databases/redis.js +16 -0
- package/dist/guest/toolchains/databases/server.d.ts +14 -0
- package/dist/guest/toolchains/databases/server.js +52 -0
- package/dist/guest/toolchains/git.js +25 -16
- package/dist/guest/toolchains/go.js +1 -1
- package/dist/guest/toolchains/index.d.ts +13 -9
- package/dist/guest/toolchains/index.js +40 -82
- package/dist/guest/toolchains/java.js +5 -5
- package/dist/guest/toolchains/leftovers.d.ts +2 -0
- package/dist/guest/toolchains/leftovers.js +26 -0
- package/dist/guest/toolchains/managers.js +12 -10
- package/dist/guest/toolchains/{binstall.js → native/binstall.js} +6 -9
- package/dist/guest/toolchains/native/cpp.d.ts +4 -0
- package/dist/guest/toolchains/native/cpp.js +38 -0
- package/dist/guest/toolchains/native/dotnet.d.ts +4 -0
- package/dist/guest/toolchains/native/dotnet.js +103 -0
- package/dist/guest/toolchains/native/mesa.d.ts +7 -0
- package/dist/guest/toolchains/native/mesa.js +56 -0
- package/dist/guest/toolchains/native/msvc/environment.d.ts +16 -0
- package/dist/guest/toolchains/native/msvc/environment.js +57 -0
- package/dist/guest/toolchains/native/msvc/index.d.ts +6 -0
- package/dist/guest/toolchains/native/msvc/index.js +48 -0
- package/dist/guest/toolchains/native/msvc/packages.d.ts +6 -0
- package/dist/guest/toolchains/native/msvc/packages.js +156 -0
- package/dist/guest/toolchains/native/msvc/tree.d.ts +15 -0
- package/dist/guest/toolchains/native/msvc/tree.js +21 -0
- package/dist/guest/toolchains/native/rust.d.ts +3 -0
- package/dist/guest/toolchains/native/rust.js +45 -0
- package/dist/guest/toolchains/node.js +26 -6
- package/dist/guest/toolchains/plan.d.ts +24 -0
- package/dist/guest/toolchains/plan.js +140 -0
- package/dist/guest/toolchains/pwsh.js +1 -1
- package/dist/guest/toolchains/python.js +43 -12
- package/dist/guest/toolchains/runtimes.d.ts +2 -0
- package/dist/guest/toolchains/runtimes.js +6 -8
- package/dist/guest/toolchains/scripting/php.d.ts +3 -0
- package/dist/guest/toolchains/scripting/php.js +71 -0
- package/dist/guest/toolchains/scripting/ruby.d.ts +3 -0
- package/dist/guest/toolchains/scripting/ruby.js +47 -0
- package/dist/guest/toolchains/scripting/vcruntime.d.ts +7 -0
- package/dist/guest/toolchains/scripting/vcruntime.js +45 -0
- package/dist/guest/toolchains/vscode-profile.d.ts +30 -0
- package/dist/guest/toolchains/vscode-profile.js +69 -0
- package/dist/guest/toolchains/vscode.d.ts +17 -0
- package/dist/guest/toolchains/vscode.js +87 -1
- package/dist/guest/view.js +21 -1
- package/dist/host/accounts.js +14 -5
- package/dist/host/agent-commands.d.ts +25 -0
- package/dist/host/agent-commands.js +145 -0
- package/dist/host/attach.d.ts +17 -0
- package/dist/host/attach.js +70 -0
- package/dist/host/audit/collect.d.ts +34 -0
- package/dist/host/audit/collect.js +126 -0
- package/dist/host/audit/log.d.ts +46 -0
- package/dist/host/audit/log.js +143 -0
- package/dist/host/channel.d.ts +23 -22
- package/dist/host/channel.js +66 -84
- package/dist/host/claude-profile.js +7 -3
- package/dist/host/cleanup.js +2 -11
- package/dist/host/database-plan.d.ts +12 -0
- package/dist/host/database-plan.js +52 -0
- package/dist/host/generate.d.ts +10 -12
- package/dist/host/generate.js +58 -135
- package/dist/host/join.d.ts +28 -0
- package/dist/host/join.js +76 -0
- package/dist/host/launch/mappings.d.ts +3 -0
- package/dist/host/launch/mappings.js +54 -0
- package/dist/host/launch/projects.d.ts +15 -0
- package/dist/host/launch/projects.js +56 -0
- package/dist/host/launch/stage.d.ts +11 -0
- package/dist/host/launch/stage.js +66 -0
- package/dist/host/launch/wsb.d.ts +10 -0
- package/dist/host/launch/wsb.js +34 -0
- package/dist/host/motw.d.ts +17 -0
- package/dist/host/motw.js +74 -0
- package/dist/host/pc-scan.d.ts +6 -0
- package/dist/host/pc-scan.js +37 -0
- package/dist/host/platform.d.ts +2 -0
- package/dist/host/platform.js +16 -1
- package/dist/host/port-forward.d.ts +8 -0
- package/dist/host/port-forward.js +37 -0
- package/dist/host/project-scan.d.ts +1 -17
- package/dist/host/project-scan.js +2 -86
- package/dist/host/projects.d.ts +100 -0
- package/dist/host/projects.js +147 -0
- package/dist/host/repo-guard.d.ts +25 -5
- package/dist/host/repo-guard.js +242 -23
- package/dist/host/stops.d.ts +67 -0
- package/dist/host/stops.js +126 -0
- package/dist/host/terminal.d.ts +8 -0
- package/dist/host/terminal.js +48 -1
- package/dist/host/test-guard.d.ts +6 -0
- package/dist/host/test-guard.js +15 -0
- package/dist/host/window.js +7 -3
- package/dist/host/workspace-view/index.d.ts +20 -0
- package/dist/host/workspace-view/index.js +53 -0
- package/dist/host/workspace-view/rules.d.ts +26 -0
- package/dist/host/workspace-view/rules.js +93 -0
- package/dist/host/workspace-view/view.d.ts +50 -0
- package/dist/host/workspace-view/view.js +281 -0
- package/dist/host/wsb.d.ts +37 -0
- package/dist/host/wsb.js +101 -0
- package/dist/runtime/daemon.js +11791 -2821
- package/dist/runtime/db.js +6585 -466
- package/dist/runtime/main.js +10238 -1724
- package/dist/runtime/netproxy.js +25936 -0
- package/dist/runtime/view.js +6183 -59
- package/dist/selftest/accounts.test.d.ts +2 -0
- package/dist/selftest/accounts.test.js +44 -0
- package/dist/selftest/agent-commands.test.d.ts +2 -0
- package/dist/selftest/agent-commands.test.js +47 -0
- package/dist/selftest/audit.test.d.ts +2 -0
- package/dist/selftest/audit.test.js +57 -0
- package/dist/selftest/channel.test.d.ts +2 -0
- package/dist/selftest/channel.test.js +44 -0
- package/dist/selftest/cli.test.d.ts +2 -2
- package/dist/selftest/cli.test.js +145 -27
- package/dist/selftest/cmdline.test.d.ts +2 -0
- package/dist/selftest/cmdline.test.js +45 -0
- package/dist/selftest/config.test.d.ts +2 -3
- package/dist/selftest/config.test.js +36 -72
- package/dist/selftest/data.test.d.ts +2 -2
- package/dist/selftest/data.test.js +77 -70
- package/dist/selftest/detect.test.d.ts +2 -2
- package/dist/selftest/detect.test.js +54 -38
- package/dist/selftest/fixtures.d.ts +89 -4
- package/dist/selftest/fixtures.js +43 -24
- package/dist/selftest/generate.test.d.ts +2 -0
- package/dist/selftest/generate.test.js +68 -0
- package/dist/selftest/git-access.test.d.ts +2 -0
- package/dist/selftest/git-access.test.js +26 -0
- package/dist/selftest/guest-boot.test.d.ts +2 -0
- package/dist/selftest/guest-boot.test.js +76 -0
- package/dist/selftest/harness.d.ts +44 -7
- package/dist/selftest/harness.js +62 -21
- package/dist/selftest/host-sim.test.d.ts +2 -0
- package/dist/selftest/host-sim.test.js +93 -0
- package/dist/selftest/hostile-input.test.d.ts +2 -0
- package/dist/selftest/hostile-input.test.js +54 -0
- package/dist/selftest/index.d.ts +8 -1
- package/dist/selftest/index.js +137 -35
- package/dist/selftest/links.test.d.ts +2 -0
- package/dist/selftest/links.test.js +50 -0
- package/dist/selftest/live-daemon.test.d.ts +2 -0
- package/dist/selftest/live-daemon.test.js +91 -0
- package/dist/selftest/live-git.test.d.ts +2 -0
- package/dist/selftest/live-git.test.js +60 -0
- package/dist/selftest/live-network.test.d.ts +2 -0
- package/dist/selftest/live-network.test.js +63 -0
- package/dist/selftest/live-projects.test.d.ts +2 -0
- package/dist/selftest/live-projects.test.js +127 -0
- package/dist/selftest/live.d.ts +65 -0
- package/dist/selftest/live.js +109 -0
- package/dist/selftest/local-config.test.d.ts +2 -0
- package/dist/selftest/local-config.test.js +120 -0
- package/dist/selftest/mirror.test.d.ts +2 -3
- package/dist/selftest/mirror.test.js +92 -65
- package/dist/selftest/network.test.d.ts +2 -0
- package/dist/selftest/network.test.js +40 -0
- package/dist/selftest/personalization.test.d.ts +2 -0
- package/dist/selftest/personalization.test.js +53 -0
- package/dist/selftest/projects.test.d.ts +2 -0
- package/dist/selftest/projects.test.js +254 -0
- package/dist/selftest/repair.test.d.ts +2 -0
- package/dist/selftest/repair.test.js +42 -0
- package/dist/selftest/repo-guard.test.d.ts +2 -0
- package/dist/selftest/repo-guard.test.js +121 -0
- package/dist/selftest/secrets.test.d.ts +2 -0
- package/dist/selftest/secrets.test.js +71 -0
- package/dist/selftest/setup.test.d.ts +2 -2
- package/dist/selftest/setup.test.js +45 -22
- package/dist/selftest/suite.d.ts +13 -0
- package/dist/selftest/suite.js +1 -0
- package/dist/selftest/sync.test.d.ts +2 -3
- package/dist/selftest/sync.test.js +130 -78
- package/dist/selftest/test-guard.test.d.ts +2 -0
- package/dist/selftest/test-guard.test.js +49 -0
- package/dist/selftest/toolchains.test.d.ts +2 -0
- package/dist/selftest/toolchains.test.js +133 -0
- package/dist/selftest/workspace-view.test.d.ts +2 -0
- package/dist/selftest/workspace-view.test.js +89 -0
- package/dist/selftest/workspace.test.d.ts +2 -0
- package/dist/selftest/workspace.test.js +53 -0
- package/dist/shared/apps.d.ts +49 -0
- package/dist/shared/apps.js +114 -0
- package/dist/shared/download.d.ts +3 -1
- package/dist/shared/download.js +19 -4
- package/dist/shared/netpolicy.d.ts +27 -0
- package/dist/shared/netpolicy.js +51 -0
- package/dist/shared/paths.d.ts +5 -0
- package/dist/shared/paths.js +6 -0
- package/dist/shared/projects.d.ts +53 -0
- package/dist/shared/projects.js +67 -0
- package/dist/shared/pty-client.d.ts +9 -4
- package/dist/shared/pty-client.js +139 -17
- package/dist/shared/rundir.d.ts +12 -1
- package/dist/shared/rundir.js +14 -4
- package/dist/shared/safe-remove.js +11 -0
- package/dist/shared/schema.d.ts +453 -0
- package/dist/shared/schema.js +43 -2
- package/dist/shared/system.d.ts +1 -0
- package/dist/shared/system.js +1 -0
- package/dist/shared/test-guard.d.ts +4 -0
- package/dist/shared/test-guard.js +37 -0
- package/dist/sync/claude-mem.js +6 -3
- package/dist/sync/history.d.ts +29 -12
- package/dist/sync/history.js +72 -25
- package/dist/sync/watcher.d.ts +8 -0
- package/dist/sync/watcher.js +99 -8
- package/package.json +7 -6
- package/sandbox/bootstrap.ps1 +258 -258
- package/sandbox/cargoshim.cs +56 -0
- package/sandbox/cpucap.cs +33 -0
- package/sandbox/cpucap.ps1 +20 -0
- package/sandbox/logon.cmd +24 -16
- package/sandbox/memlog.ps1 +34 -0
- package/sandbox/openssl.cs +42 -0
- package/sandbox/pagefile.cs +31 -0
- package/sandbox/pagefile.ps1 +21 -0
- package/sandbox/ptyhost.cs +120 -11
- package/sandbox/trust.cmd +35 -35
- package/schemas/config.schema.json +403 -3
- package/schemas/sandbox-config.schema.json +143 -13
- package/dist/cli/commands/data.d.ts +0 -46
- package/dist/cli/commands/data.js +0 -249
- package/dist/cli/commands/setup.js +0 -152
- package/dist/cli/menu.d.ts +0 -22
- package/dist/cli/menu.js +0 -187
- package/dist/cli/settings.d.ts +0 -11
- package/dist/cli/settings.js +0 -156
- package/dist/guest/toolchains/databases.js +0 -226
- package/dist/guest/toolchains/msvc.d.ts +0 -10
- package/dist/guest/toolchains/msvc.js +0 -216
- package/dist/guest/toolchains/native.d.ts +0 -12
- package/dist/guest/toolchains/native.js +0 -220
- package/dist/guest/toolchains/scripting.d.ts +0 -10
- package/dist/guest/toolchains/scripting.js +0 -137
- package/dist/selftest/guest.test.d.ts +0 -3
- package/dist/selftest/guest.test.js +0 -61
- package/dist/selftest/helpers.test.d.ts +0 -2
- package/dist/selftest/helpers.test.js +0 -125
- package/dist/selftest/host.test.d.ts +0 -2
- package/dist/selftest/host.test.js +0 -71
- package/dist/selftest/live.test.d.ts +0 -7
- package/dist/selftest/live.test.js +0 -127
- package/dist/selftest/security.test.d.ts +0 -3
- package/dist/selftest/security.test.js +0 -143
- /package/dist/guest/toolchains/{binstall.d.ts → native/binstall.d.ts} +0 -0
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
// `launch` / `generate`, and what sandbox claude runs: start a sandbox, or another session in the running one.
|
|
1
|
+
// `launch` / `generate`, and what sandbox claude runs: start a sandbox, or another session in the running one. From a
|
|
2
|
+
// folder the running sandbox does not have yet, the folder joins it (no restart) when it can, and otherwise a
|
|
3
|
+
// restart that adds it is offered (restart.ts).
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import { select } from '@inquirer/prompts';
|
|
2
7
|
import { activateAccount, activeAccount, defaultAccount } from '../../host/accounts.js';
|
|
3
|
-
import { attachTerminal, findUnwatchedSession
|
|
8
|
+
import { attachTerminal, findUnwatchedSession } from '../../host/attach.js';
|
|
9
|
+
import { requestSession, resetRunDir, waitForReady, waitForSession } from '../../host/channel.js';
|
|
4
10
|
import { describePrune, pruneStorage } from '../../host/cleanup.js';
|
|
5
11
|
import { generateSandbox } from '../../host/generate.js';
|
|
6
12
|
import { findSecretFiles } from '../../host/secrets.js';
|
|
7
13
|
import { checkRepo, saveRepoSnapshot } from '../../host/repo-guard.js';
|
|
8
14
|
import { assertCanLaunch, insideSandbox, isSandboxRunning, probeHost, spawnDetached, startSandbox } from '../../host/platform.js';
|
|
9
|
-
import {
|
|
15
|
+
import { NeedsRestart, rememberProject, startRegistry } from '../../host/projects.js';
|
|
16
|
+
import { ensureConpty, ensureTerminal } from '../../host/terminal.js';
|
|
17
|
+
import { planView, saveActiveViews, viewSkipped, WorkspaceView } from '../../host/workspace-view/index.js';
|
|
18
|
+
import { saveForwards } from '../../host/port-forward.js';
|
|
19
|
+
import { saveAuditSettings } from '../../host/audit/collect.js';
|
|
20
|
+
import { readDataSize, saveMarkedProjects } from '../../host/motw.js';
|
|
21
|
+
import { humanBytes } from '../../core/disk.js';
|
|
10
22
|
import { hideSandboxWindow, showSandboxWindow } from '../../host/window.js';
|
|
11
23
|
import { readSandboxStatus } from '../../shared/rundir.js';
|
|
12
|
-
import
|
|
13
|
-
import fs from 'node:fs';
|
|
24
|
+
import { isWithin } from '../../shared/projects.js';
|
|
14
25
|
import { syncBeforeLaunch, watcherRunning } from '../../sync/watcher.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
26
|
+
import { protectionsOf } from '../../core/project-policy.js';
|
|
27
|
+
import { assertSafeMapping, assertSafeWorkspace } from '../../core/safe-paths.js';
|
|
28
|
+
import { errMsg, fail, isRootPath, sleep } from '../../core/util.js';
|
|
29
|
+
import { syncAgentCommands } from './agent-commands.js';
|
|
30
|
+
import { askYesNo } from '../../core/prompt.js';
|
|
31
|
+
import { resolveRun } from '../../core/workspace.js';
|
|
32
|
+
import { c } from '../colors.js';
|
|
33
|
+
import { working } from '../progress.js';
|
|
34
|
+
import { requireOnPc, sandboxAlive, table } from './context.js';
|
|
35
|
+
import _ from 'lodash';
|
|
36
|
+
import { hereDir, joinHere, readyHere } from './project.js';
|
|
37
|
+
import { offerRestart } from './restart.js';
|
|
38
|
+
import { addToList, setSetting } from './user-config.js';
|
|
39
|
+
import { lastStopWarning, startLife, UPDATE_RESTART_WARNING, updateRestartPending } from '../../host/stops.js';
|
|
18
40
|
/** Attaches this terminal; with attach.autoHide the sandbox window hides meanwhile (best effort, never fails the attach). */
|
|
19
41
|
export const attachHere = (ctx, session) => {
|
|
20
42
|
if (ctx.loaded.config.attach.autoHide && !insideSandbox())
|
|
@@ -24,9 +46,9 @@ export const attachHere = (ctx, session) => {
|
|
|
24
46
|
/** Nothing has been installed into this data set yet: the first start downloads every toolchain once. */
|
|
25
47
|
const firstBoot = (dataPath) => !fs.existsSync(path.join(dataPath, 'tools', 'resolved-versions.json'));
|
|
26
48
|
const FIRST_BOOT = 'First start for this storage: the sandbox downloads and installs the toolchains, databases and agent this project needs.\n' +
|
|
27
|
-
'That takes a few minutes, once. Everything is kept, so every later start reuses it and takes seconds.
|
|
49
|
+
'That takes a few minutes, once. Everything is kept, so every later start reuses it and takes seconds.';
|
|
28
50
|
/** The sandbox writes sandbox.json a few seconds into its boot; a second launch right after the first waits for it. */
|
|
29
|
-
const runningSandboxStatus = async (dataPath) => {
|
|
51
|
+
export const runningSandboxStatus = async (dataPath) => {
|
|
30
52
|
for (let i = 0; i < 60; i++) {
|
|
31
53
|
const status = readSandboxStatus(dataPath);
|
|
32
54
|
if (status)
|
|
@@ -35,28 +57,124 @@ const runningSandboxStatus = async (dataPath) => {
|
|
|
35
57
|
}
|
|
36
58
|
return fail('A Windows Sandbox is running that this tool did not start (or that uses another storage.dataName).', 'Close that sandbox window first, then run sandbox claude again.');
|
|
37
59
|
};
|
|
38
|
-
/**
|
|
39
|
-
const
|
|
40
|
-
|
|
60
|
+
/** Waits for the boot with its current step on a spinner (plain lines without a terminal). */
|
|
61
|
+
export const waitForBoot = (dataPath, launchId) => {
|
|
62
|
+
let step = 'starting Windows Sandbox';
|
|
63
|
+
return working(() => 'Waiting for the sandbox: ' + step, () => waitForReady(dataPath, launchId, sandboxAlive, (m) => { step = m; }));
|
|
64
|
+
};
|
|
65
|
+
/** The running sandbox, once it is ready. */
|
|
66
|
+
export const readySandbox = async (dataPath) => {
|
|
41
67
|
const status = await runningSandboxStatus(dataPath);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
return status.phase === 'ready' ? status : waitForBoot(dataPath, status.launchId);
|
|
69
|
+
};
|
|
70
|
+
/** Waits for a session to start (its project's setup, the agent's install) with its progress on a spinner. */
|
|
71
|
+
const waitForStart = (ctx, requestId, what) => {
|
|
72
|
+
let step = 'starting';
|
|
73
|
+
return working(() => what + ': ' + step, () => waitForSession(ctx.dataPath, requestId, sandboxAlive, 60 * 60 * 1000, (m) => { step = m; }));
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Starts (or picks back up) a session in the folder `joined` describes. attach: show it in this terminal.
|
|
77
|
+
* Exported for restart.ts, which reopens the sessions a restart ended.
|
|
78
|
+
*/
|
|
79
|
+
export const openSession = async (ctx, ready, joined, o) => {
|
|
80
|
+
const { options, loaded, dataPath } = ctx;
|
|
81
|
+
const cwd = joined.guestDir;
|
|
82
|
+
const harness = o.harness ?? options.harness ?? joined.harness ?? loaded.config.defaultHarness;
|
|
83
|
+
const args = o.args ?? options.passthrough;
|
|
45
84
|
// -t with nothing new for the agent: pick up this folder's session if no terminal on this PC shows it (its tab was
|
|
46
85
|
// closed, or you detached). Someone already attached, --new, or agent arguments: a new session, as before.
|
|
47
|
-
const reuse =
|
|
86
|
+
const reuse = (o.reuse ?? true) && o.attach && !options.newSession && args.length === 0 && loaded.config.attach.reuseSession;
|
|
48
87
|
const existing = reuse ? await findUnwatchedSession(dataPath, harness, cwd) : null;
|
|
49
88
|
if (existing) {
|
|
50
89
|
console.log('Reattaching to ' + harness + ' session ' + existing.id + ' in ' + cwd + ' (no other terminal is attached; --new starts another).');
|
|
51
90
|
return attachHere(ctx, existing);
|
|
52
91
|
}
|
|
53
|
-
console.log(
|
|
54
|
-
|
|
55
|
-
|
|
92
|
+
console.log(joined.spec
|
|
93
|
+
? 'Starting ' + harness + ' for ' + joined.project?.host + ' in the running sandbox (' + cwd + '; the first time sets up what it needs).'
|
|
94
|
+
: 'Sandbox already running: starting another ' + harness + ' session in ' + cwd);
|
|
95
|
+
// The agent's definition goes along: the sandbox may have booted with another agent.
|
|
96
|
+
const harnessSpec = loaded.config.harnesses[harness];
|
|
97
|
+
const requestId = requestSession(dataPath, harness, args, cwd, { ...(joined.spec ? { project: joined.spec } : {}), ...(harnessSpec ? { harnessSpec } : {}) });
|
|
98
|
+
const session = await waitForStart(ctx, requestId, 'Starting ' + harness + ' in ' + cwd);
|
|
99
|
+
if (o.attach)
|
|
56
100
|
return attachHere(ctx, session);
|
|
57
101
|
console.log('Session ' + session.id + ' opened in a new tab inside the sandbox. Attach here with: sandbox attach ' + session.id + (ready.headless ? ' (headless: sbx-show opens the window)' : ''));
|
|
58
102
|
return 0;
|
|
59
103
|
};
|
|
104
|
+
/** The sessions a launch asks for: each --session, else one (the agent, in this folder). */
|
|
105
|
+
const wantedSessions = (ctx) => ctx.options.sessions.length ? ctx.options.sessions : [{ harness: ctx.options.harness, folder: hereDir(ctx) }];
|
|
106
|
+
/** The same command, for one of its sessions (its folder, agent, and the arguments after -- plus its own). */
|
|
107
|
+
const contextFor = (ctx, want) => ({ ...ctx, options: { ...ctx.options, workspace: want.folder, harness: want.harness, sessions: [], passthrough: [...ctx.options.passthrough, ...(want.args ?? [])] } });
|
|
108
|
+
/** Several sessions at once: all requested together (projects set up in parallel), then listed; -t attaches the first. */
|
|
109
|
+
const openSessions = async (ctx, ready, list) => {
|
|
110
|
+
const { dataPath, loaded, options } = ctx;
|
|
111
|
+
const requests = list.map(({ ctx: at, joined }) => {
|
|
112
|
+
const harness = at.options.harness ?? joined.harness ?? loaded.config.defaultHarness;
|
|
113
|
+
const harnessSpec = loaded.config.harnesses[harness];
|
|
114
|
+
const id = requestSession(dataPath, harness, at.options.passthrough, joined.guestDir, { ...(joined.spec ? { project: joined.spec } : {}), ...(harnessSpec ? { harnessSpec } : {}) });
|
|
115
|
+
return { id, harness, folder: at.options.workspace ?? joined.guestDir, cwd: joined.guestDir };
|
|
116
|
+
});
|
|
117
|
+
let started = 0;
|
|
118
|
+
const results = await working(() => 'Starting ' + requests.length + ' sessions (' + started + ' running)', () => Promise.allSettled(requests.map(async (r) => {
|
|
119
|
+
const s = await waitForSession(dataPath, r.id, sandboxAlive, 60 * 60 * 1000, () => undefined);
|
|
120
|
+
started++;
|
|
121
|
+
return s;
|
|
122
|
+
})));
|
|
123
|
+
table([['SESSION', 'AGENT', 'FOLDER', ''], ...requests.map((r, i) => {
|
|
124
|
+
const result = results[i];
|
|
125
|
+
return [r.id, r.harness, r.folder, result.status === 'fulfilled' ? 'running sandbox attach ' + r.id : c.red('FAILED: ' + errMsg(result.reason))];
|
|
126
|
+
})]);
|
|
127
|
+
const first = results.find((r) => r.status === 'fulfilled');
|
|
128
|
+
if (options.terminal && first)
|
|
129
|
+
return attachHere(ctx, first.value);
|
|
130
|
+
if (!first)
|
|
131
|
+
return 1;
|
|
132
|
+
console.log('Each has its own tab inside the sandbox' + (ready.headless ? ' (headless: sbx-show opens the window)' : '') + '. Attach to any of them, from any terminal: sandbox attach');
|
|
133
|
+
return results.every((r) => r.status === 'fulfilled') ? 0 : 1;
|
|
134
|
+
};
|
|
135
|
+
/** A sandbox is already running: open the sessions in it (new tabs inside; optionally attach here). */
|
|
136
|
+
const launchIntoRunning = async (ctx) => {
|
|
137
|
+
const ready = await readySandbox(ctx.dataPath);
|
|
138
|
+
const wants = wantedSessions(ctx);
|
|
139
|
+
// Every folder joins first: when one needs a restart, nothing has been started that the restart would end.
|
|
140
|
+
const joined = [];
|
|
141
|
+
const needs = [];
|
|
142
|
+
for (const want of wants) {
|
|
143
|
+
const at = ctx.options.sessions.length ? contextFor(ctx, want) : ctx;
|
|
144
|
+
try {
|
|
145
|
+
joined.push({ ctx: at, joined: await joinHere(at, ready) });
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
if (!(e instanceof NeedsRestart))
|
|
149
|
+
throw e;
|
|
150
|
+
if (!needs.some((n) => n.hostDir.toLowerCase() === e.hostDir.toLowerCase()))
|
|
151
|
+
needs.push(e);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (needs.length)
|
|
155
|
+
return offerRestart(ctx, needs, () => launchIntoRunning(ctx));
|
|
156
|
+
for (const note of _.uniq(joined.flatMap((j) => j.joined.notes)))
|
|
157
|
+
console.log(note);
|
|
158
|
+
if (joined.length === 1)
|
|
159
|
+
return openSession(joined[0].ctx, ready, joined[0].joined, { attach: ctx.options.terminal });
|
|
160
|
+
return openSessions(ctx, ready, joined);
|
|
161
|
+
};
|
|
162
|
+
/** `sandbox start` while one runs: this folder joins it (set up, no agent), or a restart that adds it is offered. */
|
|
163
|
+
const startIntoRunning = async (ctx) => {
|
|
164
|
+
const ready = await readySandbox(ctx.dataPath);
|
|
165
|
+
let joined;
|
|
166
|
+
try {
|
|
167
|
+
joined = await readyHere(ctx, ready);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
if (e instanceof NeedsRestart)
|
|
171
|
+
return offerRestart(ctx, [e], () => startIntoRunning(ctx));
|
|
172
|
+
throw e;
|
|
173
|
+
}
|
|
174
|
+
const where = joined.spec ? ' This folder is ready in it as ' + joined.guestDir + ' (sbx-shell ' + joined.spec.name + ' opens a terminal there inside).' : '';
|
|
175
|
+
console.log('A sandbox is already running' + (showSandboxWindow(ctx.storageRoot) ? '; its window is in front now.' : '.') + where + ' Start an agent in it with sandbox claude (or sandbox <agent>); stop it with sandbox stop.');
|
|
176
|
+
return 0;
|
|
177
|
+
};
|
|
60
178
|
const syncSummary = (config, dataPath, workspaceHost) => {
|
|
61
179
|
try {
|
|
62
180
|
const s = syncBeforeLaunch(config, dataPath, workspaceHost);
|
|
@@ -66,6 +184,63 @@ const syncSummary = (config, dataPath, workspaceHost) => {
|
|
|
66
184
|
return 'FAILED: ' + errMsg(e);
|
|
67
185
|
}
|
|
68
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* Asked once per parent folder: map it at every start (a project root), so the projects next to this one open in the
|
|
189
|
+
* running sandbox without a restart. The answer is saved to your config.
|
|
190
|
+
*/
|
|
191
|
+
const maybeAddRoot = async (ctx, run) => {
|
|
192
|
+
const { projects } = run.config;
|
|
193
|
+
const parent = path.dirname(run.workspaceHost);
|
|
194
|
+
if (!projects.askToAddRoot || ctx.options.yes || !process.stdin.isTTY || !process.stdout.isTTY)
|
|
195
|
+
return;
|
|
196
|
+
if (projects.roots.some((r) => isWithin(r, run.workspaceHost)) || projects.declinedRoots.some((d) => isWithin(d, parent) && isWithin(parent, d)))
|
|
197
|
+
return;
|
|
198
|
+
if (isRootPath(parent))
|
|
199
|
+
return;
|
|
200
|
+
try {
|
|
201
|
+
assertSafeWorkspace(parent, ctx.packageRoot, run.storageRoot);
|
|
202
|
+
assertSafeMapping(parent, ctx.packageRoot, run.storageRoot);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const answer = await select({
|
|
208
|
+
message: 'Map ' + parent + ' at every start, so other projects there (also new ones) open in the running sandbox without a restart? Agents in the sandbox can then see every project in it.',
|
|
209
|
+
choices: [
|
|
210
|
+
{ name: 'Yes, from now on', value: 'yes' },
|
|
211
|
+
{ name: 'No (and do not ask again for this folder)', value: 'no' },
|
|
212
|
+
{ name: 'Never ask this again', value: 'never' },
|
|
213
|
+
],
|
|
214
|
+
});
|
|
215
|
+
if (answer === 'yes') {
|
|
216
|
+
addToList(ctx, ['projects', 'roots'], parent);
|
|
217
|
+
run.config.projects.roots.push(parent);
|
|
218
|
+
console.log('Added ' + parent + ' to projects.roots (sandbox projects roots remove ' + parent + ' undoes it).');
|
|
219
|
+
}
|
|
220
|
+
if (answer === 'no')
|
|
221
|
+
addToList(ctx, ['projects', 'declinedRoots'], parent);
|
|
222
|
+
if (answer === 'never')
|
|
223
|
+
setSetting(ctx, ['projects', 'askToAddRoot'], false);
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* workspaceFilter: brings the project's filtered view in step before the sandbox maps it, and tells the background
|
|
227
|
+
* watcher to keep it in step while the sandbox runs. Returns the line for the launch table.
|
|
228
|
+
*/
|
|
229
|
+
const prepareWorkspaceView = async (ctx, run) => {
|
|
230
|
+
const plan = planView(run.config, ctx.storageRoot, run.workspaceHost);
|
|
231
|
+
saveActiveViews(ctx.storageRoot, ctx.dataPath, plan ? [plan.options] : []);
|
|
232
|
+
saveForwards(ctx.storageRoot, ctx.dataPath, run.config.sandbox.networking ? run.config.network.forwardPorts : []);
|
|
233
|
+
saveAuditSettings(ctx.storageRoot, ctx.dataPath, { ...run.config.audit, projects: [run.workspaceHost] });
|
|
234
|
+
saveMarkedProjects(ctx.storageRoot, ctx.dataPath, run.config.storage.markSandboxFiles ? [run.workspaceHost] : []);
|
|
235
|
+
const size = readDataSize(ctx.storageRoot, ctx.dataPath);
|
|
236
|
+
const limit = run.config.storage.warnDataGb;
|
|
237
|
+
if (limit > 0 && size && size.bytes > limit * 1024 ** 3)
|
|
238
|
+
console.warn(c.yellow('The persisted data takes ' + humanBytes(size.bytes) + ' (more than storage.warnDataGb, ' + limit + ' GB). See what: sandbox data; free space: sandbox data clean <what>.'));
|
|
239
|
+
if (!plan)
|
|
240
|
+
return viewSkipped(run.config, run.workspaceHost) ?? 'off (git-ignored files are visible in the sandbox; workspaceFilter.enabled keeps them out)';
|
|
241
|
+
const stats = await working('Preparing the workspace without its git-ignored files', () => new WorkspaceView(plan.options).prepare());
|
|
242
|
+
return 'on: git-ignored files stay on this PC' + (stats.toView || stats.toHost ? ' (' + stats.toView + ' copied in, ' + stats.toHost + ' out' + (stats.conflicts ? ', ' + stats.conflicts + ' conflicts kept next to the file' : '') + ')' : '') + '; ' + plan.options.view;
|
|
243
|
+
};
|
|
69
244
|
/** Everything a real launch does before the sandbox starts (skipped by `generate`, which only writes files). */
|
|
70
245
|
const prepare = async (ctx, run) => {
|
|
71
246
|
const { options, dataPath, storageRoot } = ctx;
|
|
@@ -74,25 +249,48 @@ const prepare = async (ctx, run) => {
|
|
|
74
249
|
if (account && run.harnessName === 'claude' && account !== activeAccount(dataPath))
|
|
75
250
|
activateAccount(storageRoot, dataPath, account);
|
|
76
251
|
const terminal = config.provisioning.terminal.enabled ? await ensureTerminal(dataPath, config.provisioning.refresh, { pwsh: config.toolchains.pwsh.enabled !== false }) : { exe: null, message: 'disabled' };
|
|
252
|
+
const conpty = config.provisioning.conpty.enabled ? await ensureConpty(dataPath, config.provisioning.refresh) : 'off';
|
|
77
253
|
const history = syncSummary(config, dataPath, run.workspaceHost);
|
|
78
254
|
const guarded = checkRepo(dataPath);
|
|
79
255
|
if (guarded.length)
|
|
80
|
-
console.warn('
|
|
81
|
-
|
|
256
|
+
console.warn(c.yellow('SECURITY: neutralised ' + guarded.length + ' change(s) the last sandbox made that could run code on this PC (see sandbox status).'));
|
|
257
|
+
const stopped = lastStopWarning(storageRoot, dataPath, watcherRunning(dataPath));
|
|
258
|
+
if (stopped)
|
|
259
|
+
console.warn(c.yellow(stopped));
|
|
260
|
+
if (updateRestartPending())
|
|
261
|
+
console.warn(c.yellow(UPDATE_RESTART_WARNING));
|
|
82
262
|
resetRunDir(dataPath);
|
|
83
|
-
|
|
263
|
+
const filter = await prepareWorkspaceView(ctx, run);
|
|
264
|
+
return { account, terminal: terminal.message + '; pseudo console: ' + conpty, history, pruned: describePrune(pruneStorage(storageRoot)), filter };
|
|
84
265
|
};
|
|
85
|
-
export const launch = async (ctx, generateOnly = false) => {
|
|
266
|
+
export const launch = async (ctx, generateOnly = false, extras = {}) => {
|
|
86
267
|
const { options, loaded, packageRoot, dataPath, storageRoot } = ctx;
|
|
87
268
|
// attach.auto: an agent started from an interactive terminal attaches it, as with -t.
|
|
88
269
|
if (loaded.config.attach.auto && !options.noAgent && process.stdin.isTTY && process.stdout.isTTY)
|
|
89
270
|
options.terminal = true;
|
|
90
|
-
if (!generateOnly
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
271
|
+
if (!generateOnly)
|
|
272
|
+
requireOnPc('launch');
|
|
273
|
+
// agentCommands (Beta) follows the config: a setting changed in the file takes effect here too. Never blocks a launch.
|
|
274
|
+
if (!generateOnly) {
|
|
275
|
+
try {
|
|
276
|
+
syncAgentCommands(ctx, loaded.config);
|
|
277
|
+
}
|
|
278
|
+
catch (e) {
|
|
279
|
+
console.warn('Agent commands (Beta): ' + errMsg(e));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (!generateOnly && isSandboxRunning())
|
|
283
|
+
return options.noAgent ? startIntoRunning(ctx) : launchIntoRunning(ctx);
|
|
284
|
+
// Several sessions: the sandbox starts from the first one's folder with the others' folders mapped too, then
|
|
285
|
+
// they all open in it (each project is set up on demand, in parallel). One --session is an ordinary launch.
|
|
286
|
+
const wants = options.sessions;
|
|
287
|
+
if (wants.length === 1)
|
|
288
|
+
return launch(contextFor(ctx, wants[0]), generateOnly, extras);
|
|
289
|
+
if (wants.length > 1) {
|
|
290
|
+
const first = contextFor(ctx, wants[0]);
|
|
291
|
+
const others = _.uniqBy(wants.slice(1).map((w) => w.folder).filter((f) => !isWithin(wants[0].folder, f)), (f) => f.toLowerCase());
|
|
292
|
+
const started = await launch({ ...first, options: { ...first.options, terminal: false } }, generateOnly, { ...extras, extraProjects: [...(extras.extraProjects ?? []), ...others], autoSession: false, waitUntilReady: true });
|
|
293
|
+
return generateOnly || started !== 0 ? started : launchIntoRunning(ctx);
|
|
96
294
|
}
|
|
97
295
|
const run = await resolveRun({
|
|
98
296
|
packageRoot, loaded, cwd: process.cwd(), workspace: options.workspace, harness: options.harness, noAgent: options.noAgent,
|
|
@@ -102,45 +300,61 @@ export const launch = async (ctx, generateOnly = false) => {
|
|
|
102
300
|
const { config } = run;
|
|
103
301
|
if (!generateOnly)
|
|
104
302
|
assertCanLaunch();
|
|
303
|
+
if (!generateOnly && !extras.extraProjects)
|
|
304
|
+
await maybeAddRoot(ctx, run);
|
|
105
305
|
const prepared = generateOnly ? null : await prepare(ctx, run);
|
|
106
|
-
const generated = generateSandbox({ packageRoot, run, harnessArgs: options.passthrough, probe: probeHost(config, run.harnessName) });
|
|
107
|
-
for (const note of run.notes)
|
|
306
|
+
const generated = generateSandbox({ packageRoot, run, harnessArgs: options.passthrough, probe: probeHost(config, run.harnessName), extraProjects: extras.extraProjects, autoSession: extras.autoSession });
|
|
307
|
+
for (const note of [...run.notes, ...generated.projects.notes])
|
|
108
308
|
console.log(note);
|
|
109
309
|
const secretFiles = config.secrets.warnFiles ? findSecretFiles(run.workspaceHost) : [];
|
|
110
|
-
if (secretFiles.length)
|
|
111
|
-
|
|
310
|
+
if (secretFiles.length) {
|
|
311
|
+
const shown = secretFiles.slice(0, 12).join(', ') + (secretFiles.length > 12 ? ', ...' : '');
|
|
312
|
+
console.warn(c.yellow('Heads-up: the agent can read these files in your workspace, which often hold secrets: ' + shown + '. Move real credentials out of the folder (or use test ones). Silence with secrets.warnFiles = false.'));
|
|
313
|
+
}
|
|
314
|
+
const { roots, projects } = generated.projects;
|
|
112
315
|
table([
|
|
113
316
|
['Workspace', run.workspaceHost + ' -> ' + config.guestWorkspace + (config.readOnly ? ' (read-only)' : '')],
|
|
114
|
-
['Agent', run.harnessName + (prepared?.account ? ' (account: ' + prepared.account + ')' : '') + ' Memory: ' + generated.memoryMb + ' MB Network: ' + config.sandbox.networking + (config.sandbox.headless ? ' HEADLESS' : '')],
|
|
317
|
+
['Agent', run.harnessName + (prepared?.account ? ' (account: ' + prepared.account + ')' : '') + ' Memory: ' + generated.memoryMb + ' MB CPU: ' + (config.sandbox.cpuLimit === 'none' ? 'all' : 'max ' + config.sandbox.cpuLimit + '%') + ' Network: ' + config.sandbox.networking + (config.sandbox.headless ? ' HEADLESS' : '')],
|
|
115
318
|
['Node', run.versions.node.spec + ' (' + run.versions.node.source + ') Python: ' + run.versions.python.spec + ' (' + run.versions.python.source + ')'],
|
|
116
|
-
...(prepared ? [['Terminal', prepared.terminal], ['History', prepared.history], ['Cleanup', prepared.pruned]] : []),
|
|
319
|
+
...(prepared ? [['Ignored files', prepared.filter], ['Terminal', prepared.terminal], ['History', prepared.history], ['Cleanup', prepared.pruned]] : []),
|
|
117
320
|
['Toolchains', Object.entries(generated.toolchains).filter(([, d]) => d.on).map(([name, d]) => name + ' (' + d.reason + ')').join(', ') || 'Node only (nothing else used by this project)'],
|
|
118
321
|
...(generated.databases.length
|
|
119
|
-
? generated.databases.map((d, i) => [i ? '' : 'Databases', d.database + (d.database === 'sqlserver' ? ' (cannot run in the sandbox;
|
|
322
|
+
? generated.databases.map((d, i) => [i ? '' : 'Databases', d.database + (d.database === 'sqlserver' ? ' (cannot run in the sandbox; use Postgres or SQLite for local work)' : ' on port ' + d.port) + ' because ' + d.reasons[0] + (d.reasons.length > 1 ? ' (+' + (d.reasons.length - 1) + ' more)' : '')])
|
|
120
323
|
: [['Databases', 'none needed (databases.<name>.enabled = true adds one)']]),
|
|
121
324
|
['Desktop', generated.personalization],
|
|
122
325
|
['Claude', generated.profile.staged.length ? generated.profile.staged.join(', ') + (generated.profile.credentials ? ' (INCLUDING YOUR LOGIN)' : '') : 'no settings copied'],
|
|
123
326
|
['Secrets', !config.secrets.strip ? 'NOT stripped (secrets.strip is off)' : generated.profile.secretsRemoved.length ? 'kept on this PC: ' + generated.profile.secretsRemoved.join(', ') + ' (secrets.allow lets one through)' : 'none found in what is copied'],
|
|
124
|
-
...
|
|
327
|
+
...roots.map((r, i) => [i ? '' : 'Project roots', r.host + ' -> ' + r.guest + ' (every project in it opens without a restart)']),
|
|
328
|
+
...projects.map((p, i) => [i ? '' : 'Projects', p.host + ' -> ' + p.guest]),
|
|
329
|
+
...generated.mappings.slice(3).filter((m) => ![...roots, ...projects].some((p) => p.guest === m.guest)).map((m) => [' map ' + (m.readOnly ? 'ro' : 'rw'), m.host + ' -> ' + m.guest]),
|
|
125
330
|
['Generated', generated.wsbPath],
|
|
126
331
|
]);
|
|
127
332
|
if (generateOnly)
|
|
128
333
|
return 0;
|
|
334
|
+
// Every folder the sandbox can write is snapshotted before it starts (the guard compares against this), and the
|
|
335
|
+
// projects it starts with are recorded host-side for the commands that run later.
|
|
336
|
+
saveRepoSnapshot(dataPath, run.workspaceHost, projects.map((p) => p.host), roots.map((r) => r.host));
|
|
337
|
+
startRegistry(storageRoot, { launchId: generated.launchId, protections: protectionsOf(config), primary: { host: run.workspaceHost, guest: config.guestWorkspace }, roots, boot: projects });
|
|
338
|
+
rememberProject(storageRoot, run.workspaceHost);
|
|
339
|
+
startLife(storageRoot, dataPath, config.sandbox.keepAwake);
|
|
129
340
|
startSandbox(generated.wsbPath);
|
|
130
341
|
// Absolute: the watcher runs from another folder, and a relative --config there would make it exit silently.
|
|
131
342
|
if (!watcherRunning(dataPath))
|
|
132
343
|
spawnDetached(ctx.entry, ['_watch', ...(options.config ? ['--config', path.resolve(options.config)] : [])]);
|
|
133
344
|
// Hiding runs alongside; a failure to find the window must never break the launch or an attach.
|
|
134
345
|
const hidden = config.sandbox.headless ? hideSandboxWindow(storageRoot).catch(() => false) : null;
|
|
135
|
-
if (options.terminal || options.noAgent) {
|
|
136
|
-
|
|
137
|
-
|
|
346
|
+
if (options.terminal || options.noAgent || extras.waitUntilReady) {
|
|
347
|
+
if (firstBoot(dataPath))
|
|
348
|
+
console.log(FIRST_BOOT);
|
|
349
|
+
await waitForBoot(dataPath, generated.launchId);
|
|
350
|
+
if (extras.waitUntilReady)
|
|
351
|
+
return 0;
|
|
138
352
|
// Without an agent there is no session to attach to: the sandbox itself is the result.
|
|
139
353
|
if (options.noAgent) {
|
|
140
354
|
console.log('Sandbox ready. Its window has a terminal in ' + config.guestWorkspace + '; from here: sandbox exec -- <command>, sandbox stop.');
|
|
141
355
|
return 0;
|
|
142
356
|
}
|
|
143
|
-
return attachHere(ctx, await
|
|
357
|
+
return attachHere(ctx, await waitForStart(ctx, generated.launchId, 'Starting ' + run.harnessName));
|
|
144
358
|
}
|
|
145
359
|
if (firstBoot(dataPath))
|
|
146
360
|
console.log(FIRST_BOOT);
|
|
@@ -6,3 +6,5 @@ export declare const config: (ctx: Context) => number;
|
|
|
6
6
|
export declare const doctor: (ctx: Context) => number;
|
|
7
7
|
export declare const claudeHost: (ctx: Context) => number;
|
|
8
8
|
export declare const watcher: (ctx: Context) => Promise<void>;
|
|
9
|
+
/** `sandbox audit`: the audit log of the last days (audit.enabled), newest last. */
|
|
10
|
+
export declare const audit: (ctx: Context) => Promise<number>;
|
|
@@ -5,12 +5,17 @@ import { pathToFileURL } from 'node:url';
|
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import { DEFAULTS, userConfigPath, userDir } from '../../core/config.js';
|
|
7
7
|
import { describeOverrides, isTrusted, LOCAL_CONFIG_NAME, normalizeOverrides, readLocalConfig, trustStorePath } from '../../core/local-config.js';
|
|
8
|
-
import { fail, safeText, sleep, writeJson } from '../../core/util.js';
|
|
8
|
+
import { assertNoLinks, expandPath, fail, plainText, safeText, sleep, writeJson } from '../../core/util.js';
|
|
9
|
+
import { humanBytes } from '../../core/disk.js';
|
|
10
|
+
import { AuditLog } from '../../host/audit/log.js';
|
|
11
|
+
import { readKnown, readRegistry } from '../../host/projects.js';
|
|
12
|
+
import { detectWsb } from '../../host/wsb.js';
|
|
9
13
|
import { describePrune, pruneStorage } from '../../host/cleanup.js';
|
|
10
|
-
import { doctorRows, hostClaude, isSandboxRunning } from '../../host/platform.js';
|
|
14
|
+
import { doctorRows, hostClaude, insideSandbox, isSandboxRunning } from '../../host/platform.js';
|
|
11
15
|
import { readSandboxStatus } from '../../shared/rundir.js';
|
|
12
16
|
import { syncBack, watch } from '../../sync/watcher.js';
|
|
13
|
-
import { table } from './context.js';
|
|
17
|
+
import { printJson, table } from './context.js';
|
|
18
|
+
import { c } from '../colors.js';
|
|
14
19
|
export const sync = (ctx) => {
|
|
15
20
|
const running = isSandboxRunning();
|
|
16
21
|
const result = syncBack(ctx.dataPath, !running);
|
|
@@ -26,6 +31,8 @@ const newestLog = (dir) => {
|
|
|
26
31
|
};
|
|
27
32
|
export const logs = async (ctx) => {
|
|
28
33
|
const dir = path.join(ctx.dataPath, 'logs');
|
|
34
|
+
// The sandbox writes this folder: never read through a link it planted there.
|
|
35
|
+
assertNoLinks(ctx.dataPath, dir);
|
|
29
36
|
const file = newestLog(dir) ?? fail('No sandbox logs yet in ' + dir + '.', 'Logs appear after the first start (sandbox claude).');
|
|
30
37
|
console.log('== ' + file + ' ==');
|
|
31
38
|
let printed = 0;
|
|
@@ -44,6 +51,8 @@ export const logs = async (ctx) => {
|
|
|
44
51
|
printed = from + buffer.length;
|
|
45
52
|
};
|
|
46
53
|
print();
|
|
54
|
+
if (ctx.options.follow)
|
|
55
|
+
console.error('(following; Ctrl+C to stop)');
|
|
47
56
|
while (ctx.options.follow) {
|
|
48
57
|
await sleep(1000);
|
|
49
58
|
print();
|
|
@@ -103,8 +112,17 @@ const checkLocalConfig = (ctx) => {
|
|
|
103
112
|
return 0;
|
|
104
113
|
};
|
|
105
114
|
export const config = (ctx) => {
|
|
106
|
-
const [action = '
|
|
115
|
+
const [action = 'summary'] = ctx.options.positionals;
|
|
107
116
|
switch (action) {
|
|
117
|
+
case 'summary':
|
|
118
|
+
table([
|
|
119
|
+
['Settings file', ctx.loaded.configPath ?? userConfigPath() + ' (does not exist yet; sandbox config init creates it)'],
|
|
120
|
+
['Default agent', ctx.loaded.config.defaultHarness],
|
|
121
|
+
['Storage', ctx.storageRoot],
|
|
122
|
+
['Memory', String(ctx.loaded.config.sandbox.memoryMb) + (ctx.loaded.config.sandbox.memoryMb === 'auto' ? '' : ' MB')],
|
|
123
|
+
]);
|
|
124
|
+
console.log('\nChange settings in the menu (sandbox > Settings). All of them as JSON: sandbox config show');
|
|
125
|
+
return 0;
|
|
108
126
|
case 'path':
|
|
109
127
|
console.log(ctx.loaded.configPath ?? userConfigPath() + ' (does not exist yet)');
|
|
110
128
|
return 0;
|
|
@@ -118,8 +136,52 @@ export const config = (ctx) => {
|
|
|
118
136
|
}
|
|
119
137
|
};
|
|
120
138
|
export const doctor = (ctx) => {
|
|
121
|
-
|
|
139
|
+
const rows = doctorRows(ctx.loaded.config, ctx.options.harness ?? ctx.loaded.config.defaultHarness, ctx.storageRoot, ctx.loaded.configPath);
|
|
140
|
+
// Inside a sandbox the feature and "running" rows describe the sandbox itself, and the host rows describe nothing useful.
|
|
141
|
+
if (insideSandbox()) {
|
|
142
|
+
table([['Where', 'inside a Windows Sandbox started by this tool (run doctor on your PC to check the PC)'], ...rows.filter(([name]) => name === 'Config file')]);
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
// Several projects: the roots mapped at every start, what the running sandbox has, and whether wsb share is there.
|
|
146
|
+
const p = ctx.loaded.config.projects;
|
|
147
|
+
const registry = isSandboxRunning() ? readRegistry(ctx.storageRoot) : null;
|
|
148
|
+
const wsb = p.wsbShare ? detectWsb() : null;
|
|
149
|
+
table([
|
|
150
|
+
...rows,
|
|
151
|
+
['Project roots', p.roots.length ? p.roots.map((r) => expandPath(r, ctx.loaded.base)).join(', ') : 'none (sandbox projects roots add <folder>)'],
|
|
152
|
+
['All projects', p.all ? 'on: ' + readKnown(ctx.storageRoot).length + ' known project(s) mapped at every start (' + p.exclude.length + ' excluded)' : 'off'],
|
|
153
|
+
['Projects running', registry ? registry.projects.map((x) => x.name + ' (' + x.mechanism + ')').join(', ') : '-'],
|
|
154
|
+
['wsb share', !p.wsbShare ? 'off (projects.wsbShare)' : wsb ? 'available: ' + wsb.exe + (wsb.version ? ' ' + wsb.version : '') + ' (untested; a failure offers a restart instead)' : 'not on this Windows (needs Windows 11 24H2+ with the updated Windows Sandbox): folders outside your roots need a restart'],
|
|
155
|
+
]);
|
|
122
156
|
return 0;
|
|
123
157
|
};
|
|
124
158
|
export const claudeHost = (ctx) => hostClaude(ctx.storageRoot, ctx.options.personal, ctx.options.passthrough);
|
|
125
159
|
export const watcher = (ctx) => watch(ctx.dataPath);
|
|
160
|
+
const KINDS = ['proc', 'file', 'session', 'guard', 'note'];
|
|
161
|
+
const KIND_LABEL = { proc: 'program', file: 'file', session: 'session', guard: 'GUARD', note: 'note' };
|
|
162
|
+
/** `sandbox audit`: the audit log of the last days (audit.enabled), newest last. */
|
|
163
|
+
export const audit = async (ctx) => {
|
|
164
|
+
const settings = ctx.loaded.config.audit;
|
|
165
|
+
const kind = ctx.options.kind;
|
|
166
|
+
if (kind && !KINDS.includes(kind))
|
|
167
|
+
fail('Unknown kind "' + kind + '".', 'Use one of: ' + KINDS.join(', '));
|
|
168
|
+
const log = new AuditLog(AuditLog.dirFor(ctx.storageRoot, ctx.dataPath), settings);
|
|
169
|
+
const events = log.read({ days: ctx.options.days, kinds: kind ? [kind] : undefined, grep: ctx.options.grep });
|
|
170
|
+
if (printJson(ctx, events))
|
|
171
|
+
return 0;
|
|
172
|
+
if (!events.length) {
|
|
173
|
+
console.log(settings.enabled ? 'Nothing in the audit log for the last ' + ctx.options.days + ' day(s).' : 'The audit log is off. Turn it on in the menu (Settings > Security & privacy > Audit log) or with audit.enabled in your config.');
|
|
174
|
+
return 0;
|
|
175
|
+
}
|
|
176
|
+
for (const e of events) {
|
|
177
|
+
// What the sandbox reported is text from the sandbox: no control codes reach your terminal.
|
|
178
|
+
const [p, cmd, parent, dir, act] = [e.p, e.c, e.pp, e.w, e.a].map((v) => plainText(v ?? ''));
|
|
179
|
+
const what = e.k === 'proc' ? (cmd || p) + (parent ? c.dim(' <- ' + path.win32.basename(parent)) : '')
|
|
180
|
+
: e.k === 'file' ? act + ' ' + p + c.dim(' in ' + dir)
|
|
181
|
+
: e.k === 'session' ? act + ' ' + p + c.dim(' ' + dir + ' ' + cmd)
|
|
182
|
+
: p;
|
|
183
|
+
console.log(c.dim(new Date(e.t).toLocaleString()) + ' ' + (e.k === 'guard' ? c.yellow(KIND_LABEL[e.k].padEnd(8)) : KIND_LABEL[e.k].padEnd(8)) + what + (e.n && e.n > 1 ? c.dim(' x' + e.n) : ''));
|
|
184
|
+
}
|
|
185
|
+
console.log(c.dim('\n' + events.length + ' event(s); the log takes ' + humanBytes(log.bytes()) + ' (' + AuditLog.dirFor(ctx.storageRoot, ctx.dataPath) + ').'));
|
|
186
|
+
return 0;
|
|
187
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SandboxStatus } from '../../core/types.js';
|
|
2
|
+
import { type RegistryEntry } from '../../host/projects.js';
|
|
3
|
+
import type { ProjectSpecT } from '../../shared/schema.js';
|
|
4
|
+
import { type Context } from './context.js';
|
|
5
|
+
/** The folder the command is about: --workspace, else the current one. */
|
|
6
|
+
export declare const hereDir: (ctx: Context) => string;
|
|
7
|
+
export interface Located {
|
|
8
|
+
project: RegistryEntry | null;
|
|
9
|
+
guestDir: string | null;
|
|
10
|
+
}
|
|
11
|
+
/** Where this folder is in the running sandbox, if it is in it at all (nothing is registered). */
|
|
12
|
+
export declare const locateHere: (ctx: Context, status: SandboxStatus | null) => Located;
|
|
13
|
+
export interface Joined {
|
|
14
|
+
project: RegistryEntry | null;
|
|
15
|
+
guestDir: string;
|
|
16
|
+
spec: ProjectSpecT | null;
|
|
17
|
+
harness: string | null;
|
|
18
|
+
notes: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Makes this folder a project of the running sandbox (nothing to do for the launch folder and projects already in
|
|
22
|
+
* it): its .sandbox-config.json is approved like at a launch, its protections are checked, and it is made visible.
|
|
23
|
+
* Throws NeedsRestart (host/projects.ts) when that is impossible without a restart.
|
|
24
|
+
*/
|
|
25
|
+
export declare const joinHere: (ctx: Context, status: SandboxStatus) => Promise<Joined>;
|
|
26
|
+
/** Waits until the sandbox has set a project up, with its progress on a spinner (plain lines without a terminal). */
|
|
27
|
+
export declare const provisionJoined: (ctx: Context, joined: Joined) => Promise<void>;
|
|
28
|
+
/** joinHere, then (for another project) waits until the sandbox has set it up. */
|
|
29
|
+
export declare const readyHere: (ctx: Context, status: SandboxStatus) => Promise<Joined>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Which project of the running sandbox a command is run from. Every command that works on a running sandbox uses
|
|
2
|
+
// these, so they all agree: `locateHere` only looks (attach, sessions, status, restart), `joinHere` also makes the
|
|
3
|
+
// folder a project of the running sandbox when it can without a restart (launch, start, exec, db).
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { askYesNo } from '../../core/prompt.js';
|
|
6
|
+
import { isInsideOrEqual } from '../../core/util.js';
|
|
7
|
+
import { resolveRun } from '../../core/workspace.js';
|
|
8
|
+
import { prepareProject } from '../../host/channel.js';
|
|
9
|
+
import { projectHere, readRegistry } from '../../host/projects.js';
|
|
10
|
+
import { joinRunning } from '../../host/join.js';
|
|
11
|
+
import { working } from '../progress.js';
|
|
12
|
+
import { guestPathFor, sandboxAlive } from './context.js';
|
|
13
|
+
/** The folder the command is about: --workspace, else the current one. */
|
|
14
|
+
export const hereDir = (ctx) => path.resolve(ctx.options.workspace ?? process.cwd());
|
|
15
|
+
/** Where this folder is in the running sandbox, if it is in it at all (nothing is registered). */
|
|
16
|
+
export const locateHere = (ctx, status) => {
|
|
17
|
+
const dir = hereDir(ctx);
|
|
18
|
+
const here = projectHere(ctx.storageRoot, dir);
|
|
19
|
+
if (here)
|
|
20
|
+
return here;
|
|
21
|
+
// A sandbox started before projects existed: only its launch folder.
|
|
22
|
+
if (!readRegistry(ctx.storageRoot) && status && isInsideOrEqual(status.workspaceHost, dir))
|
|
23
|
+
return { project: null, guestDir: guestPathFor(dir, status.workspaceHost, status.guestWorkspace) };
|
|
24
|
+
return { project: null, guestDir: null };
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Makes this folder a project of the running sandbox (nothing to do for the launch folder and projects already in
|
|
28
|
+
* it): its .sandbox-config.json is approved like at a launch, its protections are checked, and it is made visible.
|
|
29
|
+
* Throws NeedsRestart (host/projects.ts) when that is impossible without a restart.
|
|
30
|
+
*/
|
|
31
|
+
export const joinHere = async (ctx, status) => {
|
|
32
|
+
const { options, loaded, packageRoot, storageRoot, dataPath } = ctx;
|
|
33
|
+
const dir = hereDir(ctx);
|
|
34
|
+
// A sandbox started before projects existed: only its launch folder (guestPathFor explains why otherwise).
|
|
35
|
+
if (!readRegistry(storageRoot))
|
|
36
|
+
return { project: null, guestDir: guestPathFor(dir, status.workspaceHost, status.guestWorkspace), spec: null, harness: null, notes: [] };
|
|
37
|
+
const joined = await joinRunning({
|
|
38
|
+
storageRoot, dataPath, packageRoot, hostDir: dir, wsbShare: loaded.config.projects.wsbShare,
|
|
39
|
+
resolve: (root) => resolveRun({
|
|
40
|
+
packageRoot, loaded, cwd: root, workspace: root, harness: options.harness, noAgent: options.noAgent,
|
|
41
|
+
noLocalConfig: options.noLocalConfig, trustConfig: options.trustConfig, scripts: options.scripts, databases: options.databases,
|
|
42
|
+
nodeVersion: options.node, pythonVersion: options.python, ask: askYesNo,
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
const harness = joined.run && joined.run.harnessName !== 'none' ? joined.run.harnessName : null;
|
|
46
|
+
return { project: joined.project, guestDir: joined.guestDir, spec: joined.spec, harness, notes: joined.notes };
|
|
47
|
+
};
|
|
48
|
+
/** Waits until the sandbox has set a project up, with its progress on a spinner (plain lines without a terminal). */
|
|
49
|
+
export const provisionJoined = async (ctx, joined) => {
|
|
50
|
+
if (!joined.spec)
|
|
51
|
+
return;
|
|
52
|
+
const spec = joined.spec;
|
|
53
|
+
let step = 'starting';
|
|
54
|
+
await working(() => 'Setting up ' + spec.name + ' in the running sandbox: ' + step, () => prepareProject(ctx.dataPath, spec, sandboxAlive, (m) => { step = m; }));
|
|
55
|
+
};
|
|
56
|
+
/** joinHere, then (for another project) waits until the sandbox has set it up. */
|
|
57
|
+
export const readyHere = async (ctx, status) => {
|
|
58
|
+
const joined = await joinHere(ctx, status);
|
|
59
|
+
for (const note of joined.notes)
|
|
60
|
+
console.log(note);
|
|
61
|
+
await provisionJoined(ctx, joined);
|
|
62
|
+
return joined;
|
|
63
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Context } from './context.js';
|
|
2
|
+
interface Row {
|
|
3
|
+
folder: string;
|
|
4
|
+
here: boolean;
|
|
5
|
+
known: boolean;
|
|
6
|
+
root: string | null;
|
|
7
|
+
excluded: boolean;
|
|
8
|
+
mappedAtStart: boolean;
|
|
9
|
+
running: string | null;
|
|
10
|
+
}
|
|
11
|
+
/** Every project worth listing: known ones, the running sandbox's, and this folder. */
|
|
12
|
+
export declare const projectRows: (ctx: Context) => Row[];
|
|
13
|
+
export declare const projects: (ctx: Context) => Promise<number>;
|
|
14
|
+
export {};
|