zidane 3.1.1 → 3.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.
@@ -259,6 +259,32 @@ function buildMcpToolDef(config, client, tool, namespacedName, hooks) {
259
259
  if (gateCtx.block)
260
260
  return `Blocked: ${gateCtx.reason}`;
261
261
  const effectiveInput = gateCtx.input;
262
+ if (gateCtx.result !== void 0) {
263
+ let substitute = gateCtx.result;
264
+ const transformCtx = {
265
+ turnId,
266
+ callId,
267
+ server: config.name,
268
+ tool: tool.name,
269
+ displayName,
270
+ input: effectiveInput,
271
+ result: substitute,
272
+ outputBytes: toolOutputByteLength(substitute)
273
+ };
274
+ await hooks?.callHook("mcp:tool:transform", transformCtx);
275
+ substitute = transformCtx.result;
276
+ await hooks?.callHook("mcp:tool:after", {
277
+ turnId,
278
+ callId,
279
+ server: config.name,
280
+ tool: tool.name,
281
+ displayName,
282
+ input: effectiveInput,
283
+ result: substitute,
284
+ outputBytes: toolOutputByteLength(substitute)
285
+ });
286
+ return substitute;
287
+ }
262
288
  await hooks?.callHook("mcp:tool:before", {
263
289
  turnId,
264
290
  callId,
@@ -5,7 +5,7 @@ import {
5
5
  toAnthropic,
6
6
  toolResultsMessage,
7
7
  userMessage
8
- } from "./chunk-VF4A7HAC.js";
8
+ } from "./chunk-QX7TDFD4.js";
9
9
  import {
10
10
  matchesContextExceeded
11
11
  } from "./chunk-LNN5UTS2.js";
@@ -437,6 +437,11 @@ function anthropic(anthropicParams) {
437
437
  const thinking = options.thinking ?? "off";
438
438
  const modelId = options.model;
439
439
  const params = {
440
+ // Forward-compat escape hatch for un-typed beta fields. Spread first so
441
+ // the typed core (model / max_tokens / system / tools / messages /
442
+ // stream) and the explicit `context_management` below override on
443
+ // collision — explicit always wins.
444
+ ...anthropicParams?.extraBodyParams ?? {},
440
445
  model: modelId,
441
446
  max_tokens: options.maxTokens,
442
447
  system,
@@ -6,7 +6,7 @@ import {
6
6
  shell,
7
7
  spawn,
8
8
  writeFile
9
- } from "./chunk-EBSFBIP3.js";
9
+ } from "./chunk-6JIVVEQQ.js";
10
10
 
11
11
  // src/presets/basic.ts
12
12
  var basicTools = { shell, readFile, writeFile, listFiles, edit, multiEdit };
@@ -740,11 +740,16 @@ function writeSkillsToDisk(skills, targetDir) {
740
740
  }
741
741
 
742
742
  // src/skills/resolve.ts
743
- import { mkdtempSync } from "fs";
743
+ import { mkdtempSync, rmSync } from "fs";
744
744
  import { tmpdir } from "os";
745
745
  import { join as join3 } from "path";
746
746
  async function resolveSkills(config) {
747
+ const { skills } = await resolveSkillsWithCleanup(config);
748
+ return skills;
749
+ }
750
+ async function resolveSkillsWithCleanup(config) {
747
751
  const sourcedPaths = [];
752
+ let writeDir;
748
753
  if (!config.skipDefaultPaths) {
749
754
  sourcedPaths.push(...getDefaultScanPaths());
750
755
  }
@@ -752,7 +757,7 @@ async function resolveSkills(config) {
752
757
  sourcedPaths.push({ path: p, source: inferSource(p) });
753
758
  }
754
759
  if (config.write?.length) {
755
- const writeDir = mkdtempSync(join3(tmpdir(), "zidane-skills-"));
760
+ writeDir = mkdtempSync(join3(tmpdir(), "zidane-skills-"));
756
761
  writeSkillsToDisk(config.write, writeDir);
757
762
  sourcedPaths.push({ path: writeDir, source: "inline" });
758
763
  }
@@ -766,7 +771,14 @@ async function resolveSkills(config) {
766
771
  const allowlist = new Set(config.enabled);
767
772
  filtered = filtered.filter((s) => allowlist.has(s.name));
768
773
  }
769
- return filtered;
774
+ const cleanup = writeDir ? () => {
775
+ try {
776
+ rmSync(writeDir, { recursive: true, force: true });
777
+ } catch {
778
+ }
779
+ } : () => {
780
+ };
781
+ return { skills: filtered, cleanup };
770
782
  }
771
783
 
772
784
  // src/skills/interpolate.ts
@@ -816,5 +828,6 @@ export {
816
828
  writeSkillToDisk,
817
829
  writeSkillsToDisk,
818
830
  resolveSkills,
831
+ resolveSkillsWithCleanup,
819
832
  interpolateShellCommands
820
833
  };
@@ -393,6 +393,9 @@ function openaiCompat(params) {
393
393
  }
394
394
  const maxTokens = options.thinkingBudget ? options.thinkingBudget + options.maxTokens : options.maxTokens;
395
395
  const body = {
396
+ // Spread first so the typed core below wins on collision — explicit
397
+ // always overrides generic.
398
+ ...params.extraBodyParams ?? {},
396
399
  model: modelId,
397
400
  messages,
398
401
  max_tokens: maxTokens,
@@ -529,22 +532,31 @@ function fromOpenAI(msg) {
529
532
  content.push({ type: "text", text: c });
530
533
  return { role, content };
531
534
  }
532
- if (typeof c === "object" && c._tag === ASSISTANT_TOOL_CALLS_TAG) {
533
- if (c.text) {
534
- content.push({ type: "text", text: c.text });
535
+ if (typeof c === "object" && !Array.isArray(c) && c._tag === ASSISTANT_TOOL_CALLS_TAG) {
536
+ const tagged = c;
537
+ if (typeof tagged.text === "string" && tagged.text) {
538
+ content.push({ type: "text", text: tagged.text });
535
539
  }
536
- if (Array.isArray(c.tool_calls)) {
537
- for (const tc of c.tool_calls) {
538
- const input = tc.function?.arguments ? typeof tc.function.arguments === "string" ? JSON.parse(tc.function.arguments) : tc.function.arguments : {};
539
- content.push({ type: "tool_call", id: tc.id, name: tc.function?.name ?? "", input });
540
+ if (Array.isArray(tagged.tool_calls)) {
541
+ for (const raw of tagged.tool_calls) {
542
+ if (!raw || typeof raw !== "object")
543
+ continue;
544
+ const tc = raw;
545
+ const rawArgs = tc.function?.arguments;
546
+ const input = rawArgs ? typeof rawArgs === "string" ? JSON.parse(rawArgs) : rawArgs : {};
547
+ content.push({ type: "tool_call", id: tc.id ?? "", name: tc.function?.name ?? "", input });
540
548
  }
541
549
  }
542
550
  return { role, content };
543
551
  }
544
- if (typeof c === "object" && c._tag === TOOL_RESULTS_TAG) {
545
- if (Array.isArray(c.results)) {
546
- for (const r of c.results) {
547
- content.push({ type: "tool_result", callId: r.tool_call_id, output: r.content });
552
+ if (typeof c === "object" && !Array.isArray(c) && c._tag === TOOL_RESULTS_TAG) {
553
+ const tagged = c;
554
+ if (Array.isArray(tagged.results)) {
555
+ for (const raw of tagged.results) {
556
+ if (!raw || typeof raw !== "object")
557
+ continue;
558
+ const r = raw;
559
+ content.push({ type: "tool_result", callId: r.tool_call_id ?? "", output: r.content ?? "" });
548
560
  }
549
561
  }
550
562
  return { role, content };
@@ -646,8 +658,10 @@ function toOpenAI(msg) {
646
658
  }
647
659
  function autoDetectAndConvert(msg) {
648
660
  const c = msg.content;
649
- if (c && typeof c === "object" && typeof c._tag === "string" && c._tag.startsWith("__zidane_")) {
650
- return fromOpenAI(msg);
661
+ if (c && typeof c === "object" && !Array.isArray(c)) {
662
+ const tag = c._tag;
663
+ if (typeof tag === "string" && tag.startsWith("__zidane_"))
664
+ return fromOpenAI(msg);
651
665
  }
652
666
  if (Array.isArray(c)) {
653
667
  for (const block of c) {
@@ -78,19 +78,77 @@ function createDockerContext(config) {
78
78
  const stream = await exec.start({ Detach: false });
79
79
  return new Promise((resolve2) => {
80
80
  let stdout = "";
81
- const stderr = "";
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
+ }
82
120
  const timeout = options?.timeout ?? defaultLimits?.timeout ?? 30;
83
121
  const timer = setTimeout(() => {
84
- resolve2({ stdout, stderr: `${stderr}
85
- [timeout]`, exitCode: 124 });
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 });
86
131
  }, timeout * 1e3);
87
- stream.on("data", (chunk) => {
88
- stdout += chunk.toString("utf-8");
89
- });
90
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;
91
149
  clearTimeout(timer);
92
- const inspect = await exec.inspect();
93
- resolve2({ stdout, stderr, exitCode: inspect.ExitCode ?? 0 });
150
+ resolve2({ stdout, stderr: stderr ? `${stderr}
151
+ ${err.message}` : err.message, exitCode: 1 });
94
152
  });
95
153
  });
96
154
  },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validateSkillForWrite
3
- } from "./chunk-TPXPVEH6.js";
3
+ } from "./chunk-J4ZOSNSH.js";
4
4
 
5
5
  // src/skills/index.ts
6
6
  function defineSkill(config) {
package/dist/contexts.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  createDockerContext,
3
3
  createProcessContext,
4
4
  createSandboxContext
5
- } from "./chunk-IUBBVF53.js";
5
+ } from "./chunk-UD25QF3H.js";
6
6
  export {
7
7
  createDockerContext,
8
8
  createProcessContext,
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { d as AgentHooks } from './agent-Cq009tbG.js';
2
- export { ac as ActivationVia, ad 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, ae as DeactivationReason, af as FileMapAdapter, ag as FileMapStoreOptions, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, ah as OpenAICompatAuthHeader, ai as OpenAICompatHttpError, aj 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, ak as SkillActivationState, al as SkillActivationStateOptions, K as SkillConfig, am as SkillDiagnostic, L as SkillResource, an 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, ao as anthropic, ap as autoDetectAndConvert, aq as cerebras, ar as classifyOpenAICompatError, as as connectMcpServers, at as createAgent, au as createFileMapStore, av as createMemoryStore, aw as createRemoteStore, ax as createSession, ay as createSkillActivationState, az as fromAnthropic, aA as fromOpenAI, aB as loadSession, aC as mapOAIFinishReason, a9 as matchesContextExceeded, aD as normalizeMcpBlocks, aE as normalizeMcpServers, aF as openai, aG as openaiCompat, aH as openrouter, aI as resultToString, aJ as toAnthropic, aK as toOpenAI, aL as toTypedError, aa as toolOutputByteLength, ab as toolResultToText } from './agent-Cq009tbG.js';
1
+ import { d as AgentHooks } from './agent-CE2jhpNE.js';
2
+ export { ac as ActivationVia, ad 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, ae as DeactivationReason, af as FileMapAdapter, ag as FileMapStoreOptions, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, ah as OpenAICompatAuthHeader, ai as OpenAICompatHttpError, aj 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, ak as SkillActivationState, al as SkillActivationStateOptions, K as SkillConfig, am as SkillDiagnostic, L as SkillResource, an 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, ao as anthropic, ap as autoDetectAndConvert, aq as cerebras, ar as classifyOpenAICompatError, as as connectMcpServers, at as createAgent, au as createFileMapStore, av as createMemoryStore, aw as createRemoteStore, ax as createSession, ay as createSkillActivationState, az as fromAnthropic, aA as fromOpenAI, aB as loadSession, aC as mapOAIFinishReason, a9 as matchesContextExceeded, aD as normalizeMcpBlocks, aE as normalizeMcpServers, aF as openai, aG as openaiCompat, aH as openrouter, aI as resultToString, aJ as toAnthropic, aK as toOpenAI, aL as toTypedError, aa as toolOutputByteLength, ab as toolResultToText } from './agent-CE2jhpNE.js';
3
3
  export { createDockerContext, createProcessContext } from './contexts.js';
4
4
  export { S as SandboxProvider, c as createSandboxContext } from './sandbox-CLghrTLi.js';
5
5
  export { C as ContextCapabilities, a as ContextType, E as ExecResult, b as ExecutionContext, c as ExecutionHandle, S as SpawnConfig } from './types-vA1a_ZX7.js';
6
6
  export { Preset, basic, basicTools, definePreset } from './presets.js';
7
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, f as edit, g as glob, h as grep, m as multiEdit } from './skills-use-Bi6Dklye.js';
9
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, V as ValidationResult, c as createInteractionTool, b as createSpawnTool, s as spawn, v as validateToolArgs } from './validation-BeQD94ft.js';
8
+ export { S as SkillsReadToolOptions, a as SkillsRunScriptToolOptions, b as SkillsUseToolOptions, c as createSkillsReadTool, d as createSkillsRunScriptTool, e as createSkillsUseTool, f as edit, g as glob, h as grep, m as multiEdit } from './skills-use-CqOKEN56.js';
9
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, V as ValidationResult, c as createInteractionTool, b as createSpawnTool, s as spawn, v as validateToolArgs } from './validation-DlIURVGV.js';
10
10
  import { Hookable } from 'hookable';
11
11
  import '@modelcontextprotocol/sdk/client/index.js';
12
12
 
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  defineSkill
3
- } from "./chunk-BW3WTFIR.js";
3
+ } from "./chunk-YPU6KVL6.js";
4
4
  import {
5
5
  anthropic,
6
6
  cerebras,
7
7
  openai,
8
8
  openrouter
9
- } from "./chunk-3DUWP7YU.js";
9
+ } from "./chunk-AUBXCLUC.js";
10
10
  import {
11
11
  basicTools,
12
12
  basic_default,
13
13
  definePreset
14
- } from "./chunk-ATMVSCGJ.js";
14
+ } from "./chunk-HPTCF3EX.js";
15
15
  import {
16
16
  createAgent,
17
17
  createInteractionTool,
@@ -25,7 +25,7 @@ import {
25
25
  multiEdit,
26
26
  spawn,
27
27
  validateToolArgs
28
- } from "./chunk-EBSFBIP3.js";
28
+ } from "./chunk-6JIVVEQQ.js";
29
29
  import {
30
30
  IMPLICITLY_ALLOWED_SKILL_TOOLS,
31
31
  buildCatalog,
@@ -43,18 +43,18 @@ import {
43
43
  validateSkillName,
44
44
  writeSkillToDisk,
45
45
  writeSkillsToDisk
46
- } from "./chunk-TPXPVEH6.js";
46
+ } from "./chunk-J4ZOSNSH.js";
47
47
  import {
48
48
  createDockerContext,
49
49
  createProcessContext,
50
50
  createSandboxContext
51
- } from "./chunk-IUBBVF53.js";
51
+ } from "./chunk-UD25QF3H.js";
52
52
  import {
53
53
  connectMcpServers,
54
54
  normalizeMcpBlocks,
55
55
  normalizeMcpServers,
56
56
  resultToString
57
- } from "./chunk-R74LQKAM.js";
57
+ } from "./chunk-7H34OFDA.js";
58
58
  import {
59
59
  toolOutputByteLength,
60
60
  toolResultToText
@@ -76,7 +76,7 @@ import {
76
76
  openaiCompat,
77
77
  toAnthropic,
78
78
  toOpenAI
79
- } from "./chunk-VF4A7HAC.js";
79
+ } from "./chunk-QX7TDFD4.js";
80
80
  import {
81
81
  AgentAbortedError,
82
82
  AgentContextExceededError,
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import 'hookable';
2
- export { M as McpConnection, p as McpServerConfig, as as connectMcpServers, aD as normalizeMcpBlocks, aE as normalizeMcpServers, aI as resultToString } from './agent-Cq009tbG.js';
2
+ export { M as McpConnection, p as McpServerConfig, as as connectMcpServers, aD as normalizeMcpBlocks, aE as normalizeMcpServers, aI as resultToString } from './agent-CE2jhpNE.js';
3
3
  import '@modelcontextprotocol/sdk/client/index.js';
4
4
  import './types-vA1a_ZX7.js';
package/dist/mcp.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  normalizeMcpBlocks,
4
4
  normalizeMcpServers,
5
5
  resultToString
6
- } from "./chunk-R74LQKAM.js";
6
+ } from "./chunk-7H34OFDA.js";
7
7
  import "./chunk-JH6IAAFA.js";
