@mozaik-ai/core 3.13.0 → 3.14.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/index.d.ts CHANGED
@@ -1,10 +1,6 @@
1
- import OpenAI from 'openai';
2
- import Anthropic from '@anthropic-ai/sdk';
3
-
4
1
  declare abstract class ContextItem {
5
2
  abstract readonly type: string;
6
3
  getType(): string;
7
- abstract toJSON(): any;
8
4
  }
9
5
 
10
6
  declare class ModelContext {
@@ -22,7 +18,6 @@ declare class ModelContext {
22
18
  projectId: string;
23
19
  items: ContextItem[];
24
20
  }): ModelContext;
25
- toJSON(): any;
26
21
  }
27
22
 
28
23
  declare abstract class ItemContent {
@@ -37,7 +32,6 @@ declare class InputText extends ItemContent {
37
32
  static rehydrate(data: {
38
33
  text: string;
39
34
  }): InputText;
40
- toJSON(): any[];
41
35
  }
42
36
 
43
37
  declare class UserMessageItem extends ContextItem {
@@ -49,7 +43,6 @@ declare class UserMessageItem extends ContextItem {
49
43
  static rehydrate(data: {
50
44
  text: string;
51
45
  }): UserMessageItem;
52
- toJSON(): any;
53
46
  }
54
47
 
55
48
  declare class DeveloperMessageItem extends ContextItem {
@@ -57,7 +50,6 @@ declare class DeveloperMessageItem extends ContextItem {
57
50
  readonly role = "developer";
58
51
  readonly content: InputText;
59
52
  private constructor();
60
- toJSON(): any;
61
53
  static create(text: string): DeveloperMessageItem;
62
54
  static rehydrate(data: {
63
55
  text: string;
@@ -71,7 +63,6 @@ declare class OutputText extends ItemContent {
71
63
  static rehydrate(data: {
72
64
  text: string;
73
65
  }): OutputText;
74
- toJSON(): any[];
75
66
  }
76
67
 
77
68
  declare class ModelMessageItem extends ContextItem {
@@ -82,7 +73,6 @@ declare class ModelMessageItem extends ContextItem {
82
73
  static rehydrate(data: {
83
74
  text: string;
84
75
  }): ModelMessageItem;
85
- toJSON(): any;
86
76
  }
87
77
 
88
78
  declare class FunctionCallItem extends ContextItem {
@@ -96,7 +86,6 @@ declare class FunctionCallItem extends ContextItem {
96
86
  name: string;
97
87
  args: string;
98
88
  }): FunctionCallItem;
99
- toJSON(): any;
100
89
  }
101
90
 
102
91
  declare class SummaryText extends ItemContent {
@@ -106,7 +95,6 @@ declare class SummaryText extends ItemContent {
106
95
  static rehydrate(data: {
107
96
  text: string;
108
97
  }): SummaryText;
109
- toJSON(): Record<string, any>;
110
98
  }
111
99
 
112
100
  declare class ReasoningItem extends ContextItem {
@@ -120,28 +108,6 @@ declare class ReasoningItem extends ContextItem {
120
108
  encryptedContent: string | undefined;
121
109
  summary: SummaryText[];
122
110
  }): ReasoningItem;
123
- toJSON(): any;
124
- }
125
-
126
- interface ReasoningEffort<Effort extends string> {
127
- setReasoningEffort(effort: Effort): void;
128
- getReasoningEffort(): Effort;
129
- }
130
-
131
- interface StreamingCapability {
132
- setStreaming(streaming: boolean): void;
133
- getStreaming(): boolean;
134
- }
135
-
136
- type StructuredOutputFormat = {
137
- name?: string;
138
- schema: Record<string, any>;
139
- strict?: boolean;
140
- };
141
- interface StructuredOutputCapability {
142
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
143
- getStructuredOutput(): StructuredOutputFormat | undefined;
144
- hasStructuredOutput(): boolean;
145
111
  }
146
112
 
147
113
  interface FunctionTool {
@@ -154,26 +120,6 @@ interface FunctionTool {
154
120
  }
155
121
  type Tool = FunctionTool;
156
122
 
157
- interface ToolCallingCapability {
158
- setTools(tools: Tool[]): void;
159
- getTools(): Tool[];
160
- }
161
-
162
- type ModelSpecification = {
163
- name: string;
164
- provider: string;
165
- supportReasoningEffort: boolean;
166
- defaultReasoningEffort: string | undefined;
167
- supportStreaming: boolean;
168
- contextWindowSize: number;
169
- maxOutputTokens: number;
170
- supportFunctionCalling: boolean;
171
- supportStructuredOutput: boolean;
172
- };
173
- interface GenerativeModel extends ReasoningEffort<string>, ToolCallingCapability, StreamingCapability, StructuredOutputCapability {
174
- readonly specification: ModelSpecification;
175
- }
176
-
177
123
  declare class FunctionCallOutputItem extends ContextItem {
178
124
  readonly type = "function_call_output";
179
125
  readonly callId: string;
@@ -184,134 +130,6 @@ declare class FunctionCallOutputItem extends ContextItem {
184
130
  callId: string;
185
131
  output: InputText;
186
132
  }): FunctionCallOutputItem;
187
- toJSON(): any;
188
- }
189
-
190
- interface ModelContextRepository {
191
- save(context: ModelContext): Promise<void>;
192
- get(id: string): Promise<ModelContext>;
193
- getByProjectId(projectId: string): Promise<ModelContext[]>;
194
- }
195
-
196
- type OpenAIReasoningEffortType = "xhigh" | "high" | "medium" | "low" | "none";
197
-
198
- declare class Gpt54Nano implements GenerativeModel {
199
- readonly specification: {
200
- name: string;
201
- provider: string;
202
- supportReasoningEffort: boolean;
203
- defaultReasoningEffort: OpenAIReasoningEffortType;
204
- supportStreaming: boolean;
205
- contextWindowSize: number;
206
- maxOutputTokens: number;
207
- supportFunctionCalling: boolean;
208
- supportStructuredOutput: boolean;
209
- };
210
- private tools;
211
- private streaming;
212
- private structuredOutput;
213
- private readonly effort;
214
- setStreaming(streaming: boolean): void;
215
- getStreaming(): boolean;
216
- setTools(tools: Tool[]): void;
217
- getTools(): Tool[];
218
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
219
- getReasoningEffort(): OpenAIReasoningEffortType;
220
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
221
- getStructuredOutput(): StructuredOutputFormat | undefined;
222
- hasStructuredOutput(): boolean;
223
- }
224
-
225
- declare class Gpt54 implements GenerativeModel {
226
- readonly specification: {
227
- name: string;
228
- provider: string;
229
- supportReasoningEffort: boolean;
230
- defaultReasoningEffort: OpenAIReasoningEffortType;
231
- supportStreaming: boolean;
232
- contextWindowSize: number;
233
- maxOutputTokens: number;
234
- supportFunctionCalling: boolean;
235
- supportStructuredOutput: boolean;
236
- };
237
- private tools;
238
- private streaming;
239
- private structuredOutput;
240
- private readonly effort;
241
- setStreaming(streaming: boolean): void;
242
- getStreaming(): boolean;
243
- setTools(tools: Tool[]): void;
244
- getTools(): Tool[];
245
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
246
- getReasoningEffort(): OpenAIReasoningEffortType;
247
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
248
- getStructuredOutput(): StructuredOutputFormat | undefined;
249
- hasStructuredOutput(): boolean;
250
- }
251
-
252
- declare class Gpt54Mini implements GenerativeModel {
253
- readonly specification: {
254
- name: string;
255
- provider: string;
256
- supportReasoningEffort: boolean;
257
- defaultReasoningEffort: OpenAIReasoningEffortType;
258
- supportStreaming: boolean;
259
- contextWindowSize: number;
260
- maxOutputTokens: number;
261
- supportFunctionCalling: boolean;
262
- supportStructuredOutput: boolean;
263
- };
264
- private tools;
265
- private streaming;
266
- private structuredOutput;
267
- private readonly effort;
268
- setStreaming(streaming: boolean): void;
269
- getStreaming(): boolean;
270
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
271
- getReasoningEffort(): OpenAIReasoningEffortType;
272
- setTools(tools: Tool[]): void;
273
- getTools(): Tool[];
274
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
275
- getStructuredOutput(): StructuredOutputFormat | undefined;
276
- hasStructuredOutput(): boolean;
277
- }
278
-
279
- declare class InputTokenDetails {
280
- readonly cached_tokens: number;
281
- constructor(cached_tokens: number);
282
- }
283
- declare class OutputTokenDetails {
284
- readonly reasoning_tokens: number;
285
- constructor(reasoning_tokens: number);
286
- }
287
- declare class TokenUsage {
288
- readonly inputTokens: number;
289
- readonly outputTokens: number;
290
- readonly totalTokens: number;
291
- readonly inputTokenDetails: InputTokenDetails;
292
- readonly outputTokenDetails: OutputTokenDetails;
293
- constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
294
- }
295
-
296
- declare class InMemoryModelContextRepository implements ModelContextRepository {
297
- private readonly store;
298
- private readonly projectIndex;
299
- save(context: ModelContext): Promise<void>;
300
- get(id: string): Promise<ModelContext>;
301
- getByProjectId(projectId: string): Promise<ModelContext[]>;
302
- private clone;
303
- }
304
-
305
- declare class SystemMessageItem extends ContextItem {
306
- readonly type = "message";
307
- readonly role = "system";
308
- readonly content: InputText;
309
- private constructor();
310
- toJSON(): any;
311
- static create(text: string): SystemMessageItem;
312
- static rehydrate(data: {
313
- text: string;
314
- }): SystemMessageItem;
315
133
  }
316
134
 
317
135
  declare class SemanticEvent<T> {
@@ -335,29 +153,6 @@ declare class AgenticError extends Error {
335
153
  getEnvironment(): AgenticEnvironment | undefined;
336
154
  }
337
155
 
338
- interface AgenticEnvironmentOptions {
339
- silent?: boolean;
340
- }
341
- declare class AgenticEnvironment {
342
- protected subscribers: Participant[];
343
- private name?;
344
- private options?;
345
- private showLogs?;
346
- constructor(name?: string, opts?: AgenticEnvironmentOptions);
347
- subscribe(participant: Participant): void;
348
- unsubscribe(participant: Participant): void;
349
- deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
350
- deliverModelMessage(source: Participant, item: ModelMessageItem): void;
351
- deliverReasoning(source: Participant, item: ReasoningItem): void;
352
- deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
353
- deliverMessage(source: Participant, message: string): void;
354
- deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
355
- deliverError(source: Participant, error: AgenticError): void;
356
- private getListeningParticipants;
357
- private deliverToSubscribers;
358
- private handleError;
359
- }
360
-
361
156
  type ParticipantClassConstructor = new (...args: any[]) => Participant;
362
157
  declare abstract class Participant {
363
158
  private environments;
@@ -390,37 +185,57 @@ declare abstract class Participant {
390
185
  abstract onParticipantError(source: Participant, error: AgenticError): void;
391
186
  }
392
187
 
393
- declare class Gpt55 implements GenerativeModel {
394
- readonly specification: {
395
- name: string;
396
- provider: string;
397
- supportReasoningEffort: boolean;
398
- defaultReasoningEffort: OpenAIReasoningEffortType;
399
- supportStreaming: boolean;
400
- contextWindowSize: number;
401
- maxOutputTokens: number;
402
- supportFunctionCalling: boolean;
403
- supportStructuredOutput: boolean;
404
- };
405
- private tools;
406
- private streaming;
407
- private structuredOutput;
408
- private readonly effort;
409
- setStreaming(streaming: boolean): void;
410
- getStreaming(): boolean;
411
- setTools(tools: Tool[]): void;
412
- getTools(): Tool[];
413
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
414
- getReasoningEffort(): OpenAIReasoningEffortType;
415
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
416
- getStructuredOutput(): StructuredOutputFormat | undefined;
417
- hasStructuredOutput(): boolean;
188
+ interface AgenticEnvironmentOptions {
189
+ silent?: boolean;
190
+ }
191
+ declare class AgenticEnvironment {
192
+ protected subscribers: Participant[];
193
+ private name?;
194
+ private options?;
195
+ private showLogs?;
196
+ constructor(name?: string, opts?: AgenticEnvironmentOptions);
197
+ subscribe(participant: Participant): void;
198
+ unsubscribe(participant: Participant): void;
199
+ deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
200
+ deliverModelMessage(source: Participant, item: ModelMessageItem): void;
201
+ deliverReasoning(source: Participant, item: ReasoningItem): void;
202
+ deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
203
+ deliverMessage(source: Participant, message: string): void;
204
+ deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
205
+ deliverError(source: Participant, error: AgenticError): void;
206
+ private getListeningParticipants;
207
+ private deliverToSubscribers;
208
+ private handleError;
418
209
  }
419
210
 
420
- declare class InferenceRequest {
421
- readonly model: GenerativeModel;
422
- readonly context: ModelContext;
423
- constructor(model: GenerativeModel, context: ModelContext);
211
+ type InferenceParams<TModel extends string> = {
212
+ model: TModel;
213
+ maxOutputTokens?: number;
214
+ reasoningEffort?: string;
215
+ tools?: Tool[];
216
+ streaming?: boolean;
217
+ structuredOutput?: StructuredOutputFormat;
218
+ context: ModelContext;
219
+ caller: Participant;
220
+ environment: AgenticEnvironment;
221
+ signal?: AbortSignal;
222
+ };
223
+
224
+ declare class InputTokenDetails {
225
+ readonly cached_tokens: number;
226
+ constructor(cached_tokens: number);
227
+ }
228
+ declare class OutputTokenDetails {
229
+ readonly reasoning_tokens: number;
230
+ constructor(reasoning_tokens: number);
231
+ }
232
+ declare class TokenUsage {
233
+ readonly inputTokens: number;
234
+ readonly outputTokens: number;
235
+ readonly totalTokens: number;
236
+ readonly inputTokenDetails: InputTokenDetails;
237
+ readonly outputTokenDetails: OutputTokenDetails;
238
+ constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
424
239
  }
425
240
 
426
241
  declare class InferenceResponse {
@@ -429,378 +244,138 @@ declare class InferenceResponse {
429
244
  constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
430
245
  }
431
246
 
432
- interface Endpoint {
433
- infer(request: InferenceRequest): Promise<InferenceResponse>;
434
- stream(request: InferenceRequest): AsyncIterable<SemanticEvent<unknown>>;
435
- }
436
-
437
- declare class OpenAIResponses implements Endpoint {
438
- private readonly client;
439
- constructor();
440
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
441
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
442
- private buildRequest;
443
- extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
444
- mapContextToRequest(context: ModelContext): any[];
445
- extractContextItems(response: any): ContextItem[];
247
+ interface InferenceEndpointMapper {
248
+ toRequest(inferenceParams: InferenceParams<ModelName>): any;
249
+ toResponse(response: any): InferenceResponse;
446
250
  }
447
251
 
448
- declare class AnthropicMessages implements Endpoint {
449
- private readonly client;
450
- constructor();
451
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
452
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
453
- private buildRequest;
454
- extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
455
- mapContextToRequest(context: ModelContext): {
456
- messages: any[];
457
- system?: string;
458
- };
459
- extractContextItems(response: Anthropic.Messages.Message): ContextItem[];
460
- private addContentBlock;
461
- }
462
-
463
- type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
464
-
465
- declare class ClaudeOpus48 implements GenerativeModel {
466
- readonly specification: {
467
- name: string;
468
- provider: string;
469
- supportReasoningEffort: boolean;
470
- defaultReasoningEffort: AnthropicReasoningEffortType;
471
- supportStreaming: boolean;
472
- contextWindowSize: number;
473
- maxOutputTokens: number;
474
- supportFunctionCalling: boolean;
475
- supportStructuredOutput: boolean;
476
- };
477
- private tools;
478
- private streaming;
479
- private structuredOutput;
480
- private readonly effort;
481
- setStreaming(streaming: boolean): void;
482
- getStreaming(): boolean;
483
- setTools(tools: Tool[]): void;
484
- getTools(): Tool[];
485
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
486
- getReasoningEffort(): AnthropicReasoningEffortType;
487
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
488
- getStructuredOutput(): StructuredOutputFormat | undefined;
489
- hasStructuredOutput(): boolean;
252
+ interface Endpoint {
253
+ endpointMapper: InferenceEndpointMapper;
254
+ infer(requestParams: InferenceParams<ModelName>): Promise<InferenceResponse>;
255
+ stream(requestParams: InferenceParams<ModelName>, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
490
256
  }
491
257
 
492
- declare class ClaudeOpus47 implements GenerativeModel {
493
- readonly specification: {
494
- name: string;
495
- provider: string;
496
- supportReasoningEffort: boolean;
497
- defaultReasoningEffort: AnthropicReasoningEffortType;
498
- supportStreaming: boolean;
499
- contextWindowSize: number;
500
- maxOutputTokens: number;
501
- supportFunctionCalling: boolean;
502
- supportStructuredOutput: boolean;
503
- };
504
- private tools;
505
- private streaming;
506
- private structuredOutput;
507
- private readonly effort;
508
- setStreaming(streaming: boolean): void;
509
- getStreaming(): boolean;
510
- setTools(tools: Tool[]): void;
511
- getTools(): Tool[];
512
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
513
- getReasoningEffort(): AnthropicReasoningEffortType;
514
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
515
- getStructuredOutput(): StructuredOutputFormat | undefined;
516
- hasStructuredOutput(): boolean;
517
- }
258
+ type ModelName = "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-nano" | "gpt-5.5" | "claude-haiku-4-5" | "claude-sonnet-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "gemini-3.5-flash" | "gemini-3.1-pro-preview" | "deepseek-v4-flash" | "deepseek-v4-pro";
518
259
 
519
- declare class ClaudeSonnet46 implements GenerativeModel {
520
- readonly specification: {
521
- name: string;
522
- provider: string;
523
- supportReasoningEffort: boolean;
524
- defaultReasoningEffort: AnthropicReasoningEffortType;
525
- supportStreaming: boolean;
526
- contextWindowSize: number;
527
- maxOutputTokens: number;
528
- supportFunctionCalling: boolean;
529
- supportStructuredOutput: boolean;
530
- };
531
- private tools;
532
- private streaming;
533
- private structuredOutput;
534
- setStreaming(streaming: boolean): void;
535
- getStreaming(): boolean;
536
- setTools(tools: Tool[]): void;
537
- getTools(): Tool[];
538
- private readonly effort;
539
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
540
- getReasoningEffort(): AnthropicReasoningEffortType;
541
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
542
- getStructuredOutput(): StructuredOutputFormat | undefined;
543
- hasStructuredOutput(): boolean;
544
- }
260
+ type StructuredOutputFormat = {
261
+ name?: string;
262
+ schema: Record<string, any>;
263
+ strict?: boolean;
264
+ };
545
265
 
546
- declare class ClaudeHaiku45 implements GenerativeModel {
547
- readonly specification: {
548
- name: string;
549
- provider: string;
550
- supportReasoningEffort: boolean;
551
- defaultReasoningEffort: AnthropicReasoningEffortType;
552
- supportStreaming: boolean;
553
- contextWindowSize: number;
554
- maxOutputTokens: number;
555
- supportFunctionCalling: boolean;
556
- supportStructuredOutput: boolean;
557
- };
558
- private tools;
559
- private streaming;
560
- private structuredOutput;
561
- private readonly effort;
562
- setStreaming(streaming: boolean): void;
563
- getStreaming(): boolean;
564
- setTools(tools: Tool[]): void;
565
- getTools(): Tool[];
566
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
567
- getReasoningEffort(): AnthropicReasoningEffortType;
568
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
569
- getStructuredOutput(): StructuredOutputFormat | undefined;
570
- hasStructuredOutput(): boolean;
266
+ interface ModelContextRepository {
267
+ save(context: ModelContext): Promise<void>;
268
+ get(id: string): Promise<ModelContext>;
269
+ getByProjectId(projectId: string): Promise<ModelContext[]>;
571
270
  }
572
271
 
573
- /**
574
- * DeepSeek V4 reasoning levels. `"none"` selects non-thinking mode
575
- * (`thinking: { type: "disabled" }`); any other value enables thinking
576
- * mode and is forwarded as the `reasoning_effort` request parameter.
577
- */
578
- type DeepSeekReasoningEffortType = "max" | "high" | "medium" | "low" | "none";
579
-
580
- declare class DeepSeekV4Flash implements GenerativeModel {
581
- readonly specification: {
582
- name: string;
583
- provider: string;
584
- supportReasoningEffort: boolean;
585
- defaultReasoningEffort: DeepSeekReasoningEffortType;
586
- supportStreaming: boolean;
587
- contextWindowSize: number;
588
- maxOutputTokens: number;
589
- supportFunctionCalling: boolean;
590
- supportStructuredOutput: boolean;
591
- };
592
- private tools;
593
- private streaming;
594
- private structuredOutput;
595
- private readonly effort;
596
- setStreaming(streaming: boolean): void;
597
- getStreaming(): boolean;
598
- setTools(tools: Tool[]): void;
599
- getTools(): Tool[];
600
- setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
601
- getReasoningEffort(): DeepSeekReasoningEffortType;
602
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
603
- getStructuredOutput(): StructuredOutputFormat | undefined;
604
- hasStructuredOutput(): boolean;
272
+ interface McpServerConfig {
273
+ /** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */
274
+ url: string;
275
+ /** Bearer token sent as `Authorization: Bearer <token>` (e.g. a GitHub token). */
276
+ authToken?: string;
277
+ /** Extra headers merged into every request (overridden by `authToken` for Authorization). */
278
+ headers?: Record<string, string>;
279
+ /** Client name reported to the server (defaults to "mozaik"). */
280
+ name?: string;
605
281
  }
606
-
607
- declare class DeepSeekV4Pro implements GenerativeModel {
608
- readonly specification: {
609
- name: string;
610
- provider: string;
611
- supportReasoningEffort: boolean;
612
- defaultReasoningEffort: DeepSeekReasoningEffortType;
613
- supportStreaming: boolean;
614
- contextWindowSize: number;
615
- maxOutputTokens: number;
616
- supportFunctionCalling: boolean;
617
- supportStructuredOutput: boolean;
618
- };
619
- private tools;
620
- private streaming;
621
- private structuredOutput;
622
- private readonly effort;
623
- setStreaming(streaming: boolean): void;
624
- getStreaming(): boolean;
625
- setTools(tools: Tool[]): void;
626
- getTools(): Tool[];
627
- setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
628
- getReasoningEffort(): DeepSeekReasoningEffortType;
629
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
630
- getStructuredOutput(): StructuredOutputFormat | undefined;
631
- hasStructuredOutput(): boolean;
282
+ interface McpToolSpec {
283
+ name: string;
284
+ description: string;
285
+ /** JSON Schema for the tool's arguments (maps 1:1 to FunctionTool.parameters). */
286
+ inputSchema: Record<string, any>;
632
287
  }
633
-
634
288
  /**
635
- * Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
636
- * `generateContentStream`). Unlike an OpenAI-compat shim this maps our
637
- * domain context to Gemini's native `contents`/`parts` shape, system
638
- * instruction, `functionDeclarations`, and `thinkingConfig`, and reads
639
- * thought parts + native usage metadata back out. Another `ModelRuntime`
640
- * — no runner or port changes.
289
+ * A thin wrapper over the MCP TypeScript SDK using the Streamable HTTP transport — what
290
+ * remote MCP servers (e.g. GitHub's `api.githubcopilot.com/mcp/`) speak. One client per
291
+ * server; lazily connects on first use. Infrastructure-only: the domain never sees this.
641
292
  */
642
- declare class GeminiGenerateContent implements Endpoint {
293
+ declare class McpClient {
294
+ private readonly config;
643
295
  private readonly client;
644
- constructor();
645
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
646
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
647
- private buildRequest;
648
- extractTokenUsage(response: any): TokenUsage | undefined;
649
- mapContextToRequest(context: ModelContext): {
650
- contents: any[];
651
- systemInstruction?: string;
652
- };
653
- extractContextItems(response: any): ContextItem[];
654
- private parseResponse;
655
- private addPart;
296
+ private readonly transport;
297
+ private connected;
298
+ constructor(config: McpServerConfig);
299
+ connect(): Promise<void>;
300
+ /** The tools this server exposes. */
301
+ listTools(): Promise<McpToolSpec[]>;
302
+ /** Call a tool by name; returns its text output. Throws if the server flags an error. */
303
+ callTool(name: string, args: Record<string, any>): Promise<string>;
304
+ close(): Promise<void>;
305
+ }
306
+
307
+ /** The slice of an MCP client the registry needs — lets tests inject a fake. */
308
+ interface McpClientLike {
309
+ listTools(): Promise<Array<{
310
+ name: string;
311
+ description: string;
312
+ inputSchema: Record<string, any>;
313
+ }>>;
314
+ callTool(name: string, args: Record<string, any>): Promise<string>;
315
+ close(): Promise<void>;
656
316
  }
657
-
658
317
  /**
659
- * Gemini reasoning levels, forwarded as the `reasoning_effort` request
660
- * parameter on the OpenAI-compatible endpoint. `"none"` only disables
661
- * thinking on Gemini 2.5 models; Gemini 3.x always thinks, so for those
662
- * the adapter simply omits `reasoning_effort` when set to `"none"` and
663
- * lets the model use its default thinking level.
318
+ * Connects to one or more MCP servers and exposes their tools as mozaik `FunctionTool`s.
319
+ * Each tool's `invoke()` proxies the call back to its MCP server. Because they are plain
320
+ * FunctionTools, every provider mapper and the existing function-call loop handle them
321
+ * with no changes — MCP support adds no new tool type and touches no provider code.
322
+ *
323
+ * `strict` is false: MCP servers publish arbitrary JSON Schemas that won't always satisfy
324
+ * a provider's strict function-calling mode.
664
325
  */
665
- type GeminiReasoningEffortType = "high" | "medium" | "low" | "minimal" | "none";
666
-
667
- declare class Gemini35Flash implements GenerativeModel {
668
- readonly specification: {
669
- name: string;
670
- provider: string;
671
- supportReasoningEffort: boolean;
672
- defaultReasoningEffort: GeminiReasoningEffortType;
673
- supportStreaming: boolean;
674
- contextWindowSize: number;
675
- maxOutputTokens: number;
676
- supportFunctionCalling: boolean;
677
- supportStructuredOutput: boolean;
678
- };
679
- private tools;
680
- private streaming;
681
- private structuredOutput;
682
- private readonly effort;
683
- setStreaming(streaming: boolean): void;
684
- getStreaming(): boolean;
685
- setTools(tools: Tool[]): void;
686
- getTools(): Tool[];
687
- setReasoningEffort(effort: GeminiReasoningEffortType): void;
688
- getReasoningEffort(): GeminiReasoningEffortType;
689
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
690
- getStructuredOutput(): StructuredOutputFormat | undefined;
691
- hasStructuredOutput(): boolean;
326
+ declare class McpToolRegistry {
327
+ private readonly servers;
328
+ private readonly createClient;
329
+ private readonly clients;
330
+ constructor(servers: McpServerConfig[], createClient?: (config: McpServerConfig) => McpClientLike);
331
+ /** Discover every tool across the configured servers, as FunctionTools ready to pass to a model. */
332
+ discoverTools(): Promise<FunctionTool[]>;
333
+ /** Close all underlying MCP connections. */
334
+ close(): Promise<void>;
692
335
  }
693
336
 
694
- declare class Gemini31Pro implements GenerativeModel {
695
- readonly specification: {
696
- name: string;
697
- provider: string;
698
- supportReasoningEffort: boolean;
699
- defaultReasoningEffort: GeminiReasoningEffortType;
700
- supportStreaming: boolean;
701
- contextWindowSize: number;
702
- maxOutputTokens: number;
703
- supportFunctionCalling: boolean;
704
- supportStructuredOutput: boolean;
705
- };
706
- private tools;
707
- private streaming;
708
- private structuredOutput;
709
- private readonly effort;
710
- setStreaming(streaming: boolean): void;
711
- getStreaming(): boolean;
712
- setTools(tools: Tool[]): void;
713
- getTools(): Tool[];
714
- setReasoningEffort(effort: GeminiReasoningEffortType): void;
715
- getReasoningEffort(): GeminiReasoningEffortType;
716
- setStructuredOutput(format: StructuredOutputFormat | undefined): void;
717
- getStructuredOutput(): StructuredOutputFormat | undefined;
718
- hasStructuredOutput(): boolean;
337
+ declare class InMemoryModelContextRepository implements ModelContextRepository {
338
+ private readonly store;
339
+ private readonly projectIndex;
340
+ save(context: ModelContext): Promise<void>;
341
+ get(id: string): Promise<ModelContext>;
342
+ getByProjectId(projectId: string): Promise<ModelContext[]>;
343
+ private clone;
719
344
  }
720
345
 
721
- /**
722
- * Optional connection config. When omitted, the `openai` SDK reads
723
- * `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
724
- * default-constructed runtime targets whatever `OPENAI_BASE_URL` points
725
- * at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
726
- * explicit base URL + credential.
727
- */
728
- interface OpenAICompatibleConfig {
729
- baseURL?: string;
730
- apiKey?: string;
731
- /**
732
- * Extra request-body fields merged into every `chat.completions`
733
- * call. This is how provider-specific quirks are handled **without
734
- * a per-provider subclass in mozaik** — the consumer supplies the
735
- * vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
736
- * safety flags, routing hints). Standard fields the runtime already
737
- * sets (`model`, `messages`, `tools`, `reasoning_effort`) take
738
- * precedence and are not overwritten.
739
- */
740
- extraBody?: Record<string, unknown>;
741
- }
742
- /**
743
- * Generic adapter for any **OpenAI Chat Completions**-compatible
744
- * endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
745
- * Ollama, etc. It speaks `/chat/completions` (not the Responses API),
746
- * which is the dialect third-party OpenAI-compatible providers expose.
747
- *
748
- * The base URL and credential are configurable; everything else (the
749
- * `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
750
- * usage extraction) is provider-agnostic. Provider-specific request
751
- * shaping (e.g. DeepSeek's `thinking` field) is supplied by the
752
- * consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
753
- * generic and gains no per-provider subclasses.
754
- *
755
- * Was `DeepSeekChatCompletions`; generalized so consumers can point it
756
- * at any OpenAI-compatible endpoint.
757
- */
758
- declare class OpenAIChatCompletions implements Endpoint {
759
- private readonly client;
760
- private readonly extraBody;
761
- constructor(config?: OpenAICompatibleConfig);
762
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
763
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
764
- buildRequest(inferenceRequest: InferenceRequest): any;
765
- extractTokenUsage(response: any): TokenUsage | undefined;
766
- mapContextToRequest(context: ModelContext): any[];
767
- extractContextItems(response: any): ContextItem[];
346
+ declare class SystemMessageItem extends ContextItem {
347
+ readonly type = "message";
348
+ readonly role = "system";
349
+ readonly content: InputText;
350
+ private constructor();
351
+ static create(text: string): SystemMessageItem;
352
+ static rehydrate(data: {
353
+ text: string;
354
+ }): SystemMessageItem;
768
355
  }
769
356
 
770
- type InferenceParams = {
771
- model: string;
772
- reasoningEffort?: string;
773
- tools?: Tool[];
774
- streaming?: boolean;
775
- structuredOutput?: StructuredOutputFormat;
776
- context: ModelContext;
777
- caller: Participant;
778
- environment: AgenticEnvironment;
779
- signal?: AbortSignal;
780
- };
781
-
782
357
  declare class BaseParticipant extends Participant {
783
- onFunctionCall(item: FunctionCallItem): void;
784
- onExternalFunctionCall(source: Participant, item: FunctionCallItem): void;
785
- onFunctionCallOutput(item: FunctionCallOutputItem): void;
786
- onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
787
- onReasoning(item: ReasoningItem): void;
788
- onExternalReasoning(source: Participant, item: ReasoningItem): void;
789
- onModelMessage(item: ModelMessageItem): void;
790
- onExternalModelMessage(source: Participant, item: ModelMessageItem): void;
791
- onMessage(message: string): void;
358
+ onFunctionCall(_item: FunctionCallItem): void;
359
+ onExternalFunctionCall(_source: Participant, _item: FunctionCallItem): void;
360
+ onFunctionCallOutput(_item: FunctionCallOutputItem): void;
361
+ onExternalFunctionCallOutput(_source: Participant, _item: FunctionCallOutputItem): void;
362
+ onReasoning(_item: ReasoningItem): void;
363
+ onExternalReasoning(_source: Participant, _item: ReasoningItem): void;
364
+ onModelMessage(_item: ModelMessageItem): void;
365
+ onExternalModelMessage(_source: Participant, _item: ModelMessageItem): void;
366
+ onMessage(_message: string): void;
792
367
  onJoined(): void;
793
368
  onLeft(): void;
794
- onParticipantJoined(participant: Participant): void;
795
- onParticipantLeft(participant: Participant): void;
796
- onInternalEvent(item: SemanticEvent<unknown>): void;
797
- onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
798
- onError(error: AgenticError): void;
799
- onParticipantError(source: Participant, error: AgenticError): void;
369
+ onParticipantJoined(_participant: Participant): void;
370
+ onParticipantLeft(_participant: Participant): void;
371
+ onInternalEvent(_item: SemanticEvent<unknown>): void;
372
+ onExternalEvent(_source: Participant, _item: SemanticEvent<unknown>): void;
373
+ onError(_error: AgenticError): void;
374
+ onParticipantError(_source: Participant, _error: AgenticError): void;
800
375
  }
801
376
 
802
- declare const runInference: (inferenceParams: InferenceParams) => void;
377
+ declare const runInference: (inferenceParams: InferenceParams<ModelName>) => void;
803
378
  declare const executeFunctionCall: (environment: AgenticEnvironment, functionCallItem: FunctionCallItem, tool: Tool, caller: Participant) => void;
804
379
  declare const sendMessage: (environment: AgenticEnvironment, message: string, caller: Participant) => void;
805
380
 
806
- export { AgenticEnvironment, AgenticError, AnthropicMessages, BaseParticipant, ClaudeHaiku45, ClaudeOpus47, ClaudeOpus48, ClaudeSonnet46, ContextItem, DeepSeekV4Flash, DeepSeekV4Pro, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, Gemini31Pro, Gemini35Flash, GeminiGenerateContent, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, InMemoryModelContextRepository, InferenceRequest, InferenceResponse, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StructuredOutputCapability, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, executeFunctionCall, runInference, sendMessage };
381
+ export { AgenticEnvironment, AgenticError, BaseParticipant, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, InMemoryModelContextRepository, type InferenceParams, InferenceResponse, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, type ModelName, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, executeFunctionCall, runInference, sendMessage };