@anthropic-ai/sandbox-runtime 0.0.1

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.
Files changed (62) hide show
  1. package/README.md +497 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +75 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/sandbox/http-proxy.d.ts +7 -0
  11. package/dist/sandbox/http-proxy.d.ts.map +1 -0
  12. package/dist/sandbox/http-proxy.js +118 -0
  13. package/dist/sandbox/http-proxy.js.map +1 -0
  14. package/dist/sandbox/linux-sandbox-utils.d.ts +60 -0
  15. package/dist/sandbox/linux-sandbox-utils.d.ts.map +1 -0
  16. package/dist/sandbox/linux-sandbox-utils.js +333 -0
  17. package/dist/sandbox/linux-sandbox-utils.js.map +1 -0
  18. package/dist/sandbox/macos-sandbox-utils.d.ts +53 -0
  19. package/dist/sandbox/macos-sandbox-utils.d.ts.map +1 -0
  20. package/dist/sandbox/macos-sandbox-utils.js +496 -0
  21. package/dist/sandbox/macos-sandbox-utils.js.map +1 -0
  22. package/dist/sandbox/sandbox-manager.d.ts +34 -0
  23. package/dist/sandbox/sandbox-manager.d.ts.map +1 -0
  24. package/dist/sandbox/sandbox-manager.js +655 -0
  25. package/dist/sandbox/sandbox-manager.js.map +1 -0
  26. package/dist/sandbox/sandbox-schemas.d.ts +93 -0
  27. package/dist/sandbox/sandbox-schemas.d.ts.map +1 -0
  28. package/dist/sandbox/sandbox-schemas.js +231 -0
  29. package/dist/sandbox/sandbox-schemas.js.map +1 -0
  30. package/dist/sandbox/sandbox-utils.d.ts +49 -0
  31. package/dist/sandbox/sandbox-utils.d.ts.map +1 -0
  32. package/dist/sandbox/sandbox-utils.js +345 -0
  33. package/dist/sandbox/sandbox-utils.js.map +1 -0
  34. package/dist/sandbox/sandbox-violation-store.d.ts +19 -0
  35. package/dist/sandbox/sandbox-violation-store.d.ts.map +1 -0
  36. package/dist/sandbox/sandbox-violation-store.js +54 -0
  37. package/dist/sandbox/sandbox-violation-store.js.map +1 -0
  38. package/dist/sandbox/socks-proxy.d.ts +13 -0
  39. package/dist/sandbox/socks-proxy.d.ts.map +1 -0
  40. package/dist/sandbox/socks-proxy.js +95 -0
  41. package/dist/sandbox/socks-proxy.js.map +1 -0
  42. package/dist/utils/debug.d.ts +7 -0
  43. package/dist/utils/debug.d.ts.map +1 -0
  44. package/dist/utils/debug.js +22 -0
  45. package/dist/utils/debug.js.map +1 -0
  46. package/dist/utils/exec.d.ts +13 -0
  47. package/dist/utils/exec.d.ts.map +1 -0
  48. package/dist/utils/exec.js +38 -0
  49. package/dist/utils/exec.js.map +1 -0
  50. package/dist/utils/platform.d.ts +6 -0
  51. package/dist/utils/platform.d.ts.map +1 -0
  52. package/dist/utils/platform.js +16 -0
  53. package/dist/utils/platform.js.map +1 -0
  54. package/dist/utils/ripgrep.d.ts +16 -0
  55. package/dist/utils/ripgrep.d.ts.map +1 -0
  56. package/dist/utils/ripgrep.js +57 -0
  57. package/dist/utils/ripgrep.js.map +1 -0
  58. package/dist/utils/settings.d.ts +147 -0
  59. package/dist/utils/settings.d.ts.map +1 -0
  60. package/dist/utils/settings.js +244 -0
  61. package/dist/utils/settings.js.map +1 -0
  62. package/package.json +72 -0
