zidane 1.8.0 → 1.8.1

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.
@@ -811,16 +811,6 @@ interface RemoteStoreOptions {
811
811
  }
812
812
  declare function createRemoteStore(options: RemoteStoreOptions): SessionStore;
813
813
 
814
- /**
815
- * SQLite session store using Bun's built-in bun:sqlite.
816
- */
817
-
818
- interface SqliteStoreOptions {
819
- /** Path to the SQLite database file */
820
- path: string;
821
- }
822
- declare function createSqliteStore(options: SqliteStoreOptions): SessionStore;
823
-
824
814
  /**
825
815
  * Session management for agents.
826
816
  *
@@ -1114,4 +1104,4 @@ interface Agent {
1114
1104
  }
1115
1105
  declare function createAgent({ harness: harnessOption, provider, behavior: agentBehavior, execution, mcpServers, session, skills: agentSkills, _mcpConnector }: AgentOptions): Agent;
1116
1106
 
1117
- export { type ToolResult as $, type Agent as A, type SessionEndStatus as B, CONTEXT_EXCEEDED_MESSAGE_PATTERNS as C, type SessionHookContext as D, type SessionMessage as E, type SessionRun as F, type SessionStore as G, type Harness as H, type ImageContent as I, type SessionTurn as J, type SpawnHookContext as K, type SqliteStoreOptions as L, type McpConnection as M, type StreamCallbacks as N, type OAuthRefreshHookContext as O, type PromptDocumentPart as P, type StreamHookContext as Q, type RemoteStoreOptions as R, type Session as S, type StreamOptions as T, type ThinkingLevel as U, type ToolCall as V, type ToolContext as W, type ToolDef as X, type ToolExecutionMode as Y, type ToolHookContext as Z, type ToolMap as _, AgentAbortedError as a, type ToolSpec as a0, type TurnFinishReason as a1, type TurnResult as a2, type TurnUsage as a3, matchesContextExceeded as a4, type FileMapAdapter as a5, type FileMapStoreOptions as a6, type OpenAICompatAuthHeader as a7, OpenAICompatHttpError as a8, type OpenAICompatParams as a9, resultToString as aA, anthropic as aa, autoDetectAndConvert as ab, cerebras as ac, classifyOpenAICompatError as ad, connectMcpServers as ae, createAgent as af, createFileMapStore as ag, createMemoryStore as ah, createRemoteStore as ai, createSession as aj, createSqliteStore as ak, defineHarness as al, fromAnthropic as am, fromOpenAI as an, loadSession as ao, mapOAIFinishReason as ap, noTools as aq, normalizeMcpServers as ar, openai as as, openaiCompat as at, openrouter as au, toAnthropic as av, toOpenAI as aw, toTypedError as ax, _default as ay, basicTools as az, type AgentBehavior as b, AgentContextExceededError as c, type AgentHooks as d, type AgentOptions as e, AgentProviderError as f, type AgentRunOptions as g, type AgentStats as h, type AnthropicParams as i, type CerebrasParams as j, type ChildRunStats as k, type ClassifiedError as l, type ClassifiedErrorKind as m, type CreateSessionOptions as n, type HarnessConfig as o, type McpServerConfig as p, type McpToolHookContext as q, type OpenAIParams as r, type OpenRouterParams as s, type PromptImagePart as t, type PromptPart as u, type PromptTextPart as v, type Provider as w, type RunHookMap as x, type SessionContentBlock as y, type SessionData as z };
1107
+ export { type ToolSpec as $, type Agent as A, type SessionEndStatus as B, CONTEXT_EXCEEDED_MESSAGE_PATTERNS as C, type SessionHookContext as D, type SessionMessage as E, type SessionRun as F, type SessionStore as G, type Harness as H, type ImageContent as I, type SessionTurn as J, type SpawnHookContext as K, type StreamCallbacks as L, type McpConnection as M, type StreamHookContext as N, type OAuthRefreshHookContext as O, type PromptDocumentPart as P, type StreamOptions as Q, type RemoteStoreOptions as R, type Session as S, type ThinkingLevel as T, type ToolCall as U, type ToolContext as V, type ToolDef as W, type ToolExecutionMode as X, type ToolHookContext as Y, type ToolMap as Z, type ToolResult as _, AgentAbortedError as a, type TurnFinishReason as a0, type TurnResult as a1, type TurnUsage as a2, matchesContextExceeded as a3, type FileMapAdapter as a4, type FileMapStoreOptions as a5, type OpenAICompatAuthHeader as a6, OpenAICompatHttpError as a7, type OpenAICompatParams as a8, anthropic as a9, autoDetectAndConvert as aa, cerebras as ab, classifyOpenAICompatError as ac, connectMcpServers as ad, createAgent as ae, createFileMapStore as af, createMemoryStore as ag, createRemoteStore as ah, createSession as ai, defineHarness as aj, fromAnthropic as ak, fromOpenAI as al, loadSession as am, mapOAIFinishReason as an, noTools as ao, normalizeMcpServers as ap, openai as aq, openaiCompat as ar, openrouter as as, toAnthropic as at, toOpenAI as au, toTypedError as av, _default as aw, basicTools as ax, resultToString as ay, type AgentBehavior as b, AgentContextExceededError as c, type AgentHooks as d, type AgentOptions as e, AgentProviderError as f, type AgentRunOptions as g, type AgentStats as h, type AnthropicParams as i, type CerebrasParams as j, type ChildRunStats as k, type ClassifiedError as l, type ClassifiedErrorKind as m, type CreateSessionOptions as n, type HarnessConfig as o, type McpServerConfig as p, type McpToolHookContext as q, type OpenAIParams as r, type OpenRouterParams as s, type PromptImagePart as t, type PromptPart as u, type PromptTextPart as v, type Provider as w, type RunHookMap as x, type SessionContentBlock as y, type SessionData as z };
@@ -13,7 +13,6 @@ import {
13
13
  // src/providers/anthropic.ts
14
14
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
15
15
  import { resolve as resolve2 } from "path";
16
- import Anthropic from "@anthropic-ai/sdk";
17
16
 
18
17
  // src/providers/oauth.ts
19
18
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -88,6 +87,21 @@ async function resolveOAuthApiKey(options, callbacks) {
88
87
 
89
88
  // src/providers/anthropic.ts
90
89
  var CREDENTIALS_FILE2 = resolve2(process.cwd(), ".credentials.json");
90
+ var _sdkCtor = null;
91
+ async function loadAnthropicSdk() {
92
+ if (_sdkCtor)
93
+ return _sdkCtor;
94
+ try {
95
+ const mod = await import("@anthropic-ai/sdk");
96
+ _sdkCtor = mod.default;
97
+ return _sdkCtor;
98
+ } catch (err) {
99
+ throw new Error(
100
+ "The `anthropic` provider requires the `@anthropic-ai/sdk` package, which is an optional peer dependency. Install it with your package manager (e.g. `bun add @anthropic-ai/sdk`).",
101
+ err instanceof Error ? { cause: err } : void 0
102
+ );
103
+ }
104
+ }
91
105
  function getConfiguredApiKey(anthropicParams) {
92
106
  if (anthropicParams?.apiKey)
93
107
  return anthropicParams.apiKey;
@@ -102,9 +116,9 @@ function getConfiguredApiKey(anthropicParams) {
102
116
  }
103
117
  throw new Error("No API key found. Run `bun run auth` first.");
104
118
  }
105
- function createClient(apiKey, isOAuth, baseURL) {
119
+ function createClient(SDK, apiKey, isOAuth, baseURL) {
106
120
  const base = baseURL ? { baseURL } : {};
107
- return new Anthropic(
121
+ return new SDK(
108
122
  isOAuth ? {
109
123
  apiKey: null,
110
124
  authToken: apiKey,
@@ -144,13 +158,19 @@ function mapStopReason(stopReason) {
144
158
  return "other";
145
159
  }
146
160
  }
161
+ function looksLikeAnthropicApiError(err) {
162
+ if (!err || typeof err !== "object")
163
+ return false;
164
+ const e = err;
165
+ return typeof e.status === "number" && "error" in e;
166
+ }
147
167
  function classifyAnthropicError(err) {
148
168
  if (!err || typeof err !== "object")
149
169
  return null;
150
170
  const anyErr = err;
151
171
  if (anyErr.name === "AbortError")
152
172
  return { kind: "aborted" };
153
- if (!(err instanceof Anthropic.APIError))
173
+ if (!looksLikeAnthropicApiError(err))
154
174
  return null;
155
175
  const innerType = anyErr.error?.error?.type;
156
176
  const outerType = anyErr.error?.type;
@@ -246,6 +266,7 @@ function anthropic(anthropicParams) {
246
266
  promptMessage: anthropicPromptMessage,
247
267
  classifyError: classifyAnthropicError,
248
268
  async stream(options, callbacks) {
269
+ const SDK = await loadAnthropicSdk();
249
270
  const apiKey = await resolveOAuthApiKey(
250
271
  {
251
272
  provider: "anthropic",
@@ -269,7 +290,7 @@ function anthropic(anthropicParams) {
269
290
  }
270
291
  }
271
292
  );
272
- const client = createClient(apiKey, apiKey.includes("sk-ant-oat"), anthropicParams?.baseURL);
293
+ const client = createClient(SDK, apiKey, apiKey.includes("sk-ant-oat"), anthropicParams?.baseURL);
273
294
  const system = isOAuth ? `You are Claude Code, Anthropic's official CLI for Claude.` : options.system;
274
295
  const messages = isOAuth && options.system ? [
275
296
  { role: "user", content: [{ type: "text", text: options.system }] },
@@ -319,102 +319,6 @@ function createRemoteStore(options) {
319
319
  };
320
320
  }
321
321
 
322
- // src/session/sqlite.ts
323
- import { Database } from "bun:sqlite";
324
- function createSqliteStore(options) {
325
- const db = new Database(options.path);
326
- db.run("PRAGMA journal_mode = WAL");
327
- db.run(`
328
- CREATE TABLE IF NOT EXISTS sessions (
329
- id TEXT PRIMARY KEY,
330
- agent_id TEXT,
331
- data TEXT NOT NULL,
332
- created_at INTEGER NOT NULL,
333
- updated_at INTEGER NOT NULL
334
- )
335
- `);
336
- db.run(`CREATE INDEX IF NOT EXISTS idx_sessions_agent_id ON sessions(agent_id)`);
337
- const stmtLoad = db.prepare("SELECT data FROM sessions WHERE id = ?");
338
- const stmtUpsert = db.prepare(`
339
- INSERT INTO sessions (id, agent_id, data, created_at, updated_at)
340
- VALUES (?, ?, ?, ?, ?)
341
- ON CONFLICT(id) DO UPDATE SET
342
- agent_id = excluded.agent_id,
343
- data = excluded.data,
344
- updated_at = excluded.updated_at
345
- `);
346
- const stmtDelete = db.prepare("DELETE FROM sessions WHERE id = ?");
347
- const stmtList = db.prepare("SELECT id FROM sessions ORDER BY updated_at DESC");
348
- const stmtListByAgent = db.prepare("SELECT id FROM sessions WHERE agent_id = ? ORDER BY updated_at DESC");
349
- const store = {
350
- async load(sessionId) {
351
- const row = stmtLoad.get(sessionId);
352
- if (!row)
353
- return null;
354
- return JSON.parse(row.data);
355
- },
356
- async save(session) {
357
- stmtUpsert.run(
358
- session.id,
359
- session.agentId ?? null,
360
- JSON.stringify(session),
361
- session.createdAt,
362
- session.updatedAt
363
- );
364
- },
365
- async delete(sessionId) {
366
- stmtDelete.run(sessionId);
367
- },
368
- async list(filter) {
369
- let rows;
370
- if (filter?.agentId) {
371
- rows = stmtListByAgent.all(filter.agentId);
372
- } else {
373
- rows = stmtList.all();
374
- }
375
- const ids = rows.map((r) => r.id);
376
- if (filter?.limit) {
377
- return ids.slice(0, filter.limit);
378
- }
379
- return ids;
380
- },
381
- async appendTurns(sessionId, turns) {
382
- const data = await store.load(sessionId);
383
- if (data) {
384
- data.turns.push(...turns);
385
- data.updatedAt = Date.now();
386
- await store.save(data);
387
- }
388
- },
389
- async getTurns(sessionId, from = 0, limit) {
390
- const data = await store.load(sessionId);
391
- if (!data)
392
- return [];
393
- return data.turns.slice(from, limit !== void 0 ? from + limit : void 0);
394
- },
395
- async updateRun(sessionId, run) {
396
- const data = await store.load(sessionId);
397
- if (data) {
398
- const idx = data.runs.findIndex((r) => r.id === run.id);
399
- if (idx >= 0) {
400
- data.runs[idx] = run;
401
- }
402
- data.updatedAt = Date.now();
403
- await store.save(data);
404
- }
405
- },
406
- async updateStatus(sessionId, status) {
407
- const data = await store.load(sessionId);
408
- if (data) {
409
- data.status = status;
410
- data.updatedAt = Date.now();
411
- await store.save(data);
412
- }
413
- }
414
- };
415
- return store;
416
- }
417
-
418
322
  // src/session/index.ts
419
323
  async function createSession(options = {}) {
420
324
  const store = options.store;
@@ -579,7 +483,6 @@ export {
579
483
  createFileMapStore,
580
484
  createMemoryStore,
581
485
  createRemoteStore,
582
- createSqliteStore,
583
486
  createSession,
584
487
  loadSession
585
488
  };
@@ -1,4 +1,4 @@
1
- import { X as ToolDef } from './agent-CWQ5XOw6.js';
1
+ import { W as ToolDef } from './agent-8QBOx4_0.js';
2
2
 
3
3
  declare const glob: ToolDef;
4
4
 
@@ -1,5 +1,5 @@
1
1
  import 'hookable';
2
- export { H as Harness, o as HarnessConfig, W as ToolContext, X as ToolDef, _ as ToolMap, ay as basic, az as basicTools, al as defineHarness, aq as noTools } from './agent-CWQ5XOw6.js';
2
+ export { H as Harness, o as HarnessConfig, V as ToolContext, W as ToolDef, Z as ToolMap, aw as basic, ax as basicTools, aj as defineHarness, ao as noTools } from './agent-8QBOx4_0.js';
3
3
  import './types-BpvTmawk.js';
4
4
  import './types-CDI8Kmve.js';
5
5
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { d as AgentHooks } from './agent-CWQ5XOw6.js';
2
- export { 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 AnthropicParams, C as CONTEXT_EXCEEDED_MESSAGE_PATTERNS, j as CerebrasParams, l as ClassifiedError, m as ClassifiedErrorKind, n as CreateSessionOptions, a5 as FileMapAdapter, a6 as FileMapStoreOptions, H as Harness, o as HarnessConfig, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, a7 as OpenAICompatAuthHeader, a8 as OpenAICompatHttpError, a9 as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, P as PromptDocumentPart, t as PromptImagePart, u as PromptPart, v as PromptTextPart, w as Provider, R as RemoteStoreOptions, x as RunHookMap, S as Session, y as SessionContentBlock, z as SessionData, B as SessionEndStatus, D as SessionHookContext, E as SessionMessage, F as SessionRun, G as SessionStore, J as SessionTurn, K as SpawnHookContext, L as SqliteStoreOptions, N as StreamCallbacks, Q as StreamHookContext, T as StreamOptions, U as ThinkingLevel, V as ToolCall, W as ToolContext, X as ToolDef, Y as ToolExecutionMode, Z as ToolHookContext, _ as ToolMap, $ as ToolResult, a0 as ToolSpec, a1 as TurnFinishReason, a2 as TurnResult, a3 as TurnUsage, aa as anthropic, ab as autoDetectAndConvert, ac as cerebras, ad as classifyOpenAICompatError, ae as connectMcpServers, af as createAgent, ag as createFileMapStore, ah as createMemoryStore, ai as createRemoteStore, aj as createSession, ak as createSqliteStore, al as defineHarness, am as fromAnthropic, an as fromOpenAI, ao as loadSession, ap as mapOAIFinishReason, a4 as matchesContextExceeded, aq as noTools, ar as normalizeMcpServers, as as openai, at as openaiCompat, au as openrouter, av as toAnthropic, aw as toOpenAI, ax as toTypedError } from './agent-CWQ5XOw6.js';
1
+ import { d as AgentHooks } from './agent-8QBOx4_0.js';
2
+ export { 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 AnthropicParams, C as CONTEXT_EXCEEDED_MESSAGE_PATTERNS, j as CerebrasParams, l as ClassifiedError, m as ClassifiedErrorKind, n as CreateSessionOptions, a4 as FileMapAdapter, a5 as FileMapStoreOptions, H as Harness, o as HarnessConfig, I as ImageContent, M as McpConnection, p as McpServerConfig, q as McpToolHookContext, O as OAuthRefreshHookContext, a6 as OpenAICompatAuthHeader, a7 as OpenAICompatHttpError, a8 as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, P as PromptDocumentPart, t as PromptImagePart, u as PromptPart, v as PromptTextPart, w as Provider, R as RemoteStoreOptions, x as RunHookMap, S as Session, y as SessionContentBlock, z as SessionData, B as SessionEndStatus, D as SessionHookContext, E as SessionMessage, F as SessionRun, G as SessionStore, J as SessionTurn, K as SpawnHookContext, L as StreamCallbacks, N as StreamHookContext, Q as StreamOptions, T as ThinkingLevel, U as ToolCall, V as ToolContext, W as ToolDef, X as ToolExecutionMode, Y as ToolHookContext, Z as ToolMap, _ as ToolResult, $ as ToolSpec, a0 as TurnFinishReason, a1 as TurnResult, a2 as TurnUsage, a9 as anthropic, aa as autoDetectAndConvert, ab as cerebras, ac as classifyOpenAICompatError, ad as connectMcpServers, ae as createAgent, af as createFileMapStore, ag as createMemoryStore, ah as createRemoteStore, ai as createSession, aj as defineHarness, ak as fromAnthropic, al as fromOpenAI, am as loadSession, an as mapOAIFinishReason, a3 as matchesContextExceeded, ao as noTools, ap as normalizeMcpServers, aq as openai, ar as openaiCompat, as as openrouter, at as toAnthropic, au as toOpenAI, av as toTypedError } from './agent-8QBOx4_0.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
6
  export { buildCatalog, defineSkill, discoverSkills, interpolateShellCommands, mergeSkillsConfig, parseSkillFile, resolveSkills, validateSkillName, writeSkillToDisk, writeSkillsToDisk } from './skills.js';
7
7
  export { S as SkillConfig, a as SkillResource, b as SkillsConfig } from './types-CDI8Kmve.js';
8
- export { g as glob } from './glob-j9gbk6xm.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-EEv1Johs.js';
8
+ export { g as glob } from './glob-Bo0GAiKk.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-jjxPcNcH.js';
10
10
  import { Hookable } from 'hookable';
11
11
  import '@modelcontextprotocol/sdk/client/index.js';
12
12
 
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  cerebras,
7
7
  openai,
8
8
  openrouter
9
- } from "./chunk-WQBKOZVI.js";
9
+ } from "./chunk-3S377TS4.js";
10
10
  import {
11
11
  defineHarness,
12
12
  noTools
@@ -43,9 +43,8 @@ import {
43
43
  createMemoryStore,
44
44
  createRemoteStore,
45
45
  createSession,
46
- createSqliteStore,
47
46
  loadSession
48
- } from "./chunk-2IB4XBQE.js";
47
+ } from "./chunk-VG2E6YK3.js";
49
48
  import {
50
49
  OpenAICompatHttpError,
51
50
  autoDetectAndConvert,
@@ -200,7 +199,6 @@ export {
200
199
  createSandboxContext,
201
200
  createSession,
202
201
  createSpawnTool,
203
- createSqliteStore,
204
202
  createTracingHooks,
205
203
  defineHarness,
206
204
  defineSkill,
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'hookable';
2
- export { M as McpConnection, p as McpServerConfig, ae as connectMcpServers, ar as normalizeMcpServers, aA as resultToString } from './agent-CWQ5XOw6.js';
2
+ export { M as McpConnection, p as McpServerConfig, ad as connectMcpServers, ap as normalizeMcpServers, ay as resultToString } from './agent-8QBOx4_0.js';
3
3
  import '@modelcontextprotocol/sdk/client/index.js';
4
4
  import './types-BpvTmawk.js';
5
5
  import './types-CDI8Kmve.js';
@@ -1,4 +1,4 @@
1
- export { i as AnthropicParams, j as CerebrasParams, a7 as OpenAICompatAuthHeader, a8 as OpenAICompatHttpError, a9 as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, w as Provider, N as StreamCallbacks, T as StreamOptions, V as ToolCall, $ as ToolResult, a0 as ToolSpec, a2 as TurnResult, aa as anthropic, ac as cerebras, ad as classifyOpenAICompatError, ap as mapOAIFinishReason, as as openai, at as openaiCompat, au as openrouter } from './agent-CWQ5XOw6.js';
1
+ export { i as AnthropicParams, j as CerebrasParams, a6 as OpenAICompatAuthHeader, a7 as OpenAICompatHttpError, a8 as OpenAICompatParams, r as OpenAIParams, s as OpenRouterParams, w as Provider, L as StreamCallbacks, Q as StreamOptions, U as ToolCall, _ as ToolResult, $ as ToolSpec, a1 as TurnResult, a9 as anthropic, ab as cerebras, ac as classifyOpenAICompatError, an as mapOAIFinishReason, aq as openai, ar as openaiCompat, as as openrouter } from './agent-8QBOx4_0.js';
2
2
  import 'hookable';
3
3
  import './types-BpvTmawk.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/providers.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  cerebras,
4
4
  openai,
5
5
  openrouter
6
- } from "./chunk-WQBKOZVI.js";
6
+ } from "./chunk-3S377TS4.js";
7
7
  import {
8
8
  OpenAICompatHttpError,
9
9
  classifyOpenAICompatError,
@@ -0,0 +1,17 @@
1
+ import { G as SessionStore } from '../agent-8QBOx4_0.js';
2
+ import 'hookable';
3
+ import '../types-BpvTmawk.js';
4
+ import '@modelcontextprotocol/sdk/client/index.js';
5
+ import '../types-CDI8Kmve.js';
6
+
7
+ /**
8
+ * SQLite session store using Bun's built-in bun:sqlite.
9
+ */
10
+
11
+ interface SqliteStoreOptions {
12
+ /** Path to the SQLite database file */
13
+ path: string;
14
+ }
15
+ declare function createSqliteStore(options: SqliteStoreOptions): SessionStore;
16
+
17
+ export { type SqliteStoreOptions, createSqliteStore };
@@ -0,0 +1,98 @@
1
+ // src/session/sqlite.ts
2
+ import { Database } from "bun:sqlite";
3
+ function createSqliteStore(options) {
4
+ const db = new Database(options.path);
5
+ db.run("PRAGMA journal_mode = WAL");
6
+ db.run(`
7
+ CREATE TABLE IF NOT EXISTS sessions (
8
+ id TEXT PRIMARY KEY,
9
+ agent_id TEXT,
10
+ data TEXT NOT NULL,
11
+ created_at INTEGER NOT NULL,
12
+ updated_at INTEGER NOT NULL
13
+ )
14
+ `);
15
+ db.run(`CREATE INDEX IF NOT EXISTS idx_sessions_agent_id ON sessions(agent_id)`);
16
+ const stmtLoad = db.prepare("SELECT data FROM sessions WHERE id = ?");
17
+ const stmtUpsert = db.prepare(`
18
+ INSERT INTO sessions (id, agent_id, data, created_at, updated_at)
19
+ VALUES (?, ?, ?, ?, ?)
20
+ ON CONFLICT(id) DO UPDATE SET
21
+ agent_id = excluded.agent_id,
22
+ data = excluded.data,
23
+ updated_at = excluded.updated_at
24
+ `);
25
+ const stmtDelete = db.prepare("DELETE FROM sessions WHERE id = ?");
26
+ const stmtList = db.prepare("SELECT id FROM sessions ORDER BY updated_at DESC");
27
+ const stmtListByAgent = db.prepare("SELECT id FROM sessions WHERE agent_id = ? ORDER BY updated_at DESC");
28
+ const store = {
29
+ async load(sessionId) {
30
+ const row = stmtLoad.get(sessionId);
31
+ if (!row)
32
+ return null;
33
+ return JSON.parse(row.data);
34
+ },
35
+ async save(session) {
36
+ stmtUpsert.run(
37
+ session.id,
38
+ session.agentId ?? null,
39
+ JSON.stringify(session),
40
+ session.createdAt,
41
+ session.updatedAt
42
+ );
43
+ },
44
+ async delete(sessionId) {
45
+ stmtDelete.run(sessionId);
46
+ },
47
+ async list(filter) {
48
+ let rows;
49
+ if (filter?.agentId) {
50
+ rows = stmtListByAgent.all(filter.agentId);
51
+ } else {
52
+ rows = stmtList.all();
53
+ }
54
+ const ids = rows.map((r) => r.id);
55
+ if (filter?.limit) {
56
+ return ids.slice(0, filter.limit);
57
+ }
58
+ return ids;
59
+ },
60
+ async appendTurns(sessionId, turns) {
61
+ const data = await store.load(sessionId);
62
+ if (data) {
63
+ data.turns.push(...turns);
64
+ data.updatedAt = Date.now();
65
+ await store.save(data);
66
+ }
67
+ },
68
+ async getTurns(sessionId, from = 0, limit) {
69
+ const data = await store.load(sessionId);
70
+ if (!data)
71
+ return [];
72
+ return data.turns.slice(from, limit !== void 0 ? from + limit : void 0);
73
+ },
74
+ async updateRun(sessionId, run) {
75
+ const data = await store.load(sessionId);
76
+ if (data) {
77
+ const idx = data.runs.findIndex((r) => r.id === run.id);
78
+ if (idx >= 0) {
79
+ data.runs[idx] = run;
80
+ }
81
+ data.updatedAt = Date.now();
82
+ await store.save(data);
83
+ }
84
+ },
85
+ async updateStatus(sessionId, status) {
86
+ const data = await store.load(sessionId);
87
+ if (data) {
88
+ data.status = status;
89
+ data.updatedAt = Date.now();
90
+ await store.save(data);
91
+ }
92
+ }
93
+ };
94
+ return store;
95
+ }
96
+ export {
97
+ createSqliteStore
98
+ };
package/dist/session.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { n as CreateSessionOptions, a5 as FileMapAdapter, a6 as FileMapStoreOptions, R as RemoteStoreOptions, S as Session, y as SessionContentBlock, z as SessionData, E as SessionMessage, F as SessionRun, G as SessionStore, J as SessionTurn, L as SqliteStoreOptions, ab as autoDetectAndConvert, ag as createFileMapStore, ah as createMemoryStore, ai as createRemoteStore, aj as createSession, ak as createSqliteStore, am as fromAnthropic, an as fromOpenAI, ao as loadSession, av as toAnthropic, aw as toOpenAI } from './agent-CWQ5XOw6.js';
1
+ export { n as CreateSessionOptions, a4 as FileMapAdapter, a5 as FileMapStoreOptions, R as RemoteStoreOptions, S as Session, y as SessionContentBlock, z as SessionData, E as SessionMessage, F as SessionRun, G as SessionStore, J as SessionTurn, aa as autoDetectAndConvert, af as createFileMapStore, ag as createMemoryStore, ah as createRemoteStore, ai as createSession, ak as fromAnthropic, al as fromOpenAI, am as loadSession, at as toAnthropic, au as toOpenAI } from './agent-8QBOx4_0.js';
2
2
  import 'hookable';
