zidane 1.8.0 → 2.0.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.
Files changed (36) hide show
  1. package/dist/{agent-CWQ5XOw6.d.ts → agent-D-ZFMbSd.d.ts} +371 -21
  2. package/dist/{chunk-FFFDQHMA.js → chunk-7JTBBZ2U.js} +21 -0
  3. package/dist/chunk-BCXXXJ3G.js +779 -0
  4. package/dist/{chunk-WQBKOZVI.js → chunk-FRNFVKWW.js} +50 -12
  5. package/dist/{chunk-EC7IRWVS.js → chunk-LN4LLLHA.js} +101 -7
  6. package/dist/chunk-LVC7NQUZ.js +22 -0
  7. package/dist/chunk-MYWDHD7C.js +14 -0
  8. package/dist/{chunk-3RJOWJOJ.js → chunk-OVQ4N64O.js} +1 -1
  9. package/dist/{chunk-4N5ADW7A.js → chunk-PASFWG7S.js} +343 -32
  10. package/dist/{chunk-TBC6MSVK.js → chunk-PJUUYBKF.js} +53 -4
  11. package/dist/{chunk-2IB4XBQE.js → chunk-VG2E6YK3.js} +0 -97
  12. package/dist/harnesses.d.ts +1 -2
  13. package/dist/harnesses.js +5 -5
  14. package/dist/index.d.ts +5 -6
  15. package/dist/index.js +42 -12
  16. package/dist/mcp.d.ts +1 -2
  17. package/dist/mcp.js +3 -1
  18. package/dist/providers.d.ts +1 -2
  19. package/dist/providers.js +3 -3
  20. package/dist/session/sqlite.d.ts +16 -0
  21. package/dist/session/sqlite.js +98 -0
  22. package/dist/session.d.ts +1 -2
  23. package/dist/session.js +3 -5
  24. package/dist/skills-use-C4KFVla0.d.ts +66 -0
  25. package/dist/skills.d.ts +215 -30
  26. package/dist/skills.js +21 -2
  27. package/dist/{spawn-EEv1Johs.d.ts → spawn-RoqpjYLZ.d.ts} +1 -1
  28. package/dist/tools.d.ts +3 -4
  29. package/dist/tools.js +10 -4
  30. package/dist/types.d.ts +2 -3
  31. package/dist/types.js +8 -2
  32. package/package.json +12 -3
  33. package/dist/chunk-4C6Y56CC.js +0 -390
  34. package/dist/chunk-CFLC2I7D.js +0 -8
  35. package/dist/glob-j9gbk6xm.d.ts +0 -5
  36. package/dist/types-CDI8Kmve.d.ts +0 -64
@@ -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,5 +1,4 @@
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, p as HarnessConfig, _ as ToolContext, $ as ToolDef, a2 as ToolMap, aP as basic, aQ as basicTools, aA as defineHarness, aF as noTools } from './agent-D-ZFMbSd.js';
3
3
  import './types-BpvTmawk.js';
4
- import './types-CDI8Kmve.js';
5
4
  import '@modelcontextprotocol/sdk/client/index.js';
package/dist/harnesses.js CHANGED
@@ -3,12 +3,12 @@ import {
3
3
  basic_default,
4
4
  defineHarness,
5
5
  noTools
6
- } from "./chunk-3RJOWJOJ.js";
7
- import "./chunk-4N5ADW7A.js";
8
- import "./chunk-4C6Y56CC.js";
6
+ } from "./chunk-OVQ4N64O.js";
7
+ import "./chunk-PASFWG7S.js";
8
+ import "./chunk-BCXXXJ3G.js";
9
9
  import "./chunk-SZA4FKW5.js";
