@witqq/agent-sdk 0.7.0 → 0.9.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/dist/{types-CqvUAYxt.d.ts → agent-C6H2CgJA.d.cts} +139 -102
- package/dist/{types-CqvUAYxt.d.cts → agent-F7oB6eKp.d.ts} +139 -102
- package/dist/auth/index.cjs +72 -1
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +21 -154
- package/dist/auth/index.d.ts +21 -154
- package/dist/auth/index.js +72 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/backends/claude.cjs +480 -261
- package/dist/backends/claude.cjs.map +1 -1
- package/dist/backends/claude.d.cts +3 -1
- package/dist/backends/claude.d.ts +3 -1
- package/dist/backends/claude.js +480 -261
- package/dist/backends/claude.js.map +1 -1
- package/dist/backends/copilot.cjs +337 -112
- package/dist/backends/copilot.cjs.map +1 -1
- package/dist/backends/copilot.d.cts +12 -4
- package/dist/backends/copilot.d.ts +12 -4
- package/dist/backends/copilot.js +337 -112
- package/dist/backends/copilot.js.map +1 -1
- package/dist/backends/mock-llm.cjs +719 -0
- package/dist/backends/mock-llm.cjs.map +1 -0
- package/dist/backends/mock-llm.d.cts +37 -0
- package/dist/backends/mock-llm.d.ts +37 -0
- package/dist/backends/mock-llm.js +717 -0
- package/dist/backends/mock-llm.js.map +1 -0
- package/dist/backends/vercel-ai.cjs +301 -61
- package/dist/backends/vercel-ai.cjs.map +1 -1
- package/dist/backends/vercel-ai.d.cts +3 -1
- package/dist/backends/vercel-ai.d.ts +3 -1
- package/dist/backends/vercel-ai.js +301 -61
- package/dist/backends/vercel-ai.js.map +1 -1
- package/dist/backends-Cno0gZjy.d.cts +114 -0
- package/dist/backends-Cno0gZjy.d.ts +114 -0
- package/dist/chat/accumulator.cjs +1 -1
- package/dist/chat/accumulator.cjs.map +1 -1
- package/dist/chat/accumulator.d.cts +5 -2
- package/dist/chat/accumulator.d.ts +5 -2
- package/dist/chat/accumulator.js +1 -1
- package/dist/chat/accumulator.js.map +1 -1
- package/dist/chat/backends.cjs +1084 -821
- package/dist/chat/backends.cjs.map +1 -1
- package/dist/chat/backends.d.cts +10 -6
- package/dist/chat/backends.d.ts +10 -6
- package/dist/chat/backends.js +1082 -800
- package/dist/chat/backends.js.map +1 -1
- package/dist/chat/context.cjs +50 -0
- package/dist/chat/context.cjs.map +1 -1
- package/dist/chat/context.d.cts +27 -3
- package/dist/chat/context.d.ts +27 -3
- package/dist/chat/context.js +50 -0
- package/dist/chat/context.js.map +1 -1
- package/dist/chat/core.cjs +60 -27
- package/dist/chat/core.cjs.map +1 -1
- package/dist/chat/core.d.cts +41 -382
- package/dist/chat/core.d.ts +41 -382
- package/dist/chat/core.js +58 -28
- package/dist/chat/core.js.map +1 -1
- package/dist/chat/errors.cjs +48 -26
- package/dist/chat/errors.cjs.map +1 -1
- package/dist/chat/errors.d.cts +6 -31
- package/dist/chat/errors.d.ts +6 -31
- package/dist/chat/errors.js +48 -25
- package/dist/chat/errors.js.map +1 -1
- package/dist/chat/events.cjs.map +1 -1
- package/dist/chat/events.d.cts +6 -2
- package/dist/chat/events.d.ts +6 -2
- package/dist/chat/events.js.map +1 -1
- package/dist/chat/index.cjs +1612 -1125
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +35 -10
- package/dist/chat/index.d.ts +35 -10
- package/dist/chat/index.js +1600 -1097
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react/theme.css +2517 -0
- package/dist/chat/react.cjs +2212 -1158
- package/dist/chat/react.cjs.map +1 -1
- package/dist/chat/react.d.cts +665 -122
- package/dist/chat/react.d.ts +665 -122
- package/dist/chat/react.js +2191 -1156
- package/dist/chat/react.js.map +1 -1
- package/dist/chat/runtime.cjs +405 -186
- package/dist/chat/runtime.cjs.map +1 -1
- package/dist/chat/runtime.d.cts +92 -28
- package/dist/chat/runtime.d.ts +92 -28
- package/dist/chat/runtime.js +405 -186
- package/dist/chat/runtime.js.map +1 -1
- package/dist/chat/server.cjs +2247 -212
- package/dist/chat/server.cjs.map +1 -1
- package/dist/chat/server.d.cts +451 -90
- package/dist/chat/server.d.ts +451 -90
- package/dist/chat/server.js +2234 -213
- package/dist/chat/server.js.map +1 -1
- package/dist/chat/sessions.cjs +64 -66
- package/dist/chat/sessions.cjs.map +1 -1
- package/dist/chat/sessions.d.cts +37 -118
- package/dist/chat/sessions.d.ts +37 -118
- package/dist/chat/sessions.js +65 -67
- package/dist/chat/sessions.js.map +1 -1
- package/dist/chat/sqlite.cjs +536 -0
- package/dist/chat/sqlite.cjs.map +1 -0
- package/dist/chat/sqlite.d.cts +164 -0
- package/dist/chat/sqlite.d.ts +164 -0
- package/dist/chat/sqlite.js +527 -0
- package/dist/chat/sqlite.js.map +1 -0
- package/dist/chat/state.cjs +14 -1
- package/dist/chat/state.cjs.map +1 -1
- package/dist/chat/state.d.cts +5 -2
- package/dist/chat/state.d.ts +5 -2
- package/dist/chat/state.js +14 -1
- package/dist/chat/state.js.map +1 -1
- package/dist/chat/storage.cjs +58 -33
- package/dist/chat/storage.cjs.map +1 -1
- package/dist/chat/storage.d.cts +18 -8
- package/dist/chat/storage.d.ts +18 -8
- package/dist/chat/storage.js +59 -34
- package/dist/chat/storage.js.map +1 -1
- package/dist/errors-C-so0M4t.d.cts +33 -0
- package/dist/errors-C-so0M4t.d.ts +33 -0
- package/dist/errors-CmVvczxZ.d.cts +28 -0
- package/dist/errors-CmVvczxZ.d.ts +28 -0
- package/dist/{in-process-transport-C2oPTYs6.d.ts → in-process-transport-7EIit9Xk.d.ts} +72 -33
- package/dist/{in-process-transport-DG-w5G6k.d.cts → in-process-transport-Ct9YcX8I.d.cts} +72 -33
- package/dist/index.cjs +354 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +294 -123
- package/dist/index.d.ts +294 -123
- package/dist/index.js +347 -60
- package/dist/index.js.map +1 -1
- package/dist/provider-types-PTSlRPNB.d.cts +39 -0
- package/dist/provider-types-PTSlRPNB.d.ts +39 -0
- package/dist/refresh-manager-B81PpYBr.d.cts +153 -0
- package/dist/refresh-manager-Dlv_iNZi.d.ts +153 -0
- package/dist/testing.cjs +1107 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +144 -0
- package/dist/testing.d.ts +144 -0
- package/dist/testing.js +1101 -0
- package/dist/testing.js.map +1 -0
- package/dist/token-store-CSUBgYwn.d.ts +48 -0
- package/dist/token-store-CuC4hB9Z.d.cts +48 -0
- package/dist/{transport-DX1Nhm4N.d.cts → transport-DLWCN18G.d.cts} +5 -4
- package/dist/{transport-D1OaUgRk.d.ts → transport-DsuS-GeM.d.ts} +5 -4
- package/dist/{types-CGF7AEX1.d.cts → types-4vbcmPTp.d.cts} +4 -2
- package/dist/{types-Bh5AhqD-.d.ts → types-BxggH0Yh.d.ts} +4 -2
- package/dist/types-DgtI1hzh.d.ts +364 -0
- package/dist/types-DkSXALKg.d.cts +364 -0
- package/package.json +41 -5
- package/LICENSE +0 -21
- package/README.md +0 -948
- package/dist/errors-BDLbNu9w.d.cts +0 -13
- package/dist/errors-BDLbNu9w.d.ts +0 -13
- package/dist/types-DLZzlJxt.d.ts +0 -39
- package/dist/types-tE0CXwBl.d.cts +0 -39
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/** Pluggable store for persisting permission (scope) decisions across runs. */
|
|
4
|
-
interface IPermissionStore {
|
|
5
|
-
/** Check if tool is already approved */
|
|
6
|
-
isApproved(toolName: string): Promise<boolean>;
|
|
7
|
-
/** Store an approval decision */
|
|
8
|
-
approve(toolName: string, scope: PermissionScope): Promise<void>;
|
|
9
|
-
/** Revoke approval for a tool */
|
|
10
|
-
revoke(toolName: string): Promise<void>;
|
|
11
|
-
/** Clear all approvals */
|
|
12
|
-
clear(): Promise<void>;
|
|
13
|
-
/** Dispose resources */
|
|
14
|
-
dispose(): Promise<void>;
|
|
15
|
-
}
|
|
2
|
+
import { E as ErrorCode } from './errors-C-so0M4t.cjs';
|
|
16
3
|
|
|
17
4
|
/** JSON-serializable value used for tool arguments and results */
|
|
18
5
|
type JSONValue = string | number | boolean | null | JSONValue[] | {
|
|
19
6
|
[key: string]: JSONValue;
|
|
20
7
|
};
|
|
21
|
-
|
|
22
|
-
type MessageContent = string | Array<ContentPart>;
|
|
23
|
-
/** Individual content part within a multi-part message */
|
|
24
|
-
type ContentPart = {
|
|
25
|
-
type: "text";
|
|
26
|
-
text: string;
|
|
27
|
-
} | {
|
|
28
|
-
type: "image";
|
|
29
|
-
data: string;
|
|
30
|
-
mimeType: string;
|
|
31
|
-
};
|
|
8
|
+
|
|
32
9
|
/** What the LLM sees — name, description, schema. Passed to all backends. */
|
|
33
10
|
interface ToolDeclaration<TParams = unknown> {
|
|
34
11
|
name: string;
|
|
@@ -46,7 +23,7 @@ interface ToolDeclaration<TParams = unknown> {
|
|
|
46
23
|
* The optional second parameter receives request-scoped context
|
|
47
24
|
* when invoked through ChatRuntime (session ID, user data, custom metadata). */
|
|
48
25
|
interface ToolDefinition<TParams = unknown> extends ToolDeclaration<TParams> {
|
|
49
|
-
execute: (params: TParams, context?: ToolContext) => Promise<
|
|
26
|
+
execute: (params: TParams, context?: ToolContext) => Promise<unknown> | unknown;
|
|
50
27
|
}
|
|
51
28
|
/** Request-scoped context passed to tool execute functions via ChatRuntime.
|
|
52
29
|
* Contains session identity and user-defined metadata from the current session. */
|
|
@@ -69,6 +46,18 @@ interface ToolResult {
|
|
|
69
46
|
result: JSONValue;
|
|
70
47
|
isError?: boolean;
|
|
71
48
|
}
|
|
49
|
+
|
|
50
|
+
/** Message content — plain string or array of text/image parts */
|
|
51
|
+
type MessageContent = string | Array<ContentPart>;
|
|
52
|
+
/** Individual content part within a multi-part message */
|
|
53
|
+
type ContentPart = {
|
|
54
|
+
type: "text";
|
|
55
|
+
text: string;
|
|
56
|
+
} | {
|
|
57
|
+
type: "image";
|
|
58
|
+
data: string;
|
|
59
|
+
mimeType: string;
|
|
60
|
+
};
|
|
72
61
|
/** Conversation message — discriminated union on `role` */
|
|
73
62
|
type Message = {
|
|
74
63
|
role: "user";
|
|
@@ -77,6 +66,7 @@ type Message = {
|
|
|
77
66
|
role: "assistant";
|
|
78
67
|
content: MessageContent;
|
|
79
68
|
toolCalls?: ToolCall[];
|
|
69
|
+
thinking?: string;
|
|
80
70
|
} | {
|
|
81
71
|
role: "tool";
|
|
82
72
|
content?: string;
|
|
@@ -85,12 +75,15 @@ type Message = {
|
|
|
85
75
|
role: "system";
|
|
86
76
|
content: string;
|
|
87
77
|
};
|
|
78
|
+
|
|
88
79
|
/** Scope for "remember this decision" */
|
|
89
80
|
type PermissionScope = "once" | "session" | "project" | "always";
|
|
90
81
|
/** What the permission callback receives */
|
|
91
82
|
interface PermissionRequest {
|
|
92
83
|
toolName: string;
|
|
93
84
|
toolArgs: Record<string, unknown>;
|
|
85
|
+
/** Unique identifier for this specific tool call */
|
|
86
|
+
toolCallId?: string;
|
|
94
87
|
/** SDK-suggested scope (from Claude CLI's suggestions) */
|
|
95
88
|
suggestedScope?: PermissionScope;
|
|
96
89
|
/** Original SDK permission request (for pass-through) */
|
|
@@ -128,12 +121,32 @@ interface SupervisorHooks {
|
|
|
128
121
|
onPermission?: PermissionCallback;
|
|
129
122
|
onAskUser?: (request: UserInputRequest, signal: AbortSignal) => Promise<UserInputResponse>;
|
|
130
123
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
124
|
+
|
|
125
|
+
/** Model metadata returned by listModels() */
|
|
126
|
+
interface ModelInfo {
|
|
127
|
+
id: string;
|
|
134
128
|
name?: string;
|
|
135
|
-
|
|
129
|
+
provider?: string;
|
|
130
|
+
/** Model tier for UI categorization and cost hints */
|
|
131
|
+
tier?: "fast" | "standard" | "premium";
|
|
132
|
+
/** Context window size in tokens */
|
|
133
|
+
contextWindow?: number;
|
|
134
|
+
/** Model capabilities (e.g. "vision", "tools", "structured") */
|
|
135
|
+
capabilities?: string[];
|
|
136
|
+
}
|
|
137
|
+
/** LLM model parameters */
|
|
138
|
+
interface ModelParams {
|
|
139
|
+
temperature?: number;
|
|
140
|
+
maxTokens?: number;
|
|
141
|
+
topP?: number;
|
|
142
|
+
stopSequences?: string[];
|
|
143
|
+
}
|
|
144
|
+
/** Result of backend validation check */
|
|
145
|
+
interface ValidationResult {
|
|
146
|
+
valid: boolean;
|
|
147
|
+
errors: string[];
|
|
136
148
|
}
|
|
149
|
+
|
|
137
150
|
/** Usage data from LLM execution — tokens consumed plus optional metadata */
|
|
138
151
|
interface UsageData {
|
|
139
152
|
promptTokens: number;
|
|
@@ -192,24 +205,79 @@ type AgentEvent = {
|
|
|
192
205
|
type: "error";
|
|
193
206
|
error: string;
|
|
194
207
|
recoverable: boolean;
|
|
208
|
+
code?: ErrorCode;
|
|
195
209
|
} | {
|
|
196
210
|
type: "done";
|
|
197
211
|
finalOutput: string | null;
|
|
198
212
|
structuredOutput?: unknown;
|
|
213
|
+
streamed?: boolean;
|
|
214
|
+
finishReason?: string;
|
|
199
215
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
216
|
+
|
|
217
|
+
/** Pluggable store for persisting permission (scope) decisions across runs. */
|
|
218
|
+
interface IPermissionStore {
|
|
219
|
+
/** Check if tool is already approved */
|
|
220
|
+
isApproved(toolName: string): Promise<boolean>;
|
|
221
|
+
/** Store an approval decision */
|
|
222
|
+
approve(toolName: string, scope: PermissionScope): Promise<void>;
|
|
223
|
+
/** Revoke approval for a tool */
|
|
224
|
+
revoke(toolName: string): Promise<void>;
|
|
225
|
+
/** Clear all approvals */
|
|
226
|
+
clear(): Promise<void>;
|
|
227
|
+
/** Dispose resources */
|
|
228
|
+
dispose(): Promise<void>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Per-call overrides passed to run(), stream(), runStructured().
|
|
232
|
+
* Allows overriding the model, tools, signal, and other parameters
|
|
233
|
+
* on a per-request basis without modifying the agent configuration. */
|
|
234
|
+
interface CallOptions {
|
|
235
|
+
/** Override the default model for this call */
|
|
236
|
+
model?: string;
|
|
237
|
+
/** Override/extend tools for this call */
|
|
238
|
+
tools?: ToolDefinition[];
|
|
239
|
+
/** Per-call abort signal */
|
|
203
240
|
signal?: AbortSignal;
|
|
241
|
+
/** Override system message for this call */
|
|
242
|
+
systemMessage?: string;
|
|
243
|
+
/** Provider-specific options passed through to the underlying SDK */
|
|
244
|
+
providerOptions?: Record<string, unknown>;
|
|
245
|
+
/** Per-call timeout in milliseconds */
|
|
246
|
+
timeout?: number;
|
|
247
|
+
/** Per-call token limit */
|
|
248
|
+
maxTokens?: number;
|
|
249
|
+
/** Retry configuration for this call */
|
|
250
|
+
retry?: RetryConfig;
|
|
251
|
+
}
|
|
252
|
+
/** Configuration for automatic retries on transient errors */
|
|
253
|
+
interface RetryConfig {
|
|
254
|
+
/** Maximum number of retries (default: 0 — no retry) */
|
|
255
|
+
maxRetries?: number;
|
|
256
|
+
/** Initial delay in ms before first retry (default: 1000) */
|
|
257
|
+
initialDelayMs?: number;
|
|
258
|
+
/** Backoff multiplier (default: 2) */
|
|
259
|
+
backoffMultiplier?: number;
|
|
260
|
+
/** Which error codes to retry (default: all recoverable codes) */
|
|
261
|
+
retryableErrors?: ErrorCode[];
|
|
262
|
+
}
|
|
263
|
+
/** Configuration for typed structured output from LLM */
|
|
264
|
+
interface StructuredOutputConfig<T = unknown> {
|
|
265
|
+
schema: z.ZodType<T>;
|
|
266
|
+
name?: string;
|
|
267
|
+
description?: string;
|
|
268
|
+
}
|
|
269
|
+
/** Options passed to agent.run() / agent.stream().
|
|
270
|
+
* Extends CallOptions with run-specific fields (context, activityTimeoutMs).
|
|
271
|
+
* model is REQUIRED — every agent call must specify the model explicitly. */
|
|
272
|
+
interface RunOptions extends CallOptions {
|
|
273
|
+
/** Model to use for this call (required — no implicit defaults) */
|
|
274
|
+
model: string;
|
|
204
275
|
/** Arbitrary context passed to the agent run */
|
|
205
276
|
context?: Record<string, unknown>;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
maxTokens?: number;
|
|
211
|
-
topP?: number;
|
|
212
|
-
stopSequences?: string[];
|
|
277
|
+
/** Inactivity timeout for streaming (ms). When set, the stream aborts if no
|
|
278
|
+
* event (including heartbeats/progress) arrives within this period. Resets on
|
|
279
|
+
* every received event. Default: no timeout. Only affects stream()/streamWithContext(). */
|
|
280
|
+
activityTimeoutMs?: number;
|
|
213
281
|
}
|
|
214
282
|
/** Timeout configuration for agent operations */
|
|
215
283
|
interface TimeoutConfig {
|
|
@@ -234,12 +302,10 @@ interface ErrorHandlingConfig {
|
|
|
234
302
|
phase: "tool" | "llm" | "permission" | "ask-user";
|
|
235
303
|
}) => void;
|
|
236
304
|
}
|
|
237
|
-
/**
|
|
305
|
+
/** Identity-only agent configuration — defines the agent's behavior, NOT per-call defaults.
|
|
306
|
+
* For creating an agent with model/tools defaults, use FullAgentConfig. */
|
|
238
307
|
interface AgentConfig {
|
|
239
|
-
model?: string;
|
|
240
|
-
modelParams?: ModelParams;
|
|
241
308
|
systemPrompt: string;
|
|
242
|
-
tools: ToolDefinition[];
|
|
243
309
|
supervisor?: SupervisorHooks;
|
|
244
310
|
maxTurns?: number;
|
|
245
311
|
timeout?: TimeoutConfig;
|
|
@@ -249,8 +315,14 @@ interface AgentConfig {
|
|
|
249
315
|
/** How to apply systemPrompt: "append" adds to backend default, "replace" overrides it.
|
|
250
316
|
* Default: "append". Currently used by the Copilot backend. */
|
|
251
317
|
systemMessageMode?: "append" | "replace";
|
|
252
|
-
/**
|
|
253
|
-
*
|
|
318
|
+
/**
|
|
319
|
+
* Filter for backend built-in tools (e.g. `["web_search", "web_fetch"]` for Copilot).
|
|
320
|
+
* When set, only listed built-in tools are available. Backend-specific.
|
|
321
|
+
*
|
|
322
|
+
* **Security note**: This is a trust boundary — it controls which backend-native tools
|
|
323
|
+
* the AI agent can invoke. By default, backends expose ALL their built-in tools.
|
|
324
|
+
* Set this to restrict access (e.g. prevent file system access in a web-facing agent).
|
|
325
|
+
*/
|
|
254
326
|
availableTools?: string[];
|
|
255
327
|
/** Callback invoked with usage data after run completion or during streaming.
|
|
256
328
|
* Fire-and-forget: errors are logged but not propagated. */
|
|
@@ -264,11 +336,24 @@ interface AgentConfig {
|
|
|
264
336
|
* "persistent": reuses the same CLI session across calls, preserving conversation
|
|
265
337
|
* history natively in the CLI backend. Session is destroyed on agent dispose(). */
|
|
266
338
|
sessionMode?: "per-call" | "persistent";
|
|
339
|
+
}
|
|
340
|
+
/** Per-call defaults that can be provided at agent creation time.
|
|
341
|
+
* Each field can also be overridden on individual calls via RunOptions. */
|
|
342
|
+
interface CallDefaults {
|
|
343
|
+
/** Default model (overridable per-call via RunOptions.model) */
|
|
344
|
+
model?: string;
|
|
345
|
+
/** Default model parameters */
|
|
346
|
+
modelParams?: ModelParams;
|
|
347
|
+
/** Default tools (overridable per-call via RunOptions.tools) */
|
|
348
|
+
tools?: ToolDefinition[];
|
|
267
349
|
/** Provider-specific options passed through to the underlying SDK.
|
|
268
350
|
* For Vercel AI: passed as providerOptions to generateText/streamText.
|
|
269
351
|
* Example: { google: { thinkingConfig: { thinkingBudget: 1024 } } } */
|
|
270
352
|
providerOptions?: Record<string, Record<string, unknown>>;
|
|
271
353
|
}
|
|
354
|
+
/** Full agent configuration: identity + per-call defaults.
|
|
355
|
+
* This is what createAgent() accepts. Backward-compatible with the old AgentConfig shape. */
|
|
356
|
+
type FullAgentConfig = AgentConfig & CallDefaults;
|
|
272
357
|
/** Result of an agent run, generic over structured output type T */
|
|
273
358
|
interface AgentResult<T = void> {
|
|
274
359
|
output: string | null;
|
|
@@ -290,15 +375,15 @@ interface IAgent {
|
|
|
290
375
|
* or before the first call. Can be stored externally for session resume. */
|
|
291
376
|
readonly sessionId: string | undefined;
|
|
292
377
|
/** Run a single prompt and return the result. Wraps prompt in a user message. */
|
|
293
|
-
run(prompt: MessageContent, options
|
|
378
|
+
run(prompt: MessageContent, options: RunOptions): Promise<AgentResult>;
|
|
294
379
|
/** Run with full conversation history. Messages are passed directly to the backend. */
|
|
295
|
-
runWithContext(messages: Message[], options
|
|
380
|
+
runWithContext(messages: Message[], options: RunOptions): Promise<AgentResult>;
|
|
296
381
|
/** Run with structured output validated against a Zod schema. */
|
|
297
|
-
runStructured<T>(prompt: MessageContent, schema: StructuredOutputConfig<T>, options
|
|
382
|
+
runStructured<T>(prompt: MessageContent, schema: StructuredOutputConfig<T>, options: RunOptions): Promise<AgentResult<T>>;
|
|
298
383
|
/** Stream events for a single prompt. Wraps prompt in a user message. */
|
|
299
|
-
stream(prompt: MessageContent, options
|
|
384
|
+
stream(prompt: MessageContent, options: RunOptions): AsyncIterable<AgentEvent>;
|
|
300
385
|
/** Stream events with full conversation history. Messages are passed directly to the backend. */
|
|
301
|
-
streamWithContext(messages: Message[], options
|
|
386
|
+
streamWithContext(messages: Message[], options: RunOptions): AsyncIterable<AgentEvent>;
|
|
302
387
|
/** Abort the current operation. No-op if not running. */
|
|
303
388
|
abort(): void;
|
|
304
389
|
/** Gracefully interrupt the current operation. Resolves when the backend acknowledges. */
|
|
@@ -306,65 +391,17 @@ interface IAgent {
|
|
|
306
391
|
/** Get current agent lifecycle state. */
|
|
307
392
|
getState(): AgentState;
|
|
308
393
|
/** Get frozen agent configuration. */
|
|
309
|
-
getConfig(): Readonly<
|
|
394
|
+
getConfig(): Readonly<FullAgentConfig>;
|
|
310
395
|
/** Release resources. After dispose(), agent must not be used. */
|
|
311
396
|
dispose(): void;
|
|
312
397
|
}
|
|
313
|
-
/** Model metadata returned by listModels() */
|
|
314
|
-
interface ModelInfo {
|
|
315
|
-
id: string;
|
|
316
|
-
name?: string;
|
|
317
|
-
provider?: string;
|
|
318
|
-
}
|
|
319
|
-
/** Result of backend validation check */
|
|
320
|
-
interface ValidationResult {
|
|
321
|
-
valid: boolean;
|
|
322
|
-
errors: string[];
|
|
323
|
-
}
|
|
324
398
|
/** Backend service interface — creates agents, lists models, validates config */
|
|
325
399
|
interface IAgentService {
|
|
326
400
|
readonly name: string;
|
|
327
|
-
createAgent(config:
|
|
401
|
+
createAgent(config: FullAgentConfig): IAgent;
|
|
328
402
|
listModels(): Promise<ModelInfo[]>;
|
|
329
403
|
validate(): Promise<ValidationResult>;
|
|
330
404
|
dispose(): Promise<void>;
|
|
331
405
|
}
|
|
332
|
-
/** Options for Copilot CLI backend */
|
|
333
|
-
interface CopilotBackendOptions {
|
|
334
|
-
cliPath?: string;
|
|
335
|
-
workingDirectory?: string;
|
|
336
|
-
githubToken?: string;
|
|
337
|
-
useLoggedInUser?: boolean;
|
|
338
|
-
/** Extra CLI arguments passed to the Copilot subprocess (e.g. ["--allow-all"]) */
|
|
339
|
-
cliArgs?: string[];
|
|
340
|
-
/** Timeout in milliseconds for sendAndWait() calls. When undefined, uses copilot-sdk default (60s). */
|
|
341
|
-
timeout?: number;
|
|
342
|
-
/** Timeout in milliseconds for CLI startup and auth check (default: 30000). */
|
|
343
|
-
startupTimeoutMs?: number;
|
|
344
|
-
/** Custom environment variables merged into the subprocess env */
|
|
345
|
-
env?: Record<string, string | undefined>;
|
|
346
|
-
/** Session ID to resume after server restart. On startup, the backend attempts
|
|
347
|
-
* to resume this session before creating a new one. */
|
|
348
|
-
resumeSessionId?: string;
|
|
349
|
-
}
|
|
350
|
-
/** Options for Claude CLI backend */
|
|
351
|
-
interface ClaudeBackendOptions {
|
|
352
|
-
cliPath?: string;
|
|
353
|
-
workingDirectory?: string;
|
|
354
|
-
maxTurns?: number;
|
|
355
|
-
/** OAuth token for Claude authentication (set as CLAUDE_CODE_OAUTH_TOKEN env var) */
|
|
356
|
-
oauthToken?: string;
|
|
357
|
-
/** Custom environment variables merged into the subprocess env */
|
|
358
|
-
env?: Record<string, string | undefined>;
|
|
359
|
-
/** Session ID to resume after server restart. On startup, the backend attempts
|
|
360
|
-
* to resume this session before creating a new one. */
|
|
361
|
-
resumeSessionId?: string;
|
|
362
|
-
}
|
|
363
|
-
/** Options for Vercel AI SDK backend */
|
|
364
|
-
interface VercelAIBackendOptions {
|
|
365
|
-
apiKey: string;
|
|
366
|
-
provider?: string;
|
|
367
|
-
baseUrl?: string;
|
|
368
|
-
}
|
|
369
406
|
|
|
370
|
-
export type { AgentEvent as A,
|
|
407
|
+
export type { AgentEvent as A, FullAgentConfig as F, IAgentService as I, ModelInfo as M, RunOptions as R, ToolDefinition as T, UsageData as U, ValidationResult as V, MessageContent as a, AgentResult as b, IAgent as c, Message as d, ToolResult as e };
|