@mozaik-ai/core 3.12.0 → 3.13.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.mts CHANGED
@@ -133,6 +133,17 @@ interface StreamingCapability {
133
133
  getStreaming(): boolean;
134
134
  }
135
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
+ }
146
+
136
147
  interface FunctionTool {
137
148
  type: "function";
138
149
  name: string;
@@ -150,14 +161,16 @@ interface ToolCallingCapability {
150
161
 
151
162
  type ModelSpecification = {
152
163
  name: string;
164
+ provider: string;
153
165
  supportReasoningEffort: boolean;
154
166
  defaultReasoningEffort: string | undefined;
155
167
  supportStreaming: boolean;
156
168
  contextWindowSize: number;
157
169
  maxOutputTokens: number;
158
170
  supportFunctionCalling: boolean;
171
+ supportStructuredOutput: boolean;
159
172
  };
160
- interface GenerativeModel extends ReasoningEffort<string>, ToolCallingCapability, StreamingCapability {
173
+ interface GenerativeModel extends ReasoningEffort<string>, ToolCallingCapability, StreamingCapability, StructuredOutputCapability {
161
174
  readonly specification: ModelSpecification;
162
175
  }
163
176
 
@@ -185,15 +198,18 @@ type OpenAIReasoningEffortType = "xhigh" | "high" | "medium" | "low" | "none";
185
198
  declare class Gpt54Nano implements GenerativeModel {
186
199
  readonly specification: {
187
200
  name: string;
201
+ provider: string;
188
202
  supportReasoningEffort: boolean;
189
203
  defaultReasoningEffort: OpenAIReasoningEffortType;
190
204
  supportStreaming: boolean;
191
205
  contextWindowSize: number;
192
206
  maxOutputTokens: number;
193
207
  supportFunctionCalling: boolean;
208
+ supportStructuredOutput: boolean;
194
209
  };
195
210
  private tools;
196
211
  private streaming;
212
+ private structuredOutput;
197
213
  private readonly effort;
198
214
  setStreaming(streaming: boolean): void;
199
215
  getStreaming(): boolean;
@@ -201,20 +217,26 @@ declare class Gpt54Nano implements GenerativeModel {
201
217
  getTools(): Tool[];
202
218
  setReasoningEffort(effort: OpenAIReasoningEffortType): void;
203
219
  getReasoningEffort(): OpenAIReasoningEffortType;
220
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
221
+ getStructuredOutput(): StructuredOutputFormat | undefined;
222
+ hasStructuredOutput(): boolean;
204
223
  }
205
224
 
206
225
  declare class Gpt54 implements GenerativeModel {
207
226
  readonly specification: {
208
227
  name: string;
228
+ provider: string;
209
229
  supportReasoningEffort: boolean;
210
230
  defaultReasoningEffort: OpenAIReasoningEffortType;
211
231
  supportStreaming: boolean;
212
232
  contextWindowSize: number;
213
233
  maxOutputTokens: number;
214
234
  supportFunctionCalling: boolean;
235
+ supportStructuredOutput: boolean;
215
236
  };
216
237
  private tools;
217
238
  private streaming;
239
+ private structuredOutput;
218
240
  private readonly effort;
219
241
  setStreaming(streaming: boolean): void;
220
242
  getStreaming(): boolean;
@@ -222,20 +244,26 @@ declare class Gpt54 implements GenerativeModel {
222
244
  getTools(): Tool[];
223
245
  setReasoningEffort(effort: OpenAIReasoningEffortType): void;
224
246
  getReasoningEffort(): OpenAIReasoningEffortType;
247
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
248
+ getStructuredOutput(): StructuredOutputFormat | undefined;
249
+ hasStructuredOutput(): boolean;
225
250
  }
226
251
 
227
252
  declare class Gpt54Mini implements GenerativeModel {
228
253
  readonly specification: {
229
254
  name: string;
255
+ provider: string;
230
256
  supportReasoningEffort: boolean;
231
257
  defaultReasoningEffort: OpenAIReasoningEffortType;
232
258
  supportStreaming: boolean;
233
259
  contextWindowSize: number;
234
260
  maxOutputTokens: number;
235
261
  supportFunctionCalling: boolean;
262
+ supportStructuredOutput: boolean;
236
263
  };
237
264
  private tools;
238
265
  private streaming;
266
+ private structuredOutput;
239
267
  private readonly effort;
240
268
  setStreaming(streaming: boolean): void;
241
269
  getStreaming(): boolean;
@@ -243,6 +271,9 @@ declare class Gpt54Mini implements GenerativeModel {
243
271
  getReasoningEffort(): OpenAIReasoningEffortType;
244
272
  setTools(tools: Tool[]): void;
245
273
  getTools(): Tool[];
274
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
275
+ getStructuredOutput(): StructuredOutputFormat | undefined;
276
+ hasStructuredOutput(): boolean;
246
277
  }
247
278
 
248
279
  declare class InputTokenDetails {
@@ -290,11 +321,29 @@ declare class SemanticEvent<T> {
290
321
  getType(): string;
291
322
  }
292
323
 
324
+ interface AgenticErrorOpts {
325
+ message: string;
326
+ stack?: string;
327
+ source?: Participant;
328
+ enviornment?: AgenticEnvironment;
329
+ }
330
+ declare class AgenticError extends Error {
331
+ private source?;
332
+ private environment?;
333
+ constructor({ message, stack, source, enviornment }: AgenticErrorOpts);
334
+ getSource(): Participant | undefined;
335
+ getEnvironment(): AgenticEnvironment | undefined;
336
+ }
337
+
338
+ interface AgenticEnvironmentOptions {
339
+ silent?: boolean;
340
+ }
293
341
  declare class AgenticEnvironment {
294
342
  protected subscribers: Participant[];
295
343
  private name?;
296
- private isActive;
297
- constructor(name?: string);
344
+ private options?;
345
+ private showLogs?;
346
+ constructor(name?: string, opts?: AgenticEnvironmentOptions);
298
347
  subscribe(participant: Participant): void;
299
348
  unsubscribe(participant: Participant): void;
300
349
  deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
@@ -303,21 +352,25 @@ declare class AgenticEnvironment {
303
352
  deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
304
353
  deliverMessage(source: Participant, message: string): void;
305
354
  deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
355
+ deliverError(source: Participant, error: AgenticError): void;
306
356
  private getListeningParticipants;
307
357
  private deliverToSubscribers;
308
- start(): Promise<void>;
309
- stop(): void;
358
+ private handleError;
310
359
  }
311
360
 
312
361
  type ParticipantClassConstructor = new (...args: any[]) => Participant;
313
362
  declare abstract class Participant {
314
363
  private environments;
315
364
  protected listens: ParticipantClassConstructor[];
365
+ private active;
316
366
  join(environment: AgenticEnvironment): void;
317
367
  leave(environment: AgenticEnvironment): void;
318
- protected isJoinedTo(environment: AgenticEnvironment): boolean;
368
+ isJoinedTo(environment: AgenticEnvironment): boolean;
319
369
  getEnvironments(): AgenticEnvironment[];
320
370
  getListeners(): ParticipantClassConstructor[];
371
+ getEnvironmentState(environment: AgenticEnvironment): boolean | undefined;
372
+ markInactive(environment: AgenticEnvironment): void;
373
+ markActive(environment: AgenticEnvironment): void;
321
374
  abstract onParticipantJoined(participant: Participant): Promise<void> | void;
322
375
  abstract onParticipantLeft(participant: Participant): Promise<void> | void;
323
376
  abstract onJoined(): Promise<void> | void;
@@ -333,123 +386,25 @@ declare abstract class Participant {
333
386
  abstract onMessage(message: string): Promise<void> | void;
334
387
  abstract onInternalEvent(item: SemanticEvent<unknown>): Promise<void> | void;
335
388
  abstract onExternalEvent(source: Participant, item: SemanticEvent<unknown>): Promise<void> | void;
336
- }
337
-
338
- interface InferenceRunner {
339
- run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
340
- }
341
-
342
- interface FunctionCallRunner {
343
- run(functionCallItem: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
344
- }
345
-
346
- declare abstract class Agent extends Participant {
347
- abstract executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
348
- abstract runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
349
- }
350
-
351
- declare class BaseAgent extends Agent {
352
- private inferenceRunner;
353
- private functionCallRunner;
354
- constructor(inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
355
- onJoined(): void;
356
- onLeft(): void;
357
- onParticipantJoined(participant: Participant): void;
358
- onParticipantLeft(participant: Participant): void;
359
- onFunctionCall(item: FunctionCallItem): void;
360
- onExternalFunctionCall(source: Participant, item: FunctionCallItem): void;
361
- onFunctionCallOutput(item: FunctionCallOutputItem): void;
362
- onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
363
- onReasoning(item: ReasoningItem): void;
364
- onExternalReasoning(source: Participant, item: ReasoningItem): void;
365
- onModelMessage(item: ModelMessageItem): void;
366
- onExternalModelMessage(source: Participant, item: ModelMessageItem): void;
367
- onMessage(message: string): void;
368
- onInternalEvent(item: SemanticEvent<unknown>): void;
369
- onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
370
- executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
371
- runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
372
- }
373
-
374
- declare abstract class Human extends Participant {
375
- sendMessage(environment: AgenticEnvironment, message: string): void;
376
- }
377
-
378
- declare class BaseHuman extends Human {
379
- onJoined(): void;
380
- onLeft(): void;
381
- onParticipantJoined(participant: Participant): void;
382
- onParticipantLeft(participant: Participant): void;
383
- onMessage(message: string): void;
384
- onFunctionCall(item: FunctionCallItem): void;
385
- onFunctionCallOutput(item: FunctionCallOutputItem): void;
386
- onReasoning(item: ReasoningItem): void;
387
- onModelMessage(item: ModelMessageItem): void;
388
- onExternalFunctionCall(source: Participant, item: FunctionCallItem): void;
389
- onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
390
- onExternalReasoning(source: Participant, item: ReasoningItem): void;
391
- onExternalModelMessage(source: Participant, item: ModelMessageItem): void;
392
- onInternalEvent(item: SemanticEvent<unknown>): void;
393
- onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
394
- }
395
-
396
- declare class InferenceRequest {
397
- readonly model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability;
398
- readonly context: ModelContext;
399
- constructor(model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext);
400
- }
401
-
402
- declare class InferenceResponse {
403
- readonly contextItems: ContextItem[];
404
- readonly tokenUsage?: TokenUsage;
405
- constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
406
- }
407
-
408
- /**
409
- * Provider-agnostic port for a single round of inference.
410
- *
411
- * Lives in the domain layer; concrete adapters (OpenAI Responses,
412
- * Anthropic Messages, DeepSeek Chat Completions, …) live in the
413
- * infrastructure layer and are injected into application-layer runners
414
- * through their constructor. The application layer must depend on this
415
- * interface, never on a concrete provider client.
416
- */
417
- interface ModelRuntime {
418
- infer(request: InferenceRequest): Promise<InferenceResponse>;
419
- }
420
-
421
- type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>;
422
- /**
423
- * Provider-agnostic inference runner: it depends on
424
- * the {@link ModelRuntime} domain port and receives a concrete
425
- * infrastructure adapter (OpenAIResponses, AnthropicMessages, …)
426
- * through its constructor.
427
- */
428
- declare class DefaultInferenceRunner implements InferenceRunner {
429
- private readonly runtime;
430
- constructor(runtime: ModelRuntime);
431
- run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem>;
432
- private isStreamingRuntime;
433
- }
434
-
435
- declare class DefaultFunctionCallRunner implements FunctionCallRunner {
436
- private readonly tools;
437
- constructor(tools: Tool[]);
438
- run(call: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
389
+ abstract onError(error: AgenticError): void;
390
+ abstract onParticipantError(source: Participant, error: AgenticError): void;
439
391
  }
440
392
 
441
393
  declare class Gpt55 implements GenerativeModel {
442
394
  readonly specification: {
443
395
  name: string;
396
+ provider: string;
444
397
  supportReasoningEffort: boolean;
445
398
  defaultReasoningEffort: OpenAIReasoningEffortType;
446
399
  supportStreaming: boolean;
447
400
  contextWindowSize: number;
448
401
  maxOutputTokens: number;
449
402
  supportFunctionCalling: boolean;
403
+ supportStructuredOutput: boolean;
450
404
  };
451
405
  private tools;
452
406
  private streaming;
407
+ private structuredOutput;
453
408
  private readonly effort;
454
409
  setStreaming(streaming: boolean): void;
455
410
  getStreaming(): boolean;
@@ -457,104 +412,44 @@ declare class Gpt55 implements GenerativeModel {
457
412
  getTools(): Tool[];
458
413
  setReasoningEffort(effort: OpenAIReasoningEffortType): void;
459
414
  getReasoningEffort(): OpenAIReasoningEffortType;
415
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
416
+ getStructuredOutput(): StructuredOutputFormat | undefined;
417
+ hasStructuredOutput(): boolean;
460
418
  }
461
419
 
462
- declare abstract class Observer extends Participant {
420
+ declare class InferenceRequest {
421
+ readonly model: GenerativeModel;
422
+ readonly context: ModelContext;
423
+ constructor(model: GenerativeModel, context: ModelContext);
463
424
  }
464
425
 
465
- declare class BaseObserver extends Observer {
466
- onFunctionCall(item: FunctionCallItem): void;
467
- onExternalFunctionCall(source: Participant, item: FunctionCallItem): void;
468
- onFunctionCallOutput(item: FunctionCallOutputItem): void;
469
- onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
470
- onReasoning(item: ReasoningItem): void;
471
- onExternalReasoning(source: Participant, item: ReasoningItem): void;
472
- onModelMessage(item: ModelMessageItem): void;
473
- onExternalModelMessage(source: Participant, item: ModelMessageItem): void;
474
- onMessage(message: string): void;
475
- onJoined(): void;
476
- onLeft(): void;
477
- onParticipantJoined(participant: Participant): void;
478
- onParticipantLeft(participant: Participant): void;
479
- onInternalEvent(item: SemanticEvent<unknown>): void;
480
- onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
426
+ declare class InferenceResponse {
427
+ readonly contextItems: ContextItem[];
428
+ readonly tokenUsage?: TokenUsage;
429
+ constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
481
430
  }
482
431
 
483
- /**
484
- * Optional streaming companion to {@link ModelRuntime}. Adapters whose
485
- * provider can stream a round implement this in addition to
486
- * `ModelRuntime`; runners delegate to `stream` only when the model has
487
- * streaming enabled and the injected runtime actually implements it.
488
- */
489
- interface StreamingRuntime {
490
- stream(request: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
432
+ interface Endpoint {
433
+ infer(request: InferenceRequest): Promise<InferenceResponse>;
434
+ stream(request: InferenceRequest): AsyncIterable<SemanticEvent<unknown>>;
491
435
  }
492
436
 
493
- declare class OpenAIResponses implements ModelRuntime, StreamingRuntime {
437
+ declare class OpenAIResponses implements Endpoint {
494
438
  private readonly client;
495
439
  constructor();
496
440
  infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
497
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
441
+ stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
498
442
  private buildRequest;
499
443
  extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
500
444
  mapContextToRequest(context: ModelContext): any[];
501
445
  extractContextItems(response: any): ContextItem[];
502
446
  }
503
447
 
504
- /**
505
- * Optional connection config. When omitted, the `openai` SDK reads
506
- * `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
507
- * default-constructed runtime targets whatever `OPENAI_BASE_URL` points
508
- * at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
509
- * explicit base URL + credential.
510
- */
511
- interface OpenAICompatibleConfig {
512
- baseURL?: string;
513
- apiKey?: string;
514
- /**
515
- * Extra request-body fields merged into every `chat.completions`
516
- * call. This is how provider-specific quirks are handled **without
517
- * a per-provider subclass in mozaik** — the consumer supplies the
518
- * vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
519
- * safety flags, routing hints). Standard fields the runtime already
520
- * sets (`model`, `messages`, `tools`, `reasoning_effort`) take
521
- * precedence and are not overwritten.
522
- */
523
- extraBody?: Record<string, unknown>;
524
- }
525
- /**
526
- * Generic adapter for any **OpenAI Chat Completions**-compatible
527
- * endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
528
- * Ollama, etc. It speaks `/chat/completions` (not the Responses API),
529
- * which is the dialect third-party OpenAI-compatible providers expose.
530
- *
531
- * The base URL and credential are configurable; everything else (the
532
- * `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
533
- * usage extraction) is provider-agnostic. Provider-specific request
534
- * shaping (e.g. DeepSeek's `thinking` field) is supplied by the
535
- * consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
536
- * generic and gains no per-provider subclasses.
537
- *
538
- * Was `DeepSeekChatCompletions`; generalized so consumers can point it
539
- * at any OpenAI-compatible endpoint.
540
- */
541
- declare class OpenAICompatibleChatCompletions implements ModelRuntime, StreamingRuntime {
542
- private readonly client;
543
- private readonly extraBody;
544
- constructor(config?: OpenAICompatibleConfig);
545
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
546
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
547
- buildRequest(inferenceRequest: InferenceRequest): any;
548
- extractTokenUsage(response: any): TokenUsage | undefined;
549
- mapContextToRequest(context: ModelContext): any[];
550
- extractContextItems(response: any): ContextItem[];
551
- }
552
-
553
- declare class AnthropicMessages implements ModelRuntime, StreamingRuntime {
448
+ declare class AnthropicMessages implements Endpoint {
554
449
  private readonly client;
555
450
  constructor();
556
451
  infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
557
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
452
+ stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
558
453
  private buildRequest;
559
454
  extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
560
455
  mapContextToRequest(context: ModelContext): {
@@ -570,15 +465,18 @@ type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
570
465
  declare class ClaudeOpus48 implements GenerativeModel {
571
466
  readonly specification: {
572
467
  name: string;
468
+ provider: string;
573
469
  supportReasoningEffort: boolean;
574
470
  defaultReasoningEffort: AnthropicReasoningEffortType;
575
471
  supportStreaming: boolean;
576
472
  contextWindowSize: number;
577
473
  maxOutputTokens: number;
578
474
  supportFunctionCalling: boolean;
475
+ supportStructuredOutput: boolean;
579
476
  };
580
477
  private tools;
581
478
  private streaming;
479
+ private structuredOutput;
582
480
  private readonly effort;
583
481
  setStreaming(streaming: boolean): void;
584
482
  getStreaming(): boolean;
@@ -586,20 +484,26 @@ declare class ClaudeOpus48 implements GenerativeModel {
586
484
  getTools(): Tool[];
587
485
  setReasoningEffort(effort: AnthropicReasoningEffortType): void;
588
486
  getReasoningEffort(): AnthropicReasoningEffortType;
487
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
488
+ getStructuredOutput(): StructuredOutputFormat | undefined;
489
+ hasStructuredOutput(): boolean;
589
490
  }
590
491
 
591
492
  declare class ClaudeOpus47 implements GenerativeModel {
592
493
  readonly specification: {
593
494
  name: string;
495
+ provider: string;
594
496
  supportReasoningEffort: boolean;
595
497
  defaultReasoningEffort: AnthropicReasoningEffortType;
596
498
  supportStreaming: boolean;
597
499
  contextWindowSize: number;
598
500
  maxOutputTokens: number;
599
501
  supportFunctionCalling: boolean;
502
+ supportStructuredOutput: boolean;
600
503
  };
601
504
  private tools;
602
505
  private streaming;
506
+ private structuredOutput;
603
507
  private readonly effort;
604
508
  setStreaming(streaming: boolean): void;
605
509
  getStreaming(): boolean;
@@ -607,20 +511,26 @@ declare class ClaudeOpus47 implements GenerativeModel {
607
511
  getTools(): Tool[];
608
512
  setReasoningEffort(effort: AnthropicReasoningEffortType): void;
609
513
  getReasoningEffort(): AnthropicReasoningEffortType;
514
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
515
+ getStructuredOutput(): StructuredOutputFormat | undefined;
516
+ hasStructuredOutput(): boolean;
610
517
  }
611
518
 
612
519
  declare class ClaudeSonnet46 implements GenerativeModel {
613
520
  readonly specification: {
614
521
  name: string;
522
+ provider: string;
615
523
  supportReasoningEffort: boolean;
616
524
  defaultReasoningEffort: AnthropicReasoningEffortType;
617
525
  supportStreaming: boolean;
618
526
  contextWindowSize: number;
619
527
  maxOutputTokens: number;
620
528
  supportFunctionCalling: boolean;
529
+ supportStructuredOutput: boolean;
621
530
  };
622
531
  private tools;
623
532
  private streaming;
533
+ private structuredOutput;
624
534
  setStreaming(streaming: boolean): void;
625
535
  getStreaming(): boolean;
626
536
  setTools(tools: Tool[]): void;
@@ -628,20 +538,26 @@ declare class ClaudeSonnet46 implements GenerativeModel {
628
538
  private readonly effort;
629
539
  setReasoningEffort(effort: AnthropicReasoningEffortType): void;
630
540
  getReasoningEffort(): AnthropicReasoningEffortType;
541
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
542
+ getStructuredOutput(): StructuredOutputFormat | undefined;
543
+ hasStructuredOutput(): boolean;
631
544
  }
632
545
 
633
546
  declare class ClaudeHaiku45 implements GenerativeModel {
634
547
  readonly specification: {
635
548
  name: string;
549
+ provider: string;
636
550
  supportReasoningEffort: boolean;
637
551
  defaultReasoningEffort: AnthropicReasoningEffortType;
638
552
  supportStreaming: boolean;
639
553
  contextWindowSize: number;
640
554
  maxOutputTokens: number;
641
555
  supportFunctionCalling: boolean;
556
+ supportStructuredOutput: boolean;
642
557
  };
643
558
  private tools;
644
559
  private streaming;
560
+ private structuredOutput;
645
561
  private readonly effort;
646
562
  setStreaming(streaming: boolean): void;
647
563
  getStreaming(): boolean;
@@ -649,6 +565,9 @@ declare class ClaudeHaiku45 implements GenerativeModel {
649
565
  getTools(): Tool[];
650
566
  setReasoningEffort(effort: AnthropicReasoningEffortType): void;
651
567
  getReasoningEffort(): AnthropicReasoningEffortType;
568
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
569
+ getStructuredOutput(): StructuredOutputFormat | undefined;
570
+ hasStructuredOutput(): boolean;
652
571
  }
653
572
 
654
573
  /**
@@ -661,15 +580,18 @@ type DeepSeekReasoningEffortType = "max" | "high" | "medium" | "low" | "none";
661
580
  declare class DeepSeekV4Flash implements GenerativeModel {
662
581
  readonly specification: {
663
582
  name: string;
583
+ provider: string;
664
584
  supportReasoningEffort: boolean;
665
585
  defaultReasoningEffort: DeepSeekReasoningEffortType;
666
586
  supportStreaming: boolean;
667
587
  contextWindowSize: number;
668
588
  maxOutputTokens: number;
669
589
  supportFunctionCalling: boolean;
590
+ supportStructuredOutput: boolean;
670
591
  };
671
592
  private tools;
672
593
  private streaming;
594
+ private structuredOutput;
673
595
  private readonly effort;
674
596
  setStreaming(streaming: boolean): void;
675
597
  getStreaming(): boolean;
@@ -677,20 +599,26 @@ declare class DeepSeekV4Flash implements GenerativeModel {
677
599
  getTools(): Tool[];
678
600
  setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
679
601
  getReasoningEffort(): DeepSeekReasoningEffortType;
602
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
603
+ getStructuredOutput(): StructuredOutputFormat | undefined;
604
+ hasStructuredOutput(): boolean;
680
605
  }
681
606
 
682
607
  declare class DeepSeekV4Pro implements GenerativeModel {
683
608
  readonly specification: {
684
609
  name: string;
610
+ provider: string;
685
611
  supportReasoningEffort: boolean;
686
612
  defaultReasoningEffort: DeepSeekReasoningEffortType;
687
613
  supportStreaming: boolean;
688
614
  contextWindowSize: number;
689
615
  maxOutputTokens: number;
690
616
  supportFunctionCalling: boolean;
617
+ supportStructuredOutput: boolean;
691
618
  };
692
619
  private tools;
693
620
  private streaming;
621
+ private structuredOutput;
694
622
  private readonly effort;
695
623
  setStreaming(streaming: boolean): void;
696
624
  getStreaming(): boolean;
@@ -698,6 +626,9 @@ declare class DeepSeekV4Pro implements GenerativeModel {
698
626
  getTools(): Tool[];
699
627
  setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
700
628
  getReasoningEffort(): DeepSeekReasoningEffortType;
629
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
630
+ getStructuredOutput(): StructuredOutputFormat | undefined;
631
+ hasStructuredOutput(): boolean;
701
632
  }
702
633
 
703
634
  /**
@@ -708,11 +639,11 @@ declare class DeepSeekV4Pro implements GenerativeModel {
708
639
  * thought parts + native usage metadata back out. Another `ModelRuntime`
709
640
  * — no runner or port changes.
710
641
  */
711
- declare class GeminiGenerateContent implements ModelRuntime, StreamingRuntime {
642
+ declare class GeminiGenerateContent implements Endpoint {
712
643
  private readonly client;
713
644
  constructor();
714
645
  infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
715
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
646
+ stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
716
647
  private buildRequest;
717
648
  extractTokenUsage(response: any): TokenUsage | undefined;
718
649
  mapContextToRequest(context: ModelContext): {
@@ -736,15 +667,18 @@ type GeminiReasoningEffortType = "high" | "medium" | "low" | "minimal" | "none";
736
667
  declare class Gemini35Flash implements GenerativeModel {
737
668
  readonly specification: {
738
669
  name: string;
670
+ provider: string;
739
671
  supportReasoningEffort: boolean;
740
672
  defaultReasoningEffort: GeminiReasoningEffortType;
741
673
  supportStreaming: boolean;
742
674
  contextWindowSize: number;
743
675
  maxOutputTokens: number;
744
676
  supportFunctionCalling: boolean;
677
+ supportStructuredOutput: boolean;
745
678
  };
746
679
  private tools;
747
680
  private streaming;
681
+ private structuredOutput;
748
682
  private readonly effort;
749
683
  setStreaming(streaming: boolean): void;
750
684
  getStreaming(): boolean;
@@ -752,20 +686,26 @@ declare class Gemini35Flash implements GenerativeModel {
752
686
  getTools(): Tool[];
753
687
  setReasoningEffort(effort: GeminiReasoningEffortType): void;
754
688
  getReasoningEffort(): GeminiReasoningEffortType;
689
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
690
+ getStructuredOutput(): StructuredOutputFormat | undefined;
691
+ hasStructuredOutput(): boolean;
755
692
  }
756
693
 
757
694
  declare class Gemini31Pro implements GenerativeModel {
758
695
  readonly specification: {
759
696
  name: string;
697
+ provider: string;
760
698
  supportReasoningEffort: boolean;
761
699
  defaultReasoningEffort: GeminiReasoningEffortType;
762
700
  supportStreaming: boolean;
763
701
  contextWindowSize: number;
764
702
  maxOutputTokens: number;
765
703
  supportFunctionCalling: boolean;
704
+ supportStructuredOutput: boolean;
766
705
  };
767
706
  private tools;
768
707
  private streaming;
708
+ private structuredOutput;
769
709
  private readonly effort;
770
710
  setStreaming(streaming: boolean): void;
771
711
  getStreaming(): boolean;
@@ -773,6 +713,94 @@ declare class Gemini31Pro implements GenerativeModel {
773
713
  getTools(): Tool[];
774
714
  setReasoningEffort(effort: GeminiReasoningEffortType): void;
775
715
  getReasoningEffort(): GeminiReasoningEffortType;
716
+ setStructuredOutput(format: StructuredOutputFormat | undefined): void;
717
+ getStructuredOutput(): StructuredOutputFormat | undefined;
718
+ hasStructuredOutput(): boolean;
719
+ }
720
+
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[];
768
+ }
769
+
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
+ 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;
792
+ onJoined(): void;
793
+ 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;
776
800
  }
777
801
 
778
- export { Agent, AgenticEnvironment, AnthropicMessages, BaseAgent, BaseHuman, BaseObserver, ClaudeHaiku45, ClaudeOpus47, ClaudeOpus48, ClaudeSonnet46, ContextItem, DeepSeekV4Flash, DeepSeekV4Pro, DefaultFunctionCallRunner, DefaultInferenceRunner, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type FunctionCallRunner, Gemini31Pro, Gemini35Flash, GeminiGenerateContent, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, Human, InMemoryModelContextRepository, InferenceRequest, InferenceResponse, type InferenceRunner, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, type ModelRuntime, Observer, OpenAICompatibleChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StreamingRuntime, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
802
+ declare const runInference: (inferenceParams: InferenceParams) => void;
803
+ declare const executeFunctionCall: (environment: AgenticEnvironment, functionCallItem: FunctionCallItem, tool: Tool, caller: Participant) => void;
804
+ declare const sendMessage: (environment: AgenticEnvironment, message: string, caller: Participant) => void;
805
+
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 };