noumen 0.4.0 → 0.5.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/README.md +63 -8
- package/dist/a2a/index.d.ts +4 -2
- package/dist/acp/index.d.ts +5 -3
- package/dist/{agent-1nFVUP9E.d.ts → agent-C3eDRsxs.d.ts} +19 -508
- package/dist/chunk-I5SBSOS6.js +40 -0
- package/dist/chunk-I5SBSOS6.js.map +1 -0
- package/dist/{chunk-4HW6LN6D.js → chunk-WPCYGZOE.js} +58 -1228
- package/dist/chunk-WPCYGZOE.js.map +1 -0
- package/dist/{chunk-5JN4SPI7.js → chunk-WTLK2ZAR.js} +1 -1
- package/dist/{chunk-HL6JCRZJ.js → chunk-XZN4QZLK.js} +4 -4
- package/dist/cli/index.js +10 -10
- package/dist/computer-BPdxSo6X.d.ts +88 -0
- package/dist/docker.d.ts +129 -0
- package/dist/docker.js +401 -0
- package/dist/docker.js.map +1 -0
- package/dist/e2b.d.ts +157 -0
- package/dist/e2b.js +202 -0
- package/dist/e2b.js.map +1 -0
- package/dist/freestyle.d.ts +174 -0
- package/dist/freestyle.js +240 -0
- package/dist/freestyle.js.map +1 -0
- package/dist/index.d.ts +9 -201
- package/dist/index.js +24 -48
- package/dist/lsp/index.d.ts +3 -2
- package/dist/mcp/index.d.ts +4 -3
- package/dist/mcp/index.js +2 -2
- package/dist/{provider-factory-KCLIF34X.js → provider-factory-KI7OZUY3.js} +2 -2
- package/dist/{resolve-4JA2BBDA.js → resolve-GDSHNMG6.js} +2 -2
- package/dist/sandbox-9qeMTNrD.d.ts +126 -0
- package/dist/server/index.d.ts +4 -2
- package/dist/{server-CHMxuWKq.d.ts → server-Cu9gv1dk.d.ts} +1 -1
- package/dist/sprites.d.ts +136 -0
- package/dist/sprites.js +334 -0
- package/dist/sprites.js.map +1 -0
- package/dist/ssh.d.ts +187 -0
- package/dist/ssh.js +392 -0
- package/dist/ssh.js.map +1 -0
- package/dist/{types-RPKUTu1k.d.ts → types-BA87bHPV.d.ts} +2 -88
- package/package.json +25 -1
- package/dist/chunk-4HW6LN6D.js.map +0 -1
- /package/dist/{chunk-5JN4SPI7.js.map → chunk-WTLK2ZAR.js.map} +0 -0
- /package/dist/{chunk-HL6JCRZJ.js.map → chunk-XZN4QZLK.js.map} +0 -0
- /package/dist/{provider-factory-KCLIF34X.js.map → provider-factory-KI7OZUY3.js.map} +0 -0
- /package/dist/{resolve-4JA2BBDA.js.map → resolve-GDSHNMG6.js.map} +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createComputerProxy,
|
|
3
|
+
createFsProxy
|
|
4
|
+
} from "./chunk-I5SBSOS6.js";
|
|
5
|
+
import "./chunk-DGUM43GV.js";
|
|
6
|
+
|
|
7
|
+
// src/virtual/freestyle-fs.ts
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
var FreestyleFs = class {
|
|
10
|
+
vm;
|
|
11
|
+
workingDir;
|
|
12
|
+
constructor(opts) {
|
|
13
|
+
this.vm = opts.vm;
|
|
14
|
+
this.workingDir = opts.workingDir;
|
|
15
|
+
}
|
|
16
|
+
resolvePath(p) {
|
|
17
|
+
if (p.includes("\0")) {
|
|
18
|
+
throw new Error("Path contains null bytes");
|
|
19
|
+
}
|
|
20
|
+
if (!this.workingDir) return p;
|
|
21
|
+
const normalizedBase = this.workingDir.endsWith("/") ? this.workingDir : this.workingDir + "/";
|
|
22
|
+
if (p.startsWith("/")) {
|
|
23
|
+
const normalized = path.normalize(p);
|
|
24
|
+
if (normalized !== this.workingDir && !normalized.startsWith(normalizedBase)) {
|
|
25
|
+
throw new Error(`Absolute path "${p}" is outside working directory "${this.workingDir}"`);
|
|
26
|
+
}
|
|
27
|
+
return normalized;
|
|
28
|
+
}
|
|
29
|
+
const resolved = path.resolve(this.workingDir, p);
|
|
30
|
+
if (resolved !== this.workingDir && !resolved.startsWith(normalizedBase)) {
|
|
31
|
+
throw new Error(`Path "${p}" escapes working directory "${this.workingDir}"`);
|
|
32
|
+
}
|
|
33
|
+
return resolved;
|
|
34
|
+
}
|
|
35
|
+
async readFile(filePath, _opts) {
|
|
36
|
+
return this.vm.fs.readTextFile(this.resolvePath(filePath));
|
|
37
|
+
}
|
|
38
|
+
async readFileBytes(filePath, maxBytes) {
|
|
39
|
+
const resolved = this.resolvePath(filePath);
|
|
40
|
+
const cmd = maxBytes !== void 0 ? `head -c ${maxBytes} ${shellEscape(resolved)} | base64` : `base64 ${shellEscape(resolved)}`;
|
|
41
|
+
const { statusCode, stdout, stderr } = await this.vm.exec(cmd);
|
|
42
|
+
if (statusCode !== 0) {
|
|
43
|
+
throw new Error(`FreestyleFs readFileBytes failed: ${stderr?.trim() || `exit code ${statusCode}`}`);
|
|
44
|
+
}
|
|
45
|
+
return Buffer.from((stdout ?? "").trim(), "base64");
|
|
46
|
+
}
|
|
47
|
+
async writeFile(filePath, content) {
|
|
48
|
+
await this.vm.fs.writeTextFile(this.resolvePath(filePath), content);
|
|
49
|
+
}
|
|
50
|
+
async appendFile(filePath, content) {
|
|
51
|
+
const resolved = this.resolvePath(filePath);
|
|
52
|
+
const encoded = Buffer.from(content, "utf-8").toString("base64");
|
|
53
|
+
const { statusCode, stderr } = await this.vm.exec(
|
|
54
|
+
`echo ${shellEscape(encoded)} | base64 -d >> ${shellEscape(resolved)}`
|
|
55
|
+
);
|
|
56
|
+
if (statusCode !== 0) {
|
|
57
|
+
throw new Error(`FreestyleFs appendFile failed: ${stderr?.trim() || `exit code ${statusCode}`}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async deleteFile(filePath, opts) {
|
|
61
|
+
const resolved = this.resolvePath(filePath);
|
|
62
|
+
const flag = opts?.recursive ? "-rf" : "-f";
|
|
63
|
+
await this.vm.exec(`rm ${flag} ${shellEscape(resolved)}`);
|
|
64
|
+
}
|
|
65
|
+
async mkdir(filePath, opts) {
|
|
66
|
+
const resolved = this.resolvePath(filePath);
|
|
67
|
+
const flag = opts?.recursive ? "-p " : "";
|
|
68
|
+
await this.vm.exec(`mkdir ${flag}${shellEscape(resolved)}`);
|
|
69
|
+
}
|
|
70
|
+
async readdir(dirPath, _opts) {
|
|
71
|
+
const resolved = this.resolvePath(dirPath);
|
|
72
|
+
const items = await this.vm.fs.readDir(resolved);
|
|
73
|
+
return items.map((entry) => ({
|
|
74
|
+
name: entry.name,
|
|
75
|
+
path: resolved === "/" ? `/${entry.name}` : `${resolved}/${entry.name}`,
|
|
76
|
+
isDirectory: entry.kind === "dir" || entry.kind === "directory",
|
|
77
|
+
isFile: entry.kind === "file"
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
async exists(filePath) {
|
|
81
|
+
const resolved = this.resolvePath(filePath);
|
|
82
|
+
const { statusCode } = await this.vm.exec(`test -e ${shellEscape(resolved)}`);
|
|
83
|
+
return statusCode === 0;
|
|
84
|
+
}
|
|
85
|
+
async stat(filePath) {
|
|
86
|
+
const resolved = this.resolvePath(filePath);
|
|
87
|
+
const { statusCode, stdout, stderr } = await this.vm.exec(
|
|
88
|
+
`stat -c '%s %F %W %Y' ${shellEscape(resolved)}`
|
|
89
|
+
);
|
|
90
|
+
if (statusCode !== 0) {
|
|
91
|
+
throw new Error(`FreestyleFs stat failed: ${stderr?.trim() || `exit code ${statusCode}`}`);
|
|
92
|
+
}
|
|
93
|
+
const parts = (stdout ?? "").trim().split(" ");
|
|
94
|
+
const size = parseInt(parts[0], 10);
|
|
95
|
+
const fileType = parts[1];
|
|
96
|
+
const createdEpoch = parseInt(parts[2], 10);
|
|
97
|
+
const modifiedEpoch = parseInt(parts[3], 10);
|
|
98
|
+
return {
|
|
99
|
+
size,
|
|
100
|
+
isDirectory: fileType === "directory",
|
|
101
|
+
isFile: fileType.startsWith("regular"),
|
|
102
|
+
createdAt: createdEpoch > 0 ? new Date(createdEpoch * 1e3) : void 0,
|
|
103
|
+
modifiedAt: modifiedEpoch > 0 ? new Date(modifiedEpoch * 1e3) : void 0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function shellEscape(s) {
|
|
108
|
+
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/virtual/freestyle-computer.ts
|
|
112
|
+
var FreestyleComputer = class {
|
|
113
|
+
vm;
|
|
114
|
+
defaultCwd;
|
|
115
|
+
defaultTimeout;
|
|
116
|
+
constructor(opts) {
|
|
117
|
+
this.vm = opts.vm;
|
|
118
|
+
this.defaultCwd = opts.defaultCwd;
|
|
119
|
+
this.defaultTimeout = opts.defaultTimeout ?? 3e4;
|
|
120
|
+
}
|
|
121
|
+
async executeCommand(command, opts) {
|
|
122
|
+
const result = await this.vm.exec(command, {
|
|
123
|
+
cwd: opts?.cwd ?? this.defaultCwd,
|
|
124
|
+
timeout: opts?.timeout ?? this.defaultTimeout
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
exitCode: result.statusCode ?? 1,
|
|
128
|
+
stdout: result.stdout ?? "",
|
|
129
|
+
stderr: result.stderr ?? ""
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/virtual/freestyle-sandbox.ts
|
|
135
|
+
function FreestyleSandbox(opts) {
|
|
136
|
+
if (opts.vm) {
|
|
137
|
+
const v = opts.vm;
|
|
138
|
+
return {
|
|
139
|
+
fs: new FreestyleFs({ vm: v, workingDir: opts.cwd }),
|
|
140
|
+
computer: new FreestyleComputer({
|
|
141
|
+
vm: v,
|
|
142
|
+
defaultCwd: opts.cwd,
|
|
143
|
+
defaultTimeout: opts.defaultTimeout
|
|
144
|
+
}),
|
|
145
|
+
sandboxId: () => v.vmId
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const fsProxy = createFsProxy();
|
|
149
|
+
const computerProxy = createComputerProxy();
|
|
150
|
+
let resolvedId;
|
|
151
|
+
let vmRef = null;
|
|
152
|
+
let autoCreated = false;
|
|
153
|
+
let initPromise = null;
|
|
154
|
+
async function doInit(reconnectId) {
|
|
155
|
+
const mod = await import("freestyle-sandboxes");
|
|
156
|
+
const freestyle = mod.freestyle ?? mod.default?.freestyle;
|
|
157
|
+
if (!freestyle?.vms) {
|
|
158
|
+
throw new Error("Could not resolve freestyle client from 'freestyle-sandboxes' package");
|
|
159
|
+
}
|
|
160
|
+
let vm;
|
|
161
|
+
if (reconnectId) {
|
|
162
|
+
try {
|
|
163
|
+
const result = await freestyle.vms.get({ vmId: reconnectId });
|
|
164
|
+
vm = result.vm;
|
|
165
|
+
resolvedId = reconnectId;
|
|
166
|
+
} catch {
|
|
167
|
+
const result = await freestyle.vms.create({
|
|
168
|
+
...opts.spec ? { spec: opts.spec } : {},
|
|
169
|
+
snapshotId: opts.snapshotId,
|
|
170
|
+
workdir: opts.cwd,
|
|
171
|
+
idleTimeoutSeconds: opts.idleTimeoutSeconds ?? 600,
|
|
172
|
+
additionalFiles: opts.additionalFiles,
|
|
173
|
+
gitRepos: opts.gitRepos
|
|
174
|
+
});
|
|
175
|
+
vm = result.vm;
|
|
176
|
+
resolvedId = result.vmId ?? result.id;
|
|
177
|
+
autoCreated = true;
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
const result = await freestyle.vms.create({
|
|
181
|
+
...opts.spec ? { spec: opts.spec } : {},
|
|
182
|
+
snapshotId: opts.snapshotId,
|
|
183
|
+
workdir: opts.cwd,
|
|
184
|
+
idleTimeoutSeconds: opts.idleTimeoutSeconds ?? 600,
|
|
185
|
+
additionalFiles: opts.additionalFiles,
|
|
186
|
+
gitRepos: opts.gitRepos
|
|
187
|
+
});
|
|
188
|
+
vm = result.vm;
|
|
189
|
+
resolvedId = result.vmId ?? result.id;
|
|
190
|
+
autoCreated = true;
|
|
191
|
+
}
|
|
192
|
+
vmRef = vm;
|
|
193
|
+
fsProxy.setTarget(new FreestyleFs({ vm, workingDir: opts.cwd }));
|
|
194
|
+
computerProxy.setTarget(new FreestyleComputer({
|
|
195
|
+
vm,
|
|
196
|
+
defaultCwd: opts.cwd,
|
|
197
|
+
defaultTimeout: opts.defaultTimeout
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
fs: fsProxy,
|
|
202
|
+
computer: computerProxy,
|
|
203
|
+
sandboxId: () => resolvedId,
|
|
204
|
+
init(sandboxId) {
|
|
205
|
+
if (!initPromise) {
|
|
206
|
+
initPromise = doInit(sandboxId).catch((err) => {
|
|
207
|
+
initPromise = null;
|
|
208
|
+
throw err;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return initPromise;
|
|
212
|
+
},
|
|
213
|
+
async dispose() {
|
|
214
|
+
if (initPromise) {
|
|
215
|
+
await initPromise.catch(() => {
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (!autoCreated || !vmRef || !resolvedId) return;
|
|
219
|
+
try {
|
|
220
|
+
const strategy = opts.disposeStrategy ?? "suspend";
|
|
221
|
+
if (strategy === "suspend") {
|
|
222
|
+
await vmRef.suspend();
|
|
223
|
+
} else {
|
|
224
|
+
const mod = await import("freestyle-sandboxes");
|
|
225
|
+
const freestyle = mod.freestyle ?? mod.default?.freestyle;
|
|
226
|
+
if (freestyle?.vms) {
|
|
227
|
+
await freestyle.vms.delete({ vmId: resolvedId });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} catch {
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export {
|
|
236
|
+
FreestyleComputer,
|
|
237
|
+
FreestyleFs,
|
|
238
|
+
FreestyleSandbox
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=freestyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/virtual/freestyle-fs.ts","../src/virtual/freestyle-computer.ts","../src/virtual/freestyle-sandbox.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type { VirtualFs, FileEntry, FileStat, ReadOptions } from \"./fs.js\";\nimport type { FreestyleVmInstance } from \"./freestyle-computer.js\";\n\nexport interface FreestyleFsOptions {\n /** A Freestyle VM instance. */\n vm: FreestyleVmInstance;\n /** Working directory for relative path resolution. */\n workingDir?: string;\n}\n\n/**\n * VirtualFs backed by a Freestyle VM.\n *\n * Uses `vm.fs.*` for operations with native SDK support (readTextFile,\n * writeTextFile, readDir) and falls back to `vm.exec()` for the rest\n * (stat, exists, mkdir, deleteFile, appendFile, readFileBytes).\n *\n * Requires `freestyle-sandboxes` as an optional peer dependency.\n * The user is responsible for VM lifecycle when using explicit mode.\n */\nexport class FreestyleFs implements VirtualFs {\n private vm: FreestyleVmInstance;\n private workingDir: string | undefined;\n\n constructor(opts: FreestyleFsOptions) {\n this.vm = opts.vm;\n this.workingDir = opts.workingDir;\n }\n\n private resolvePath(p: string): string {\n if (p.includes(\"\\0\")) {\n throw new Error(\"Path contains null bytes\");\n }\n if (!this.workingDir) return p;\n const normalizedBase = this.workingDir.endsWith(\"/\") ? this.workingDir : this.workingDir + \"/\";\n if (p.startsWith(\"/\")) {\n const normalized = path.normalize(p);\n if (normalized !== this.workingDir && !normalized.startsWith(normalizedBase)) {\n throw new Error(`Absolute path \"${p}\" is outside working directory \"${this.workingDir}\"`);\n }\n return normalized;\n }\n const resolved = path.resolve(this.workingDir, p);\n if (resolved !== this.workingDir && !resolved.startsWith(normalizedBase)) {\n throw new Error(`Path \"${p}\" escapes working directory \"${this.workingDir}\"`);\n }\n return resolved;\n }\n\n async readFile(filePath: string, _opts?: ReadOptions): Promise<string> {\n return this.vm.fs.readTextFile(this.resolvePath(filePath));\n }\n\n async readFileBytes(filePath: string, maxBytes?: number): Promise<Buffer> {\n const resolved = this.resolvePath(filePath);\n const cmd = maxBytes !== undefined\n ? `head -c ${maxBytes} ${shellEscape(resolved)} | base64`\n : `base64 ${shellEscape(resolved)}`;\n const { statusCode, stdout, stderr } = await this.vm.exec(cmd);\n if (statusCode !== 0) {\n throw new Error(`FreestyleFs readFileBytes failed: ${stderr?.trim() || `exit code ${statusCode}`}`);\n }\n return Buffer.from((stdout ?? \"\").trim(), \"base64\");\n }\n\n async writeFile(filePath: string, content: string): Promise<void> {\n await this.vm.fs.writeTextFile(this.resolvePath(filePath), content);\n }\n\n async appendFile(filePath: string, content: string): Promise<void> {\n const resolved = this.resolvePath(filePath);\n const encoded = Buffer.from(content, \"utf-8\").toString(\"base64\");\n const { statusCode, stderr } = await this.vm.exec(\n `echo ${shellEscape(encoded)} | base64 -d >> ${shellEscape(resolved)}`,\n );\n if (statusCode !== 0) {\n throw new Error(`FreestyleFs appendFile failed: ${stderr?.trim() || `exit code ${statusCode}`}`);\n }\n }\n\n async deleteFile(\n filePath: string,\n opts?: { recursive?: boolean },\n ): Promise<void> {\n const resolved = this.resolvePath(filePath);\n const flag = opts?.recursive ? \"-rf\" : \"-f\";\n await this.vm.exec(`rm ${flag} ${shellEscape(resolved)}`);\n }\n\n async mkdir(filePath: string, opts?: { recursive?: boolean }): Promise<void> {\n const resolved = this.resolvePath(filePath);\n const flag = opts?.recursive ? \"-p \" : \"\";\n await this.vm.exec(`mkdir ${flag}${shellEscape(resolved)}`);\n }\n\n async readdir(\n dirPath: string,\n _opts?: { recursive?: boolean },\n ): Promise<FileEntry[]> {\n const resolved = this.resolvePath(dirPath);\n const items = await this.vm.fs.readDir(resolved);\n return items.map((entry) => ({\n name: entry.name,\n path: resolved === \"/\" ? `/${entry.name}` : `${resolved}/${entry.name}`,\n isDirectory: entry.kind === \"dir\" || entry.kind === \"directory\",\n isFile: entry.kind === \"file\",\n }));\n }\n\n async exists(filePath: string): Promise<boolean> {\n const resolved = this.resolvePath(filePath);\n const { statusCode } = await this.vm.exec(`test -e ${shellEscape(resolved)}`);\n return statusCode === 0;\n }\n\n async stat(filePath: string): Promise<FileStat> {\n const resolved = this.resolvePath(filePath);\n const { statusCode, stdout, stderr } = await this.vm.exec(\n `stat -c '%s\\t%F\\t%W\\t%Y' ${shellEscape(resolved)}`,\n );\n if (statusCode !== 0) {\n throw new Error(`FreestyleFs stat failed: ${stderr?.trim() || `exit code ${statusCode}`}`);\n }\n\n const parts = (stdout ?? \"\").trim().split(\"\\t\");\n const size = parseInt(parts[0], 10);\n const fileType = parts[1];\n const createdEpoch = parseInt(parts[2], 10);\n const modifiedEpoch = parseInt(parts[3], 10);\n\n return {\n size,\n isDirectory: fileType === \"directory\",\n isFile: fileType.startsWith(\"regular\"),\n createdAt: createdEpoch > 0 ? new Date(createdEpoch * 1000) : undefined,\n modifiedAt: modifiedEpoch > 0 ? new Date(modifiedEpoch * 1000) : undefined,\n };\n }\n}\n\nfunction shellEscape(s: string): string {\n return `'${s.replace(/'/g, \"'\\\\''\")}'`;\n}\n","import type { VirtualComputer, ExecOptions, CommandResult } from \"./computer.js\";\n\n/**\n * Minimal subset of the Freestyle VM interface used by FreestyleComputer and\n * FreestyleFs. Avoids a hard import of `freestyle-sandboxes` at the module\n * level — the real SDK is only loaded dynamically during `FreestyleSandbox`\n * auto-creation.\n */\nexport interface FreestyleVmInstance {\n exec(\n command: string,\n opts?: { cwd?: string; timeout?: number },\n ): Promise<{\n stdout: string | null;\n stderr: string | null;\n statusCode: number | null;\n }>;\n fs: {\n readTextFile(path: string): Promise<string>;\n writeTextFile(path: string, content: string): Promise<void>;\n readDir(path: string): Promise<Array<{ name: string; kind: string }>>;\n };\n suspend(): Promise<unknown>;\n start(): Promise<unknown>;\n}\n\nexport interface FreestyleComputerOptions {\n /** A Freestyle VM instance. */\n vm: FreestyleVmInstance;\n /** Default working directory for commands. */\n defaultCwd?: string;\n /** Default timeout in ms for commands (default: 30000). */\n defaultTimeout?: number;\n}\n\n/**\n * VirtualComputer backed by command execution in a Freestyle VM.\n *\n * Requires `freestyle-sandboxes` as an optional peer dependency.\n * The user is responsible for VM lifecycle when using explicit mode.\n */\nexport class FreestyleComputer implements VirtualComputer {\n private vm: FreestyleVmInstance;\n private defaultCwd: string | undefined;\n private defaultTimeout: number;\n\n constructor(opts: FreestyleComputerOptions) {\n this.vm = opts.vm;\n this.defaultCwd = opts.defaultCwd;\n this.defaultTimeout = opts.defaultTimeout ?? 30_000;\n }\n\n async executeCommand(\n command: string,\n opts?: ExecOptions,\n ): Promise<CommandResult> {\n const result = await this.vm.exec(command, {\n cwd: opts?.cwd ?? this.defaultCwd,\n timeout: opts?.timeout ?? this.defaultTimeout,\n });\n\n return {\n exitCode: result.statusCode ?? 1,\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n };\n }\n}\n","import type { Sandbox } from \"./sandbox.js\";\nimport { FreestyleFs } from \"./freestyle-fs.js\";\nimport { FreestyleComputer, type FreestyleVmInstance } from \"./freestyle-computer.js\";\nimport { createFsProxy, createComputerProxy } from \"./proxy.js\";\n\nexport interface FreestyleSandboxOptions {\n /**\n * A pre-existing Freestyle VM instance. When provided the sandbox\n * attaches to this VM directly — no auto-creation occurs and\n * `dispose()` will **not** suspend or delete it.\n *\n * When omitted, a new VM is created on the first `init()` call via\n * a dynamic import of the `freestyle-sandboxes` package.\n */\n vm?: FreestyleVmInstance;\n /**\n * Freestyle API key. Falls back to the `FREESTYLE_API_KEY` environment\n * variable when omitted. Only used during auto-creation.\n */\n apiKey?: string;\n /** Snapshot ID to create the VM from. Only used during auto-creation. */\n snapshotId?: string;\n /**\n * A `VmSpec` instance or configuration object passed through to\n * `freestyle.vms.create()`. Only used during auto-creation.\n */\n spec?: unknown;\n /**\n * Idle timeout in seconds for the auto-created VM (default: 600).\n * The VM auto-suspends after this many seconds of network inactivity.\n */\n idleTimeoutSeconds?: number;\n /** Working directory inside the VM. */\n cwd?: string;\n /** Default timeout (ms) for shell commands. */\n defaultTimeout?: number;\n /** Files to provision at creation time. */\n additionalFiles?: Record<string, { content: string; encoding?: string }>;\n /** Git repos to clone at creation time. */\n gitRepos?: Array<{ repo: string; path: string; rev?: string }>;\n /**\n * What to do with auto-created VMs on `dispose()`:\n * - `\"suspend\"` (default) — suspends the VM, preserving full memory\n * state for near-instant resume on reconnect.\n * - `\"delete\"` — permanently deletes the VM and frees all resources.\n */\n disposeStrategy?: \"suspend\" | \"delete\";\n}\n\n/**\n * Create a `Sandbox` backed by a Freestyle VM.\n * Requires `freestyle-sandboxes` as an optional peer dependency.\n *\n * **Auto-creation:** When `vm` is omitted a new Freestyle VM is\n * provisioned lazily on the first `init()` call. The VM ID is available\n * through `sandboxId()` for session persistence. Pass the stored ID back\n * through `init(storedId)` to reconnect (this also wakes suspended VMs).\n *\n * By default, auto-created VMs are **suspended** on `dispose()` rather\n * than deleted. This preserves full memory state and allows near-instant\n * resume. Set `disposeStrategy: \"delete\"` for full cleanup.\n *\n * **Explicit instance:** When `vm` is provided, `init()` binds it\n * immediately. `dispose()` is a no-op — the caller owns the VM's\n * lifecycle.\n *\n * @example\n * ```ts\n * // Auto-create — VM provisioned on first init()\n * const sandbox = FreestyleSandbox({ cwd: \"/workspace\" });\n *\n * // Auto-create from a snapshot\n * const sandbox = FreestyleSandbox({\n * snapshotId: \"abc123\",\n * cwd: \"/workspace\",\n * });\n *\n * // Explicit — attach to pre-existing VM\n * const sandbox = FreestyleSandbox({ vm: existingVm });\n * ```\n */\nexport function FreestyleSandbox(opts: FreestyleSandboxOptions): Sandbox {\n if (opts.vm) {\n const v = opts.vm;\n return {\n fs: new FreestyleFs({ vm: v, workingDir: opts.cwd }),\n computer: new FreestyleComputer({\n vm: v,\n defaultCwd: opts.cwd,\n defaultTimeout: opts.defaultTimeout,\n }),\n sandboxId: () => (v as any).vmId as string | undefined,\n };\n }\n\n const fsProxy = createFsProxy();\n const computerProxy = createComputerProxy();\n let resolvedId: string | undefined;\n let vmRef: FreestyleVmInstance | null = null;\n let autoCreated = false;\n let initPromise: Promise<void> | null = null;\n\n async function doInit(reconnectId?: string): Promise<void> {\n const mod = await import(\"freestyle-sandboxes\");\n const freestyle = (mod as any).freestyle ?? (mod as any).default?.freestyle;\n if (!freestyle?.vms) {\n throw new Error(\"Could not resolve freestyle client from 'freestyle-sandboxes' package\");\n }\n\n let vm: FreestyleVmInstance;\n if (reconnectId) {\n try {\n const result = await freestyle.vms.get({ vmId: reconnectId });\n vm = result.vm;\n resolvedId = reconnectId;\n } catch {\n const result = await freestyle.vms.create({\n ...(opts.spec ? { spec: opts.spec } : {}),\n snapshotId: opts.snapshotId,\n workdir: opts.cwd,\n idleTimeoutSeconds: opts.idleTimeoutSeconds ?? 600,\n additionalFiles: opts.additionalFiles,\n gitRepos: opts.gitRepos,\n });\n vm = result.vm;\n resolvedId = result.vmId ?? result.id;\n autoCreated = true;\n }\n } else {\n const result = await freestyle.vms.create({\n ...(opts.spec ? { spec: opts.spec } : {}),\n snapshotId: opts.snapshotId,\n workdir: opts.cwd,\n idleTimeoutSeconds: opts.idleTimeoutSeconds ?? 600,\n additionalFiles: opts.additionalFiles,\n gitRepos: opts.gitRepos,\n });\n vm = result.vm;\n resolvedId = result.vmId ?? result.id;\n autoCreated = true;\n }\n\n vmRef = vm;\n fsProxy.setTarget(new FreestyleFs({ vm, workingDir: opts.cwd }));\n computerProxy.setTarget(new FreestyleComputer({\n vm,\n defaultCwd: opts.cwd,\n defaultTimeout: opts.defaultTimeout,\n }));\n }\n\n return {\n fs: fsProxy,\n computer: computerProxy,\n sandboxId: () => resolvedId,\n\n init(sandboxId?: string): Promise<void> {\n if (!initPromise) {\n initPromise = doInit(sandboxId).catch((err) => {\n initPromise = null;\n throw err;\n });\n }\n return initPromise;\n },\n\n async dispose(): Promise<void> {\n if (initPromise) {\n await initPromise.catch(() => {});\n }\n if (!autoCreated || !vmRef || !resolvedId) return;\n try {\n const strategy = opts.disposeStrategy ?? \"suspend\";\n if (strategy === \"suspend\") {\n await vmRef.suspend();\n } else {\n const mod = await import(\"freestyle-sandboxes\");\n const freestyle = (mod as any).freestyle ?? (mod as any).default?.freestyle;\n if (freestyle?.vms) {\n await freestyle.vms.delete({ vmId: resolvedId });\n }\n }\n } catch {\n // Best-effort cleanup — network errors during dispose are non-fatal\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAAA,YAAY,UAAU;AA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M;AAAA,QAAC,CAAC;AAAA,MAClC;AACA,UAAI,CAAC,eAAe,CAAC,SAAS,CAAC,WAAY;AAC3C,UAAI;AACF,cAAM,WAAW,KAAK,mBAAmB;AACzC,YAAI,aAAa,WAAW;AAC1B,gBAAM,MAAM,QAAQ;AAAA,QACtB,OAAO;AACL,gBAAM,MAAM,MAAM,OAAO,qBAAqB;AAC9C,gBAAM,YAAa,IAAY,aAAc,IAAY,SAAS;AAClE,cAAI,WAAW,KAAK;AAClB,kBAAM,UAAU,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAAA,UACjD;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { A as Agent, S as SkillDefinition, T as ThreadConfig, a as SessionStorage, C as ContextFile, P as ProjectContextConfig, b as ContextScope, R as RetryConfig, c as RetryContext, d as RetryEngineOptions, e as Span, f as SpanAttributeValue, g as SpanStatusCode, h as Tracer, i as SpanOptions, j as StoredCostState } from './agent-C3eDRsxs.js';
|
|
2
|
+
export { k as AgentOptions, l as AutoCompactConfig, m as AutoCompactTrackingState, B as BudgetState, n as CLEARED_PLACEHOLDER, o as COMPACTABLE_TOOLS, p as ContentReplacementState, q as CostTracker, D as DEFAULT_MODELS, r as DEFAULT_RETRY_CONFIG, s as DiagnoseCheckResult, t as DiagnoseResult, M as MicrocompactConfig, u as MicrocompactResult, v as ProviderName, w as ReactiveCompactConfig, x as ReactiveCompactResult, y as ResolveProviderOptions, z as RetryEvent, E as RunCallbacks, F as RunResult, G as SUPPORTED_PROVIDERS, H as SnipConfig, I as SnipResult, J as Thread, K as ThreadOptions, L as ToolResultBudgetConfig, N as ToolResultBudgetResult, O as ToolResultReplacementRecord, Q as ToolResultSpillResult, U as ToolResultStorageConfig, V as TracingConfig, W as WebSearchConfig, X as WebSearchResult, Y as applyPersistedReplacements, Z as applySnipRemovals, _ as canAutoCompact, $ as createAutoCompactConfig, a0 as createAutoCompactTracking, a1 as createBudgetState, a2 as createContentReplacementState, a3 as createWebSearchTool, a4 as detectProvider, a5 as enforceToolResultBudget, a6 as enforceToolResultStorageBudget, a7 as microcompactMessages, a8 as persistToolResult, a9 as projectSnippedView, aa as reconstructContentReplacementState, ab as recordAutoCompactFailure, ac as recordAutoCompactSuccess, ad as resolveProvider, ae as shouldAutoCompact, af as snipMessagesByUuids, ag as tryReactiveCompact, ah as webSearchToolPlaceholder } from './agent-C3eDRsxs.js';
|
|
3
3
|
import { A as AIProvider, T as ToolDefinition, o as ToolCallContent, S as StreamEvent, e as ContentPart, b as ChatMessage, k as ChatCompletionUsage, M as ModelPricing, h as UsageRecord, a as ChatStreamChunk, p as MemoryProvider, q as MemoryEntry, l as ThinkingConfig, r as AssistantMessage, s as ToolResultMessage, d as FileCheckpointSnapshot, t as ToolResultOverflowEntry, f as ContentReplacementRecord, J as JsonSchemaOutputFormat } from './types-LrU4LRmX.js';
|
|
4
4
|
export { C as ChatParams, u as ChatStreamChoice, v as ChatStreamDelta, w as ChatStreamError, c as CheckpointConfig, x as CompactBoundaryEntry, y as ContentReplacementEntry, i as CostSummary, z as CustomTitleEntry, D as DiffStats, E as Entry, B as FileCheckpointBackup, G as FileCheckpointEntry, F as FileCheckpointState, I as ImageContent, H as ImageUrlContent, K as JsonObjectOutputFormat, m as MemoryConfig, L as MemoryType, N as MessageEntry, P as MetadataEntry, j as ModelUsageSummary, O as OutputFormat, R as RunOptions, Q as SerializedMessage, g as SessionInfo, V as SnipBoundaryEntry, W as SummaryEntry, X as SystemMessage, Y as TextContent, Z as ToolDefParameterProperty, n as ToolResult, _ as UserMessage, $ as createCheckpointState } from './types-LrU4LRmX.js';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
5
|
+
import { S as Sandbox } from './sandbox-9qeMTNrD.js';
|
|
6
|
+
export { L as LocalSandbox, a as LocalSandboxOptions, b as SandboxConfig, c as SandboxedLocalComputer, d as SandboxedLocalComputerOptions, U as UnsandboxedLocal, e as UnsandboxedLocalOptions } from './sandbox-9qeMTNrD.js';
|
|
7
|
+
import { H as HookDefinition, T as Tool, h as ToolContext, g as ToolResult, l as HookEvent, m as HookInput, P as PostToolUseFailureHookInput, n as PostToolUseFailureHookOutput, o as PostToolUseHookInput, p as PostToolUseHookOutput, q as PreToolUseHookInput, r as PreToolUseHookOutput } from './types-BA87bHPV.js';
|
|
8
|
+
export { F as FileCheckpointManager, s as FileState, t as FileStateCache, k as FileStateCacheConfig, u as FileWriteHookInput, v as HookOutput, J as JsonSchemaType, b as LspDiagnostic, c as LspLocation, d as LspOperation, L as LspServerConfig, a as LspServerState, f as LspSymbol, M as MemoryUpdateHookInput, w as ModelSwitchHookInput, N as NotificationHookInput, x as PermissionDeniedHookInput, y as PermissionRequestHookInput, R as RetryAttemptHookInput, z as SafeParseResult, A as SessionEndHookInput, B as SessionStartHookInput, S as SubagentConfig, i as SubagentRun, C as SubagentStartHookInput, E as SubagentStopHookInput, G as Task, I as TaskCreateInput, K as TaskStatus, j as TaskStore, O as TaskUpdateInput, Q as ToolParameters, Z as ZodLikeSchema, U as formatZodValidationError, V as registerZodToJsonSchema, W as zodToJsonSchema } from './types-BA87bHPV.js';
|
|
7
9
|
import { M as McpServerConfig } from './types-2kTLUCnD.js';
|
|
8
10
|
export { b as McpConfig, c as McpConnection, d as McpHttpServerConfig, e as McpOAuthConfig, f as McpSseServerConfig, g as McpStdioServerConfig, h as McpToolInfo, i as McpWebSocketServerConfig, a as OAuthProviderOptions, O as OAuthTokenData, T as TokenStorage } from './types-2kTLUCnD.js';
|
|
9
11
|
export { OpenAIProviderOptions } from './providers/openai.js';
|
|
@@ -13,9 +15,10 @@ export { OpenRouterProviderOptions } from './providers/openrouter.js';
|
|
|
13
15
|
export { BedrockAnthropicProviderOptions } from './providers/bedrock.js';
|
|
14
16
|
export { VertexAnthropicProviderOptions } from './providers/vertex.js';
|
|
15
17
|
export { OllamaProviderOptions } from './providers/ollama.js';
|
|
18
|
+
import { a as VirtualFs, R as ReadOptions, F as FileEntry, b as FileStat, V as VirtualComputer, E as ExecOptions, C as CommandResult } from './computer-BPdxSo6X.js';
|
|
16
19
|
import { c as PermissionHandler, e as PermissionContext, f as PermissionBehavior, g as PermissionRule, A as AutoModeConfig, h as PermissionDecision, i as PermissionUpdate } from './types-CD0rUKKT.js';
|
|
17
20
|
export { D as DenialTrackingConfig, j as PermissionAllowResult, k as PermissionAskResult, d as PermissionConfig, l as PermissionDenyResult, a as PermissionMode, m as PermissionPassthroughResult, n as PermissionRequest, P as PermissionResponse, b as PermissionResult, o as PermissionRuleSource, R as RULE_SOURCE_PRECEDENCE } from './types-CD0rUKKT.js';
|
|
18
|
-
export { a as McpClientManagerOptions, b as McpServerOptions, c as buildMcpToolName, g as getMcpPrefix, n as normalizeNameForMCP, p as parseMcpToolName } from './server-
|
|
21
|
+
export { a as McpClientManagerOptions, b as McpServerOptions, c as buildMcpToolName, g as getMcpPrefix, n as normalizeNameForMCP, p as parseMcpToolName } from './server-Cu9gv1dk.js';
|
|
19
22
|
export { C as CacheControlConfig, a as CacheScope, g as getMessageCacheBreakpointIndex, s as sortToolDefinitionsForCache } from './cache-DsRqxx6v.js';
|
|
20
23
|
export { JsonRpcErrorObject, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse } from './jsonrpc/index.js';
|
|
21
24
|
export { b as AcpCapabilities, c as AcpInitializeParams, d as AcpInitializeResult, A as AcpTransport } from './types-QwfylltH.js';
|
|
@@ -108,201 +111,6 @@ declare class LocalComputer implements VirtualComputer {
|
|
|
108
111
|
executeCommand(command: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
interface SpritesFsOptions {
|
|
112
|
-
/** sprites.dev API token */
|
|
113
|
-
token: string;
|
|
114
|
-
/** Name of the sprite container */
|
|
115
|
-
spriteName: string;
|
|
116
|
-
/** Base URL for sprites API (default: https://api.sprites.dev) */
|
|
117
|
-
baseURL?: string;
|
|
118
|
-
/** Working directory inside the sprite (default: /home/sprite) */
|
|
119
|
-
workingDir?: string;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Sandboxed VirtualFs backed by a remote sprites.dev container. All file
|
|
123
|
-
* operations are executed over the sprites.dev HTTP API — the agent has no
|
|
124
|
-
* access to the host filesystem. This is the recommended VirtualFs for
|
|
125
|
-
* production deployments and untrusted agents. See `LocalFs` for an
|
|
126
|
-
* unsandboxed local alternative.
|
|
127
|
-
*/
|
|
128
|
-
declare class SpritesFs implements VirtualFs {
|
|
129
|
-
private token;
|
|
130
|
-
private spriteName;
|
|
131
|
-
private baseURL;
|
|
132
|
-
private workingDir;
|
|
133
|
-
constructor(opts: SpritesFsOptions);
|
|
134
|
-
private fsUrl;
|
|
135
|
-
private resolvePath;
|
|
136
|
-
private headers;
|
|
137
|
-
readFile(filePath: string, _opts?: ReadOptions): Promise<string>;
|
|
138
|
-
readFileBytes(filePath: string, maxBytes?: number): Promise<Buffer>;
|
|
139
|
-
writeFile(filePath: string, content: string): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* @warning Not atomic. Concurrent appends may lose data due to
|
|
142
|
-
* read-then-write TOCTOU. The Sprites API does not expose an append primitive.
|
|
143
|
-
*/
|
|
144
|
-
appendFile(filePath: string, content: string): Promise<void>;
|
|
145
|
-
deleteFile(filePath: string, opts?: {
|
|
146
|
-
recursive?: boolean;
|
|
147
|
-
}): Promise<void>;
|
|
148
|
-
mkdir(dirPath: string, opts?: {
|
|
149
|
-
recursive?: boolean;
|
|
150
|
-
}): Promise<void>;
|
|
151
|
-
readdir(dirPath: string, _opts?: {
|
|
152
|
-
recursive?: boolean;
|
|
153
|
-
}): Promise<FileEntry[]>;
|
|
154
|
-
exists(filePath: string): Promise<boolean>;
|
|
155
|
-
stat(filePath: string): Promise<FileStat>;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
interface SpritesComputerOptions {
|
|
159
|
-
/** sprites.dev API token */
|
|
160
|
-
token: string;
|
|
161
|
-
/** Name of the sprite container */
|
|
162
|
-
spriteName: string;
|
|
163
|
-
/** Base URL for sprites API (default: https://api.sprites.dev) */
|
|
164
|
-
baseURL?: string;
|
|
165
|
-
/** Working directory inside the sprite (default: /home/sprite) */
|
|
166
|
-
workingDir?: string;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Sandboxed VirtualComputer that executes commands inside a remote
|
|
170
|
-
* sprites.dev container. All shell execution is fully isolated — the agent
|
|
171
|
-
* has no access to the host machine's processes, filesystem, or network.
|
|
172
|
-
*
|
|
173
|
-
* This is the recommended VirtualComputer for production deployments and
|
|
174
|
-
* untrusted agents. See `LocalComputer` for an unsandboxed local alternative.
|
|
175
|
-
*
|
|
176
|
-
* Uses the non-interactive exec REST endpoint (POST command, receive
|
|
177
|
-
* stdout/stderr/exit_code). The WebSocket exec endpoint can be used for
|
|
178
|
-
* streaming/TTY use cases, but REST is sufficient for tool calls.
|
|
179
|
-
*/
|
|
180
|
-
declare class SpritesComputer implements VirtualComputer {
|
|
181
|
-
private token;
|
|
182
|
-
private spriteName;
|
|
183
|
-
private baseURL;
|
|
184
|
-
private workingDir;
|
|
185
|
-
constructor(opts: SpritesComputerOptions);
|
|
186
|
-
private headers;
|
|
187
|
-
executeCommand(command: string, opts?: ExecOptions): Promise<CommandResult>;
|
|
188
|
-
private shellEscape;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
interface DockerFsOptions {
|
|
192
|
-
/** A dockerode Container instance for the target container. */
|
|
193
|
-
container: DockerContainer;
|
|
194
|
-
/** Working directory for relative path resolution (default: /). */
|
|
195
|
-
workingDir?: string;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* VirtualFs backed by file operations inside a Docker container.
|
|
199
|
-
*
|
|
200
|
-
* Uses `container.exec()` to run filesystem commands (cat, tee, rm, mkdir,
|
|
201
|
-
* stat, etc.) inside the container. File writes use exec + tee to avoid
|
|
202
|
-
* tar archive overhead for text content.
|
|
203
|
-
*
|
|
204
|
-
* Requires `dockerode` as an optional peer dependency.
|
|
205
|
-
* The user is responsible for container lifecycle.
|
|
206
|
-
*/
|
|
207
|
-
declare class DockerFs implements VirtualFs {
|
|
208
|
-
private container;
|
|
209
|
-
private workingDir;
|
|
210
|
-
constructor(opts: DockerFsOptions);
|
|
211
|
-
private resolvePath;
|
|
212
|
-
private exec;
|
|
213
|
-
readFile(path: string, _opts?: ReadOptions): Promise<string>;
|
|
214
|
-
readFileBytes(path: string, maxBytes?: number): Promise<Buffer>;
|
|
215
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
216
|
-
appendFile(path: string, content: string): Promise<void>;
|
|
217
|
-
deleteFile(path: string, opts?: {
|
|
218
|
-
recursive?: boolean;
|
|
219
|
-
}): Promise<void>;
|
|
220
|
-
mkdir(path: string, opts?: {
|
|
221
|
-
recursive?: boolean;
|
|
222
|
-
}): Promise<void>;
|
|
223
|
-
readdir(path: string, _opts?: {
|
|
224
|
-
recursive?: boolean;
|
|
225
|
-
}): Promise<FileEntry[]>;
|
|
226
|
-
exists(path: string): Promise<boolean>;
|
|
227
|
-
stat(path: string): Promise<FileStat>;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
interface E2BFsOptions {
|
|
231
|
-
/** An E2B Sandbox instance created via `Sandbox.create()`. */
|
|
232
|
-
sandbox: E2BSandboxInstance;
|
|
233
|
-
/** Working directory for relative path resolution. */
|
|
234
|
-
workingDir?: string;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* VirtualFs backed by the E2B cloud sandbox filesystem.
|
|
238
|
-
*
|
|
239
|
-
* Requires `e2b` as an optional peer dependency.
|
|
240
|
-
* The user is responsible for sandbox lifecycle (create, close).
|
|
241
|
-
*/
|
|
242
|
-
declare class E2BFs implements VirtualFs {
|
|
243
|
-
private sandbox;
|
|
244
|
-
private workingDir;
|
|
245
|
-
constructor(opts: E2BFsOptions);
|
|
246
|
-
private resolvePath;
|
|
247
|
-
readFile(path: string, _opts?: ReadOptions): Promise<string>;
|
|
248
|
-
readFileBytes(path: string, maxBytes?: number): Promise<Buffer>;
|
|
249
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
250
|
-
/**
|
|
251
|
-
* @warning Not atomic. Concurrent appends may lose data due to
|
|
252
|
-
* read-then-write TOCTOU. The E2B SDK does not expose an append primitive.
|
|
253
|
-
*/
|
|
254
|
-
appendFile(path: string, content: string): Promise<void>;
|
|
255
|
-
deleteFile(path: string, _opts?: {
|
|
256
|
-
recursive?: boolean;
|
|
257
|
-
}): Promise<void>;
|
|
258
|
-
mkdir(path: string, _opts?: {
|
|
259
|
-
recursive?: boolean;
|
|
260
|
-
}): Promise<void>;
|
|
261
|
-
readdir(path: string, _opts?: {
|
|
262
|
-
recursive?: boolean;
|
|
263
|
-
}): Promise<FileEntry[]>;
|
|
264
|
-
exists(path: string): Promise<boolean>;
|
|
265
|
-
stat(path: string): Promise<FileStat>;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
interface FreestyleFsOptions {
|
|
269
|
-
/** A Freestyle VM instance. */
|
|
270
|
-
vm: FreestyleVmInstance;
|
|
271
|
-
/** Working directory for relative path resolution. */
|
|
272
|
-
workingDir?: string;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* VirtualFs backed by a Freestyle VM.
|
|
276
|
-
*
|
|
277
|
-
* Uses `vm.fs.*` for operations with native SDK support (readTextFile,
|
|
278
|
-
* writeTextFile, readDir) and falls back to `vm.exec()` for the rest
|
|
279
|
-
* (stat, exists, mkdir, deleteFile, appendFile, readFileBytes).
|
|
280
|
-
*
|
|
281
|
-
* Requires `freestyle-sandboxes` as an optional peer dependency.
|
|
282
|
-
* The user is responsible for VM lifecycle when using explicit mode.
|
|
283
|
-
*/
|
|
284
|
-
declare class FreestyleFs implements VirtualFs {
|
|
285
|
-
private vm;
|
|
286
|
-
private workingDir;
|
|
287
|
-
constructor(opts: FreestyleFsOptions);
|
|
288
|
-
private resolvePath;
|
|
289
|
-
readFile(filePath: string, _opts?: ReadOptions): Promise<string>;
|
|
290
|
-
readFileBytes(filePath: string, maxBytes?: number): Promise<Buffer>;
|
|
291
|
-
writeFile(filePath: string, content: string): Promise<void>;
|
|
292
|
-
appendFile(filePath: string, content: string): Promise<void>;
|
|
293
|
-
deleteFile(filePath: string, opts?: {
|
|
294
|
-
recursive?: boolean;
|
|
295
|
-
}): Promise<void>;
|
|
296
|
-
mkdir(filePath: string, opts?: {
|
|
297
|
-
recursive?: boolean;
|
|
298
|
-
}): Promise<void>;
|
|
299
|
-
readdir(dirPath: string, _opts?: {
|
|
300
|
-
recursive?: boolean;
|
|
301
|
-
}): Promise<FileEntry[]>;
|
|
302
|
-
exists(filePath: string): Promise<boolean>;
|
|
303
|
-
stat(filePath: string): Promise<FileStat>;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
114
|
/**
|
|
307
115
|
* Resolve a tool flag that can be a static boolean or a function of the input.
|
|
308
116
|
* Returns `defaultValue` when the flag is `undefined`.
|
|
@@ -1585,4 +1393,4 @@ declare const IMAGE_EXTENSIONS: Set<string>;
|
|
|
1585
1393
|
*/
|
|
1586
1394
|
declare function createImageMetadataText(dims: ImageDimensions): string;
|
|
1587
1395
|
|
|
1588
|
-
export { AIProvider, API_IMAGE_MAX_BASE64_SIZE, Agent, AssistantMessage, AutoModeConfig, type CacheSafeParams, CannotRetryError, ChatCompletionUsage, ChatMessage, ChatStreamChunk, type ClassifiedError, type ClassifierResult, type CommandClassification, CommandResult, type CompactOptions, type CompressedImageResult, ContentPart, ContentReplacementRecord, ContextFile, ContextScope, DEFAULT_PRICING, type DenialLimits, type DenialState, DenialTracker,
|
|
1396
|
+
export { AIProvider, API_IMAGE_MAX_BASE64_SIZE, Agent, AssistantMessage, AutoModeConfig, type CacheSafeParams, CannotRetryError, ChatCompletionUsage, ChatMessage, ChatStreamChunk, type ClassifiedError, type ClassifierResult, type CommandClassification, CommandResult, type CompactOptions, type CompressedImageResult, ContentPart, ContentReplacementRecord, ContextFile, ContextScope, DEFAULT_PRICING, type DenialLimits, type DenialState, DenialTracker, ExecOptions, type ExtractMemoriesResult, FileCheckpointSnapshot, FileEntry, FileMemoryProvider, FileStat, type FrontmatterData, type GitOperationEvent, type GitOperationType, HookDefinition, HookEvent, HookInput, IMAGE_EXTENSIONS, IMAGE_MAX_HEIGHT, IMAGE_MAX_WIDTH, type ImageDimensions, InProcessBackend, type IndexTruncation, InvariantViolation, JsonSchemaOutputFormat, LocalComputer, type LocalComputerOptions, LocalFs, type LocalFsOptions, Mailbox, McpServerConfig, MemoryEntry, MemoryProvider, ModelPricing, NoopSpan, NoopTracer, OTelTracer, type ParsedFrontmatter, PermissionBehavior, PermissionContext, PermissionDecision, PermissionHandler, PermissionRule, PermissionUpdate, PostToolUseFailureHookInput, PostToolUseFailureHookOutput, PostToolUseHookInput, PostToolUseHookOutput, PreToolUseHookInput, PreToolUseHookOutput, type PresetOptions, ProjectContextConfig, ReadOptions, type ResizedImage, type ResolvePermissionOptions, type ResumePayload, RetryConfig, RetryContext, RetryEngineOptions, STRUCTURED_OUTPUT_TOOL_NAME, Sandbox, type SanitizeResult, type ShellSafetyConfig, SkillDefinition, Span, SpanAttributeValue, SpanOptions, SpanStatusCode, StoredCostState, StreamEvent, type StreamingExecResult, StreamingToolExecutor, type StreamingToolExecutorFn, type SwarmBackend, type SwarmConfig, type SwarmEvents, SwarmManager, type SwarmMember, type SwarmMemberConfig, type SwarmMemberStatus, type SwarmMessage, type SwarmStatus, TOOL_SEARCH_NAME, ThinkingConfig, ThreadConfig, Tool, ToolCallContent, type ToolCallExecResult, type ToolCallExecutor, ToolResult as ToolCallResult, ToolContext, ToolDefinition, ToolRegistry, ToolResultMessage, ToolResultOverflowEntry, type ToolWithDeferral, Tracer, type TurnInterruption, UsageRecord, type UserInputHandler, VirtualComputer, VirtualFs, type WorktreeInfo, activateContextForPaths, activateSkillsForPaths, agentTool, all, applyPermissionUpdate, applyPermissionUpdates, askUserTool, assertValidMessageSequence, bashTool, buildExtractionPrompt, buildMemorySystemPromptSection, buildProjectContextSection, buildSystemPrompt, calculateCost, classifyCommand, classifyError, classifyPermission, codingAgent, commandWritesGitInternals, compactConversation, compressImageBufferWithTokenLimit, contentMatchesRule, contentToString, countOccurrences, createCacheSafeParams, createImageMetadataText, createSkillTool, createStructuredOutputTool, createToolSearchTool, createWorktree, detectGitOperations, detectTurnInterruption, editFileTool, enterPlanModeTool, enterWorktreeTool, estimateCompactionSavings, estimateMessagesTokens, estimateTokens, exitPlanModeTool, exitWorktreeTool, extractCommandName, extractMemories, filterActiveContextFiles, filterOrphanedThinkingMessages, filterUnresolvedToolUses, filterWhitespaceOnlyAssistantMessages, findActualString, findGitRoot, findModelPricing, formatDeferredToolLine, generateMissingToolResults, getActiveSkills, getAutoCompactThreshold, getContextWindowForModel, getEffectiveContextWindow, getLastCacheSafeParams, getMatchingRules, getRetryDelay, getWorktreeChanges, globTool, grepTool, groupMessagesByTurn, hasGitIndexLockError, hasImageContent, isDeferredTool, isGitInternalPath, isPathInWorkingDirectories, isRetryable, listWorktrees, loadProjectContext, loadSkills, looksLikeBareRepo, matchSimpleGlob, maybeResizeAndDownsampleImageBlock, maybeResizeAndDownsampleImageBuffer, normalizeContent, normalizeMessagesForAPI, normalizeQuotes, notebookEditTool, parseAllowedTools, parseFrontmatter, parsePaths, partitionToolCalls, planningAgent, preserveQuoteStyle, readFileTool, registerContextWindows, removeWorktree, resolvePermission, resolveToolFlag, restoreSession, reviewAgent, runNotificationHooks, runPostToolUseFailureHooks, runPostToolUseHooks, runPreToolUseHooks, runToolsBatched, sanitizeForResume, sanitizeWorktreeSlug, saveCacheSafeParams, searchToolsWithKeywords, stripImageContent, stripTrailingWhitespace, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, tokenCountWithEstimation, toolMatchesRule, truncateHeadForPTLRetry, truncateIndex, webFetchTool, withRetry, writeFileTool };
|