@nuvin/agent-core 0.0.0-rc.3 → 0.0.0-rc.4
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/VERSION +2 -2
- package/dist/agent/index.d.ts +27 -525
- package/dist/agent/index.js +1 -1
- package/dist/chunk-G2FR4UGO.js +1 -1
- package/dist/chunk-LXQDGX4K.js +1 -1
- package/dist/chunk-NYZR4XKO.js +1 -1
- package/dist/chunk-VFTQW5WK.js +1 -1
- package/dist/chunk-X7VAACWY.js +1 -1
- package/dist/formats/index.d.ts +23 -319
- package/dist/formats/index.js +1 -1
- package/dist/models/index.d.ts +330 -634
- package/dist/models/index.js +1 -1
- package/dist/shared/index.d.ts +14 -709
- package/dist/shared/index.js +1 -1
- package/dist/tools/index.d.ts +518 -969
- package/dist/tools/index.js +1 -1
- package/package.json +4 -1
package/dist/models/index.d.ts
CHANGED
|
@@ -1,646 +1,342 @@
|
|
|
1
|
-
|
|
1
|
+
import { P as ProviderSessionResolver, p as ResolvedProviderSession, q as ProviderRequestMutator, i as ModelRequest, r as PreparedRequest, j as ChatRequest, s as ProviderCredential, t as EngineChatModel, u as ReasoningConfig, v as ChatResponseChunk, l as ChatResponse, w as ModelExecutionOptions, B as BaseChatModelOptions, x as ModelInfo } from '../types-QPBW5jHO.js';
|
|
2
|
+
export { y as ProviderCredentialKind, z as ProviderEndpoints } from '../types-QPBW5jHO.js';
|
|
3
|
+
import { t as toOpenAiResponsesRequest } from '../provider-adapters-Cb5hUJoD.js';
|
|
2
4
|
|
|
3
|
-
|
|
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
|
-
type: "image";
|
|
34
|
-
source: {
|
|
35
|
-
type: "base64";
|
|
36
|
-
media_type: ImageMediaType;
|
|
37
|
-
data: string;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export type ToolResultContentBlock = ImageBlock | TextBlock;
|
|
41
|
-
export type ToolResultContent = string | ToolResultContentBlock[];
|
|
42
|
-
export interface AnthropicThinkingBlock {
|
|
43
|
-
type: "anthropic_thinking";
|
|
44
|
-
thinking: string;
|
|
45
|
-
signature: string;
|
|
46
|
-
}
|
|
47
|
-
export interface AnthropicRedactedThinkingBlock {
|
|
48
|
-
type: "anthropic_redacted_thinking";
|
|
49
|
-
data: string;
|
|
50
|
-
}
|
|
51
|
-
export interface OpenAiReasoningSummaryText {
|
|
52
|
-
type: "summary_text";
|
|
53
|
-
text: string;
|
|
54
|
-
}
|
|
55
|
-
export interface OpenAiReasoningBlock {
|
|
56
|
-
type: "openai_reasoning";
|
|
57
|
-
encryptedContent?: string;
|
|
58
|
-
id?: string;
|
|
59
|
-
summary: OpenAiReasoningSummaryText[];
|
|
60
|
-
text?: string;
|
|
61
|
-
}
|
|
62
|
-
export interface ToolUseBlock {
|
|
63
|
-
type: "tool_use";
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
input: JsonValue;
|
|
67
|
-
}
|
|
68
|
-
export interface ToolResultBlock {
|
|
69
|
-
type: "tool_result";
|
|
70
|
-
tool_use_id: string;
|
|
71
|
-
content: ToolResultContent;
|
|
72
|
-
is_error: boolean;
|
|
73
|
-
}
|
|
74
|
-
export interface AnthropicThinkingWireBlock {
|
|
75
|
-
type: "thinking";
|
|
76
|
-
thinking: string;
|
|
77
|
-
signature: string;
|
|
78
|
-
}
|
|
79
|
-
export interface AnthropicRedactedThinkingWireBlock {
|
|
80
|
-
type: "redacted_thinking";
|
|
81
|
-
data: string;
|
|
82
|
-
}
|
|
83
|
-
export type AnthropicAssistantContentBlock = AnthropicRedactedThinkingWireBlock | AnthropicThinkingWireBlock | TextBlock | ToolUseBlock;
|
|
84
|
-
export type ReasoningVisibility = "continuity-only" | "user-visible";
|
|
85
|
-
export type AutoReasoningEffort = "low" | "medium" | "high";
|
|
86
|
-
export interface AutoReasoningConfig {
|
|
87
|
-
effort: AutoReasoningEffort;
|
|
88
|
-
}
|
|
89
|
-
export type AnthropicThinkingDisplay = "omitted" | "summarized";
|
|
90
|
-
export type AnthropicThinkingEffort = "low" | "medium" | "high";
|
|
91
|
-
export interface AnthropicEnabledThinkingConfig {
|
|
92
|
-
type: "enabled";
|
|
93
|
-
budgetTokens: number;
|
|
94
|
-
display?: AnthropicThinkingDisplay;
|
|
95
|
-
interleaved?: boolean;
|
|
96
|
-
}
|
|
97
|
-
export interface AnthropicAdaptiveThinkingConfig {
|
|
98
|
-
type: "adaptive";
|
|
99
|
-
display?: AnthropicThinkingDisplay;
|
|
100
|
-
effort?: AnthropicThinkingEffort;
|
|
101
|
-
interleaved?: boolean;
|
|
102
|
-
}
|
|
103
|
-
export interface AnthropicDisabledThinkingConfig {
|
|
104
|
-
type: "disabled";
|
|
105
|
-
}
|
|
106
|
-
export type AnthropicThinkingConfig = AnthropicAdaptiveThinkingConfig | AnthropicDisabledThinkingConfig | AnthropicEnabledThinkingConfig;
|
|
107
|
-
export type OpenAiReasoningEffort = "high" | "low" | "medium" | "minimal" | "none" | "xhigh";
|
|
108
|
-
export type OpenAiReasoningSummary = "auto" | "concise" | "detailed";
|
|
109
|
-
export interface OpenAiReasoningConfig {
|
|
110
|
-
effort?: OpenAiReasoningEffort;
|
|
111
|
-
includeEncryptedContent?: boolean;
|
|
112
|
-
summary?: OpenAiReasoningSummary;
|
|
113
|
-
}
|
|
114
|
-
export interface ReasoningConfig {
|
|
115
|
-
auto?: AutoReasoningConfig;
|
|
116
|
-
anthropic?: AnthropicThinkingConfig;
|
|
117
|
-
openai?: OpenAiReasoningConfig;
|
|
118
|
-
visibility?: ReasoningVisibility;
|
|
119
|
-
}
|
|
120
|
-
export interface MessageProviderState {
|
|
121
|
-
anthropicAssistantContent?: AnthropicAssistantContentBlock[];
|
|
122
|
-
openaiResponsesOutput?: OpenAiResponsesOutputItem[];
|
|
123
|
-
openaiResponsesResponseId?: string;
|
|
124
|
-
}
|
|
125
|
-
export type AssistantContentBlock = AnthropicRedactedThinkingBlock | AnthropicThinkingBlock | OpenAiReasoningBlock | TextBlock | ToolUseBlock;
|
|
126
|
-
export type ContentBlock = AssistantContentBlock | ToolResultBlock;
|
|
127
|
-
export type MessageRole = "assistant" | "user";
|
|
128
|
-
export interface Message {
|
|
129
|
-
id?: string;
|
|
130
|
-
role: MessageRole;
|
|
131
|
-
content: ContentBlock[];
|
|
132
|
-
providerState?: MessageProviderState;
|
|
133
|
-
}
|
|
134
|
-
export interface ToolSchema {
|
|
135
|
-
name: string;
|
|
136
|
-
description: string;
|
|
137
|
-
input_schema: JsonSchemaObject;
|
|
138
|
-
}
|
|
139
|
-
export interface ModelRequest {
|
|
140
|
-
model: string;
|
|
141
|
-
max_tokens: number;
|
|
142
|
-
reasoning?: ReasoningConfig;
|
|
143
|
-
system: TextBlock[];
|
|
144
|
-
messages: Message[];
|
|
145
|
-
tools: ToolSchema[];
|
|
146
|
-
metadata: {
|
|
147
|
-
session_id: string;
|
|
148
|
-
turn_id: string;
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
export interface ChatRequest {
|
|
152
|
-
model: string;
|
|
153
|
-
maxTokens: number;
|
|
154
|
-
reasoning?: ReasoningConfig;
|
|
155
|
-
system: TextBlock[];
|
|
156
|
-
messages: Message[];
|
|
157
|
-
tools: ToolSchema[];
|
|
158
|
-
metadata: {
|
|
159
|
-
sessionId: string;
|
|
160
|
-
turnId: string;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
export interface ChatResponse {
|
|
164
|
-
id: string;
|
|
165
|
-
content: AssistantContentBlock[];
|
|
166
|
-
stopReason: "end_turn" | "tool_use";
|
|
167
|
-
usage: {
|
|
168
|
-
inputTokens: number;
|
|
169
|
-
outputTokens: number;
|
|
170
|
-
reasoningTokens?: number;
|
|
171
|
-
};
|
|
172
|
-
providerState?: MessageProviderState;
|
|
173
|
-
}
|
|
174
|
-
export interface ChatResponseChunk {
|
|
175
|
-
type: "anthropic_signature_delta" | "anthropic_thinking_delta" | "content_delta" | "done" | "openai_reasoning_delta" | "openai_reasoning_summary_delta" | "tool_use_delta";
|
|
176
|
-
contentIndex?: number;
|
|
177
|
-
delta?: string;
|
|
178
|
-
index?: number;
|
|
179
|
-
itemId?: string;
|
|
180
|
-
outputIndex?: number;
|
|
181
|
-
signature?: string;
|
|
182
|
-
summaryIndex?: number;
|
|
183
|
-
text?: string;
|
|
184
|
-
thinking?: string;
|
|
185
|
-
inputDelta?: string;
|
|
186
|
-
name?: string;
|
|
187
|
-
id?: string;
|
|
188
|
-
response?: ChatResponse;
|
|
189
|
-
}
|
|
190
|
-
export interface ModelLimits {
|
|
191
|
-
contextWindow?: number;
|
|
192
|
-
maxOutput?: number;
|
|
193
|
-
}
|
|
194
|
-
export interface ModelInfo {
|
|
195
|
-
id: string;
|
|
196
|
-
name: string;
|
|
197
|
-
limits?: ModelLimits;
|
|
198
|
-
supportedEndpoints?: string[];
|
|
199
|
-
}
|
|
200
|
-
export type ProviderCredentialKind = "api-key" | "oauth-token" | "session-token";
|
|
201
|
-
export interface ProviderCredential {
|
|
202
|
-
kind: ProviderCredentialKind;
|
|
203
|
-
value: string;
|
|
204
|
-
}
|
|
205
|
-
export interface ProviderEndpoints {
|
|
206
|
-
api?: string;
|
|
207
|
-
originTracker?: string;
|
|
208
|
-
proxy?: string;
|
|
209
|
-
telemetry?: string;
|
|
210
|
-
}
|
|
211
|
-
export interface ResolvedProviderSession {
|
|
212
|
-
credential: ProviderCredential;
|
|
213
|
-
endpoints?: ProviderEndpoints;
|
|
214
|
-
metadata?: Record<string, string>;
|
|
215
|
-
}
|
|
216
|
-
export interface ProviderSessionResolver {
|
|
217
|
-
resolve(signal?: AbortSignal): Promise<ResolvedProviderSession>;
|
|
218
|
-
}
|
|
219
|
-
export interface PreparedRequest {
|
|
220
|
-
request: ModelRequest;
|
|
221
|
-
session?: ResolvedProviderSession;
|
|
222
|
-
}
|
|
223
|
-
export type ProviderRequestMutator = (preparedRequest: PreparedRequest) => PreparedRequest | Promise<PreparedRequest>;
|
|
224
|
-
export interface ModelExecutionOptions {
|
|
225
|
-
signal?: AbortSignal;
|
|
226
|
-
}
|
|
227
|
-
export interface EngineChatModel {
|
|
228
|
-
model: string;
|
|
229
|
-
maxTokens?: number;
|
|
230
|
-
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
231
|
-
stream?(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
232
|
-
getModels?(signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
233
|
-
}
|
|
234
|
-
export interface BaseChatModelOptions {
|
|
235
|
-
model: string;
|
|
236
|
-
maxTokens?: number;
|
|
237
|
-
reasoning?: ReasoningConfig;
|
|
238
|
-
providerSessionResolver?: ProviderSessionResolver;
|
|
239
|
-
requestMutators?: ProviderRequestMutator[];
|
|
240
|
-
}
|
|
241
|
-
export interface OpenAiInputText {
|
|
242
|
-
type: "input_text";
|
|
243
|
-
text: string;
|
|
244
|
-
}
|
|
245
|
-
export interface OpenAiInputImage {
|
|
246
|
-
type: "input_image";
|
|
247
|
-
image_url: string;
|
|
248
|
-
detail?: string;
|
|
249
|
-
}
|
|
250
|
-
export interface OpenAiInputMessage {
|
|
251
|
-
type: "message";
|
|
252
|
-
role: MessageRole;
|
|
253
|
-
content: Array<OpenAiInputImage | OpenAiInputText>;
|
|
254
|
-
}
|
|
255
|
-
export interface OpenAiFunctionCall {
|
|
256
|
-
type: "function_call";
|
|
257
|
-
call_id: string;
|
|
258
|
-
name: string;
|
|
259
|
-
arguments: string;
|
|
260
|
-
}
|
|
261
|
-
export interface OpenAiFunctionCallOutput {
|
|
262
|
-
type: "function_call_output";
|
|
263
|
-
call_id: string;
|
|
264
|
-
output: string;
|
|
265
|
-
}
|
|
266
|
-
export interface OpenAiOutputTextPart {
|
|
267
|
-
type: "output_text";
|
|
268
|
-
text: string;
|
|
269
|
-
}
|
|
270
|
-
export interface OpenAiRefusalPart {
|
|
271
|
-
type: "refusal";
|
|
272
|
-
refusal: string;
|
|
273
|
-
}
|
|
274
|
-
export interface OpenAiOutputMessage {
|
|
275
|
-
type: "message";
|
|
276
|
-
content?: Array<OpenAiOutputTextPart | OpenAiRefusalPart>;
|
|
277
|
-
role?: string;
|
|
278
|
-
status?: string;
|
|
279
|
-
}
|
|
280
|
-
export interface OpenAiReasoningOutputItem {
|
|
281
|
-
type: "reasoning";
|
|
282
|
-
content?: Array<{
|
|
283
|
-
text?: string;
|
|
284
|
-
type?: string;
|
|
285
|
-
}>;
|
|
286
|
-
encrypted_content?: string;
|
|
287
|
-
id?: string;
|
|
288
|
-
status?: string;
|
|
289
|
-
summary?: OpenAiReasoningSummaryText[];
|
|
290
|
-
text?: string;
|
|
291
|
-
}
|
|
292
|
-
export type OpenAiResponsesOutputItem = JsonObject | OpenAiFunctionCall | OpenAiOutputMessage | OpenAiReasoningOutputItem;
|
|
293
|
-
export interface OpenAiResponsesReasoningParam {
|
|
294
|
-
effort?: OpenAiReasoningEffort;
|
|
295
|
-
generate_summary?: OpenAiReasoningSummary;
|
|
296
|
-
summary?: OpenAiReasoningSummary;
|
|
297
|
-
}
|
|
298
|
-
export interface OpenAiFunctionTool {
|
|
299
|
-
type: "function";
|
|
300
|
-
name: string;
|
|
301
|
-
description: string;
|
|
302
|
-
parameters: JsonSchemaObject;
|
|
303
|
-
}
|
|
304
|
-
export interface OpenAiResponsesRequest {
|
|
305
|
-
include?: string[];
|
|
306
|
-
model: string;
|
|
307
|
-
instructions: string;
|
|
308
|
-
input: Array<OpenAiFunctionCall | OpenAiFunctionCallOutput | OpenAiInputMessage | OpenAiResponsesOutputItem>;
|
|
309
|
-
max_output_tokens?: number;
|
|
310
|
-
reasoning?: OpenAiResponsesReasoningParam;
|
|
311
|
-
tools: OpenAiFunctionTool[];
|
|
312
|
-
}
|
|
313
|
-
export interface PrepareProviderRequestOptions {
|
|
314
|
-
sessionManager?: ProviderSessionManager;
|
|
315
|
-
requestMutators?: ProviderRequestMutator[];
|
|
316
|
-
signal?: AbortSignal;
|
|
317
|
-
}
|
|
318
|
-
export declare class ProviderSessionManager {
|
|
319
|
-
private readonly resolver;
|
|
320
|
-
private cached?;
|
|
321
|
-
constructor(resolver: ProviderSessionResolver);
|
|
322
|
-
resolve(signal?: AbortSignal): Promise<ResolvedProviderSession>;
|
|
323
|
-
invalidate(): void;
|
|
324
|
-
}
|
|
325
|
-
export declare function prepareProviderRequest(request: ModelRequest, options?: PrepareProviderRequestOptions): Promise<PreparedRequest>;
|
|
326
|
-
export type RoutedModelMode = "complete" | "stream";
|
|
327
|
-
export interface ModelSurfaceRouter {
|
|
328
|
-
selectSurface(request: ChatRequest, options: {
|
|
329
|
-
mode: RoutedModelMode;
|
|
330
|
-
}): Promise<string> | string;
|
|
331
|
-
}
|
|
332
|
-
export declare class StaticModelSurfaceRouter implements ModelSurfaceRouter {
|
|
333
|
-
private readonly completeSurface;
|
|
334
|
-
private readonly streamSurface;
|
|
335
|
-
constructor(options: {
|
|
336
|
-
complete: string;
|
|
337
|
-
stream: string;
|
|
338
|
-
});
|
|
339
|
-
selectSurface(_request: ChatRequest, options: {
|
|
340
|
-
mode: RoutedModelMode;
|
|
341
|
-
}): string;
|
|
342
|
-
}
|
|
343
|
-
export interface ModelWebSocket {
|
|
344
|
-
readonly readyState: number;
|
|
345
|
-
addEventListener(type: "close" | "error" | "message" | "open", listener: EventListenerOrEventListenerObject): void;
|
|
346
|
-
close(code?: number, reason?: string): void;
|
|
347
|
-
removeEventListener(type: "close" | "error" | "message" | "open", listener: EventListenerOrEventListenerObject): void;
|
|
348
|
-
send(data: string): void;
|
|
5
|
+
interface PrepareProviderRequestOptions {
|
|
6
|
+
sessionManager?: ProviderSessionManager;
|
|
7
|
+
requestMutators?: ProviderRequestMutator[];
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
declare class ProviderSessionManager {
|
|
11
|
+
private readonly resolver;
|
|
12
|
+
private cached?;
|
|
13
|
+
constructor(resolver: ProviderSessionResolver);
|
|
14
|
+
resolve(signal?: AbortSignal): Promise<ResolvedProviderSession>;
|
|
15
|
+
invalidate(): void;
|
|
16
|
+
}
|
|
17
|
+
declare function prepareProviderRequest(request: ModelRequest, options?: PrepareProviderRequestOptions): Promise<PreparedRequest>;
|
|
18
|
+
|
|
19
|
+
type RoutedModelMode = "complete" | "stream";
|
|
20
|
+
interface ModelSurfaceRouter {
|
|
21
|
+
selectSurface(request: ChatRequest, options: {
|
|
22
|
+
mode: RoutedModelMode;
|
|
23
|
+
}): Promise<string> | string;
|
|
24
|
+
}
|
|
25
|
+
declare class StaticModelSurfaceRouter implements ModelSurfaceRouter {
|
|
26
|
+
private readonly completeSurface;
|
|
27
|
+
private readonly streamSurface;
|
|
28
|
+
constructor(options: {
|
|
29
|
+
complete: string;
|
|
30
|
+
stream: string;
|
|
31
|
+
});
|
|
32
|
+
selectSurface(_request: ChatRequest, options: {
|
|
33
|
+
mode: RoutedModelMode;
|
|
34
|
+
}): string;
|
|
349
35
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
36
|
+
|
|
37
|
+
interface ModelWebSocket {
|
|
38
|
+
readonly readyState: number;
|
|
39
|
+
addEventListener(type: "close" | "error" | "message" | "open", listener: EventListenerOrEventListenerObject): void;
|
|
40
|
+
close(code?: number, reason?: string): void;
|
|
41
|
+
removeEventListener(type: "close" | "error" | "message" | "open", listener: EventListenerOrEventListenerObject): void;
|
|
42
|
+
send(data: string): void;
|
|
43
|
+
}
|
|
44
|
+
type WebSocketFactory = (options: {
|
|
45
|
+
headers: Record<string, string>;
|
|
46
|
+
url: string;
|
|
353
47
|
}) => ModelWebSocket;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
requestMutators?: ProviderRequestMutator[];
|
|
465
|
-
headerResolver?: AnthropicHeaderResolver;
|
|
466
|
-
}
|
|
467
|
-
export interface AnthropicRequestHeadersContext {
|
|
468
|
-
request?: ChatRequest;
|
|
469
|
-
body: unknown;
|
|
470
|
-
credential: ProviderCredential;
|
|
471
|
-
session?: ResolvedProviderSession;
|
|
472
|
-
stream: boolean;
|
|
473
|
-
}
|
|
474
|
-
export type AnthropicHeaderResolver = (context: AnthropicRequestHeadersContext) => Promise<Record<string, string>> | Record<string, string>;
|
|
475
|
-
export declare class AnthropicModel extends RoutedModel {
|
|
476
|
-
constructor(options?: AnthropicModelOptions);
|
|
477
|
-
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
478
|
-
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
479
|
-
}
|
|
480
|
-
export declare const ANTHROPIC_MESSAGES_SURFACE = "anthropic-messages";
|
|
481
|
-
export declare const ANTHROPIC_MESSAGES_STREAM_SURFACE = "anthropic-messages-stream";
|
|
482
|
-
export declare function createAnthropicSurfaces(): RoutedModelSurface[];
|
|
483
|
-
declare function toOpenAiResponsesRequest(request: ChatRequest): OpenAiResponsesRequest;
|
|
484
|
-
export declare const OPENAI_CHAT_COMPLETIONS_SURFACE = "openai-chat-completions";
|
|
485
|
-
export declare const OPENAI_CHAT_COMPLETIONS_STREAM_SURFACE = "openai-chat-completions-stream";
|
|
486
|
-
export declare const OPENAI_RESPONSES_SURFACE = "openai-responses";
|
|
487
|
-
export declare const OPENAI_RESPONSES_STREAM_SURFACE = "openai-responses-stream";
|
|
488
|
-
export declare const OPENAI_RESPONSES_WEBSOCKET_SURFACE = "openai-responses-ws";
|
|
489
|
-
export declare class OpenAiApiError extends Error {
|
|
490
|
-
readonly status: number;
|
|
491
|
-
readonly body: string;
|
|
492
|
-
constructor(status: number, body: string, message: string);
|
|
48
|
+
declare function createDefaultWebSocketFactory(): WebSocketFactory;
|
|
49
|
+
declare function iterateSseEvents(response: Response, signal?: AbortSignal): AsyncGenerator<string>;
|
|
50
|
+
declare function waitForWebSocketOpen(socket: ModelWebSocket, signal?: AbortSignal): Promise<void>;
|
|
51
|
+
declare function iterateWebSocketMessages(socket: ModelWebSocket, signal?: AbortSignal): AsyncIterable<Record<string, unknown>>;
|
|
52
|
+
declare function toWebSocketUrl(baseUrl: string, path: string): string;
|
|
53
|
+
|
|
54
|
+
interface ProviderHeaderContext {
|
|
55
|
+
request?: ChatRequest;
|
|
56
|
+
body?: unknown;
|
|
57
|
+
credential: ProviderCredential;
|
|
58
|
+
session?: ResolvedProviderSession;
|
|
59
|
+
stream: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface ProviderAdapter {
|
|
62
|
+
createHeaders(context: ProviderHeaderContext, options: {
|
|
63
|
+
accept: string;
|
|
64
|
+
includeContentType?: boolean;
|
|
65
|
+
}): Headers | Promise<Headers>;
|
|
66
|
+
createMissingCredentialError(): Error;
|
|
67
|
+
mapApiError(error: Error): Error;
|
|
68
|
+
resolveBaseUrl(defaultBaseUrl: string, session: ResolvedProviderSession | undefined): string;
|
|
69
|
+
resolveCredential(apiKey: string | undefined, session: ResolvedProviderSession | undefined): ProviderCredential | undefined;
|
|
70
|
+
toApiError(response: Response): Promise<Error>;
|
|
71
|
+
}
|
|
72
|
+
declare function trimTrailingSlashes(value: string): string;
|
|
73
|
+
declare function resolveApiCredential(apiKey: string | undefined, session: ResolvedProviderSession | undefined): ProviderCredential | undefined;
|
|
74
|
+
declare function resolveSessionBaseUrl(defaultBaseUrl: string, session: ResolvedProviderSession | undefined): string;
|
|
75
|
+
|
|
76
|
+
interface RoutedModelStreamParser {
|
|
77
|
+
consumeSseEvent?(rawEvent: string): ChatResponseChunk[];
|
|
78
|
+
consumeWebSocketEvent?(event: Record<string, unknown>): ChatResponseChunk[];
|
|
79
|
+
finish(): ChatResponse;
|
|
80
|
+
isDone?(): boolean;
|
|
81
|
+
}
|
|
82
|
+
interface RoutedModelSurfaceRequest {
|
|
83
|
+
accept?: string;
|
|
84
|
+
body?: unknown;
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
initialEvent?: unknown;
|
|
87
|
+
path?: string;
|
|
88
|
+
url?: string;
|
|
89
|
+
}
|
|
90
|
+
interface RoutedModelSurface {
|
|
91
|
+
id: string;
|
|
92
|
+
transport: "http-json" | "http-sse" | "websocket";
|
|
93
|
+
createRequest(request: ChatRequest): RoutedModelSurfaceRequest;
|
|
94
|
+
createStreamParser?(request: ChatRequest): RoutedModelStreamParser;
|
|
95
|
+
parseResponse?(payload: unknown, request: ChatRequest): ChatResponse;
|
|
96
|
+
}
|
|
97
|
+
interface RoutedModelOptions {
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
baseUrl: string;
|
|
100
|
+
fetch?: typeof globalThis.fetch;
|
|
101
|
+
model: string;
|
|
102
|
+
maxTokens?: number;
|
|
103
|
+
reasoning?: ReasoningConfig;
|
|
104
|
+
providerAdapter: ProviderAdapter;
|
|
105
|
+
providerSessionResolver?: ProviderSessionResolver;
|
|
106
|
+
requestMutators?: ProviderRequestMutator[];
|
|
107
|
+
router: ModelSurfaceRouter;
|
|
108
|
+
sessionManager?: ProviderSessionManager;
|
|
109
|
+
surfaces: RoutedModelSurface[];
|
|
110
|
+
webSocketFactory?: WebSocketFactory;
|
|
111
|
+
}
|
|
112
|
+
declare class RoutedModel implements EngineChatModel {
|
|
113
|
+
readonly model: string;
|
|
114
|
+
readonly maxTokens: number;
|
|
115
|
+
protected readonly reasoning?: ReasoningConfig;
|
|
116
|
+
protected readonly apiKey?: string;
|
|
117
|
+
protected readonly baseUrl: string;
|
|
118
|
+
protected readonly fetchImpl: typeof globalThis.fetch;
|
|
119
|
+
protected readonly providerAdapter: ProviderAdapter;
|
|
120
|
+
protected readonly requestMutators: ProviderRequestMutator[];
|
|
121
|
+
protected readonly router: ModelSurfaceRouter;
|
|
122
|
+
protected readonly sessionManager?: ProviderSessionManager;
|
|
123
|
+
protected readonly webSocketFactory: WebSocketFactory;
|
|
124
|
+
private readonly surfaces;
|
|
125
|
+
constructor(options: RoutedModelOptions);
|
|
126
|
+
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
127
|
+
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
128
|
+
protected completeViaRouter(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
129
|
+
protected streamViaRouter(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
130
|
+
protected completeViaSurface(request: ChatRequest, surfaceId: string, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
131
|
+
protected streamViaSurface(request: ChatRequest, surfaceId: string, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
132
|
+
protected sendRawRequest(options: {
|
|
133
|
+
accept?: string;
|
|
134
|
+
body?: unknown;
|
|
135
|
+
method: "GET" | "POST";
|
|
136
|
+
path: string;
|
|
137
|
+
signal?: AbortSignal;
|
|
138
|
+
}): Promise<Response>;
|
|
139
|
+
protected getRetryDelayMs(response: Response | undefined, attemptIndex: number): number;
|
|
140
|
+
private shouldRetryResponse;
|
|
141
|
+
private shouldRetryRequestError;
|
|
142
|
+
private shouldRetryStreamAttemptError;
|
|
143
|
+
private waitForRetry;
|
|
144
|
+
private sendWithRetries;
|
|
145
|
+
protected createMissingCredentialError(): Error;
|
|
146
|
+
protected createHeaders(context: ProviderHeaderContext, options: {
|
|
147
|
+
accept: string;
|
|
148
|
+
includeContentType?: boolean;
|
|
149
|
+
}): Promise<Headers>;
|
|
150
|
+
protected mapApiError(error: Error): Error;
|
|
151
|
+
protected toApiError(response: Response): Promise<Error>;
|
|
152
|
+
private getSurface;
|
|
153
|
+
private prepareChatRequest;
|
|
154
|
+
protected applyModelDefaults(request: ChatRequest): ChatRequest;
|
|
155
|
+
private sendHttpSurfaceRequest;
|
|
156
|
+
private streamHttpSurface;
|
|
157
|
+
private streamWebSocketSurface;
|
|
493
158
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
159
|
+
|
|
160
|
+
interface AnthropicModelOptions extends Partial<BaseChatModelOptions> {
|
|
161
|
+
apiKey?: string;
|
|
162
|
+
baseUrl?: string;
|
|
163
|
+
protocolVersion?: string;
|
|
164
|
+
authScheme?: "bearer" | "x-api-key";
|
|
165
|
+
fetch?: typeof globalThis.fetch;
|
|
166
|
+
providerSessionResolver?: ProviderSessionResolver;
|
|
167
|
+
requestMutators?: ProviderRequestMutator[];
|
|
168
|
+
headerResolver?: AnthropicHeaderResolver;
|
|
169
|
+
}
|
|
170
|
+
interface AnthropicRequestHeadersContext {
|
|
171
|
+
request?: ChatRequest;
|
|
172
|
+
body: unknown;
|
|
173
|
+
credential: ProviderCredential;
|
|
174
|
+
session?: ResolvedProviderSession;
|
|
175
|
+
stream: boolean;
|
|
176
|
+
}
|
|
177
|
+
type AnthropicHeaderResolver = (context: AnthropicRequestHeadersContext) => Promise<Record<string, string>> | Record<string, string>;
|
|
178
|
+
declare class AnthropicModel extends RoutedModel {
|
|
179
|
+
constructor(options?: AnthropicModelOptions);
|
|
180
|
+
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
181
|
+
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
501
182
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
183
|
+
|
|
184
|
+
declare const ANTHROPIC_MESSAGES_SURFACE = "anthropic-messages";
|
|
185
|
+
declare const ANTHROPIC_MESSAGES_STREAM_SURFACE = "anthropic-messages-stream";
|
|
186
|
+
declare function createAnthropicSurfaces(): RoutedModelSurface[];
|
|
187
|
+
|
|
188
|
+
declare const OPENAI_CHAT_COMPLETIONS_SURFACE = "openai-chat-completions";
|
|
189
|
+
declare const OPENAI_CHAT_COMPLETIONS_STREAM_SURFACE = "openai-chat-completions-stream";
|
|
190
|
+
declare const OPENAI_RESPONSES_SURFACE = "openai-responses";
|
|
191
|
+
declare const OPENAI_RESPONSES_STREAM_SURFACE = "openai-responses-stream";
|
|
192
|
+
declare const OPENAI_RESPONSES_WEBSOCKET_SURFACE = "openai-responses-ws";
|
|
193
|
+
declare class OpenAiApiError extends Error {
|
|
194
|
+
readonly status: number;
|
|
195
|
+
readonly body: string;
|
|
196
|
+
constructor(status: number, body: string, message: string);
|
|
197
|
+
}
|
|
198
|
+
declare function createOpenAiResponsesWebSocketEvent(request: ChatRequest, options?: {
|
|
199
|
+
input?: ReturnType<typeof toOpenAiResponsesRequest>["input"];
|
|
200
|
+
previousResponseId?: string;
|
|
505
201
|
}): Record<string, unknown>;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
202
|
+
declare function createOpenAiApiError(response: Response): Promise<OpenAiApiError>;
|
|
203
|
+
declare function createOpenAiResponsesStreamParser(request: ChatRequest): RoutedModelStreamParser;
|
|
204
|
+
declare function createOpenAiSurfaces(options?: {
|
|
205
|
+
chatCompletionsPath?: string;
|
|
206
|
+
responsesPath?: string;
|
|
511
207
|
}): RoutedModelSurface[];
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
export declare const AVAILABLE_CHAT_MODEL_SURFACES: readonly [
|
|
564
|
-
"anthropic-messages",
|
|
565
|
-
"openai-chat-completions",
|
|
566
|
-
"openai-responses",
|
|
567
|
-
"openai-responses-ws"
|
|
568
|
-
];
|
|
569
|
-
export type ChatModelSurface = (typeof AVAILABLE_CHAT_MODEL_SURFACES)[number];
|
|
570
|
-
export type ChatModelAuthScheme = NonNullable<AnthropicModelOptions["authScheme"]>;
|
|
571
|
-
export interface ChatModelOptions extends Partial<BaseChatModelOptions> {
|
|
572
|
-
apiKey?: string;
|
|
573
|
-
baseUrl?: string;
|
|
574
|
-
surface?: ChatModelSurface;
|
|
575
|
-
authScheme?: ChatModelAuthScheme;
|
|
576
|
-
fetch?: typeof globalThis.fetch;
|
|
577
|
-
providerSessionResolver?: ProviderSessionResolver;
|
|
578
|
-
requestMutators?: ProviderRequestMutator[];
|
|
579
|
-
headerResolver?: OpenAiHeaderResolver;
|
|
580
|
-
webSocketFactory?: WebSocketFactory;
|
|
581
|
-
}
|
|
582
|
-
export declare class ChatModel implements EngineChatModel {
|
|
583
|
-
readonly model: string;
|
|
584
|
-
readonly maxTokens: number;
|
|
585
|
-
readonly surface: ChatModelSurface;
|
|
586
|
-
private readonly anthropicDelegate?;
|
|
587
|
-
private readonly openAiDelegate?;
|
|
588
|
-
constructor(options?: ChatModelOptions);
|
|
589
|
-
private getAnthropicDelegate;
|
|
590
|
-
private getOpenAiDelegate;
|
|
591
|
-
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
592
|
-
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
593
|
-
}
|
|
594
|
-
export type GitHubModelSurface = "auto" | "anthropic-messages" | "openai-chat-completions" | "openai-responses" | "openai-responses-ws";
|
|
595
|
-
export interface GitHubModelOptions extends Partial<BaseChatModelOptions> {
|
|
596
|
-
apiKey?: string;
|
|
597
|
-
accessToken?: string;
|
|
598
|
-
baseUrl?: string;
|
|
599
|
-
surface?: GitHubModelSurface;
|
|
600
|
-
githubApiUrl?: string;
|
|
601
|
-
fetch?: typeof globalThis.fetch;
|
|
602
|
-
editorVersion?: string;
|
|
603
|
-
editorPluginVersion?: string;
|
|
604
|
-
tokenExchangeApiVersion?: string;
|
|
605
|
-
providerSessionResolver?: ProviderSessionResolver;
|
|
606
|
-
}
|
|
607
|
-
export declare class GitHubModel extends OpenAiModel {
|
|
608
|
-
private readonly anthropicDelegate;
|
|
609
|
-
private readonly modelEndpointCache;
|
|
610
|
-
private readonly surface;
|
|
611
|
-
constructor(options?: GitHubModelOptions);
|
|
612
|
-
protected createMissingCredentialError(): Error;
|
|
613
|
-
private usesResponsesApi;
|
|
614
|
-
private shouldPreferResponsesApi;
|
|
615
|
-
private markModelAsResponsesOnly;
|
|
616
|
-
protected mapApiError(error: Error): Error;
|
|
617
|
-
private completeViaConfiguredSurface;
|
|
618
|
-
private streamViaConfiguredSurface;
|
|
619
|
-
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
620
|
-
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
621
|
-
getModels(signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
208
|
+
|
|
209
|
+
interface OpenAiRequestHeadersContext {
|
|
210
|
+
request?: ChatRequest;
|
|
211
|
+
body: unknown;
|
|
212
|
+
credential: ProviderCredential;
|
|
213
|
+
session?: ResolvedProviderSession;
|
|
214
|
+
stream: boolean;
|
|
215
|
+
}
|
|
216
|
+
type OpenAiHeaderResolver = (context: OpenAiRequestHeadersContext) => Promise<Record<string, string>> | Record<string, string>;
|
|
217
|
+
interface OpenAiModelOptions extends Partial<BaseChatModelOptions> {
|
|
218
|
+
apiKey?: string;
|
|
219
|
+
baseUrl?: string;
|
|
220
|
+
chatCompletionsPath?: string;
|
|
221
|
+
responsesPath?: string;
|
|
222
|
+
fetch?: typeof globalThis.fetch;
|
|
223
|
+
providerSessionResolver?: ProviderSessionResolver;
|
|
224
|
+
requestMutators?: ProviderRequestMutator[];
|
|
225
|
+
headerResolver?: OpenAiHeaderResolver;
|
|
226
|
+
sessionManager?: ProviderSessionManager;
|
|
227
|
+
webSocketFactory?: WebSocketFactory;
|
|
228
|
+
}
|
|
229
|
+
declare class OpenAiModel extends RoutedModel {
|
|
230
|
+
private static readonly sharedResponsesSocketSessions;
|
|
231
|
+
protected readonly chatCompletionsPath: string;
|
|
232
|
+
protected readonly responsesPath: string;
|
|
233
|
+
constructor(options?: OpenAiModelOptions);
|
|
234
|
+
protected completeViaChatCompletionsSurface(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
235
|
+
protected completeViaResponsesSurface(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
236
|
+
protected completeViaResponsesWebSocketSurface(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
237
|
+
protected streamViaChatCompletionsSurface(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
238
|
+
protected streamViaResponsesSurface(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
239
|
+
protected streamViaResponsesWebSocketSurface(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
240
|
+
chatComplete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
241
|
+
response(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
242
|
+
responseSocket(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
243
|
+
chatStream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
244
|
+
responseStream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
245
|
+
responseSocketStream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
246
|
+
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
247
|
+
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
248
|
+
private getResponsesSocketSessionState;
|
|
249
|
+
private getResponsesSocketSessionKey;
|
|
250
|
+
private acquireResponsesSocketLock;
|
|
251
|
+
private prepareResponsesSocketRequest;
|
|
252
|
+
private buildResponsesSocketEvent;
|
|
253
|
+
private findResponsesSocketCheckpoint;
|
|
254
|
+
private shouldRetryResponsesSocketRequest;
|
|
255
|
+
private invalidateResponsesSocketSession;
|
|
256
|
+
private getOrCreateResponsesSocket;
|
|
257
|
+
private streamViaPersistentResponsesSocket;
|
|
258
|
+
private streamViaResponsesSocketAttempt;
|
|
622
259
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
260
|
+
|
|
261
|
+
declare const AVAILABLE_CHAT_MODEL_SURFACES: readonly ["anthropic-messages", "openai-chat-completions", "openai-responses", "openai-responses-ws"];
|
|
262
|
+
type ChatModelSurface = (typeof AVAILABLE_CHAT_MODEL_SURFACES)[number];
|
|
263
|
+
type ChatModelAuthScheme = NonNullable<AnthropicModelOptions["authScheme"]>;
|
|
264
|
+
interface ChatModelOptions extends Partial<BaseChatModelOptions> {
|
|
265
|
+
apiKey?: string;
|
|
266
|
+
baseUrl?: string;
|
|
267
|
+
surface?: ChatModelSurface;
|
|
268
|
+
authScheme?: ChatModelAuthScheme;
|
|
269
|
+
fetch?: typeof globalThis.fetch;
|
|
270
|
+
providerSessionResolver?: ProviderSessionResolver;
|
|
271
|
+
requestMutators?: ProviderRequestMutator[];
|
|
272
|
+
headerResolver?: OpenAiHeaderResolver;
|
|
273
|
+
webSocketFactory?: WebSocketFactory;
|
|
274
|
+
}
|
|
275
|
+
declare class ChatModel implements EngineChatModel {
|
|
276
|
+
readonly model: string;
|
|
277
|
+
readonly maxTokens: number;
|
|
278
|
+
readonly surface: ChatModelSurface;
|
|
279
|
+
private readonly anthropicDelegate?;
|
|
280
|
+
private readonly openAiDelegate?;
|
|
281
|
+
constructor(options?: ChatModelOptions);
|
|
282
|
+
private getAnthropicDelegate;
|
|
283
|
+
private getOpenAiDelegate;
|
|
284
|
+
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
285
|
+
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
629
286
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
287
|
+
|
|
288
|
+
type GitHubModelSurface = "auto" | "anthropic-messages" | "openai-chat-completions" | "openai-responses" | "openai-responses-ws";
|
|
289
|
+
interface GitHubModelOptions extends Partial<BaseChatModelOptions> {
|
|
290
|
+
apiKey?: string;
|
|
291
|
+
accessToken?: string;
|
|
292
|
+
baseUrl?: string;
|
|
293
|
+
surface?: GitHubModelSurface;
|
|
294
|
+
githubApiUrl?: string;
|
|
295
|
+
fetch?: typeof globalThis.fetch;
|
|
296
|
+
editorVersion?: string;
|
|
297
|
+
editorPluginVersion?: string;
|
|
298
|
+
tokenExchangeApiVersion?: string;
|
|
299
|
+
providerSessionResolver?: ProviderSessionResolver;
|
|
300
|
+
}
|
|
301
|
+
declare class GitHubModel extends OpenAiModel {
|
|
302
|
+
private readonly anthropicDelegate;
|
|
303
|
+
private readonly modelEndpointCache;
|
|
304
|
+
private readonly surface;
|
|
305
|
+
constructor(options?: GitHubModelOptions);
|
|
306
|
+
protected createMissingCredentialError(): Error;
|
|
307
|
+
private usesResponsesApi;
|
|
308
|
+
private shouldPreferResponsesApi;
|
|
309
|
+
private markModelAsResponsesOnly;
|
|
310
|
+
protected mapApiError(error: Error): Error;
|
|
311
|
+
private completeViaConfiguredSurface;
|
|
312
|
+
private streamViaConfiguredSurface;
|
|
313
|
+
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
314
|
+
stream(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
315
|
+
getModels(signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
636
316
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
317
|
+
|
|
318
|
+
interface FetchJsonOptions {
|
|
319
|
+
url: string;
|
|
320
|
+
body: unknown;
|
|
321
|
+
headers: Record<string, string>;
|
|
322
|
+
fetch?: typeof globalThis.fetch;
|
|
323
|
+
signal?: AbortSignal;
|
|
324
|
+
}
|
|
325
|
+
declare function fetchRawResponse(options: FetchJsonOptions): Promise<Response>;
|
|
326
|
+
declare function fetchJsonResponse<T>(options: FetchJsonOptions): Promise<T>;
|
|
327
|
+
|
|
328
|
+
interface MockModelOptions {
|
|
329
|
+
model?: string;
|
|
330
|
+
maxTokens?: number;
|
|
331
|
+
reasoning?: ReasoningConfig;
|
|
332
|
+
}
|
|
333
|
+
declare class MockModel implements EngineChatModel {
|
|
334
|
+
readonly model: string;
|
|
335
|
+
readonly maxTokens: number;
|
|
336
|
+
readonly requests: ChatRequest[];
|
|
337
|
+
private readonly reasoning?;
|
|
338
|
+
constructor(options?: MockModelOptions);
|
|
339
|
+
complete(request: ChatRequest, _options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
644
340
|
}
|
|
645
341
|
|
|
646
|
-
export {};
|
|
342
|
+
export { ANTHROPIC_MESSAGES_STREAM_SURFACE, ANTHROPIC_MESSAGES_SURFACE, AVAILABLE_CHAT_MODEL_SURFACES, type AnthropicHeaderResolver, AnthropicModel, type AnthropicModelOptions, type AnthropicRequestHeadersContext, ChatModel, type ChatModelAuthScheme, type ChatModelOptions, type ChatModelSurface, type FetchJsonOptions, GitHubModel, type GitHubModelOptions, type GitHubModelSurface, MockModel, type MockModelOptions, type ModelSurfaceRouter, type ModelWebSocket, OPENAI_CHAT_COMPLETIONS_STREAM_SURFACE, OPENAI_CHAT_COMPLETIONS_SURFACE, OPENAI_RESPONSES_STREAM_SURFACE, OPENAI_RESPONSES_SURFACE, OPENAI_RESPONSES_WEBSOCKET_SURFACE, OpenAiApiError, type OpenAiHeaderResolver, OpenAiModel, type OpenAiModelOptions, type OpenAiRequestHeadersContext, type PrepareProviderRequestOptions, type ProviderAdapter, ProviderCredential, type ProviderHeaderContext, ProviderRequestMutator, ProviderSessionManager, ProviderSessionResolver, ResolvedProviderSession, RoutedModel, type RoutedModelMode, type RoutedModelOptions, type RoutedModelStreamParser, type RoutedModelSurface, type RoutedModelSurfaceRequest, StaticModelSurfaceRouter, type WebSocketFactory, createAnthropicSurfaces, createDefaultWebSocketFactory, createOpenAiApiError, createOpenAiResponsesStreamParser, createOpenAiResponsesWebSocketEvent, createOpenAiSurfaces, fetchJsonResponse, fetchRawResponse, iterateSseEvents, iterateWebSocketMessages, prepareProviderRequest, resolveApiCredential, resolveSessionBaseUrl, toWebSocketUrl, trimTrailingSlashes, waitForWebSocketOpen };
|