brosh 0.2.2
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 +181 -0
- package/brosh_brandmark.svg +3 -0
- package/brosh_logo.svg +27 -0
- package/cli_icon.svg +52 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +138 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +618 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +25 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +28 -0
- package/dist/lib.js.map +1 -0
- package/dist/mode-selector.d.ts +7 -0
- package/dist/mode-selector.d.ts.map +1 -0
- package/dist/mode-selector.js +138 -0
- package/dist/mode-selector.js.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +79 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/recording/index.d.ts +4 -0
- package/dist/recording/index.d.ts.map +1 -0
- package/dist/recording/index.js +3 -0
- package/dist/recording/index.js.map +1 -0
- package/dist/recording/manager.d.ts +62 -0
- package/dist/recording/manager.d.ts.map +1 -0
- package/dist/recording/manager.js +123 -0
- package/dist/recording/manager.js.map +1 -0
- package/dist/recording/recorder.d.ts +95 -0
- package/dist/recording/recorder.d.ts.map +1 -0
- package/dist/recording/recorder.js +330 -0
- package/dist/recording/recorder.js.map +1 -0
- package/dist/recording/types.d.ts +65 -0
- package/dist/recording/types.d.ts.map +1 -0
- package/dist/recording/types.js +2 -0
- package/dist/recording/types.js.map +1 -0
- package/dist/sandbox/ModeSelector.d.ts +2 -0
- package/dist/sandbox/ModeSelector.d.ts.map +1 -0
- package/dist/sandbox/ModeSelector.js +2 -0
- package/dist/sandbox/ModeSelector.js.map +1 -0
- package/dist/sandbox/config.d.ts +46 -0
- package/dist/sandbox/config.d.ts.map +1 -0
- package/dist/sandbox/config.js +144 -0
- package/dist/sandbox/config.js.map +1 -0
- package/dist/sandbox/controller.d.ts +72 -0
- package/dist/sandbox/controller.d.ts.map +1 -0
- package/dist/sandbox/controller.js +208 -0
- package/dist/sandbox/controller.js.map +1 -0
- package/dist/sandbox/index.d.ts +6 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +4 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/mode-prompt.d.ts +10 -0
- package/dist/sandbox/mode-prompt.d.ts.map +1 -0
- package/dist/sandbox/mode-prompt.js +130 -0
- package/dist/sandbox/mode-prompt.js.map +1 -0
- package/dist/sandbox/prompt.d.ts +10 -0
- package/dist/sandbox/prompt.d.ts.map +1 -0
- package/dist/sandbox/prompt.js +434 -0
- package/dist/sandbox/prompt.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +59 -0
- package/dist/server.js.map +1 -0
- package/dist/terminal/index.d.ts +5 -0
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +3 -0
- package/dist/terminal/index.js.map +1 -0
- package/dist/terminal/manager.d.ts +153 -0
- package/dist/terminal/manager.d.ts.map +1 -0
- package/dist/terminal/manager.js +276 -0
- package/dist/terminal/manager.js.map +1 -0
- package/dist/terminal/session.d.ts +137 -0
- package/dist/terminal/session.d.ts.map +1 -0
- package/dist/terminal/session.js +752 -0
- package/dist/terminal/session.js.map +1 -0
- package/dist/tools/definitions.d.ts +18 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +114 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/getContent.d.ts +32 -0
- package/dist/tools/getContent.d.ts.map +1 -0
- package/dist/tools/getContent.js +38 -0
- package/dist/tools/getContent.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +49 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/screenshot.d.ts +20 -0
- package/dist/tools/screenshot.d.ts.map +1 -0
- package/dist/tools/screenshot.js +28 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/sendKey.d.ts +31 -0
- package/dist/tools/sendKey.d.ts.map +1 -0
- package/dist/tools/sendKey.js +38 -0
- package/dist/tools/sendKey.js.map +1 -0
- package/dist/tools/startRecording.d.ts +68 -0
- package/dist/tools/startRecording.d.ts.map +1 -0
- package/dist/tools/startRecording.js +111 -0
- package/dist/tools/startRecording.js.map +1 -0
- package/dist/tools/stopRecording.d.ts +31 -0
- package/dist/tools/stopRecording.d.ts.map +1 -0
- package/dist/tools/stopRecording.js +76 -0
- package/dist/tools/stopRecording.js.map +1 -0
- package/dist/tools/type.d.ts +31 -0
- package/dist/tools/type.d.ts.map +1 -0
- package/dist/tools/type.js +31 -0
- package/dist/tools/type.js.map +1 -0
- package/dist/transport/gui-protocol.d.ts +163 -0
- package/dist/transport/gui-protocol.d.ts.map +1 -0
- package/dist/transport/gui-protocol.js +68 -0
- package/dist/transport/gui-protocol.js.map +1 -0
- package/dist/transport/gui-stream.d.ts +139 -0
- package/dist/transport/gui-stream.d.ts.map +1 -0
- package/dist/transport/gui-stream.js +440 -0
- package/dist/transport/gui-stream.js.map +1 -0
- package/dist/transport/index.d.ts +6 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +6 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/socket.d.ts +46 -0
- package/dist/transport/socket.d.ts.map +1 -0
- package/dist/transport/socket.js +310 -0
- package/dist/transport/socket.js.map +1 -0
- package/dist/types/mcp-client-info.d.ts +226 -0
- package/dist/types/mcp-client-info.d.ts.map +1 -0
- package/dist/types/mcp-client-info.js +62 -0
- package/dist/types/mcp-client-info.js.map +1 -0
- package/dist/ui/index.d.ts +12 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +84 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/utils/env.d.ts +17 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +35 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/keys.d.ts +16 -0
- package/dist/utils/keys.d.ts.map +1 -0
- package/dist/utils/keys.js +155 -0
- package/dist/utils/keys.js.map +1 -0
- package/dist/utils/platform.d.ts +16 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +41 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/session-logger.d.ts +31 -0
- package/dist/utils/session-logger.d.ts.map +1 -0
- package/dist/utils/session-logger.js +125 -0
- package/dist/utils/session-logger.js.map +1 -0
- package/dist/utils/stats.d.ts +46 -0
- package/dist/utils/stats.d.ts.map +1 -0
- package/dist/utils/stats.js +89 -0
- package/dist/utils/stats.js.map +1 -0
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +9 -0
- package/dist/utils/version.js.map +1 -0
- package/logo.png +0 -0
- package/package.json +61 -0
- package/packages/desktop-electron/THIRD-PARTY-NOTICES +56 -0
- package/packages/desktop-electron/build/afterPack.cjs +147 -0
- package/packages/desktop-electron/package-lock.json +10071 -0
- package/packages/desktop-electron/package.json +170 -0
- package/packages/desktop-electron/resources/icons/mac/icon.icns +0 -0
- package/packages/desktop-electron/resources/icons/png/1024x1024.png +0 -0
- package/packages/desktop-electron/resources/icons/png/128x128.png +0 -0
- package/packages/desktop-electron/resources/icons/png/16x16.png +0 -0
- package/packages/desktop-electron/resources/icons/png/24x24.png +0 -0
- package/packages/desktop-electron/resources/icons/png/256x256.png +0 -0
- package/packages/desktop-electron/resources/icons/png/32x32.png +0 -0
- package/packages/desktop-electron/resources/icons/png/48x48.png +0 -0
- package/packages/desktop-electron/resources/icons/png/512x512.png +0 -0
- package/packages/desktop-electron/resources/icons/png/64x64.png +0 -0
- package/packages/desktop-electron/resources/icons/win/icon.ico +0 -0
- package/packages/desktop-electron/scripts/download-models.js +97 -0
- package/packages/desktop-electron/scripts/prepare-sandbox-bins.js +186 -0
- package/packages/desktop-electron/tests/main/ai-detection/additionalFunctions.test.ts +224 -0
- package/packages/desktop-electron/tests/main/ai-detection/checkOverridePrefix.test.ts +162 -0
- package/packages/desktop-electron/tests/main/ai-detection/classifyInput.test.ts +132 -0
- package/packages/desktop-electron/tests/main/ai-detection/detectTypos.test.ts +342 -0
- package/packages/desktop-electron/tests/main/ai-detection/fixtures/commands.ts +134 -0
- package/packages/desktop-electron/tests/main/ai-detection/fixtures/natural-language.ts +133 -0
- package/packages/desktop-electron/tests/main/ai-detection/fixtures/typos.ts +123 -0
- package/packages/desktop-electron/tests/main/ai-detection/hasValidSubcommand.test.ts +218 -0
- package/packages/desktop-electron/tests/main/ai-detection/isCommandNotFound.test.ts +117 -0
- package/packages/desktop-electron/tests/main/error-triage/buildTriagePrompt.test.ts +133 -0
- package/packages/desktop-electron/tests/main/error-triage/parseTriageResponse.test.ts +123 -0
- package/packages/desktop-electron/tests/main/terminal-bridge/battery-optimization.test.ts +243 -0
- package/packages/desktop-electron/tests/main/terminal-bridge/command-fast-track.test.ts +292 -0
- package/packages/desktop-electron/tests/main/terminal-bridge/default-cwd.test.ts +70 -0
- package/packages/desktop-electron/tests/setup.ts +274 -0
- package/packages/desktop-electron/tsconfig.json +18 -0
- package/packages/desktop-electron/tsconfig.main.json +20 -0
- package/packages/desktop-electron/vite.config.ts +19 -0
- package/packages/desktop-electron/vitest.config.ts +18 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SandboxPermissions } from "./config.js";
|
|
2
|
+
export type SandboxPlatform = "darwin" | "linux" | "win32" | "unsupported";
|
|
3
|
+
export interface SandboxStatus {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
platform: SandboxPlatform;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Controller that wraps sandbox-runtime for brosh
|
|
10
|
+
* Manages sandbox lifecycle and command wrapping
|
|
11
|
+
*/
|
|
12
|
+
export declare class SandboxController {
|
|
13
|
+
private initialized;
|
|
14
|
+
private permissions;
|
|
15
|
+
private platform;
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Get the current platform
|
|
19
|
+
*/
|
|
20
|
+
getPlatform(): SandboxPlatform;
|
|
21
|
+
/**
|
|
22
|
+
* Check if sandboxing is supported on this platform
|
|
23
|
+
*/
|
|
24
|
+
isSupported(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if Linux dependencies are available
|
|
27
|
+
*/
|
|
28
|
+
checkLinuxDependencies(): {
|
|
29
|
+
supported: boolean;
|
|
30
|
+
message?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Clean up sandbox artifacts left by previous runs.
|
|
34
|
+
*
|
|
35
|
+
* Workaround for sandbox-runtime bug: when sandbox binds /dev/null to .claude,
|
|
36
|
+
* it leaves a 0-byte file artifact. On the next run, sandbox-runtime tries to
|
|
37
|
+
* create .claude/commands inside this file, which fails with "Not a directory".
|
|
38
|
+
*
|
|
39
|
+
* This removes the .claude artifact if it's a 0-byte file (not a real directory).
|
|
40
|
+
*/
|
|
41
|
+
cleanupSandboxArtifacts(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Convert our permission model to sandbox-runtime config format
|
|
44
|
+
*/
|
|
45
|
+
private toSandboxConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the sandbox with given permissions
|
|
48
|
+
* Returns status indicating whether sandbox is active
|
|
49
|
+
*/
|
|
50
|
+
initialize(permissions: SandboxPermissions): Promise<SandboxStatus>;
|
|
51
|
+
/**
|
|
52
|
+
* Wrap a shell command with sandbox restrictions
|
|
53
|
+
* Returns the wrapped command string to execute
|
|
54
|
+
*/
|
|
55
|
+
wrapShellCommand(shell: string, args: string[]): Promise<{
|
|
56
|
+
cmd: string;
|
|
57
|
+
args: string[];
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Check if sandbox is currently active
|
|
61
|
+
*/
|
|
62
|
+
isActive(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Get current permissions (if initialized)
|
|
65
|
+
*/
|
|
66
|
+
getPermissions(): SandboxPermissions | null;
|
|
67
|
+
/**
|
|
68
|
+
* Cleanup sandbox resources
|
|
69
|
+
*/
|
|
70
|
+
cleanup(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/sandbox/controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAc,MAAM,aAAa,CAAC;AAI7D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,QAAQ,CAAkB;;IAYlC;;OAEG;IACH,WAAW,IAAI,eAAe;IAI9B;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,sBAAsB,IAAI;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAUlE;;;;;;;;OAQG;IACH,uBAAuB,IAAI,IAAI;IAgB/B;;OAEG;IACH,OAAO,CAAC,eAAe;IA6CvB;;;OAGG;IACG,UAAU,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAkDzE;;;OAGG;IACG,gBAAgB,CACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IA2B3C;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,cAAc,IAAI,kBAAkB,GAAG,IAAI;IAI3C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { SandboxManager, } from "@anthropic-ai/sandbox-runtime";
|
|
2
|
+
import { expandPath } from "./config.js";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
/**
|
|
6
|
+
* Controller that wraps sandbox-runtime for brosh
|
|
7
|
+
* Manages sandbox lifecycle and command wrapping
|
|
8
|
+
*/
|
|
9
|
+
export class SandboxController {
|
|
10
|
+
initialized = false;
|
|
11
|
+
permissions = null;
|
|
12
|
+
platform;
|
|
13
|
+
constructor() {
|
|
14
|
+
// Get platform from Node
|
|
15
|
+
const nodePlatform = process.platform;
|
|
16
|
+
if (nodePlatform === "darwin" || nodePlatform === "linux" || nodePlatform === "win32") {
|
|
17
|
+
this.platform = nodePlatform;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.platform = "unsupported";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the current platform
|
|
25
|
+
*/
|
|
26
|
+
getPlatform() {
|
|
27
|
+
return this.platform;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if sandboxing is supported on this platform
|
|
31
|
+
*/
|
|
32
|
+
isSupported() {
|
|
33
|
+
return SandboxManager.isSupportedPlatform();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if Linux dependencies are available
|
|
37
|
+
*/
|
|
38
|
+
checkLinuxDependencies() {
|
|
39
|
+
if (this.platform !== "linux") {
|
|
40
|
+
return { supported: true };
|
|
41
|
+
}
|
|
42
|
+
const depCheck = SandboxManager.checkDependencies();
|
|
43
|
+
const supported = depCheck.errors.length === 0;
|
|
44
|
+
const message = supported ? undefined : depCheck.errors.join("; ");
|
|
45
|
+
return { supported, message };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clean up sandbox artifacts left by previous runs.
|
|
49
|
+
*
|
|
50
|
+
* Workaround for sandbox-runtime bug: when sandbox binds /dev/null to .claude,
|
|
51
|
+
* it leaves a 0-byte file artifact. On the next run, sandbox-runtime tries to
|
|
52
|
+
* create .claude/commands inside this file, which fails with "Not a directory".
|
|
53
|
+
*
|
|
54
|
+
* This removes the .claude artifact if it's a 0-byte file (not a real directory).
|
|
55
|
+
*/
|
|
56
|
+
cleanupSandboxArtifacts() {
|
|
57
|
+
const claudePath = path.join(process.cwd(), ".claude");
|
|
58
|
+
try {
|
|
59
|
+
const stat = fs.statSync(claudePath);
|
|
60
|
+
// If .claude is a file (not directory) and 0 bytes, it's a sandbox artifact
|
|
61
|
+
if (stat.isFile() && stat.size === 0) {
|
|
62
|
+
fs.unlinkSync(claudePath);
|
|
63
|
+
if (process.env.DEBUG_SANDBOX) {
|
|
64
|
+
console.error("[sandbox-debug] Cleaned up .claude artifact (0-byte file from previous sandbox run)");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// File doesn't exist or can't be accessed - that's fine
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Convert our permission model to sandbox-runtime config format
|
|
74
|
+
*/
|
|
75
|
+
toSandboxConfig(permissions) {
|
|
76
|
+
// Expand all paths
|
|
77
|
+
const expandPaths = (paths) => paths.map((p) => expandPath(p));
|
|
78
|
+
// Configure network based on mode
|
|
79
|
+
let allowedDomains;
|
|
80
|
+
let deniedDomains = [];
|
|
81
|
+
switch (permissions.network.mode) {
|
|
82
|
+
case "none":
|
|
83
|
+
// Block all network by using empty allowed list
|
|
84
|
+
allowedDomains = [];
|
|
85
|
+
break;
|
|
86
|
+
case "allowlist":
|
|
87
|
+
allowedDomains = permissions.network.allowedDomains ?? [];
|
|
88
|
+
break;
|
|
89
|
+
case "all":
|
|
90
|
+
default:
|
|
91
|
+
// Allow all network access with wildcard
|
|
92
|
+
allowedDomains = ["*"];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const config = {
|
|
96
|
+
filesystem: {
|
|
97
|
+
// Read/write paths go to allowWrite
|
|
98
|
+
allowWrite: expandPaths(permissions.filesystem.readWrite),
|
|
99
|
+
// Blocked paths go to denyRead (blocks both read and write)
|
|
100
|
+
denyRead: expandPaths(permissions.filesystem.blocked),
|
|
101
|
+
// Read-only paths: we want to allow read but deny write
|
|
102
|
+
// Paths not in allowWrite are read-only by default
|
|
103
|
+
denyWrite: [],
|
|
104
|
+
},
|
|
105
|
+
network: {
|
|
106
|
+
allowedDomains,
|
|
107
|
+
deniedDomains,
|
|
108
|
+
},
|
|
109
|
+
// Enable PTY support since we're spawning a shell
|
|
110
|
+
allowPty: true,
|
|
111
|
+
};
|
|
112
|
+
return config;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Initialize the sandbox with given permissions
|
|
116
|
+
* Returns status indicating whether sandbox is active
|
|
117
|
+
*/
|
|
118
|
+
async initialize(permissions) {
|
|
119
|
+
// Check platform support
|
|
120
|
+
if (!this.isSupported()) {
|
|
121
|
+
return {
|
|
122
|
+
enabled: false,
|
|
123
|
+
platform: this.platform,
|
|
124
|
+
reason: this.platform === "win32"
|
|
125
|
+
? "Sandbox not available on Windows"
|
|
126
|
+
: `Platform ${this.platform} is not supported`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Check Linux dependencies
|
|
130
|
+
if (this.platform === "linux") {
|
|
131
|
+
const depCheck = this.checkLinuxDependencies();
|
|
132
|
+
if (!depCheck.supported) {
|
|
133
|
+
return {
|
|
134
|
+
enabled: false,
|
|
135
|
+
platform: this.platform,
|
|
136
|
+
reason: depCheck.message ?? "Linux sandbox dependencies not available",
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Clean up any sandbox artifacts from previous runs
|
|
141
|
+
// This works around a sandbox-runtime bug where .claude becomes a 0-byte file
|
|
142
|
+
this.cleanupSandboxArtifacts();
|
|
143
|
+
try {
|
|
144
|
+
const config = this.toSandboxConfig(permissions);
|
|
145
|
+
await SandboxManager.initialize(config, undefined, true);
|
|
146
|
+
this.initialized = true;
|
|
147
|
+
this.permissions = permissions;
|
|
148
|
+
return {
|
|
149
|
+
enabled: true,
|
|
150
|
+
platform: this.platform,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
155
|
+
return {
|
|
156
|
+
enabled: false,
|
|
157
|
+
platform: this.platform,
|
|
158
|
+
reason: `Failed to initialize sandbox: ${message}`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Wrap a shell command with sandbox restrictions
|
|
164
|
+
* Returns the wrapped command string to execute
|
|
165
|
+
*/
|
|
166
|
+
async wrapShellCommand(shell, args) {
|
|
167
|
+
if (!this.initialized) {
|
|
168
|
+
throw new Error("Sandbox not initialized");
|
|
169
|
+
}
|
|
170
|
+
// Build the full command string
|
|
171
|
+
const fullCommand = [shell, ...args].join(" ");
|
|
172
|
+
// Wrap with sandbox
|
|
173
|
+
const sandboxedCommand = await SandboxManager.wrapWithSandbox(fullCommand, shell);
|
|
174
|
+
// Debug: log the generated command
|
|
175
|
+
if (process.env.DEBUG_SANDBOX) {
|
|
176
|
+
console.error("[sandbox-debug] Generated command:", sandboxedCommand);
|
|
177
|
+
}
|
|
178
|
+
// The sandboxed command should be executed via shell
|
|
179
|
+
// Return it as a shell -c command
|
|
180
|
+
return {
|
|
181
|
+
cmd: "/bin/sh",
|
|
182
|
+
args: ["-c", sandboxedCommand],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Check if sandbox is currently active
|
|
187
|
+
*/
|
|
188
|
+
isActive() {
|
|
189
|
+
return this.initialized;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get current permissions (if initialized)
|
|
193
|
+
*/
|
|
194
|
+
getPermissions() {
|
|
195
|
+
return this.permissions;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Cleanup sandbox resources
|
|
199
|
+
*/
|
|
200
|
+
async cleanup() {
|
|
201
|
+
if (this.initialized) {
|
|
202
|
+
await SandboxManager.reset();
|
|
203
|
+
this.initialized = false;
|
|
204
|
+
this.permissions = null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/sandbox/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAEf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAsB,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAU7B;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACpB,WAAW,GAAG,KAAK,CAAC;IACpB,WAAW,GAA8B,IAAI,CAAC;IAC9C,QAAQ,CAAkB;IAElC;QACE,yBAAyB;QACzB,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;QACtC,IAAI,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,OAAO,IAAI,YAAY,KAAK,OAAO,EAAE,CAAC;YACtF,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC;QAChC,CAAC;IACH,CAAC;IAED;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AE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,gCAAgC;QAChC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE/C,oBAAoB;QACpB,MAAM,gBAAgB,GAAG,MAAM,cAAc,CAAC,eAAe,CAC3D,WAAW,EACX,KAAK,CACN,CAAC;QAEF,mCAAmC;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YAC9B,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,gBAAgB,CAAC,CAAC;QACxE,CAAC;QAED,qDAAqD;QACrD,kCAAkC;QAClC,OAAO;YACL,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC;SAC/B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { SandboxPermissions, FilesystemPermissions, NetworkPermissions, } from "./config.js";
|
|
2
|
+
export { DEFAULT_PERMISSIONS, loadConfigFromFile, expandPath, mergePermissions, } from "./config.js";
|
|
3
|
+
export type { SandboxPlatform, SandboxStatus, } from "./controller.js";
|
|
4
|
+
export { SandboxController, } from "./controller.js";
|
|
5
|
+
export { promptForPermissions, displayPermissionsSummary, } from "./prompt.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DEFAULT_PERMISSIONS, loadConfigFromFile, expandPath, mergePermissions, } from "./config.js";
|
|
2
|
+
export { SandboxController, } from "./controller.js";
|
|
3
|
+
export { promptForPermissions, displayPermissionsSummary, } from "./prompt.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-prompt.d.ts","sourceRoot":"","sources":["../../src/sandbox/mode-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6BH,KAAK,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEjC;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAmHnD"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mode selection prompt using raw ANSI codes
|
|
3
|
+
*/
|
|
4
|
+
// ANSI escape codes
|
|
5
|
+
const ESC = "\x1b";
|
|
6
|
+
const CURSOR_HIDE = `${ESC}[?25l`;
|
|
7
|
+
const CURSOR_SHOW = `${ESC}[?25h`;
|
|
8
|
+
const CLEAR_SCREEN = `${ESC}[2J`;
|
|
9
|
+
const CURSOR_HOME = `${ESC}[H`;
|
|
10
|
+
const CURSOR_TO = (row, col) => `${ESC}[${row};${col}H`;
|
|
11
|
+
// Colors
|
|
12
|
+
const BOLD = `${ESC}[1m`;
|
|
13
|
+
const DIM = `${ESC}[2m`;
|
|
14
|
+
const RESET = `${ESC}[0m`;
|
|
15
|
+
const GREEN = `${ESC}[32m`;
|
|
16
|
+
const YELLOW = `${ESC}[33m`;
|
|
17
|
+
const GRAY = `${ESC}[90m`;
|
|
18
|
+
const WHITE = `${ESC}[97m`;
|
|
19
|
+
// Box drawing
|
|
20
|
+
const BOX = {
|
|
21
|
+
topLeft: "╭",
|
|
22
|
+
topRight: "╮",
|
|
23
|
+
bottomLeft: "╰",
|
|
24
|
+
bottomRight: "╯",
|
|
25
|
+
horizontal: "─",
|
|
26
|
+
vertical: "│",
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Prompt user to select terminal mode
|
|
30
|
+
*/
|
|
31
|
+
export async function promptForMode() {
|
|
32
|
+
// Check if we can use raw mode
|
|
33
|
+
if (typeof process.stdin.setRawMode !== 'function') {
|
|
34
|
+
return 'direct';
|
|
35
|
+
}
|
|
36
|
+
let selected = 'direct';
|
|
37
|
+
const boxWidth = 42;
|
|
38
|
+
const boxHeight = 8;
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
try {
|
|
41
|
+
process.stdin.setRawMode(true);
|
|
42
|
+
process.stdin.resume();
|
|
43
|
+
process.stdin.setEncoding("utf8");
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
// Can't set raw mode, return default
|
|
47
|
+
resolve('direct');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Get terminal size
|
|
51
|
+
const cols = process.stdout.columns || 80;
|
|
52
|
+
const rows = process.stdout.rows || 24;
|
|
53
|
+
// Calculate center position
|
|
54
|
+
const startCol = Math.max(1, Math.floor((cols - boxWidth) / 2));
|
|
55
|
+
const startRow = Math.max(1, Math.floor((rows - boxHeight) / 2));
|
|
56
|
+
const render = () => {
|
|
57
|
+
const output = [];
|
|
58
|
+
// Clear screen and hide cursor
|
|
59
|
+
output.push(CLEAR_SCREEN + CURSOR_HOME + CURSOR_HIDE);
|
|
60
|
+
// Build the box content
|
|
61
|
+
const lines = [];
|
|
62
|
+
// Title bar
|
|
63
|
+
const title = " Terminal Mode ";
|
|
64
|
+
const titlePadLeft = Math.floor((boxWidth - 2 - title.length) / 2);
|
|
65
|
+
const titlePadRight = boxWidth - 2 - titlePadLeft - title.length;
|
|
66
|
+
lines.push(`${YELLOW}${BOX.topLeft}${BOX.horizontal.repeat(titlePadLeft)}${WHITE}${BOLD}${title}${RESET}${YELLOW}${BOX.horizontal.repeat(titlePadRight)}${BOX.topRight}${RESET}`);
|
|
67
|
+
// Empty line
|
|
68
|
+
lines.push(`${YELLOW}${BOX.vertical}${RESET}${" ".repeat(boxWidth - 2)}${YELLOW}${BOX.vertical}${RESET}`);
|
|
69
|
+
// Standard option
|
|
70
|
+
const stdSelected = selected === 'direct';
|
|
71
|
+
const stdBullet = stdSelected ? `${GREEN}●${RESET}` : `${GRAY}○${RESET}`;
|
|
72
|
+
const stdLabel = stdSelected ? `${WHITE}${BOLD}Standard${RESET}` : `${GRAY}Standard${RESET}`;
|
|
73
|
+
lines.push(`${YELLOW}${BOX.vertical}${RESET} ${stdBullet} ${stdLabel}${" ".repeat(boxWidth - 14)}${YELLOW}${BOX.vertical}${RESET}`);
|
|
74
|
+
// Standard description
|
|
75
|
+
lines.push(`${YELLOW}${BOX.vertical}${RESET} ${DIM}full access to resources${RESET}${" ".repeat(boxWidth - 31)}${YELLOW}${BOX.vertical}${RESET}`);
|
|
76
|
+
// Empty line
|
|
77
|
+
lines.push(`${YELLOW}${BOX.vertical}${RESET}${" ".repeat(boxWidth - 2)}${YELLOW}${BOX.vertical}${RESET}`);
|
|
78
|
+
// Sandboxed option
|
|
79
|
+
const sbxSelected = selected === 'sandbox';
|
|
80
|
+
const sbxBullet = sbxSelected ? `${GREEN}●${RESET}` : `${GRAY}○${RESET}`;
|
|
81
|
+
const sbxLabel = sbxSelected ? `${WHITE}${BOLD}Sandboxed${RESET}` : `${GRAY}Sandboxed${RESET}`;
|
|
82
|
+
lines.push(`${YELLOW}${BOX.vertical}${RESET} ${sbxBullet} ${sbxLabel}${" ".repeat(boxWidth - 15)}${YELLOW}${BOX.vertical}${RESET}`);
|
|
83
|
+
// Sandboxed description
|
|
84
|
+
lines.push(`${YELLOW}${BOX.vertical}${RESET} ${DIM}restricted access with controls${RESET}${" ".repeat(boxWidth - 39)}${YELLOW}${BOX.vertical}${RESET}`);
|
|
85
|
+
// Bottom border
|
|
86
|
+
lines.push(`${YELLOW}${BOX.bottomLeft}${BOX.horizontal.repeat(boxWidth - 2)}${BOX.bottomRight}${RESET}`);
|
|
87
|
+
// Draw each line at the correct position
|
|
88
|
+
for (let i = 0; i < lines.length; i++) {
|
|
89
|
+
output.push(CURSOR_TO(startRow + i, startCol) + lines[i]);
|
|
90
|
+
}
|
|
91
|
+
process.stdout.write(output.join(''));
|
|
92
|
+
};
|
|
93
|
+
const cleanup = () => {
|
|
94
|
+
try {
|
|
95
|
+
process.stdin.setRawMode(false);
|
|
96
|
+
process.stdin.pause();
|
|
97
|
+
process.stdin.removeAllListeners("data");
|
|
98
|
+
process.stdout.write(CLEAR_SCREEN + CURSOR_HOME + CURSOR_SHOW);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Ignore cleanup errors
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const handleKey = (key) => {
|
|
105
|
+
if (key === "\r" || key === "\n") {
|
|
106
|
+
// Enter - confirm
|
|
107
|
+
cleanup();
|
|
108
|
+
resolve(selected);
|
|
109
|
+
}
|
|
110
|
+
else if (key === "\x1b[A" || key === "k" || key === "1") {
|
|
111
|
+
// Up arrow or k or 1
|
|
112
|
+
selected = 'direct';
|
|
113
|
+
render();
|
|
114
|
+
}
|
|
115
|
+
else if (key === "\x1b[B" || key === "j" || key === "2") {
|
|
116
|
+
// Down arrow or j or 2
|
|
117
|
+
selected = 'sandbox';
|
|
118
|
+
render();
|
|
119
|
+
}
|
|
120
|
+
else if (key === "\x03" || key === "q") {
|
|
121
|
+
// Ctrl+C or q - cancel
|
|
122
|
+
cleanup();
|
|
123
|
+
reject(new Error("Cancelled by user"));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
render();
|
|
127
|
+
process.stdin.on("data", handleKey);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=mode-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-prompt.js","sourceRoot":"","sources":["../../src/sandbox/mode-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAoB;AACpB,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,WAAW,GAAG,GAAG,GAAG,OAAO,CAAC;AAClC,MAAM,WAAW,GAAG,GAAG,GAAG,OAAO,CAAC;AAClC,MAAM,YAAY,GAAG,GAAG,GAAG,KAAK,CAAC;AACjC,MAAM,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC;AAC/B,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC;AAExE,SAAS;AACT,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC;AACzB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,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SandboxPermissions } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interactive permission selection prompt
|
|
4
|
+
*/
|
|
5
|
+
export declare function promptForPermissions(): Promise<SandboxPermissions>;
|
|
6
|
+
/**
|
|
7
|
+
* Display a summary of the sandbox permissions
|
|
8
|
+
*/
|
|
9
|
+
export declare function displayPermissionsSummary(permissions: SandboxPermissions): void;
|
|
10
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/sandbox/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAiEjD;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CA+VxE;AAoED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAmB/E"}
|