10
- import "./chunk-TBC6MSVK.js";
11
- import "./chunk-FFFDQHMA.js";
10
+ import "./chunk-PJUUYBKF.js";
11
+ import "./chunk-7JTBBZ2U.js";
12
12
  export {
13
13
  basic_default as basic,
14
14
  basicTools,
package/dist/index.d.ts CHANGED
@@ -1,12 +1,11 @@
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-D-ZFMbSd.js';
2
+ export { ad as ActivationVia, ae 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, af as DeactivationReason, ag as FileMapAdapter, ah as FileMapStoreOptions, H as Harness, p as HarnessConfig, I as ImageContent, M as McpConnection, q as McpServerConfig, r as McpToolHookContext, O as OAuthRefreshHookContext, ai as OpenAICompatAuthHeader, aj as OpenAICompatHttpError, ak as OpenAICompatParams, s as OpenAIParams, t as OpenRouterParams, P as PromptDocumentPart, u as PromptImagePart, v as PromptPart, w as PromptTextPart, x as Provider, y as ProviderCapabilities, R as RemoteStoreOptions, z as RunHookMap, S as Session, B as SessionContentBlock, D as SessionData, E as SessionEndStatus, F as SessionHookContext, G as SessionMessage, J as SessionRun, K as SessionStore, L as SessionTurn, al as SkillActivationState, am as SkillActivationStateOptions, N as SkillConfig, an as SkillDiagnostic, Q as SkillResource, ao as SkillSource, T as SkillsConfig, U as SpawnHookContext, V as StreamCallbacks, W as StreamHookContext, X as StreamOptions, Y as ThinkingLevel, Z as ToolCall, _ as ToolContext, $ as ToolDef, a0 as ToolExecutionMode, a1 as ToolHookContext, a2 as ToolMap, a3 as ToolResult, a4 as ToolResultContent, a5 as ToolResultImageContent, a6 as ToolResultTextContent, a7 as ToolSpec, a8 as TurnFinishReason, a9 as TurnResult, aa as TurnUsage, ap as anthropic, aq as autoDetectAndConvert, ar as cerebras, as as classifyOpenAICompatError, at as connectMcpServers, au as createAgent, av as createFileMapStore, aw as createMemoryStore, ax as createRemoteStore, ay as createSession, az as createSkillActivationState, aA as defineHarness, aB as fromAnthropic, aC as fromOpenAI, aD as loadSession, aE as mapOAIFinishReason, ab as matchesContextExceeded, aF as noTools, aG as normalizeMcpBlocks, aH as normalizeMcpServers, aI as openai, aJ as openaiCompat, aK as openrouter, aL as resultToString, aM as toAnthropic, aN as toOpenAI, aO as toTypedError, ac as toolResultToText } from './agent-D-ZFMbSd.js';
3
3
  export { createDockerContext, createProcessContext } from './contexts.js';
4
4
  export { S as SandboxProvider, c as createSandboxContext } from './sandbox-CW72eLDP.js';
5
5
  export { C as ContextCapabilities, a as ContextType, E as ExecResult, b as ExecutionContext, c as ExecutionHandle, S as SpawnConfig } from './types-BpvTmawk.js';
6
- export { buildCatalog, defineSkill, discoverSkills, interpolateShellCommands, mergeSkillsConfig, parseSkillFile, resolveSkills, validateSkillName, writeSkillToDisk, writeSkillsToDisk } from './skills.js';
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';
6
+ export { IMPLICITLY_ALLOWED_SKILL_TOOLS, SkillValidationIssue, SkillValidationResult, SourcedScanPath, buildCatalog, defineSkill, discoverSkills, installAllowedToolsGate, interpolateShellCommands, isToolAllowedByUnion, matchesAllowedTool, mergeSkillsConfig, parseAllowedToolPattern, parseSkillFile, resolveSkills, validateResourcePath, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk } from './skills.js';
7
+ export { S as SkillsReadToolOptions, a as SkillsRunScriptToolOptions, b as SkillsUseToolOptions, c as createSkillsReadTool, d as createSkillsRunScriptTool, e as createSkillsUseTool, g as glob } from './skills-use-C4KFVla0.js';
8
+ export { C as ChildAgent, I as InteractionToolOptions, S as SpawnToolOptions, a as SpawnToolState, c as createInteractionTool, b as createSpawnTool, s as spawn } from './spawn-RoqpjYLZ.js';
10
9
  import { Hookable } from 'hookable';
11
10
  import '@modelcontextprotocol/sdk/client/index.js';
12
11
 
package/dist/index.js CHANGED
@@ -1,34 +1,48 @@
1
1
  import {
2
2
  defineSkill
3
- } from "./chunk-CFLC2I7D.js";
3
+ } from "./chunk-LVC7NQUZ.js";
4
+ import {
5
+ toolResultToText
6
+ } from "./chunk-MYWDHD7C.js";
4
7
  import {
5
8
  anthropic,
6
9
  cerebras,
7
10
  openai,
8
11
  openrouter
9
- } from "./chunk-WQBKOZVI.js";
12
+ } from "./chunk-FRNFVKWW.js";
10
13
  import {
11
14
  defineHarness,
12
15
  noTools
13
- } from "./chunk-3RJOWJOJ.js";
16
+ } from "./chunk-OVQ4N64O.js";
14
17
  import {
15
18
  createAgent,
16
19
  createInteractionTool,
20
+ createSkillsReadTool,
21
+ createSkillsRunScriptTool,
22
+ createSkillsUseTool,
17
23
  createSpawnTool,
18
24
  glob,
19
25
  spawn
20
- } from "./chunk-4N5ADW7A.js";
26
+ } from "./chunk-PASFWG7S.js";
21
27
  import {
28
+ IMPLICITLY_ALLOWED_SKILL_TOOLS,
22
29
  buildCatalog,
30
+ createSkillActivationState,
23
31
  discoverSkills,
32
+ installAllowedToolsGate,
24
33
  interpolateShellCommands,
34
+ isToolAllowedByUnion,
35
+ matchesAllowedTool,
25
36
  mergeSkillsConfig,
37
+ parseAllowedToolPattern,
26
38
  parseSkillFile,
27
39
  resolveSkills,
40
+ validateResourcePath,
41
+ validateSkillForWrite,
28
42
  validateSkillName,
29
43
  writeSkillToDisk,
30
44
  writeSkillsToDisk
31
- } from "./chunk-4C6Y56CC.js";
45
+ } from "./chunk-BCXXXJ3G.js";
32
46
  import {
33
47
  createDockerContext,
34
48
  createProcessContext,
@@ -36,16 +50,17 @@ import {
36
50
  } from "./chunk-SZA4FKW5.js";
37
51
  import {
38
52
  connectMcpServers,
39
- normalizeMcpServers
40
- } from "./chunk-TBC6MSVK.js";
53
+ normalizeMcpBlocks,
54
+ normalizeMcpServers,
55
+ resultToString
56
+ } from "./chunk-PJUUYBKF.js";
41
57
  import {
42
58
  createFileMapStore,
43
59
  createMemoryStore,
44
60
  createRemoteStore,
45
61
  createSession,
46
- createSqliteStore,
47
62
  loadSession
48
- } from "./chunk-2IB4XBQE.js";
63
+ } from "./chunk-VG2E6YK3.js";
49
64
  import {
50
65
  OpenAICompatHttpError,
51
66
  autoDetectAndConvert,
@@ -56,15 +71,16 @@ import {
56
71
  openaiCompat,
57
72
  toAnthropic,
58
73
  toOpenAI
59
- } from "./chunk-EC7IRWVS.js";
74
+ } from "./chunk-LN4LLLHA.js";
60
75
  import {
61
76
  AgentAbortedError,
62
77
  AgentContextExceededError,
63
78
  AgentProviderError,
79
+ AgentToolNotAllowedError,
64
80
  CONTEXT_EXCEEDED_MESSAGE_PATTERNS,
65
81
  matchesContextExceeded,
66
82
  toTypedError
67
- } from "./chunk-FFFDQHMA.js";
83
+ } from "./chunk-7JTBBZ2U.js";
68
84
 
