@cuylabs/agent-core 0.6.0 → 0.8.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 +5 -1
- package/dist/{builder-BKkipazh.d.ts → builder-UpOWQMW3.d.ts} +2 -2
- package/dist/{chunk-3C4VKG4P.js → chunk-4BDA7DQY.js} +273 -807
- package/dist/chunk-7VKQ4WPB.js +73 -0
- package/dist/chunk-BFM2YHNM.js +222 -0
- package/dist/chunk-CAA7FHIH.js +280 -0
- package/dist/chunk-KUVSERLJ.js +50 -0
- package/dist/chunk-N6HWIEEA.js +423 -0
- package/dist/chunk-N7P4PN3O.js +84 -0
- package/dist/{chunk-QWFMX226.js → chunk-RFEKJKTO.js} +252 -13
- package/dist/chunk-RZITT45F.js +202 -0
- package/dist/{chunk-X635CM2F.js → chunk-SQU2AJHO.js} +1 -1
- package/dist/chunk-VNQBHPCT.js +398 -0
- package/dist/{chunk-QAQADS4X.js → chunk-WWYYNWEW.js} +2 -1
- package/dist/{chunk-O2ZCFQL6.js → chunk-YSLSEQ6B.js} +105 -220
- package/dist/context/index.js +1 -1
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.js +16 -0
- package/dist/events-CE72w8W4.d.ts +149 -0
- package/dist/host/index.d.ts +45 -0
- package/dist/host/index.js +8 -0
- package/dist/{index-DZQJD_hp.d.ts → index-CWSchSql.d.ts} +42 -51
- package/dist/index.d.ts +98 -190
- package/dist/index.js +476 -939
- package/dist/inference/index.d.ts +62 -0
- package/dist/inference/index.js +27 -0
- package/dist/llm-error-D93FNNLY.d.ts +32 -0
- package/dist/middleware/index.d.ts +246 -5
- package/dist/middleware/index.js +7 -3
- package/dist/models/index.d.ts +226 -3
- package/dist/models/index.js +41 -3
- package/dist/presets/index.d.ts +53 -0
- package/dist/presets/index.js +28 -0
- package/dist/prompt/index.d.ts +12 -7
- package/dist/reasoning/index.d.ts +53 -8
- package/dist/reasoning/index.js +2 -7
- package/dist/{registry-CuRWWtcT.d.ts → registry-DwYqsQkX.d.ts} +1 -1
- package/dist/{runner-G1wxEgac.d.ts → runner-e2YRcUoX.d.ts} +82 -148
- package/dist/runtime/index.d.ts +44 -7
- package/dist/runtime/index.js +16 -5
- package/dist/safety/index.d.ts +38 -0
- package/dist/safety/index.js +12 -0
- package/dist/scope/index.d.ts +10 -0
- package/dist/scope/index.js +14 -0
- package/dist/{session-manager-Uawm2Le7.d.ts → session-manager-B_CWGTsl.d.ts} +1 -1
- package/dist/signal/index.d.ts +28 -0
- package/dist/signal/index.js +6 -0
- package/dist/skill/index.d.ts +8 -5
- package/dist/storage/index.d.ts +2 -2
- package/dist/sub-agent/index.d.ts +17 -8
- package/dist/tool/index.d.ts +9 -4
- package/dist/tool/index.js +4 -3
- package/dist/tool-BHbyUAy3.d.ts +150 -0
- package/dist/{tool-DYp6-cC3.d.ts → tool-DLXAR9Ce.d.ts} +5 -99
- package/dist/tracking/index.d.ts +3 -1
- package/dist/{tool-pFAnJc5Y.d.ts → types-BfNpU8NS.d.ts} +1 -150
- package/dist/types-BnpEOYV-.d.ts +50 -0
- package/dist/types-CHiPh8U2.d.ts +100 -0
- package/dist/types-CQL-SvTn.d.ts +29 -0
- package/dist/types-CWm-7rvB.d.ts +55 -0
- package/dist/types-KKDrdU9Y.d.ts +325 -0
- package/dist/{resolver-DOfZ-xuk.d.ts → types-QA4WhEfz.d.ts} +1 -117
- package/dist/types-QKHHQLLq.d.ts +336 -0
- package/dist/types-YuWV4ag7.d.ts +72 -0
- package/package.json +74 -8
- package/dist/capabilities/index.d.ts +0 -97
- package/dist/capabilities/index.js +0 -46
- package/dist/chunk-6TDTQJ4P.js +0 -116
- package/dist/chunk-FG4MD5MU.js +0 -54
- package/dist/config-D2xeGEHK.d.ts +0 -52
- package/dist/identifiers-BLUxFqV_.d.ts +0 -12
- package/dist/index-ipP3_ztp.d.ts +0 -198
- package/dist/network-D76DS5ot.d.ts +0 -5
- package/dist/types-BWo810L_.d.ts +0 -648
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
// src/host/local.ts
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
import { existsSync } from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import process from "process";
|
|
7
|
+
function getShell() {
|
|
8
|
+
if (process.platform === "win32") {
|
|
9
|
+
return { shell: "cmd.exe", args: ["/c"] };
|
|
10
|
+
}
|
|
11
|
+
const userShell = process.env.SHELL ?? "/bin/bash";
|
|
12
|
+
return { shell: userShell, args: ["-c"] };
|
|
13
|
+
}
|
|
14
|
+
async function killProcessTree(pid) {
|
|
15
|
+
try {
|
|
16
|
+
if (process.platform !== "win32") {
|
|
17
|
+
process.kill(-pid, "SIGKILL");
|
|
18
|
+
} else {
|
|
19
|
+
const { exec: execCb } = await import("child_process");
|
|
20
|
+
execCb(`taskkill /pid ${pid} /t /f`, () => {
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
try {
|
|
25
|
+
process.kill(pid, "SIGKILL");
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function localHost(defaultCwd) {
|
|
31
|
+
const cwd = defaultCwd ?? process.cwd();
|
|
32
|
+
return {
|
|
33
|
+
name: "local",
|
|
34
|
+
// --------------------------------------------------------------------------
|
|
35
|
+
// File system
|
|
36
|
+
// --------------------------------------------------------------------------
|
|
37
|
+
async readFile(filePath) {
|
|
38
|
+
const abs = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
39
|
+
return fs.readFile(abs, "utf-8");
|
|
40
|
+
},
|
|
41
|
+
async readBytes(filePath, offset, length) {
|
|
42
|
+
const abs = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
43
|
+
const fh = await fs.open(abs, "r");
|
|
44
|
+
try {
|
|
45
|
+
const buf = Buffer.alloc(length);
|
|
46
|
+
await fh.read(buf, 0, length, offset);
|
|
47
|
+
return buf;
|
|
48
|
+
} finally {
|
|
49
|
+
await fh.close();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
async writeFile(filePath, content) {
|
|
53
|
+
const abs = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
54
|
+
await fs.mkdir(path.dirname(abs), { recursive: true });
|
|
55
|
+
await fs.writeFile(abs, content, "utf-8");
|
|
56
|
+
},
|
|
57
|
+
async exists(filePath) {
|
|
58
|
+
const abs = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
59
|
+
return existsSync(abs);
|
|
60
|
+
},
|
|
61
|
+
async stat(filePath) {
|
|
62
|
+
const abs = path.isAbsolute(filePath) ? filePath : path.resolve(cwd, filePath);
|
|
63
|
+
const s = await fs.stat(abs);
|
|
64
|
+
return {
|
|
65
|
+
size: s.size,
|
|
66
|
+
mtime: s.mtime,
|
|
67
|
+
isDirectory: s.isDirectory(),
|
|
68
|
+
isFile: s.isFile()
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
async readdir(dirPath) {
|
|
72
|
+
const abs = path.isAbsolute(dirPath) ? dirPath : path.resolve(cwd, dirPath);
|
|
73
|
+
const entries = await fs.readdir(abs, { withFileTypes: true });
|
|
74
|
+
return entries.map((e) => ({
|
|
75
|
+
name: e.name,
|
|
76
|
+
isDirectory: e.isDirectory(),
|
|
77
|
+
isFile: e.isFile()
|
|
78
|
+
}));
|
|
79
|
+
},
|
|
80
|
+
async mkdir(dirPath) {
|
|
81
|
+
const abs = path.isAbsolute(dirPath) ? dirPath : path.resolve(cwd, dirPath);
|
|
82
|
+
await fs.mkdir(abs, { recursive: true });
|
|
83
|
+
},
|
|
84
|
+
// --------------------------------------------------------------------------
|
|
85
|
+
// Process execution
|
|
86
|
+
// --------------------------------------------------------------------------
|
|
87
|
+
exec(command, options) {
|
|
88
|
+
const { shell, args } = getShell();
|
|
89
|
+
const execCwd = options?.cwd ?? cwd;
|
|
90
|
+
const env = {
|
|
91
|
+
...process.env,
|
|
92
|
+
...options?.env,
|
|
93
|
+
// Disable pagers — tools collect output, not interactive
|
|
94
|
+
PAGER: "cat",
|
|
95
|
+
GIT_PAGER: "cat"
|
|
96
|
+
};
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
let stdout = "";
|
|
99
|
+
let stderr = "";
|
|
100
|
+
let timedOut = false;
|
|
101
|
+
let settled = false;
|
|
102
|
+
const child = spawn(shell, [...args, command], {
|
|
103
|
+
cwd: execCwd,
|
|
104
|
+
detached: process.platform !== "win32",
|
|
105
|
+
env,
|
|
106
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
107
|
+
});
|
|
108
|
+
child.stdout?.on("data", (data) => {
|
|
109
|
+
stdout += data.toString();
|
|
110
|
+
options?.onStdout?.(data);
|
|
111
|
+
});
|
|
112
|
+
child.stderr?.on("data", (data) => {
|
|
113
|
+
stderr += data.toString();
|
|
114
|
+
options?.onStderr?.(data);
|
|
115
|
+
});
|
|
116
|
+
let timer;
|
|
117
|
+
if (options?.timeout && options.timeout > 0) {
|
|
118
|
+
timer = setTimeout(() => {
|
|
119
|
+
timedOut = true;
|
|
120
|
+
if (child.pid) killProcessTree(child.pid);
|
|
121
|
+
}, options.timeout);
|
|
122
|
+
}
|
|
123
|
+
const onAbort = () => {
|
|
124
|
+
if (child.pid) killProcessTree(child.pid);
|
|
125
|
+
};
|
|
126
|
+
options?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
127
|
+
child.on("close", (code) => {
|
|
128
|
+
if (settled) return;
|
|
129
|
+
settled = true;
|
|
130
|
+
if (timer) clearTimeout(timer);
|
|
131
|
+
options?.signal?.removeEventListener("abort", onAbort);
|
|
132
|
+
resolve({ stdout, stderr, exitCode: code, timedOut });
|
|
133
|
+
});
|
|
134
|
+
child.on("error", (err) => {
|
|
135
|
+
if (settled) return;
|
|
136
|
+
settled = true;
|
|
137
|
+
if (timer) clearTimeout(timer);
|
|
138
|
+
options?.signal?.removeEventListener("abort", onAbort);
|
|
139
|
+
reject(err);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/host/docker/exec.ts
|
|
147
|
+
async function loadDockerode() {
|
|
148
|
+
try {
|
|
149
|
+
const module = await import("dockerode");
|
|
150
|
+
return module.default ?? module;
|
|
151
|
+
} catch {
|
|
152
|
+
throw new Error(
|
|
153
|
+
"dockerHost requires the 'dockerode' package. Install it with: npm install dockerode"
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function resolveDockerRuntime(options) {
|
|
158
|
+
const Dockerode = await loadDockerode();
|
|
159
|
+
if (typeof options.container === "string") {
|
|
160
|
+
const docker = new Dockerode(options.dockerOptions);
|
|
161
|
+
const container2 = docker.getContainer(options.container);
|
|
162
|
+
return {
|
|
163
|
+
docker,
|
|
164
|
+
container: container2,
|
|
165
|
+
label: options.container
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const container = options.container;
|
|
169
|
+
return {
|
|
170
|
+
docker: { modem: container.modem },
|
|
171
|
+
container,
|
|
172
|
+
label: container.id?.slice(0, 12) ?? "unknown"
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function containerExec(runtime, command, options = {}) {
|
|
176
|
+
const envEntries = options.env ? Object.entries(options.env).filter((entry) => entry[1] !== void 0).map(([key, value]) => `${key}=${value}`) : void 0;
|
|
177
|
+
const exec = await runtime.container.exec({
|
|
178
|
+
Cmd: ["sh", "-c", command],
|
|
179
|
+
...options.user ? { User: options.user } : {},
|
|
180
|
+
...options.workdir ? { WorkingDir: options.workdir } : {},
|
|
181
|
+
...envEntries && envEntries.length > 0 ? { Env: envEntries } : {},
|
|
182
|
+
AttachStdout: true,
|
|
183
|
+
AttachStderr: true
|
|
184
|
+
});
|
|
185
|
+
const stream = await exec.start({});
|
|
186
|
+
let timedOut = false;
|
|
187
|
+
let aborted = false;
|
|
188
|
+
return await new Promise((resolve, reject) => {
|
|
189
|
+
const stdoutChunks = [];
|
|
190
|
+
const stderrChunks = [];
|
|
191
|
+
runtime.docker.modem.demuxStream(
|
|
192
|
+
stream,
|
|
193
|
+
{
|
|
194
|
+
write: (chunk) => {
|
|
195
|
+
stdoutChunks.push(chunk);
|
|
196
|
+
options.onStdout?.(chunk);
|
|
197
|
+
return true;
|
|
198
|
+
},
|
|
199
|
+
end: function() {
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
write: (chunk) => {
|
|
205
|
+
stderrChunks.push(chunk);
|
|
206
|
+
options.onStderr?.(chunk);
|
|
207
|
+
return true;
|
|
208
|
+
},
|
|
209
|
+
end: function() {
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
let timer;
|
|
215
|
+
if (options.timeout && options.timeout > 0) {
|
|
216
|
+
timer = setTimeout(() => {
|
|
217
|
+
timedOut = true;
|
|
218
|
+
stream.destroy?.();
|
|
219
|
+
}, options.timeout);
|
|
220
|
+
}
|
|
221
|
+
const onAbort = () => {
|
|
222
|
+
aborted = true;
|
|
223
|
+
stream.destroy?.();
|
|
224
|
+
};
|
|
225
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
226
|
+
stream.on("end", async () => {
|
|
227
|
+
if (timer) {
|
|
228
|
+
clearTimeout(timer);
|
|
229
|
+
}
|
|
230
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
231
|
+
try {
|
|
232
|
+
const info = await exec.inspect();
|
|
233
|
+
resolve({
|
|
234
|
+
stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
|
|
235
|
+
stderr: Buffer.concat(stderrChunks).toString("utf-8"),
|
|
236
|
+
exitCode: timedOut || aborted ? null : info.ExitCode ?? 0,
|
|
237
|
+
timedOut
|
|
238
|
+
});
|
|
239
|
+
} catch (error) {
|
|
240
|
+
reject(error);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
stream.on("error", (error) => {
|
|
244
|
+
if (timer) {
|
|
245
|
+
clearTimeout(timer);
|
|
246
|
+
}
|
|
247
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
248
|
+
if (timedOut || aborted) {
|
|
249
|
+
resolve({
|
|
250
|
+
stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
|
|
251
|
+
stderr: Buffer.concat(stderrChunks).toString("utf-8"),
|
|
252
|
+
exitCode: null,
|
|
253
|
+
timedOut
|
|
254
|
+
});
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
reject(error);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
async function runDockerCommand(options) {
|
|
262
|
+
const { runtime, command, defaultUser, defaultWorkdir, execOptions } = options;
|
|
263
|
+
return await containerExec(runtime, command, {
|
|
264
|
+
user: defaultUser,
|
|
265
|
+
workdir: execOptions?.workdir ?? execOptions?.cwd ?? defaultWorkdir,
|
|
266
|
+
env: execOptions?.env,
|
|
267
|
+
timeout: execOptions?.timeout,
|
|
268
|
+
signal: execOptions?.signal,
|
|
269
|
+
onStdout: execOptions?.onStdout,
|
|
270
|
+
onStderr: execOptions?.onStderr
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/host/docker/shell.ts
|
|
275
|
+
function sq(value) {
|
|
276
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
277
|
+
}
|
|
278
|
+
function resolveDockerPath(path2, defaultWorkdir) {
|
|
279
|
+
if (path2.startsWith("/")) {
|
|
280
|
+
return path2;
|
|
281
|
+
}
|
|
282
|
+
const base = defaultWorkdir.endsWith("/") ? defaultWorkdir : `${defaultWorkdir}/`;
|
|
283
|
+
return `${base}${path2}`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/host/docker/host.ts
|
|
287
|
+
async function dockerHost(options) {
|
|
288
|
+
const runtime = await resolveDockerRuntime(options);
|
|
289
|
+
const defaultUser = options.user;
|
|
290
|
+
const defaultWorkdir = options.workdir ?? "/";
|
|
291
|
+
async function run(command, execOptions) {
|
|
292
|
+
return await runDockerCommand({
|
|
293
|
+
runtime,
|
|
294
|
+
command,
|
|
295
|
+
defaultUser,
|
|
296
|
+
defaultWorkdir,
|
|
297
|
+
execOptions
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
name: `docker:${runtime.label}`,
|
|
302
|
+
async readFile(filePath) {
|
|
303
|
+
const absPath = resolveDockerPath(filePath, defaultWorkdir);
|
|
304
|
+
const result = await run(`cat ${sq(absPath)}`);
|
|
305
|
+
if (result.exitCode !== 0) {
|
|
306
|
+
throw new Error(`readFile failed (${absPath}): ${result.stderr.trim()}`);
|
|
307
|
+
}
|
|
308
|
+
return result.stdout;
|
|
309
|
+
},
|
|
310
|
+
async readBytes(filePath, offset, length) {
|
|
311
|
+
const absPath = resolveDockerPath(filePath, defaultWorkdir);
|
|
312
|
+
const result = await run(
|
|
313
|
+
`dd if=${sq(absPath)} bs=1 skip=${offset} count=${length} 2>/dev/null`
|
|
314
|
+
);
|
|
315
|
+
if (result.exitCode !== 0) {
|
|
316
|
+
throw new Error(
|
|
317
|
+
`readBytes failed (${absPath}): ${result.stderr.trim()}`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
return Buffer.from(result.stdout, "binary");
|
|
321
|
+
},
|
|
322
|
+
async writeFile(filePath, content) {
|
|
323
|
+
const absPath = resolveDockerPath(filePath, defaultWorkdir);
|
|
324
|
+
const dir = absPath.substring(0, absPath.lastIndexOf("/")) || "/";
|
|
325
|
+
await run(`mkdir -p ${sq(dir)}`);
|
|
326
|
+
const encoded = Buffer.from(content, "utf-8").toString("base64");
|
|
327
|
+
const result = await run(`echo ${sq(encoded)} | base64 -d > ${sq(absPath)}`);
|
|
328
|
+
if (result.exitCode !== 0) {
|
|
329
|
+
throw new Error(
|
|
330
|
+
`writeFile failed (${absPath}): ${result.stderr.trim()}`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
async exists(filePath) {
|
|
335
|
+
const absPath = resolveDockerPath(filePath, defaultWorkdir);
|
|
336
|
+
const result = await run(`test -e ${sq(absPath)}`);
|
|
337
|
+
return result.exitCode === 0;
|
|
338
|
+
},
|
|
339
|
+
async stat(filePath) {
|
|
340
|
+
const absPath = resolveDockerPath(filePath, defaultWorkdir);
|
|
341
|
+
const result = await run(
|
|
342
|
+
`stat -c '%s %Y %F' ${sq(absPath)} 2>/dev/null || stat -f '%z %m %HT' ${sq(absPath)}`
|
|
343
|
+
);
|
|
344
|
+
if (result.exitCode !== 0) {
|
|
345
|
+
throw new Error(`stat failed (${absPath}): ${result.stderr.trim()}`);
|
|
346
|
+
}
|
|
347
|
+
const parts = result.stdout.trim().split(/\s+/);
|
|
348
|
+
if (parts.length < 3) {
|
|
349
|
+
throw new Error(
|
|
350
|
+
`stat: unexpected output format for ${absPath}: ${result.stdout}`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
const size = parseInt(parts[0], 10);
|
|
354
|
+
const mtimeSec = parseInt(parts[1], 10);
|
|
355
|
+
const typeStr = parts.slice(2).join(" ").toLowerCase();
|
|
356
|
+
return {
|
|
357
|
+
size,
|
|
358
|
+
mtime: new Date(mtimeSec * 1e3),
|
|
359
|
+
isDirectory: typeStr.includes("directory"),
|
|
360
|
+
isFile: typeStr.includes("regular") || typeStr.includes("file")
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
async readdir(dirPath) {
|
|
364
|
+
const absPath = resolveDockerPath(dirPath, defaultWorkdir);
|
|
365
|
+
const result = await run(
|
|
366
|
+
`find ${sq(absPath)} -maxdepth 1 -mindepth 1 -printf '%f\\t%y\\n' 2>/dev/null || for f in ${sq(absPath)}/*; do [ -e "$f" ] || continue; n=$(basename "$f"); if [ -d "$f" ]; then printf '%s\\td\\n' "$n"; else printf '%s\\tf\\n' "$n"; fi; done`
|
|
367
|
+
);
|
|
368
|
+
if (result.exitCode !== 0) {
|
|
369
|
+
throw new Error(
|
|
370
|
+
`readdir failed (${absPath}): ${result.stderr.trim()}`
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
return result.stdout.trim().split("\n").filter(Boolean).map((line) => {
|
|
374
|
+
const [name, type] = line.split(" ");
|
|
375
|
+
return {
|
|
376
|
+
name,
|
|
377
|
+
isDirectory: type === "d",
|
|
378
|
+
isFile: type === "f"
|
|
379
|
+
};
|
|
380
|
+
});
|
|
381
|
+
},
|
|
382
|
+
async mkdir(dirPath) {
|
|
383
|
+
const absPath = resolveDockerPath(dirPath, defaultWorkdir);
|
|
384
|
+
const result = await run(`mkdir -p ${sq(absPath)}`);
|
|
385
|
+
if (result.exitCode !== 0) {
|
|
386
|
+
throw new Error(`mkdir failed (${absPath}): ${result.stderr.trim()}`);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
async exec(command, execOptions) {
|
|
390
|
+
return await run(command, execOptions);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export {
|
|
396
|
+
localHost,
|
|
397
|
+
dockerHost
|
|
398
|
+
};
|
|
@@ -30,7 +30,7 @@ function estimateConversationTokens(messages) {
|
|
|
30
30
|
return total;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// src/types/
|
|
33
|
+
// src/agent/types/compaction.ts
|
|
34
34
|
var PRUNE_PROTECTED_TOOLS = ["skill"];
|
|
35
35
|
|
|
36
36
|
// src/context/pruning.ts
|
|
@@ -247,6 +247,7 @@ export {
|
|
|
247
247
|
estimateTokens,
|
|
248
248
|
estimateMessageTokens,
|
|
249
249
|
estimateConversationTokens,
|
|
250
|
+
PRUNE_PROTECTED_TOOLS,
|
|
250
251
|
DEFAULT_CONTEXT_LIMITS,
|
|
251
252
|
isContextOverflowing,
|
|
252
253
|
shouldPruneContext,
|