@n8n/agents 0.10.1 → 0.11.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/dist/build.tsbuildinfo +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime/agent-runtime.d.ts +14 -6
- package/dist/runtime/agent-runtime.js +320 -243
- 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 +1 -2
- package/dist/runtime/mcp-connection.js +1 -4
- 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 +3 -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 +20 -4
- package/dist/sdk/catalog.js.map +1 -1
- 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/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 +58 -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 +41 -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,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSandbox = createSandbox;
|
|
4
|
+
exports.createFilesystem = createFilesystem;
|
|
5
|
+
const daytona_sandbox_1 = require("./daytona-sandbox");
|
|
6
|
+
const n8n_sandbox_sandbox_1 = require("./n8n-sandbox-sandbox");
|
|
7
|
+
const daytona_filesystem_1 = require("../filesystem/daytona-filesystem");
|
|
8
|
+
const n8n_sandbox_filesystem_1 = require("../filesystem/n8n-sandbox-filesystem");
|
|
9
|
+
async function createSandbox(config, options = {}) {
|
|
10
|
+
return await Promise.resolve(buildSandbox(config, options));
|
|
11
|
+
}
|
|
12
|
+
function buildSandbox(config, options = {}) {
|
|
13
|
+
if (!config.enabled)
|
|
14
|
+
return undefined;
|
|
15
|
+
const provider = config.provider;
|
|
16
|
+
if (provider === 'daytona') {
|
|
17
|
+
const mode = config.getAuthToken ? 'proxy' : 'direct';
|
|
18
|
+
const logger = options.logger ?? config.logger;
|
|
19
|
+
return new daytona_sandbox_1.DaytonaSandbox({
|
|
20
|
+
id: config.id,
|
|
21
|
+
name: config.name,
|
|
22
|
+
apiKey: config.getAuthToken ? undefined : config.daytonaApiKey,
|
|
23
|
+
getAuthToken: config.getAuthToken,
|
|
24
|
+
refreshSkewMs: config.refreshSkewMs,
|
|
25
|
+
logger,
|
|
26
|
+
apiUrl: config.daytonaApiUrl,
|
|
27
|
+
labels: config.labels,
|
|
28
|
+
...(config.image ? { image: config.image } : {}),
|
|
29
|
+
...(config.snapshot ? { snapshot: config.snapshot } : {}),
|
|
30
|
+
language: 'typescript',
|
|
31
|
+
timeout: config.timeout ?? 300_000,
|
|
32
|
+
createTimeoutSeconds: config.createTimeoutSeconds ?? 300,
|
|
33
|
+
errorReporter: options.errorReporter,
|
|
34
|
+
createStrategyMode: mode,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (provider === 'n8n-sandbox') {
|
|
38
|
+
return new n8n_sandbox_sandbox_1.N8nSandboxServiceSandbox({
|
|
39
|
+
apiKey: config.apiKey,
|
|
40
|
+
serviceUrl: config.serviceUrl,
|
|
41
|
+
timeout: config.timeout ?? 300_000,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const exhaustiveProvider = provider;
|
|
45
|
+
throw new Error(`Unsupported sandbox provider: ${String(exhaustiveProvider)}`);
|
|
46
|
+
}
|
|
47
|
+
function createFilesystem(sandbox) {
|
|
48
|
+
if (!sandbox)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (sandbox instanceof n8n_sandbox_sandbox_1.N8nSandboxServiceSandbox) {
|
|
51
|
+
return new n8n_sandbox_filesystem_1.N8nSandboxFilesystem(sandbox);
|
|
52
|
+
}
|
|
53
|
+
if (sandbox instanceof daytona_sandbox_1.DaytonaSandbox) {
|
|
54
|
+
return new daytona_filesystem_1.DaytonaFilesystem(sandbox);
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Unsupported sandbox instance: ${sandbox.name}`);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=create-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-workspace.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/create-workspace.ts"],"names":[],"mappings":";;AA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AC;YACzD,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,OAAO;YAClC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,GAAG;YACxD,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,kBAAkB,EAAE,IAAI;SACxB,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,KAAK,aAAa,EAAE,CAAC;QAChC,OAAO,IAAI,8CAAwB,CAAC;YACnC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,OAAO;SAClC,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,kBAAkB,GAAU,QAAQ,CAAC;IAC3C,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC;AAID,SAAgB,gBAAgB,CAC/B,OAAoC;IAEpC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/B,IAAI,OAAO,YAAY,8CAAwB,EAAE,CAAC;QACjD,OAAO,IAAI,6CAAoB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,OAAO,YAAY,gCAAc,EAAE,CAAC;QACvC,OAAO,IAAI,sCAAiB,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Daytona } from '@daytonaio/sdk';
|
|
2
|
+
import type { Logger } from './logger';
|
|
3
|
+
export interface DaytonaAuthManagerOptions {
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
target?: string;
|
|
6
|
+
staticApiKey?: string;
|
|
7
|
+
getAuthToken?: () => Promise<string>;
|
|
8
|
+
refreshSkewMs?: number;
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
sandboxName?: string;
|
|
11
|
+
now?: () => number;
|
|
12
|
+
}
|
|
13
|
+
export declare class DaytonaAuthManager {
|
|
14
|
+
private readonly options;
|
|
15
|
+
private readonly now;
|
|
16
|
+
private readonly refreshSkewMs;
|
|
17
|
+
private client?;
|
|
18
|
+
private expiresAt;
|
|
19
|
+
private pendingRefresh?;
|
|
20
|
+
private generation;
|
|
21
|
+
constructor(options: DaytonaAuthManagerOptions);
|
|
22
|
+
getClient(): Promise<Daytona>;
|
|
23
|
+
getGeneration(): number;
|
|
24
|
+
private refresh;
|
|
25
|
+
private doRefresh;
|
|
26
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DaytonaAuthManager = void 0;
|
|
4
|
+
const utils_1 = require("@n8n/utils");
|
|
5
|
+
const lazy_daytona_1 = require("./lazy-daytona");
|
|
6
|
+
const DEFAULT_REFRESH_SKEW_MS = 5 * 60 * 1000;
|
|
7
|
+
const DECODE_FALLBACK_TTL_MS = 30 * 60 * 1000;
|
|
8
|
+
class DaytonaAuthManager {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.expiresAt = 0;
|
|
11
|
+
this.generation = 0;
|
|
12
|
+
const hasStatic = options.staticApiKey !== undefined;
|
|
13
|
+
const hasCallback = options.getAuthToken !== undefined;
|
|
14
|
+
if (hasStatic === hasCallback) {
|
|
15
|
+
throw new Error('DaytonaAuthManager requires exactly one of staticApiKey or getAuthToken');
|
|
16
|
+
}
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.now = options.now ?? Date.now;
|
|
19
|
+
this.refreshSkewMs =
|
|
20
|
+
options.refreshSkewMs !== undefined && options.refreshSkewMs > 0
|
|
21
|
+
? options.refreshSkewMs
|
|
22
|
+
: DEFAULT_REFRESH_SKEW_MS;
|
|
23
|
+
if (hasStatic) {
|
|
24
|
+
this.expiresAt = Number.POSITIVE_INFINITY;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async getClient() {
|
|
28
|
+
if (this.client && this.now() + this.refreshSkewMs < this.expiresAt) {
|
|
29
|
+
return this.client;
|
|
30
|
+
}
|
|
31
|
+
await this.refresh();
|
|
32
|
+
if (!this.client) {
|
|
33
|
+
throw new Error('DaytonaAuthManager.refresh did not set a client');
|
|
34
|
+
}
|
|
35
|
+
return this.client;
|
|
36
|
+
}
|
|
37
|
+
getGeneration() {
|
|
38
|
+
return this.generation;
|
|
39
|
+
}
|
|
40
|
+
async refresh() {
|
|
41
|
+
if (this.pendingRefresh) {
|
|
42
|
+
await this.pendingRefresh;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.pendingRefresh = this.doRefresh().finally(() => {
|
|
46
|
+
this.pendingRefresh = undefined;
|
|
47
|
+
});
|
|
48
|
+
await this.pendingRefresh;
|
|
49
|
+
}
|
|
50
|
+
async doRefresh() {
|
|
51
|
+
const { Daytona } = (0, lazy_daytona_1.loadDaytona)();
|
|
52
|
+
const apiKey = this.options.getAuthToken
|
|
53
|
+
? await this.options.getAuthToken()
|
|
54
|
+
: this.options.staticApiKey;
|
|
55
|
+
const connection = { apiKey };
|
|
56
|
+
if (this.options.apiUrl !== undefined)
|
|
57
|
+
connection.apiUrl = this.options.apiUrl;
|
|
58
|
+
if (this.options.target !== undefined)
|
|
59
|
+
connection.target = this.options.target;
|
|
60
|
+
let decodedFromJwt = false;
|
|
61
|
+
if (this.options.getAuthToken && apiKey) {
|
|
62
|
+
const expSeconds = (0, utils_1.getJwtExpiry)(apiKey);
|
|
63
|
+
decodedFromJwt = expSeconds !== undefined;
|
|
64
|
+
this.expiresAt =
|
|
65
|
+
expSeconds !== undefined ? expSeconds * 1000 : this.now() + DECODE_FALLBACK_TTL_MS;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.expiresAt = Number.POSITIVE_INFINITY;
|
|
69
|
+
}
|
|
70
|
+
this.client = new Daytona(connection);
|
|
71
|
+
this.generation += 1;
|
|
72
|
+
if (this.options.getAuthToken) {
|
|
73
|
+
const ttlMs = this.expiresAt - this.now();
|
|
74
|
+
this.options.logger?.debug('Daytona auth token refreshed', {
|
|
75
|
+
sandboxName: this.options.sandboxName,
|
|
76
|
+
generation: this.generation,
|
|
77
|
+
expiresInMs: ttlMs,
|
|
78
|
+
expirySource: decodedFromJwt ? 'jwt-exp' : 'fallback',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.DaytonaAuthManager = DaytonaAuthManager;
|
|
84
|
+
//# sourceMappingURL=daytona-auth-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daytona-auth-manager.js","sourceRoot":"","sources":["../../../src/workspace/sandbox/daytona-auth-manager.ts"],"names":[],"mappings":";;;AACA,sCAA0C;AAE1C,iDAA6C;AAG7C,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9C,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAqC9C,MAAa,kBAAkB;IAS9B,YAAY,OAAkC;QAJtC,cAAS,GAAG,CAAC,CAAC;QAEd,eAAU,GAAG,CAAC,CAAC;QAGtB,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC;QACrD,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC;QACvD,IAAI,SAAS,KAAK,WAAW,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;QAC5F,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;QACnC,IAAI,CAAC,aAAa;YACjB,OAAO,CAAC,aAAa,KAAK,SAAS,IAAI,OAA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AAC,UAAU;aACrD,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD;AApFD,gDAoFC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CreateSandboxFromImageParams, Resources, Sandbox, VolumeMount } from '@daytonaio/sdk';
|
|
2
|
+
import type { CommandResult, ExecuteCommandOptions, ProviderStatus, SandboxInfo } from '../types';
|
|
3
|
+
import { BaseSandbox } from './base-sandbox';
|
|
4
|
+
import type { ErrorReporter, Logger } from './logger';
|
|
5
|
+
export interface DaytonaSandboxOptions {
|
|
6
|
+
id?: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
getAuthToken?: () => Promise<string>;
|
|
9
|
+
refreshSkewMs?: number;
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
apiUrl?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
createTimeoutSeconds?: number;
|
|
15
|
+
language?: 'typescript' | 'javascript' | 'python';
|
|
16
|
+
resources?: Resources;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
labels?: Record<string, string>;
|
|
19
|
+
snapshot?: string;
|
|
20
|
+
image?: CreateSandboxFromImageParams['image'];
|
|
21
|
+
ephemeral?: boolean;
|
|
22
|
+
autoStopInterval?: number;
|
|
23
|
+
autoArchiveInterval?: number;
|
|
24
|
+
autoDeleteInterval?: number;
|
|
25
|
+
volumes?: VolumeMount[];
|
|
26
|
+
name?: string;
|
|
27
|
+
user?: string;
|
|
28
|
+
public?: boolean;
|
|
29
|
+
networkBlockAll?: boolean;
|
|
30
|
+
networkAllowList?: string;
|
|
31
|
+
errorReporter?: ErrorReporter;
|
|
32
|
+
createStrategyMode?: 'direct' | 'proxy';
|
|
33
|
+
}
|
|
34
|
+
export declare class DaytonaSandbox extends BaseSandbox {
|
|
35
|
+
private readonly options;
|
|
36
|
+
private static readonly DEAD_STATES;
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly name = "DaytonaSandbox";
|
|
39
|
+
readonly provider = "daytona";
|
|
40
|
+
status: ProviderStatus;
|
|
41
|
+
private readonly timeout;
|
|
42
|
+
private readonly language;
|
|
43
|
+
private readonly createdAt;
|
|
44
|
+
private readonly auth;
|
|
45
|
+
private readonly sandboxName;
|
|
46
|
+
private lastClientGeneration;
|
|
47
|
+
private sandbox?;
|
|
48
|
+
private workingDirectory?;
|
|
49
|
+
private recoveryPromise?;
|
|
50
|
+
constructor(options?: DaytonaSandboxOptions);
|
|
51
|
+
get instance(): Sandbox;
|
|
52
|
+
start(): Promise<void>;
|
|
53
|
+
stop(): Promise<void>;
|
|
54
|
+
destroy(): Promise<void>;
|
|
55
|
+
executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
56
|
+
withFilesystem<T>(op: (fs: Sandbox['fs']) => Promise<T>): Promise<T>;
|
|
57
|
+
ensureAuthFresh(): Promise<void>;
|
|
58
|
+
getInfo(): SandboxInfo;
|
|
59
|
+
getInstructions(): string;
|
|
60
|
+
private getDaytona;
|
|
61
|
+
private resetLocalHandle;
|
|
62
|
+
private isRecoverable;
|
|
63
|
+
private recoverAndRetry;
|
|
64
|
+
private recover;
|
|
65
|
+
private findExistingSandbox;
|
|
66
|
+
private createSandbox;
|
|
67
|
+
private createSandboxParams;
|
|
68
|
+
private reportCreateError;
|
|
69
|
+
private detectWorkingDirectory;
|
|
70
|
+
private isDeadState;
|
|
71
|
+
private compactEnv;
|
|
72
|
+
}
|
|
@@ -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,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BAAmB;IACnB,0BAA0B;CAC1B,CAA8B,AALI,CAKH"}
|
|
@@ -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
|