3
3
  import './types-BpvTmawk.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/session.js CHANGED
@@ -3,9 +3,8 @@ import {
3
3
  createMemoryStore,
4
4
  createRemoteStore,
5
5
  createSession,
6
- createSqliteStore,
7
6
  loadSession
8
- } from "./chunk-2IB4XBQE.js";
7
+ } from "./chunk-VG2E6YK3.js";
9
8
  import {
10
9
  autoDetectAndConvert,
11
10
  fromAnthropic,
@@ -20,7 +19,6 @@ export {
20
19
  createMemoryStore,
21
20
  createRemoteStore,
22
21
  createSession,
23
- createSqliteStore,
24
22
  fromAnthropic,
25
23
  fromOpenAI,
26
24
  loadSession,
@@ -1,4 +1,4 @@
1
- import { W as ToolContext, X as ToolDef, o as HarnessConfig, h as AgentStats } from './agent-CWQ5XOw6.js';
1
+ import { V as ToolContext, W as ToolDef, o as HarnessConfig, h as AgentStats } from './agent-8QBOx4_0.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,6 +1,6 @@
1
- export { g as glob } from './glob-j9gbk6xm.js';
2
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-EEv1Johs.js';
3
- import { X as ToolDef } from './agent-CWQ5XOw6.js';
1
+ export { g as glob } from './glob-Bo0GAiKk.js';
2
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-jjxPcNcH.js';
3
+ import { W as ToolDef } from './agent-8QBOx4_0.js';
4
4
  export { V as ValidationResult, v as validateToolArgs } from './validation-DOY_k7lW.js';
5
5
  import 'hookable';
6
6
  import './types-BpvTmawk.js';
package/dist/types.d.ts CHANGED
@@ -1,8 +1,8 @@
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 AnthropicParams, C as CONTEXT_EXCEEDED_MESSAGE_PATTERNS, j as CerebrasParams, k as ChildRunStats, l as ClassifiedError, m as ClassifiedErrorKind, n as CreateSessionOptions, H as Harness, o as HarnessConfig, 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, R as RemoteStoreOptions, x as RunHookMap, S as Session, y as SessionContentBlock, z as SessionData, B as SessionEndStatus, D as SessionHookContext, E as SessionMessage, F as SessionRun, G as SessionStore, J as SessionTurn, K as SpawnHookContext, L as SqliteStoreOptions, N as StreamCallbacks, Q as StreamHookContext, T as StreamOptions, U as ThinkingLevel, V as ToolCall, W as ToolContext, X as ToolDef, Y as ToolExecutionMode, Z as ToolHookContext, _ as ToolMap, $ as ToolResult, a0 as ToolSpec, a1 as TurnFinishReason, a2 as TurnResult, a3 as TurnUsage, a4 as matchesContextExceeded } from './agent-CWQ5XOw6.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 AnthropicParams, C as CONTEXT_EXCEEDED_MESSAGE_PATTERNS, j as CerebrasParams, k as ChildRunStats, l as ClassifiedError, m as ClassifiedErrorKind, n as CreateSessionOptions, H as Harness, o as HarnessConfig, 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, R as RemoteStoreOptions, x as RunHookMap, S as Session, y as SessionContentBlock, z as SessionData, B as SessionEndStatus, D as SessionHookContext, E as SessionMessage, F as SessionRun, G as SessionStore, J as SessionTurn, K as SpawnHookContext, L as StreamCallbacks, N as StreamHookContext, Q as StreamOptions, T as ThinkingLevel, U as ToolCall, V as ToolContext, W as ToolDef, X as ToolExecutionMode, Y as ToolHookContext, Z as ToolMap, _ as ToolResult, $ as ToolSpec, a0 as TurnFinishReason, a1 as TurnResult, a2 as TurnUsage, a3 as matchesContextExceeded } from './agent-8QBOx4_0.js';
2
2
  export { C as ContextCapabilities, a as ContextType, E as ExecResult, b as ExecutionContext, c as ExecutionHandle, S as SpawnConfig } from './types-BpvTmawk.js';
3
3
  export { S as SandboxProvider } from './sandbox-CW72eLDP.js';
4
4
  export { S as SkillConfig, a as SkillResource, b as SkillsConfig } from './types-CDI8Kmve.js';
5
- export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState } from './spawn-EEv1Johs.js';
5
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState } from './spawn-jjxPcNcH.js';
6
6
  export { V as ValidationResult } from './validation-DOY_k7lW.js';