@@ -0,0 +1,38 @@
1
+ import { execFile } from 'child_process';
2
+ import { promisify } from 'util';
3
+ const execFilePromise = promisify(execFile);
4
+ /**
5
+ * Simple wrapper around execFile that doesn't throw on non-zero exit codes
6
+ * Simplified version for standalone sandbox use
7
+ */
8
+ export async function execFileNoThrow(file, args, options = {}) {
9
+ try {
10
+ const result = await execFilePromise(file, args, {
11
+ timeout: options.timeout || 10000,
12
+ cwd: options.cwd,
13
+ maxBuffer: 10 * 1024 * 1024, // 10MB
14
+ });
15
+ return {
16
+ stdout: result.stdout,
17
+ stderr: result.stderr,
18
+ code: 0,
19
+ };
20
+ }
21
+ catch (error) {
22
+ // execFile throws on non-zero exit, but we want to return the result
23
+ if (error && typeof error === 'object' && 'code' in error) {
24
+ return {
25
+ stdout: error.stdout || '',
26
+ stderr: error.stderr || '',
27
+ code: typeof error.code === 'number' ? error.code : 1,
28
+ };
29
+ }
30
+ // For other errors (like ENOENT), return error info
31
+ return {
32
+ stdout: '',
33
+ stderr: error instanceof Error ? error.message : String(error),
34
+ code: 1,
35
+ };
36
+ }
37
+ }
38
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAEhC,MAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAE3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,IAAc,EACd,UAA8C,EAAE;IAEhD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE;YAC/C,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;YACjC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,OAAO;SACrC,CAAC,CAAA;QACF,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI,EAAE,CAAC;SACR,CAAA;IACH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,qEAAqE;QACrE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;YAC1D,OAAO;gBACL,MAAM,EAAG,KAA6B,CAAC,MAAM,IAAI,EAAE;gBACnD,MAAM,EAAG,KAA6B,CAAC,MAAM,IAAI,EAAE;gBACnD,IAAI,EAAE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACtD,CAAA;QACH,CAAC;QACD,oDAAoD;QACpD,OAAO;YACL,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC9D,IAAI,EAAE,CAAC;SACR,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Platform detection utilities
3
+ */
4
+ export type Platform = 'macos' | 'linux' | 'windows' | 'unknown';
5
+ export declare function getPlatform(): Platform;
6
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/utils/platform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAEhE,wBAAgB,WAAW,IAAI,QAAQ,CAWtC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Platform detection utilities
3
+ */
4
+ export function getPlatform() {
5
+ switch (process.platform) {
6
+ case 'darwin':
7
+ return 'macos';
8
+ case 'linux':
9
+ return 'linux';
10
+ case 'win32':
11
+ return 'windows';
12
+ default:
13
+ return 'unknown';
14
+ }
15
+ }
16
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/utils/platform.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,UAAU,WAAW;IACzB,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAA;QAChB,KAAK,OAAO;YACV,OAAO,OAAO,CAAA;QAChB,KAAK,OAAO;YACV,OAAO,SAAS,CAAA;QAClB;YACE,OAAO,SAAS,CAAA;IACpB,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Check if ripgrep (rg) is available synchronously
3
+ * Returns true if rg is installed, false otherwise
4
+ * Cached to avoid repeated system calls
5
+ */
6
+ export declare function hasRipgrepSync(): boolean;
7
+ /**
8
+ * Execute ripgrep with the given arguments
9
+ * @param args Command-line arguments to pass to rg
10
+ * @param target Target directory or file to search
11
+ * @param abortSignal AbortSignal to cancel the operation
12
+ * @returns Array of matching lines (one per line of output)
13
+ * @throws Error if ripgrep exits with non-zero status (except exit code 1 which means no matches)
14
+ */
15
+ export declare function ripGrep(args: string[], target: string, abortSignal: AbortSignal): Promise<string[]>;
16
+ //# sourceMappingURL=ripgrep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ripgrep.d.ts","sourceRoot":"","sources":["../../src/utils/ripgrep.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAiBxC;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC,CAgCnB"}
@@ -0,0 +1,57 @@
1
+ import { spawnSync } from 'child_process';
2
+ import { execFile } from 'child_process';
3
+ // Cache for ripgrep availability check
4
+ let ripgrepCache;
5
+ /**
6
+ * Check if ripgrep (rg) is available synchronously
7
+ * Returns true if rg is installed, false otherwise
8
+ * Cached to avoid repeated system calls
9
+ */
10
+ export function hasRipgrepSync() {
11
+ if (ripgrepCache !== undefined) {
12
+ return ripgrepCache;
13
+ }
14
+ try {
15
+ const result = spawnSync('which', ['rg'], {
16
+ stdio: 'ignore',
17
+ timeout: 1000,
18
+ });
19
+ ripgrepCache = result.status === 0;
20
+ return ripgrepCache;
21
+ }
22
+ catch {
23
+ ripgrepCache = false;
24
+ return false;
25
+ }
26
+ }
27
+ /**
28
+ * Execute ripgrep with the given arguments
29
+ * @param args Command-line arguments to pass to rg
30
+ * @param target Target directory or file to search
31
+ * @param abortSignal AbortSignal to cancel the operation
32
+ * @returns Array of matching lines (one per line of output)
33
+ * @throws Error if ripgrep exits with non-zero status (except exit code 1 which means no matches)
34
+ */
35
+ export async function ripGrep(args, target, abortSignal) {
36
+ return new Promise((resolve, reject) => {
37
+ execFile('rg', [...args, target], {
38
+ maxBuffer: 20000000, // 20MB
39
+ signal: abortSignal,
40
+ timeout: 10000, // 10 second timeout
41
+ }, (error, stdout, stderr) => {
42
+ // Success case - exit code 0
43
+ if (!error) {
44
+ resolve(stdout.trim().split('\n').filter(Boolean));
45
+ return;
46
+ }
47
+ // Exit code 1 means "no matches found" - this is normal, return empty array
48
+ if (error.code === 1) {
49
+ resolve([]);
50
+ return;
51
+ }
52
+ // All other errors should fail
53
+ reject(new Error(`ripgrep failed with exit code ${error.code}: ${stderr || error.message}`));
54
+ });
55
+ });
56
+ }
57
+ //# sourceMappingURL=ripgrep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ripgrep.js","sourceRoot":"","sources":["../../src/utils/ripgrep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,uCAAuC;AACvC,IAAI,YAAiC,CAAA;AAErC;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE;YACxC,KAAK,EAAE,QAAQ;YACf,OAA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
+ export declare const FILE_READ_TOOL_NAME = "Read";
5
+ /**
6
+ * Permission rule structure
7
+ */
8
+ export type PermissionRule = {
9
+ toolName: string;
10
+ ruleContent?: string;
11
+ };
12
+ /**
13
+ * Zod schema for sandbox settings
14
+ */
15
+ declare const SandboxSettingsSchema: z.ZodObject<{
16
+ permissions: z.ZodOptional<z.ZodObject<{
17
+ allow: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
18
+ deny: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
19
+ ask: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ allow?: string[] | undefined;
22
+ deny?: string[] | undefined;
23
+ ask?: string[] | undefined;
24
+ }, {
25
+ allow?: string[] | undefined;
26
+ deny?: string[] | undefined;
27
+ ask?: string[] | undefined;
28
+ }>>;
29
+ sandbox: z.ZodOptional<z.ZodObject<{
30
+ network: z.ZodOptional<z.ZodObject<{
31
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
32
+ allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
33
+ httpProxyPort: z.ZodOptional<z.ZodNumber>;
34
+ socksProxyPort: z.ZodOptional<z.ZodNumber>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ allowUnixSockets?: string[] | undefined;
37
+ allowLocalBinding?: boolean | undefined;
38
+ httpProxyPort?: number | undefined;
39
+ socksProxyPort?: number | undefined;
40
+ }, {
41
+ allowUnixSockets?: string[] | undefined;
42
+ allowLocalBinding?: boolean | undefined;
43
+ httpProxyPort?: number | undefined;
44
+ socksProxyPort?: number | undefined;
45
+ }>>;
46
+ ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
47
+ enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ network?: {
50
+ allowUnixSockets?: string[] | undefined;
51
+ allowLocalBinding?: boolean | undefined;
52
+ httpProxyPort?: number | undefined;
53
+ socksProxyPort?: number | undefined;
54
+ } | undefined;
55
+ ignoreViolations?: Record<string, string[]> | undefined;
56
+ enableWeakerNestedSandbox?: boolean | undefined;
57
+ }, {
58
+ network?: {
59
+ allowUnixSockets?: string[] | undefined;
60
+ allowLocalBinding?: boolean | undefined;
61
+ httpProxyPort?: number | undefined;
62
+ socksProxyPort?: number | undefined;
63
+ } | undefined;
64
+ ignoreViolations?: Record<string, string[]> | undefined;
65
+ enableWeakerNestedSandbox?: boolean | undefined;
66
+ }>>;
67
+ }, "strip", z.ZodTypeAny, {
68
+ permissions?: {
69
+ allow?: string[] | undefined;
70
+ deny?: string[] | undefined;
71
+ ask?: string[] | undefined;
72
+ } | undefined;
73
+ sandbox?: {
74
+ network?: {
75
+ allowUnixSockets?: string[] | undefined;
76
+ allowLocalBinding?: boolean | undefined;
77
+ httpProxyPort?: number | undefined;
78
+ socksProxyPort?: number | undefined;
79
+ } | undefined;
80
+ ignoreViolations?: Record<string, string[]> | undefined;
81
+ enableWeakerNestedSandbox?: boolean | undefined;
82
+ } | undefined;
83
+ }, {
84
+ permissions?: {
85
+ allow?: string[] | undefined;
86
+ deny?: string[] | undefined;
87
+ ask?: string[] | undefined;
88
+ } | undefined;
89
+ sandbox?: {
90
+ network?: {
91
+ allowUnixSockets?: string[] | undefined;
92
+ allowLocalBinding?: boolean | undefined;
93
+ httpProxyPort?: number | undefined;
94
+ socksProxyPort?: number | undefined;
95
+ } | undefined;
96
+ ignoreViolations?: Record<string, string[]> | undefined;
97
+ enableWeakerNestedSandbox?: boolean | undefined;
98
+ } | undefined;
99
+ }>;
100
+ /**
101
+ * Minimal settings structure for sandbox
102
+ */
103
+ export type SandboxSettings = z.infer<typeof SandboxSettingsSchema>;
104
+ /**
105
+ * Setting source types
106
+ */
107
+ export type SettingSource = 'userSettings' | 'projectSettings' | 'localSettings' | 'policySettings' | 'flagSettings';
108
+ export type EditableSettingSource = 'userSettings' | 'projectSettings' | 'localSettings';
109
+ /**
110
+ * Set the path for flag-based settings (e.g., from --settings flag)
111
+ */
112
+ export declare function setFlagSettingsPath(path: string | undefined): void;
113
+ /**
114
+ * Get file path for a specific setting source
115
+ */
116
+ export declare function getSettingsFilePathForSource(source: SettingSource): string | undefined;
117
+ /**
118
+ * Parse permission rule string into structured format
119
+ * Format: "ToolName(rule)" or "ToolName"
120
+ */
121
+ export declare function permissionRuleValueFromString(ruleString: string): PermissionRule;
122
+ /**
123
+ * Reset the session-level settings cache
124
+ */
125
+ export declare function resetSettingsCache(): void;
126
+ /**
127
+ * Get settings for a specific source
128
+ */
129
+ export declare function getSettingsForSource(source: SettingSource): SandboxSettings | null;
130
+ /**
131
+ * Update settings for a specific source
132
+ */
133
+ export declare function updateSettingsForSource(source: EditableSettingSource, settings: SandboxSettings): void;
134
+ /**
135
+ * Get merged settings from all sources with session-level caching
136
+ * Merges in priority order:
137
+ * 1. User settings (~/.claude/settings.json)
138
+ * 2. Project settings ($CWD/.claude/settings.json)
139
+ * 3. Local settings ($CWD/.claude/settings.local.json)
140
+ * 4. Policy settings (platform-specific managed settings)
141
+ * 5. Flag settings (from --settings flag if provided)
142
+ *
143
+ * Settings are cached for the session. Call resetSettingsCache() to invalidate.
144
+ */
145
+ export declare function getSettings(): SandboxSettings;
146
+ export {};
147
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/utils/settings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,eAAO,MAAM,mBAAmB,aAAa,CAAA;AAC7C,eAAO,MAAM,mBAAmB,SAAS,CAAA;AACzC,eAAO,MAAM,mBAAmB,SAAS,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASzB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,cAAc,CAAA;AAElB,MAAM,MAAM,qBAAqB,GAC7B,cAAc,GACd,iBAAiB,GACjB,eAAe,CAAA;AAQnB;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAGlE;AAgBD;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,aAAa,GACpB,MAAM,GAAG,SAAS,CAgBpB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,GACjB,cAAc,CAahB;AA0FD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,GACpB,eAAe,GAAG,IAAI,CAMxB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,EAAE,eAAe,GACxB,IAAI,CA6BN;AAkCD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,eAAe,CAS7C"}
@@ -0,0 +1,244 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as os from 'os';
4
+ import { z } from 'zod';
5
+ import { mergeWith } from 'lodash-es';
6
+ import { SandboxConfigSchema } from '../sandbox/sandbox-schemas.js';
7
+ import { getPlatform } from './platform.js';
8
+ import { logForDebugging } from './debug.js';
9
+ // Tool name constants
10
+ export const WEB_FETCH_TOOL_NAME = 'WebFetch';
11
+ export const FILE_EDIT_TOOL_NAME = 'Edit';
12
+ export const FILE_READ_TOOL_NAME = 'Read';
13
+ /**
14
+ * Zod schema for sandbox settings
15
+ */
16
+ const SandboxSettingsSchema = z.object({
17
+ permissions: z
18
+ .object({
19
+ allow: z.array(z.string()).optional(),
20
+ deny: z.array(z.string()).optional(),
21
+ ask: z.array(z.string()).optional(),
22
+ })
23
+ .optional(),
24
+ sandbox: SandboxConfigSchema.optional(),
25
+ });
26
+ // Session-level cache for settings
27
+ let sessionSettingsCache = null;
28
+ // Store the --settings flag path
29
+ let flagSettingsPath;
30
+ /**
31
+ * Set the path for flag-based settings (e.g., from --settings flag)
32
+ */
33
+ export function setFlagSettingsPath(path) {
34
+ flagSettingsPath = path;
35
+ resetSettingsCache();
36
+ }
37
+ /**
38
+ * Get the managed settings file path based on platform
39
+ */
40
+ function getManagedSettingsFilePath() {
41
+ switch (getPlatform()) {
42
+ case 'macos':
43
+ return '/Library/Application Support/ClaudeCode/managed-settings.json';
44
+ case 'windows':
45
+ return 'C:\\ProgramData\\ClaudeCode\\managed-settings.json';
46
+ default:
47
+ return '/etc/claude-code/managed-settings.json';
48
+ }
49
+ }
50
+ /**
51
+ * Get file path for a specific setting source
52
+ */
53
+ export function getSettingsFilePathForSource(source) {
54
+ const cwd = process.cwd();
55
+ const homeDir = os.homedir();
56
+ switch (source) {
57
+ case 'userSettings':
58
+ return path.join(homeDir, '.claude', 'settings.json');
59
+ case 'projectSettings':
60
+ return path.join(cwd, '.claude', 'settings.json');
61
+ case 'localSettings':
62
+ return path.join(cwd, '.claude', 'settings.local.json');
63
+ case 'policySettings':
64
+ return getManagedSettingsFilePath();
65
+ case 'flagSettings':
66
+ return flagSettingsPath;
67
+ }
68
+ }
69
+ /**
70
+ * Parse permission rule string into structured format
71
+ * Format: "ToolName(rule)" or "ToolName"
72
+ */
73
+ export function permissionRuleValueFromString(ruleString) {
74
+ const match = ruleString.match(/^([^(]+)(?:\(([^)]*)\))?$/);
75
+ if (!match) {
76
+ throw new Error(`Invalid permission rule format: ${ruleString}`);
77
+ }
78
+ const [, toolName, ruleContent] = match;
79
+ return {
80
+ toolName: toolName?.trim() || '',
81
+ ruleContent: ruleContent?.trim(),
82
+ };
83
+ }
84
+ /**
85
+ * Load settings from a single file
86
+ */
87
+ function loadSettingsFile(filePath) {
88
+ try {
89
+ if (!fs.existsSync(filePath)) {
90
+ return null;
91
+ }
92
+ const content = fs.readFileSync(filePath, 'utf-8');
93
+ if (content.trim() === '') {
94
+ return null;
95
+ }
96
+ const data = JSON.parse(content);
97
+ // Validate with Zod
98
+ const result = SandboxSettingsSchema.safeParse(data);
99
+ if (!result.success) {
100
+ // Loud error to stderr
101
+ console.error(`\n❌ Settings validation error in: ${filePath}`);
102
+ console.error('Details:');
103
+ result.error.issues.forEach(issue => {
104
+ const pathStr = issue.path.length > 0 ? issue.path.join('.') : 'root';
105
+ console.error(` - ${pathStr}: ${issue.message}`);
106
+ });
107
+ console.error('');
108
+ // Also log for debugging
109
+ logForDebugging(`Validation failed for ${filePath}: ${result.error.message}`, { level: 'error' });
110
+ return null;
111
+ }
112
+ logForDebugging(`Loaded from ${filePath}: ${JSON.stringify(result.data, null, 2)}`);
113
+ return result.data;
114
+ }
115
+ catch (error) {
116
+ // Loud error to stderr
117
+ console.error(`\n❌ Failed to parse settings file: ${filePath}`);
118
+ if (error instanceof SyntaxError) {
119
+ console.error(`JSON syntax error: ${error.message}`);
120
+ }
121
+ else {
122
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
123
+ }
124
+ console.error('');
125
+ // Also log for debugging
126
+ logForDebugging(`Failed to read ${filePath}: ${error}`, {
127
+ level: 'error',
128
+ });
129
+ return null;
130
+ }
131
+ }
132
+ /**
133
+ * Merge two arrays and deduplicate
134
+ */
135
+ function mergeArrays(arr1, arr2) {
136
+ return Array.from(new Set([...arr1, ...arr2]));
137
+ }
138
+ /**
139
+ * Deep merge two settings objects using lodash mergeWith
140
+ * Arrays are concatenated and deduplicated
141
+ * Objects are recursively deep merged
142
+ */
143
+ function mergeSettings(base, override) {
144
+ return mergeWith(base, override, (objValue, srcValue) => {
145
+ // Custom merge for arrays: concatenate and deduplicate
146
+ if (Array.isArray(objValue) && Array.isArray(srcValue)) {
147
+ return mergeArrays(objValue, srcValue);
148
+ }
149
+ // For non-arrays, let lodash handle the default deep merge behavior
150
+ return undefined;
151
+ });
152
+ }
153
+ /**
154
+ * Reset the session-level settings cache
155
+ */
156
+ export function resetSettingsCache() {
157
+ sessionSettingsCache = null;
158
+ }
159
+ /**
160
+ * Get settings for a specific source
161
+ */
162
+ export function getSettingsForSource(source) {
163
+ const settingsFilePath = getSettingsFilePathForSource(source);
164
+ if (!settingsFilePath) {
165
+ return null;
166
+ }
167
+ return loadSettingsFile(settingsFilePath);
168
+ }
169
+ /**
170
+ * Update settings for a specific source
171
+ */
172
+ export function updateSettingsForSource(source, settings) {
173
+ const filePath = getSettingsFilePathForSource(source);
174
+ if (!filePath) {
175
+ return;
176
+ }
177
+ try {
178
+ // Create the directory if needed
179
+ const dir = path.dirname(filePath);
180
+ if (!fs.existsSync(dir)) {
181
+ fs.mkdirSync(dir, { recursive: true });
182
+ }
183
+ // Load existing settings
184
+ const existingSettings = loadSettingsFile(filePath) || {};
185
+ // Merge with new settings
186
+ const updatedSettings = mergeSettings(existingSettings, settings);
187
+ // Write to file
188
+ fs.writeFileSync(filePath, JSON.stringify(updatedSettings, null, 2) + '\n');
189
+ // Invalidate cache
190
+ resetSettingsCache();
191
+ }
192
+ catch (error) {
193
+ logForDebugging(`Failed to write ${filePath}: ${error}`, {
194
+ level: 'error',
195
+ });
196
+ }
197
+ }
198
+ /**
199
+ * Load settings from disk without using cache
200
+ */
201
+ function loadSettingsFromDisk() {
202
+ // Define setting sources in priority order (lowest to highest)
203
+ const sources = [
204
+ 'userSettings',
205
+ 'projectSettings',
206
+ 'localSettings',
207
+ 'policySettings',
208
+ ];
209
+ // Add flagSettings if a path was provided
210
+ if (flagSettingsPath) {
211
+ sources.push('flagSettings');
212
+ }
213
+ let merged = {};
214
+ // Merge settings from each source
215
+ for (const source of sources) {
216
+ const settings = getSettingsForSource(source);
217
+ if (settings) {
218
+ merged = mergeSettings(merged, settings);
219
+ }
220
+ }
221
+ logForDebugging(`Final merged settings: ${JSON.stringify(merged, null, 2)}`);
222
+ return merged;
223
+ }
224
+ /**
225
+ * Get merged settings from all sources with session-level caching
226
+ * Merges in priority order:
227
+ * 1. User settings (~/.claude/settings.json)
228
+ * 2. Project settings ($CWD/.claude/settings.json)
229
+ * 3. Local settings ($CWD/.claude/settings.local.json)
230
+ * 4. Policy settings (platform-specific managed settings)
231
+ * 5. Flag settings (from --settings flag if provided)
232
+ *
233
+ * Settings are cached for the session. Call resetSettingsCache() to invalidate.
234
+ */
235
+ export function getSettings() {
236
+ // Use cached result if available
237
+ if (sessionSettingsCache !== null) {
238
+ return sessionSettingsCache;
239
+ }
240
+ // Load from disk and cache the result
241
+ sessionSettingsCache = loadSettingsFromDisk();
242
+ return sessionSettingsCache;
243
+ }
244
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/utils/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,sBAAsB;AACtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAA;AAC7C,MAAM,CAAC,MAAM,mBA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AAI,MAAM,GAAoB,EAAE,CAAA;IAEhC,kCAAkC;IAClC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;QAC7C,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,eAAe,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;IAE5E,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW;IACzB,iCAAiC;IACjC,IAAI,oBAAoB,KAAK,IAAI,EAAE,CAAC;QAClC,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,sCAAsC;IACtC,oBAAoB,GAAG,oBAAoB,EAAE,CAAA;IAC7C,OAAO,oBAAoB,CAAA;AAC7B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@anthropic-ai/sandbox-runtime",
3
+ "version": "0.0.1",
4
+ "description": "Anthropic Sandbox Runtime (ASRT) - A general-purpose tool for wrapping security boundaries around arbitrary processes",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "srt": "dist/cli.js"
10
+ },
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "clean": "rm -rf dist",
17
+ "typecheck": "tsc --noEmit",
18
+ "lint": "eslint 'src/**/*.ts' --fix --cache --cache-location=node_modules/.cache/.eslintcache",
19
+ "lint:check": "eslint 'src/**/*.ts' --cache --cache-location=node_modules/.cache/.eslintcache",
20
+ "format": "prettier --write 'src/**/*.ts' --cache --log-level warn",
21
+ "prepublishOnly": "npm run clean && npm run build"
22
+ },
23
+ "dependencies": {
24
+ "@pondwader/socks5-server": "^1.0.10",
25
+ "@types/lodash-es": "^4.17.12",
26
+ "commander": "^12.1.0",
27
+ "lodash-es": "^4.17.21",
28
+ "shell-quote": "^1.8.3",
29
+ "zod": "^3.24.1"
30
+ },
31
+ "devDependencies": {
32
+ "@eslint/js": "^9.14.0",
33
+ "@types/node": "^18",
34
+ "@types/shell-quote": "^1.7.5",
35
+ "eslint": "^9.14.0",
36
+ "eslint-config-prettier": "^8.10.0",
37
+ "eslint-import-resolver-typescript": "^3.6.3",
38
+ "eslint-plugin-import": "^2.31.0",
39
+ "eslint-plugin-n": "^17.16.2",
40
+ "eslint-plugin-prettier": "^5.1.3",
41
+ "globals": "^15.12.0",
42
+ "prettier": "3.3.3",
43
+ "typescript": "^5.6.3",
44
+ "typescript-eslint": "^8.13.0"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ "keywords": [
52
+ "sandbox",
53
+ "seatbelt",
54
+ "sandbox-exec",
55
+ "anthropic",
56
+ "claude",
57
+ "security",
58
+ "bubblewrap",
59
+ "network-filtering",
60
+ "filesystem-restrictions"
61
+ ],
62
+ "author": "Anthropic PBC",
63
+ "license": "Apache-2.0",
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "git+https://github.com/anthropics/sandbox-runtime.git"
67
+ },
68
+ "bugs": {
69
+ "url": "https://github.com/anthropics/sandbox-runtime/issues"
70
+ },
71
+ "homepage": "https://github.com/anthropics/sandbox-runtime#readme"
72
+ }