zidane 1.1.5 → 1.2.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 +453 -26
- package/dist/agent-DvZm8U14.d.ts +313 -0
- package/dist/chunk-26LIQARN.js +109 -0
- package/dist/chunk-27EP7HB3.js +1005 -0
- package/dist/chunk-34KXKPNN.js +45 -0
- package/dist/chunk-LMSOIIAT.js +274 -0
- package/dist/chunk-LS57GDAV.js +365 -0
- package/dist/chunk-PNKVD2UK.js +26 -0
- package/dist/harnesses.d.ts +7 -24
- package/dist/harnesses.js +6 -1
- package/dist/index.d.ts +49 -82
- package/dist/index.js +51 -255
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.js +11 -0
- package/dist/providers.d.ts +65 -1
- package/dist/providers.js +37 -157
- package/dist/session.d.ts +167 -0
- package/dist/session.js +27 -0
- package/dist/spawn-pP2grsVp.d.ts +63 -0
- package/dist/tools.d.ts +28 -0
- package/dist/tools.js +20 -0
- package/dist/types-4CFQ-6Qu.d.ts +94 -0
- package/package.json +15 -1
- package/dist/chunk-ECE5USCO.js +0 -125
- package/dist/index-ByJfS-kX.d.ts +0 -101
package/dist/harnesses.d.ts
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
type ToolMap = Map<string, ToolDef>;
|
|
10
|
-
interface HarnessConfig {
|
|
11
|
-
/** Display name for this harness */
|
|
12
|
-
name: string;
|
|
13
|
-
/** Default system prompt injected when no system is provided at run time */
|
|
14
|
-
system?: string;
|
|
15
|
-
/** Tool definitions available to the agent */
|
|
16
|
-
tools: Record<string, ToolDef>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Define a harness with a name, optional system prompt, and tools.
|
|
20
|
-
*/
|
|
21
|
-
declare function defineHarness(config: HarnessConfig): HarnessConfig;
|
|
22
|
-
type Harness = HarnessConfig;
|
|
23
|
-
|
|
24
|
-
export { type Harness, type HarnessConfig, type ToolDef, type ToolMap, _default as basic, defineHarness };
|
|
1
|
+
import '@anthropic-ai/sdk';
|
|
2
|
+
import 'hookable';
|
|
3
|
+
export { H as Harness, f as HarnessConfig, T as ToolContext, g as ToolDef, h as ToolMap, _ as basic, l as basicTools, k as defineHarness } from './agent-DvZm8U14.js';
|
|
4
|
+
import './providers.js';
|
|
5
|
+
import './types-4CFQ-6Qu.js';
|
|
6
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
7
|
+
import './session.js';
|
package/dist/harnesses.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
basicTools,
|
|
2
3
|
basic_default,
|
|
3
4
|
defineHarness
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-34KXKPNN.js";
|
|
6
|
+
import "./chunk-27EP7HB3.js";
|
|
7
|
+
import "./chunk-26LIQARN.js";
|
|
8
|
+
import "./chunk-PNKVD2UK.js";
|
|
5
9
|
export {
|
|
6
10
|
basic_default as basic,
|
|
11
|
+
basicTools,
|
|
7
12
|
defineHarness
|
|
8
13
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,89 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
export {
|
|
1
|
+
import { S as SpawnConfig, E as ExecutionContext, a as ExecResult } from './agent-DvZm8U14.js';
|
|
2
|
+
export { A as Agent, b as AgentHooks, c as AgentOptions, C as ContextCapabilities, d as ContextType, e as ExecutionHandle, H as Harness, f as HarnessConfig, M as McpConnection, T as ToolContext, g as ToolDef, h as ToolMap, i as connectMcpServers, j as createAgent, k as defineHarness } from './agent-DvZm8U14.js';
|
|
3
|
+
export { CreateSessionOptions, RemoteStoreOptions, Session, SessionData, SessionRun, SessionStore, SqliteStoreOptions, autoDetectAndConvert, createMemoryStore, createRemoteStore, createSession, createSqliteStore, fromAnthropic, fromOpenAI, loadSession, toAnthropic, toOpenAI } from './session.js';
|
|
4
|
+
export { C as ChildAgent, S as SpawnToolOptions, a as SpawnToolState, c as createSpawnTool, s as spawn } from './spawn-pP2grsVp.js';
|
|
5
|
+
export { A as AgentRunOptions, a as AgentStats, I as ImageContent, M as McpServerConfig, S as SessionContentBlock, b as SessionMessage, T as ThinkingLevel, c as ToolExecutionMode, d as TurnUsage } from './types-4CFQ-6Qu.js';
|
|
6
|
+
import 'hookable';
|
|
6
7
|
import '@anthropic-ai/sdk';
|
|
8
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
9
|
+
import './providers.js';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
12
|
+
* Docker execution context.
|
|
13
|
+
*
|
|
14
|
+
* Runs tools inside a Docker container via dockerode.
|
|
15
|
+
* Full isolation with configurable resource limits.
|
|
16
|
+
*
|
|
17
|
+
* Requires `dockerode` as an optional peer dependency.
|
|
10
18
|
*/
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
input: Record<string, unknown>;
|
|
46
|
-
error: Error;
|
|
47
|
-
}) => void;
|
|
48
|
-
'tool:gate': (ctx: {
|
|
49
|
-
name: string;
|
|
50
|
-
input: Record<string, unknown>;
|
|
51
|
-
block: boolean;
|
|
52
|
-
reason: string;
|
|
53
|
-
}) => void;
|
|
54
|
-
'tool:transform': (ctx: {
|
|
55
|
-
name: string;
|
|
56
|
-
input: Record<string, unknown>;
|
|
57
|
-
result: string;
|
|
58
|
-
isError: boolean;
|
|
59
|
-
}) => void;
|
|
60
|
-
'context:transform': (ctx: {
|
|
61
|
-
messages: Message[];
|
|
62
|
-
}) => void;
|
|
63
|
-
'steer:inject': (ctx: {
|
|
64
|
-
message: string;
|
|
65
|
-
}) => void;
|
|
66
|
-
'agent:abort': (ctx: object) => void;
|
|
67
|
-
'agent:done': (ctx: AgentStats) => void;
|
|
68
|
-
}
|
|
69
|
-
interface AgentOptions {
|
|
70
|
-
harness: HarnessConfig;
|
|
71
|
-
provider: Provider;
|
|
72
|
-
/** Tool execution mode: 'sequential' (default) or 'parallel' */
|
|
73
|
-
toolExecution?: ToolExecutionMode;
|
|
74
|
-
}
|
|
75
|
-
interface Agent {
|
|
76
|
-
hooks: Hookable<AgentHooks>;
|
|
77
|
-
run: (options: AgentRunOptions) => Promise<AgentStats>;
|
|
78
|
-
abort: () => void;
|
|
79
|
-
steer: (message: string) => void;
|
|
80
|
-
followUp: (message: string) => void;
|
|
81
|
-
waitForIdle: () => Promise<void>;
|
|
82
|
-
reset: () => void;
|
|
83
|
-
readonly isRunning: boolean;
|
|
84
|
-
readonly messages: Message[];
|
|
85
|
-
meta: Record<string, unknown>;
|
|
20
|
+
declare function createDockerContext(config?: SpawnConfig): ExecutionContext;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* In-process execution context.
|
|
24
|
+
*
|
|
25
|
+
* Runs everything in the current Node/Bun process.
|
|
26
|
+
* No isolation — fastest, used as the default.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
declare function createProcessContext(config?: SpawnConfig): ExecutionContext;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Remote sandbox execution context.
|
|
33
|
+
*
|
|
34
|
+
* Offloads execution to a remote sandbox API (e.g. Rivet, E2B).
|
|
35
|
+
* Specific providers implement the SandboxProvider interface.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
interface SandboxProvider {
|
|
39
|
+
name: string;
|
|
40
|
+
spawn: (config: SpawnConfig) => Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
cwd: string;
|
|
43
|
+
}>;
|
|
44
|
+
exec: (sandboxId: string, command: string, options?: {
|
|
45
|
+
cwd?: string;
|
|
46
|
+
env?: Record<string, string>;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
}) => Promise<ExecResult>;
|
|
49
|
+
readFile: (sandboxId: string, path: string) => Promise<string>;
|
|
50
|
+
writeFile: (sandboxId: string, path: string, content: string) => Promise<void>;
|
|
51
|
+
listFiles: (sandboxId: string, path: string) => Promise<string[]>;
|
|
52
|
+
destroy: (sandboxId: string) => Promise<void>;
|
|
86
53
|
}
|
|
87
|
-
declare function
|
|
54
|
+
declare function createSandboxContext(provider: SandboxProvider): ExecutionContext;
|
|
88
55
|
|
|
89
|
-
export {
|
|
56
|
+
export { ExecResult, ExecutionContext, type SandboxProvider, SpawnConfig, createDockerContext, createProcessContext, createSandboxContext };
|
package/dist/index.js
CHANGED
|
@@ -1,261 +1,57 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineHarness
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (ctx.signal.aborted) {
|
|
34
|
-
await ctx.hooks.callHook("agent:abort", {});
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
if (ctx.steeringQueue.length > 0) {
|
|
38
|
-
const steerMsg = ctx.steeringQueue.shift();
|
|
39
|
-
await ctx.hooks.callHook("steer:inject", { message: steerMsg });
|
|
40
|
-
ctx.messages.push(ctx.provider.userMessage(steerMsg));
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (result.ended) {
|
|
44
|
-
if (ctx.followUpQueue.length > 0) {
|
|
45
|
-
const followUp = ctx.followUpQueue.shift();
|
|
46
|
-
await ctx.hooks.callHook("steer:inject", { message: followUp });
|
|
47
|
-
ctx.messages.push(ctx.provider.userMessage(followUp));
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
return { totalIn, totalOut, turns: turn + 1, elapsed: Date.now() - startTime };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const stats = { totalIn, totalOut, turns: maxTurns, elapsed: Date.now() - startTime };
|
|
54
|
-
await ctx.hooks.callHook("agent:done", stats);
|
|
55
|
-
return stats;
|
|
56
|
-
}
|
|
57
|
-
async function executeTurn(ctx, turn) {
|
|
58
|
-
const streamOptions = {
|
|
59
|
-
model: ctx.model,
|
|
60
|
-
system: ctx.system,
|
|
61
|
-
tools: ctx.formattedTools,
|
|
62
|
-
messages: ctx.messages,
|
|
63
|
-
maxTokens: 16384,
|
|
64
|
-
thinking: ctx.thinking,
|
|
65
|
-
signal: ctx.signal
|
|
66
|
-
};
|
|
67
|
-
await ctx.hooks.callHook("context:transform", { messages: ctx.messages });
|
|
68
|
-
await ctx.hooks.callHook("turn:before", { turn, options: streamOptions });
|
|
69
|
-
let currentText = "";
|
|
70
|
-
const result = await ctx.provider.stream(
|
|
71
|
-
streamOptions,
|
|
72
|
-
{
|
|
73
|
-
onText(delta) {
|
|
74
|
-
currentText += delta;
|
|
75
|
-
ctx.hooks.callHook("stream:text", { delta, text: currentText });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
if (currentText) {
|
|
80
|
-
await ctx.hooks.callHook("stream:end", { text: currentText });
|
|
81
|
-
}
|
|
82
|
-
await ctx.hooks.callHook("turn:after", { turn, usage: result.usage });
|
|
83
|
-
if (result.done) {
|
|
84
|
-
return { ended: true, usage: result.usage };
|
|
85
|
-
}
|
|
86
|
-
ctx.messages.push({ role: "assistant", content: result.assistantMessage });
|
|
87
|
-
const toolResults = ctx.toolExecution === "parallel" ? await executeToolsParallel(ctx, result.toolCalls) : await executeToolsSequential(ctx, result.toolCalls);
|
|
88
|
-
ctx.messages.push(ctx.provider.toolResultsMessage(toolResults));
|
|
89
|
-
return { ended: false, usage: result.usage };
|
|
90
|
-
}
|
|
91
|
-
async function executeSingleTool(ctx, call) {
|
|
92
|
-
const toolDef = ctx.tools[call.name];
|
|
93
|
-
const gateCtx = { name: call.name, input: call.input, block: false, reason: "Tool execution was blocked" };
|
|
94
|
-
await ctx.hooks.callHook("tool:gate", gateCtx);
|
|
95
|
-
if (gateCtx.block) {
|
|
96
|
-
return { result: { id: call.id, content: `Blocked: ${gateCtx.reason}` }, steered: false };
|
|
97
|
-
}
|
|
98
|
-
if (!toolDef) {
|
|
99
|
-
const err = new Error(`Unknown tool: ${call.name}`);
|
|
100
|
-
await ctx.hooks.callHook("tool:error", { name: call.name, input: call.input, error: err });
|
|
101
|
-
return { result: { id: call.id, content: `Tool error: ${err.message}` }, steered: false };
|
|
102
|
-
}
|
|
103
|
-
const validation = validateToolArgs(call.input, toolDef.spec.input_schema);
|
|
104
|
-
if (!validation.valid) {
|
|
105
|
-
return { result: { id: call.id, content: `Validation error: ${validation.error}` }, steered: false };
|
|
106
|
-
}
|
|
107
|
-
await ctx.hooks.callHook("tool:before", { name: call.name, input: call.input });
|
|
108
|
-
let output;
|
|
109
|
-
let isError = false;
|
|
110
|
-
try {
|
|
111
|
-
output = await toolDef.execute(call.input);
|
|
112
|
-
} catch (err) {
|
|
113
|
-
await ctx.hooks.callHook("tool:error", { name: call.name, input: call.input, error: err });
|
|
114
|
-
output = `Tool error: ${err.message}`;
|
|
115
|
-
isError = true;
|
|
116
|
-
}
|
|
117
|
-
const transformCtx = { name: call.name, input: call.input, result: output, isError };
|
|
118
|
-
await ctx.hooks.callHook("tool:transform", transformCtx);
|
|
119
|
-
output = transformCtx.result;
|
|
120
|
-
isError = transformCtx.isError;
|
|
121
|
-
await ctx.hooks.callHook("tool:after", { name: call.name, input: call.input, result: output });
|
|
122
|
-
return { result: { id: call.id, content: output }, steered: false };
|
|
123
|
-
}
|
|
124
|
-
async function executeToolsSequential(ctx, toolCalls) {
|
|
125
|
-
const results = [];
|
|
126
|
-
for (const call of toolCalls) {
|
|
127
|
-
if (ctx.signal.aborted)
|
|
128
|
-
break;
|
|
129
|
-
if (ctx.steeringQueue.length > 0) {
|
|
130
|
-
const steerMsg = ctx.steeringQueue.shift();
|
|
131
|
-
await ctx.hooks.callHook("steer:inject", { message: steerMsg });
|
|
132
|
-
for (const skipped of toolCalls.slice(toolCalls.indexOf(call))) {
|
|
133
|
-
results.push({ id: skipped.id, content: "Skipped: steering message received" });
|
|
134
|
-
}
|
|
135
|
-
ctx.messages.push(ctx.provider.toolResultsMessage(results));
|
|
136
|
-
ctx.messages.push(ctx.provider.userMessage(steerMsg));
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
const { result } = await executeSingleTool(ctx, call);
|
|
140
|
-
results.push(result);
|
|
141
|
-
}
|
|
142
|
-
return results;
|
|
143
|
-
}
|
|
144
|
-
async function executeToolsParallel(ctx, toolCalls) {
|
|
145
|
-
const executions = toolCalls.map((call) => executeSingleTool(ctx, call));
|
|
146
|
-
const settled = await Promise.all(executions);
|
|
147
|
-
return settled.map((s) => s.result);
|
|
148
|
-
}
|
|
3
|
+
} from "./chunk-34KXKPNN.js";
|
|
4
|
+
import {
|
|
5
|
+
createAgent,
|
|
6
|
+
createDockerContext,
|
|
7
|
+
createProcessContext,
|
|
8
|
+
createSandboxContext,
|
|
9
|
+
createSpawnTool,
|
|
10
|
+
init_agent,
|
|
11
|
+
init_contexts,
|
|
12
|
+
spawn
|
|
13
|
+
} from "./chunk-27EP7HB3.js";
|
|
14
|
+
import {
|
|
15
|
+
connectMcpServers,
|
|
16
|
+
init_mcp
|
|
17
|
+
} from "./chunk-26LIQARN.js";
|
|
18
|
+
import {
|
|
19
|
+
createMemoryStore,
|
|
20
|
+
createRemoteStore,
|
|
21
|
+
createSession,
|
|
22
|
+
createSqliteStore,
|
|
23
|
+
loadSession
|
|
24
|
+
} from "./chunk-LMSOIIAT.js";
|
|
25
|
+
import {
|
|
26
|
+
autoDetectAndConvert,
|
|
27
|
+
fromAnthropic,
|
|
28
|
+
fromOpenAI,
|
|
29
|
+
toAnthropic,
|
|
30
|
+
toOpenAI
|
|
31
|
+
} from "./chunk-LS57GDAV.js";
|
|
32
|
+
import "./chunk-PNKVD2UK.js";
|
|
149
33
|
|
|
150
|
-
// src/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
let running = false;
|
|
155
|
-
let idleResolve;
|
|
156
|
-
let idlePromise;
|
|
157
|
-
const steeringQueue = [];
|
|
158
|
-
const followUpQueue = [];
|
|
159
|
-
let conversationMessages = [];
|
|
160
|
-
async function run(options) {
|
|
161
|
-
if (running) {
|
|
162
|
-
throw new Error("Agent is already running. Use steer() or followUp() to queue messages, or waitForIdle().");
|
|
163
|
-
}
|
|
164
|
-
running = true;
|
|
165
|
-
abortController = new AbortController();
|
|
166
|
-
idlePromise = new Promise((resolve) => {
|
|
167
|
-
idleResolve = resolve;
|
|
168
|
-
});
|
|
169
|
-
const thinking = options.thinking ?? "off";
|
|
170
|
-
const model = options.model ?? provider.meta.defaultModel;
|
|
171
|
-
const system = options.system || harness.system || "You are a helpful assistant.";
|
|
172
|
-
const tools = harness.tools;
|
|
173
|
-
const toolSpecs = Object.values(tools).map(
|
|
174
|
-
(t) => ({
|
|
175
|
-
name: t.spec.name,
|
|
176
|
-
description: t.spec.description || "",
|
|
177
|
-
input_schema: t.spec.input_schema
|
|
178
|
-
})
|
|
179
|
-
);
|
|
180
|
-
const formattedTools = provider.formatTools(toolSpecs);
|
|
181
|
-
const messages = [];
|
|
182
|
-
if (options.system) {
|
|
183
|
-
await hooks.callHook("system:before", { system: options.system });
|
|
184
|
-
messages.push(provider.userMessage(options.system));
|
|
185
|
-
messages.push(provider.assistantMessage("Understood. I will proceed with these instructions above the rest of my system prompt."));
|
|
186
|
-
}
|
|
187
|
-
messages.push(provider.userMessage(options.prompt, options.images));
|
|
188
|
-
conversationMessages = messages;
|
|
189
|
-
try {
|
|
190
|
-
const stats = await runLoop({
|
|
191
|
-
provider,
|
|
192
|
-
hooks,
|
|
193
|
-
tools,
|
|
194
|
-
toolSpecs,
|
|
195
|
-
formattedTools,
|
|
196
|
-
model,
|
|
197
|
-
system,
|
|
198
|
-
thinking,
|
|
199
|
-
toolExecution,
|
|
200
|
-
signal: abortController.signal,
|
|
201
|
-
steeringQueue,
|
|
202
|
-
followUpQueue,
|
|
203
|
-
messages
|
|
204
|
-
});
|
|
205
|
-
await hooks.callHook("agent:done", stats);
|
|
206
|
-
return stats;
|
|
207
|
-
} catch (err) {
|
|
208
|
-
if (abortController.signal.aborted) {
|
|
209
|
-
const stats = { totalIn: 0, totalOut: 0, turns: 0, elapsed: 0 };
|
|
210
|
-
await hooks.callHook("agent:done", stats);
|
|
211
|
-
return stats;
|
|
212
|
-
}
|
|
213
|
-
throw err;
|
|
214
|
-
} finally {
|
|
215
|
-
running = false;
|
|
216
|
-
abortController = void 0;
|
|
217
|
-
steeringQueue.length = 0;
|
|
218
|
-
followUpQueue.length = 0;
|
|
219
|
-
idleResolve?.();
|
|
220
|
-
idlePromise = void 0;
|
|
221
|
-
idleResolve = void 0;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function abort() {
|
|
225
|
-
abortController?.abort();
|
|
226
|
-
}
|
|
227
|
-
function steer(message) {
|
|
228
|
-
steeringQueue.push(message);
|
|
229
|
-
}
|
|
230
|
-
function followUpFn(message) {
|
|
231
|
-
followUpQueue.push(message);
|
|
232
|
-
}
|
|
233
|
-
function waitForIdle() {
|
|
234
|
-
return idlePromise ?? Promise.resolve();
|
|
235
|
-
}
|
|
236
|
-
function reset() {
|
|
237
|
-
conversationMessages = [];
|
|
238
|
-
steeringQueue.length = 0;
|
|
239
|
-
followUpQueue.length = 0;
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
hooks,
|
|
243
|
-
run,
|
|
244
|
-
abort,
|
|
245
|
-
steer,
|
|
246
|
-
followUp: followUpFn,
|
|
247
|
-
waitForIdle,
|
|
248
|
-
reset,
|
|
249
|
-
get isRunning() {
|
|
250
|
-
return running;
|
|
251
|
-
},
|
|
252
|
-
get messages() {
|
|
253
|
-
return conversationMessages;
|
|
254
|
-
},
|
|
255
|
-
meta: provider.meta
|
|
256
|
-
};
|
|
257
|
-
}
|
|
34
|
+
// src/index.ts
|
|
35
|
+
init_agent();
|
|
36
|
+
init_contexts();
|
|
37
|
+
init_mcp();
|
|
258
38
|
export {
|
|
39
|
+
autoDetectAndConvert,
|
|
40
|
+
connectMcpServers,
|
|
259
41
|
createAgent,
|
|
260
|
-
|
|
42
|
+
createDockerContext,
|
|
43
|
+
createMemoryStore,
|
|
44
|
+
createProcessContext,
|
|
45
|
+
createRemoteStore,
|
|
46
|
+
createSandboxContext,
|
|
47
|
+
createSession,
|
|
48
|
+
createSpawnTool,
|
|
49
|
+
createSqliteStore,
|
|
50
|
+
defineHarness,
|
|
51
|
+
fromAnthropic,
|
|
52
|
+
fromOpenAI,
|
|
53
|
+
loadSession,
|
|
54
|
+
spawn,
|
|
55
|
+
toAnthropic,
|
|
56
|
+
toOpenAI
|
|
261
57
|
};
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'hookable';
|
|
2
|
+
export { M as McpConnection, i as connectMcpServers, r as resultToString } from './agent-DvZm8U14.js';
|
|
3
|
+
export { M as McpServerConfig } from './types-4CFQ-6Qu.js';
|
|
4
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
5
|
+
import '@anthropic-ai/sdk';
|
|
6
|
+
import './providers.js';
|
|
7
|
+
import './session.js';
|
package/dist/mcp.js
ADDED
package/dist/providers.d.ts
CHANGED
|
@@ -1 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
import { b as SessionMessage, T as ThinkingLevel, I as ImageContent, d as TurnUsage } from './types-4CFQ-6Qu.js';
|
|
2
|
+
|
|
3
|
+
declare function anthropic(): Provider;
|
|
4
|
+
|
|
5
|
+
declare function cerebras(defaultModel?: string): Provider;
|
|
6
|
+
|
|
7
|
+
declare function openrouter(defaultModel?: string): Provider;
|
|
8
|
+
|
|
9
|
+
interface ToolSpec {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
input_schema: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
interface ToolCall {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
input: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
interface ToolResult {
|
|
20
|
+
id: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
interface StreamCallbacks {
|
|
24
|
+
onText: (delta: string) => void;
|
|
25
|
+
}
|
|
26
|
+
interface TurnResult {
|
|
27
|
+
/** Full assistant turn as a SessionMessage */
|
|
28
|
+
assistantMessage: SessionMessage;
|
|
29
|
+
/** Text content blocks concatenated */
|
|
30
|
+
text: string;
|
|
31
|
+
/** Tool calls requested by the model */
|
|
32
|
+
toolCalls: ToolCall[];
|
|
33
|
+
/** Whether the model wants to stop */
|
|
34
|
+
done: boolean;
|
|
35
|
+
usage: TurnUsage;
|
|
36
|
+
}
|
|
37
|
+
interface StreamOptions {
|
|
38
|
+
model: string;
|
|
39
|
+
system: string;
|
|
40
|
+
tools: unknown[];
|
|
41
|
+
messages: SessionMessage[];
|
|
42
|
+
maxTokens: number;
|
|
43
|
+
/** Thinking/reasoning level (optional, default: off) */
|
|
44
|
+
thinking?: ThinkingLevel;
|
|
45
|
+
/** Abort signal for cancellation */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
interface Provider {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly meta: {
|
|
51
|
+
defaultModel: string;
|
|
52
|
+
} & Record<string, unknown>;
|
|
53
|
+
/** Format tool specs for this provider */
|
|
54
|
+
formatTools: (tools: ToolSpec[]) => unknown[];
|
|
55
|
+
/** Create a user message (text or with images) */
|
|
56
|
+
userMessage: (content: string, images?: ImageContent[]) => SessionMessage;
|
|
57
|
+
/** Create an assistant message (for priming) */
|
|
58
|
+
assistantMessage: (content: string) => SessionMessage;
|
|
59
|
+
/** Create a tool results message to send back */
|
|
60
|
+
toolResultsMessage: (results: ToolResult[]) => SessionMessage;
|
|
61
|
+
/** Stream a turn, calling onText for each text delta */
|
|
62
|
+
stream: (options: StreamOptions, callbacks: StreamCallbacks) => Promise<TurnResult>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { type Provider, type StreamCallbacks, type StreamOptions, type ToolCall, type ToolResult, type ToolSpec, type TurnResult, anthropic, cerebras, openrouter };
|