69
85
  // src/tracing.ts
70
86
  function createTracingHooks(options) {
@@ -182,7 +198,9 @@ export {
182
198
  AgentAbortedError,
183
199
  AgentContextExceededError,
184
200
  AgentProviderError,
201
+ AgentToolNotAllowedError,
185
202
  CONTEXT_EXCEEDED_MESSAGE_PATTERNS,
203
+ IMPLICITLY_ALLOWED_SKILL_TOOLS,
186
204
  OpenAICompatHttpError,
187
205
  anthropic,
188
206
  autoDetectAndConvert,
@@ -199,8 +217,11 @@ export {
199
217
  createRemoteStore,
200
218
  createSandboxContext,
201
219
  createSession,
220
+ createSkillActivationState,
221
+ createSkillsReadTool,
222
+ createSkillsRunScriptTool,
223
+ createSkillsUseTool,
202
224
  createSpawnTool,
203
- createSqliteStore,
204
225
  createTracingHooks,
205
226
  defineHarness,
206
227
  defineSkill,
@@ -208,22 +229,31 @@ export {
208
229
  fromAnthropic,
209
230
  fromOpenAI,
210
231
  glob,
232
+ installAllowedToolsGate,
211
233
  interpolateShellCommands,
234
+ isToolAllowedByUnion,
212
235
  loadSession,
213
236
  mapOAIFinishReason,
237
+ matchesAllowedTool,
214
238
  matchesContextExceeded,
215
239
  mergeSkillsConfig,
216
240
  noTools,
241
+ normalizeMcpBlocks,
217
242
  normalizeMcpServers,
218
243
  openai,
219
244
  openaiCompat,
220
245
  openrouter,
246
+ parseAllowedToolPattern,
221
247
  parseSkillFile,
222
248
  resolveSkills,
249
+ resultToString,
223
250
  spawn,
224
251
  toAnthropic,
225
252
  toOpenAI,
226
253
  toTypedError,
254
+ toolResultToText,
255
+ validateResourcePath,
256
+ validateSkillForWrite,
227
257
  validateSkillName,
228
258
  writeSkillToDisk,
229
259
  writeSkillsToDisk,
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,4 @@
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, q as McpServerConfig, at as connectMcpServers, aG as normalizeMcpBlocks, aH as normalizeMcpServers, aL as resultToString } from './agent-D-ZFMbSd.js';
3
3
  import '@modelcontextprotocol/sdk/client/index.js';
4
4
  import './types-BpvTmawk.js';
5
- import './types-CDI8Kmve.js';
package/dist/mcp.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  connectMcpServers,
3
+ normalizeMcpBlocks,
3
4
  normalizeMcpServers,
4
5
  resultToString
5
- } from "./chunk-TBC6MSVK.js";
6
+ } from "./chunk-PJUUYBKF.js";
6
7
  export {
7
8
  connectMcpServers,
9
+ normalizeMcpBlocks,
8
10
  normalizeMcpServers,
9
11
  resultToString
10
12
  };
@@ -1,5 +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 { j as AnthropicParams, k as CerebrasParams, ai as OpenAICompatAuthHeader, aj as OpenAICompatHttpError, ak as OpenAICompatParams, s as OpenAIParams, t as OpenRouterParams, x as Provider, y as ProviderCapabilities, V as StreamCallbacks, X as StreamOptions, Z as ToolCall, a3 as ToolResult, a7 as ToolSpec, a9 as TurnResult, ap as anthropic, ar as cerebras, as as classifyOpenAICompatError, aE as mapOAIFinishReason, aI as openai, aJ as openaiCompat, aK as openrouter } from './agent-D-ZFMbSd.js';
2
2
  import 'hookable';
3
3
  import './types-BpvTmawk.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
5
- import './types-CDI8Kmve.js';
package/dist/providers.js CHANGED
@@ -3,14 +3,14 @@ import {
3
3
  cerebras,
4
4
  openai,
5
5
  openrouter
6
- } from "./chunk-WQBKOZVI.js";
6
+ } from "./chunk-FRNFVKWW.js";
7
7
  import {
8
8
  OpenAICompatHttpError,
9
9
  classifyOpenAICompatError,
10
10
  mapOAIFinishReason,
11
11
  openaiCompat
12
- } from "./chunk-EC7IRWVS.js";
13
- import "./chunk-FFFDQHMA.js";
12
+ } from "./chunk-LN4LLLHA.js";
13
+ import "./chunk-7JTBBZ2U.js";
14
14
  export {
15
15
  OpenAICompatHttpError,
16
16
  anthropic,
@@ -0,0 +1,16 @@
1
+ import { K as SessionStore } from '../agent-D-ZFMbSd.js';
2
+ import 'hookable';
3
+ import '../types-BpvTmawk.js';
4
+ import '@modelcontextprotocol/sdk/client/index.js';
5
+
6
+ /**
7
+ * SQLite session store using Bun's built-in bun:sqlite.
8
+ */
9
+
10
+ interface SqliteStoreOptions {
11
+ /** Path to the SQLite database file */
12
+ path: string;
13
+ }
14
+ declare function createSqliteStore(options: SqliteStoreOptions): SessionStore;
15
+
16
+ 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,5 +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 { o as CreateSessionOptions, ag as FileMapAdapter, ah as FileMapStoreOptions, R as RemoteStoreOptions, S as Session, B as SessionContentBlock, D as SessionData, G as SessionMessage, J as SessionRun, K as SessionStore, L as SessionTurn, aq as autoDetectAndConvert, av as createFileMapStore, aw as createMemoryStore, ax as createRemoteStore, ay as createSession, aB as fromAnthropic, aC as fromOpenAI, aD as loadSession, aM as toAnthropic, aN as toOpenAI } from './agent-D-ZFMbSd.js';
2
2
  import 'hookable';
3
3
  import './types-BpvTmawk.js';
4
4
  import '@modelcontextprotocol/sdk/client/index.js';
5
- import './types-CDI8Kmve.js';
package/dist/session.js CHANGED
@@ -3,24 +3,22 @@ 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,
12
11
  fromOpenAI,
13
12
  toAnthropic,
14
13
  toOpenAI
15
- } from "./chunk-EC7IRWVS.js";
16
- import "./chunk-FFFDQHMA.js";
14
+ } from "./chunk-LN4LLLHA.js";
15
+ import "./chunk-7JTBBZ2U.js";
17
16
  export {
18
17
  autoDetectAndConvert,
19
18
  createFileMapStore,
20
19
  createMemoryStore,
21
20
  createRemoteStore,
22
21
  createSession,
23
- createSqliteStore,
24
22
  fromAnthropic,
25
23
  fromOpenAI,
26
24
  loadSession,
@@ -0,0 +1,66 @@
1
+ import { $ as ToolDef, N as SkillConfig, al as SkillActivationState, d as AgentHooks } from './agent-D-ZFMbSd.js';
2
+ import { Hookable } from 'hookable';
3
+
4
+ declare const glob: ToolDef;
5
+
6
+ /**
7
+ * `skills_read` tool — reads a bundled resource file from an active skill.
8
+ *
9
+ * Requires the skill to be active (model must have called `skills_use` first).
10
+ * Paths are validated against the skill's `baseDir` to prevent directory
11
+ * traversal. File I/O goes through `ctx.execution.readFile` so docker/sandbox
12
+ * execution contexts work identically to in-process.
13
+ */
14
+
15
+ interface SkillsReadToolOptions {
16
+ catalog: readonly SkillConfig[];
17
+ state: SkillActivationState;
18
+ }
19
+ declare function createSkillsReadTool(options: SkillsReadToolOptions): ToolDef;
20
+
21
+ /**
22
+ * `skills_run_script` tool — executes a script from an active skill's
23
+ * `scripts/` directory via the agent's execution context.
24
+ *
25
+ * Path is validated against the skill's `baseDir` and constrained to the
26
+ * `scripts/` subdirectory. Timeout is configurable via
27
+ * `SkillsConfig.scriptTimeoutMs` (default 60 s).
28
+ */
29
+
30
+ interface SkillsRunScriptToolOptions {
31
+ catalog: readonly SkillConfig[];
32
+ state: SkillActivationState;
33
+ /** Script timeout in milliseconds. Default 60000. */
34
+ scriptTimeoutMs?: number;
35
+ }
36
+ declare function createSkillsRunScriptTool(options: SkillsRunScriptToolOptions): ToolDef;
37
+
38
+ /**
39
+ * `skills_use` tool — activates a skill and returns its full instructions.
40
+ *
41
+ * Implements tier 2 of progressive disclosure per the Agent Skills spec.
42
+ * Body is frontmatter-stripped (the model gets the markdown only, wrapped in
43
+ * `<skill_content>` tags so the harness can identify it during context
44
+ * management). Shell-interpolation (`!` `` `cmd` ``) runs per-activation rather
45
+ * than once per agent, so values like `gh pr diff` reflect the current state.
46
+ */
47
+
48
+ interface SkillsUseToolOptions {
49
+ /** Resolved skills catalog for this run. */
50
+ catalog: readonly SkillConfig[];
51
+ /** Per-agent activation state the tool mutates. */
52
+ state: SkillActivationState;
53
+ /** Agent hooks — used to fire `skills:activate` on first activation. */
54
+ hooks: Hookable<AgentHooks>;
55
+ }
56
+ /**
57
+ * Factory for `skills_use`. Auto-injected into the agent's tool set by the
58
+ * agent runtime when a non-empty skills catalog is available (unless
59
+ * `SkillsConfig.tool === false`).
60
+ *
61
+ * The tool schema's `name` property is `enum`-constrained to the resolved
62
+ * catalog so the LLM cannot hallucinate a skill that doesn't exist.
63
+ */
64
+ declare function createSkillsUseTool(options: SkillsUseToolOptions): ToolDef;
65
+
66
+ export { type SkillsReadToolOptions as S, type SkillsRunScriptToolOptions as a, type SkillsUseToolOptions as b, createSkillsReadTool as c, createSkillsRunScriptTool as d, createSkillsUseTool as e, glob as g };