@n8n/agents 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.tsbuildinfo +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime/agent-runtime.d.ts +14 -6
- package/dist/runtime/agent-runtime.js +359 -267
- package/dist/runtime/agent-runtime.js.map +1 -1
- package/dist/runtime/delegate-sub-agent-tool.d.ts +87 -0
- package/dist/runtime/delegate-sub-agent-tool.js +362 -0
- package/dist/runtime/delegate-sub-agent-tool.js.map +1 -0
- package/dist/runtime/event-bus.d.ts +8 -0
- package/dist/runtime/event-bus.js +48 -0
- package/dist/runtime/event-bus.js.map +1 -1
- package/dist/runtime/mcp-connection.d.ts +2 -3
- package/dist/runtime/mcp-connection.js +3 -6
- package/dist/runtime/mcp-connection.js.map +1 -1
- package/dist/runtime/message-list.d.ts +9 -3
- package/dist/runtime/message-list.js +16 -5
- package/dist/runtime/message-list.js.map +1 -1
- package/dist/runtime/messages.js +10 -2
- package/dist/runtime/messages.js.map +1 -1
- package/dist/runtime/model-factory.js +12 -0
- package/dist/runtime/model-factory.js.map +1 -1
- package/dist/runtime/provider-credentials.d.ts +13 -0
- package/dist/runtime/provider-credentials.js +1 -0
- package/dist/runtime/provider-credentials.js.map +1 -1
- package/dist/runtime/runtime-helpers.d.ts +1 -2
- package/dist/runtime/runtime-helpers.js +0 -8
- package/dist/runtime/runtime-helpers.js.map +1 -1
- package/dist/runtime/sdk-owned-tool.d.ts +4 -0
- package/dist/runtime/sdk-owned-tool.js +19 -0
- package/dist/runtime/sdk-owned-tool.js.map +1 -0
- package/dist/runtime/stream.js +8 -0
- package/dist/runtime/stream.js.map +1 -1
- package/dist/runtime/sub-agent-task-path.d.ts +10 -0
- package/dist/runtime/sub-agent-task-path.js +39 -0
- package/dist/runtime/sub-agent-task-path.js.map +1 -0
- package/dist/runtime/title-generation.js +8 -5
- package/dist/runtime/title-generation.js.map +1 -1
- package/dist/runtime/tool-adapter.d.ts +0 -9
- package/dist/runtime/tool-adapter.js +12 -21
- package/dist/runtime/tool-adapter.js.map +1 -1
- package/dist/runtime/write-todos-tool.d.ts +3 -0
- package/dist/runtime/write-todos-tool.js +95 -0
- package/dist/runtime/write-todos-tool.js.map +1 -0
- package/dist/sdk/agent.d.ts +19 -12
- package/dist/sdk/agent.js +318 -91
- package/dist/sdk/agent.js.map +1 -1
- package/dist/sdk/cancellation.d.ts +7 -0
- package/dist/sdk/cancellation.js +16 -0
- package/dist/sdk/cancellation.js.map +1 -0
- package/dist/sdk/catalog.js +40 -4
- package/dist/sdk/catalog.js.map +1 -1
- package/dist/sdk/guardrails/index.d.ts +5 -0
- package/dist/sdk/guardrails/index.js +15 -0
- package/dist/sdk/guardrails/index.js.map +1 -0
- package/dist/sdk/guardrails/patterns.d.ts +13 -0
- package/dist/sdk/guardrails/patterns.js +61 -0
- package/dist/sdk/guardrails/patterns.js.map +1 -0
- package/dist/sdk/guardrails/redactor.d.ts +24 -0
- package/dist/sdk/guardrails/redactor.js +86 -0
- package/dist/sdk/guardrails/redactor.js.map +1 -0
- package/dist/sdk/guardrails/streaming-redactor.d.ts +9 -0
- package/dist/sdk/guardrails/streaming-redactor.js +43 -0
- package/dist/sdk/guardrails/streaming-redactor.js.map +1 -0
- package/dist/sdk/mcp-client.d.ts +1 -1
- package/dist/sdk/mcp-client.js +2 -2
- package/dist/sdk/mcp-client.js.map +1 -1
- package/dist/sdk/memory.d.ts +1 -3
- package/dist/sdk/memory.js +0 -14
- package/dist/sdk/memory.js.map +1 -1
- package/dist/sdk/provider-capabilities.js +1 -0
- package/dist/sdk/provider-capabilities.js.map +1 -1
- package/dist/sdk/tool.d.ts +3 -0
- package/dist/sdk/tool.js +42 -10
- package/dist/sdk/tool.js.map +1 -1
- package/dist/storage/base-memory.d.ts +0 -31
- package/dist/storage/base-memory.js +0 -9
- package/dist/storage/base-memory.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/runtime/event.d.ts +31 -1
- package/dist/types/runtime/event.js +2 -0
- package/dist/types/runtime/event.js.map +1 -1
- package/dist/types/sdk/agent-builder.d.ts +0 -1
- package/dist/types/sdk/agent.d.ts +20 -15
- package/dist/types/sdk/guardrail.d.ts +1 -1
- package/dist/types/sdk/memory.d.ts +0 -42
- package/dist/types/sdk/message.d.ts +1 -0
- package/dist/types/sdk/tool.d.ts +19 -1
- package/dist/utils/json-schema.d.ts +3 -0
- package/dist/utils/json-schema.js +72 -0
- package/dist/utils/json-schema.js.map +1 -0
- package/dist/workspace/filesystem/daytona-filesystem.d.ts +25 -0
- package/dist/workspace/filesystem/daytona-filesystem.js +130 -0
- package/dist/workspace/filesystem/daytona-filesystem.js.map +1 -0
- package/dist/workspace/filesystem/n8n-sandbox-filesystem.d.ts +25 -0
- package/dist/workspace/filesystem/n8n-sandbox-filesystem.js +126 -0
- package/dist/workspace/filesystem/n8n-sandbox-filesystem.js.map +1 -0
- package/dist/workspace/sandbox/create-workspace.d.ts +4 -0
- package/dist/workspace/sandbox/create-workspace.js +68 -0
- package/dist/workspace/sandbox/create-workspace.js.map +1 -0
- package/dist/workspace/sandbox/daytona-auth-manager.d.ts +26 -0
- package/dist/workspace/sandbox/daytona-auth-manager.js +84 -0
- package/dist/workspace/sandbox/daytona-auth-manager.js.map +1 -0
- package/dist/workspace/sandbox/daytona-sandbox.d.ts +72 -0
- package/dist/workspace/sandbox/daytona-sandbox.js +357 -0
- package/dist/workspace/sandbox/daytona-sandbox.js.map +1 -0
- package/dist/workspace/sandbox/index.d.ts +7 -0
- package/dist/workspace/sandbox/index.js +22 -0
- package/dist/workspace/sandbox/index.js.map +1 -0
- package/dist/workspace/sandbox/lazy-daytona.d.ts +2 -0
- package/dist/workspace/sandbox/lazy-daytona.js +12 -0
- package/dist/workspace/sandbox/lazy-daytona.js.map +1 -0
- package/dist/workspace/sandbox/logger.d.ts +12 -0
- package/dist/workspace/sandbox/logger.js +3 -0
- package/dist/workspace/sandbox/logger.js.map +1 -0
- package/dist/workspace/sandbox/n8n-sandbox-sandbox.d.ts +35 -0
- package/dist/workspace/sandbox/n8n-sandbox-sandbox.js +138 -0
- package/dist/workspace/sandbox/n8n-sandbox-sandbox.js.map +1 -0
- package/dist/workspace/sandbox/provider.d.ts +4 -0
- package/dist/workspace/sandbox/provider.js +14 -0
- package/dist/workspace/sandbox/provider.js.map +1 -0
- package/dist/workspace/sandbox/run-in-sandbox.d.ts +26 -0
- package/dist/workspace/sandbox/run-in-sandbox.js +19 -0
- package/dist/workspace/sandbox/run-in-sandbox.js.map +1 -0
- package/dist/workspace/sandbox/types.d.ts +45 -0
- package/dist/workspace/sandbox/types.js +3 -0
- package/dist/workspace/sandbox/types.js.map +1 -0
- package/dist/workspace/sandbox/workspace-root.d.ts +16 -0
- package/dist/workspace/sandbox/workspace-root.js +69 -0
- package/dist/workspace/sandbox/workspace-root.js.map +1 -0
- package/dist/workspace/tools/batch-str-replace-file.js +2 -2
- package/dist/workspace/tools/batch-str-replace-file.js.map +1 -1
- package/dist/workspace/tools/str-replace-file.js +2 -2
- package/dist/workspace/tools/str-replace-file.js.map +1 -1
- package/package.json +29 -17
- package/dist/sdk/network.d.ts +0 -20
- package/dist/sdk/network.js +0 -46
- package/dist/sdk/network.js.map +0 -1
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DaytonaSandbox = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const base_sandbox_1 = require("./base-sandbox");
|
|
6
|
+
const daytona_auth_manager_1 = require("./daytona-auth-manager");
|
|
7
|
+
const lazy_daytona_1 = require("./lazy-daytona");
|
|
8
|
+
const SANDBOX_STATE_STARTED = 'started';
|
|
9
|
+
const SANDBOX_STATE_STOPPED = 'stopped';
|
|
10
|
+
const SANDBOX_STATE_ARCHIVED = 'archived';
|
|
11
|
+
const SANDBOX_STATE_DESTROYED = 'destroyed';
|
|
12
|
+
const SANDBOX_STATE_DESTROYING = 'destroying';
|
|
13
|
+
const SANDBOX_STATE_ERROR = 'error';
|
|
14
|
+
const SANDBOX_STATE_BUILD_FAILED = 'build_failed';
|
|
15
|
+
const RECOVERABLE_SANDBOX_STATES = new Set([
|
|
16
|
+
SANDBOX_STATE_STOPPED,
|
|
17
|
+
SANDBOX_STATE_ARCHIVED,
|
|
18
|
+
]);
|
|
19
|
+
function shellEscape(value) {
|
|
20
|
+
return /^[A-Za-z0-9_./:=@+-]+$/.test(value) ? value : `'${value.replace(/'/g, "'\\''")}'`;
|
|
21
|
+
}
|
|
22
|
+
function toShellCommand(command, args) {
|
|
23
|
+
if (args.length === 0)
|
|
24
|
+
return command;
|
|
25
|
+
return [command, ...args.map((arg) => shellEscape(arg))].join(' ');
|
|
26
|
+
}
|
|
27
|
+
function isDaytonaAuthError(error) {
|
|
28
|
+
const { DaytonaError } = (0, lazy_daytona_1.loadDaytona)();
|
|
29
|
+
return error instanceof DaytonaError && (error.statusCode === 401 || error.statusCode === 403);
|
|
30
|
+
}
|
|
31
|
+
function isSandboxGone(error) {
|
|
32
|
+
const { DaytonaNotFoundError } = (0, lazy_daytona_1.loadDaytona)();
|
|
33
|
+
return error instanceof DaytonaNotFoundError;
|
|
34
|
+
}
|
|
35
|
+
class DaytonaSandbox extends base_sandbox_1.BaseSandbox {
|
|
36
|
+
constructor(options = {}) {
|
|
37
|
+
super();
|
|
38
|
+
this.options = options;
|
|
39
|
+
this.name = 'DaytonaSandbox';
|
|
40
|
+
this.provider = 'daytona';
|
|
41
|
+
this.status = 'pending';
|
|
42
|
+
this.createdAt = new Date();
|
|
43
|
+
this.lastClientGeneration = -1;
|
|
44
|
+
this.id = options.id ?? `daytona-sandbox-${(0, node_crypto_1.randomUUID)()}`;
|
|
45
|
+
this.timeout = options.timeout ?? 300_000;
|
|
46
|
+
this.language = options.language ?? 'typescript';
|
|
47
|
+
this.sandboxName = options.name ?? this.id;
|
|
48
|
+
this.auth = new daytona_auth_manager_1.DaytonaAuthManager({
|
|
49
|
+
apiUrl: options.apiUrl,
|
|
50
|
+
target: options.target,
|
|
51
|
+
staticApiKey: options.apiKey,
|
|
52
|
+
getAuthToken: options.getAuthToken,
|
|
53
|
+
refreshSkewMs: options.refreshSkewMs,
|
|
54
|
+
logger: options.logger,
|
|
55
|
+
sandboxName: this.sandboxName,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
get instance() {
|
|
59
|
+
if (!this.sandbox) {
|
|
60
|
+
throw new Error(`Daytona sandbox "${this.id}" is not running`);
|
|
61
|
+
}
|
|
62
|
+
return this.sandbox;
|
|
63
|
+
}
|
|
64
|
+
async start() {
|
|
65
|
+
if (this.sandbox)
|
|
66
|
+
return;
|
|
67
|
+
const client = await this.getDaytona();
|
|
68
|
+
const existing = await this.findExistingSandbox(client);
|
|
69
|
+
if (existing) {
|
|
70
|
+
this.sandbox = existing;
|
|
71
|
+
await this.detectWorkingDirectory();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.sandbox = await this.createSandbox(client);
|
|
75
|
+
await this.detectWorkingDirectory();
|
|
76
|
+
}
|
|
77
|
+
async stop() {
|
|
78
|
+
if (!this.sandbox)
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
await this.ensureAuthFresh();
|
|
82
|
+
await this.sandbox.stop(Math.ceil(this.timeout / 1000));
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (!isSandboxGone(error))
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
this.sandbox = undefined;
|
|
89
|
+
}
|
|
90
|
+
async destroy() {
|
|
91
|
+
try {
|
|
92
|
+
if (this.sandbox) {
|
|
93
|
+
await this.ensureAuthFresh();
|
|
94
|
+
await this.sandbox.delete(Math.ceil(this.timeout / 1000));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const client = await this.getDaytona();
|
|
98
|
+
const existing = await client.get(this.sandboxName);
|
|
99
|
+
await existing.delete(Math.ceil(this.timeout / 1000));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (!isSandboxGone(error))
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
this.sandbox = undefined;
|
|
107
|
+
}
|
|
108
|
+
async executeCommand(command, args = [], options) {
|
|
109
|
+
return await this.recoverAndRetry(async () => {
|
|
110
|
+
await this.ensureRunning();
|
|
111
|
+
await this.ensureAuthFresh();
|
|
112
|
+
const startedAt = Date.now();
|
|
113
|
+
const fullCommand = toShellCommand(command, args);
|
|
114
|
+
const result = await this.instance.process.executeCommand(fullCommand, options?.cwd, this.compactEnv(options?.env), Math.ceil((options?.timeout ?? this.timeout) / 1000));
|
|
115
|
+
const stdout = result.artifacts?.stdout ?? result.result ?? '';
|
|
116
|
+
if (stdout)
|
|
117
|
+
options?.onStdout?.(stdout);
|
|
118
|
+
return {
|
|
119
|
+
command,
|
|
120
|
+
args,
|
|
121
|
+
success: result.exitCode === 0,
|
|
122
|
+
exitCode: result.exitCode,
|
|
123
|
+
stdout,
|
|
124
|
+
stderr: '',
|
|
125
|
+
executionTimeMs: Date.now() - startedAt,
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async withFilesystem(op) {
|
|
130
|
+
return await this.recoverAndRetry(async () => {
|
|
131
|
+
await this.ensureRunning();
|
|
132
|
+
await this.ensureAuthFresh();
|
|
133
|
+
return await op(this.instance.fs);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async ensureAuthFresh() {
|
|
137
|
+
await this.getDaytona();
|
|
138
|
+
}
|
|
139
|
+
getInfo() {
|
|
140
|
+
return {
|
|
141
|
+
id: this.id,
|
|
142
|
+
name: this.name,
|
|
143
|
+
provider: this.provider,
|
|
144
|
+
status: this.status,
|
|
145
|
+
createdAt: this.createdAt,
|
|
146
|
+
resources: this.sandbox
|
|
147
|
+
? {
|
|
148
|
+
cpuCores: this.sandbox.cpu,
|
|
149
|
+
memoryMB: this.sandbox.memory * 1024,
|
|
150
|
+
}
|
|
151
|
+
: undefined,
|
|
152
|
+
metadata: {
|
|
153
|
+
language: this.language,
|
|
154
|
+
workingDirectory: this.workingDirectory,
|
|
155
|
+
target: this.sandbox?.target,
|
|
156
|
+
remoteSandboxId: this.sandbox?.id,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
getInstructions() {
|
|
161
|
+
const parts = [`Cloud sandbox with isolated execution (${this.language} runtime).`];
|
|
162
|
+
if (this.workingDirectory) {
|
|
163
|
+
parts.push(`Default working directory: ${this.workingDirectory}.`);
|
|
164
|
+
}
|
|
165
|
+
parts.push(`Command timeout: ${Math.ceil(this.timeout / 1000)}s.`);
|
|
166
|
+
return parts.join(' ');
|
|
167
|
+
}
|
|
168
|
+
async getDaytona() {
|
|
169
|
+
const client = await this.auth.getClient();
|
|
170
|
+
const generation = this.auth.getGeneration();
|
|
171
|
+
if (this.sandbox && generation !== this.lastClientGeneration) {
|
|
172
|
+
this.sandbox = await client.get(this.sandboxName);
|
|
173
|
+
}
|
|
174
|
+
this.lastClientGeneration = generation;
|
|
175
|
+
return client;
|
|
176
|
+
}
|
|
177
|
+
resetLocalHandle() {
|
|
178
|
+
this.sandbox = undefined;
|
|
179
|
+
this.lastClientGeneration = -1;
|
|
180
|
+
this.workingDirectory = undefined;
|
|
181
|
+
this.markNeedsStart();
|
|
182
|
+
}
|
|
183
|
+
async isRecoverable(error) {
|
|
184
|
+
if (isSandboxGone(error))
|
|
185
|
+
return true;
|
|
186
|
+
try {
|
|
187
|
+
const client = await this.auth.getClient();
|
|
188
|
+
const remote = await client.get(this.sandboxName);
|
|
189
|
+
return remote.state !== undefined && RECOVERABLE_SANDBOX_STATES.has(remote.state);
|
|
190
|
+
}
|
|
191
|
+
catch (probeError) {
|
|
192
|
+
return isSandboxGone(probeError);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async recoverAndRetry(op) {
|
|
196
|
+
try {
|
|
197
|
+
return await op();
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
if (!(await this.isRecoverable(error)))
|
|
201
|
+
throw error;
|
|
202
|
+
await this.recover();
|
|
203
|
+
return await op();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async recover() {
|
|
207
|
+
this.recoveryPromise ??= (async () => {
|
|
208
|
+
this.resetLocalHandle();
|
|
209
|
+
await this.ensureRunning();
|
|
210
|
+
})().finally(() => {
|
|
211
|
+
this.recoveryPromise = undefined;
|
|
212
|
+
});
|
|
213
|
+
await this.recoveryPromise;
|
|
214
|
+
}
|
|
215
|
+
async findExistingSandbox(client) {
|
|
216
|
+
try {
|
|
217
|
+
const sandbox = await client.get(this.sandboxName);
|
|
218
|
+
if (sandbox.state && this.isDeadState(sandbox.state)) {
|
|
219
|
+
await sandbox.delete(Math.ceil(this.timeout / 1000));
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
if (sandbox.state !== SANDBOX_STATE_STARTED) {
|
|
223
|
+
await sandbox.start(Math.ceil(this.timeout / 1000));
|
|
224
|
+
}
|
|
225
|
+
return sandbox;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
const { DaytonaNotFoundError } = (0, lazy_daytona_1.loadDaytona)();
|
|
229
|
+
if (error instanceof DaytonaNotFoundError)
|
|
230
|
+
return null;
|
|
231
|
+
if (isDaytonaAuthError(error))
|
|
232
|
+
throw error;
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async createSandbox(client) {
|
|
237
|
+
const candidates = this.createSandboxParams();
|
|
238
|
+
let lastError;
|
|
239
|
+
for (const candidate of candidates) {
|
|
240
|
+
try {
|
|
241
|
+
return this.options.createTimeoutSeconds
|
|
242
|
+
? await client.create(candidate.params, { timeout: this.options.createTimeoutSeconds })
|
|
243
|
+
: await client.create(candidate.params);
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
lastError = error;
|
|
247
|
+
this.reportCreateError(error, candidate.strategy);
|
|
248
|
+
if (candidate.strategy === 'snapshot' &&
|
|
249
|
+
candidates.some(({ strategy }) => strategy === 'image')) {
|
|
250
|
+
this.options.logger?.warn('Sandbox create from snapshot failed; falling back to image', {
|
|
251
|
+
snapshotName: this.options.snapshot,
|
|
252
|
+
mode: this.options.createStrategyMode,
|
|
253
|
+
error: error instanceof Error ? error.message : String(error),
|
|
254
|
+
});
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
throw error;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
throw lastError instanceof Error ? lastError : new Error('Failed to create Daytona sandbox');
|
|
261
|
+
}
|
|
262
|
+
createSandboxParams() {
|
|
263
|
+
const base = {
|
|
264
|
+
language: this.language,
|
|
265
|
+
autoStopInterval: this.options.autoStopInterval ?? 15,
|
|
266
|
+
name: this.sandboxName,
|
|
267
|
+
};
|
|
268
|
+
if (this.options.labels !== undefined)
|
|
269
|
+
base.labels = this.options.labels;
|
|
270
|
+
if (this.options.ephemeral !== undefined)
|
|
271
|
+
base.ephemeral = this.options.ephemeral;
|
|
272
|
+
if (this.options.autoArchiveInterval !== undefined) {
|
|
273
|
+
base.autoArchiveInterval = this.options.autoArchiveInterval;
|
|
274
|
+
}
|
|
275
|
+
if (this.options.autoDeleteInterval !== undefined) {
|
|
276
|
+
base.autoDeleteInterval = this.options.autoDeleteInterval;
|
|
277
|
+
}
|
|
278
|
+
if (this.options.volumes !== undefined)
|
|
279
|
+
base.volumes = this.options.volumes;
|
|
280
|
+
if (this.options.user !== undefined)
|
|
281
|
+
base.user = this.options.user;
|
|
282
|
+
if (this.options.public !== undefined)
|
|
283
|
+
base.public = this.options.public;
|
|
284
|
+
if (this.options.networkBlockAll !== undefined) {
|
|
285
|
+
base.networkBlockAll = this.options.networkBlockAll;
|
|
286
|
+
}
|
|
287
|
+
if (this.options.networkAllowList !== undefined) {
|
|
288
|
+
base.networkAllowList = this.options.networkAllowList;
|
|
289
|
+
}
|
|
290
|
+
if (this.options.env !== undefined)
|
|
291
|
+
base.envVars = this.options.env;
|
|
292
|
+
const candidates = [];
|
|
293
|
+
if (this.options.snapshot) {
|
|
294
|
+
candidates.push({
|
|
295
|
+
strategy: 'snapshot',
|
|
296
|
+
params: {
|
|
297
|
+
...base,
|
|
298
|
+
snapshot: this.options.snapshot,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
if (this.options.image) {
|
|
303
|
+
candidates.push({
|
|
304
|
+
strategy: 'image',
|
|
305
|
+
params: {
|
|
306
|
+
...base,
|
|
307
|
+
image: this.options.image,
|
|
308
|
+
resources: this.options.resources,
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
if (candidates.length > 0)
|
|
313
|
+
return candidates;
|
|
314
|
+
return [{ strategy: 'snapshot', params: { ...base, snapshot: this.options.snapshot } }];
|
|
315
|
+
}
|
|
316
|
+
reportCreateError(error, strategy) {
|
|
317
|
+
this.options.errorReporter?.error(error, {
|
|
318
|
+
tags: {
|
|
319
|
+
component: 'builder-sandbox-factory',
|
|
320
|
+
strategy,
|
|
321
|
+
...(this.options.createStrategyMode ? { mode: this.options.createStrategyMode } : {}),
|
|
322
|
+
},
|
|
323
|
+
extra: {
|
|
324
|
+
sandboxId: this.id,
|
|
325
|
+
sandboxName: this.sandboxName,
|
|
326
|
+
snapshotName: this.options.snapshot,
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
async detectWorkingDirectory() {
|
|
331
|
+
try {
|
|
332
|
+
this.workingDirectory = await this.instance.getWorkDir();
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
this.workingDirectory = undefined;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
isDeadState(state) {
|
|
339
|
+
return DaytonaSandbox.DEAD_STATES.has(state);
|
|
340
|
+
}
|
|
341
|
+
compactEnv(env) {
|
|
342
|
+
const merged = {
|
|
343
|
+
...this.options.env,
|
|
344
|
+
...env,
|
|
345
|
+
};
|
|
346
|
+
const entries = Object.entries(merged).filter((entry) => typeof entry[1] === 'string');
|
|
347
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
exports.DaytonaSandbox = DaytonaSandbox;
|
|
351
|
+
DaytonaSandbox.DEAD_STATES = new Set([
|
|
352
|
+
SANDBOX_STATE_DESTROYED,
|
|
353
|
+
SANDBOX_STATE_DESTROYING,
|
|
354
|
+
SANDBOX_STATE_ERROR,
|
|
355
|
+
SANDBOX_STATE_BUILD_FAILED,
|
|
356
|
+
]);
|
|
357
|
+
//# sourceMappingURL=daytona-sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daytona-sandbox.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/daytona-sandbox.ts"],"names":[],"mappings":";;;AAUA,6CAAyC;AAGzC,iDAA6C;AAC7C,iEAA4D;AAC5D,iDAA6C;AAG7C,MAAM,qBAAqB,GAAG,SAAS,CAAC;AACxC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AACxC,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAC1C,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAC5C,MAAM,wBAAwB,GAAG,YAAY,CAAC;AAC9C,MAAM,mBAAmB,GAAG,OAAO,CAAC;AACpC,MAAM,0BAA0B,GAAG,cAAc,CAAC;AAYlD,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IAC/D,qBAAqB;IACrB,sBAAsB;CACtB,CAAC,CAAC;AA2CH,SAAS,WAAW,CAAC,KAAa;IACjC,OAAO,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC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}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DEFAULT_SANDBOX_PROVIDER, normalizeSandboxProvider, } from './provider';
|
|
2
|
+
export { WORKSPACE_DIR, DAYTONA_HOME, DAYTONA_WORKSPACE_ROOT, N8N_SANDBOX_HOME, N8N_SANDBOX_WORKSPACE_ROOT, getPromptWorkspaceRoot, getWorkspaceRoot, type SandboxWorkspace, } from './workspace-root';
|
|
3
|
+
export { runInSandbox, type SandboxCommandTarget } from './run-in-sandbox';
|
|
4
|
+
export { loadDaytona } from './lazy-daytona';
|
|
5
|
+
export { createFilesystem, createSandbox } from './create-workspace';
|
|
6
|
+
export type { CommandResult, CopyOptions, SandboxProvider, SandboxConfig, SandboxInstance, SandboxFilesystem, CreateSandboxOptions, DaytonaSandboxConfig, N8nSandboxConfig, DisabledSandboxConfig, ExecuteCommandOptions, FileContent, FileEntry, FileStat, ListOptions, MountConfig, ProcessHandle, ProcessInfo, ProviderStatus, ReadOptions, RemoveOptions, SandboxInfo, SandboxProcessManager, SpawnProcessOptions, WorkspaceFilesystem, WorkspaceSandbox, WriteOptions, } from './types';
|
|
7
|
+
export type { Logger, ErrorReporter } from './logger';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSandbox = exports.createFilesystem = exports.loadDaytona = exports.runInSandbox = exports.getWorkspaceRoot = exports.getPromptWorkspaceRoot = exports.N8N_SANDBOX_WORKSPACE_ROOT = exports.N8N_SANDBOX_HOME = exports.DAYTONA_WORKSPACE_ROOT = exports.DAYTONA_HOME = exports.WORKSPACE_DIR = exports.normalizeSandboxProvider = exports.DEFAULT_SANDBOX_PROVIDER = void 0;
|
|
4
|
+
var provider_1 = require("./provider");
|
|
5
|
+
Object.defineProperty(exports, "DEFAULT_SANDBOX_PROVIDER", { enumerable: true, get: function () { return provider_1.DEFAULT_SANDBOX_PROVIDER; } });
|
|
6
|
+
Object.defineProperty(exports, "normalizeSandboxProvider", { enumerable: true, get: function () { return provider_1.normalizeSandboxProvider; } });
|
|
7
|
+
var workspace_root_1 = require("./workspace-root");
|
|
8
|
+
Object.defineProperty(exports, "WORKSPACE_DIR", { enumerable: true, get: function () { return workspace_root_1.WORKSPACE_DIR; } });
|
|
9
|
+
Object.defineProperty(exports, "DAYTONA_HOME", { enumerable: true, get: function () { return workspace_root_1.DAYTONA_HOME; } });
|
|
10
|
+
Object.defineProperty(exports, "DAYTONA_WORKSPACE_ROOT", { enumerable: true, get: function () { return workspace_root_1.DAYTONA_WORKSPACE_ROOT; } });
|
|
11
|
+
Object.defineProperty(exports, "N8N_SANDBOX_HOME", { enumerable: true, get: function () { return workspace_root_1.N8N_SANDBOX_HOME; } });
|
|
12
|
+
Object.defineProperty(exports, "N8N_SANDBOX_WORKSPACE_ROOT", { enumerable: true, get: function () { return workspace_root_1.N8N_SANDBOX_WORKSPACE_ROOT; } });
|
|
13
|
+
Object.defineProperty(exports, "getPromptWorkspaceRoot", { enumerable: true, get: function () { return workspace_root_1.getPromptWorkspaceRoot; } });
|
|
14
|
+
Object.defineProperty(exports, "getWorkspaceRoot", { enumerable: true, get: function () { return workspace_root_1.getWorkspaceRoot; } });
|
|
15
|
+
var run_in_sandbox_1 = require("./run-in-sandbox");
|
|
16
|
+
Object.defineProperty(exports, "runInSandbox", { enumerable: true, get: function () { return run_in_sandbox_1.runInSandbox; } });
|
|
17
|
+
var lazy_daytona_1 = require("./lazy-daytona");
|
|
18
|
+
Object.defineProperty(exports, "loadDaytona", { enumerable: true, get: function () { return lazy_daytona_1.loadDaytona; } });
|
|
19
|
+
var create_workspace_1 = require("./create-workspace");
|
|
20
|
+
Object.defineProperty(exports, "createFilesystem", { enumerable: true, get: function () { return create_workspace_1.createFilesystem; } });
|
|
21
|
+
Object.defineProperty(exports, "createSandbox", { enumerable: true, get: function () { return create_workspace_1.createSandbox; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/index.ts"],"names":[],"mappings":";;;AAAA,uCAGoB;AAFnB,oHAAA,wBAAwB,OAAA;AACxB,oHAAA,wBAAwB,OAAA;AAEzB,mDAS0B;AARzB,+GAAA,aAAa,OAAA;AACb,8GAAA,YAAY,OAAA;AACZ,wHAAA,sBAAsB,OAAA;AACtB,kHAAA,gBAAgB,OAAA;AAChB,4HAAA,0BAA0B,OAAA;AAC1B,wHAAA,sBAAsB,OAAA;AACtB,kHAAA,gBAAgB,OAAA;AAGjB,mDAA2E;AAAlE,8GAAA,YAAY,OAAA;AACrB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,uDAAqE;AAA5D,oHAAA,gBAAgB,OAAA;AAAE,iHAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadDaytona = loadDaytona;
|
|
4
|
+
let _daytonaMod;
|
|
5
|
+
function loadDaytona() {
|
|
6
|
+
if (!_daytonaMod) {
|
|
7
|
+
const mod = require('@daytonaio/sdk');
|
|
8
|
+
_daytonaMod = mod;
|
|
9
|
+
}
|
|
10
|
+
return _daytonaMod;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=lazy-daytona.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-daytona.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/lazy-daytona.ts"],"names":[],"mappings":";;AAIA,kCAOC;AATD,IAAI,WAA0C,CAAC;AAE/C,SAAgB,WAAW;IAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;QAElB,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAsB,CAAC;QAC3D,WAAW,GAAG,GAAG,CAAC;IACnB,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
info(message: string, metadata?: Record<string, unknown>): void;
|
|
3
|
+
warn(message: string, metadata?: Record<string, unknown>): void;
|
|
4
|
+
error(message: string, metadata?: Record<string, unknown>): void;
|
|
5
|
+
debug(message: string, metadata?: Record<string, unknown>): void;
|
|
6
|
+
}
|
|
7
|
+
export interface ErrorReporter {
|
|
8
|
+
error(error: unknown, options?: {
|
|
9
|
+
tags?: Record<string, string>;
|
|
10
|
+
extra?: Record<string, unknown>;
|
|
11
|
+
}): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/logger.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SandboxClient } from '@n8n/sandbox-client';
|
|
2
|
+
import { BaseSandbox } from './base-sandbox';
|
|
3
|
+
import type { CommandResult, ExecuteCommandOptions, ProviderStatus, SandboxInfo } from '../types';
|
|
4
|
+
export interface N8nSandboxServiceSandboxOptions {
|
|
5
|
+
id?: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
serviceUrl?: string;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export declare class N8nSandboxServiceSandbox extends BaseSandbox {
|
|
12
|
+
private readonly options;
|
|
13
|
+
readonly name = "N8nSandboxServiceSandbox";
|
|
14
|
+
readonly provider = "n8n-sandbox";
|
|
15
|
+
status: ProviderStatus;
|
|
16
|
+
private readonly instanceId;
|
|
17
|
+
private readonly client;
|
|
18
|
+
private readonly timeout;
|
|
19
|
+
private static readonly HOME_DIR;
|
|
20
|
+
private static readonly WORKSPACE_DIR;
|
|
21
|
+
private sandboxId?;
|
|
22
|
+
private createdAt?;
|
|
23
|
+
constructor(options: N8nSandboxServiceSandboxOptions);
|
|
24
|
+
get id(): string;
|
|
25
|
+
start(): Promise<void>;
|
|
26
|
+
destroy(): Promise<void>;
|
|
27
|
+
stop(): Promise<void>;
|
|
28
|
+
getInfo(): Promise<SandboxInfo>;
|
|
29
|
+
getInstructions(): string;
|
|
30
|
+
executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
31
|
+
getClient(): SandboxClient;
|
|
32
|
+
private tryGetExistingSandbox;
|
|
33
|
+
private compactEnv;
|
|
34
|
+
private requireSandboxId;
|
|
35
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.N8nSandboxServiceSandbox = void 0;
|
|
7
|
+
const sandbox_client_1 = require("@n8n/sandbox-client");
|
|
8
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
const base_sandbox_1 = require("./base-sandbox");
|
|
11
|
+
function shellEscape(value) {
|
|
12
|
+
return /^[A-Za-z0-9_./:=+-]+$/.test(value) ? value : `'${value.replace(/'/g, "'\\''")}'`;
|
|
13
|
+
}
|
|
14
|
+
function toShellCommand(command, args = []) {
|
|
15
|
+
if (args.length === 0)
|
|
16
|
+
return command;
|
|
17
|
+
return [command, ...args.map((arg) => shellEscape(arg))].join(' ');
|
|
18
|
+
}
|
|
19
|
+
class N8nSandboxServiceSandbox extends base_sandbox_1.BaseSandbox {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
super();
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.name = 'N8nSandboxServiceSandbox';
|
|
24
|
+
this.provider = 'n8n-sandbox';
|
|
25
|
+
this.status = 'pending';
|
|
26
|
+
this.instanceId = `n8n-sandbox-${(0, node_crypto_1.randomUUID)()}`;
|
|
27
|
+
this.client = new sandbox_client_1.SandboxClient({
|
|
28
|
+
apiKey: options.apiKey,
|
|
29
|
+
baseUrl: options.serviceUrl,
|
|
30
|
+
});
|
|
31
|
+
this.sandboxId = options.id;
|
|
32
|
+
this.timeout = options.timeout ?? 300_000;
|
|
33
|
+
}
|
|
34
|
+
get id() {
|
|
35
|
+
return this.sandboxId ?? this.instanceId;
|
|
36
|
+
}
|
|
37
|
+
async start() {
|
|
38
|
+
if (this.sandboxId) {
|
|
39
|
+
const existing = await this.tryGetExistingSandbox(this.sandboxId);
|
|
40
|
+
if (existing) {
|
|
41
|
+
this.createdAt = new Date(existing.createdAt * 1000);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const sandbox = await this.client.createSandbox();
|
|
46
|
+
this.sandboxId = sandbox.id;
|
|
47
|
+
this.createdAt = new Date();
|
|
48
|
+
}
|
|
49
|
+
async destroy() {
|
|
50
|
+
if (!this.sandboxId)
|
|
51
|
+
return;
|
|
52
|
+
try {
|
|
53
|
+
await this.client.deleteSandbox(this.sandboxId);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error instanceof sandbox_client_1.SandboxServiceError && error.status === 404)
|
|
57
|
+
return;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async stop() {
|
|
62
|
+
}
|
|
63
|
+
async getInfo() {
|
|
64
|
+
await this.ensureRunning();
|
|
65
|
+
const sandbox = await this.client.getSandbox(this.requireSandboxId());
|
|
66
|
+
return {
|
|
67
|
+
id: sandbox.id,
|
|
68
|
+
name: this.name,
|
|
69
|
+
provider: this.provider,
|
|
70
|
+
status: this.status,
|
|
71
|
+
createdAt: this.createdAt ?? new Date(sandbox.createdAt * 1000),
|
|
72
|
+
metadata: {
|
|
73
|
+
lastActiveAt: new Date(sandbox.lastActiveAt * 1000).toISOString(),
|
|
74
|
+
remoteStatus: sandbox.status,
|
|
75
|
+
workingDirectory: N8nSandboxServiceSandbox.WORKSPACE_DIR,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
getInstructions() {
|
|
80
|
+
return [
|
|
81
|
+
'Cloud sandbox with isolated execution (TypeScript runtime).',
|
|
82
|
+
`Default working directory: ${N8nSandboxServiceSandbox.WORKSPACE_DIR}.`,
|
|
83
|
+
`Command timeout: ${Math.ceil(this.timeout / 1000)}s.`,
|
|
84
|
+
].join(' ');
|
|
85
|
+
}
|
|
86
|
+
async executeCommand(command, args = [], options) {
|
|
87
|
+
await this.ensureRunning();
|
|
88
|
+
const result = await this.client.exec(this.requireSandboxId(), {
|
|
89
|
+
command: toShellCommand(command, args),
|
|
90
|
+
env: this.compactEnv(options?.env),
|
|
91
|
+
workdir: options?.cwd,
|
|
92
|
+
timeoutMs: options?.timeout ?? this.timeout,
|
|
93
|
+
abortSignal: options?.abortSignal,
|
|
94
|
+
onStdout: options?.onStdout,
|
|
95
|
+
onStderr: options?.onStderr,
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
command,
|
|
99
|
+
args,
|
|
100
|
+
success: result.success,
|
|
101
|
+
exitCode: result.exitCode,
|
|
102
|
+
stdout: result.stdout,
|
|
103
|
+
stderr: result.stderr,
|
|
104
|
+
executionTimeMs: result.executionTimeMs,
|
|
105
|
+
timedOut: result.timedOut,
|
|
106
|
+
killed: result.killed,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
getClient() {
|
|
110
|
+
return this.client;
|
|
111
|
+
}
|
|
112
|
+
async tryGetExistingSandbox(sandboxId) {
|
|
113
|
+
try {
|
|
114
|
+
return await this.client.getSandbox(sandboxId);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (error instanceof sandbox_client_1.SandboxServiceError && error.status === 404)
|
|
118
|
+
return null;
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
compactEnv(env) {
|
|
123
|
+
const merged = {
|
|
124
|
+
...this.options.env,
|
|
125
|
+
...env,
|
|
126
|
+
};
|
|
127
|
+
const entries = Object.entries(merged).filter((entry) => typeof entry[1] === 'string');
|
|
128
|
+
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
129
|
+
}
|
|
130
|
+
requireSandboxId() {
|
|
131
|
+
(0, strict_1.default)(this.sandboxId, 'Sandbox has not been created yet');
|
|
132
|
+
return this.sandboxId;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.N8nSandboxServiceSandbox = N8nSandboxServiceSandbox;
|
|
136
|
+
N8nSandboxServiceSandbox.HOME_DIR = '/home/user';
|
|
137
|
+
N8nSandboxServiceSandbox.WORKSPACE_DIR = `${N8nSandboxServiceSandbox.HOME_DIR}/workspace`;
|
|
138
|
+
//# sourceMappingURL=n8n-sandbox-sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n8n-sandbox-sandbox.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/n8n-sandbox-sandbox.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA6F;AAC7F,gEAAwC;AACxC,6CAAyC;AAEzC,iDAA6C;AAW7C,SAAS,WAAW,CAAC,KAAa;IACjC,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AAC1F,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,OAAiB,EAAE;IAC3D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACtC,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpE,CAAC;AAGD,MAAa,wBAAyB,SAAQ,0BAAW;IA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N,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAC5C,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAClE,CAAC;QACF,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAEO,gBAAgB;QACvB,IAAA,gBAAM,EAAC,IAAI,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;;AAnJF,4DAoJC;AAvIwB,iCAAQ,GAAG,YAAY,AAAf,CAAgB;AAExB,sCAAa,GAAG,GAAG,wBAAwB,CAAC,QAAQ,YAAY,AAAnD,CAAoD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SandboxProvider } from './types';
|
|
2
|
+
export declare const DEFAULT_SANDBOX_PROVIDER: SandboxProvider;
|
|
3
|
+
export declare function isSandboxProvider(value: string | undefined): value is SandboxProvider;
|
|
4
|
+
export declare function normalizeSandboxProvider(value: string | undefined): SandboxProvider;
|