zidane 1.6.4 → 1.6.5

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 CHANGED
@@ -174,6 +174,8 @@ await agent.run({ prompt: 'solve this', thinking: 'high', behavior: { thinkingBu
174
174
  const agent = createAgent({ provider, harness, behavior: { thinkingBudget: 16384 } })
175
175
  ```
176
176
 
177
+ Thinking traces are stored in session turns as `{ type: 'thinking', text }` content blocks and streamed live via the `stream:thinking` hook. Supported by Anthropic (native) and OpenRouter/Cerebras (`reasoning_content`/`reasoning` SSE fields).
178
+
177
179
  ## Hooks
178
180
 
179
181
  Every hook receives a mutable context object.
@@ -214,6 +216,11 @@ agent.hooks.hook('stream:end', (ctx) => {
214
216
  // ctx.text (final), ctx.turnId
215
217
  // Only fires when there is text content (not on tool-only turns)
216
218
  })
219
+
220
+ agent.hooks.hook('stream:thinking', (ctx) => {
221
+ // ctx.delta, ctx.thinking (accumulated), ctx.turnId
222
+ // Fires when the model streams reasoning traces (Anthropic, OpenRouter)
223
+ })
217
224
  ```
218
225
 
219
226
  ### Tool execution
@@ -582,7 +589,7 @@ import type { Agent, SessionTurn, TurnUsage, Provider, ToolDef } from 'zidane/ty
582
589
  bun test
583
590
  ```
584
591
 
585
- 474+ tests with mock provider and execution context. No API keys or Docker needed.
592
+ 484+ tests with mock provider and execution context. No API keys or Docker needed.
586
593
 
587
594
  ## License
588
595
 
@@ -164,6 +164,7 @@ interface ToolResult {
164
164
  }
165
165
  interface StreamCallbacks {
166
166
  onText: (delta: string) => void;
167
+ onThinking?: (delta: string) => void;
167
168
  }
168
169
  interface TurnResult {
169
170
  /** Full assistant turn as a SessionMessage */
@@ -513,6 +514,11 @@ interface AgentHooks {
513
514
  text: string;
514
515
  turnId: string;
515
516
  }) => void;
517
+ 'stream:thinking': (ctx: {
518
+ delta: string;
519
+ thinking: string;
520
+ turnId: string;
521
+ }) => void;
516
522
  'tool:before': (ctx: {
517
523
  name: string;
518
524
  input: Record<string, unknown>;
@@ -420,6 +420,7 @@ async function executeTurn(ctx, turn) {
420
420
  await ctx.hooks.callHook("context:transform", { messages });
421
421
  await ctx.hooks.callHook("turn:before", { turn, turnId, options: streamOptions });
422
422
  let currentText = "";
423
+ let currentThinking = "";
423
424
  let result;
424
425
  try {
425
426
  result = await ctx.provider.stream(
@@ -428,6 +429,10 @@ async function executeTurn(ctx, turn) {
428
429
  onText(delta) {
429
430
  currentText += delta;
430
431
  ctx.hooks.callHook("stream:text", { delta, text: currentText, turnId });
432
+ },
433
+ onThinking(delta) {
434
+ currentThinking += delta;
435
+ ctx.hooks.callHook("stream:thinking", { delta, thinking: currentThinking, turnId });
431
436
  }
432
437
  }
433
438
  );
@@ -4,7 +4,7 @@ import {
4
4
  shell,
5
5
  spawn,
6
6
  writeFile
7
- } from "./chunk-KWNFSVVE.js";
7
+ } from "./chunk-R7PIZ4MU.js";
8
8
 
9
9
  // src/harnesses/basic.ts
10
10
  var basicTools = { shell, readFile, writeFile, listFiles };
@@ -6,6 +6,7 @@ async function consumeSSE(response, callbacks, signal) {
6
6
  const decoder = new TextDecoder();
7
7
  let buffer = "";
8
8
  let text = "";
9
+ let thinking = "";
9
10
  let finishReason = "stop";
10
11
  let usage = { input: 0, output: 0 };
11
12
  const tcMap = /* @__PURE__ */ new Map();
@@ -36,6 +37,11 @@ async function consumeSSE(response, callbacks, signal) {
36
37
  continue;
37
38
  if (choice.finish_reason)
38
39
  finishReason = choice.finish_reason;
40
+ const thinkingDelta = choice.delta?.reasoning_content ?? choice.delta?.reasoning;
41
+ if (thinkingDelta) {
42
+ thinking += thinkingDelta;
43
+ callbacks.onThinking?.(thinkingDelta);
44
+ }
39
45
  if (choice.delta?.content) {
40
46
  text += choice.delta.content;
41
47
  callbacks.onText(choice.delta.content);
@@ -72,7 +78,7 @@ async function consumeSSE(response, callbacks, signal) {
72
78
  name: tc.name,
73
79
  input: tc.args ? JSON.parse(tc.args) : {}
74
80
  }));
75
- return { text, toolCalls, finishReason, usage };
81
+ return { text, thinking, toolCalls, finishReason, usage };
76
82
  }
77
83
  function toOAIMessages(system, messages) {
78
84
  const out = [{ role: "system", content: system }];
@@ -156,8 +162,10 @@ function toolResultsMessage(results) {
156
162
  }))
157
163
  };
158
164
  }
159
- function buildAssistantContent(text, toolCalls) {
165
+ function buildAssistantContent(text, toolCalls, thinking) {
160
166
  const content = [];
167
+ if (thinking)
168
+ content.push({ type: "thinking", text: thinking });
161
169
  if (text)
162
170
  content.push({ type: "text", text });
163
171
  for (const tc of toolCalls) {
@@ -1,4 +1,4 @@
1
1
  import 'hookable';
2
- export { H as Harness, i as HarnessConfig, u as ToolContext, v as ToolDef, x as ToolMap, a1 as basic, a2 as basicTools, Q as defineHarness, X as noTools } from './agent-CPOBJlcn.js';
2
+ export { H as Harness, i as HarnessConfig, u as ToolContext, v as ToolDef, x as ToolMap, a1 as basic, a2 as basicTools, Q as defineHarness, X as noTools } from './agent-BDZbObgy.js';
3
3
  import './types-CKXAp41h.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/harnesses.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  basic_default,
4
4
  defineHarness,
5
5
  noTools
6
- } from "./chunk-BDBQ5MIB.js";
7
- import "./chunk-KWNFSVVE.js";
6
+ } from "./chunk-TWRNLI6I.js";
7
+ import "./chunk-R7PIZ4MU.js";
8
8
  import "./chunk-NNMWWSBY.js";
9
9
  import "./chunk-4C6Y56CC.js";
10
10
  export {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { A as Agent, a as AgentBehavior, b as AgentHooks, c as AgentOptions, d as AgentRunOptions, e as AgentStats, h as CreateSessionOptions, H as Harness, i as HarnessConfig, I as ImageContent, M as McpConnection, j as McpServerConfig, R as RemoteStoreOptions, S as Session, k as SessionContentBlock, l as SessionData, m as SessionMessage, n as SessionRun, o as SessionStore, p as SessionTurn, q as SqliteStoreOptions, T as ThinkingLevel, u as ToolContext, v as ToolDef, w as ToolExecutionMode, x as ToolMap, D as TurnUsage, E as autoDetectAndConvert, F as connectMcpServers, G as createAgent, J as createMemoryStore, K as createRemoteStore, L as createSession, N as createSqliteStore, Q as defineHarness, U as fromAnthropic, V as fromOpenAI, W as loadSession, X as noTools, Y as toAnthropic, Z as toOpenAI } from './agent-CPOBJlcn.js';
1
+ export { A as Agent, a as AgentBehavior, b as AgentHooks, c as AgentOptions, d as AgentRunOptions, e as AgentStats, h as CreateSessionOptions, H as Harness, i as HarnessConfig, I as ImageContent, M as McpConnection, j as McpServerConfig, R as RemoteStoreOptions, S as Session, k as SessionContentBlock, l as SessionData, m as SessionMessage, n as SessionRun, o as SessionStore, p as SessionTurn, q as SqliteStoreOptions, T as ThinkingLevel, u as ToolContext, v as ToolDef, w as ToolExecutionMode, x as ToolMap, D as TurnUsage, E as autoDetectAndConvert, F as connectMcpServers, G as createAgent, J as createMemoryStore, K as createRemoteStore, L as createSession, N as createSqliteStore, Q as defineHarness, U as fromAnthropic, V as fromOpenAI, W as loadSession, X as noTools, Y as toAnthropic, Z as toOpenAI } from './agent-BDZbObgy.js';
2
2
  import { f as SpawnConfig, b as ExecutionContext } from './types-CKXAp41h.js';
3
3
  export { C as ContextCapabilities, a as ContextType, E as ExecResult, c as ExecutionHandle, S as SkillConfig, d as SkillResource, e as SkillsConfig } from './types-CKXAp41h.js';
4
4
  export { S as SandboxProvider, c as createSandboxContext } from './sandbox-DZn3ybp_.js';
5
5
  export { buildCatalog, defineSkill, discoverSkills, interpolateShellCommands, mergeSkillsConfig, parseSkillFile, resolveSkills, validateSkillName, writeSkillToDisk, writeSkillsToDisk } from './skills.js';
6
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-CK08YMPC.js';
6
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-CQieNB1Y.js';
7
7
  import 'hookable';
8
8
  import '@modelcontextprotocol/sdk/client/index.js';
9
9
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineHarness,
3
3
  noTools
4
- } from "./chunk-BDBQ5MIB.js";
4
+ } from "./chunk-TWRNLI6I.js";
5
5
  import {
6
6
  createAgent,
7
7
  createDockerContext,
@@ -10,7 +10,7 @@ import {
10
10
  createSandboxContext,
11
11
  createSpawnTool,
12
12
  spawn
13
- } from "./chunk-KWNFSVVE.js";
13
+ } from "./chunk-R7PIZ4MU.js";
14
14
  import {
15
15
  connectMcpServers
16
16
  } from "./chunk-NNMWWSBY.js";
@@ -27,7 +27,7 @@ import {
27
27
  fromOpenAI,
28
28
  toAnthropic,
29
29
  toOpenAI
30
- } from "./chunk-UHCWNQGG.js";
30
+ } from "./chunk-UUITMJ7G.js";
31
31
  import {
32
32
  defineSkill
33
33
  } from "./chunk-CFLC2I7D.js";
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import 'hookable';
2
- export { M as McpConnection, j as McpServerConfig, F as connectMcpServers, a3 as resultToString } from './agent-CPOBJlcn.js';
2
+ export { M as McpConnection, j as McpServerConfig, F as connectMcpServers, a3 as resultToString } from './agent-BDZbObgy.js';
3
3
  import '@modelcontextprotocol/sdk/client/index.js';
4
4
  import './types-CKXAp41h.js';
@@ -1,4 +1,4 @@
1
- export { f as AnthropicParams, C as CerebrasParams, O as OpenRouterParams, P as Provider, r as StreamCallbacks, s as StreamOptions, t as ToolCall, y as ToolResult, z as ToolSpec, B as TurnResult, _ as anthropic, $ as cerebras, a0 as openrouter } from './agent-CPOBJlcn.js';
1
+ export { f as AnthropicParams, C as CerebrasParams, O as OpenRouterParams, P as Provider, r as StreamCallbacks, s as StreamOptions, t as ToolCall, y as ToolResult, z as ToolSpec, B as TurnResult, _ as anthropic, $ as cerebras, a0 as openrouter } from './agent-BDZbObgy.js';
2
2
  import 'hookable';
3
3
  import './types-CKXAp41h.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/providers.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  toOAIMessages,
9
9
  toolResultsMessage,
10
10
  userMessage
11
- } from "./chunk-UHCWNQGG.js";
11
+ } from "./chunk-UUITMJ7G.js";
12
12
 
13
13
  // src/providers/anthropic.ts
14
14
  import { existsSync, readFileSync } from "fs";
@@ -127,6 +127,11 @@ function anthropic(anthropicParams) {
127
127
  text += delta;
128
128
  callbacks.onText(delta);
129
129
  });
130
+ if (callbacks.onThinking) {
131
+ s.on("thinking", (delta) => {
132
+ callbacks.onThinking(delta);
133
+ });
134
+ }
130
135
  const response = await s.finalMessage();
131
136
  const toolCalls = response.content.filter((b) => b.type === "tool_use").map((b) => ({ id: b.id, name: b.name, input: b.input }));
132
137
  return {
@@ -198,7 +203,7 @@ function cerebras(params) {
198
203
  }
199
204
  const result = await consumeSSE(response, callbacks, options.signal);
200
205
  return {
201
- assistantMessage: buildAssistantContent(result.text, result.toolCalls),
206
+ assistantMessage: buildAssistantContent(result.text, result.toolCalls, result.thinking),
202
207
  text: result.text,
203
208
  toolCalls: result.toolCalls,
204
209
  done: result.finishReason === "stop" || result.toolCalls.length === 0,
@@ -266,7 +271,7 @@ function openrouter(params) {
266
271
  }
267
272
  const result = await consumeSSE(response, callbacks, options.signal);
268
273
  return {
269
- assistantMessage: buildAssistantContent(result.text, result.toolCalls),
274
+ assistantMessage: buildAssistantContent(result.text, result.toolCalls, result.thinking),
270
275
  text: result.text,
271
276
  toolCalls: result.toolCalls,
272
277
  done: result.finishReason === "stop" || result.toolCalls.length === 0,
package/dist/session.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { h as CreateSessionOptions, R as RemoteStoreOptions, S as Session, k as SessionContentBlock, l as SessionData, m as SessionMessage, n as SessionRun, o as SessionStore, p as SessionTurn, q as SqliteStoreOptions, E as autoDetectAndConvert, J as createMemoryStore, K as createRemoteStore, L as createSession, N as createSqliteStore, U as fromAnthropic, V as fromOpenAI, W as loadSession, Y as toAnthropic, Z as toOpenAI } from './agent-CPOBJlcn.js';
1
+ export { h as CreateSessionOptions, R as RemoteStoreOptions, S as Session, k as SessionContentBlock, l as SessionData, m as SessionMessage, n as SessionRun, o as SessionStore, p as SessionTurn, q as SqliteStoreOptions, E as autoDetectAndConvert, J as createMemoryStore, K as createRemoteStore, L as createSession, N as createSqliteStore, U as fromAnthropic, V as fromOpenAI, W as loadSession, Y as toAnthropic, Z as toOpenAI } from './agent-BDZbObgy.js';
2
2
  import 'hookable';
3
3
  import './types-CKXAp41h.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-UHCWNQGG.js";
14
+ } from "./chunk-UUITMJ7G.js";
15
15
  export {
16
16
  autoDetectAndConvert,
17
17
  createMemoryStore,
@@ -1,4 +1,4 @@
1
- import { v as ToolDef, i as HarnessConfig, e as AgentStats } from './agent-CPOBJlcn.js';
1
+ import { v as ToolDef, i as HarnessConfig, e as AgentStats } from './agent-BDZbObgy.js';
2
2
 
3
3
  /**
4
4
  * Interaction tool — lets the agent request structured input from the outside world.
package/dist/tools.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-CK08YMPC.js';
2
- import { v as ToolDef } from './agent-CPOBJlcn.js';
1
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-CQieNB1Y.js';
2
+ import { v as ToolDef } from './agent-BDZbObgy.js';
3
3
  export { V as ValidationResult, v as validateToolArgs } from './validation-DOY_k7lW.js';
4
4
  import 'hookable';
5
5
  import './types-CKXAp41h.js';
package/dist/tools.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  spawn,
8
8
  validateToolArgs,
9
9
  writeFile
10
- } from "./chunk-KWNFSVVE.js";
10
+ } from "./chunk-R7PIZ4MU.js";
11
11
  import "./chunk-NNMWWSBY.js";
12
12
  import "./chunk-4C6Y56CC.js";
13
13
  export {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { A as Agent, a as AgentBehavior, b as AgentHooks, c as AgentOptions, d as AgentRunOptions, e as AgentStats, f as AnthropicParams, C as CerebrasParams, g as ChildRunStats, h as CreateSessionOptions, H as Harness, i as HarnessConfig, I as ImageContent, M as McpConnection, j as McpServerConfig, O as OpenRouterParams, P as Provider, R as RemoteStoreOptions, S as Session, k as SessionContentBlock, l as SessionData, m as SessionMessage, n as SessionRun, o as SessionStore, p as SessionTurn, q as SqliteStoreOptions, r as StreamCallbacks, s as StreamOptions, T as ThinkingLevel, t as ToolCall, u as ToolContext, v as ToolDef, w as ToolExecutionMode, x as ToolMap, y as ToolResult, z as ToolSpec, B as TurnResult, D as TurnUsage } from './agent-CPOBJlcn.js';
1
+ export { A as Agent, a as AgentBehavior, b as AgentHooks, c as AgentOptions, d as AgentRunOptions, e as AgentStats, f as AnthropicParams, C as CerebrasParams, g as ChildRunStats, h as CreateSessionOptions, H as Harness, i as HarnessConfig, I as ImageContent, M as McpConnection, j as McpServerConfig, O as OpenRouterParams, P as Provider, R as RemoteStoreOptions, S as Session, k as SessionContentBlock, l as SessionData, m as SessionMessage, n as SessionRun, o as SessionStore, p as SessionTurn, q as SqliteStoreOptions, r as StreamCallbacks, s as StreamOptions, T as ThinkingLevel, t as ToolCall, u as ToolContext, v as ToolDef, w as ToolExecutionMode, x as ToolMap, y as ToolResult, z as ToolSpec, B as TurnResult, D as TurnUsage } from './agent-BDZbObgy.js';
2
2
  export { C as ContextCapabilities, a as ContextType, E as ExecResult, b as ExecutionContext, c as ExecutionHandle, S as SkillConfig, d as SkillResource, e as SkillsConfig, f as SpawnConfig } from './types-CKXAp41h.js';
3
3
  export { S as SandboxProvider } from './sandbox-DZn3ybp_.js';
4
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState } from './spawn-CK08YMPC.js';
4
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState } from './spawn-CQieNB1Y.js';
5
5
  export { V as ValidationResult } from './validation-DOY_k7lW.js';
6
6
  import 'hookable';
7
7
  import '@modelcontextprotocol/sdk/client/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zidane",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "an agent that goes straight to the goal",
5
5
  "type": "module",
6
6
  "private": false,