coding-agents-sdk 0.0.1 → 0.2.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 +242 -0
- package/dist/Agent-D8WkUilj.mjs +262 -0
- package/dist/SdkAgent-B47mJiIE.mjs +38 -0
- package/dist/adapters/claude-code-cli/index.d.mts +2 -0
- package/dist/adapters/claude-code-cli/index.mjs +490 -0
- package/dist/adapters/claude-code-sdk/index.d.mts +2 -0
- package/dist/adapters/claude-code-sdk/index.mjs +483 -0
- package/dist/adapters/codex-cli/index.d.mts +2 -0
- package/dist/adapters/codex-cli/index.mjs +626 -0
- package/dist/adapters/codex-sdk/index.d.mts +2 -0
- package/dist/adapters/codex-sdk/index.mjs +286 -0
- package/dist/adapters/gemini-cli/index.d.mts +2 -0
- package/dist/adapters/gemini-cli/index.mjs +292 -0
- package/dist/classify-error-pL6jeu4T.mjs +456 -0
- package/dist/container/index.d.mts +2 -0
- package/dist/container/index.mjs +24 -0
- package/dist/container-2UmPZ0CI.mjs +22 -0
- package/dist/container-CHxKIonn.mjs +440 -0
- package/dist/container-D2Z0ITDJ.mjs +22 -0
- package/dist/diff-De8d3MVb.mjs +333 -0
- package/dist/errors-BAmHDQu8.mjs +45 -0
- package/dist/events-nxuRbYIu.d.mts +239 -0
- package/dist/index-B3YqrgIp.d.mts +45 -0
- package/dist/index-ByAOGMUM.d.mts +224 -0
- package/dist/index-C3ZxLAd0.d.mts +315 -0
- package/dist/index-CFpNOmdA.d.mts +145 -0
- package/dist/index-dRVpEAr8.d.mts +39 -0
- package/dist/index-nzo1sBiK.d.mts +110 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +61 -0
- package/dist/oci-DMZZQZ47.mjs +438 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +2 -0
- package/dist/schemas-DwD4pwJB.mjs +96 -0
- package/dist/spawner-Bw9UBEGX.mjs +54 -0
- package/dist/structured-output-BHtr_zpz.mjs +19 -0
- package/dist/types-Cb_EXIEe.d.mts +177 -0
- package/dist/types-aNMD8h3x.mjs +19 -0
- package/dist/util-B4RQZkKr.mjs +77 -0
- package/package.json +86 -9
- package/index.js +0 -7
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { t as formatError } from "./util-B4RQZkKr.mjs";
|
|
2
|
+
import { n as ContainerDiffError, o as ContainerNotRunningError, r as ContainerDisposedError } from "./errors-BAmHDQu8.mjs";
|
|
3
|
+
import { createReadStream } from "node:fs";
|
|
4
|
+
import { copyFile, lstat, mkdir, mkdtemp, readdir, readlink, rm, stat, symlink } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, isAbsolute, join, posix, relative, sep } from "node:path";
|
|
7
|
+
import { execFile } from "node:child_process";
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import { promisify } from "node:util";
|
|
10
|
+
import { pipeline } from "node:stream/promises";
|
|
11
|
+
//#region src/core/process/errors.ts
|
|
12
|
+
const isExecFileError = (error) => {
|
|
13
|
+
return error instanceof Error && "code" in error && ("stdout" in error || "stderr" in error);
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/process/shell.ts
|
|
17
|
+
const shellEscape = (s) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/container/diff.ts
|
|
20
|
+
const execFileAsync = promisify(execFile);
|
|
21
|
+
const isRelativePath = (value) => {
|
|
22
|
+
return value !== ".." && !value.startsWith(`..${sep}`) && !isAbsolute(value);
|
|
23
|
+
};
|
|
24
|
+
const toPosixRelativePath = (rootDir, absolutePath) => {
|
|
25
|
+
const relativePath = relative(rootDir, absolutePath);
|
|
26
|
+
if (!isRelativePath(relativePath)) return;
|
|
27
|
+
return relativePath.split(sep).join(posix.sep);
|
|
28
|
+
};
|
|
29
|
+
const relativizeGitPath = (absolutePath, beforeDir, afterDir) => {
|
|
30
|
+
const beforePath = toPosixRelativePath(beforeDir, absolutePath);
|
|
31
|
+
if (beforePath !== void 0) return beforePath;
|
|
32
|
+
const afterPath = toPosixRelativePath(afterDir, absolutePath);
|
|
33
|
+
if (afterPath !== void 0) return afterPath;
|
|
34
|
+
throw new ContainerDiffError(`Git diff produced a path outside the materialized trees: ${absolutePath}`);
|
|
35
|
+
};
|
|
36
|
+
const sortFileChanges = (changes) => changes.sort((left, right) => {
|
|
37
|
+
if (left.path === right.path) return (left.previousPath ?? "").localeCompare(right.previousPath ?? "");
|
|
38
|
+
return left.path.localeCompare(right.path);
|
|
39
|
+
});
|
|
40
|
+
const removeGitMetadataDirs = async (rootDir) => {
|
|
41
|
+
const entries = await readdir(rootDir, { withFileTypes: true });
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const fullPath = join(rootDir, entry.name);
|
|
44
|
+
if (entry.name === ".git") {
|
|
45
|
+
await rm(fullPath, {
|
|
46
|
+
recursive: true,
|
|
47
|
+
force: true
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (entry.isDirectory()) await removeGitMetadataDirs(fullPath);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const createTempTree = () => mkdtemp(join(tmpdir(), "cw-workdir-diff-"));
|
|
55
|
+
const cleanupTempTree = async (path) => {
|
|
56
|
+
if (!path) return;
|
|
57
|
+
await rm(path, {
|
|
58
|
+
recursive: true,
|
|
59
|
+
force: true
|
|
60
|
+
}).catch(() => {});
|
|
61
|
+
};
|
|
62
|
+
const createSnapshot = (meta, snapshotMetadata) => {
|
|
63
|
+
const snapshot = {
|
|
64
|
+
cwd: meta.cwd,
|
|
65
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
66
|
+
};
|
|
67
|
+
snapshotMetadata.set(snapshot, meta);
|
|
68
|
+
return snapshot;
|
|
69
|
+
};
|
|
70
|
+
const getSnapshotMeta = (owner, snapshot, snapshotMetadata) => {
|
|
71
|
+
if (typeof snapshot !== "object" || snapshot === null) throw new ContainerDiffError("Invalid workdir snapshot.");
|
|
72
|
+
const meta = snapshotMetadata.get(snapshot);
|
|
73
|
+
if (!meta) throw new ContainerDiffError("Invalid workdir snapshot.");
|
|
74
|
+
if (meta.owner !== owner) throw new ContainerDiffError("Workdir snapshot was created by a different container instance.");
|
|
75
|
+
return meta;
|
|
76
|
+
};
|
|
77
|
+
const assertSnapshotActive = (snapshot, activeSnapshots) => {
|
|
78
|
+
if (!activeSnapshots.has(snapshot)) throw new ContainerDiffError("Workdir snapshot has been released.");
|
|
79
|
+
};
|
|
80
|
+
const createContentHash = (value) => createHash("sha256").update(value).digest("hex");
|
|
81
|
+
const toBuffer = (value) => Buffer.isBuffer(value) ? value : Buffer.from(value, "utf8");
|
|
82
|
+
const hashFileStream = async (path) => {
|
|
83
|
+
const hash = createHash("sha256");
|
|
84
|
+
await pipeline(createReadStream(path), hash);
|
|
85
|
+
return hash.digest("hex");
|
|
86
|
+
};
|
|
87
|
+
const getFileMetadata = async (rootDir, relativePath, cache) => {
|
|
88
|
+
const cacheKey = `${rootDir}:${relativePath}`;
|
|
89
|
+
if (cache.has(cacheKey)) return cache.get(cacheKey);
|
|
90
|
+
const absolutePath = join(rootDir, ...relativePath.split(posix.sep));
|
|
91
|
+
try {
|
|
92
|
+
const entry = await lstat(absolutePath);
|
|
93
|
+
let hash;
|
|
94
|
+
let size;
|
|
95
|
+
if (entry.isSymbolicLink()) {
|
|
96
|
+
const linkTarget = Buffer.from(await readlink(absolutePath));
|
|
97
|
+
hash = createContentHash(linkTarget);
|
|
98
|
+
size = linkTarget.byteLength;
|
|
99
|
+
} else if (entry.isFile()) {
|
|
100
|
+
hash = await hashFileStream(absolutePath);
|
|
101
|
+
size = entry.size;
|
|
102
|
+
} else throw new ContainerDiffError(`Unsupported filesystem entry in diff metadata: ${absolutePath}`);
|
|
103
|
+
const metadata = {
|
|
104
|
+
hash,
|
|
105
|
+
size
|
|
106
|
+
};
|
|
107
|
+
cache.set(cacheKey, metadata);
|
|
108
|
+
return metadata;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
111
|
+
cache.set(cacheKey, void 0);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const parseGitDiffOutput = (stdout, beforeDir, afterDir) => {
|
|
118
|
+
if (stdout.byteLength === 0) return [];
|
|
119
|
+
const fields = stdout.toString("utf8").split("\0");
|
|
120
|
+
if (fields[fields.length - 1] === "") fields.pop();
|
|
121
|
+
const changes = [];
|
|
122
|
+
for (let index = 0; index < fields.length;) {
|
|
123
|
+
const status = fields[index++];
|
|
124
|
+
if (!status) continue;
|
|
125
|
+
if (status.startsWith("R")) {
|
|
126
|
+
const previousPath = fields[index++];
|
|
127
|
+
const path = fields[index++];
|
|
128
|
+
if (!previousPath || !path) throw new ContainerDiffError("Failed to parse git rename entry.");
|
|
129
|
+
changes.push({
|
|
130
|
+
kind: "renamed",
|
|
131
|
+
previousPath: relativizeGitPath(previousPath, beforeDir, afterDir),
|
|
132
|
+
path: relativizeGitPath(path, beforeDir, afterDir)
|
|
133
|
+
});
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const path = fields[index++];
|
|
137
|
+
if (!path) throw new ContainerDiffError("Failed to parse git diff entry.");
|
|
138
|
+
switch (status) {
|
|
139
|
+
case "A":
|
|
140
|
+
changes.push({
|
|
141
|
+
kind: "added",
|
|
142
|
+
path: relativizeGitPath(path, beforeDir, afterDir)
|
|
143
|
+
});
|
|
144
|
+
break;
|
|
145
|
+
case "D":
|
|
146
|
+
changes.push({
|
|
147
|
+
kind: "deleted",
|
|
148
|
+
path: relativizeGitPath(path, beforeDir, afterDir)
|
|
149
|
+
});
|
|
150
|
+
break;
|
|
151
|
+
case "M":
|
|
152
|
+
changes.push({
|
|
153
|
+
kind: "modified",
|
|
154
|
+
path: relativizeGitPath(path, beforeDir, afterDir)
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
case "T":
|
|
158
|
+
changes.push({
|
|
159
|
+
kind: "modified",
|
|
160
|
+
path: relativizeGitPath(path, beforeDir, afterDir)
|
|
161
|
+
});
|
|
162
|
+
break;
|
|
163
|
+
default: throw new ContainerDiffError(`Unsupported git diff change kind: ${status}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return changes;
|
|
167
|
+
};
|
|
168
|
+
const runGitDiff = async (beforeDir, afterDir) => {
|
|
169
|
+
try {
|
|
170
|
+
return parseGitDiffOutput(toBuffer((await execFileAsync("git", [
|
|
171
|
+
"diff",
|
|
172
|
+
"--no-index",
|
|
173
|
+
"-z",
|
|
174
|
+
"--name-status",
|
|
175
|
+
"-M",
|
|
176
|
+
"--find-renames=100%",
|
|
177
|
+
beforeDir,
|
|
178
|
+
afterDir
|
|
179
|
+
], {
|
|
180
|
+
cwd: tmpdir(),
|
|
181
|
+
encoding: "buffer",
|
|
182
|
+
maxBuffer: 50 * 1024 * 1024
|
|
183
|
+
})).stdout), beforeDir, afterDir);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (!isExecFileError(error)) throw new ContainerDiffError(`Failed to run git diff: ${formatError(error)}`);
|
|
186
|
+
const code = error.code ?? 1;
|
|
187
|
+
const stdout = Buffer.isBuffer(error.stdout) ? error.stdout : Buffer.from(String(error.stdout ?? ""), "utf8");
|
|
188
|
+
const stderr = Buffer.isBuffer(error.stderr) ? error.stderr : Buffer.from(String(error.stderr ?? ""), "utf8");
|
|
189
|
+
if (code === 0 || code === 1) return parseGitDiffOutput(stdout, beforeDir, afterDir);
|
|
190
|
+
throw new ContainerDiffError(`Failed to run git diff: ${stderr.toString("utf8").trim() || stdout.toString("utf8").trim() || `exit code ${code}`}`);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const enrichFileChanges = async (changes, beforeDir, afterDir) => {
|
|
194
|
+
const metadataCache = /* @__PURE__ */ new Map();
|
|
195
|
+
return sortFileChanges(await Promise.all(changes.map(async (change) => {
|
|
196
|
+
let beforePath;
|
|
197
|
+
if (change.kind === "added") beforePath = void 0;
|
|
198
|
+
else if (change.kind === "renamed") beforePath = change.previousPath;
|
|
199
|
+
else beforePath = change.path;
|
|
200
|
+
const afterPath = change.kind === "deleted" ? void 0 : change.path;
|
|
201
|
+
const [beforeMetadata, afterMetadata] = await Promise.all([beforePath === void 0 ? void 0 : getFileMetadata(beforeDir, beforePath, metadataCache), afterPath === void 0 ? void 0 : getFileMetadata(afterDir, afterPath, metadataCache)]);
|
|
202
|
+
return {
|
|
203
|
+
path: change.path,
|
|
204
|
+
previousPath: change.previousPath,
|
|
205
|
+
kind: change.kind,
|
|
206
|
+
beforeHash: beforeMetadata?.hash,
|
|
207
|
+
afterHash: afterMetadata?.hash,
|
|
208
|
+
beforeSize: beforeMetadata?.size,
|
|
209
|
+
afterSize: afterMetadata?.size
|
|
210
|
+
};
|
|
211
|
+
})));
|
|
212
|
+
};
|
|
213
|
+
const buildChangedFiles = (fileChanges) => {
|
|
214
|
+
const changedFiles = /* @__PURE__ */ new Set();
|
|
215
|
+
for (const change of fileChanges) {
|
|
216
|
+
changedFiles.add(change.path);
|
|
217
|
+
if (change.kind === "renamed" && change.previousPath) changedFiles.add(change.previousPath);
|
|
218
|
+
}
|
|
219
|
+
return [...changedFiles].sort((left, right) => left.localeCompare(right));
|
|
220
|
+
};
|
|
221
|
+
const wrapMaterializeError = (action, error) => {
|
|
222
|
+
if (error instanceof ContainerDiffError || error instanceof ContainerDisposedError || error instanceof ContainerNotRunningError) throw error;
|
|
223
|
+
throw new ContainerDiffError(`${action}: ${formatError(error)}`);
|
|
224
|
+
};
|
|
225
|
+
const copyLocalDirectoryContents = async (sourceDir, targetDir) => {
|
|
226
|
+
if (!(await stat(sourceDir)).isDirectory()) throw new ContainerDiffError(`Target path is not a directory: ${sourceDir}`);
|
|
227
|
+
await mkdir(targetDir, { recursive: true });
|
|
228
|
+
const entries = await readdir(sourceDir, { withFileTypes: true });
|
|
229
|
+
await Promise.all(entries.filter((entry) => entry.name !== ".git").map(async (entry) => {
|
|
230
|
+
const sourcePath = join(sourceDir, entry.name);
|
|
231
|
+
const targetPath = join(targetDir, entry.name);
|
|
232
|
+
if (entry.isDirectory()) {
|
|
233
|
+
await copyLocalDirectoryContents(sourcePath, targetPath);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (entry.isSymbolicLink()) {
|
|
237
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
238
|
+
await symlink(await readlink(sourcePath), targetPath);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (entry.isFile()) {
|
|
242
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
243
|
+
await copyFile(sourcePath, targetPath);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
throw new ContainerDiffError(`Unsupported filesystem entry in workdir diff: ${sourcePath}`);
|
|
247
|
+
}));
|
|
248
|
+
};
|
|
249
|
+
const createWorkdirDiffApi = (options) => {
|
|
250
|
+
const activeSnapshots = /* @__PURE__ */ new Set();
|
|
251
|
+
const snapshotMetadata = /* @__PURE__ */ new WeakMap();
|
|
252
|
+
const snapshotWorkdir = async (snapshotOptions = {}) => {
|
|
253
|
+
const cwd = snapshotOptions.cwd ?? options.workdir;
|
|
254
|
+
let tempDir;
|
|
255
|
+
try {
|
|
256
|
+
tempDir = await createTempTree();
|
|
257
|
+
await options.materialize(cwd, tempDir);
|
|
258
|
+
await removeGitMetadataDirs(tempDir);
|
|
259
|
+
const snapshotMeta = {
|
|
260
|
+
owner: options.owner,
|
|
261
|
+
tempDir,
|
|
262
|
+
cwd,
|
|
263
|
+
inFlightDiffs: 0,
|
|
264
|
+
released: false
|
|
265
|
+
};
|
|
266
|
+
activeSnapshots.add(snapshotMeta);
|
|
267
|
+
tempDir = void 0;
|
|
268
|
+
return createSnapshot(snapshotMeta, snapshotMetadata);
|
|
269
|
+
} catch (error) {
|
|
270
|
+
await cleanupTempTree(tempDir);
|
|
271
|
+
return wrapMaterializeError("Failed to materialize workdir snapshot", error);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const diffWorkdir = async (snapshot) => {
|
|
275
|
+
const startedAt = Date.now();
|
|
276
|
+
const snapshotMeta = getSnapshotMeta(options.owner, snapshot, snapshotMetadata);
|
|
277
|
+
assertSnapshotActive(snapshotMeta, activeSnapshots);
|
|
278
|
+
snapshotMeta.inFlightDiffs++;
|
|
279
|
+
let currentTempDir;
|
|
280
|
+
try {
|
|
281
|
+
currentTempDir = await createTempTree();
|
|
282
|
+
await options.materialize(snapshotMeta.cwd, currentTempDir);
|
|
283
|
+
await removeGitMetadataDirs(currentTempDir);
|
|
284
|
+
const fileChanges = await enrichFileChanges(await runGitDiff(snapshotMeta.tempDir, currentTempDir), snapshotMeta.tempDir, currentTempDir);
|
|
285
|
+
const changedFiles = buildChangedFiles(fileChanges);
|
|
286
|
+
return {
|
|
287
|
+
cwd: snapshotMeta.cwd,
|
|
288
|
+
changedFiles,
|
|
289
|
+
fileChanges,
|
|
290
|
+
stats: {
|
|
291
|
+
durationMs: Date.now() - startedAt,
|
|
292
|
+
filesCompared: changedFiles.length
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
} catch (error) {
|
|
296
|
+
return wrapMaterializeError("Failed to diff workdir snapshot", error);
|
|
297
|
+
} finally {
|
|
298
|
+
snapshotMeta.inFlightDiffs--;
|
|
299
|
+
if (snapshotMeta.inFlightDiffs === 0) {
|
|
300
|
+
snapshotMeta.resolveIdle?.();
|
|
301
|
+
snapshotMeta.resolveIdle = void 0;
|
|
302
|
+
}
|
|
303
|
+
await cleanupTempTree(currentTempDir);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const releaseSnapshot = (snapshotMeta) => {
|
|
307
|
+
const meta = snapshotMeta;
|
|
308
|
+
if (meta.releasePromise) return meta.releasePromise;
|
|
309
|
+
meta.released = true;
|
|
310
|
+
activeSnapshots.delete(meta);
|
|
311
|
+
meta.releasePromise = (async () => {
|
|
312
|
+
if (meta.inFlightDiffs > 0) await new Promise((resolve) => {
|
|
313
|
+
meta.resolveIdle = resolve;
|
|
314
|
+
});
|
|
315
|
+
await cleanupTempTree(meta.tempDir);
|
|
316
|
+
})();
|
|
317
|
+
return meta.releasePromise;
|
|
318
|
+
};
|
|
319
|
+
const releaseWorkdirSnapshot = async (snapshot) => {
|
|
320
|
+
await releaseSnapshot(getSnapshotMeta(options.owner, snapshot, snapshotMetadata));
|
|
321
|
+
};
|
|
322
|
+
const disposeSnapshots = async () => {
|
|
323
|
+
await Promise.all(Array.from(activeSnapshots).map(releaseSnapshot));
|
|
324
|
+
};
|
|
325
|
+
return {
|
|
326
|
+
snapshotWorkdir,
|
|
327
|
+
diffWorkdir,
|
|
328
|
+
releaseWorkdirSnapshot,
|
|
329
|
+
disposeSnapshots
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
//#endregion
|
|
333
|
+
export { isExecFileError as i, createWorkdirDiffApi as n, shellEscape as r, copyLocalDirectoryContents as t };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/container/errors.ts
|
|
2
|
+
var ContainerError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "ContainerError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var ContainerCreateError = class extends ContainerError {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "ContainerCreateError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var ContainerStartError = class extends ContainerError {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "ContainerStartError";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var ContainerExecError = class extends ContainerError {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "ContainerExecError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var ContainerNotRunningError = class extends ContainerError {
|
|
27
|
+
constructor(message = "Container is not running.") {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = "ContainerNotRunningError";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var ContainerDisposedError = class extends ContainerError {
|
|
33
|
+
constructor(message = "Container has been disposed.") {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "ContainerDisposedError";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var ContainerDiffError = class extends ContainerError {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "ContainerDiffError";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ContainerExecError as a, ContainerError as i, ContainerDiffError as n, ContainerNotRunningError as o, ContainerDisposedError as r, ContainerStartError as s, ContainerCreateError as t };
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { ZodType, z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas/agent.d.ts
|
|
4
|
+
declare const textContentPartSchema: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"text">;
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type TextContentPart = z.infer<typeof textContentPartSchema>;
|
|
9
|
+
declare const imageContentPartSchema: z.ZodObject<{
|
|
10
|
+
type: z.ZodLiteral<"image">;
|
|
11
|
+
path: z.ZodString;
|
|
12
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
type ImageContentPart = z.infer<typeof imageContentPartSchema>;
|
|
15
|
+
declare const contentPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"text">;
|
|
17
|
+
text: z.ZodString;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
+
type: z.ZodLiteral<"image">;
|
|
20
|
+
path: z.ZodString;
|
|
21
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>], "type">;
|
|
23
|
+
type ContentPart = z.infer<typeof contentPartSchema>;
|
|
24
|
+
declare const agentCapabilitiesSchema: z.ZodObject<{
|
|
25
|
+
structuredOutput: z.ZodBoolean;
|
|
26
|
+
sessionResume: z.ZodBoolean;
|
|
27
|
+
imageInput: z.ZodBoolean;
|
|
28
|
+
mcp: z.ZodBoolean;
|
|
29
|
+
eventStreaming: z.ZodBoolean;
|
|
30
|
+
sessionFork: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
type AgentCapabilities = z.infer<typeof agentCapabilitiesSchema>;
|
|
33
|
+
type JsonSchema = Record<string, unknown> | ReturnType<typeof z.toJSONSchema>;
|
|
34
|
+
type OutputSchema = JsonSchema | ZodType;
|
|
35
|
+
interface McpServerConfig {
|
|
36
|
+
command?: string;
|
|
37
|
+
args?: string[];
|
|
38
|
+
url?: string;
|
|
39
|
+
cwd?: string;
|
|
40
|
+
env?: Record<string, string>;
|
|
41
|
+
headers?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/schemas/events.d.ts
|
|
45
|
+
declare const baseEventSchema: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
runId: z.ZodString;
|
|
48
|
+
timestamp: z.ZodDate;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
declare const sessionStartEventSchema: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
runId: z.ZodString;
|
|
53
|
+
timestamp: z.ZodDate;
|
|
54
|
+
type: z.ZodLiteral<"session-start">;
|
|
55
|
+
requestedSessionId: z.ZodOptional<z.ZodString>;
|
|
56
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
resumed: z.ZodBoolean;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
type SessionStartEvent = z.infer<typeof sessionStartEventSchema>;
|
|
60
|
+
declare const messageEventSchema: z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
runId: z.ZodString;
|
|
63
|
+
timestamp: z.ZodDate;
|
|
64
|
+
type: z.ZodLiteral<"message">;
|
|
65
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
model: z.ZodNullable<z.ZodString>;
|
|
67
|
+
role: z.ZodEnum<{
|
|
68
|
+
system: "system";
|
|
69
|
+
user: "user";
|
|
70
|
+
assistant: "assistant";
|
|
71
|
+
}>;
|
|
72
|
+
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
73
|
+
type: z.ZodLiteral<"text">;
|
|
74
|
+
text: z.ZodString;
|
|
75
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
76
|
+
type: z.ZodLiteral<"image">;
|
|
77
|
+
path: z.ZodString;
|
|
78
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>], "type">>;
|
|
80
|
+
text: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
type MessageEvent = z.infer<typeof messageEventSchema>;
|
|
83
|
+
declare const reasoningEventSchema: z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
runId: z.ZodString;
|
|
86
|
+
timestamp: z.ZodDate;
|
|
87
|
+
type: z.ZodLiteral<"reasoning">;
|
|
88
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
89
|
+
model: z.ZodNullable<z.ZodString>;
|
|
90
|
+
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
91
|
+
type: z.ZodLiteral<"text">;
|
|
92
|
+
text: z.ZodString;
|
|
93
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"image">;
|
|
95
|
+
path: z.ZodString;
|
|
96
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strip>], "type">>;
|
|
98
|
+
text: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
type ReasoningEvent = z.infer<typeof reasoningEventSchema>;
|
|
101
|
+
declare const toolCallEventSchema: z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
runId: z.ZodString;
|
|
104
|
+
timestamp: z.ZodDate;
|
|
105
|
+
type: z.ZodLiteral<"tool-call">;
|
|
106
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
107
|
+
model: z.ZodNullable<z.ZodString>;
|
|
108
|
+
toolCallId: z.ZodString;
|
|
109
|
+
toolName: z.ZodString;
|
|
110
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
type ToolCallEvent = z.infer<typeof toolCallEventSchema>;
|
|
113
|
+
declare const toolResultEventSchema: z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
runId: z.ZodString;
|
|
116
|
+
timestamp: z.ZodDate;
|
|
117
|
+
type: z.ZodLiteral<"tool-result">;
|
|
118
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
119
|
+
toolCallId: z.ZodString;
|
|
120
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
121
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
122
|
+
output: z.ZodUnknown;
|
|
123
|
+
isError: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
error: z.ZodOptional<z.ZodString>;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
type ToolResultEvent = z.infer<typeof toolResultEventSchema>;
|
|
127
|
+
declare const stderrEventSchema: z.ZodObject<{
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
runId: z.ZodString;
|
|
130
|
+
timestamp: z.ZodDate;
|
|
131
|
+
type: z.ZodLiteral<"stderr">;
|
|
132
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
text: z.ZodString;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
type StderrEvent = z.infer<typeof stderrEventSchema>;
|
|
136
|
+
declare const sessionEndEventSchema: z.ZodObject<{
|
|
137
|
+
id: z.ZodString;
|
|
138
|
+
runId: z.ZodString;
|
|
139
|
+
timestamp: z.ZodDate;
|
|
140
|
+
type: z.ZodLiteral<"session-end">;
|
|
141
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
142
|
+
status: z.ZodEnum<{
|
|
143
|
+
completed: "completed";
|
|
144
|
+
failed: "failed";
|
|
145
|
+
cancelled: "cancelled";
|
|
146
|
+
}>;
|
|
147
|
+
error: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
type SessionEndEvent = z.infer<typeof sessionEndEventSchema>;
|
|
150
|
+
declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
151
|
+
id: z.ZodString;
|
|
152
|
+
runId: z.ZodString;
|
|
153
|
+
timestamp: z.ZodDate;
|
|
154
|
+
type: z.ZodLiteral<"session-start">;
|
|
155
|
+
requestedSessionId: z.ZodOptional<z.ZodString>;
|
|
156
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
157
|
+
resumed: z.ZodBoolean;
|
|
158
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
159
|
+
id: z.ZodString;
|
|
160
|
+
runId: z.ZodString;
|
|
161
|
+
timestamp: z.ZodDate;
|
|
162
|
+
type: z.ZodLiteral<"message">;
|
|
163
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
164
|
+
model: z.ZodNullable<z.ZodString>;
|
|
165
|
+
role: z.ZodEnum<{
|
|
166
|
+
system: "system";
|
|
167
|
+
user: "user";
|
|
168
|
+
assistant: "assistant";
|
|
169
|
+
}>;
|
|
170
|
+
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
171
|
+
type: z.ZodLiteral<"text">;
|
|
172
|
+
text: z.ZodString;
|
|
173
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
174
|
+
type: z.ZodLiteral<"image">;
|
|
175
|
+
path: z.ZodString;
|
|
176
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
177
|
+
}, z.core.$strip>], "type">>;
|
|
178
|
+
text: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
180
|
+
id: z.ZodString;
|
|
181
|
+
runId: z.ZodString;
|
|
182
|
+
timestamp: z.ZodDate;
|
|
183
|
+
type: z.ZodLiteral<"reasoning">;
|
|
184
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
185
|
+
model: z.ZodNullable<z.ZodString>;
|
|
186
|
+
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
187
|
+
type: z.ZodLiteral<"text">;
|
|
188
|
+
text: z.ZodString;
|
|
189
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
190
|
+
type: z.ZodLiteral<"image">;
|
|
191
|
+
path: z.ZodString;
|
|
192
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, z.core.$strip>], "type">>;
|
|
194
|
+
text: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
196
|
+
id: z.ZodString;
|
|
197
|
+
runId: z.ZodString;
|
|
198
|
+
timestamp: z.ZodDate;
|
|
199
|
+
type: z.ZodLiteral<"tool-call">;
|
|
200
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
201
|
+
model: z.ZodNullable<z.ZodString>;
|
|
202
|
+
toolCallId: z.ZodString;
|
|
203
|
+
toolName: z.ZodString;
|
|
204
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
205
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
206
|
+
id: z.ZodString;
|
|
207
|
+
runId: z.ZodString;
|
|
208
|
+
timestamp: z.ZodDate;
|
|
209
|
+
type: z.ZodLiteral<"tool-result">;
|
|
210
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
211
|
+
toolCallId: z.ZodString;
|
|
212
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
213
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
214
|
+
output: z.ZodUnknown;
|
|
215
|
+
isError: z.ZodOptional<z.ZodBoolean>;
|
|
216
|
+
error: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
218
|
+
id: z.ZodString;
|
|
219
|
+
runId: z.ZodString;
|
|
220
|
+
timestamp: z.ZodDate;
|
|
221
|
+
type: z.ZodLiteral<"stderr">;
|
|
222
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
223
|
+
text: z.ZodString;
|
|
224
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
225
|
+
id: z.ZodString;
|
|
226
|
+
runId: z.ZodString;
|
|
227
|
+
timestamp: z.ZodDate;
|
|
228
|
+
type: z.ZodLiteral<"session-end">;
|
|
229
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
230
|
+
status: z.ZodEnum<{
|
|
231
|
+
completed: "completed";
|
|
232
|
+
failed: "failed";
|
|
233
|
+
cancelled: "cancelled";
|
|
234
|
+
}>;
|
|
235
|
+
error: z.ZodOptional<z.ZodString>;
|
|
236
|
+
}, z.core.$strip>], "type">;
|
|
237
|
+
type AgentEvent = z.infer<typeof eventSchema>;
|
|
238
|
+
//#endregion
|
|
239
|
+
export { OutputSchema as C, imageContentPartSchema as D, contentPartSchema as E, textContentPartSchema as O, McpServerConfig as S, agentCapabilitiesSchema as T, toolResultEventSchema as _, SessionStartEvent as a, ImageContentPart as b, ToolResultEvent as c, messageEventSchema as d, reasoningEventSchema as f, toolCallEventSchema as g, stderrEventSchema as h, SessionEndEvent as i, baseEventSchema as l, sessionStartEventSchema as m, MessageEvent as n, StderrEvent as o, sessionEndEventSchema as p, ReasoningEvent as r, ToolCallEvent as s, AgentEvent as t, eventSchema as u, AgentCapabilities as v, TextContentPart as w, JsonSchema as x, ContentPart as y };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { S as McpServerConfig } from "./events-nxuRbYIu.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-Cb_EXIEe.mjs";
|
|
3
|
+
//#region src/adapters/claude-code-sdk/types.d.ts
|
|
4
|
+
type ClaudeCodeSdkPermissionMode = "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "plan";
|
|
5
|
+
type ClaudeCodeSdkExecutable = "bun" | "deno" | "node";
|
|
6
|
+
type ClaudeCodeSdkSettingSource = "local" | "project" | "user";
|
|
7
|
+
type ClaudeCodeSdkSettings = Record<string, unknown> | string;
|
|
8
|
+
interface ClaudeCodeSdkRunOptions {
|
|
9
|
+
allowedTools?: string[];
|
|
10
|
+
disallowedTools?: string[];
|
|
11
|
+
appendSystemPrompt?: string;
|
|
12
|
+
permissionMode?: ClaudeCodeSdkPermissionMode;
|
|
13
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
14
|
+
forkSession?: boolean;
|
|
15
|
+
maxTurns?: number;
|
|
16
|
+
}
|
|
17
|
+
interface ClaudeCodeSdkAgentOptions extends ClaudeCodeSdkRunOptions {
|
|
18
|
+
command?: string;
|
|
19
|
+
env?: Record<string, string | undefined>;
|
|
20
|
+
propagateEnv?: boolean;
|
|
21
|
+
executable?: ClaudeCodeSdkExecutable;
|
|
22
|
+
executableArgs?: string[];
|
|
23
|
+
settings?: ClaudeCodeSdkSettings;
|
|
24
|
+
settingSources?: ClaudeCodeSdkSettingSource[];
|
|
25
|
+
container?: never;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
systemPrompt?: string;
|
|
30
|
+
onEvent?: AgentEventHandler;
|
|
31
|
+
}
|
|
32
|
+
interface ClaudeCodeSdkAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeSdkRunOptions>> {
|
|
33
|
+
readonly type: "claude-code-sdk";
|
|
34
|
+
fork: () => ClaudeCodeSdkAgent;
|
|
35
|
+
}
|
|
36
|
+
interface ClaudeCodeSdkEvent {
|
|
37
|
+
type: string;
|
|
38
|
+
session_id?: string;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/adapters/claude-code-sdk/adapter.d.ts
|
|
43
|
+
declare const createClaudeCodeSdkAgent: (options?: ClaudeCodeSdkAgentOptions) => ClaudeCodeSdkAgent;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ClaudeCodeSdkExecutable as a, ClaudeCodeSdkSettingSource as c, ClaudeCodeSdkEvent as i, ClaudeCodeSdkSettings as l, ClaudeCodeSdkAgent as n, ClaudeCodeSdkPermissionMode as o, ClaudeCodeSdkAgentOptions as r, ClaudeCodeSdkRunOptions as s, createClaudeCodeSdkAgent as t };
|