zidane 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -14
- package/dist/agent-DVvuhEN-.d.ts +671 -0
- package/dist/{chunk-PRNQ7DXE.js → chunk-3K5D27BF.js} +20 -59
- package/dist/chunk-7V33E7LT.js +32 -0
- package/dist/chunk-CFLC2I7D.js +8 -0
- package/dist/{chunk-XMFQK35S.js → chunk-VRAZJES3.js} +178 -271
- package/dist/{chunk-ZH2KFHLB.js → chunk-XT7QBZ47.js} +6 -6
- package/dist/{chunk-26LIQARN.js → chunk-YTZOORAP.js} +1 -10
- package/dist/harnesses.d.ts +2 -6
- package/dist/harnesses.js +4 -6
- package/dist/index.d.ts +21 -30
- package/dist/index.js +17 -21
- package/dist/mcp.d.ts +2 -6
- package/dist/mcp.js +1 -4
- package/dist/providers.d.ts +4 -82
- package/dist/providers.js +24 -1
- package/dist/sandbox-C08DQPTu.d.ts +28 -0
- package/dist/session.d.ts +4 -193
- package/dist/session.js +1 -2
- package/dist/skills.d.ts +2 -2
- package/dist/skills.js +2 -3
- package/dist/{spawn-MUlKj85h.d.ts → spawn-DJZZ9ZWw.d.ts} +1 -2
- package/dist/tools.d.ts +5 -18
- package/dist/tools.js +3 -6
- package/dist/{types-D8fzooXc.d.ts → types-CyRzBgm0.d.ts} +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.js +0 -0
- package/dist/validation-CwSuvOKf.d.ts +11 -0
- package/package.json +12 -1
- package/dist/agent-DZDheE1c.d.ts +0 -271
- package/dist/chunk-PNKVD2UK.js +0 -26
- package/dist/chunk-QPYZR2QM.js +0 -21
- package/dist/types-CskNDruh.d.ts +0 -110
|
@@ -4,10 +4,10 @@ function createMemoryStore() {
|
|
|
4
4
|
return {
|
|
5
5
|
async load(sessionId) {
|
|
6
6
|
const data = sessions.get(sessionId);
|
|
7
|
-
return data ?
|
|
7
|
+
return data ? structuredClone(data) : null;
|
|
8
8
|
},
|
|
9
9
|
async save(session) {
|
|
10
|
-
sessions.set(session.id,
|
|
10
|
+
sessions.set(session.id, structuredClone(session));
|
|
11
11
|
},
|
|
12
12
|
async delete(sessionId) {
|
|
13
13
|
sessions.delete(sessionId);
|
|
@@ -25,7 +25,7 @@ function createMemoryStore() {
|
|
|
25
25
|
async appendTurns(sessionId, turns) {
|
|
26
26
|
const data = sessions.get(sessionId);
|
|
27
27
|
if (data) {
|
|
28
|
-
data.turns.push(...
|
|
28
|
+
data.turns.push(...structuredClone(turns));
|
|
29
29
|
data.updatedAt = Date.now();
|
|
30
30
|
}
|
|
31
31
|
},
|
|
@@ -34,14 +34,14 @@ function createMemoryStore() {
|
|
|
34
34
|
if (!data)
|
|
35
35
|
return [];
|
|
36
36
|
const sliced = data.turns.slice(from, limit !== void 0 ? from + limit : void 0);
|
|
37
|
-
return
|
|
37
|
+
return structuredClone(sliced);
|
|
38
38
|
},
|
|
39
39
|
async updateRun(sessionId, run) {
|
|
40
40
|
const data = sessions.get(sessionId);
|
|
41
41
|
if (data) {
|
|
42
42
|
const idx = data.runs.findIndex((r) => r.id === run.id);
|
|
43
43
|
if (idx >= 0) {
|
|
44
|
-
data.runs[idx] =
|
|
44
|
+
data.runs[idx] = structuredClone(run);
|
|
45
45
|
}
|
|
46
46
|
data.updatedAt = Date.now();
|
|
47
47
|
}
|
|
@@ -399,7 +399,7 @@ async function createSession(options = {}) {
|
|
|
399
399
|
await store.save(data);
|
|
400
400
|
},
|
|
401
401
|
toJSON() {
|
|
402
|
-
return
|
|
402
|
+
return structuredClone(data);
|
|
403
403
|
}
|
|
404
404
|
};
|
|
405
405
|
return session;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__esm
|
|
3
|
-
} from "./chunk-PNKVD2UK.js";
|
|
4
|
-
|
|
5
1
|
// src/mcp/index.ts
|
|
6
2
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
7
3
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
@@ -97,13 +93,8 @@ async function connectMcpServers(configs, _clientFactory, hooks) {
|
|
|
97
93
|
}
|
|
98
94
|
};
|
|
99
95
|
}
|
|
100
|
-
var init_mcp = __esm({
|
|
101
|
-
"src/mcp/index.ts"() {
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
96
|
|
|
105
97
|
export {
|
|
106
98
|
resultToString,
|
|
107
|
-
connectMcpServers
|
|
108
|
-
init_mcp
|
|
99
|
+
connectMcpServers
|
|
109
100
|
};
|
package/dist/harnesses.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '@anthropic-ai/sdk';
|
|
2
1
|
import 'hookable';
|
|
3
|
-
export { H as Harness,
|
|
4
|
-
import './types-
|
|
5
|
-
import './providers.js';
|
|
6
|
-
import './types-CskNDruh.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-DVvuhEN-.js';
|
|
3
|
+
import './types-CyRzBgm0.js';
|
|
7
4
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
8
|
-
import './session.js';
|
package/dist/harnesses.js
CHANGED
|
@@ -2,13 +2,11 @@ import {
|
|
|
2
2
|
basicTools,
|
|
3
3
|
basic_default,
|
|
4
4
|
defineHarness,
|
|
5
|
-
init_harnesses,
|
|
6
5
|
noTools
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
init_harnesses();
|
|
6
|
+
} from "./chunk-7V33E7LT.js";
|
|
7
|
+
import "./chunk-VRAZJES3.js";
|
|
8
|
+
import "./chunk-YTZOORAP.js";
|
|
9
|
+
import "./chunk-3K5D27BF.js";
|
|
12
10
|
export {
|
|
13
11
|
basic_default as basic,
|
|
14
12
|
basicTools,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
export { A as Agent, a as
|
|
2
|
-
import {
|
|
3
|
-
export { C as ContextCapabilities,
|
|
4
|
-
export {
|
|
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-DVvuhEN-.js';
|
|
2
|
+
import { f as SpawnConfig, b as ExecutionContext } from './types-CyRzBgm0.js';
|
|
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-CyRzBgm0.js';
|
|
4
|
+
export { S as SandboxProvider, c as createSandboxContext } from './sandbox-C08DQPTu.js';
|
|
5
5
|
export { buildCatalog, defineSkill, discoverSkills, interpolateShellCommands, mergeSkillsConfig, parseSkillFile, resolveSkills, validateSkillName, writeSkillToDisk, writeSkillsToDisk } from './skills.js';
|
|
6
|
-
export { C as ChildAgent, S as SpawnToolOptions, a as SpawnToolState, c as createSpawnTool, s as spawn } from './spawn-
|
|
7
|
-
export { A as AgentRunOptions, a as AgentStats, I as ImageContent, M as McpServerConfig, S as SessionContentBlock, b as SessionMessage, c as SessionTurn, T as ThinkingLevel, d as ToolExecutionMode, e as TurnUsage } from './types-CskNDruh.js';
|
|
6
|
+
export { C as ChildAgent, S as SpawnToolOptions, a as SpawnToolState, c as createSpawnTool, s as spawn } from './spawn-DJZZ9ZWw.js';
|
|
8
7
|
import 'hookable';
|
|
9
|
-
import '@anthropic-ai/sdk';
|
|
10
8
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
-
import './providers.js';
|
|
12
9
|
|
|
13
10
|
/**
|
|
14
11
|
* Docker execution context.
|
|
@@ -31,28 +28,22 @@ declare function createDockerContext(config?: SpawnConfig): ExecutionContext;
|
|
|
31
28
|
declare function createProcessContext(config?: SpawnConfig): ExecutionContext;
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
|
-
*
|
|
31
|
+
* Zod v4 integration helper.
|
|
35
32
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
33
|
+
* Normalizes the output of z.toJsonSchema() for use as ToolSpec.input_schema.
|
|
34
|
+
* Zod is an optional peer dependency — consumers call z.toJsonSchema() themselves.
|
|
35
|
+
*
|
|
36
|
+
* Usage:
|
|
37
|
+
* import { z } from 'zod'
|
|
38
|
+
* import { zodToJsonSchema } from 'zidane'
|
|
39
|
+
* const schema = zodToJsonSchema(z.toJsonSchema(z.object({ name: z.string() })))
|
|
38
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* Normalize a JSON Schema (e.g. from zod v4's z.toJsonSchema()) for use
|
|
43
|
+
* as a ToolSpec.input_schema.
|
|
44
|
+
*
|
|
45
|
+
* Strips the $schema key that some providers reject.
|
|
46
|
+
*/
|
|
47
|
+
declare function zodToJsonSchema(jsonSchema: Record<string, unknown>): Record<string, unknown>;
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
name: string;
|
|
42
|
-
spawn: (config: SpawnConfig) => Promise<{
|
|
43
|
-
id: string;
|
|
44
|
-
cwd: string;
|
|
45
|
-
}>;
|
|
46
|
-
exec: (sandboxId: string, command: string, options?: {
|
|
47
|
-
cwd?: string;
|
|
48
|
-
env?: Record<string, string>;
|
|
49
|
-
timeout?: number;
|
|
50
|
-
}) => Promise<ExecResult>;
|
|
51
|
-
readFile: (sandboxId: string, path: string) => Promise<string>;
|
|
52
|
-
writeFile: (sandboxId: string, path: string, content: string) => Promise<void>;
|
|
53
|
-
listFiles: (sandboxId: string, path: string) => Promise<string[]>;
|
|
54
|
-
destroy: (sandboxId: string) => Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
declare function createSandboxContext(provider: SandboxProvider): ExecutionContext;
|
|
57
|
-
|
|
58
|
-
export { ExecResult, ExecutionContext, type SandboxProvider, SpawnConfig, createDockerContext, createProcessContext, createSandboxContext };
|
|
49
|
+
export { ExecutionContext, SpawnConfig, createDockerContext, createProcessContext, zodToJsonSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineHarness,
|
|
3
|
+
noTools
|
|
4
|
+
} from "./chunk-7V33E7LT.js";
|
|
1
5
|
import {
|
|
2
6
|
createAgent,
|
|
3
7
|
createDockerContext,
|
|
4
8
|
createProcessContext,
|
|
5
9
|
createSandboxContext,
|
|
6
10
|
createSpawnTool,
|
|
7
|
-
defineHarness,
|
|
8
|
-
init_agent,
|
|
9
|
-
init_contexts,
|
|
10
|
-
init_harnesses,
|
|
11
|
-
init_tools,
|
|
12
|
-
noTools,
|
|
13
11
|
spawn
|
|
14
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VRAZJES3.js";
|
|
15
13
|
import {
|
|
16
|
-
connectMcpServers
|
|
17
|
-
|
|
18
|
-
} from "./chunk-26LIQARN.js";
|
|
14
|
+
connectMcpServers
|
|
15
|
+
} from "./chunk-YTZOORAP.js";
|
|
19
16
|
import {
|
|
20
17
|
createMemoryStore,
|
|
21
18
|
createRemoteStore,
|
|
22
19
|
createSession,
|
|
23
20
|
createSqliteStore,
|
|
24
21
|
loadSession
|
|
25
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-XT7QBZ47.js";
|
|
26
23
|
import {
|
|
27
24
|
autoDetectAndConvert,
|
|
28
25
|
fromAnthropic,
|
|
@@ -32,7 +29,7 @@ import {
|
|
|
32
29
|
} from "./chunk-LS57GDAV.js";
|
|
33
30
|
import {
|
|
34
31
|
defineSkill
|
|
35
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-CFLC2I7D.js";
|
|
36
33
|
import {
|
|
37
34
|
buildCatalog,
|
|
38
35
|
discoverSkills,
|
|
@@ -43,15 +40,13 @@ import {
|
|
|
43
40
|
validateSkillName,
|
|
44
41
|
writeSkillToDisk,
|
|
45
42
|
writeSkillsToDisk
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import "./chunk-PNKVD2UK.js";
|
|
43
|
+
} from "./chunk-3K5D27BF.js";
|
|
48
44
|
|
|
49
|
-
// src/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
init_tools();
|
|
45
|
+
// src/zod.ts
|
|
46
|
+
function zodToJsonSchema(jsonSchema) {
|
|
47
|
+
const { $schema, ...rest } = jsonSchema;
|
|
48
|
+
return rest;
|
|
49
|
+
}
|
|
55
50
|
export {
|
|
56
51
|
autoDetectAndConvert,
|
|
57
52
|
buildCatalog,
|
|
@@ -81,5 +76,6 @@ export {
|
|
|
81
76
|
toOpenAI,
|
|
82
77
|
validateSkillName,
|
|
83
78
|
writeSkillToDisk,
|
|
84
|
-
writeSkillsToDisk
|
|
79
|
+
writeSkillsToDisk,
|
|
80
|
+
zodToJsonSchema
|
|
85
81
|
};
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import 'hookable';
|
|
2
|
-
export { M as McpConnection,
|
|
3
|
-
export { M as McpServerConfig } from './types-CskNDruh.js';
|
|
2
|
+
export { M as McpConnection, j as McpServerConfig, F as connectMcpServers, a3 as resultToString } from './agent-DVvuhEN-.js';
|
|
4
3
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
5
|
-
import './types-
|
|
6
|
-
import '@anthropic-ai/sdk';
|
|
7
|
-
import './providers.js';
|
|
8
|
-
import './session.js';
|
|
4
|
+
import './types-CyRzBgm0.js';
|
package/dist/mcp.js
CHANGED
package/dist/providers.d.ts
CHANGED
|
@@ -1,82 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
access?: string;
|
|
6
|
-
refresh?: string;
|
|
7
|
-
expires?: number;
|
|
8
|
-
defaultModel?: string;
|
|
9
|
-
}
|
|
10
|
-
declare function anthropic(anthropicParams?: AnthropicParams): Provider;
|
|
11
|
-
|
|
12
|
-
interface CerebrasParams {
|
|
13
|
-
apiKey?: string;
|
|
14
|
-
defaultModel?: string;
|
|
15
|
-
}
|
|
16
|
-
declare function cerebras(params?: CerebrasParams): Provider;
|
|
17
|
-
|
|
18
|
-
interface OpenRouterParams {
|
|
19
|
-
apiKey?: string;
|
|
20
|
-
defaultModel?: string;
|
|
21
|
-
}
|
|
22
|
-
declare function openrouter(params?: OpenRouterParams): Provider;
|
|
23
|
-
|
|
24
|
-
interface ToolSpec {
|
|
25
|
-
name: string;
|
|
26
|
-
description: string;
|
|
27
|
-
input_schema: Record<string, unknown>;
|
|
28
|
-
}
|
|
29
|
-
interface ToolCall {
|
|
30
|
-
id: string;
|
|
31
|
-
name: string;
|
|
32
|
-
input: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
interface ToolResult {
|
|
35
|
-
id: string;
|
|
36
|
-
content: string;
|
|
37
|
-
}
|
|
38
|
-
interface StreamCallbacks {
|
|
39
|
-
onText: (delta: string) => void;
|
|
40
|
-
}
|
|
41
|
-
interface TurnResult {
|
|
42
|
-
/** Full assistant turn as a SessionMessage */
|
|
43
|
-
assistantMessage: SessionMessage;
|
|
44
|
-
/** Text content blocks concatenated */
|
|
45
|
-
text: string;
|
|
46
|
-
/** Tool calls requested by the model */
|
|
47
|
-
toolCalls: ToolCall[];
|
|
48
|
-
/** Whether the model wants to stop */
|
|
49
|
-
done: boolean;
|
|
50
|
-
usage: TurnUsage;
|
|
51
|
-
}
|
|
52
|
-
interface StreamOptions {
|
|
53
|
-
model: string;
|
|
54
|
-
system: string;
|
|
55
|
-
tools: unknown[];
|
|
56
|
-
messages: SessionMessage[];
|
|
57
|
-
maxTokens: number;
|
|
58
|
-
/** Thinking/reasoning level (optional, default: off) */
|
|
59
|
-
thinking?: ThinkingLevel;
|
|
60
|
-
/** Exact thinking token budget — overrides the level-based default when set */
|
|
61
|
-
thinkingBudget?: number;
|
|
62
|
-
/** Abort signal for cancellation */
|
|
63
|
-
signal?: AbortSignal;
|
|
64
|
-
}
|
|
65
|
-
interface Provider {
|
|
66
|
-
readonly name: string;
|
|
67
|
-
readonly meta: {
|
|
68
|
-
defaultModel: string;
|
|
69
|
-
} & Record<string, unknown>;
|
|
70
|
-
/** Format tool specs for this provider */
|
|
71
|
-
formatTools: (tools: ToolSpec[]) => unknown[];
|
|
72
|
-
/** Create a user message (text or with images) */
|
|
73
|
-
userMessage: (content: string, images?: ImageContent[]) => SessionMessage;
|
|
74
|
-
/** Create an assistant message (for priming) */
|
|
75
|
-
assistantMessage: (content: string) => SessionMessage;
|
|
76
|
-
/** Create a tool results message to send back */
|
|
77
|
-
toolResultsMessage: (results: ToolResult[]) => SessionMessage;
|
|
78
|
-
/** Stream a turn, calling onText for each text delta */
|
|
79
|
-
stream: (options: StreamOptions, callbacks: StreamCallbacks) => Promise<TurnResult>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { type AnthropicParams, type CerebrasParams, type OpenRouterParams, type Provider, type StreamCallbacks, type StreamOptions, type ToolCall, type ToolResult, type ToolSpec, type TurnResult, anthropic, cerebras, openrouter };
|
|
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-DVvuhEN-.js';
|
|
2
|
+
import 'hookable';
|
|
3
|
+
import './types-CyRzBgm0.js';
|
|
4
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
package/dist/providers.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
toolResultsMessage,
|
|
10
10
|
userMessage
|
|
11
11
|
} from "./chunk-LS57GDAV.js";
|
|
12
|
-
import "./chunk-PNKVD2UK.js";
|
|
13
12
|
|
|
14
13
|
// src/providers/anthropic.ts
|
|
15
14
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -112,6 +111,14 @@ function anthropic(anthropicParams) {
|
|
|
112
111
|
};
|
|
113
112
|
params.temperature = 1;
|
|
114
113
|
}
|
|
114
|
+
if (options.toolChoice) {
|
|
115
|
+
if (options.toolChoice.type === "tool" && options.toolChoice.name)
|
|
116
|
+
params.tool_choice = { type: "tool", name: options.toolChoice.name };
|
|
117
|
+
else if (options.toolChoice.type === "required")
|
|
118
|
+
params.tool_choice = { type: "any" };
|
|
119
|
+
else
|
|
120
|
+
params.tool_choice = { type: "auto" };
|
|
121
|
+
}
|
|
115
122
|
const s = client.messages.stream(params, {
|
|
116
123
|
signal: options.signal
|
|
117
124
|
});
|
|
@@ -168,6 +175,14 @@ function cerebras(params) {
|
|
|
168
175
|
};
|
|
169
176
|
if (options.tools && options.tools.length > 0)
|
|
170
177
|
body.tools = options.tools;
|
|
178
|
+
if (options.toolChoice) {
|
|
179
|
+
if (options.toolChoice.type === "tool" && options.toolChoice.name)
|
|
180
|
+
body.tool_choice = { type: "function", function: { name: options.toolChoice.name } };
|
|
181
|
+
else if (options.toolChoice.type === "required")
|
|
182
|
+
body.tool_choice = "required";
|
|
183
|
+
else
|
|
184
|
+
body.tool_choice = "auto";
|
|
185
|
+
}
|
|
171
186
|
const response = await fetch(`${BASE_URL}/chat/completions`, {
|
|
172
187
|
method: "POST",
|
|
173
188
|
headers: {
|
|
@@ -226,6 +241,14 @@ function openrouter(params) {
|
|
|
226
241
|
};
|
|
227
242
|
if (options.tools && options.tools.length > 0)
|
|
228
243
|
body.tools = options.tools;
|
|
244
|
+
if (options.toolChoice) {
|
|
245
|
+
if (options.toolChoice.type === "tool" && options.toolChoice.name)
|
|
246
|
+
body.tool_choice = { type: "function", function: { name: options.toolChoice.name } };
|
|
247
|
+
else if (options.toolChoice.type === "required")
|
|
248
|
+
body.tool_choice = "required";
|
|
249
|
+
else
|
|
250
|
+
body.tool_choice = "auto";
|
|
251
|
+
}
|
|
229
252
|
const response = await fetch(`${BASE_URL2}/chat/completions`, {
|
|
230
253
|
method: "POST",
|
|
231
254
|
headers: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { f as SpawnConfig, E as ExecResult, b as ExecutionContext } from './types-CyRzBgm0.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Remote sandbox execution context.
|
|
5
|
+
*
|
|
6
|
+
* Offloads execution to a remote sandbox API (e.g. Rivet, E2B).
|
|
7
|
+
* Specific providers implement the SandboxProvider interface.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface SandboxProvider {
|
|
11
|
+
name: string;
|
|
12
|
+
spawn: (config: SpawnConfig) => Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
cwd: string;
|
|
15
|
+
}>;
|
|
16
|
+
exec: (sandboxId: string, command: string, options?: {
|
|
17
|
+
cwd?: string;
|
|
18
|
+
env?: Record<string, string>;
|
|
19
|
+
timeout?: number;
|
|
20
|
+
}) => Promise<ExecResult>;
|
|
21
|
+
readFile: (sandboxId: string, path: string) => Promise<string>;
|
|
22
|
+
writeFile: (sandboxId: string, path: string, content: string) => Promise<void>;
|
|
23
|
+
listFiles: (sandboxId: string, path: string) => Promise<string[]>;
|
|
24
|
+
destroy: (sandboxId: string) => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
declare function createSandboxContext(provider: SandboxProvider): ExecutionContext;
|
|
27
|
+
|
|
28
|
+
export { type SandboxProvider as S, createSandboxContext as c };
|
package/dist/session.d.ts
CHANGED
|
@@ -1,193 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* In-memory session store.
|
|
6
|
-
* Useful for development and testing. Data is lost when the process exits.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
declare function createMemoryStore(): SessionStore;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Canonical SessionMessage format with converters from/to Anthropic and OpenAI-compat formats.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
declare function fromAnthropic(msg: {
|
|
16
|
-
role: string;
|
|
17
|
-
content: unknown;
|
|
18
|
-
}): SessionMessage;
|
|
19
|
-
declare function fromOpenAI(msg: {
|
|
20
|
-
role: string;
|
|
21
|
-
content: unknown;
|
|
22
|
-
}): SessionMessage;
|
|
23
|
-
declare function toAnthropic(msg: SessionMessage): {
|
|
24
|
-
role: string;
|
|
25
|
-
content: unknown;
|
|
26
|
-
};
|
|
27
|
-
declare function toOpenAI(msg: SessionMessage): {
|
|
28
|
-
role: string;
|
|
29
|
-
content: unknown;
|
|
30
|
-
};
|
|
31
|
-
declare function autoDetectAndConvert(msg: {
|
|
32
|
-
role: string;
|
|
33
|
-
content: unknown;
|
|
34
|
-
}): SessionMessage;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Remote session store via HTTP API.
|
|
38
|
-
*
|
|
39
|
-
* Expects a REST API with:
|
|
40
|
-
* GET {url}/sessions/{id} -> SessionData | 404
|
|
41
|
-
* PUT {url}/sessions/{id} -> save SessionData
|
|
42
|
-
* DELETE {url}/sessions/{id} -> delete
|
|
43
|
-
* GET {url}/sessions?agentId=&limit= -> { ids: string[] }
|
|
44
|
-
* POST {url}/sessions/{id}/turns -> append turns
|
|
45
|
-
* GET {url}/sessions/{id}/turns?from=&limit= -> SessionTurn[]
|
|
46
|
-
* PUT {url}/sessions/{id}/runs/{runId} -> update run
|
|
47
|
-
* PATCH {url}/sessions/{id} -> { status }
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
interface RemoteStoreOptions {
|
|
51
|
-
/** Base URL of the session API */
|
|
52
|
-
url: string;
|
|
53
|
-
/** Optional headers (e.g. for authentication) */
|
|
54
|
-
headers?: Record<string, string>;
|
|
55
|
-
}
|
|
56
|
-
declare function createRemoteStore(options: RemoteStoreOptions): SessionStore;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* SQLite session store using Bun's built-in bun:sqlite.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
interface SqliteStoreOptions {
|
|
63
|
-
/** Path to the SQLite database file */
|
|
64
|
-
path: string;
|
|
65
|
-
}
|
|
66
|
-
declare function createSqliteStore(options: SqliteStoreOptions): SessionStore;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Session management for agents.
|
|
70
|
-
*
|
|
71
|
-
* A session tracks identity, turn history, and run metadata.
|
|
72
|
-
* Plug in any storage backend by implementing the SessionStore interface,
|
|
73
|
-
* or use one of the built-in stores: memory, sqlite, remote.
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
interface SessionRun {
|
|
77
|
-
id: string;
|
|
78
|
-
startedAt: number;
|
|
79
|
-
endedAt?: number;
|
|
80
|
-
prompt: string;
|
|
81
|
-
status: 'running' | 'completed' | 'aborted' | 'error';
|
|
82
|
-
turns?: number;
|
|
83
|
-
tokensIn?: number;
|
|
84
|
-
tokensOut?: number;
|
|
85
|
-
error?: string;
|
|
86
|
-
/** Per-turn usage breakdown */
|
|
87
|
-
turnUsage?: TurnUsage[];
|
|
88
|
-
/** Total usage across all turns */
|
|
89
|
-
totalUsage?: TurnUsage;
|
|
90
|
-
/** Estimated cost in USD */
|
|
91
|
-
cost?: number;
|
|
92
|
-
}
|
|
93
|
-
interface SessionData {
|
|
94
|
-
id: string;
|
|
95
|
-
agentId?: string;
|
|
96
|
-
turns: SessionTurn[];
|
|
97
|
-
runs: SessionRun[];
|
|
98
|
-
status: 'idle' | 'running' | 'completed' | 'error';
|
|
99
|
-
metadata: Record<string, unknown>;
|
|
100
|
-
createdAt: number;
|
|
101
|
-
updatedAt: number;
|
|
102
|
-
}
|
|
103
|
-
interface SessionStore {
|
|
104
|
-
/** Optional: generate a session ID server-side (e.g. Supabase UUID). */
|
|
105
|
-
generateSessionId?: () => string | Promise<string>;
|
|
106
|
-
/** Optional: generate a turn ID server-side. */
|
|
107
|
-
generateTurnId?: () => string | Promise<string>;
|
|
108
|
-
/** Load a session by ID. Returns null if not found. */
|
|
109
|
-
load: (sessionId: string) => Promise<SessionData | null>;
|
|
110
|
-
/** Save a session (create or update, full document). */
|
|
111
|
-
save: (session: SessionData) => Promise<void>;
|
|
112
|
-
/** Delete a session. */
|
|
113
|
-
delete: (sessionId: string) => Promise<void>;
|
|
114
|
-
/** List session IDs, optionally filtered. */
|
|
115
|
-
list: (filter?: {
|
|
116
|
-
agentId?: string;
|
|
117
|
-
limit?: number;
|
|
118
|
-
}) => Promise<string[]>;
|
|
119
|
-
/** Append new turns to a session (incremental, avoids full re-save). */
|
|
120
|
-
appendTurns: (sessionId: string, turns: SessionTurn[]) => Promise<void>;
|
|
121
|
-
/** Return a slice of turns for a session. */
|
|
122
|
-
getTurns: (sessionId: string, from?: number, limit?: number) => Promise<SessionTurn[]>;
|
|
123
|
-
/** Persist an updated run record (called after completeRun / abortRun / errorRun). */
|
|
124
|
-
updateRun: (sessionId: string, run: SessionRun) => Promise<void>;
|
|
125
|
-
/** Update the top-level status of a session. */
|
|
126
|
-
updateStatus: (sessionId: string, status: SessionData['status']) => Promise<void>;
|
|
127
|
-
}
|
|
128
|
-
interface Session {
|
|
129
|
-
/** Session ID */
|
|
130
|
-
readonly id: string;
|
|
131
|
-
/** Agent ID (optional label) */
|
|
132
|
-
readonly agentId?: string;
|
|
133
|
-
/** Current turn history */
|
|
134
|
-
readonly turns: SessionTurn[];
|
|
135
|
-
/** Top-level session status */
|
|
136
|
-
readonly status: SessionData['status'];
|
|
137
|
-
/** All runs in this session */
|
|
138
|
-
readonly runs: SessionRun[];
|
|
139
|
-
/** Arbitrary metadata */
|
|
140
|
-
readonly metadata: Record<string, unknown>;
|
|
141
|
-
/** Start tracking a new run */
|
|
142
|
-
startRun: (runId: string, prompt: string) => void;
|
|
143
|
-
/** Mark a run as completed */
|
|
144
|
-
completeRun: (runId: string, stats: {
|
|
145
|
-
turns: number;
|
|
146
|
-
tokensIn: number;
|
|
147
|
-
tokensOut: number;
|
|
148
|
-
turnUsage?: TurnUsage[];
|
|
149
|
-
cost?: number;
|
|
150
|
-
}) => void;
|
|
151
|
-
/** Mark a run as aborted */
|
|
152
|
-
abortRun: (runId: string) => void;
|
|
153
|
-
/** Mark a run as errored */
|
|
154
|
-
errorRun: (runId: string, error: string) => void;
|
|
155
|
-
/** Append turns to in-memory history AND persist via store.appendTurns (if store present) */
|
|
156
|
-
appendTurns: (turns: SessionTurn[]) => Promise<void>;
|
|
157
|
-
/** Replace all turns in-memory (does not persist — use save() for that) */
|
|
158
|
-
setTurns: (turns: SessionTurn[]) => void;
|
|
159
|
-
/** Update the session status in memory AND via store.updateStatus (if store present) */
|
|
160
|
-
updateStatus: (status: SessionData['status']) => Promise<void>;
|
|
161
|
-
/** Persist an updated run record via store.updateRun (if store present) */
|
|
162
|
-
updateRun: (run: SessionRun) => Promise<void>;
|
|
163
|
-
/** Generate a turn ID using store.generateTurnId if available, else crypto.randomUUID() */
|
|
164
|
-
generateTurnId: () => string | Promise<string>;
|
|
165
|
-
/** Set metadata key */
|
|
166
|
-
setMeta: (key: string, value: unknown) => void;
|
|
167
|
-
/** Persist the full session document to the store */
|
|
168
|
-
save: () => Promise<void>;
|
|
169
|
-
/** Serialize to SessionData */
|
|
170
|
-
toJSON: () => SessionData;
|
|
171
|
-
}
|
|
172
|
-
interface CreateSessionOptions {
|
|
173
|
-
/** Session ID. If omitted and store provides generateSessionId, that is used. */
|
|
174
|
-
id?: string;
|
|
175
|
-
/** Agent ID label */
|
|
176
|
-
agentId?: string;
|
|
177
|
-
/** Initial metadata */
|
|
178
|
-
metadata?: Record<string, unknown>;
|
|
179
|
-
/** Storage backend (optional, enables save/load) */
|
|
180
|
-
store?: SessionStore;
|
|
181
|
-
_data?: SessionData;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Create a new session.
|
|
185
|
-
* Async so stores that generate IDs server-side (e.g. Supabase) can be supported.
|
|
186
|
-
*/
|
|
187
|
-
declare function createSession(options?: CreateSessionOptions): Promise<Session>;
|
|
188
|
-
/**
|
|
189
|
-
* Load an existing session from a store.
|
|
190
|
-
*/
|
|
191
|
-
declare function loadSession(store: SessionStore, sessionId: string): Promise<Session | null>;
|
|
192
|
-
|
|
193
|
-
export { type CreateSessionOptions, type RemoteStoreOptions, type Session, type SessionData, SessionMessage, type SessionRun, type SessionStore, SessionTurn, type SqliteStoreOptions, autoDetectAndConvert, createMemoryStore, createRemoteStore, createSession, createSqliteStore, fromAnthropic, fromOpenAI, loadSession, toAnthropic, toOpenAI };
|
|
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-DVvuhEN-.js';
|
|
2
|
+
import 'hookable';
|
|
3
|
+
import './types-CyRzBgm0.js';
|
|
4
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
package/dist/session.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createSession,
|
|
5
5
|
createSqliteStore,
|
|
6
6
|
loadSession
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XT7QBZ47.js";
|
|
8
8
|
import {
|
|
9
9
|
autoDetectAndConvert,
|
|
10
10
|
fromAnthropic,
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
toAnthropic,
|
|
13
13
|
toOpenAI
|
|
14
14
|
} from "./chunk-LS57GDAV.js";
|
|
15
|
-
import "./chunk-PNKVD2UK.js";
|
|
16
15
|
export {
|
|
17
16
|
autoDetectAndConvert,
|
|
18
17
|
createMemoryStore,
|
package/dist/skills.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { S as SkillConfig, b as ExecutionContext, c as ExecutionHandle, e as SkillsConfig } from './types-CyRzBgm0.js';
|
|
2
|
+
export { d as SkillResource } from './types-CyRzBgm0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Skill catalog generation.
|