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 +8 -1
- package/dist/{agent-CPOBJlcn.d.ts → agent-BDZbObgy.d.ts} +6 -0
- package/dist/{chunk-KWNFSVVE.js → chunk-R7PIZ4MU.js} +5 -0
- package/dist/{chunk-BDBQ5MIB.js → chunk-TWRNLI6I.js} +1 -1
- package/dist/{chunk-UHCWNQGG.js → chunk-UUITMJ7G.js} +10 -2
- package/dist/harnesses.d.ts +1 -1
- package/dist/harnesses.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/mcp.d.ts +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +8 -3
- package/dist/session.d.ts +1 -1
- package/dist/session.js +1 -1
- package/dist/{spawn-CK08YMPC.d.ts → spawn-CQieNB1Y.d.ts} +1 -1
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
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
|
-
|
|
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
|
);
|
|
@@ -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) {
|
package/dist/harnesses.d.ts
CHANGED
|
@@ -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-
|
|
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
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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';
|
package/dist/providers.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as ToolDef, i as HarnessConfig, e as AgentStats } from './agent-
|
|
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-
|
|
2
|
-
import { v as ToolDef } from './agent-
|
|
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
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-
|
|
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-
|
|
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';
|