8
8
  export {
9
9
  connectMcpServers,
package/dist/presets.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Z as ToolDef, e as AgentOptions } from './agent-Cq009tbG.js';
1
+ import { Z as ToolDef, e as AgentOptions } from './agent-CE2jhpNE.js';
2
2
  import 'hookable';
3
3
  import './types-vA1a_ZX7.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/presets.js CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  basicTools,
3
3
  basic_default,
4
4
  definePreset
5
- } from "./chunk-ATMVSCGJ.js";
6
- import "./chunk-EBSFBIP3.js";
7
- import "./chunk-TPXPVEH6.js";
8
- import "./chunk-IUBBVF53.js";
9
- import "./chunk-R74LQKAM.js";
5
+ } from "./chunk-HPTCF3EX.js";
6
+ import "./chunk-6JIVVEQQ.js";
7
+ import "./chunk-J4ZOSNSH.js";
8
+ import "./chunk-UD25QF3H.js";
9
+ import "./chunk-7H34OFDA.js";
10
10
  import "./chunk-JH6IAAFA.js";
11
11
  import "./chunk-LNN5UTS2.js";
12
12
  export {
@@ -1,4 +1,4 @@
1
- export { j as AnthropicParams, k as CerebrasParams, ah as OpenAICompatAuthHeader, ai as OpenAICompatHttpError, aj as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, w as Provider, x as ProviderCapabilities, T as StreamCallbacks, V as StreamOptions, X as ToolCall, a1 as ToolResult, a5 as ToolSpec, a7 as TurnResult, ao as anthropic, aq as cerebras, ar as classifyOpenAICompatError, aC as mapOAIFinishReason, aF as openai, aG as openaiCompat, aH as openrouter } from './agent-Cq009tbG.js';
1
+ export { j as AnthropicParams, k as CerebrasParams, ah as OpenAICompatAuthHeader, ai as OpenAICompatHttpError, aj as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, w as Provider, x as ProviderCapabilities, T as StreamCallbacks, V as StreamOptions, X as ToolCall, a1 as ToolResult, a5 as ToolSpec, a7 as TurnResult, ao as anthropic, aq as cerebras, ar as classifyOpenAICompatError, aC as mapOAIFinishReason, aF as openai, aG as openaiCompat, aH as openrouter } from './agent-CE2jhpNE.js';
2
2
  import 'hookable';
3
3
  import './types-vA1a_ZX7.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/providers.js CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  cerebras,
4
4
  openai,
5
5
  openrouter
6
- } from "./chunk-3DUWP7YU.js";
6
+ } from "./chunk-AUBXCLUC.js";
7
7
  import {
8
8
  OpenAICompatHttpError,
9
9
  classifyOpenAICompatError,
10
10
  mapOAIFinishReason,
11
11
  openaiCompat
12
- } from "./chunk-VF4A7HAC.js";
12
+ } from "./chunk-QX7TDFD4.js";
13
13
  import "./chunk-LNN5UTS2.js";