7
7
  import 'hookable';
8
8
  import '@modelcontextprotocol/sdk/client/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zidane",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "an agent that goes straight to the goal",
5
5
  "type": "module",
6
6
  "private": false,
@@ -46,6 +46,10 @@
46
46
  "import": "./dist/session.js",
47
47
  "types": "./dist/session.d.ts"
48
48
  },
49
+ "./session/sqlite": {
50
+ "import": "./dist/session/sqlite.js",
51
+ "types": "./dist/session/sqlite.d.ts"
52
+ },
49
53
  "./skills": {
50
54
  "import": "./dist/skills.js",
51
55
  "types": "./dist/skills.d.ts"
@@ -67,23 +71,28 @@
67
71
  "typecheck": "tsc --noEmit"
68
72
  },
69
73
  "dependencies": {
70
- "@anthropic-ai/sdk": "^0.88.0",
71
- "@modelcontextprotocol/sdk": "^1.29.0",
72
74
  "@yaelg/pi-ai": "^0.66.1",
73
75
  "chalk": "^5.6.2",
74
76
  "hookable": "^6.1.0",
75
77
  "md4x": "^0.0.25"
76
78
  },
77
79
  "peerDependencies": {
80
+ "@anthropic-ai/sdk": "^0.88.0",
81
+ "@modelcontextprotocol/sdk": ">=1.11.0",
78
82
  "zod": ">=4.0.0"
79
83
  },
80
84
  "peerDependenciesMeta": {
85
+ "@anthropic-ai/sdk": {
86
+ "optional": true
87
+ },
81
88
  "zod": {
82
89
  "optional": true
83
90
  }
84
91
  },
85
92
  "devDependencies": {
93
+ "@anthropic-ai/sdk": "^0.88.0",
86
94
  "@antfu/eslint-config": "^8.1.1",
95
+ "@modelcontextprotocol/sdk": "^1.29.0",
87
96
  "@types/bun": "^1.3.12",
88
97
  "@types/dockerode": "^4.0.1",
89
98
  "bumpp": "^11.0.1",