zeitlich 0.2.27 → 0.2.28
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/{activities-DE3_q9yq.d.ts → activities-3xj_fEJK.d.ts} +3 -3
- package/dist/{activities-p8PDlRIK.d.cts → activities-BzYq6jf7.d.cts} +3 -3
- package/dist/adapters/sandbox/e2b/index.cjs +230 -0
- package/dist/adapters/sandbox/e2b/index.cjs.map +1 -0
- package/dist/adapters/sandbox/e2b/index.d.cts +77 -0
- package/dist/adapters/sandbox/e2b/index.d.ts +77 -0
- package/dist/adapters/sandbox/e2b/index.js +227 -0
- package/dist/adapters/sandbox/e2b/index.js.map +1 -0
- package/dist/adapters/sandbox/e2b/workflow.cjs +33 -0
- package/dist/adapters/sandbox/e2b/workflow.cjs.map +1 -0
- package/dist/adapters/sandbox/e2b/workflow.d.cts +27 -0
- package/dist/adapters/sandbox/e2b/workflow.d.ts +27 -0
- package/dist/adapters/sandbox/e2b/workflow.js +31 -0
- package/dist/adapters/sandbox/e2b/workflow.js.map +1 -0
- package/dist/adapters/sandbox/virtual/index.d.cts +4 -4
- package/dist/adapters/sandbox/virtual/index.d.ts +4 -4
- package/dist/adapters/sandbox/virtual/workflow.d.cts +2 -2
- package/dist/adapters/sandbox/virtual/workflow.d.ts +2 -2
- package/dist/adapters/thread/anthropic/index.d.cts +5 -5
- package/dist/adapters/thread/anthropic/index.d.ts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.cts +5 -5
- package/dist/adapters/thread/anthropic/workflow.d.ts +5 -5
- package/dist/adapters/thread/google-genai/index.d.cts +5 -5
- package/dist/adapters/thread/google-genai/index.d.ts +5 -5
- package/dist/adapters/thread/google-genai/workflow.d.cts +5 -5
- package/dist/adapters/thread/google-genai/workflow.d.ts +5 -5
- package/dist/adapters/thread/langchain/index.cjs +22 -10
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +12 -9
- package/dist/adapters/thread/langchain/index.d.ts +12 -9
- package/dist/adapters/thread/langchain/index.js +22 -10
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +5 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +5 -5
- package/dist/index.cjs +27 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +27 -16
- package/dist/index.js.map +1 -1
- package/dist/{proxy-BK1ydQt0.d.ts → proxy-7e7v8ccg.d.ts} +1 -1
- package/dist/{proxy-BMAsMHdp.d.cts → proxy-CsB8r0RR.d.cts} +1 -1
- package/dist/{queries-DwnE2bu3.d.cts → queries-DVnukByF.d.cts} +1 -1
- package/dist/{queries-BCgJ9Sr5.d.ts → queries-kjlvsUfz.d.ts} +1 -1
- package/dist/{thread-manager-Bh9x847n.d.ts → thread-manager-B5qA4v7V.d.ts} +1 -1
- package/dist/{thread-manager-dzaJHQEA.d.ts → thread-manager-D8C5QvLi.d.ts} +1 -1
- package/dist/{thread-manager-BlHua5_v.d.cts → thread-manager-DFJ3sKKU.d.cts} +1 -1
- package/dist/{thread-manager-Bz8txKKj.d.cts → thread-manager-DdVFl1IY.d.cts} +1 -1
- package/dist/{types-CIkYBoF8.d.ts → types-BZ75HpYd.d.ts} +1 -1
- package/dist/{types-mCVxKIZb.d.cts → types-BclYm5Ic.d.cts} +0 -4
- package/dist/{types-mCVxKIZb.d.ts → types-BclYm5Ic.d.ts} +0 -4
- package/dist/{types-DRnz-OZp.d.cts → types-BgsAwN3L.d.cts} +1 -1
- package/dist/{types-CvJyXDYt.d.ts → types-BtqbM1bO.d.ts} +1 -1
- package/dist/{types-DSOefLpY.d.cts → types-BuCEZ4dF.d.cts} +1 -1
- package/dist/{types-BfIQABzu.d.cts → types-HbjqzyJH.d.cts} +1 -1
- package/dist/{types-DFUNSYbj.d.ts → types-yU5AINiP.d.ts} +1 -1
- package/dist/workflow.cjs +27 -16
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +7 -7
- package/dist/workflow.d.ts +7 -7
- package/dist/workflow.js +27 -16
- package/dist/workflow.js.map +1 -1
- package/package.json +21 -1
- package/src/adapters/sandbox/e2b/proxy.ts +56 -0
- package/src/adapters/thread/langchain/hooks.test.ts +195 -0
- package/src/adapters/thread/langchain/hooks.ts +29 -12
- package/src/lib/.env +1 -0
- package/src/lib/session/session.ts +16 -5
- package/src/lib/subagent/handler.ts +5 -2
- package/src/lib/subagent/register.ts +7 -2
- package/src/lib/tool-router/router.ts +2 -5
- package/src/lib/tool-router/types.ts +0 -4
- package/src/tools/bash/.env +1 -0
- package/tsup.config.ts +3 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import { Part, Content, GoogleGenAI } from '@google/genai';
|
|
3
|
-
import { R as RouterContext, T as ToolHandlerResponse, A as ActivityToolHandler } from './types-
|
|
4
|
-
import { a as ModelInvoker, P as PrefixedThreadOps, S as ScopedPrefix } from './types-
|
|
5
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { R as RouterContext, T as ToolHandlerResponse, A as ActivityToolHandler } from './types-BclYm5Ic.js';
|
|
4
|
+
import { a as ModelInvoker, P as PrefixedThreadOps, S as ScopedPrefix } from './types-BtqbM1bO.js';
|
|
5
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BZ75HpYd.js';
|
|
6
6
|
|
|
7
7
|
/** SDK-native content type for Google GenAI human messages */
|
|
8
8
|
type GoogleGenAIContent = string | Part[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import { Part, Content, GoogleGenAI } from '@google/genai';
|
|
3
|
-
import { R as RouterContext, T as ToolHandlerResponse, A as ActivityToolHandler } from './types-
|
|
4
|
-
import { a as ModelInvoker, P as PrefixedThreadOps, S as ScopedPrefix } from './types-
|
|
5
|
-
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-
|
|
3
|
+
import { R as RouterContext, T as ToolHandlerResponse, A as ActivityToolHandler } from './types-BclYm5Ic.cjs';
|
|
4
|
+
import { a as ModelInvoker, P as PrefixedThreadOps, S as ScopedPrefix } from './types-BuCEZ4dF.cjs';
|
|
5
|
+
import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-HbjqzyJH.cjs';
|
|
6
6
|
|
|
7
7
|
/** SDK-native content type for Google GenAI human messages */
|
|
8
8
|
type GoogleGenAIContent = string | Part[];
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var codeInterpreter = require('@e2b/code-interpreter');
|
|
4
|
+
var common = require('@temporalio/common');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
|
|
7
|
+
// src/adapters/sandbox/e2b/index.ts
|
|
8
|
+
var SandboxNotSupportedError = class extends common.ApplicationFailure {
|
|
9
|
+
constructor(operation) {
|
|
10
|
+
super(
|
|
11
|
+
`Sandbox does not support: ${operation}`,
|
|
12
|
+
"SandboxNotSupportedError",
|
|
13
|
+
true
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var SandboxNotFoundError = class extends common.ApplicationFailure {
|
|
18
|
+
constructor(sandboxId) {
|
|
19
|
+
super(`Sandbox not found: ${sandboxId}`, "SandboxNotFoundError", true);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function toArrayBuffer(u8) {
|
|
23
|
+
return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
|
|
24
|
+
}
|
|
25
|
+
var E2bSandboxFileSystem = class {
|
|
26
|
+
constructor(sandbox, workspaceBase = "/home/user") {
|
|
27
|
+
this.sandbox = sandbox;
|
|
28
|
+
this.workspaceBase = path.posix.resolve("/", workspaceBase);
|
|
29
|
+
}
|
|
30
|
+
workspaceBase;
|
|
31
|
+
normalisePath(path$1) {
|
|
32
|
+
return path.posix.resolve(this.workspaceBase, path$1);
|
|
33
|
+
}
|
|
34
|
+
async readFile(path) {
|
|
35
|
+
return this.sandbox.files.read(this.normalisePath(path));
|
|
36
|
+
}
|
|
37
|
+
async readFileBuffer(path) {
|
|
38
|
+
return this.sandbox.files.read(this.normalisePath(path), {
|
|
39
|
+
format: "bytes"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async writeFile(path, content) {
|
|
43
|
+
const norm = this.normalisePath(path);
|
|
44
|
+
if (typeof content === "string") {
|
|
45
|
+
await this.sandbox.files.write(norm, content);
|
|
46
|
+
} else {
|
|
47
|
+
await this.sandbox.files.write(norm, toArrayBuffer(content));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async appendFile(path, content) {
|
|
51
|
+
const norm = this.normalisePath(path);
|
|
52
|
+
let existing = "";
|
|
53
|
+
try {
|
|
54
|
+
existing = await this.sandbox.files.read(norm);
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
const addition = typeof content === "string" ? content : new TextDecoder().decode(content);
|
|
58
|
+
await this.sandbox.files.write(norm, existing + addition);
|
|
59
|
+
}
|
|
60
|
+
async exists(path) {
|
|
61
|
+
return this.sandbox.files.exists(this.normalisePath(path));
|
|
62
|
+
}
|
|
63
|
+
async stat(path) {
|
|
64
|
+
const norm = this.normalisePath(path);
|
|
65
|
+
const info = await this.sandbox.files.getInfo(norm);
|
|
66
|
+
const isSymlink = !!info.symlinkTarget;
|
|
67
|
+
return {
|
|
68
|
+
isFile: isSymlink ? false : info.type === codeInterpreter.FileType.FILE,
|
|
69
|
+
isDirectory: isSymlink ? false : info.type === codeInterpreter.FileType.DIR,
|
|
70
|
+
isSymbolicLink: isSymlink,
|
|
71
|
+
size: info.size,
|
|
72
|
+
mtime: info.modifiedTime ?? /* @__PURE__ */ new Date(0)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async mkdir(path, _options) {
|
|
76
|
+
await this.sandbox.files.makeDir(this.normalisePath(path));
|
|
77
|
+
}
|
|
78
|
+
async readdir(path$1) {
|
|
79
|
+
const entries = await this.sandbox.files.list(this.normalisePath(path$1));
|
|
80
|
+
return entries.map((e) => path.posix.basename(e.path));
|
|
81
|
+
}
|
|
82
|
+
async readdirWithFileTypes(path$1) {
|
|
83
|
+
const entries = await this.sandbox.files.list(this.normalisePath(path$1));
|
|
84
|
+
return entries.map((e) => {
|
|
85
|
+
const isSymlink = !!e.symlinkTarget;
|
|
86
|
+
return {
|
|
87
|
+
name: path.posix.basename(e.path),
|
|
88
|
+
isFile: isSymlink ? false : e.type === codeInterpreter.FileType.FILE,
|
|
89
|
+
isDirectory: isSymlink ? false : e.type === codeInterpreter.FileType.DIR,
|
|
90
|
+
isSymbolicLink: isSymlink
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async rm(path, options) {
|
|
95
|
+
const norm = this.normalisePath(path);
|
|
96
|
+
try {
|
|
97
|
+
await this.sandbox.files.remove(norm);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (!options?.force) throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async cp(src, dest, _options) {
|
|
103
|
+
const normSrc = this.normalisePath(src);
|
|
104
|
+
const normDest = this.normalisePath(dest);
|
|
105
|
+
await this.sandbox.commands.run(`cp -r "${normSrc}" "${normDest}"`);
|
|
106
|
+
}
|
|
107
|
+
async mv(src, dest) {
|
|
108
|
+
const normSrc = this.normalisePath(src);
|
|
109
|
+
const normDest = this.normalisePath(dest);
|
|
110
|
+
await this.sandbox.files.rename(normSrc, normDest);
|
|
111
|
+
}
|
|
112
|
+
async readlink(path) {
|
|
113
|
+
const norm = this.normalisePath(path);
|
|
114
|
+
const info = await this.sandbox.files.getInfo(norm);
|
|
115
|
+
if (!info.symlinkTarget) {
|
|
116
|
+
throw new Error(`EINVAL: invalid argument, readlink '${path}'`);
|
|
117
|
+
}
|
|
118
|
+
return info.symlinkTarget;
|
|
119
|
+
}
|
|
120
|
+
resolvePath(base, path$1) {
|
|
121
|
+
return path.posix.resolve(this.normalisePath(base), path$1);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/adapters/sandbox/e2b/index.ts
|
|
126
|
+
var E2bSandboxImpl = class {
|
|
127
|
+
constructor(id, sdkSandbox, workspaceBase = "/home/user") {
|
|
128
|
+
this.id = id;
|
|
129
|
+
this.sdkSandbox = sdkSandbox;
|
|
130
|
+
this.fs = new E2bSandboxFileSystem(sdkSandbox, workspaceBase);
|
|
131
|
+
}
|
|
132
|
+
capabilities = {
|
|
133
|
+
filesystem: true,
|
|
134
|
+
execution: true,
|
|
135
|
+
persistence: true
|
|
136
|
+
};
|
|
137
|
+
fs;
|
|
138
|
+
async exec(command, options) {
|
|
139
|
+
const result = await this.sdkSandbox.commands.run(command, {
|
|
140
|
+
cwd: options?.cwd,
|
|
141
|
+
envs: options?.env,
|
|
142
|
+
timeoutMs: options?.timeout
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
exitCode: result.exitCode,
|
|
146
|
+
stdout: result.stdout,
|
|
147
|
+
stderr: result.stderr
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async destroy() {
|
|
151
|
+
await this.sdkSandbox.kill();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var E2bSandboxProvider = class {
|
|
155
|
+
id = "e2b";
|
|
156
|
+
capabilities = {
|
|
157
|
+
filesystem: true,
|
|
158
|
+
execution: true,
|
|
159
|
+
persistence: true
|
|
160
|
+
};
|
|
161
|
+
defaultTemplate;
|
|
162
|
+
defaultWorkspaceBase;
|
|
163
|
+
defaultTimeoutMs;
|
|
164
|
+
constructor(config) {
|
|
165
|
+
this.defaultTemplate = config?.template;
|
|
166
|
+
this.defaultWorkspaceBase = config?.workspaceBase ?? "/home/user";
|
|
167
|
+
this.defaultTimeoutMs = config?.timeoutMs;
|
|
168
|
+
}
|
|
169
|
+
async create(options) {
|
|
170
|
+
const template = options?.template ?? this.defaultTemplate;
|
|
171
|
+
const workspaceBase = this.defaultWorkspaceBase;
|
|
172
|
+
const createOpts = {
|
|
173
|
+
envs: options?.env,
|
|
174
|
+
timeoutMs: options?.timeoutMs ?? this.defaultTimeoutMs
|
|
175
|
+
};
|
|
176
|
+
const sdkSandbox = template ? await codeInterpreter.Sandbox.create(template, createOpts) : await codeInterpreter.Sandbox.create(createOpts);
|
|
177
|
+
const sandbox = new E2bSandboxImpl(
|
|
178
|
+
sdkSandbox.sandboxId,
|
|
179
|
+
sdkSandbox,
|
|
180
|
+
workspaceBase
|
|
181
|
+
);
|
|
182
|
+
if (options?.initialFiles) {
|
|
183
|
+
await Promise.all(
|
|
184
|
+
Object.entries(options.initialFiles).map(
|
|
185
|
+
([path, content]) => sandbox.fs.writeFile(path, content)
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return { sandbox };
|
|
190
|
+
}
|
|
191
|
+
async get(sandboxId) {
|
|
192
|
+
try {
|
|
193
|
+
const sdkSandbox = await codeInterpreter.Sandbox.connect(sandboxId);
|
|
194
|
+
return new E2bSandboxImpl(sandboxId, sdkSandbox, this.defaultWorkspaceBase);
|
|
195
|
+
} catch {
|
|
196
|
+
throw new SandboxNotFoundError(sandboxId);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async destroy(sandboxId) {
|
|
200
|
+
try {
|
|
201
|
+
const sdkSandbox = await codeInterpreter.Sandbox.connect(sandboxId);
|
|
202
|
+
await sdkSandbox.kill();
|
|
203
|
+
} catch {
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async pause(sandboxId, _ttlSeconds) {
|
|
207
|
+
const sdkSandbox = await codeInterpreter.Sandbox.connect(sandboxId);
|
|
208
|
+
await sdkSandbox.pause();
|
|
209
|
+
}
|
|
210
|
+
async snapshot(_sandboxId) {
|
|
211
|
+
throw new SandboxNotSupportedError("snapshot");
|
|
212
|
+
}
|
|
213
|
+
async restore(_snapshot) {
|
|
214
|
+
throw new SandboxNotSupportedError("restore");
|
|
215
|
+
}
|
|
216
|
+
async fork(sandboxId) {
|
|
217
|
+
const { snapshotId } = await codeInterpreter.Sandbox.createSnapshot(sandboxId);
|
|
218
|
+
const sdkSandbox = await codeInterpreter.Sandbox.create(snapshotId);
|
|
219
|
+
return new E2bSandboxImpl(
|
|
220
|
+
sdkSandbox.sandboxId,
|
|
221
|
+
sdkSandbox,
|
|
222
|
+
this.defaultWorkspaceBase
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
exports.E2bSandboxFileSystem = E2bSandboxFileSystem;
|
|
228
|
+
exports.E2bSandboxProvider = E2bSandboxProvider;
|
|
229
|
+
//# sourceMappingURL=index.cjs.map
|
|
230
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/sandbox/types.ts","../../../../src/adapters/sandbox/e2b/filesystem.ts","../../../../src/adapters/sandbox/e2b/index.ts"],"names":["ApplicationFailure","posix","path","FileType","E2bSdkSandbox"],"mappings":";;;;;;;AAkLO,IAAM,wBAAA,GAAN,cAAuCA,yBAAA,CAAmB;AAAA,EAC/D,YAAY,SAAA,EAAmB;AAC7B,IAAA,KAAA;AAAA,MACE,6BAA6B,SAAS,CAAA,CAAA;AAAA,MACtC,0BAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF,CAAA;AAEO,IAAM,oBAAA,GAAN,cAAmCA,yBAAA,CAAmB;AAAA,EAC3D,YAAY,SAAA,EAAmB;AAC7B,IAAA,KAAA,CAAM,CAAA,mBAAA,EAAsB,SAAS,CAAA,CAAA,EAAI,sBAAA,EAAwB,IAAI,CAAA;AAAA,EACvE;AACF,CAAA;ACxLA,SAAS,cAAc,EAAA,EAA6B;AAClD,EAAA,OAAO,EAAA,CAAG,OAAO,KAAA,CAAM,EAAA,CAAG,YAAY,EAAA,CAAG,UAAA,GAAa,GAAG,UAA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E,CAAA,CAAA,MAAQ;AACN,MAAA,MAAM,IAAI,qBAAqB,SAAS,CAAA;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,MAAM,QAAQ,SAAA,EAAkC;AAC9C,IAAA,IAAI;AACF,MAAA,MAAM,UAAA,GAAa,MAAMA,uBAAA,CAAc,OAAA,CAAQ,SAAS,CAAA;AACxD,MAAA,MAAM,WAAW,IAAA,EAAK;AAAA,IACxB,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAAA,EAEA,MAAM,KAAA,CAAM,SAAA,EAAmB,WAAA,EAAqC;AAClE,IAAA,MAAM,UAAA,GAAa,MAAMA,uBAAA,CAAc,OAAA,CAAQ,SAAS,CAAA;AACxD,IAAA,MAAM,WAAW,KAAA,EAAM;AAAA,EACzB;AAAA,EAEA,MAAM,SAAS,UAAA,EAA8C;AAC3D,IAAA,MAAM,IAAI,yBAAyB,UAAU,CAAA;AAAA,EAC/C;AAAA,EAEA,MAAM,QAAQ,SAAA,EAA8C;AAC1D,IAAA,MAAM,IAAI,yBAAyB,SAAS,CAAA;AAAA,EAC9C;AAAA,EAEA,MAAM,KAAK,SAAA,EAAqC;AAC9C,IAAA,MAAM,EAAE,UAAA,EAAW,GAAI,MAAMA,uBAAA,CAAc,eAAe,SAAS,CAAA;AACnE,IAAA,MAAM,UAAA,GAAa,MAAMA,uBAAA,CAAc,MAAA,CAAO,UAAU,CAAA;AACxD,IAAA,OAAO,IAAI,cAAA;AAAA,MACT,UAAA,CAAW,SAAA;AAAA,MACX,UAAA;AAAA,MACA,IAAA,CAAK;AAAA,KACP;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["// ============================================================================\n// Sandbox Filesystem\n// ============================================================================\n\nexport interface DirentEntry {\n name: string;\n isFile: boolean;\n isDirectory: boolean;\n isSymbolicLink: boolean;\n}\n\nexport interface FileStat {\n isFile: boolean;\n isDirectory: boolean;\n isSymbolicLink: boolean;\n size: number;\n mtime: Date;\n}\n\n/**\n * Provider-agnostic filesystem interface.\n *\n * Implementations that don't support a method should throw\n * {@link SandboxNotSupportedError}.\n */\nexport interface SandboxFileSystem {\n /** Base directory used when resolving relative paths. */\n readonly workspaceBase: string;\n readFile(path: string): Promise<string>;\n readFileBuffer(path: string): Promise<Uint8Array>;\n writeFile(path: string, content: string | Uint8Array): Promise<void>;\n appendFile(path: string, content: string | Uint8Array): Promise<void>;\n exists(path: string): Promise<boolean>;\n stat(path: string): Promise<FileStat>;\n mkdir(path: string, options?: { recursive?: boolean }): Promise<void>;\n readdir(path: string): Promise<string[]>;\n readdirWithFileTypes(path: string): Promise<DirentEntry[]>;\n rm(\n path: string,\n options?: { recursive?: boolean; force?: boolean }\n ): Promise<void>;\n cp(\n src: string,\n dest: string,\n options?: { recursive?: boolean }\n ): Promise<void>;\n mv(src: string, dest: string): Promise<void>;\n readlink(path: string): Promise<string>;\n resolvePath(base: string, path: string): string;\n}\n\n// ============================================================================\n// Execution\n// ============================================================================\n\nexport interface ExecOptions {\n timeout?: number;\n cwd?: string;\n env?: Record<string, string>;\n}\n\nexport interface ExecResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\n// ============================================================================\n// Capabilities\n// ============================================================================\n\nexport interface SandboxCapabilities {\n /** Sandbox supports filesystem operations */\n filesystem: boolean;\n /** Sandbox supports shell/command execution */\n execution: boolean;\n /** Sandbox state can be persisted and restored */\n persistence: boolean;\n}\n\n// ============================================================================\n// Sandbox\n// ============================================================================\n\nexport interface Sandbox {\n readonly id: string;\n readonly capabilities: SandboxCapabilities;\n readonly fs: SandboxFileSystem;\n\n exec(command: string, options?: ExecOptions): Promise<ExecResult>;\n destroy(): Promise<void>;\n}\n\n// ============================================================================\n// Snapshots\n// ============================================================================\n\nexport interface SandboxSnapshot {\n sandboxId: string;\n providerId: string;\n /** Provider-specific serialised state */\n data: unknown;\n createdAt: string;\n}\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport interface SandboxCreateOptions {\n /** Preferred sandbox ID (provider may ignore) */\n id?: string;\n /** Seed the filesystem with these files */\n initialFiles?: Record<string, string | Uint8Array>;\n /** Environment variables available inside the sandbox */\n env?: Record<string, string>;\n}\n\nexport interface SandboxCreateResult {\n sandbox: Sandbox;\n /** Optional state to merge into the workflow's `AgentState` via the session. */\n stateUpdate?: Record<string, unknown>;\n}\n\nexport interface SandboxProvider<\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n TSandbox extends Sandbox = Sandbox,\n> {\n readonly id: string;\n readonly capabilities: SandboxCapabilities;\n\n create(options?: TOptions): Promise<SandboxCreateResult>;\n get(sandboxId: string): Promise<TSandbox>;\n destroy(sandboxId: string): Promise<void>;\n pause(sandboxId: string, ttlSeconds?: number): Promise<void>;\n snapshot(sandboxId: string): Promise<SandboxSnapshot>;\n restore(snapshot: SandboxSnapshot): Promise<Sandbox>;\n fork(sandboxId: string): Promise<Sandbox>;\n}\n\n// ============================================================================\n// SandboxOps — workflow-side activity interface (like ThreadOps)\n// ============================================================================\n\nexport interface SandboxOps<\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n> {\n createSandbox(\n options?: TOptions\n ): Promise<{ sandboxId: string; stateUpdate?: Record<string, unknown> }>;\n destroySandbox(sandboxId: string): Promise<void>;\n pauseSandbox(sandboxId: string): Promise<void>;\n snapshotSandbox(sandboxId: string): Promise<SandboxSnapshot>;\n forkSandbox(sandboxId: string): Promise<string>;\n}\n\n/**\n * Maps generic {@link SandboxOps} method names to adapter-prefixed names.\n *\n * @example\n * ```typescript\n * type InMemOps = PrefixedSandboxOps<\"inMemory\">;\n * // → { inMemoryCreateSandbox, inMemoryDestroySandbox, inMemorySnapshotSandbox }\n * ```\n */\nexport type PrefixedSandboxOps<\n TPrefix extends string,\n TOptions extends SandboxCreateOptions = SandboxCreateOptions,\n> = {\n [K in keyof SandboxOps<TOptions> as `${TPrefix}${Capitalize<K & string>}`]: SandboxOps<TOptions>[K];\n};\n\n// ============================================================================\n// Errors\n// ============================================================================\n\nimport { ApplicationFailure } from \"@temporalio/common\";\n\nexport class SandboxNotSupportedError extends ApplicationFailure {\n constructor(operation: string) {\n super(\n `Sandbox does not support: ${operation}`,\n \"SandboxNotSupportedError\",\n true\n );\n }\n}\n\nexport class SandboxNotFoundError extends ApplicationFailure {\n constructor(sandboxId: string) {\n super(`Sandbox not found: ${sandboxId}`, \"SandboxNotFoundError\", true);\n }\n}\n","import { FileType, type Sandbox as E2bSdkSandbox } from \"@e2b/code-interpreter\";\nimport type {\n SandboxFileSystem,\n DirentEntry,\n FileStat,\n} from \"../../../lib/sandbox/types\";\nimport { posix } from \"node:path\";\n\nfunction toArrayBuffer(u8: Uint8Array): ArrayBuffer {\n return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength) as ArrayBuffer;\n}\n\n/**\n * {@link SandboxFileSystem} backed by an E2B SDK sandbox.\n *\n * Maps zeitlich's filesystem interface to E2B's `sandbox.files` and\n * `sandbox.commands` APIs. Operations that have no direct E2B equivalent\n * (e.g. `appendFile`, `cp`) are composed from primitives.\n */\nexport class E2bSandboxFileSystem implements SandboxFileSystem {\n readonly workspaceBase: string;\n\n constructor(\n private sandbox: E2bSdkSandbox,\n workspaceBase = \"/home/user\"\n ) {\n this.workspaceBase = posix.resolve(\"/\", workspaceBase);\n }\n\n private normalisePath(path: string): string {\n return posix.resolve(this.workspaceBase, path);\n }\n\n async readFile(path: string): Promise<string> {\n return this.sandbox.files.read(this.normalisePath(path));\n }\n\n async readFileBuffer(path: string): Promise<Uint8Array> {\n return this.sandbox.files.read(this.normalisePath(path), {\n format: \"bytes\",\n });\n }\n\n async writeFile(path: string, content: string | Uint8Array): Promise<void> {\n const norm = this.normalisePath(path);\n if (typeof content === \"string\") {\n await this.sandbox.files.write(norm, content);\n } else {\n await this.sandbox.files.write(norm, toArrayBuffer(content));\n }\n }\n\n async appendFile(path: string, content: string | Uint8Array): Promise<void> {\n const norm = this.normalisePath(path);\n let existing = \"\";\n try {\n existing = await this.sandbox.files.read(norm);\n } catch {\n // file doesn't exist yet — write from scratch\n }\n const addition =\n typeof content === \"string\"\n ? content\n : new TextDecoder().decode(content);\n await this.sandbox.files.write(norm, existing + addition);\n }\n\n async exists(path: string): Promise<boolean> {\n return this.sandbox.files.exists(this.normalisePath(path));\n }\n\n async stat(path: string): Promise<FileStat> {\n const norm = this.normalisePath(path);\n const info = await this.sandbox.files.getInfo(norm);\n const isSymlink = !!info.symlinkTarget;\n return {\n isFile: isSymlink ? false : info.type === FileType.FILE,\n isDirectory: isSymlink ? false : info.type === FileType.DIR,\n isSymbolicLink: isSymlink,\n size: info.size,\n mtime: info.modifiedTime ?? new Date(0),\n };\n }\n\n async mkdir(path: string, _options?: { recursive?: boolean }): Promise<void> {\n await this.sandbox.files.makeDir(this.normalisePath(path));\n }\n\n async readdir(path: string): Promise<string[]> {\n const entries = await this.sandbox.files.list(this.normalisePath(path));\n return entries.map((e) => posix.basename(e.path));\n }\n\n async readdirWithFileTypes(path: string): Promise<DirentEntry[]> {\n const entries = await this.sandbox.files.list(this.normalisePath(path));\n return entries.map((e) => {\n const isSymlink = !!e.symlinkTarget;\n return {\n name: posix.basename(e.path),\n isFile: isSymlink ? false : e.type === FileType.FILE,\n isDirectory: isSymlink ? false : e.type === FileType.DIR,\n isSymbolicLink: isSymlink,\n };\n });\n }\n\n async rm(\n path: string,\n options?: { recursive?: boolean; force?: boolean }\n ): Promise<void> {\n const norm = this.normalisePath(path);\n try {\n await this.sandbox.files.remove(norm);\n } catch (err) {\n if (!options?.force) throw err;\n }\n }\n\n async cp(\n src: string,\n dest: string,\n _options?: { recursive?: boolean }\n ): Promise<void> {\n const normSrc = this.normalisePath(src);\n const normDest = this.normalisePath(dest);\n await this.sandbox.commands.run(`cp -r \"${normSrc}\" \"${normDest}\"`);\n }\n\n async mv(src: string, dest: string): Promise<void> {\n const normSrc = this.normalisePath(src);\n const normDest = this.normalisePath(dest);\n await this.sandbox.files.rename(normSrc, normDest);\n }\n\n async readlink(path: string): Promise<string> {\n const norm = this.normalisePath(path);\n const info = await this.sandbox.files.getInfo(norm);\n if (!info.symlinkTarget) {\n throw new Error(`EINVAL: invalid argument, readlink '${path}'`);\n }\n return info.symlinkTarget;\n }\n\n resolvePath(base: string, path: string): string {\n return posix.resolve(this.normalisePath(base), path);\n }\n}\n","import { Sandbox as E2bSdkSandbox } from \"@e2b/code-interpreter\";\nimport type {\n Sandbox,\n SandboxCapabilities,\n SandboxCreateResult,\n SandboxProvider,\n SandboxSnapshot,\n ExecOptions,\n ExecResult,\n} from \"../../../lib/sandbox/types\";\nimport {\n SandboxNotFoundError,\n SandboxNotSupportedError,\n} from \"../../../lib/sandbox/types\";\nimport { E2bSandboxFileSystem } from \"./filesystem\";\nimport type {\n E2bSandbox,\n E2bSandboxConfig,\n E2bSandboxCreateOptions,\n} from \"./types\";\n\n// ============================================================================\n// E2bSandbox\n// ============================================================================\n\nclass E2bSandboxImpl implements Sandbox {\n readonly capabilities: SandboxCapabilities = {\n filesystem: true,\n execution: true,\n persistence: true,\n };\n\n readonly fs: E2bSandboxFileSystem;\n\n constructor(\n readonly id: string,\n private sdkSandbox: E2bSdkSandbox,\n workspaceBase = \"/home/user\"\n ) {\n this.fs = new E2bSandboxFileSystem(sdkSandbox, workspaceBase);\n }\n\n async exec(command: string, options?: ExecOptions): Promise<ExecResult> {\n const result = await this.sdkSandbox.commands.run(command, {\n cwd: options?.cwd,\n envs: options?.env,\n timeoutMs: options?.timeout,\n });\n return {\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n };\n }\n\n async destroy(): Promise<void> {\n await this.sdkSandbox.kill();\n }\n}\n\n// ============================================================================\n// E2bSandboxProvider\n// ============================================================================\n\nexport class E2bSandboxProvider\n implements SandboxProvider<E2bSandboxCreateOptions, E2bSandbox>\n{\n readonly id = \"e2b\";\n readonly capabilities: SandboxCapabilities = {\n filesystem: true,\n execution: true,\n persistence: true,\n };\n\n private readonly defaultTemplate?: string;\n private readonly defaultWorkspaceBase: string;\n private readonly defaultTimeoutMs?: number;\n\n constructor(config?: E2bSandboxConfig) {\n this.defaultTemplate = config?.template;\n this.defaultWorkspaceBase = config?.workspaceBase ?? \"/home/user\";\n this.defaultTimeoutMs = config?.timeoutMs;\n }\n\n async create(\n options?: E2bSandboxCreateOptions\n ): Promise<SandboxCreateResult> {\n const template = options?.template ?? this.defaultTemplate;\n const workspaceBase = this.defaultWorkspaceBase;\n const createOpts = {\n envs: options?.env,\n timeoutMs: options?.timeoutMs ?? this.defaultTimeoutMs,\n };\n\n const sdkSandbox = template\n ? await E2bSdkSandbox.create(template, createOpts)\n : await E2bSdkSandbox.create(createOpts);\n\n const sandbox = new E2bSandboxImpl(\n sdkSandbox.sandboxId,\n sdkSandbox,\n workspaceBase\n );\n\n if (options?.initialFiles) {\n await Promise.all(\n Object.entries(options.initialFiles).map(([path, content]) =>\n sandbox.fs.writeFile(path, content)\n )\n );\n }\n\n return { sandbox };\n }\n\n async get(sandboxId: string): Promise<E2bSandbox> {\n try {\n const sdkSandbox = await E2bSdkSandbox.connect(sandboxId);\n return new E2bSandboxImpl(sandboxId, sdkSandbox, this.defaultWorkspaceBase);\n } catch {\n throw new SandboxNotFoundError(sandboxId);\n }\n }\n\n async destroy(sandboxId: string): Promise<void> {\n try {\n const sdkSandbox = await E2bSdkSandbox.connect(sandboxId);\n await sdkSandbox.kill();\n } catch {\n // Already gone or not found\n }\n }\n\n async pause(sandboxId: string, _ttlSeconds?: number): Promise<void> {\n const sdkSandbox = await E2bSdkSandbox.connect(sandboxId);\n await sdkSandbox.pause();\n }\n\n async snapshot(_sandboxId: string): Promise<SandboxSnapshot> {\n throw new SandboxNotSupportedError(\"snapshot\");\n }\n\n async restore(_snapshot: SandboxSnapshot): Promise<Sandbox> {\n throw new SandboxNotSupportedError(\"restore\");\n }\n\n async fork(sandboxId: string): Promise<Sandbox> {\n const { snapshotId } = await E2bSdkSandbox.createSnapshot(sandboxId);\n const sdkSandbox = await E2bSdkSandbox.create(snapshotId);\n return new E2bSandboxImpl(\n sdkSandbox.sandboxId,\n sdkSandbox,\n this.defaultWorkspaceBase\n );\n }\n}\n\n// Re-exports\nexport { E2bSandboxFileSystem } from \"./filesystem\";\nexport type {\n E2bSandbox,\n E2bSandboxConfig,\n E2bSandboxCreateOptions,\n} from \"./types\";\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox$1, d as SandboxCreateOptions, b as SandboxProvider, c as SandboxCapabilities, e as SandboxCreateResult, f as SandboxSnapshot } from '../../../types-ChAMwU3q.cjs';
|
|
2
|
+
import { Sandbox } from '@e2b/code-interpreter';
|
|
3
|
+
import '@temporalio/common';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@link SandboxFileSystem} backed by an E2B SDK sandbox.
|
|
7
|
+
*
|
|
8
|
+
* Maps zeitlich's filesystem interface to E2B's `sandbox.files` and
|
|
9
|
+
* `sandbox.commands` APIs. Operations that have no direct E2B equivalent
|
|
10
|
+
* (e.g. `appendFile`, `cp`) are composed from primitives.
|
|
11
|
+
*/
|
|
12
|
+
declare class E2bSandboxFileSystem implements SandboxFileSystem {
|
|
13
|
+
private sandbox;
|
|
14
|
+
readonly workspaceBase: string;
|
|
15
|
+
constructor(sandbox: Sandbox, workspaceBase?: string);
|
|
16
|
+
private normalisePath;
|
|
17
|
+
readFile(path: string): Promise<string>;
|
|
18
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
19
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
20
|
+
appendFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
21
|
+
exists(path: string): Promise<boolean>;
|
|
22
|
+
stat(path: string): Promise<FileStat>;
|
|
23
|
+
mkdir(path: string, _options?: {
|
|
24
|
+
recursive?: boolean;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
readdir(path: string): Promise<string[]>;
|
|
27
|
+
readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
|
|
28
|
+
rm(path: string, options?: {
|
|
29
|
+
recursive?: boolean;
|
|
30
|
+
force?: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
cp(src: string, dest: string, _options?: {
|
|
33
|
+
recursive?: boolean;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
mv(src: string, dest: string): Promise<void>;
|
|
36
|
+
readlink(path: string): Promise<string>;
|
|
37
|
+
resolvePath(base: string, path: string): string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An E2B-backed {@link Sandbox} with its typed filesystem.
|
|
42
|
+
*/
|
|
43
|
+
type E2bSandbox = Sandbox$1 & {
|
|
44
|
+
fs: E2bSandboxFileSystem;
|
|
45
|
+
};
|
|
46
|
+
interface E2bSandboxConfig {
|
|
47
|
+
/** Sandbox template name or ID */
|
|
48
|
+
template?: string;
|
|
49
|
+
/** Default working directory inside the sandbox */
|
|
50
|
+
workspaceBase?: string;
|
|
51
|
+
/** Sandbox idle timeout in milliseconds */
|
|
52
|
+
timeoutMs?: number;
|
|
53
|
+
}
|
|
54
|
+
interface E2bSandboxCreateOptions extends SandboxCreateOptions {
|
|
55
|
+
/** Sandbox template name or ID — overrides the provider default */
|
|
56
|
+
template?: string;
|
|
57
|
+
/** Sandbox idle timeout in milliseconds — overrides the provider default */
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare class E2bSandboxProvider implements SandboxProvider<E2bSandboxCreateOptions, E2bSandbox> {
|
|
62
|
+
readonly id = "e2b";
|
|
63
|
+
readonly capabilities: SandboxCapabilities;
|
|
64
|
+
private readonly defaultTemplate?;
|
|
65
|
+
private readonly defaultWorkspaceBase;
|
|
66
|
+
private readonly defaultTimeoutMs?;
|
|
67
|
+
constructor(config?: E2bSandboxConfig);
|
|
68
|
+
create(options?: E2bSandboxCreateOptions): Promise<SandboxCreateResult>;
|
|
69
|
+
get(sandboxId: string): Promise<E2bSandbox>;
|
|
70
|
+
destroy(sandboxId: string): Promise<void>;
|
|
71
|
+
pause(sandboxId: string, _ttlSeconds?: number): Promise<void>;
|
|
72
|
+
snapshot(_sandboxId: string): Promise<SandboxSnapshot>;
|
|
73
|
+
restore(_snapshot: SandboxSnapshot): Promise<Sandbox$1>;
|
|
74
|
+
fork(sandboxId: string): Promise<Sandbox$1>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { type E2bSandbox, type E2bSandboxConfig, type E2bSandboxCreateOptions, E2bSandboxFileSystem, E2bSandboxProvider };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox$1, d as SandboxCreateOptions, b as SandboxProvider, c as SandboxCapabilities, e as SandboxCreateResult, f as SandboxSnapshot } from '../../../types-ChAMwU3q.js';
|
|
2
|
+
import { Sandbox } from '@e2b/code-interpreter';
|
|
3
|
+
import '@temporalio/common';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@link SandboxFileSystem} backed by an E2B SDK sandbox.
|
|
7
|
+
*
|
|
8
|
+
* Maps zeitlich's filesystem interface to E2B's `sandbox.files` and
|
|
9
|
+
* `sandbox.commands` APIs. Operations that have no direct E2B equivalent
|
|
10
|
+
* (e.g. `appendFile`, `cp`) are composed from primitives.
|
|
11
|
+
*/
|
|
12
|
+
declare class E2bSandboxFileSystem implements SandboxFileSystem {
|
|
13
|
+
private sandbox;
|
|
14
|
+
readonly workspaceBase: string;
|
|
15
|
+
constructor(sandbox: Sandbox, workspaceBase?: string);
|
|
16
|
+
private normalisePath;
|
|
17
|
+
readFile(path: string): Promise<string>;
|
|
18
|
+
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
19
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
20
|
+
appendFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
21
|
+
exists(path: string): Promise<boolean>;
|
|
22
|
+
stat(path: string): Promise<FileStat>;
|
|
23
|
+
mkdir(path: string, _options?: {
|
|
24
|
+
recursive?: boolean;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
readdir(path: string): Promise<string[]>;
|
|
27
|
+
readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
|
|
28
|
+
rm(path: string, options?: {
|
|
29
|
+
recursive?: boolean;
|
|
30
|
+
force?: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
cp(src: string, dest: string, _options?: {
|
|
33
|
+
recursive?: boolean;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
mv(src: string, dest: string): Promise<void>;
|
|
36
|
+
readlink(path: string): Promise<string>;
|
|
37
|
+
resolvePath(base: string, path: string): string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An E2B-backed {@link Sandbox} with its typed filesystem.
|
|
42
|
+
*/
|
|
43
|
+
type E2bSandbox = Sandbox$1 & {
|
|
44
|
+
fs: E2bSandboxFileSystem;
|
|
45
|
+
};
|
|
46
|
+
interface E2bSandboxConfig {
|
|
47
|
+
/** Sandbox template name or ID */
|
|
48
|
+
template?: string;
|
|
49
|
+
/** Default working directory inside the sandbox */
|
|
50
|
+
workspaceBase?: string;
|
|
51
|
+
/** Sandbox idle timeout in milliseconds */
|
|
52
|
+
timeoutMs?: number;
|
|
53
|
+
}
|
|
54
|
+
interface E2bSandboxCreateOptions extends SandboxCreateOptions {
|
|
55
|
+
/** Sandbox template name or ID — overrides the provider default */
|
|
56
|
+
template?: string;
|
|
57
|
+
/** Sandbox idle timeout in milliseconds — overrides the provider default */
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare class E2bSandboxProvider implements SandboxProvider<E2bSandboxCreateOptions, E2bSandbox> {
|
|
62
|
+
readonly id = "e2b";
|
|
63
|
+
readonly capabilities: SandboxCapabilities;
|
|
64
|
+
private readonly defaultTemplate?;
|
|
65
|
+
private readonly defaultWorkspaceBase;
|
|
66
|
+
private readonly defaultTimeoutMs?;
|
|
67
|
+
constructor(config?: E2bSandboxConfig);
|
|
68
|
+
create(options?: E2bSandboxCreateOptions): Promise<SandboxCreateResult>;
|
|
69
|
+
get(sandboxId: string): Promise<E2bSandbox>;
|
|
70
|
+
destroy(sandboxId: string): Promise<void>;
|
|
71
|
+
pause(sandboxId: string, _ttlSeconds?: number): Promise<void>;
|
|
72
|
+
snapshot(_sandboxId: string): Promise<SandboxSnapshot>;
|
|
73
|
+
restore(_snapshot: SandboxSnapshot): Promise<Sandbox$1>;
|
|
74
|
+
fork(sandboxId: string): Promise<Sandbox$1>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { type E2bSandbox, type E2bSandboxConfig, type E2bSandboxCreateOptions, E2bSandboxFileSystem, E2bSandboxProvider };
|