zidane 2.0.1 → 2.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 +40 -26
- package/dist/{agent-D-ZFMbSd.d.ts → agent-vPBFXnu-.d.ts} +389 -274
- package/dist/{chunk-SZA4FKW5.js → chunk-2EQT4EHD.js} +4 -3
- package/dist/{chunk-PJUUYBKF.js → chunk-37GD7NL3.js} +45 -16
- package/dist/{chunk-LVC7NQUZ.js → chunk-BW3WTFIR.js} +1 -1
- package/dist/{chunk-FRNFVKWW.js → chunk-CDRXC7A7.js} +64 -33
- package/dist/{chunk-PASFWG7S.js → chunk-F5UBXERT.js} +309 -77
- package/dist/{chunk-7JTBBZ2U.js → chunk-LNN5UTS2.js} +8 -0
- package/dist/{chunk-VG2E6YK3.js → chunk-PMCQOMV4.js} +4 -2
- package/dist/{chunk-LN4LLLHA.js → chunk-S3FCOMRI.js} +63 -20
- package/dist/{chunk-OVQ4N64O.js → chunk-SP5NA6WF.js} +6 -12
- package/dist/{chunk-BCXXXJ3G.js → chunk-TPXPVEH6.js} +99 -58
- package/dist/contexts.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +16 -16
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +1 -1
- package/dist/presets.d.ts +33 -0
- package/dist/presets.js +15 -0
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +3 -3
- package/dist/session/sqlite.d.ts +1 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +3 -3
- package/dist/{skills-use-C4KFVla0.d.ts → skills-use-39cCsA7_.d.ts} +4 -4
- package/dist/skills.d.ts +3 -9
- package/dist/skills.js +3 -5
- package/dist/spawn-Czx3owjX.d.ts +152 -0
- package/dist/tools.d.ts +6 -4
- package/dist/tools.js +5 -5
- package/dist/types.d.ts +3 -2
- package/dist/types.js +1 -1
- package/package.json +5 -5
- package/dist/harnesses.d.ts +0 -4
- package/dist/harnesses.js +0 -17
- package/dist/spawn-RoqpjYLZ.d.ts +0 -99
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
matchesContextExceeded
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LNN5UTS2.js";
|
|
4
4
|
|
|
5
5
|
// src/providers/openai-compat.ts
|
|
6
6
|
var TOOL_RESULTS_TAG = "__zidane_tool_results__";
|
|
7
7
|
var ASSISTANT_TOOL_CALLS_TAG = "__zidane_assistant_tc__";
|
|
8
|
+
var SSE_MAX_BUFFER_BYTES = 8 * 1024 * 1024;
|
|
9
|
+
var OpenAICompatStreamError = class extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "OpenAICompatStreamError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
async function consumeSSE(response, callbacks, signal) {
|
|
9
16
|
const reader = response.body.getReader();
|
|
10
17
|
const decoder = new TextDecoder();
|
|
@@ -22,6 +29,11 @@ async function consumeSSE(response, callbacks, signal) {
|
|
|
22
29
|
if (done)
|
|
23
30
|
break;
|
|
24
31
|
buffer += decoder.decode(value, { stream: true });
|
|
32
|
+
if (buffer.length > SSE_MAX_BUFFER_BYTES) {
|
|
33
|
+
throw new OpenAICompatStreamError(
|
|
34
|
+
`SSE buffer exceeded ${SSE_MAX_BUFFER_BYTES} bytes without a line boundary \u2014 upstream may be streaming non-SSE data.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
25
37
|
const lines = buffer.split("\n");
|
|
26
38
|
buffer = lines.pop() || "";
|
|
27
39
|
for (const line of lines) {
|
|
@@ -36,22 +48,27 @@ async function consumeSSE(response, callbacks, signal) {
|
|
|
36
48
|
} catch {
|
|
37
49
|
continue;
|
|
38
50
|
}
|
|
39
|
-
const
|
|
51
|
+
const choices = chunk.choices;
|
|
52
|
+
const choice = choices?.[0];
|
|
40
53
|
if (!choice)
|
|
41
54
|
continue;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
const fr = choice.finish_reason;
|
|
56
|
+
if (fr)
|
|
57
|
+
finishReason = fr;
|
|
58
|
+
const delta = choice.delta;
|
|
59
|
+
const thinkingDelta = delta?.reasoning_content ?? delta?.reasoning;
|
|
45
60
|
if (thinkingDelta) {
|
|
46
61
|
thinking += thinkingDelta;
|
|
47
62
|
callbacks.onThinking?.(thinkingDelta);
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
const contentDelta = delta?.content;
|
|
65
|
+
if (contentDelta) {
|
|
66
|
+
text += contentDelta;
|
|
67
|
+
callbacks.onText(contentDelta);
|
|
52
68
|
}
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
const toolCallsDelta = delta?.tool_calls;
|
|
70
|
+
if (toolCallsDelta) {
|
|
71
|
+
for (const tc of toolCallsDelta) {
|
|
55
72
|
const existing = tcMap.get(tc.index);
|
|
56
73
|
if (existing) {
|
|
57
74
|
if (tc.function?.arguments)
|
|
@@ -65,11 +82,12 @@ async function consumeSSE(response, callbacks, signal) {
|
|
|
65
82
|
}
|
|
66
83
|
}
|
|
67
84
|
}
|
|
68
|
-
|
|
85
|
+
const chunkUsage = chunk.usage;
|
|
86
|
+
if (chunkUsage) {
|
|
69
87
|
usage = {
|
|
70
|
-
input:
|
|
71
|
-
output:
|
|
72
|
-
cost:
|
|
88
|
+
input: chunkUsage.prompt_tokens ?? 0,
|
|
89
|
+
output: chunkUsage.completion_tokens ?? 0,
|
|
90
|
+
cost: chunkUsage.total_cost ?? void 0
|
|
73
91
|
};
|
|
74
92
|
}
|
|
75
93
|
}
|
|
@@ -77,11 +95,20 @@ async function consumeSSE(response, callbacks, signal) {
|
|
|
77
95
|
} finally {
|
|
78
96
|
reader.releaseLock();
|
|
79
97
|
}
|
|
80
|
-
const toolCalls =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
const toolCalls = [];
|
|
99
|
+
for (const tc of tcMap.values()) {
|
|
100
|
+
if (!tc.args) {
|
|
101
|
+
toolCalls.push({ id: tc.id, name: tc.name, input: {} });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
toolCalls.push({ id: tc.id, name: tc.name, input: JSON.parse(tc.args) });
|
|
106
|
+
} catch (err) {
|
|
107
|
+
throw new OpenAICompatStreamError(
|
|
108
|
+
`Tool call "${tc.name}" (${tc.id}) arguments were truncated or malformed: ${err.message}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
85
112
|
return { text, thinking, toolCalls, finishReason, usage };
|
|
86
113
|
}
|
|
87
114
|
function toImageUrlPart(img) {
|
|
@@ -249,6 +276,14 @@ function classifyOpenAICompatError(err) {
|
|
|
249
276
|
return null;
|
|
250
277
|
if (err.name === "AbortError")
|
|
251
278
|
return { kind: "aborted" };
|
|
279
|
+
if (err instanceof OpenAICompatStreamError) {
|
|
280
|
+
return {
|
|
281
|
+
kind: "provider_error",
|
|
282
|
+
providerCode: "stream_error",
|
|
283
|
+
message: err.message,
|
|
284
|
+
retryable: true
|
|
285
|
+
};
|
|
286
|
+
}
|
|
252
287
|
if (!(err instanceof OpenAICompatHttpError))
|
|
253
288
|
return null;
|
|
254
289
|
const code = err.providerCode;
|
|
@@ -263,9 +298,17 @@ function classifyOpenAICompatError(err) {
|
|
|
263
298
|
return {
|
|
264
299
|
kind: "provider_error",
|
|
265
300
|
providerCode: code ?? String(err.status),
|
|
266
|
-
message: msg
|
|
301
|
+
message: msg,
|
|
302
|
+
retryable: isRetryableHttpStatus(err.status)
|
|
267
303
|
};
|
|
268
304
|
}
|
|
305
|
+
function isRetryableHttpStatus(status) {
|
|
306
|
+
if (status === 429)
|
|
307
|
+
return true;
|
|
308
|
+
if (status >= 500 && status !== 501)
|
|
309
|
+
return true;
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
269
312
|
function mapOAIFinishReason(reason) {
|
|
270
313
|
if (!reason)
|
|
271
314
|
return void 0;
|
|
@@ -4,29 +4,23 @@ import {
|
|
|
4
4
|
shell,
|
|
5
5
|
spawn,
|
|
6
6
|
writeFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-F5UBXERT.js";
|
|
8
8
|
|
|
9
|
-
// src/
|
|
9
|
+
// src/presets/basic.ts
|
|
10
10
|
var basicTools = { shell, readFile, writeFile, listFiles };
|
|
11
|
-
var basic_default =
|
|
11
|
+
var basic_default = definePreset({
|
|
12
12
|
name: "basic",
|
|
13
13
|
system: "You are a helpful assistant with access to shell, file reading, file writing, directory listing, and sub-agent spawning tools. Use them to accomplish tasks in the project directory.",
|
|
14
14
|
tools: { ...basicTools, spawn }
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
// src/
|
|
18
|
-
function
|
|
17
|
+
// src/presets/index.ts
|
|
18
|
+
function definePreset(config) {
|
|
19
19
|
return config;
|
|
20
20
|
}
|
|
21
|
-
var noTools = defineHarness({
|
|
22
|
-
name: "none",
|
|
23
|
-
system: "You are a helpful assistant.",
|
|
24
|
-
tools: {}
|
|
25
|
-
});
|
|
26
21
|
|
|
27
22
|
export {
|
|
28
23
|
basicTools,
|
|
29
24
|
basic_default,
|
|
30
|
-
|
|
31
|
-
noTools
|
|
25
|
+
definePreset
|
|
32
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentToolNotAllowedError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LNN5UTS2.js";
|
|
4
4
|
|
|
5
5
|
// src/skills/activation.ts
|
|
6
6
|
function createSkillActivationState(options = {}) {
|
|
@@ -328,10 +328,12 @@ function escapeXml(str) {
|
|
|
328
328
|
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
329
329
|
import { homedir } from "os";
|
|
330
330
|
import { basename as basename2, dirname, join, resolve } from "path";
|
|
331
|
-
var FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/;
|
|
331
|
+
var FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
332
332
|
var INDENT_RE = /^[ \t]{2,}/;
|
|
333
333
|
var KV_RE = /^([^:]+):(.*)$/;
|
|
334
|
-
var
|
|
334
|
+
var DOUBLE_QUOTED_RE = /^"((?:\\.|[^"\\])*)"$/;
|
|
335
|
+
var SINGLE_QUOTED_RE = /^'((?:''|[^'])*)'$/;
|
|
336
|
+
var DQ_ESCAPE_RE = /\\(["\\/bfnrt])/g;
|
|
335
337
|
var WHITESPACE_SPLIT_RE = /\s+/;
|
|
336
338
|
var PARAGRAPH_SPLIT_RE = /\n\n/;
|
|
337
339
|
var COMMA_OR_SPACE_RE = /[,\s]+/;
|
|
@@ -390,11 +392,54 @@ function matchFirstColon(line) {
|
|
|
390
392
|
return { key, value };
|
|
391
393
|
}
|
|
392
394
|
function unquoteYaml(val) {
|
|
393
|
-
const
|
|
394
|
-
if (
|
|
395
|
-
return
|
|
395
|
+
const dq = val.match(DOUBLE_QUOTED_RE);
|
|
396
|
+
if (dq) {
|
|
397
|
+
return dq[1].replace(DQ_ESCAPE_RE, (_, ch) => {
|
|
398
|
+
switch (ch) {
|
|
399
|
+
case '"':
|
|
400
|
+
return '"';
|
|
401
|
+
case "\\":
|
|
402
|
+
return "\\";
|
|
403
|
+
case "/":
|
|
404
|
+
return "/";
|
|
405
|
+
case "b":
|
|
406
|
+
return "\b";
|
|
407
|
+
case "f":
|
|
408
|
+
return "\f";
|
|
409
|
+
case "n":
|
|
410
|
+
return "\n";
|
|
411
|
+
case "r":
|
|
412
|
+
return "\r";
|
|
413
|
+
case "t":
|
|
414
|
+
return " ";
|
|
415
|
+
default:
|
|
416
|
+
return ch;
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
const sq = val.match(SINGLE_QUOTED_RE);
|
|
421
|
+
if (sq) {
|
|
422
|
+
return sq[1].replace(/''/g, "'");
|
|
423
|
+
}
|
|
424
|
+
const hashIdx = val.indexOf(" #");
|
|
425
|
+
if (hashIdx >= 0)
|
|
426
|
+
return val.slice(0, hashIdx).trimEnd();
|
|
396
427
|
return val;
|
|
397
428
|
}
|
|
429
|
+
function takeString(frontmatter, key, diagnostics) {
|
|
430
|
+
const raw = frontmatter[key];
|
|
431
|
+
if (raw === void 0 || raw === null)
|
|
432
|
+
return void 0;
|
|
433
|
+
if (typeof raw === "string")
|
|
434
|
+
return raw;
|
|
435
|
+
diagnostics.push({
|
|
436
|
+
severity: "warning",
|
|
437
|
+
code: "invalid-field-type",
|
|
438
|
+
message: `Frontmatter field "${key}" expected string, got ${typeof raw}. Coerced.`,
|
|
439
|
+
field: key
|
|
440
|
+
});
|
|
441
|
+
return String(raw);
|
|
442
|
+
}
|
|
398
443
|
var RESOURCE_DIRS = {
|
|
399
444
|
scripts: "script",
|
|
400
445
|
references: "reference",
|
|
@@ -409,9 +454,10 @@ function enumerateResources(baseDir) {
|
|
|
409
454
|
try {
|
|
410
455
|
const files = readdirSync(dirPath, { recursive: true });
|
|
411
456
|
for (const file of files) {
|
|
412
|
-
const
|
|
457
|
+
const rel = typeof file === "string" ? file : file.toString("utf-8");
|
|
458
|
+
const fullPath = join(dirPath, rel);
|
|
413
459
|
if (statSync(fullPath).isFile()) {
|
|
414
|
-
resources.push({ path: join(dir,
|
|
460
|
+
resources.push({ path: join(dir, rel), type });
|
|
415
461
|
}
|
|
416
462
|
}
|
|
417
463
|
} catch {
|
|
@@ -436,7 +482,7 @@ async function parseSkillFile(filePath, options = {}) {
|
|
|
436
482
|
return null;
|
|
437
483
|
const content = readFileSync(absPath, "utf-8");
|
|
438
484
|
const { frontmatter, body, diagnostics } = parseFrontmatter(content);
|
|
439
|
-
let description = frontmatter
|
|
485
|
+
let description = takeString(frontmatter, "description", diagnostics);
|
|
440
486
|
if (!description && body) {
|
|
441
487
|
const firstParagraph = body.split(PARAGRAPH_SPLIT_RE)[0]?.trim();
|
|
442
488
|
if (firstParagraph)
|
|
@@ -454,12 +500,13 @@ async function parseSkillFile(filePath, options = {}) {
|
|
|
454
500
|
}
|
|
455
501
|
const baseDir = dirname(absPath);
|
|
456
502
|
const dirName = basename2(baseDir);
|
|
457
|
-
const
|
|
458
|
-
|
|
503
|
+
const frontmatterName = takeString(frontmatter, "name", diagnostics);
|
|
504
|
+
const name = frontmatterName || dirName;
|
|
505
|
+
if (frontmatterName && frontmatterName !== dirName) {
|
|
459
506
|
diagnostics.push({
|
|
460
507
|
severity: "warning",
|
|
461
508
|
code: "name-mismatch-directory",
|
|
462
|
-
message: `Skill name "${
|
|
509
|
+
message: `Skill name "${frontmatterName}" does not match parent directory "${dirName}". Loading anyway.`,
|
|
463
510
|
field: "name"
|
|
464
511
|
});
|
|
465
512
|
}
|
|
@@ -488,23 +535,25 @@ async function parseSkillFile(filePath, options = {}) {
|
|
|
488
535
|
baseDir,
|
|
489
536
|
resources: enumerateResources(baseDir)
|
|
490
537
|
};
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
538
|
+
const license = takeString(frontmatter, "license", diagnostics);
|
|
539
|
+
if (license)
|
|
540
|
+
config.license = license;
|
|
541
|
+
const compatibility = takeString(frontmatter, "compatibility", diagnostics);
|
|
542
|
+
if (compatibility) {
|
|
543
|
+
if (compatibility.length > 500) {
|
|
496
544
|
diagnostics.push({
|
|
497
545
|
severity: "warning",
|
|
498
546
|
code: "compatibility-too-long",
|
|
499
|
-
message: `Compatibility exceeds spec limit of 500 characters (got ${
|
|
547
|
+
message: `Compatibility exceeds spec limit of 500 characters (got ${compatibility.length}). Loading anyway.`,
|
|
500
548
|
field: "compatibility"
|
|
501
549
|
});
|
|
502
550
|
}
|
|
503
|
-
config.compatibility =
|
|
551
|
+
config.compatibility = compatibility;
|
|
504
552
|
}
|
|
505
553
|
const metadata = {};
|
|
506
|
-
|
|
507
|
-
|
|
554
|
+
const rawMetadata = frontmatter.metadata;
|
|
555
|
+
if (rawMetadata && typeof rawMetadata === "object" && !Array.isArray(rawMetadata)) {
|
|
556
|
+
for (const [k, v] of Object.entries(rawMetadata)) {
|
|
508
557
|
if (typeof v !== "string") {
|
|
509
558
|
diagnostics.push({
|
|
510
559
|
severity: "warning",
|
|
@@ -517,11 +566,17 @@ async function parseSkillFile(filePath, options = {}) {
|
|
|
517
566
|
}
|
|
518
567
|
metadata[k] = v;
|
|
519
568
|
}
|
|
569
|
+
} else if (rawMetadata !== void 0) {
|
|
570
|
+
diagnostics.push({
|
|
571
|
+
severity: "warning",
|
|
572
|
+
code: "invalid-metadata-shape",
|
|
573
|
+
message: `Frontmatter "metadata" expected a map, got ${Array.isArray(rawMetadata) ? "array" : typeof rawMetadata}. Ignored.`,
|
|
574
|
+
field: "metadata"
|
|
575
|
+
});
|
|
520
576
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
metadata["zidane.paths"] = normalized;
|
|
577
|
+
const pathsField = takeString(frontmatter, "paths", diagnostics);
|
|
578
|
+
if (pathsField) {
|
|
579
|
+
metadata["zidane.paths"] = pathsField.split(COMMA_OR_SPACE_RE).filter(Boolean).join(",");
|
|
525
580
|
diagnostics.push({
|
|
526
581
|
severity: "warning",
|
|
527
582
|
code: "deprecated-top-level-field",
|
|
@@ -529,8 +584,9 @@ async function parseSkillFile(filePath, options = {}) {
|
|
|
529
584
|
field: "paths"
|
|
530
585
|
});
|
|
531
586
|
}
|
|
532
|
-
|
|
533
|
-
|
|
587
|
+
const modelField = takeString(frontmatter, "model", diagnostics);
|
|
588
|
+
if (modelField) {
|
|
589
|
+
metadata["zidane.model"] = modelField;
|
|
534
590
|
diagnostics.push({
|
|
535
591
|
severity: "warning",
|
|
536
592
|
code: "deprecated-top-level-field",
|
|
@@ -538,20 +594,23 @@ async function parseSkillFile(filePath, options = {}) {
|
|
|
538
594
|
field: "model"
|
|
539
595
|
});
|
|
540
596
|
}
|
|
541
|
-
const
|
|
597
|
+
const thinkingField = takeString(frontmatter, "thinking", diagnostics);
|
|
598
|
+
const effortField = thinkingField ? void 0 : takeString(frontmatter, "effort", diagnostics);
|
|
599
|
+
const legacyThinking = thinkingField ?? effortField;
|
|
542
600
|
if (legacyThinking) {
|
|
543
601
|
metadata["zidane.thinking"] = legacyThinking;
|
|
544
602
|
diagnostics.push({
|
|
545
603
|
severity: "warning",
|
|
546
604
|
code: "deprecated-top-level-field",
|
|
547
|
-
message: `\`${
|
|
548
|
-
field:
|
|
605
|
+
message: `\`${thinkingField ? "thinking" : "effort"}\` is not a spec field and is deprecated \u2014 moved to \`metadata["zidane.thinking"]\`.`,
|
|
606
|
+
field: thinkingField ? "thinking" : "effort"
|
|
549
607
|
});
|
|
550
608
|
}
|
|
551
609
|
if (Object.keys(metadata).length > 0)
|
|
552
610
|
config.metadata = metadata;
|
|
553
|
-
|
|
554
|
-
|
|
611
|
+
const allowedTools = takeString(frontmatter, "allowed-tools", diagnostics);
|
|
612
|
+
if (allowedTools) {
|
|
613
|
+
config.allowedTools = allowedTools.split(WHITESPACE_SPLIT_RE).filter(Boolean);
|
|
555
614
|
}
|
|
556
615
|
if (diagnostics.length > 0)
|
|
557
616
|
config.diagnostics = diagnostics;
|
|
@@ -627,6 +686,7 @@ import { join as join2 } from "path";
|
|
|
627
686
|
var YAML_RESERVED_RE = /[:#&*!|>%@`]/;
|
|
628
687
|
var YAML_EDGE_OR_QUOTE_RE = /^\s|\s$|["']/;
|
|
629
688
|
var DQUOTE_RE = /"/g;
|
|
689
|
+
var LEADING_NEWLINES_RE = /^\n+/;
|
|
630
690
|
function yamlEscape(value) {
|
|
631
691
|
if (YAML_RESERVED_RE.test(value) || YAML_EDGE_OR_QUOTE_RE.test(value) || value === "")
|
|
632
692
|
return `"${value.replace(DQUOTE_RE, '\\"')}"`;
|
|
@@ -661,10 +721,11 @@ ${summary}`);
|
|
|
661
721
|
const skillDir = join2(targetDir, skill.name);
|
|
662
722
|
mkdirSync(skillDir, { recursive: true });
|
|
663
723
|
const frontmatter = serializeFrontmatter(skill);
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
${
|
|
724
|
+
const bodyTrimmed = skill.instructions ? skill.instructions.replace(LEADING_NEWLINES_RE, "") : "";
|
|
725
|
+
const content = bodyTrimmed ? `${frontmatter}
|
|
726
|
+
|
|
727
|
+
${bodyTrimmed}
|
|
728
|
+
` : `${frontmatter}
|
|
668
729
|
`;
|
|
669
730
|
const skillPath = join2(skillDir, "SKILL.md");
|
|
670
731
|
writeFileSync(skillPath, content);
|
|
@@ -707,26 +768,6 @@ async function resolveSkills(config) {
|
|
|
707
768
|
}
|
|
708
769
|
return filtered;
|
|
709
770
|
}
|
|
710
|
-
function mergeSkillsConfig(harness, agent) {
|
|
711
|
-
if (!harness && !agent)
|
|
712
|
-
return void 0;
|
|
713
|
-
if (!harness)
|
|
714
|
-
return agent;
|
|
715
|
-
if (!agent)
|
|
716
|
-
return harness;
|
|
717
|
-
return {
|
|
718
|
-
// Agent-level takes precedence when explicitly set
|
|
719
|
-
enabled: agent.enabled !== void 0 ? agent.enabled : harness.enabled,
|
|
720
|
-
scan: [...harness.scan ?? [], ...agent.scan ?? []],
|
|
721
|
-
write: [...harness.write ?? [], ...agent.write ?? []],
|
|
722
|
-
exclude: [.../* @__PURE__ */ new Set([...harness.exclude ?? [], ...agent.exclude ?? []])],
|
|
723
|
-
skipDefaultPaths: agent.skipDefaultPaths ?? harness.skipDefaultPaths,
|
|
724
|
-
tool: agent.tool ?? harness.tool,
|
|
725
|
-
maxActive: agent.maxActive ?? harness.maxActive,
|
|
726
|
-
scriptTimeoutMs: agent.scriptTimeoutMs ?? harness.scriptTimeoutMs,
|
|
727
|
-
trustProjectSkills: agent.trustProjectSkills ?? harness.trustProjectSkills
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
771
|
|
|
731
772
|
// src/skills/interpolate.ts
|
|
732
773
|
var SHELL_INTERPOLATION_RE = /!`([^`]+)`/g;
|
|
@@ -744,7 +785,8 @@ async function interpolateShellCommands(instructions, execution, handle) {
|
|
|
744
785
|
const output = result2.exitCode === 0 ? result2.stdout.trim() : `[command failed (exit ${result2.exitCode}): ${result2.stderr.trim() || result2.stdout.trim()}]`;
|
|
745
786
|
replacements.push({ index, length, output });
|
|
746
787
|
} catch (err) {
|
|
747
|
-
|
|
788
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
789
|
+
replacements.push({ index, length, output: `[command error: ${message}]` });
|
|
748
790
|
}
|
|
749
791
|
}
|
|
750
792
|
let result = instructions;
|
|
@@ -774,6 +816,5 @@ export {
|
|
|
774
816
|
writeSkillToDisk,
|
|
775
817
|
writeSkillsToDisk,
|
|
776
818
|
resolveSkills,
|
|
777
|
-
mergeSkillsConfig,
|
|
778
819
|
interpolateShellCommands
|
|
779
820
|
};
|
package/dist/contexts.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { d as AgentHooks } from './agent-
|
|
2
|
-
export {
|
|
1
|
+
import { d as AgentHooks } from './agent-vPBFXnu-.js';
|
|
2
|
+
export { ab as ActivationVia, ac as ActiveSkill, A as Agent, a as AgentAbortedError, b as AgentBehavior, c as AgentContextExceededError, e as AgentOptions, f as AgentProviderError, g as AgentRunOptions, h as AgentStats, i as AgentToolNotAllowedError, j as AnthropicParams, C as CONTEXT_EXCEEDED_MESSAGE_PATTERNS, k as CerebrasParams, m as ClassifiedError, n as ClassifiedErrorKind, o as CreateSessionOptions, ad as DeactivationReason, ae as FileMapAdapter, af as FileMapStoreOptions, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, ag as OpenAICompatAuthHeader, ah as OpenAICompatHttpError, ai as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, P as PromptDocumentPart, t as PromptImagePart, u as PromptPart, v as PromptTextPart, w as Provider, x as ProviderCapabilities, R as RemoteStoreOptions, y as RunHookMap, S as Session, z as SessionContentBlock, B as SessionData, D as SessionEndStatus, E as SessionHookContext, F as SessionMessage, G as SessionRun, H as SessionStore, J as SessionTurn, aj as SkillActivationState, ak as SkillActivationStateOptions, K as SkillConfig, al as SkillDiagnostic, L as SkillResource, am as SkillSource, N as SkillsConfig, Q as SpawnHookContext, T as StreamCallbacks, U as StreamHookContext, V as StreamOptions, W as ThinkingLevel, X as ToolCall, Y as ToolContext, Z as ToolDef, _ as ToolExecutionMode, $ as ToolHookContext, a0 as ToolMap, a1 as ToolResult, a2 as ToolResultContent, a3 as ToolResultImageContent, a4 as ToolResultTextContent, a5 as ToolSpec, a6 as TurnFinishReason, a7 as TurnResult, a8 as TurnUsage, an as anthropic, ao as autoDetectAndConvert, ap as cerebras, aq as classifyOpenAICompatError, ar as connectMcpServers, as as createAgent, at as createFileMapStore, au as createMemoryStore, av as createRemoteStore, aw as createSession, ax as createSkillActivationState, ay as fromAnthropic, az as fromOpenAI, aA as loadSession, aB as mapOAIFinishReason, a9 as matchesContextExceeded, aC as normalizeMcpBlocks, aD as normalizeMcpServers, aE as openai, aF as openaiCompat, aG as openrouter, aH as resultToString, aI as toAnthropic, aJ as toOpenAI, aK as toTypedError, aa as toolResultToText } from './agent-vPBFXnu-.js';
|
|
3
3
|
export { createDockerContext, createProcessContext } from './contexts.js';
|
|
4
4
|
export { S as SandboxProvider, c as createSandboxContext } from './sandbox-CW72eLDP.js';
|
|
5
5
|
export { C as ContextCapabilities, a as ContextType, E as ExecResult, b as ExecutionContext, c as ExecutionHandle, S as SpawnConfig } from './types-BpvTmawk.js';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
6
|
+
export { Preset, basic, basicTools, definePreset } from './presets.js';
|
|
7
|
+
export { IMPLICITLY_ALLOWED_SKILL_TOOLS, SkillValidationIssue, SkillValidationResult, SourcedScanPath, buildCatalog, defineSkill, discoverSkills, installAllowedToolsGate, interpolateShellCommands, isToolAllowedByUnion, matchesAllowedTool, parseAllowedToolPattern, parseSkillFile, resolveSkills, validateResourcePath, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk } from './skills.js';
|
|
8
|
+
export { S as SkillsReadToolOptions, a as SkillsRunScriptToolOptions, b as SkillsUseToolOptions, c as createSkillsReadTool, d as createSkillsRunScriptTool, e as createSkillsUseTool, g as glob } from './skills-use-39cCsA7_.js';
|
|
9
|
+
export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-Czx3owjX.js';
|
|
9
10
|
import { Hookable } from 'hookable';
|
|
10
11
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
11
12
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineSkill
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BW3WTFIR.js";
|
|
4
4
|
import {
|
|
5
5
|
toolResultToText
|
|
6
6
|
} from "./chunk-MYWDHD7C.js";
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
cerebras,
|
|
10
10
|
openai,
|
|
11
11
|
openrouter
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CDRXC7A7.js";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
basicTools,
|
|
15
|
+
basic_default,
|
|
16
|
+
definePreset
|
|
17
|
+
} from "./chunk-SP5NA6WF.js";
|
|
17
18
|
import {
|
|
18
19
|
createAgent,
|
|
19
20
|
createInteractionTool,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
createSpawnTool,
|
|
24
25
|
glob,
|
|
25
26
|
spawn
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-F5UBXERT.js";
|
|
27
28
|
import {
|
|
28
29
|
IMPLICITLY_ALLOWED_SKILL_TOOLS,
|
|
29
30
|
buildCatalog,
|
|
@@ -33,7 +34,6 @@ import {
|
|
|
33
34
|
interpolateShellCommands,
|
|
34
35
|
isToolAllowedByUnion,
|
|
35
36
|
matchesAllowedTool,
|
|
36
|
-
mergeSkillsConfig,
|
|
37
37
|
parseAllowedToolPattern,
|
|
38
38
|
parseSkillFile,
|
|
39
39
|
resolveSkills,
|
|
@@ -42,25 +42,25 @@ import {
|
|
|
42
42
|
validateSkillName,
|
|
43
43
|
writeSkillToDisk,
|
|
44
44
|
writeSkillsToDisk
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-TPXPVEH6.js";
|
|
46
46
|
import {
|
|
47
47
|
createDockerContext,
|
|
48
48
|
createProcessContext,
|
|
49
49
|
createSandboxContext
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-2EQT4EHD.js";
|
|
51
51
|
import {
|
|
52
52
|
connectMcpServers,
|
|
53
53
|
normalizeMcpBlocks,
|
|
54
54
|
normalizeMcpServers,
|
|
55
55
|
resultToString
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-37GD7NL3.js";
|
|
57
57
|
import {
|
|
58
58
|
createFileMapStore,
|
|
59
59
|
createMemoryStore,
|
|
60
60
|
createRemoteStore,
|
|
61
61
|
createSession,
|
|
62
62
|
loadSession
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-PMCQOMV4.js";
|
|
64
64
|
import {
|
|
65
65
|
OpenAICompatHttpError,
|
|
66
66
|
autoDetectAndConvert,
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
openaiCompat,
|
|
72
72
|
toAnthropic,
|
|
73
73
|
toOpenAI
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-S3FCOMRI.js";
|
|
75
75
|
import {
|
|
76
76
|
AgentAbortedError,
|
|
77
77
|
AgentContextExceededError,
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
CONTEXT_EXCEEDED_MESSAGE_PATTERNS,
|
|
81
81
|
matchesContextExceeded,
|
|
82
82
|
toTypedError
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-LNN5UTS2.js";
|
|
84
84
|
|
|
85
85
|
// src/tracing.ts
|
|
86
86
|
function createTracingHooks(options) {
|
|
@@ -204,6 +204,8 @@ export {
|
|
|
204
204
|
OpenAICompatHttpError,
|
|
205
205
|
anthropic,
|
|
206
206
|
autoDetectAndConvert,
|
|
207
|
+
basic_default as basic,
|
|
208
|
+
basicTools,
|
|
207
209
|
buildCatalog,
|
|
208
210
|
cerebras,
|
|
209
211
|
classifyOpenAICompatError,
|
|
@@ -223,7 +225,7 @@ export {
|
|
|
223
225
|
createSkillsUseTool,
|
|
224
226
|
createSpawnTool,
|
|
225
227
|
createTracingHooks,
|
|
226
|
-
|
|
228
|
+
definePreset,
|
|
227
229
|
defineSkill,
|
|
228
230
|
discoverSkills,
|
|
229
231
|
fromAnthropic,
|
|
@@ -236,8 +238,6 @@ export {
|
|
|
236
238
|
mapOAIFinishReason,
|
|
237
239
|
matchesAllowedTool,
|
|
238
240
|
matchesContextExceeded,
|
|
239
|
-
mergeSkillsConfig,
|
|
240
|
-
noTools,
|
|
241
241
|
normalizeMcpBlocks,
|
|
242
242
|
normalizeMcpServers,
|
|
243
243
|
openai,
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'hookable';
|
|
2
|
-
export { M as McpConnection,
|
|
2
|
+
export { M as McpConnection, p as McpServerConfig, ar as connectMcpServers, aC as normalizeMcpBlocks, aD as normalizeMcpServers, aH as resultToString } from './agent-vPBFXnu-.js';
|
|
3
3
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
4
4
|
import './types-BpvTmawk.js';
|
package/dist/mcp.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Z as ToolDef, e as AgentOptions } from './agent-vPBFXnu-.js';
|
|
2
|
+
import 'hookable';
|
|
3
|
+
import './types-BpvTmawk.js';
|
|
4
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
5
|
+
|
|
6
|
+
/** Core tools available in every basic preset (without spawn) */
|
|
7
|
+
declare const basicTools: {
|
|
8
|
+
shell: ToolDef;
|
|
9
|
+
readFile: ToolDef;
|
|
10
|
+
writeFile: ToolDef;
|
|
11
|
+
listFiles: ToolDef;
|
|
12
|
+
};
|
|
13
|
+
declare const _default: Preset;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A preset is a reusable slice of `AgentOptions` — spread it into `createAgent()`
|
|
17
|
+
* to configure tools, a default system prompt, aliases, and behavior defaults.
|
|
18
|
+
*
|
|
19
|
+
* `provider`, `execution`, `session`, and internal fields are excluded so presets
|
|
20
|
+
* remain shareable and composable.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { basic } from 'zidane/presets'
|
|
24
|
+
* createAgent({ ...basic, provider })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
type Preset = Omit<Partial<AgentOptions>, 'provider' | 'execution' | 'session' | '_mcpConnector'>;
|
|
28
|
+
/**
|
|
29
|
+
* Identity helper for type inference when defining a preset.
|
|
30
|
+
*/
|
|
31
|
+
declare function definePreset(config: Preset): Preset;
|
|
32
|
+
|
|
33
|
+
export { type Preset, _default as basic, basicTools, definePreset };
|