zidane 4.0.2 → 4.1.3
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 +196 -614
- package/dist/agent-BoV5Twdl.d.ts +2347 -0
- package/dist/agent-BoV5Twdl.d.ts.map +1 -0
- package/dist/contexts-3Arvn7yR.js +321 -0
- package/dist/contexts-3Arvn7yR.js.map +1 -0
- package/dist/contexts.d.ts +2 -25
- package/dist/contexts.js +2 -10
- package/dist/errors-D1lhd6mX.js +118 -0
- package/dist/errors-D1lhd6mX.js.map +1 -0
- package/dist/index-28otmfLX.d.ts +400 -0
- package/dist/index-28otmfLX.d.ts.map +1 -0
- package/dist/index-BfSdALzk.d.ts +113 -0
- package/dist/index-BfSdALzk.d.ts.map +1 -0
- package/dist/index-DPsd0qwm.d.ts +254 -0
- package/dist/index-DPsd0qwm.d.ts.map +1 -0
- package/dist/index.d.ts +5 -95
- package/dist/index.js +141 -271
- package/dist/index.js.map +1 -0
- package/dist/interpolate-CukJwP2G.js +887 -0
- package/dist/interpolate-CukJwP2G.js.map +1 -0
- package/dist/mcp-8wClKY-3.js +771 -0
- package/dist/mcp-8wClKY-3.js.map +1 -0
- package/dist/mcp.d.ts +2 -4
- package/dist/mcp.js +2 -13
- package/dist/messages-z5Pq20p7.js +1020 -0
- package/dist/messages-z5Pq20p7.js.map +1 -0
- package/dist/presets-Cs7_CsMk.js +39 -0
- package/dist/presets-Cs7_CsMk.js.map +1 -0
- package/dist/presets.d.ts +2 -43
- package/dist/presets.js +2 -17
- package/dist/providers-CX-R-Oy-.js +969 -0
- package/dist/providers-CX-R-Oy-.js.map +1 -0
- package/dist/providers.d.ts +2 -4
- package/dist/providers.js +3 -23
- package/dist/session/sqlite.d.ts +7 -12
- package/dist/session/sqlite.d.ts.map +1 -0
- package/dist/session/sqlite.js +67 -79
- package/dist/session/sqlite.js.map +1 -0
- package/dist/session-Cn68UASv.js +440 -0
- package/dist/session-Cn68UASv.js.map +1 -0
- package/dist/session.d.ts +2 -4
- package/dist/session.js +3 -27
- package/dist/skills.d.ts +3 -322
- package/dist/skills.js +24 -47
- package/dist/skills.js.map +1 -0
- package/dist/stats-DoKUtF5T.js +58 -0
- package/dist/stats-DoKUtF5T.js.map +1 -0
- package/dist/tools-DpeWKzP1.js +3941 -0
- package/dist/tools-DpeWKzP1.js.map +1 -0
- package/dist/tools.d.ts +3 -95
- package/dist/tools.js +2 -40
- package/dist/tui.d.ts +533 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +2004 -0
- package/dist/tui.js.map +1 -0
- package/dist/types-Bx_F8jet.js +39 -0
- package/dist/types-Bx_F8jet.js.map +1 -0
- package/dist/types.d.ts +4 -55
- package/dist/types.js +4 -28
- package/package.json +38 -4
- package/dist/agent-BAHrGtqu.d.ts +0 -2425
- package/dist/chunk-4ILGBQ23.js +0 -803
- package/dist/chunk-4LPBN547.js +0 -3540
- package/dist/chunk-64LLNY7F.js +0 -28
- package/dist/chunk-6STZTA4N.js +0 -830
- package/dist/chunk-7GQ7P6DM.js +0 -566
- package/dist/chunk-IC7FT4OD.js +0 -37
- package/dist/chunk-JCOB6IYO.js +0 -22
- package/dist/chunk-JH6IAAFA.js +0 -28
- package/dist/chunk-LNN5UTS2.js +0 -97
- package/dist/chunk-PMCQOMV4.js +0 -490
- package/dist/chunk-UD25QF3H.js +0 -304
- package/dist/chunk-W57VY6DJ.js +0 -834
- package/dist/sandbox-D7v6Wy62.d.ts +0 -28
- package/dist/skills-use-DwZrNmcw.d.ts +0 -80
- package/dist/types-Bai5rKpa.d.ts +0 -89
- package/dist/validation-Pm--dQEU.d.ts +0 -185
package/dist/chunk-UD25QF3H.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
// src/contexts/docker.ts
|
|
2
|
-
var SINGLE_QUOTE_RE = /'/g;
|
|
3
|
-
function createDockerContext(config) {
|
|
4
|
-
let counter = 0;
|
|
5
|
-
const containers = /* @__PURE__ */ new Map();
|
|
6
|
-
const defaultImage = config?.image ?? "oven/bun:latest";
|
|
7
|
-
const defaultCwd = config?.cwd ?? "/workspace";
|
|
8
|
-
const defaultEnv = config?.env;
|
|
9
|
-
const defaultLimits = config?.limits;
|
|
10
|
-
async function getDockerode() {
|
|
11
|
-
try {
|
|
12
|
-
const Dockerode = (await import("dockerode")).default;
|
|
13
|
-
return new Dockerode();
|
|
14
|
-
} catch {
|
|
15
|
-
throw new Error("dockerode is required for Docker execution context. Install it with: bun add dockerode");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const ctx = {
|
|
19
|
-
type: "docker",
|
|
20
|
-
capabilities: {
|
|
21
|
-
shell: true,
|
|
22
|
-
filesystem: true,
|
|
23
|
-
network: true,
|
|
24
|
-
gpu: false
|
|
25
|
-
},
|
|
26
|
-
async spawn(overrides) {
|
|
27
|
-
const docker = await getDockerode();
|
|
28
|
-
const id = `docker-${++counter}`;
|
|
29
|
-
const image = overrides?.image ?? defaultImage;
|
|
30
|
-
const cwd = overrides?.cwd ?? defaultCwd;
|
|
31
|
-
try {
|
|
32
|
-
await docker.getImage(image).inspect();
|
|
33
|
-
} catch {
|
|
34
|
-
await new Promise((resolve2, reject) => {
|
|
35
|
-
docker.pull(image, (err, stream) => {
|
|
36
|
-
if (err)
|
|
37
|
-
return reject(err);
|
|
38
|
-
docker.modem.followProgress(stream, (err2) => {
|
|
39
|
-
err2 ? reject(err2) : resolve2();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const limits = { ...defaultLimits, ...overrides?.limits };
|
|
45
|
-
const hostConfig = {};
|
|
46
|
-
if (limits?.memory) {
|
|
47
|
-
hostConfig.Memory = limits.memory * 1024 * 1024;
|
|
48
|
-
}
|
|
49
|
-
if (limits?.cpu) {
|
|
50
|
-
hostConfig.NanoCpus = Number.parseFloat(limits.cpu) * 1e9;
|
|
51
|
-
}
|
|
52
|
-
const env = { ...defaultEnv, ...overrides?.env };
|
|
53
|
-
const container = await docker.createContainer({
|
|
54
|
-
Image: image,
|
|
55
|
-
Cmd: ["sleep", "infinity"],
|
|
56
|
-
WorkingDir: cwd,
|
|
57
|
-
Env: Object.entries(env).map(([k, v]) => `${k}=${v}`),
|
|
58
|
-
HostConfig: hostConfig
|
|
59
|
-
});
|
|
60
|
-
await container.start();
|
|
61
|
-
const handle = { id, type: "docker", cwd };
|
|
62
|
-
containers.set(id, { handle, container, docker });
|
|
63
|
-
return handle;
|
|
64
|
-
},
|
|
65
|
-
async exec(handle, command, options) {
|
|
66
|
-
const ref = containers.get(handle.id);
|
|
67
|
-
if (!ref)
|
|
68
|
-
throw new Error(`Container ${handle.id} not found`);
|
|
69
|
-
const execCwd = options?.cwd ?? handle.cwd;
|
|
70
|
-
const env = options?.env ? Object.entries(options.env).map(([k, v]) => `${k}=${v}`) : [];
|
|
71
|
-
const exec = await ref.container.exec({
|
|
72
|
-
Cmd: ["sh", "-c", command],
|
|
73
|
-
WorkingDir: execCwd,
|
|
74
|
-
Env: env,
|
|
75
|
-
AttachStdout: true,
|
|
76
|
-
AttachStderr: true
|
|
77
|
-
});
|
|
78
|
-
const stream = await exec.start({ Detach: false });
|
|
79
|
-
return new Promise((resolve2) => {
|
|
80
|
-
let stdout = "";
|
|
81
|
-
let stderr = "";
|
|
82
|
-
let resolved = false;
|
|
83
|
-
const stdoutSink = {
|
|
84
|
-
write(chunk) {
|
|
85
|
-
stdout += typeof chunk === "string" ? chunk : chunk.toString("utf-8");
|
|
86
|
-
return true;
|
|
87
|
-
},
|
|
88
|
-
end() {
|
|
89
|
-
},
|
|
90
|
-
on() {
|
|
91
|
-
},
|
|
92
|
-
once() {
|
|
93
|
-
},
|
|
94
|
-
emit() {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const stderrSink = {
|
|
99
|
-
write(chunk) {
|
|
100
|
-
stderr += typeof chunk === "string" ? chunk : chunk.toString("utf-8");
|
|
101
|
-
return true;
|
|
102
|
-
},
|
|
103
|
-
end() {
|
|
104
|
-
},
|
|
105
|
-
on() {
|
|
106
|
-
},
|
|
107
|
-
once() {
|
|
108
|
-
},
|
|
109
|
-
emit() {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
try {
|
|
114
|
-
ref.docker.modem.demuxStream(stream, stdoutSink, stderrSink);
|
|
115
|
-
} catch {
|
|
116
|
-
stream.on("data", (chunk) => {
|
|
117
|
-
stdout += chunk.toString("utf-8");
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
const timeout = options?.timeout ?? defaultLimits?.timeout ?? 30;
|
|
121
|
-
const timer = setTimeout(() => {
|
|
122
|
-
if (resolved)
|
|
123
|
-
return;
|
|
124
|
-
resolved = true;
|
|
125
|
-
try {
|
|
126
|
-
stream.destroy?.();
|
|
127
|
-
} catch {
|
|
128
|
-
}
|
|
129
|
-
resolve2({ stdout, stderr: stderr ? `${stderr}
|
|
130
|
-
[timeout]` : "[timeout]", exitCode: 124 });
|
|
131
|
-
}, timeout * 1e3);
|
|
132
|
-
stream.on("end", async () => {
|
|
133
|
-
if (resolved)
|
|
134
|
-
return;
|
|
135
|
-
resolved = true;
|
|
136
|
-
clearTimeout(timer);
|
|
137
|
-
let exitCode = 0;
|
|
138
|
-
try {
|
|
139
|
-
const inspect = await exec.inspect();
|
|
140
|
-
exitCode = inspect.ExitCode ?? 0;
|
|
141
|
-
} catch {
|
|
142
|
-
}
|
|
143
|
-
resolve2({ stdout, stderr, exitCode });
|
|
144
|
-
});
|
|
145
|
-
stream.on("error", (err) => {
|
|
146
|
-
if (resolved)
|
|
147
|
-
return;
|
|
148
|
-
resolved = true;
|
|
149
|
-
clearTimeout(timer);
|
|
150
|
-
resolve2({ stdout, stderr: stderr ? `${stderr}
|
|
151
|
-
${err.message}` : err.message, exitCode: 1 });
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
},
|
|
155
|
-
async readFile(handle, path) {
|
|
156
|
-
const result = await ctx.exec(handle, `cat ${JSON.stringify(path)}`);
|
|
157
|
-
if (result.exitCode !== 0)
|
|
158
|
-
throw new Error(`Failed to read file: ${result.stderr}`);
|
|
159
|
-
return result.stdout;
|
|
160
|
-
},
|
|
161
|
-
async writeFile(handle, path, content) {
|
|
162
|
-
const escaped = content.replace(SINGLE_QUOTE_RE, String.raw`'\''`);
|
|
163
|
-
const result = await ctx.exec(handle, `mkdir -p "$(dirname ${JSON.stringify(path)})" && printf '%s' '${escaped}' > ${JSON.stringify(path)}`);
|
|
164
|
-
if (result.exitCode !== 0)
|
|
165
|
-
throw new Error(`Failed to write file: ${result.stderr}`);
|
|
166
|
-
},
|
|
167
|
-
async listFiles(handle, path) {
|
|
168
|
-
const result = await ctx.exec(handle, `ls -1 ${JSON.stringify(path)}`);
|
|
169
|
-
if (result.exitCode !== 0)
|
|
170
|
-
return [];
|
|
171
|
-
return result.stdout.trim().split("\n").filter(Boolean);
|
|
172
|
-
},
|
|
173
|
-
async destroy(handle) {
|
|
174
|
-
const ref = containers.get(handle.id);
|
|
175
|
-
if (!ref)
|
|
176
|
-
return;
|
|
177
|
-
try {
|
|
178
|
-
await ref.container.stop({ t: 5 });
|
|
179
|
-
await ref.container.remove({ force: true });
|
|
180
|
-
} catch {
|
|
181
|
-
}
|
|
182
|
-
containers.delete(handle.id);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
return ctx;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// src/contexts/process.ts
|
|
189
|
-
import { exec as execCb } from "child_process";
|
|
190
|
-
import { mkdir, readdir, readFile, writeFile } from "fs/promises";
|
|
191
|
-
import { dirname, resolve } from "path";
|
|
192
|
-
import { promisify } from "util";
|
|
193
|
-
var execAsync = promisify(execCb);
|
|
194
|
-
function createProcessContext(config) {
|
|
195
|
-
let counter = 0;
|
|
196
|
-
const handles = /* @__PURE__ */ new Map();
|
|
197
|
-
const defaultCwd = config?.cwd ?? process.cwd();
|
|
198
|
-
const defaultEnv = config?.env;
|
|
199
|
-
return {
|
|
200
|
-
type: "process",
|
|
201
|
-
capabilities: {
|
|
202
|
-
shell: true,
|
|
203
|
-
filesystem: true,
|
|
204
|
-
network: true,
|
|
205
|
-
gpu: false
|
|
206
|
-
},
|
|
207
|
-
async spawn(overrides) {
|
|
208
|
-
const id = `process-${++counter}`;
|
|
209
|
-
const cwd = overrides?.cwd ?? defaultCwd;
|
|
210
|
-
await mkdir(cwd, { recursive: true });
|
|
211
|
-
const handle = { id, type: "process", cwd };
|
|
212
|
-
handles.set(id, handle);
|
|
213
|
-
return handle;
|
|
214
|
-
},
|
|
215
|
-
async exec(handle, command, options) {
|
|
216
|
-
const cwd = options?.cwd ? resolve(handle.cwd, options.cwd) : handle.cwd;
|
|
217
|
-
try {
|
|
218
|
-
const { stdout, stderr } = await execAsync(command, {
|
|
219
|
-
cwd,
|
|
220
|
-
env: { ...process.env, ...defaultEnv, ...options?.env },
|
|
221
|
-
timeout: (options?.timeout ?? config?.limits?.timeout ?? 30) * 1e3,
|
|
222
|
-
maxBuffer: 10 * 1024 * 1024
|
|
223
|
-
});
|
|
224
|
-
return { stdout, stderr, exitCode: 0 };
|
|
225
|
-
} catch (err) {
|
|
226
|
-
const e = err;
|
|
227
|
-
return {
|
|
228
|
-
stdout: typeof e.stdout === "string" ? e.stdout : "",
|
|
229
|
-
stderr: typeof e.stderr === "string" ? e.stderr : typeof e.message === "string" ? e.message : String(err),
|
|
230
|
-
exitCode: typeof e.code === "number" ? e.code : 1
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
async readFile(handle, path) {
|
|
235
|
-
return readFile(resolve(handle.cwd, path), "utf-8");
|
|
236
|
-
},
|
|
237
|
-
async readFileBinary(handle, path) {
|
|
238
|
-
const buf = await readFile(resolve(handle.cwd, path));
|
|
239
|
-
return new Uint8Array(buf);
|
|
240
|
-
},
|
|
241
|
-
async writeFile(handle, path, content) {
|
|
242
|
-
const fullPath = resolve(handle.cwd, path);
|
|
243
|
-
await mkdir(dirname(fullPath), { recursive: true });
|
|
244
|
-
await writeFile(fullPath, content, "utf-8");
|
|
245
|
-
},
|
|
246
|
-
async listFiles(handle, path) {
|
|
247
|
-
return readdir(resolve(handle.cwd, path));
|
|
248
|
-
},
|
|
249
|
-
async destroy(handle) {
|
|
250
|
-
handles.delete(handle.id);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// src/contexts/sandbox.ts
|
|
256
|
-
function createSandboxContext(provider) {
|
|
257
|
-
const sandboxes = /* @__PURE__ */ new Map();
|
|
258
|
-
function getSandboxId(handle) {
|
|
259
|
-
const id = sandboxes.get(handle.id);
|
|
260
|
-
if (!id)
|
|
261
|
-
throw new Error(`Sandbox ${handle.id} not found`);
|
|
262
|
-
return id;
|
|
263
|
-
}
|
|
264
|
-
return {
|
|
265
|
-
type: "sandbox",
|
|
266
|
-
capabilities: {
|
|
267
|
-
shell: true,
|
|
268
|
-
filesystem: true,
|
|
269
|
-
network: true,
|
|
270
|
-
gpu: false
|
|
271
|
-
},
|
|
272
|
-
async spawn(config) {
|
|
273
|
-
const result = await provider.spawn(config ?? {});
|
|
274
|
-
const handle = { id: result.id, type: "sandbox", cwd: result.cwd };
|
|
275
|
-
sandboxes.set(handle.id, result.id);
|
|
276
|
-
return handle;
|
|
277
|
-
},
|
|
278
|
-
async exec(handle, command, options) {
|
|
279
|
-
return provider.exec(getSandboxId(handle), command, options);
|
|
280
|
-
},
|
|
281
|
-
async readFile(handle, path) {
|
|
282
|
-
return provider.readFile(getSandboxId(handle), path);
|
|
283
|
-
},
|
|
284
|
-
async writeFile(handle, path, content) {
|
|
285
|
-
return provider.writeFile(getSandboxId(handle), path, content);
|
|
286
|
-
},
|
|
287
|
-
async listFiles(handle, path) {
|
|
288
|
-
return provider.listFiles(getSandboxId(handle), path);
|
|
289
|
-
},
|
|
290
|
-
async destroy(handle) {
|
|
291
|
-
const id = sandboxes.get(handle.id);
|
|
292
|
-
if (!id)
|
|
293
|
-
return;
|
|
294
|
-
await provider.destroy(id);
|
|
295
|
-
sandboxes.delete(handle.id);
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export {
|
|
301
|
-
createDockerContext,
|
|
302
|
-
createProcessContext,
|
|
303
|
-
createSandboxContext
|
|
304
|
-
};
|