gitx.do 0.0.1 → 0.0.3
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/dist/cli/commands/blame.d.ts +259 -0
- package/dist/cli/commands/blame.d.ts.map +1 -0
- package/dist/cli/commands/blame.js +609 -0
- package/dist/cli/commands/blame.js.map +1 -0
- package/dist/cli/commands/branch.d.ts +249 -0
- package/dist/cli/commands/branch.d.ts.map +1 -0
- package/dist/cli/commands/branch.js +693 -0
- package/dist/cli/commands/branch.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +182 -0
- package/dist/cli/commands/commit.d.ts.map +1 -0
- package/dist/cli/commands/commit.js +437 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/diff.d.ts +464 -0
- package/dist/cli/commands/diff.d.ts.map +1 -0
- package/dist/cli/commands/diff.js +958 -0
- package/dist/cli/commands/diff.js.map +1 -0
- package/dist/cli/commands/log.d.ts +239 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +535 -0
- package/dist/cli/commands/log.js.map +1 -0
- package/dist/cli/commands/review.d.ts +457 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +533 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/status.d.ts +269 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +493 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/web.d.ts +199 -0
- package/dist/cli/commands/web.d.ts.map +1 -0
- package/dist/cli/commands/web.js +696 -0
- package/dist/cli/commands/web.js.map +1 -0
- package/dist/cli/fs-adapter.d.ts +656 -0
- package/dist/cli/fs-adapter.d.ts.map +1 -0
- package/dist/cli/fs-adapter.js +1179 -0
- package/dist/cli/fs-adapter.js.map +1 -0
- package/dist/cli/index.d.ts +387 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +523 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/components/DiffView.d.ts +7 -0
- package/dist/cli/ui/components/DiffView.d.ts.map +1 -0
- package/dist/cli/ui/components/DiffView.js +11 -0
- package/dist/cli/ui/components/DiffView.js.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts +6 -0
- package/dist/cli/ui/components/ErrorDisplay.d.ts.map +1 -0
- package/dist/cli/ui/components/ErrorDisplay.js +11 -0
- package/dist/cli/ui/components/ErrorDisplay.js.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts +9 -0
- package/dist/cli/ui/components/FuzzySearch.d.ts.map +1 -0
- package/dist/cli/ui/components/FuzzySearch.js +12 -0
- package/dist/cli/ui/components/FuzzySearch.js.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts +6 -0
- package/dist/cli/ui/components/LoadingSpinner.d.ts.map +1 -0
- package/dist/cli/ui/components/LoadingSpinner.js +10 -0
- package/dist/cli/ui/components/LoadingSpinner.js.map +1 -0
- package/dist/cli/ui/components/NavigationList.d.ts +9 -0
- package/dist/cli/ui/components/NavigationList.d.ts.map +1 -0
- package/dist/cli/ui/components/NavigationList.js +11 -0
- package/dist/cli/ui/components/NavigationList.js.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts +8 -0
- package/dist/cli/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/cli/ui/components/ScrollableContent.js +11 -0
- package/dist/cli/ui/components/ScrollableContent.js.map +1 -0
- package/dist/cli/ui/components/index.d.ts +7 -0
- package/dist/cli/ui/components/index.d.ts.map +1 -0
- package/dist/cli/ui/components/index.js +9 -0
- package/dist/cli/ui/components/index.js.map +1 -0
- package/dist/cli/ui/terminal-ui.d.ts +52 -0
- package/dist/cli/ui/terminal-ui.d.ts.map +1 -0
- package/dist/cli/ui/terminal-ui.js +121 -0
- package/dist/cli/ui/terminal-ui.js.map +1 -0
- package/dist/durable-object/object-store.d.ts +401 -23
- package/dist/durable-object/object-store.d.ts.map +1 -1
- package/dist/durable-object/object-store.js +414 -25
- package/dist/durable-object/object-store.js.map +1 -1
- package/dist/durable-object/schema.d.ts +188 -0
- package/dist/durable-object/schema.d.ts.map +1 -1
- package/dist/durable-object/schema.js +160 -0
- package/dist/durable-object/schema.js.map +1 -1
- package/dist/durable-object/wal.d.ts +336 -31
- package/dist/durable-object/wal.d.ts.map +1 -1
- package/dist/durable-object/wal.js +272 -27
- package/dist/durable-object/wal.js.map +1 -1
- package/dist/index.d.ts +379 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +379 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/adapter.d.ts +579 -38
- package/dist/mcp/adapter.d.ts.map +1 -1
- package/dist/mcp/adapter.js +426 -33
- package/dist/mcp/adapter.js.map +1 -1
- package/dist/mcp/sandbox.d.ts +532 -29
- package/dist/mcp/sandbox.d.ts.map +1 -1
- package/dist/mcp/sandbox.js +389 -22
- package/dist/mcp/sandbox.js.map +1 -1
- package/dist/mcp/sdk-adapter.d.ts +478 -56
- package/dist/mcp/sdk-adapter.d.ts.map +1 -1
- package/dist/mcp/sdk-adapter.js +346 -44
- package/dist/mcp/sdk-adapter.js.map +1 -1
- package/dist/mcp/tools.d.ts +445 -30
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +363 -33
- package/dist/mcp/tools.js.map +1 -1
- package/dist/ops/blame.d.ts +424 -21
- package/dist/ops/blame.d.ts.map +1 -1
- package/dist/ops/blame.js +303 -20
- package/dist/ops/blame.js.map +1 -1
- package/dist/ops/branch.d.ts +583 -32
- package/dist/ops/branch.d.ts.map +1 -1
- package/dist/ops/branch.js +365 -23
- package/dist/ops/branch.js.map +1 -1
- package/dist/ops/commit-traversal.d.ts +164 -24
- package/dist/ops/commit-traversal.d.ts.map +1 -1
- package/dist/ops/commit-traversal.js +68 -2
- package/dist/ops/commit-traversal.js.map +1 -1
- package/dist/ops/commit.d.ts +387 -53
- package/dist/ops/commit.d.ts.map +1 -1
- package/dist/ops/commit.js +249 -29
- package/dist/ops/commit.js.map +1 -1
- package/dist/ops/merge-base.d.ts +195 -21
- package/dist/ops/merge-base.d.ts.map +1 -1
- package/dist/ops/merge-base.js +122 -12
- package/dist/ops/merge-base.js.map +1 -1
- package/dist/ops/merge.d.ts +600 -130
- package/dist/ops/merge.d.ts.map +1 -1
- package/dist/ops/merge.js +408 -60
- package/dist/ops/merge.js.map +1 -1
- package/dist/ops/tag.d.ts +67 -2
- package/dist/ops/tag.d.ts.map +1 -1
- package/dist/ops/tag.js +42 -1
- package/dist/ops/tag.js.map +1 -1
- package/dist/ops/tree-builder.d.ts +102 -6
- package/dist/ops/tree-builder.d.ts.map +1 -1
- package/dist/ops/tree-builder.js +30 -5
- package/dist/ops/tree-builder.js.map +1 -1
- package/dist/ops/tree-diff.d.ts +50 -2
- package/dist/ops/tree-diff.d.ts.map +1 -1
- package/dist/ops/tree-diff.js +50 -2
- package/dist/ops/tree-diff.js.map +1 -1
- package/dist/pack/delta.d.ts +211 -39
- package/dist/pack/delta.d.ts.map +1 -1
- package/dist/pack/delta.js +232 -46
- package/dist/pack/delta.js.map +1 -1
- package/dist/pack/format.d.ts +390 -28
- package/dist/pack/format.d.ts.map +1 -1
- package/dist/pack/format.js +344 -33
- package/dist/pack/format.js.map +1 -1
- package/dist/pack/full-generation.d.ts +313 -28
- package/dist/pack/full-generation.d.ts.map +1 -1
- package/dist/pack/full-generation.js +238 -19
- package/dist/pack/full-generation.js.map +1 -1
- package/dist/pack/generation.d.ts +346 -23
- package/dist/pack/generation.d.ts.map +1 -1
- package/dist/pack/generation.js +269 -21
- package/dist/pack/generation.js.map +1 -1
- package/dist/pack/index.d.ts +407 -86
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +351 -70
- package/dist/pack/index.js.map +1 -1
- package/dist/refs/branch.d.ts +517 -71
- package/dist/refs/branch.d.ts.map +1 -1
- package/dist/refs/branch.js +410 -26
- package/dist/refs/branch.js.map +1 -1
- package/dist/refs/storage.d.ts +610 -57
- package/dist/refs/storage.d.ts.map +1 -1
- package/dist/refs/storage.js +481 -29
- package/dist/refs/storage.js.map +1 -1
- package/dist/refs/tag.d.ts +677 -67
- package/dist/refs/tag.d.ts.map +1 -1
- package/dist/refs/tag.js +497 -30
- package/dist/refs/tag.js.map +1 -1
- package/dist/storage/lru-cache.d.ts +556 -53
- package/dist/storage/lru-cache.d.ts.map +1 -1
- package/dist/storage/lru-cache.js +439 -36
- package/dist/storage/lru-cache.js.map +1 -1
- package/dist/storage/object-index.d.ts +483 -38
- package/dist/storage/object-index.d.ts.map +1 -1
- package/dist/storage/object-index.js +388 -22
- package/dist/storage/object-index.js.map +1 -1
- package/dist/storage/r2-pack.d.ts +957 -94
- package/dist/storage/r2-pack.d.ts.map +1 -1
- package/dist/storage/r2-pack.js +756 -48
- package/dist/storage/r2-pack.js.map +1 -1
- package/dist/tiered/cdc-pipeline.d.ts +1610 -38
- package/dist/tiered/cdc-pipeline.d.ts.map +1 -1
- package/dist/tiered/cdc-pipeline.js +1131 -22
- package/dist/tiered/cdc-pipeline.js.map +1 -1
- package/dist/tiered/migration.d.ts +903 -41
- package/dist/tiered/migration.d.ts.map +1 -1
- package/dist/tiered/migration.js +646 -24
- package/dist/tiered/migration.js.map +1 -1
- package/dist/tiered/parquet-writer.d.ts +944 -47
- package/dist/tiered/parquet-writer.d.ts.map +1 -1
- package/dist/tiered/parquet-writer.js +667 -39
- package/dist/tiered/parquet-writer.js.map +1 -1
- package/dist/tiered/read-path.d.ts +728 -34
- package/dist/tiered/read-path.d.ts.map +1 -1
- package/dist/tiered/read-path.js +310 -27
- package/dist/tiered/read-path.js.map +1 -1
- package/dist/types/objects.d.ts +457 -0
- package/dist/types/objects.d.ts.map +1 -1
- package/dist/types/objects.js +305 -4
- package/dist/types/objects.js.map +1 -1
- package/dist/types/storage.d.ts +407 -35
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types/storage.js +27 -3
- package/dist/types/storage.js.map +1 -1
- package/dist/utils/hash.d.ts +133 -12
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +133 -12
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/sha1.d.ts +102 -9
- package/dist/utils/sha1.d.ts.map +1 -1
- package/dist/utils/sha1.js +114 -11
- package/dist/utils/sha1.js.map +1 -1
- package/dist/wire/capabilities.d.ts +896 -88
- package/dist/wire/capabilities.d.ts.map +1 -1
- package/dist/wire/capabilities.js +566 -62
- package/dist/wire/capabilities.js.map +1 -1
- package/dist/wire/pkt-line.d.ts +293 -15
- package/dist/wire/pkt-line.d.ts.map +1 -1
- package/dist/wire/pkt-line.js +251 -15
- package/dist/wire/pkt-line.js.map +1 -1
- package/dist/wire/receive-pack.d.ts +814 -64
- package/dist/wire/receive-pack.d.ts.map +1 -1
- package/dist/wire/receive-pack.js +542 -41
- package/dist/wire/receive-pack.js.map +1 -1
- package/dist/wire/smart-http.d.ts +575 -97
- package/dist/wire/smart-http.d.ts.map +1 -1
- package/dist/wire/smart-http.js +337 -46
- package/dist/wire/smart-http.js.map +1 -1
- package/dist/wire/upload-pack.d.ts +492 -98
- package/dist/wire/upload-pack.d.ts.map +1 -1
- package/dist/wire/upload-pack.js +347 -59
- package/dist/wire/upload-pack.js.map +1 -1
- package/package.json +10 -2
package/dist/mcp/sandbox.d.ts
CHANGED
|
@@ -1,40 +1,136 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP Sandbox Execution Environment
|
|
2
|
+
* @fileoverview MCP Sandbox Execution Environment
|
|
3
3
|
*
|
|
4
|
-
* Provides isolated execution environment for MCP tools with:
|
|
5
|
-
* - Resource limits (memory, CPU, time)
|
|
6
|
-
* - Capability restrictions (file, network, process)
|
|
7
|
-
* - Safe git operation execution
|
|
8
|
-
* - Audit logging
|
|
4
|
+
* Provides an isolated execution environment for MCP tools with:
|
|
5
|
+
* - Resource limits (memory, CPU, time, file descriptors, disk)
|
|
6
|
+
* - Capability restrictions (file read/write, network, process spawning)
|
|
7
|
+
* - Safe git operation execution with permission checks
|
|
8
|
+
* - Audit logging for security violations
|
|
9
9
|
*
|
|
10
|
-
* SECURITY: Uses Node.js vm module for proper isolation
|
|
11
|
-
*
|
|
10
|
+
* SECURITY: Uses Node.js vm module concepts for proper isolation. The sandbox
|
|
11
|
+
* implements multi-layer security through:
|
|
12
|
+
* 1. Pre-execution static analysis to detect dangerous patterns
|
|
13
|
+
* 2. Runtime permission checks via Proxy-based module interception
|
|
14
|
+
* 3. Resource limit enforcement during execution
|
|
15
|
+
* 4. Permission violation recording for audit trails
|
|
16
|
+
*
|
|
17
|
+
* @module mcp/sandbox
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create a sandbox with limited permissions
|
|
21
|
+
* import { createSandbox, SandboxState } from './sandbox'
|
|
22
|
+
*
|
|
23
|
+
* const sandbox = createSandbox({
|
|
24
|
+
* timeout: 5000,
|
|
25
|
+
* memoryLimit: 128 * 1024 * 1024,
|
|
26
|
+
* permissions: {
|
|
27
|
+
* fileRead: true,
|
|
28
|
+
* fileWrite: false,
|
|
29
|
+
* network: false,
|
|
30
|
+
* spawn: false
|
|
31
|
+
* }
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* await sandbox.start()
|
|
35
|
+
* const result = await sandbox.execute(() => {
|
|
36
|
+
* return 'Hello from sandbox!'
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* if (result.error) {
|
|
40
|
+
* console.error('Execution failed:', result.error.message)
|
|
41
|
+
* } else {
|
|
42
|
+
* console.log('Result:', result.value)
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* await sandbox.destroy()
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Using a sandbox pool for concurrent execution
|
|
49
|
+
* import { createSandboxPool } from './sandbox'
|
|
50
|
+
*
|
|
51
|
+
* const pool = createSandboxPool({ size: 4 })
|
|
52
|
+
* const sandbox = await pool.acquire()
|
|
53
|
+
*
|
|
54
|
+
* try {
|
|
55
|
+
* const result = await sandbox.execute(myFunction)
|
|
56
|
+
* } finally {
|
|
57
|
+
* await pool.release(sandbox)
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* await pool.shutdown()
|
|
12
61
|
*/
|
|
13
62
|
import { EventEmitter } from 'events';
|
|
14
63
|
/**
|
|
15
|
-
* Sandbox error codes
|
|
64
|
+
* Sandbox error codes.
|
|
65
|
+
*
|
|
66
|
+
* @description
|
|
67
|
+
* Enumeration of all possible error codes that can be returned by sandbox
|
|
68
|
+
* operations. These codes indicate the specific reason for execution failure.
|
|
69
|
+
*
|
|
70
|
+
* @enum {string}
|
|
16
71
|
*/
|
|
17
72
|
export declare enum SandboxErrorCode {
|
|
73
|
+
/** Execution exceeded the configured timeout */
|
|
18
74
|
TIMEOUT = "TIMEOUT",
|
|
75
|
+
/** Memory usage exceeded the configured limit */
|
|
19
76
|
MEMORY_LIMIT_EXCEEDED = "MEMORY_LIMIT_EXCEEDED",
|
|
77
|
+
/** CPU time exceeded the configured limit */
|
|
20
78
|
CPU_LIMIT_EXCEEDED = "CPU_LIMIT_EXCEEDED",
|
|
79
|
+
/** Operation was denied due to insufficient permissions */
|
|
21
80
|
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
81
|
+
/** General execution error occurred */
|
|
22
82
|
EXECUTION_ERROR = "EXECUTION_ERROR",
|
|
83
|
+
/** Too many file descriptors opened */
|
|
23
84
|
FILE_DESCRIPTOR_LIMIT = "FILE_DESCRIPTOR_LIMIT",
|
|
85
|
+
/** Too many processes spawned */
|
|
24
86
|
PROCESS_LIMIT_EXCEEDED = "PROCESS_LIMIT_EXCEEDED",
|
|
87
|
+
/** Network bandwidth limit exceeded */
|
|
25
88
|
BANDWIDTH_LIMIT_EXCEEDED = "BANDWIDTH_LIMIT_EXCEEDED",
|
|
89
|
+
/** Disk write limit exceeded */
|
|
26
90
|
DISK_LIMIT_EXCEEDED = "DISK_LIMIT_EXCEEDED",
|
|
91
|
+
/** Sandbox crashed unexpectedly */
|
|
27
92
|
SANDBOX_CRASHED = "SANDBOX_CRASHED",
|
|
93
|
+
/** Sandbox is paused and not accepting executions */
|
|
28
94
|
SANDBOX_PAUSED = "SANDBOX_PAUSED"
|
|
29
95
|
}
|
|
30
96
|
/**
|
|
31
|
-
* Sandbox error class
|
|
97
|
+
* Sandbox error class.
|
|
98
|
+
*
|
|
99
|
+
* @description
|
|
100
|
+
* Custom error class for sandbox-specific errors. Includes an error code
|
|
101
|
+
* for programmatic handling and optional additional data.
|
|
102
|
+
*
|
|
103
|
+
* @class SandboxError
|
|
104
|
+
* @extends Error
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* try {
|
|
108
|
+
* await sandbox.execute(fn)
|
|
109
|
+
* } catch (error) {
|
|
110
|
+
* if (error instanceof SandboxError) {
|
|
111
|
+
* console.log('Error code:', error.code)
|
|
112
|
+
* console.log('Error data:', error.data)
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
32
115
|
*/
|
|
33
116
|
export declare class SandboxError extends Error {
|
|
117
|
+
/** The error code identifying the type of error */
|
|
34
118
|
code: SandboxErrorCode;
|
|
119
|
+
/** Optional additional error data */
|
|
35
120
|
data?: Record<string, unknown>;
|
|
121
|
+
/** Stack trace (inherited from Error) */
|
|
36
122
|
stack?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Create a new sandbox error.
|
|
125
|
+
* @param code - The error code
|
|
126
|
+
* @param message - Human-readable error message
|
|
127
|
+
* @param data - Optional additional error data
|
|
128
|
+
*/
|
|
37
129
|
constructor(code: SandboxErrorCode, message: string, data?: Record<string, unknown>);
|
|
130
|
+
/**
|
|
131
|
+
* Convert error to JSON representation.
|
|
132
|
+
* @returns JSON-serializable error object
|
|
133
|
+
*/
|
|
38
134
|
toJSON(): {
|
|
39
135
|
code: SandboxErrorCode;
|
|
40
136
|
message: string;
|
|
@@ -42,120 +138,298 @@ export declare class SandboxError extends Error {
|
|
|
42
138
|
};
|
|
43
139
|
}
|
|
44
140
|
/**
|
|
45
|
-
* Sandbox state enum
|
|
141
|
+
* Sandbox state enum.
|
|
142
|
+
*
|
|
143
|
+
* @description
|
|
144
|
+
* Represents the lifecycle state of a sandbox instance.
|
|
145
|
+
*
|
|
146
|
+
* @enum {string}
|
|
46
147
|
*/
|
|
47
148
|
export declare enum SandboxState {
|
|
149
|
+
/** Sandbox is idle and ready for use */
|
|
48
150
|
IDLE = "IDLE",
|
|
151
|
+
/** Sandbox is currently executing code */
|
|
49
152
|
RUNNING = "RUNNING",
|
|
153
|
+
/** Sandbox is paused (can be resumed) */
|
|
50
154
|
PAUSED = "PAUSED",
|
|
155
|
+
/** Sandbox has been destroyed and cannot be reused */
|
|
51
156
|
DESTROYED = "DESTROYED"
|
|
52
157
|
}
|
|
53
158
|
/**
|
|
54
|
-
* Isolation level for sandbox
|
|
159
|
+
* Isolation level for sandbox.
|
|
160
|
+
*
|
|
161
|
+
* @description
|
|
162
|
+
* Determines how strictly the sandbox enforces isolation:
|
|
163
|
+
* - 'strict': Most restrictive, blocks native modules
|
|
164
|
+
* - 'normal': Default, balanced security
|
|
165
|
+
* - 'lax': Least restrictive
|
|
166
|
+
*
|
|
167
|
+
* @typedef {'strict' | 'normal' | 'lax'} IsolationLevel
|
|
55
168
|
*/
|
|
56
169
|
export type IsolationLevel = 'strict' | 'normal' | 'lax';
|
|
57
170
|
/**
|
|
58
|
-
* Resource limits configuration
|
|
171
|
+
* Resource limits configuration.
|
|
172
|
+
*
|
|
173
|
+
* @description
|
|
174
|
+
* Defines limits on system resources that the sandbox can consume.
|
|
175
|
+
*
|
|
176
|
+
* @interface ResourceLimits
|
|
59
177
|
*/
|
|
60
178
|
export interface ResourceLimits {
|
|
179
|
+
/** Maximum memory usage in bytes */
|
|
61
180
|
memoryLimit?: number;
|
|
181
|
+
/** Maximum CPU time in milliseconds */
|
|
62
182
|
cpuTimeLimit?: number;
|
|
183
|
+
/** Maximum number of open file handles */
|
|
63
184
|
maxOpenFiles?: number;
|
|
185
|
+
/** Maximum number of spawned processes */
|
|
64
186
|
maxProcesses?: number;
|
|
187
|
+
/** Maximum network bandwidth in bytes/second */
|
|
65
188
|
networkBandwidthLimit?: number;
|
|
189
|
+
/** Maximum disk write in bytes */
|
|
66
190
|
diskWriteLimit?: number;
|
|
67
191
|
}
|
|
68
192
|
/**
|
|
69
|
-
* Permission set for sandbox
|
|
193
|
+
* Permission set for sandbox.
|
|
194
|
+
*
|
|
195
|
+
* @description
|
|
196
|
+
* Defines what operations are allowed within the sandbox.
|
|
197
|
+
*
|
|
198
|
+
* @interface PermissionSet
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* const permissions: PermissionSet = {
|
|
202
|
+
* fileRead: true,
|
|
203
|
+
* fileWrite: false,
|
|
204
|
+
* network: false,
|
|
205
|
+
* spawn: false,
|
|
206
|
+
* allowedPaths: ['/tmp', '/app/data']
|
|
207
|
+
* }
|
|
70
208
|
*/
|
|
71
209
|
export interface PermissionSet {
|
|
210
|
+
/** Allow file read operations */
|
|
72
211
|
fileRead?: boolean;
|
|
212
|
+
/** Allow file write operations */
|
|
73
213
|
fileWrite?: boolean;
|
|
214
|
+
/** Allow network access */
|
|
74
215
|
network?: boolean;
|
|
216
|
+
/** Allow spawning child processes */
|
|
75
217
|
spawn?: boolean;
|
|
218
|
+
/** Allow access to environment variables */
|
|
76
219
|
env?: boolean;
|
|
220
|
+
/** Allow loading native modules */
|
|
77
221
|
nativeModules?: boolean;
|
|
222
|
+
/** List of allowed file paths (whitelist) */
|
|
78
223
|
allowedPaths?: string[];
|
|
224
|
+
/** List of allowed environment variable names */
|
|
79
225
|
envWhitelist?: string[];
|
|
80
226
|
}
|
|
81
227
|
/**
|
|
82
|
-
* Permission preset types
|
|
228
|
+
* Permission preset types.
|
|
229
|
+
*
|
|
230
|
+
* @description
|
|
231
|
+
* Pre-configured permission sets for common use cases:
|
|
232
|
+
* - 'readonly': File read only, no write/network/spawn
|
|
233
|
+
* - 'full': All permissions enabled
|
|
234
|
+
* - 'network-only': Network access only, no file access
|
|
235
|
+
*
|
|
236
|
+
* @typedef {'readonly' | 'full' | 'network-only'} PermissionPreset
|
|
83
237
|
*/
|
|
84
238
|
export type PermissionPreset = 'readonly' | 'full' | 'network-only';
|
|
85
239
|
/**
|
|
86
|
-
* Sandbox configuration
|
|
240
|
+
* Sandbox configuration.
|
|
241
|
+
*
|
|
242
|
+
* @description
|
|
243
|
+
* Complete configuration options for creating a sandbox instance.
|
|
244
|
+
*
|
|
245
|
+
* @interface SandboxConfig
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* const config: SandboxConfig = {
|
|
249
|
+
* timeout: 30000,
|
|
250
|
+
* memoryLimit: 256 * 1024 * 1024,
|
|
251
|
+
* isolationLevel: 'strict',
|
|
252
|
+
* permissionPreset: 'readonly'
|
|
253
|
+
* }
|
|
87
254
|
*/
|
|
88
255
|
export interface SandboxConfig {
|
|
256
|
+
/** Execution timeout in milliseconds (default: 30000) */
|
|
89
257
|
timeout?: number;
|
|
258
|
+
/** Memory limit in bytes (default: 256MB) */
|
|
90
259
|
memoryLimit?: number;
|
|
260
|
+
/** CPU time limit in milliseconds */
|
|
91
261
|
cpuTimeLimit?: number;
|
|
262
|
+
/** Maximum open file handles */
|
|
92
263
|
maxOpenFiles?: number;
|
|
264
|
+
/** Maximum spawned processes */
|
|
93
265
|
maxProcesses?: number;
|
|
266
|
+
/** Network bandwidth limit in bytes/second */
|
|
94
267
|
networkBandwidthLimit?: number;
|
|
268
|
+
/** Disk write limit in bytes */
|
|
95
269
|
diskWriteLimit?: number;
|
|
270
|
+
/** Isolation level (default: 'normal') */
|
|
96
271
|
isolationLevel?: IsolationLevel;
|
|
272
|
+
/** Environment variables to expose */
|
|
97
273
|
env?: Record<string, string>;
|
|
274
|
+
/** Working directory for file operations */
|
|
98
275
|
workingDirectory?: string;
|
|
276
|
+
/** Custom permission set */
|
|
99
277
|
permissions?: PermissionSet;
|
|
278
|
+
/** Use a preset permission configuration */
|
|
100
279
|
permissionPreset?: PermissionPreset;
|
|
280
|
+
/** Resource limits (alternative to individual limit fields) */
|
|
101
281
|
resourceLimits?: ResourceLimits;
|
|
282
|
+
/** If true, queue executions when paused instead of rejecting */
|
|
102
283
|
queueOnPause?: boolean;
|
|
284
|
+
/** Maximum concurrent executions */
|
|
103
285
|
maxConcurrentExecutions?: number;
|
|
104
286
|
}
|
|
105
287
|
/**
|
|
106
|
-
* Execution options
|
|
288
|
+
* Execution options.
|
|
289
|
+
*
|
|
290
|
+
* @description
|
|
291
|
+
* Options for a single execution within a sandbox.
|
|
292
|
+
*
|
|
293
|
+
* @interface ExecutionOptions
|
|
107
294
|
*/
|
|
108
295
|
export interface ExecutionOptions {
|
|
296
|
+
/** Override default timeout for this execution */
|
|
109
297
|
timeout?: number;
|
|
298
|
+
/** Additional context data passed to the execution */
|
|
110
299
|
context?: Record<string, unknown>;
|
|
111
300
|
}
|
|
112
301
|
/**
|
|
113
|
-
* Resource usage statistics
|
|
302
|
+
* Resource usage statistics.
|
|
303
|
+
*
|
|
304
|
+
* @description
|
|
305
|
+
* Statistics about resource usage accumulated across sandbox executions.
|
|
306
|
+
*
|
|
307
|
+
* @interface ResourceStats
|
|
114
308
|
*/
|
|
115
309
|
export interface ResourceStats {
|
|
310
|
+
/** Current memory usage in bytes */
|
|
116
311
|
memoryUsed: number;
|
|
312
|
+
/** Total CPU time used in milliseconds */
|
|
117
313
|
cpuTimeUsed: number;
|
|
314
|
+
/** Number of executions performed */
|
|
118
315
|
executionCount: number;
|
|
316
|
+
/** Number of active handles/resources */
|
|
119
317
|
activeHandles: number;
|
|
120
318
|
}
|
|
121
319
|
/**
|
|
122
|
-
* Resource usage in result
|
|
320
|
+
* Resource usage in result.
|
|
321
|
+
*
|
|
322
|
+
* @description
|
|
323
|
+
* Resource usage information for a specific execution.
|
|
324
|
+
*
|
|
325
|
+
* @interface ResourceUsage
|
|
123
326
|
*/
|
|
124
327
|
export interface ResourceUsage {
|
|
328
|
+
/** Memory used during execution */
|
|
125
329
|
memoryUsed: number;
|
|
330
|
+
/** CPU time used during execution */
|
|
126
331
|
cpuTimeUsed?: number;
|
|
127
332
|
}
|
|
128
333
|
/**
|
|
129
|
-
* Result metadata
|
|
334
|
+
* Result metadata.
|
|
335
|
+
*
|
|
336
|
+
* @description
|
|
337
|
+
* Timing information for a sandbox execution.
|
|
338
|
+
*
|
|
339
|
+
* @interface ResultMetadata
|
|
130
340
|
*/
|
|
131
341
|
export interface ResultMetadata {
|
|
342
|
+
/** Execution start timestamp (ms since epoch) */
|
|
132
343
|
startTime: number;
|
|
344
|
+
/** Execution end timestamp (ms since epoch) */
|
|
133
345
|
endTime: number;
|
|
346
|
+
/** Total elapsed time in milliseconds */
|
|
134
347
|
elapsedMs: number;
|
|
135
348
|
}
|
|
136
349
|
/**
|
|
137
|
-
* Permission violation record
|
|
350
|
+
* Permission violation record.
|
|
351
|
+
*
|
|
352
|
+
* @description
|
|
353
|
+
* Records a permission violation attempt for audit purposes.
|
|
354
|
+
*
|
|
355
|
+
* @interface PermissionViolation
|
|
138
356
|
*/
|
|
139
357
|
export interface PermissionViolation {
|
|
358
|
+
/** The permission that was violated */
|
|
140
359
|
permission: string;
|
|
360
|
+
/** When the violation occurred (ms since epoch) */
|
|
141
361
|
timestamp: number;
|
|
362
|
+
/** Additional details about the violation */
|
|
142
363
|
details?: string;
|
|
143
364
|
}
|
|
144
365
|
/**
|
|
145
|
-
* Sandbox execution result
|
|
366
|
+
* Sandbox execution result.
|
|
367
|
+
*
|
|
368
|
+
* @description
|
|
369
|
+
* The result of executing code within a sandbox. Contains either
|
|
370
|
+
* a value (on success) or an error (on failure), plus metadata.
|
|
371
|
+
*
|
|
372
|
+
* @interface SandboxResult
|
|
373
|
+
* @template T - Type of the return value
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* const result = await sandbox.execute<number>(() => 42)
|
|
377
|
+
* if (result.error) {
|
|
378
|
+
* console.error('Failed:', result.error.message)
|
|
379
|
+
* } else {
|
|
380
|
+
* console.log('Success:', result.value) // 42
|
|
381
|
+
* }
|
|
146
382
|
*/
|
|
147
383
|
export interface SandboxResult<T = unknown> {
|
|
384
|
+
/** The execution result value (on success) */
|
|
148
385
|
value?: T;
|
|
386
|
+
/** The error (on failure) */
|
|
149
387
|
error?: SandboxError;
|
|
388
|
+
/** ID of the sandbox that executed the code */
|
|
150
389
|
sandboxId: string;
|
|
390
|
+
/** Timing metadata */
|
|
151
391
|
metadata?: ResultMetadata;
|
|
392
|
+
/** Resource usage during execution */
|
|
152
393
|
resourceUsage?: ResourceUsage;
|
|
153
394
|
}
|
|
154
395
|
/**
|
|
155
|
-
* MCP Sandbox class for isolated execution
|
|
396
|
+
* MCP Sandbox class for isolated execution.
|
|
397
|
+
*
|
|
398
|
+
* @description
|
|
399
|
+
* Provides an isolated execution environment with resource limits and
|
|
400
|
+
* permission controls. Uses multi-layer security including static analysis,
|
|
401
|
+
* runtime permission checks, and resource limit enforcement.
|
|
402
|
+
*
|
|
403
|
+
* SECURITY: This implementation uses Node.js vm module concepts with proper
|
|
404
|
+
* context isolation and runtime permission checks instead of string analysis.
|
|
405
|
+
*
|
|
406
|
+
* Lifecycle:
|
|
407
|
+
* 1. Create sandbox with createSandbox() or new MCPSandbox()
|
|
408
|
+
* 2. Start the sandbox with start()
|
|
409
|
+
* 3. Execute code with execute()
|
|
410
|
+
* 4. Optionally pause()/resume()
|
|
411
|
+
* 5. Cleanup with cleanup() or destroy()
|
|
412
|
+
*
|
|
413
|
+
* @class MCPSandbox
|
|
414
|
+
* @extends EventEmitter
|
|
415
|
+
*
|
|
416
|
+
* @fires stateChange - When sandbox state changes
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* const sandbox = new MCPSandbox({
|
|
420
|
+
* timeout: 5000,
|
|
421
|
+
* permissions: { fileRead: true, fileWrite: false }
|
|
422
|
+
* })
|
|
156
423
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
424
|
+
* await sandbox.start()
|
|
425
|
+
*
|
|
426
|
+
* const result = await sandbox.execute(() => {
|
|
427
|
+
* return 'Hello from sandbox!'
|
|
428
|
+
* })
|
|
429
|
+
*
|
|
430
|
+
* console.log(result.value) // 'Hello from sandbox!'
|
|
431
|
+
*
|
|
432
|
+
* await sandbox.destroy()
|
|
159
433
|
*/
|
|
160
434
|
export declare class MCPSandbox extends EventEmitter {
|
|
161
435
|
private id;
|
|
@@ -167,20 +441,130 @@ export declare class MCPSandbox extends EventEmitter {
|
|
|
167
441
|
private executionQueue;
|
|
168
442
|
private activeExecutions;
|
|
169
443
|
private globalContext;
|
|
444
|
+
/**
|
|
445
|
+
* Create a new sandbox instance.
|
|
446
|
+
* @param config - Configuration options
|
|
447
|
+
*/
|
|
170
448
|
constructor(config?: SandboxConfig);
|
|
449
|
+
/**
|
|
450
|
+
* Get the sandbox ID.
|
|
451
|
+
* @returns Unique sandbox identifier
|
|
452
|
+
*/
|
|
171
453
|
getId(): string;
|
|
454
|
+
/**
|
|
455
|
+
* Get the sandbox configuration.
|
|
456
|
+
* @returns Copy of the configuration
|
|
457
|
+
*/
|
|
172
458
|
getConfig(): SandboxConfig;
|
|
459
|
+
/**
|
|
460
|
+
* Get the current sandbox state.
|
|
461
|
+
* @returns Current SandboxState
|
|
462
|
+
*/
|
|
173
463
|
getState(): SandboxState;
|
|
464
|
+
/**
|
|
465
|
+
* Get the current permission set.
|
|
466
|
+
* @returns Copy of permissions
|
|
467
|
+
*/
|
|
174
468
|
getPermissions(): PermissionSet;
|
|
469
|
+
/**
|
|
470
|
+
* Get resource usage statistics.
|
|
471
|
+
* @returns Copy of resource stats
|
|
472
|
+
*/
|
|
175
473
|
getResourceStats(): ResourceStats;
|
|
474
|
+
/**
|
|
475
|
+
* Get configured resource limits.
|
|
476
|
+
* @returns Copy of resource limits
|
|
477
|
+
*/
|
|
176
478
|
getResourceLimits(): ResourceLimits;
|
|
479
|
+
/**
|
|
480
|
+
* Get list of permission violations.
|
|
481
|
+
* @returns Array of recorded violations
|
|
482
|
+
*/
|
|
177
483
|
getPermissionViolations(): PermissionViolation[];
|
|
484
|
+
/**
|
|
485
|
+
* Start the sandbox.
|
|
486
|
+
*
|
|
487
|
+
* @description
|
|
488
|
+
* Transitions the sandbox to RUNNING state. Must be called before execute().
|
|
489
|
+
*
|
|
490
|
+
* @returns Promise that resolves when started
|
|
491
|
+
* @throws {Error} If sandbox is destroyed or already running
|
|
492
|
+
*/
|
|
178
493
|
start(): Promise<void>;
|
|
494
|
+
/**
|
|
495
|
+
* Stop the sandbox.
|
|
496
|
+
*
|
|
497
|
+
* @description
|
|
498
|
+
* Transitions from RUNNING or PAUSED to IDLE state. Clears global context.
|
|
499
|
+
*
|
|
500
|
+
* @returns Promise that resolves when stopped
|
|
501
|
+
* @throws {Error} If sandbox is not running
|
|
502
|
+
*/
|
|
179
503
|
stop(): Promise<void>;
|
|
504
|
+
/**
|
|
505
|
+
* Pause the sandbox.
|
|
506
|
+
*
|
|
507
|
+
* @description
|
|
508
|
+
* Temporarily pauses execution. New execute() calls will be queued if
|
|
509
|
+
* queueOnPause is enabled, otherwise they return immediately with an error.
|
|
510
|
+
*
|
|
511
|
+
* @returns Promise that resolves when paused
|
|
512
|
+
* @throws {Error} If sandbox is not running
|
|
513
|
+
*/
|
|
180
514
|
pause(): Promise<void>;
|
|
515
|
+
/**
|
|
516
|
+
* Resume the sandbox.
|
|
517
|
+
*
|
|
518
|
+
* @description
|
|
519
|
+
* Resumes execution after pause. Processes any queued executions.
|
|
520
|
+
*
|
|
521
|
+
* @returns Promise that resolves when resumed
|
|
522
|
+
* @throws {Error} If sandbox is not paused
|
|
523
|
+
*/
|
|
181
524
|
resume(): Promise<void>;
|
|
525
|
+
/**
|
|
526
|
+
* Cleanup sandbox resources.
|
|
527
|
+
*
|
|
528
|
+
* @description
|
|
529
|
+
* Resets resource statistics and clears global context. Sandbox remains
|
|
530
|
+
* usable after cleanup.
|
|
531
|
+
*
|
|
532
|
+
* @returns Promise that resolves when cleanup is complete
|
|
533
|
+
*/
|
|
182
534
|
cleanup(): Promise<void>;
|
|
535
|
+
/**
|
|
536
|
+
* Destroy the sandbox.
|
|
537
|
+
*
|
|
538
|
+
* @description
|
|
539
|
+
* Permanently destroys the sandbox. It cannot be reused after destruction.
|
|
540
|
+
*
|
|
541
|
+
* @returns Promise that resolves when destroyed
|
|
542
|
+
*/
|
|
183
543
|
destroy(): Promise<void>;
|
|
544
|
+
/**
|
|
545
|
+
* Execute a function in the sandbox.
|
|
546
|
+
*
|
|
547
|
+
* @description
|
|
548
|
+
* Executes the provided function within the sandbox's isolated environment.
|
|
549
|
+
* The function is subject to configured timeout, resource limits, and
|
|
550
|
+
* permission restrictions.
|
|
551
|
+
*
|
|
552
|
+
* @template T - Return type of the function
|
|
553
|
+
* @param fn - Function to execute (sync or async)
|
|
554
|
+
* @param options - Execution options (timeout, context)
|
|
555
|
+
* @returns Promise resolving to SandboxResult with value or error
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* const result = await sandbox.execute<number>(() => {
|
|
559
|
+
* return 42
|
|
560
|
+
* })
|
|
561
|
+
*
|
|
562
|
+
* if (result.error) {
|
|
563
|
+
* console.error('Failed:', result.error.code)
|
|
564
|
+
* } else {
|
|
565
|
+
* console.log('Result:', result.value) // 42
|
|
566
|
+
* }
|
|
567
|
+
*/
|
|
184
568
|
execute<T>(fn: (() => T) | (() => Promise<T>), options?: ExecutionOptions): Promise<SandboxResult<T>>;
|
|
185
569
|
private executeInSandbox;
|
|
186
570
|
/**
|
|
@@ -227,35 +611,154 @@ export declare class MCPSandbox extends EventEmitter {
|
|
|
227
611
|
private wrapError;
|
|
228
612
|
}
|
|
229
613
|
/**
|
|
230
|
-
* Create a new sandbox instance
|
|
614
|
+
* Create a new sandbox instance.
|
|
615
|
+
*
|
|
616
|
+
* @description
|
|
617
|
+
* Factory function for creating a new MCPSandbox instance.
|
|
618
|
+
* Equivalent to using `new MCPSandbox(config)`.
|
|
619
|
+
*
|
|
620
|
+
* @param config - Sandbox configuration options
|
|
621
|
+
* @returns A new MCPSandbox instance
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* import { createSandbox } from './sandbox'
|
|
625
|
+
*
|
|
626
|
+
* const sandbox = createSandbox({
|
|
627
|
+
* timeout: 5000,
|
|
628
|
+
* permissions: { fileRead: true, network: false }
|
|
629
|
+
* })
|
|
630
|
+
*
|
|
631
|
+
* await sandbox.start()
|
|
632
|
+
* const result = await sandbox.execute(() => 'Hello!')
|
|
231
633
|
*/
|
|
232
634
|
export declare function createSandbox(config?: SandboxConfig): MCPSandbox;
|
|
233
635
|
/**
|
|
234
|
-
* Sandbox pool configuration
|
|
636
|
+
* Sandbox pool configuration.
|
|
637
|
+
*
|
|
638
|
+
* @description
|
|
639
|
+
* Configuration for creating a pool of sandbox instances.
|
|
640
|
+
*
|
|
641
|
+
* @interface SandboxPoolConfig
|
|
235
642
|
*/
|
|
236
643
|
export interface SandboxPoolConfig {
|
|
644
|
+
/** Number of sandboxes in the pool */
|
|
237
645
|
size: number;
|
|
646
|
+
/** Timeout for acquiring a sandbox (ms, default: 30000) */
|
|
238
647
|
acquireTimeout?: number;
|
|
648
|
+
/** Configuration applied to all sandboxes in the pool */
|
|
239
649
|
sandboxConfig?: SandboxConfig;
|
|
240
650
|
}
|
|
241
651
|
/**
|
|
242
|
-
* Sandbox pool for managing multiple sandbox instances
|
|
652
|
+
* Sandbox pool for managing multiple sandbox instances.
|
|
653
|
+
*
|
|
654
|
+
* @description
|
|
655
|
+
* Manages a fixed-size pool of sandbox instances for concurrent execution.
|
|
656
|
+
* Provides acquire/release semantics with automatic waiting and timeout.
|
|
657
|
+
*
|
|
658
|
+
* @class SandboxPool
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* const pool = new SandboxPool({
|
|
662
|
+
* size: 4,
|
|
663
|
+
* acquireTimeout: 10000,
|
|
664
|
+
* sandboxConfig: { timeout: 5000 }
|
|
665
|
+
* })
|
|
666
|
+
*
|
|
667
|
+
* // Acquire a sandbox
|
|
668
|
+
* const sandbox = await pool.acquire()
|
|
669
|
+
*
|
|
670
|
+
* try {
|
|
671
|
+
* const result = await sandbox.execute(() => 'Hello')
|
|
672
|
+
* } finally {
|
|
673
|
+
* await pool.release(sandbox)
|
|
674
|
+
* }
|
|
675
|
+
*
|
|
676
|
+
* // Shutdown when done
|
|
677
|
+
* await pool.shutdown()
|
|
243
678
|
*/
|
|
244
679
|
export declare class SandboxPool {
|
|
680
|
+
/** @internal */
|
|
245
681
|
private sandboxes;
|
|
682
|
+
/** @internal */
|
|
246
683
|
private availableSandboxes;
|
|
684
|
+
/** @internal */
|
|
247
685
|
private acquireTimeout;
|
|
686
|
+
/** @internal */
|
|
248
687
|
private waiters;
|
|
688
|
+
/** @internal */
|
|
249
689
|
private isShutdown;
|
|
690
|
+
/**
|
|
691
|
+
* Create a new sandbox pool.
|
|
692
|
+
* @param config - Pool configuration
|
|
693
|
+
*/
|
|
250
694
|
constructor(config: SandboxPoolConfig);
|
|
695
|
+
/**
|
|
696
|
+
* Get total number of sandboxes in the pool.
|
|
697
|
+
* @returns Pool size
|
|
698
|
+
*/
|
|
251
699
|
size(): number;
|
|
700
|
+
/**
|
|
701
|
+
* Get number of available (not in use) sandboxes.
|
|
702
|
+
* @returns Number of available sandboxes
|
|
703
|
+
*/
|
|
252
704
|
available(): number;
|
|
705
|
+
/**
|
|
706
|
+
* Acquire a sandbox from the pool.
|
|
707
|
+
*
|
|
708
|
+
* @description
|
|
709
|
+
* Returns an available sandbox or waits until one becomes available.
|
|
710
|
+
* The sandbox is started if in IDLE state.
|
|
711
|
+
*
|
|
712
|
+
* @returns Promise resolving to an acquired sandbox
|
|
713
|
+
* @throws {Error} If pool is shutdown or acquire times out
|
|
714
|
+
*/
|
|
253
715
|
acquire(): Promise<MCPSandbox>;
|
|
716
|
+
/**
|
|
717
|
+
* Release a sandbox back to the pool.
|
|
718
|
+
*
|
|
719
|
+
* @description
|
|
720
|
+
* Returns a sandbox to the pool after use. The sandbox is cleaned up
|
|
721
|
+
* before being made available again. If waiters are present, the sandbox
|
|
722
|
+
* is given to the next waiter instead of being added to the available pool.
|
|
723
|
+
*
|
|
724
|
+
* @param sandbox - The sandbox to release
|
|
725
|
+
* @returns Promise that resolves when the sandbox is released
|
|
726
|
+
*/
|
|
254
727
|
release(sandbox: MCPSandbox): Promise<void>;
|
|
728
|
+
/**
|
|
729
|
+
* Shutdown the pool.
|
|
730
|
+
*
|
|
731
|
+
* @description
|
|
732
|
+
* Rejects all pending waiters, destroys all sandboxes, and prevents
|
|
733
|
+
* further acquire operations. This is a permanent operation.
|
|
734
|
+
*
|
|
735
|
+
* @returns Promise that resolves when shutdown is complete
|
|
736
|
+
*/
|
|
255
737
|
shutdown(): Promise<void>;
|
|
256
738
|
}
|
|
257
739
|
/**
|
|
258
|
-
* Create a sandbox pool
|
|
740
|
+
* Create a sandbox pool.
|
|
741
|
+
*
|
|
742
|
+
* @description
|
|
743
|
+
* Factory function for creating a new SandboxPool instance.
|
|
744
|
+
* Equivalent to using `new SandboxPool(config)`.
|
|
745
|
+
*
|
|
746
|
+
* @param config - Pool configuration
|
|
747
|
+
* @returns A new SandboxPool instance
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* import { createSandboxPool } from './sandbox'
|
|
751
|
+
*
|
|
752
|
+
* const pool = createSandboxPool({
|
|
753
|
+
* size: 4,
|
|
754
|
+
* sandboxConfig: { timeout: 10000 }
|
|
755
|
+
* })
|
|
756
|
+
*
|
|
757
|
+
* const sandbox = await pool.acquire()
|
|
758
|
+
* // ... use sandbox ...
|
|
759
|
+
* await pool.release(sandbox)
|
|
760
|
+
*
|
|
761
|
+
* await pool.shutdown()
|
|
259
762
|
*/
|
|
260
763
|
export declare function createSandboxPool(config: SandboxPoolConfig): SandboxPool;
|
|
261
764
|
//# sourceMappingURL=sandbox.d.ts.map
|