@lleverage-ai/agent-sdk 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.
- package/LICENSE +21 -0
- package/README.md +2321 -0
- package/dist/agent.d.ts +52 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +2122 -0
- package/dist/agent.js.map +1 -0
- package/dist/backend.d.ts +378 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +71 -0
- package/dist/backend.js.map +1 -0
- package/dist/backends/composite.d.ts +258 -0
- package/dist/backends/composite.d.ts.map +1 -0
- package/dist/backends/composite.js +437 -0
- package/dist/backends/composite.js.map +1 -0
- package/dist/backends/filesystem.d.ts +268 -0
- package/dist/backends/filesystem.d.ts.map +1 -0
- package/dist/backends/filesystem.js +623 -0
- package/dist/backends/filesystem.js.map +1 -0
- package/dist/backends/index.d.ts +14 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +14 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/persistent.d.ts +312 -0
- package/dist/backends/persistent.d.ts.map +1 -0
- package/dist/backends/persistent.js +519 -0
- package/dist/backends/persistent.js.map +1 -0
- package/dist/backends/sandbox.d.ts +315 -0
- package/dist/backends/sandbox.d.ts.map +1 -0
- package/dist/backends/sandbox.js +490 -0
- package/dist/backends/sandbox.js.map +1 -0
- package/dist/backends/state.d.ts +225 -0
- package/dist/backends/state.d.ts.map +1 -0
- package/dist/backends/state.js +396 -0
- package/dist/backends/state.js.map +1 -0
- package/dist/checkpointer/file-saver.d.ts +182 -0
- package/dist/checkpointer/file-saver.d.ts.map +1 -0
- package/dist/checkpointer/file-saver.js +298 -0
- package/dist/checkpointer/file-saver.js.map +1 -0
- package/dist/checkpointer/index.d.ts +40 -0
- package/dist/checkpointer/index.d.ts.map +1 -0
- package/dist/checkpointer/index.js +40 -0
- package/dist/checkpointer/index.js.map +1 -0
- package/dist/checkpointer/kv-saver.d.ts +142 -0
- package/dist/checkpointer/kv-saver.d.ts.map +1 -0
- package/dist/checkpointer/kv-saver.js +176 -0
- package/dist/checkpointer/kv-saver.js.map +1 -0
- package/dist/checkpointer/memory-saver.d.ts +158 -0
- package/dist/checkpointer/memory-saver.d.ts.map +1 -0
- package/dist/checkpointer/memory-saver.js +222 -0
- package/dist/checkpointer/memory-saver.js.map +1 -0
- package/dist/checkpointer/types.d.ts +353 -0
- package/dist/checkpointer/types.d.ts.map +1 -0
- package/dist/checkpointer/types.js +159 -0
- package/dist/checkpointer/types.js.map +1 -0
- package/dist/context-manager.d.ts +627 -0
- package/dist/context-manager.d.ts.map +1 -0
- package/dist/context-manager.js +1039 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/context.d.ts +57 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +76 -0
- package/dist/context.js.map +1 -0
- package/dist/errors/index.d.ts +611 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +1023 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/generation-helpers.d.ts +126 -0
- package/dist/generation-helpers.d.ts.map +1 -0
- package/dist/generation-helpers.js +181 -0
- package/dist/generation-helpers.js.map +1 -0
- package/dist/hooks/audit.d.ts +210 -0
- package/dist/hooks/audit.d.ts.map +1 -0
- package/dist/hooks/audit.js +305 -0
- package/dist/hooks/audit.js.map +1 -0
- package/dist/hooks/cache.d.ts +180 -0
- package/dist/hooks/cache.d.ts.map +1 -0
- package/dist/hooks/cache.js +273 -0
- package/dist/hooks/cache.js.map +1 -0
- package/dist/hooks/guardrails.d.ts +145 -0
- package/dist/hooks/guardrails.d.ts.map +1 -0
- package/dist/hooks/guardrails.js +326 -0
- package/dist/hooks/guardrails.js.map +1 -0
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +32 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/logging.d.ts +193 -0
- package/dist/hooks/logging.d.ts.map +1 -0
- package/dist/hooks/logging.js +345 -0
- package/dist/hooks/logging.js.map +1 -0
- package/dist/hooks/parallel-guardrails.d.ts +268 -0
- package/dist/hooks/parallel-guardrails.d.ts.map +1 -0
- package/dist/hooks/parallel-guardrails.js +416 -0
- package/dist/hooks/parallel-guardrails.js.map +1 -0
- package/dist/hooks/rate-limit.d.ts +305 -0
- package/dist/hooks/rate-limit.d.ts.map +1 -0
- package/dist/hooks/rate-limit.js +372 -0
- package/dist/hooks/rate-limit.js.map +1 -0
- package/dist/hooks/retry.d.ts +144 -0
- package/dist/hooks/retry.d.ts.map +1 -0
- package/dist/hooks/retry.js +210 -0
- package/dist/hooks/retry.js.map +1 -0
- package/dist/hooks/secrets.d.ts +174 -0
- package/dist/hooks/secrets.d.ts.map +1 -0
- package/dist/hooks/secrets.js +306 -0
- package/dist/hooks/secrets.js.map +1 -0
- package/dist/hooks.d.ts +229 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +352 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +182 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/env.d.ts +25 -0
- package/dist/mcp/env.d.ts.map +1 -0
- package/dist/mcp/env.js +18 -0
- package/dist/mcp/env.js.map +1 -0
- package/dist/mcp/index.d.ts +16 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +184 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +446 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/types.d.ts +58 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +7 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp/validation.d.ts +119 -0
- package/dist/mcp/validation.d.ts.map +1 -0
- package/dist/mcp/validation.js +407 -0
- package/dist/mcp/validation.js.map +1 -0
- package/dist/mcp/virtual-server.d.ts +78 -0
- package/dist/mcp/virtual-server.d.ts.map +1 -0
- package/dist/mcp/virtual-server.js +137 -0
- package/dist/mcp/virtual-server.js.map +1 -0
- package/dist/memory/filesystem-store.d.ts +217 -0
- package/dist/memory/filesystem-store.d.ts.map +1 -0
- package/dist/memory/filesystem-store.js +343 -0
- package/dist/memory/filesystem-store.js.map +1 -0
- package/dist/memory/index.d.ts +46 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +46 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/loader.d.ts +396 -0
- package/dist/memory/loader.d.ts.map +1 -0
- package/dist/memory/loader.js +419 -0
- package/dist/memory/loader.js.map +1 -0
- package/dist/memory/permissions.d.ts +282 -0
- package/dist/memory/permissions.d.ts.map +1 -0
- package/dist/memory/permissions.js +297 -0
- package/dist/memory/permissions.js.map +1 -0
- package/dist/memory/rules.d.ts +249 -0
- package/dist/memory/rules.d.ts.map +1 -0
- package/dist/memory/rules.js +362 -0
- package/dist/memory/rules.js.map +1 -0
- package/dist/memory/store.d.ts +286 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +263 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/middleware/apply.d.ts +73 -0
- package/dist/middleware/apply.d.ts.map +1 -0
- package/dist/middleware/apply.js +219 -0
- package/dist/middleware/apply.js.map +1 -0
- package/dist/middleware/context.d.ts +33 -0
- package/dist/middleware/context.d.ts.map +1 -0
- package/dist/middleware/context.js +176 -0
- package/dist/middleware/context.js.map +1 -0
- package/dist/middleware/index.d.ts +31 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +32 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/logging.d.ts +137 -0
- package/dist/middleware/logging.d.ts.map +1 -0
- package/dist/middleware/logging.js +374 -0
- package/dist/middleware/logging.js.map +1 -0
- package/dist/middleware/types.d.ts +183 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +11 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/observability/events.d.ts +183 -0
- package/dist/observability/events.d.ts.map +1 -0
- package/dist/observability/events.js +305 -0
- package/dist/observability/events.js.map +1 -0
- package/dist/observability/index.d.ts +55 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +87 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/logger.d.ts +318 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +436 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/metrics.d.ts +341 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +490 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/observability/preset.d.ts +161 -0
- package/dist/observability/preset.d.ts.map +1 -0
- package/dist/observability/preset.js +133 -0
- package/dist/observability/preset.js.map +1 -0
- package/dist/observability/streaming.d.ts +113 -0
- package/dist/observability/streaming.d.ts.map +1 -0
- package/dist/observability/streaming.js +114 -0
- package/dist/observability/streaming.js.map +1 -0
- package/dist/observability/tracing.d.ts +378 -0
- package/dist/observability/tracing.d.ts.map +1 -0
- package/dist/observability/tracing.js +539 -0
- package/dist/observability/tracing.js.map +1 -0
- package/dist/plugins.d.ts +55 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +63 -0
- package/dist/plugins.js.map +1 -0
- package/dist/presets/index.d.ts +7 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +7 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/production.d.ts +262 -0
- package/dist/presets/production.d.ts.map +1 -0
- package/dist/presets/production.js +295 -0
- package/dist/presets/production.js.map +1 -0
- package/dist/security/index.d.ts +179 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +323 -0
- package/dist/security/index.js.map +1 -0
- package/dist/subagents/advanced.d.ts +413 -0
- package/dist/subagents/advanced.d.ts.map +1 -0
- package/dist/subagents/advanced.js +396 -0
- package/dist/subagents/advanced.js.map +1 -0
- package/dist/subagents/index.d.ts +14 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +15 -0
- package/dist/subagents/index.js.map +1 -0
- package/dist/subagents.d.ts +73 -0
- package/dist/subagents.d.ts.map +1 -0
- package/dist/subagents.js +213 -0
- package/dist/subagents.js.map +1 -0
- package/dist/task-store/file-store.d.ts +76 -0
- package/dist/task-store/file-store.d.ts.map +1 -0
- package/dist/task-store/file-store.js +190 -0
- package/dist/task-store/file-store.js.map +1 -0
- package/dist/task-store/index.d.ts +11 -0
- package/dist/task-store/index.d.ts.map +1 -0
- package/dist/task-store/index.js +10 -0
- package/dist/task-store/index.js.map +1 -0
- package/dist/task-store/kv-store.d.ts +140 -0
- package/dist/task-store/kv-store.d.ts.map +1 -0
- package/dist/task-store/kv-store.js +169 -0
- package/dist/task-store/kv-store.js.map +1 -0
- package/dist/task-store/memory-store.d.ts +66 -0
- package/dist/task-store/memory-store.d.ts.map +1 -0
- package/dist/task-store/memory-store.js +125 -0
- package/dist/task-store/memory-store.js.map +1 -0
- package/dist/task-store/types.d.ts +235 -0
- package/dist/task-store/types.d.ts.map +1 -0
- package/dist/task-store/types.js +110 -0
- package/dist/task-store/types.js.map +1 -0
- package/dist/testing/assertions.d.ts +401 -0
- package/dist/testing/assertions.d.ts.map +1 -0
- package/dist/testing/assertions.js +630 -0
- package/dist/testing/assertions.js.map +1 -0
- package/dist/testing/index.d.ts +343 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +360 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-agent.d.ts +214 -0
- package/dist/testing/mock-agent.d.ts.map +1 -0
- package/dist/testing/mock-agent.js +448 -0
- package/dist/testing/mock-agent.js.map +1 -0
- package/dist/testing/recorder.d.ts +288 -0
- package/dist/testing/recorder.d.ts.map +1 -0
- package/dist/testing/recorder.js +499 -0
- package/dist/testing/recorder.js.map +1 -0
- package/dist/tools/execute.d.ts +104 -0
- package/dist/tools/execute.d.ts.map +1 -0
- package/dist/tools/execute.js +191 -0
- package/dist/tools/execute.js.map +1 -0
- package/dist/tools/factory.d.ts +260 -0
- package/dist/tools/factory.d.ts.map +1 -0
- package/dist/tools/factory.js +241 -0
- package/dist/tools/factory.js.map +1 -0
- package/dist/tools/filesystem.d.ts +215 -0
- package/dist/tools/filesystem.d.ts.map +1 -0
- package/dist/tools/filesystem.js +311 -0
- package/dist/tools/filesystem.js.map +1 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +33 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/search.d.ts +59 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +94 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/skills.d.ts +354 -0
- package/dist/tools/skills.d.ts.map +1 -0
- package/dist/tools/skills.js +413 -0
- package/dist/tools/skills.js.map +1 -0
- package/dist/tools/task.d.ts +272 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +521 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/todos.d.ts +131 -0
- package/dist/tools/todos.d.ts.map +1 -0
- package/dist/tools/todos.js +120 -0
- package/dist/tools/todos.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +424 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +607 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/tools/user-interaction.d.ts +116 -0
- package/dist/tools/user-interaction.d.ts.map +1 -0
- package/dist/tools/user-interaction.js +147 -0
- package/dist/tools/user-interaction.js.map +1 -0
- package/dist/tools/utils.d.ts +124 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +189 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools.d.ts +74 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +73 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +2421 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +55 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox backend for command execution.
|
|
3
|
+
*
|
|
4
|
+
* SandboxBackend provides isolated environments for running shell commands safely.
|
|
5
|
+
* The base class provides a foundation for various sandbox implementations including
|
|
6
|
+
* local processes, containers, or cloud sandboxes.
|
|
7
|
+
*
|
|
8
|
+
* This module provides:
|
|
9
|
+
* - {@link BaseSandbox} - Abstract base class for all sandbox implementations
|
|
10
|
+
* - {@link LocalSandbox} - Local shell execution with security controls
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Create a local sandbox for development
|
|
15
|
+
* const sandbox = new LocalSandbox({
|
|
16
|
+
* cwd: process.cwd(),
|
|
17
|
+
* timeout: 30000,
|
|
18
|
+
* maxOutputSize: 1024 * 1024,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Execute a command
|
|
22
|
+
* const result = await sandbox.execute("npm test");
|
|
23
|
+
* console.log(`Exit code: ${result.exitCode}`);
|
|
24
|
+
* console.log(`Output: ${result.output}`);
|
|
25
|
+
*
|
|
26
|
+
* // Use file operations
|
|
27
|
+
* const files = await sandbox.lsInfo("./src");
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @packageDocumentation
|
|
31
|
+
*/
|
|
32
|
+
import { spawn } from "node:child_process";
|
|
33
|
+
import { randomUUID } from "node:crypto";
|
|
34
|
+
import * as path from "node:path";
|
|
35
|
+
import { FileSizeLimitError, FilesystemBackend, PathTraversalError, SymlinkError, } from "./filesystem.js";
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// Error Classes
|
|
38
|
+
// =============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Error thrown when a command execution times out.
|
|
41
|
+
*
|
|
42
|
+
* @category Backend
|
|
43
|
+
*/
|
|
44
|
+
export class CommandTimeoutError extends Error {
|
|
45
|
+
command;
|
|
46
|
+
timeoutMs;
|
|
47
|
+
constructor(command, timeoutMs) {
|
|
48
|
+
super(`Command timed out after ${timeoutMs}ms: "${command.slice(0, 100)}${command.length > 100 ? "..." : ""}"`);
|
|
49
|
+
this.command = command;
|
|
50
|
+
this.timeoutMs = timeoutMs;
|
|
51
|
+
this.name = "CommandTimeoutError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown when a command is blocked by security filters.
|
|
56
|
+
*
|
|
57
|
+
* @category Backend
|
|
58
|
+
*/
|
|
59
|
+
export class CommandBlockedError extends Error {
|
|
60
|
+
command;
|
|
61
|
+
reason;
|
|
62
|
+
constructor(command, reason) {
|
|
63
|
+
super(`Command blocked: ${reason}`);
|
|
64
|
+
this.command = command;
|
|
65
|
+
this.reason = reason;
|
|
66
|
+
this.name = "CommandBlockedError";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// =============================================================================
|
|
70
|
+
// Default Dangerous Patterns
|
|
71
|
+
// =============================================================================
|
|
72
|
+
/**
|
|
73
|
+
* Default patterns that are considered dangerous.
|
|
74
|
+
* These are blocked unless allowDangerous is true.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
const DANGEROUS_PATTERNS = [
|
|
78
|
+
// Recursive force delete from root or home
|
|
79
|
+
/rm\s+(-[a-z]*r[a-z]*\s+)?(-[a-z]*f[a-z]*\s+)?[/~]/i,
|
|
80
|
+
/rm\s+(-[a-z]*f[a-z]*\s+)?(-[a-z]*r[a-z]*\s+)?[/~]/i,
|
|
81
|
+
// Format/wipe commands
|
|
82
|
+
/mkfs\./i,
|
|
83
|
+
/dd\s+.*of=\/dev\//i,
|
|
84
|
+
// Shutdown/reboot
|
|
85
|
+
/shutdown/i,
|
|
86
|
+
/reboot/i,
|
|
87
|
+
/halt/i,
|
|
88
|
+
/poweroff/i,
|
|
89
|
+
// Fork bombs
|
|
90
|
+
/:\(\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;?\s*:/,
|
|
91
|
+
// Overwrite important files
|
|
92
|
+
/>\s*\/etc\/(passwd|shadow|sudoers)/i,
|
|
93
|
+
// Downloading and executing
|
|
94
|
+
/curl.*\|\s*(ba)?sh/i,
|
|
95
|
+
/wget.*\|\s*(ba)?sh/i,
|
|
96
|
+
// Chmod dangerous patterns
|
|
97
|
+
/chmod\s+777\s+\//i,
|
|
98
|
+
/chmod\s+-R\s+777/i,
|
|
99
|
+
// Environment manipulation that could be dangerous
|
|
100
|
+
/export\s+PATH\s*=\s*$/i,
|
|
101
|
+
];
|
|
102
|
+
// =============================================================================
|
|
103
|
+
// Base Sandbox Implementation
|
|
104
|
+
// =============================================================================
|
|
105
|
+
/**
|
|
106
|
+
* Abstract base class for sandbox implementations.
|
|
107
|
+
*
|
|
108
|
+
* This class provides the foundation for various sandbox backends. Subclasses
|
|
109
|
+
* must implement the core execution method, while file operations can optionally
|
|
110
|
+
* be delegated to a wrapped backend.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* class MyCloudSandbox extends BaseSandbox {
|
|
115
|
+
* async execute(command: string): Promise<ExecuteResponse> {
|
|
116
|
+
* // Implement cloud-based execution
|
|
117
|
+
* return await this.cloudProvider.runCommand(command);
|
|
118
|
+
* }
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @category Backend
|
|
123
|
+
*/
|
|
124
|
+
export class BaseSandbox {
|
|
125
|
+
/** Unique identifier for this sandbox instance */
|
|
126
|
+
id;
|
|
127
|
+
/** Wrapped backend for file operations */
|
|
128
|
+
fileBackend;
|
|
129
|
+
/**
|
|
130
|
+
* Create a new BaseSandbox.
|
|
131
|
+
*
|
|
132
|
+
* @param fileBackend - Backend to use for file operations
|
|
133
|
+
* @param id - Optional unique identifier (auto-generated if not provided)
|
|
134
|
+
*/
|
|
135
|
+
constructor(fileBackend, id) {
|
|
136
|
+
this.id = id ?? `sandbox-${randomUUID()}`;
|
|
137
|
+
this.fileBackend = fileBackend;
|
|
138
|
+
}
|
|
139
|
+
// ===========================================================================
|
|
140
|
+
// File Operations - Delegated to file backend
|
|
141
|
+
// ===========================================================================
|
|
142
|
+
/**
|
|
143
|
+
* List files and directories at the given path.
|
|
144
|
+
*/
|
|
145
|
+
lsInfo(path) {
|
|
146
|
+
return this.fileBackend.lsInfo(path);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Read file content with line numbers.
|
|
150
|
+
*/
|
|
151
|
+
read(filePath, offset, limit) {
|
|
152
|
+
return this.fileBackend.read(filePath, offset, limit);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Read raw file content as FileData.
|
|
156
|
+
*/
|
|
157
|
+
readRaw(filePath) {
|
|
158
|
+
return this.fileBackend.readRaw(filePath);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Search for pattern matches using regex.
|
|
162
|
+
*/
|
|
163
|
+
grepRaw(pattern, path, glob) {
|
|
164
|
+
return this.fileBackend.grepRaw(pattern, path, glob);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Find files matching a glob pattern.
|
|
168
|
+
*/
|
|
169
|
+
globInfo(pattern, path) {
|
|
170
|
+
return this.fileBackend.globInfo(pattern, path);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Create or overwrite a file.
|
|
174
|
+
*/
|
|
175
|
+
write(filePath, content) {
|
|
176
|
+
return this.fileBackend.write(filePath, content);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Edit a file by replacing text.
|
|
180
|
+
*/
|
|
181
|
+
edit(filePath, oldString, newString, replaceAll) {
|
|
182
|
+
return this.fileBackend.edit(filePath, oldString, newString, replaceAll);
|
|
183
|
+
}
|
|
184
|
+
// ===========================================================================
|
|
185
|
+
// File Upload/Download - Default implementations
|
|
186
|
+
// ===========================================================================
|
|
187
|
+
/**
|
|
188
|
+
* Upload files to the sandbox.
|
|
189
|
+
*
|
|
190
|
+
* Default implementation writes files using the file backend.
|
|
191
|
+
*
|
|
192
|
+
* @param files - Array of [path, content] tuples
|
|
193
|
+
* @returns Array of upload results
|
|
194
|
+
*/
|
|
195
|
+
async uploadFiles(files) {
|
|
196
|
+
const results = [];
|
|
197
|
+
for (const [filePath, content] of files) {
|
|
198
|
+
try {
|
|
199
|
+
const textContent = new TextDecoder().decode(content);
|
|
200
|
+
const result = await this.fileBackend.write(filePath, textContent);
|
|
201
|
+
results.push({
|
|
202
|
+
path: filePath,
|
|
203
|
+
success: result.success,
|
|
204
|
+
error: result.error,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
results.push({
|
|
209
|
+
path: filePath,
|
|
210
|
+
success: false,
|
|
211
|
+
error: error instanceof Error ? error.message : String(error),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return results;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Download files from the sandbox.
|
|
219
|
+
*
|
|
220
|
+
* Default implementation reads files using the file backend.
|
|
221
|
+
*
|
|
222
|
+
* @param paths - Paths to download
|
|
223
|
+
* @returns Array of { path, content } objects
|
|
224
|
+
*/
|
|
225
|
+
async downloadFiles(paths) {
|
|
226
|
+
const results = [];
|
|
227
|
+
for (const filePath of paths) {
|
|
228
|
+
try {
|
|
229
|
+
const fileData = await this.fileBackend.readRaw(filePath);
|
|
230
|
+
const content = new TextEncoder().encode(fileData.content.join("\n"));
|
|
231
|
+
results.push({ path: filePath, content });
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
// Skip files we can't read
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return results;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// =============================================================================
|
|
241
|
+
// Local Sandbox Implementation
|
|
242
|
+
// =============================================================================
|
|
243
|
+
/**
|
|
244
|
+
* Local sandbox for shell command execution.
|
|
245
|
+
*
|
|
246
|
+
* Provides secure command execution with:
|
|
247
|
+
* - Timeout enforcement
|
|
248
|
+
* - Output size limits
|
|
249
|
+
* - Command blocking/allowlisting
|
|
250
|
+
* - Dangerous pattern detection
|
|
251
|
+
*
|
|
252
|
+
* File operations are delegated to a FilesystemBackend with the same security
|
|
253
|
+
* protections (path traversal, symlink, file size).
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const sandbox = new LocalSandbox({
|
|
258
|
+
* cwd: "/home/user/project",
|
|
259
|
+
* timeout: 30000,
|
|
260
|
+
* blockedCommands: ["rm -rf"],
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* // Execute a command
|
|
264
|
+
* const result = await sandbox.execute("ls -la");
|
|
265
|
+
* console.log(result.output);
|
|
266
|
+
*
|
|
267
|
+
* // File operations work too
|
|
268
|
+
* const files = await sandbox.lsInfo("./src");
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @category Backend
|
|
272
|
+
*/
|
|
273
|
+
export class LocalSandbox extends BaseSandbox {
|
|
274
|
+
cwd;
|
|
275
|
+
timeout;
|
|
276
|
+
maxOutputSize;
|
|
277
|
+
shell;
|
|
278
|
+
env;
|
|
279
|
+
blockedCommands;
|
|
280
|
+
allowedCommands;
|
|
281
|
+
allowDangerous;
|
|
282
|
+
/**
|
|
283
|
+
* Create a new LocalSandbox.
|
|
284
|
+
*
|
|
285
|
+
* @param options - Configuration options
|
|
286
|
+
*/
|
|
287
|
+
constructor(options = {}) {
|
|
288
|
+
// Create filesystem backend for file operations
|
|
289
|
+
const fileBackend = new FilesystemBackend({
|
|
290
|
+
rootDir: options.cwd ?? process.cwd(),
|
|
291
|
+
maxFileSizeMb: options.maxFileSizeMb ?? 10,
|
|
292
|
+
followSymlinks: options.followSymlinks ?? false,
|
|
293
|
+
allowedPaths: options.allowedPaths,
|
|
294
|
+
});
|
|
295
|
+
super(fileBackend);
|
|
296
|
+
this.cwd = path.resolve(options.cwd ?? process.cwd());
|
|
297
|
+
this.timeout = options.timeout ?? 120000; // 2 minutes default
|
|
298
|
+
this.maxOutputSize = options.maxOutputSize ?? 1048576; // 1MB default
|
|
299
|
+
this.shell = options.shell ?? (process.platform === "win32" ? "cmd.exe" : "/bin/sh");
|
|
300
|
+
this.env = { ...process.env, ...options.env };
|
|
301
|
+
this.blockedCommands = options.blockedCommands ?? [];
|
|
302
|
+
this.allowedCommands = options.allowedCommands;
|
|
303
|
+
this.allowDangerous = options.allowDangerous ?? false;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Execute a shell command.
|
|
307
|
+
*
|
|
308
|
+
* @param command - Shell command to execute
|
|
309
|
+
* @returns Execution result with output and exit code
|
|
310
|
+
* @throws {CommandBlockedError} If the command is blocked
|
|
311
|
+
* @throws {CommandTimeoutError} If the command times out
|
|
312
|
+
*/
|
|
313
|
+
async execute(command) {
|
|
314
|
+
// Validate command
|
|
315
|
+
this.validateCommand(command);
|
|
316
|
+
return new Promise((resolve) => {
|
|
317
|
+
let output = "";
|
|
318
|
+
let truncated = false;
|
|
319
|
+
let resolved = false;
|
|
320
|
+
const shellArgs = process.platform === "win32" ? ["/c", command] : ["-c", command];
|
|
321
|
+
const child = spawn(this.shell, shellArgs, {
|
|
322
|
+
cwd: this.cwd,
|
|
323
|
+
env: this.env,
|
|
324
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
325
|
+
});
|
|
326
|
+
const handleOutput = (data) => {
|
|
327
|
+
if (truncated)
|
|
328
|
+
return;
|
|
329
|
+
const chunk = data.toString();
|
|
330
|
+
if (output.length + chunk.length > this.maxOutputSize) {
|
|
331
|
+
output += chunk.slice(0, this.maxOutputSize - output.length);
|
|
332
|
+
truncated = true;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
output += chunk;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
child.stdout?.on("data", handleOutput);
|
|
339
|
+
child.stderr?.on("data", handleOutput);
|
|
340
|
+
// Set up timeout
|
|
341
|
+
const timeoutId = setTimeout(() => {
|
|
342
|
+
if (!resolved) {
|
|
343
|
+
resolved = true;
|
|
344
|
+
child.kill("SIGTERM");
|
|
345
|
+
// Give it a moment to terminate gracefully
|
|
346
|
+
setTimeout(() => {
|
|
347
|
+
child.kill("SIGKILL");
|
|
348
|
+
}, 1000);
|
|
349
|
+
resolve({
|
|
350
|
+
output: `${output}\n[Command timed out after ${this.timeout}ms]`,
|
|
351
|
+
exitCode: null,
|
|
352
|
+
truncated,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}, this.timeout);
|
|
356
|
+
child.on("close", (code) => {
|
|
357
|
+
if (!resolved) {
|
|
358
|
+
resolved = true;
|
|
359
|
+
clearTimeout(timeoutId);
|
|
360
|
+
resolve({
|
|
361
|
+
output,
|
|
362
|
+
exitCode: code,
|
|
363
|
+
truncated,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
child.on("error", (error) => {
|
|
368
|
+
if (!resolved) {
|
|
369
|
+
resolved = true;
|
|
370
|
+
clearTimeout(timeoutId);
|
|
371
|
+
resolve({
|
|
372
|
+
output: `Error: ${error.message}`,
|
|
373
|
+
exitCode: 1,
|
|
374
|
+
truncated: false,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
// ===========================================================================
|
|
381
|
+
// Command Validation
|
|
382
|
+
// ===========================================================================
|
|
383
|
+
/**
|
|
384
|
+
* Validate a command before execution.
|
|
385
|
+
*
|
|
386
|
+
* @param command - Command to validate
|
|
387
|
+
* @throws {CommandBlockedError} If the command is blocked
|
|
388
|
+
* @internal
|
|
389
|
+
*/
|
|
390
|
+
validateCommand(command) {
|
|
391
|
+
// Check allowlist first (if configured)
|
|
392
|
+
if (this.allowedCommands && this.allowedCommands.length > 0) {
|
|
393
|
+
const isAllowed = this.allowedCommands.some((pattern) => this.matchesPattern(command, pattern));
|
|
394
|
+
if (!isAllowed) {
|
|
395
|
+
throw new CommandBlockedError(command, "Command not in allowlist");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
// Check blocklist
|
|
399
|
+
for (const pattern of this.blockedCommands) {
|
|
400
|
+
if (this.matchesPattern(command, pattern)) {
|
|
401
|
+
throw new CommandBlockedError(command, "Command matches blocked pattern");
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Check dangerous patterns (unless explicitly allowed)
|
|
405
|
+
if (!this.allowDangerous) {
|
|
406
|
+
for (const pattern of DANGEROUS_PATTERNS) {
|
|
407
|
+
if (pattern.test(command)) {
|
|
408
|
+
throw new CommandBlockedError(command, `Command matches dangerous pattern: ${pattern.source.slice(0, 50)}`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Check if a command matches a pattern.
|
|
415
|
+
* @internal
|
|
416
|
+
*/
|
|
417
|
+
matchesPattern(command, pattern) {
|
|
418
|
+
if (typeof pattern === "string") {
|
|
419
|
+
return command.includes(pattern);
|
|
420
|
+
}
|
|
421
|
+
return pattern.test(command);
|
|
422
|
+
}
|
|
423
|
+
// ===========================================================================
|
|
424
|
+
// Static Factory Methods
|
|
425
|
+
// ===========================================================================
|
|
426
|
+
/**
|
|
427
|
+
* Create a LocalSandbox with restricted permissions.
|
|
428
|
+
*
|
|
429
|
+
* This factory creates a sandbox that only allows read-only commands.
|
|
430
|
+
*
|
|
431
|
+
* @param options - Base options
|
|
432
|
+
* @returns A restricted LocalSandbox
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* const sandbox = LocalSandbox.readOnly({ cwd: "/home/user/project" });
|
|
437
|
+
* await sandbox.execute("ls -la"); // OK
|
|
438
|
+
* await sandbox.execute("rm file.txt"); // Throws CommandBlockedError
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
static readOnly(options = {}) {
|
|
442
|
+
return new LocalSandbox({
|
|
443
|
+
...options,
|
|
444
|
+
blockedCommands: [
|
|
445
|
+
// Block any write operations
|
|
446
|
+
/\brm\b/i,
|
|
447
|
+
/\bmv\b/i,
|
|
448
|
+
/\bcp\b/i,
|
|
449
|
+
/\btouch\b/i,
|
|
450
|
+
/\bmkdir\b/i,
|
|
451
|
+
/\brmdir\b/i,
|
|
452
|
+
/\bchmod\b/i,
|
|
453
|
+
/\bchown\b/i,
|
|
454
|
+
/\bln\b/i,
|
|
455
|
+
/>/, // Redirect
|
|
456
|
+
/\bdd\b/i,
|
|
457
|
+
/\bwrite\b/i,
|
|
458
|
+
/\bnpm\s+(install|uninstall|update|publish)/i,
|
|
459
|
+
/\byarn\s+(add|remove|upgrade|publish)/i,
|
|
460
|
+
/\bpip\s+(install|uninstall)/i,
|
|
461
|
+
/\bgit\s+(push|commit|merge|rebase)/i,
|
|
462
|
+
],
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
// =============================================================================
|
|
467
|
+
// Factory Functions
|
|
468
|
+
// =============================================================================
|
|
469
|
+
/**
|
|
470
|
+
* Create a LocalSandbox with the specified options.
|
|
471
|
+
*
|
|
472
|
+
* @param options - Configuration options
|
|
473
|
+
* @returns A new LocalSandbox instance
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const sandbox = createLocalSandbox({
|
|
478
|
+
* cwd: "/home/user/project",
|
|
479
|
+
* timeout: 30000,
|
|
480
|
+
* });
|
|
481
|
+
* ```
|
|
482
|
+
*
|
|
483
|
+
* @category Backend
|
|
484
|
+
*/
|
|
485
|
+
export function createLocalSandbox(options) {
|
|
486
|
+
return new LocalSandbox(options);
|
|
487
|
+
}
|
|
488
|
+
// Re-export related types from backend
|
|
489
|
+
export { PathTraversalError, SymlinkError, FileSizeLimitError };
|
|
490
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../src/backends/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAYlC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAE1B;IACA;IAFlB,YACkB,OAAe,EACf,SAAiB;QAEjC,KAAK,CACH,2BAA2B,SAAS,QAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CACzG,CAAC;QALc,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAQ;QAKjC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAE1B;IACA;IAFlB,YACkB,OAAe,EACf,MAAc;QAE9B,KAAK,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAC;QAHpB,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QAG9B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAwFD,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAEhF;;;;GAI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