14
14
  export {
15
15
  OpenAICompatHttpError,
@@ -1,4 +1,4 @@
1
- import { H as SessionStore } from '../agent-Cq009tbG.js';
1
+ import { H as SessionStore } from '../agent-CE2jhpNE.js';
2
2
  import 'hookable';
3
3
  import '../types-vA1a_ZX7.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
@@ -24,7 +24,9 @@ function createSqliteStore(options) {
24
24
  `);
25
25
  const stmtDelete = db.prepare("DELETE FROM sessions WHERE id = ?");
26
26
  const stmtList = db.prepare("SELECT id FROM sessions ORDER BY updated_at DESC");
27
+ const stmtListLimited = db.prepare("SELECT id FROM sessions ORDER BY updated_at DESC LIMIT ?");
27
28
  const stmtListByAgent = db.prepare("SELECT id FROM sessions WHERE agent_id = ? ORDER BY updated_at DESC");
29
+ const stmtListByAgentLimited = db.prepare("SELECT id FROM sessions WHERE agent_id = ? ORDER BY updated_at DESC LIMIT ?");
28
30
  const store = {
29
31
  async load(sessionId) {
30
32
  const row = stmtLoad.get(sessionId);
@@ -45,17 +47,14 @@ function createSqliteStore(options) {
45
47
  stmtDelete.run(sessionId);
46
48
  },
47
49
  async list(filter) {
50
+ const limit = typeof filter?.limit === "number" && filter.limit > 0 ? filter.limit : void 0;
48
51
  let rows;
49
52
  if (filter?.agentId) {
50
- rows = stmtListByAgent.all(filter.agentId);
53
+ rows = limit ? stmtListByAgentLimited.all(filter.agentId, limit) : stmtListByAgent.all(filter.agentId);
51
54
  } else {
52
- rows = stmtList.all();
55
+ rows = limit ? stmtListLimited.all(limit) : stmtList.all();
53
56
  }
54
- const ids = rows.map((r) => r.id);
55
- if (filter?.limit) {
56
- return ids.slice(0, filter.limit);
57
- }
58
- return ids;
57
+ return rows.map((r) => r.id);
59
58
  },
60
59
  async appendTurns(sessionId, turns) {
61
60
  const data = await store.load(sessionId);
package/dist/session.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { o as CreateSessionOptions, af as FileMapAdapter, ag as FileMapStoreOptions, R as RemoteStoreOptions, S as Session, z as SessionContentBlock, B as SessionData, F as SessionMessage, G as SessionRun, H as SessionStore, J as SessionTurn, ap as autoDetectAndConvert, au as createFileMapStore, av as createMemoryStore, aw as createRemoteStore, ax as createSession, az as fromAnthropic, aA as fromOpenAI, aB as loadSession, aJ as toAnthropic, aK as toOpenAI } from './agent-Cq009tbG.js';
1
+ export { o as CreateSessionOptions, af as FileMapAdapter, ag as FileMapStoreOptions, R as RemoteStoreOptions, S as Session, z as SessionContentBlock, B as SessionData, F as SessionMessage, G as SessionRun, H as SessionStore, J as SessionTurn, ap as autoDetectAndConvert, au as createFileMapStore, av as createMemoryStore, aw as createRemoteStore, ax as createSession, az as fromAnthropic, aA as fromOpenAI, aB as loadSession, aJ as toAnthropic, aK as toOpenAI } from './agent-CE2jhpNE.js';
2
2
  import 'hookable';
3
3
  import './types-vA1a_ZX7.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/session.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  fromOpenAI,
12
12
  toAnthropic,
13
13
  toOpenAI
14
- } from "./chunk-VF4A7HAC.js";
14
+ } from "./chunk-QX7TDFD4.js";
15
15
  import "./chunk-LNN5UTS2.js";
16
16
  export {
17
17
  autoDetectAndConvert,
@@ -1,4 +1,4 @@
1
- import { Z as ToolDef, K as SkillConfig, ak as SkillActivationState, d as AgentHooks } from './agent-Cq009tbG.js';
1
+ import { Z as ToolDef, K as SkillConfig, ak as SkillActivationState, d as AgentHooks } from './agent-CE2jhpNE.js';
2
2
  import { Hookable } from 'hookable';
3
3
 
4
4
  /**
package/dist/skills.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { d as AgentHooks, ak as SkillActivationState, K as SkillConfig, an as SkillSource, am as SkillDiagnostic, N as SkillsConfig } from './agent-Cq009tbG.js';
2
- export { ac as ActivationVia, ad as ActiveSkill, ae as DeactivationReason, al as SkillActivationStateOptions, L as SkillResource, ay as createSkillActivationState } from './agent-Cq009tbG.js';
1
+ import { d as AgentHooks, ak as SkillActivationState, K as SkillConfig, an as SkillSource, am as SkillDiagnostic, N as SkillsConfig } from './agent-CE2jhpNE.js';
2
+ export { ac as ActivationVia, ad as ActiveSkill, ae as DeactivationReason, al as SkillActivationStateOptions, L as SkillResource, ay as createSkillActivationState } from './agent-CE2jhpNE.js';
3
3
  import { Hookable } from 'hookable';
4
4
  import { b as ExecutionContext, c as ExecutionHandle } from './types-vA1a_ZX7.js';
5
5
  import '@modelcontextprotocol/sdk/client/index.js';
@@ -65,6 +65,12 @@ interface BuildCatalogOptions {
65
65
  }
66
66
  /**
67
67
  * Build the skill catalog XML and behavioral instructions for the system prompt.
68
+ *
69
+ * The second argument accepts either {@link BuildCatalogOptions} (preferred)
70
+ * or — for legacy callers — a bare string interpreted as `readToolName` with
71
+ * `skillsToolRegistered: false`. The string form is kept for backward
72
+ * compatibility and will be removed in a future major; pass an options
73
+ * object instead.
68
74
  */
69
75
  declare function buildCatalog(skills: SkillConfig[], optionsOrReadToolName?: BuildCatalogOptions | string): string;
70
76
 
@@ -265,6 +271,10 @@ declare function interpolateShellCommands(instructions: string, execution: Execu
265
271
  * 2. Combine with default + user-provided scan paths (project-first, user-next)
266
272
  * 3. Run lenient discovery
267
273
  * 4. Apply filters: `exclude`, `enabled` allowlist, optional project-skill trust gate
274
+ *
275
+ * Backwards-compatible signature: returns `Promise<SkillConfig[]>`. Use
276
+ * {@link resolveSkillsWithCleanup} when you need to clean up the temp
277
+ * directory created for inline `write` skills (e.g. on `agent.destroy()`).
268
278
  */
269
279
  declare function resolveSkills(config: SkillsConfig): Promise<SkillConfig[]>;
270
280
 
package/dist/skills.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineSkill
3
- } from "./chunk-BW3WTFIR.js";
3
+ } from "./chunk-YPU6KVL6.js";
4
4
  import {
5
5
  IMPLICITLY_ALLOWED_SKILL_TOOLS,
6
6
  buildCatalog,
@@ -21,7 +21,7 @@ import {
21
21
  validateSkillName,
22
22
  writeSkillToDisk,
23
23
  writeSkillsToDisk
24
- } from "./chunk-TPXPVEH6.js";
24
+ } from "./chunk-J4ZOSNSH.js";
25
25
  import "./chunk-LNN5UTS2.js";
26
26
  export {
27
27
  IMPLICITLY_ALLOWED_SKILL_TOOLS,
package/dist/tools.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { S as SkillsReadToolOptions, a as SkillsRunScriptToolOptions, b as SkillsUseToolOptions, c as createSkillsReadTool, d as createSkillsRunScriptTool, e as createSkillsUseTool, f as edit, g as glob, h as grep, m as multiEdit } from './skills-use-Bi6Dklye.js';
2
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, V as ValidationResult, c as createInteractionTool, b as createSpawnTool, s as spawn, v as validateToolArgs } from './validation-BeQD94ft.js';
3
- import { Z as ToolDef } from './agent-Cq009tbG.js';
4
- export { Y as ToolContext, a0 as ToolMap } from './agent-Cq009tbG.js';
1
+ export { S as SkillsReadToolOptions, a as SkillsRunScriptToolOptions, b as SkillsUseToolOptions, c as createSkillsReadTool, d as createSkillsRunScriptTool, e as createSkillsUseTool, f as edit, g as glob, h as grep, m as multiEdit } from './skills-use-CqOKEN56.js';
2
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, V as ValidationResult, c as createInteractionTool, b as createSpawnTool, s as spawn, v as validateToolArgs } from './validation-DlIURVGV.js';
3
+ import { Z as ToolDef } from './agent-CE2jhpNE.js';
4
+ export { Y as ToolContext, a0 as ToolMap } from './agent-CE2jhpNE.js';
5
5
  import 'hookable';
6
6
  import './presets.js';
7
7
  import './types-vA1a_ZX7.js';
package/dist/tools.js CHANGED
@@ -14,10 +14,10 @@ import {
14
14
  spawn,
15
15
  validateToolArgs,
16
16
  writeFile
17
- } from "./chunk-EBSFBIP3.js";
18
- import "./chunk-TPXPVEH6.js";
19
- import "./chunk-IUBBVF53.js";
20
- import "./chunk-R74LQKAM.js";
17
+ } from "./chunk-6JIVVEQQ.js";
18
+ import "./chunk-J4ZOSNSH.js";
19
+ import "./chunk-UD25QF3H.js";
20
+ import "./chunk-7H34OFDA.js";
21
21
  import "./chunk-JH6IAAFA.js";
22
22
  import "./chunk-LNN5UTS2.js";
23
23
  export {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { A as Agent, a as AgentAbortedError, b as AgentBehavior, c as AgentContextExceededError, d as AgentHooks, 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, l as ChildRunStats, m as ClassifiedError, n as ClassifiedErrorKind, o as CreateSessionOptions, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, 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, K as SkillConfig, L as SkillResource, 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, a9 as matchesContextExceeded, aa as toolOutputByteLength, ab as toolResultToText } from './agent-Cq009tbG.js';
1
+ export { A as Agent, a as AgentAbortedError, b as AgentBehavior, c as AgentContextExceededError, d as AgentHooks, 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, l as ChildRunStats, m as ClassifiedError, n as ClassifiedErrorKind, o as CreateSessionOptions, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, 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, K as SkillConfig, L as SkillResource, 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, a9 as matchesContextExceeded, aa as toolOutputByteLength, ab as toolResultToText } from './agent-CE2jhpNE.js';
2
2
  export { C as ContextCapabilities, a as ContextType, E as ExecResult, b as ExecutionContext, c as ExecutionHandle, S as SpawnConfig } from './types-vA1a_ZX7.js';
3
3
  export { S as SandboxProvider } from './sandbox-CLghrTLi.js';
4
4
  export { Preset } from './presets.js';
5
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, V as ValidationResult } from './validation-BeQD94ft.js';
5
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, V as ValidationResult } from './validation-DlIURVGV.js';
6
6
  import 'hookable';
7
7
  import '@modelcontextprotocol/sdk/client/index.js';
@@ -1,4 +1,4 @@
1
- import { Y as ToolContext, Z as ToolDef, h as AgentStats, l as ChildRunStats } from './agent-Cq009tbG.js';
1
+ import { Y as ToolContext, Z as ToolDef, h as AgentStats, l as ChildRunStats } from './agent-CE2jhpNE.js';
2
2
  import { Preset } from './presets.js';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zidane",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "an agent that goes straight to the goal",
5
5
  "type": "module",
6
6
  "private": false,