@mozaik-ai/core 3.11.0 → 3.12.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 +214 -15
- package/dist/index.d.ts +214 -15
- package/dist/index.js +593 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +585 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -1
package/dist/index.d.mts
CHANGED
|
@@ -193,8 +193,8 @@ declare class Gpt54Nano implements GenerativeModel {
|
|
|
193
193
|
supportFunctionCalling: boolean;
|
|
194
194
|
};
|
|
195
195
|
private tools;
|
|
196
|
-
private readonly effort;
|
|
197
196
|
private streaming;
|
|
197
|
+
private readonly effort;
|
|
198
198
|
setStreaming(streaming: boolean): void;
|
|
199
199
|
getStreaming(): boolean;
|
|
200
200
|
setTools(tools: Tool[]): void;
|
|
@@ -215,11 +215,11 @@ declare class Gpt54 implements GenerativeModel {
|
|
|
215
215
|
};
|
|
216
216
|
private tools;
|
|
217
217
|
private streaming;
|
|
218
|
+
private readonly effort;
|
|
218
219
|
setStreaming(streaming: boolean): void;
|
|
219
220
|
getStreaming(): boolean;
|
|
220
221
|
setTools(tools: Tool[]): void;
|
|
221
222
|
getTools(): Tool[];
|
|
222
|
-
private readonly effort;
|
|
223
223
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
224
224
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
225
225
|
}
|
|
@@ -235,8 +235,8 @@ declare class Gpt54Mini implements GenerativeModel {
|
|
|
235
235
|
supportFunctionCalling: boolean;
|
|
236
236
|
};
|
|
237
237
|
private tools;
|
|
238
|
-
private readonly effort;
|
|
239
238
|
private streaming;
|
|
239
|
+
private readonly effort;
|
|
240
240
|
setStreaming(streaming: boolean): void;
|
|
241
241
|
getStreaming(): boolean;
|
|
242
242
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
@@ -292,7 +292,9 @@ declare class SemanticEvent<T> {
|
|
|
292
292
|
|
|
293
293
|
declare class AgenticEnvironment {
|
|
294
294
|
protected subscribers: Participant[];
|
|
295
|
+
private name?;
|
|
295
296
|
private isActive;
|
|
297
|
+
constructor(name?: string);
|
|
296
298
|
subscribe(participant: Participant): void;
|
|
297
299
|
unsubscribe(participant: Participant): void;
|
|
298
300
|
deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
|
|
@@ -301,16 +303,21 @@ declare class AgenticEnvironment {
|
|
|
301
303
|
deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
|
|
302
304
|
deliverMessage(source: Participant, message: string): void;
|
|
303
305
|
deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
|
|
306
|
+
private getListeningParticipants;
|
|
307
|
+
private deliverToSubscribers;
|
|
304
308
|
start(): Promise<void>;
|
|
305
309
|
stop(): void;
|
|
306
310
|
}
|
|
307
311
|
|
|
312
|
+
type ParticipantClassConstructor = new (...args: any[]) => Participant;
|
|
308
313
|
declare abstract class Participant {
|
|
309
314
|
private environments;
|
|
315
|
+
protected listens: ParticipantClassConstructor[];
|
|
310
316
|
join(environment: AgenticEnvironment): void;
|
|
311
317
|
leave(environment: AgenticEnvironment): void;
|
|
312
318
|
protected isJoinedTo(environment: AgenticEnvironment): boolean;
|
|
313
319
|
getEnvironments(): AgenticEnvironment[];
|
|
320
|
+
getListeners(): ParticipantClassConstructor[];
|
|
314
321
|
abstract onParticipantJoined(participant: Participant): Promise<void> | void;
|
|
315
322
|
abstract onParticipantLeft(participant: Participant): Promise<void> | void;
|
|
316
323
|
abstract onJoined(): Promise<void> | void;
|
|
@@ -413,16 +420,12 @@ interface ModelRuntime {
|
|
|
413
420
|
|
|
414
421
|
type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>;
|
|
415
422
|
/**
|
|
416
|
-
*
|
|
423
|
+
* Provider-agnostic inference runner: it depends on
|
|
417
424
|
* the {@link ModelRuntime} domain port and receives a concrete
|
|
418
425
|
* infrastructure adapter (OpenAIResponses, AnthropicMessages, …)
|
|
419
|
-
* through its constructor.
|
|
420
|
-
* client itself — wiring happens at the composition root.
|
|
421
|
-
*
|
|
422
|
-
* Name retained for backward compatibility; the runner works with any
|
|
423
|
-
* `ModelRuntime`, not just OpenAI.
|
|
426
|
+
* through its constructor.
|
|
424
427
|
*/
|
|
425
|
-
declare class
|
|
428
|
+
declare class DefaultInferenceRunner implements InferenceRunner {
|
|
426
429
|
private readonly runtime;
|
|
427
430
|
constructor(runtime: ModelRuntime);
|
|
428
431
|
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem>;
|
|
@@ -447,11 +450,11 @@ declare class Gpt55 implements GenerativeModel {
|
|
|
447
450
|
};
|
|
448
451
|
private tools;
|
|
449
452
|
private streaming;
|
|
453
|
+
private readonly effort;
|
|
450
454
|
setStreaming(streaming: boolean): void;
|
|
451
455
|
getStreaming(): boolean;
|
|
452
456
|
setTools(tools: Tool[]): void;
|
|
453
457
|
getTools(): Tool[];
|
|
454
|
-
private readonly effort;
|
|
455
458
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
456
459
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
457
460
|
}
|
|
@@ -498,10 +501,61 @@ declare class OpenAIResponses implements ModelRuntime, StreamingRuntime {
|
|
|
498
501
|
extractContextItems(response: any): ContextItem[];
|
|
499
502
|
}
|
|
500
503
|
|
|
501
|
-
|
|
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 {
|
|
502
554
|
private readonly client;
|
|
503
555
|
constructor();
|
|
504
556
|
infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
|
|
557
|
+
stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
|
|
558
|
+
private buildRequest;
|
|
505
559
|
extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
|
|
506
560
|
mapContextToRequest(context: ModelContext): {
|
|
507
561
|
messages: any[];
|
|
@@ -513,7 +567,7 @@ declare class AnthropicMessages implements ModelRuntime {
|
|
|
513
567
|
|
|
514
568
|
type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
|
|
515
569
|
|
|
516
|
-
declare class
|
|
570
|
+
declare class ClaudeOpus48 implements GenerativeModel {
|
|
517
571
|
readonly specification: {
|
|
518
572
|
name: string;
|
|
519
573
|
supportReasoningEffort: boolean;
|
|
@@ -525,11 +579,32 @@ declare class ClaudeOpus47 implements GenerativeModel {
|
|
|
525
579
|
};
|
|
526
580
|
private tools;
|
|
527
581
|
private streaming;
|
|
582
|
+
private readonly effort;
|
|
528
583
|
setStreaming(streaming: boolean): void;
|
|
529
584
|
getStreaming(): boolean;
|
|
530
585
|
setTools(tools: Tool[]): void;
|
|
531
586
|
getTools(): Tool[];
|
|
587
|
+
setReasoningEffort(effort: AnthropicReasoningEffortType): void;
|
|
588
|
+
getReasoningEffort(): AnthropicReasoningEffortType;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
declare class ClaudeOpus47 implements GenerativeModel {
|
|
592
|
+
readonly specification: {
|
|
593
|
+
name: string;
|
|
594
|
+
supportReasoningEffort: boolean;
|
|
595
|
+
defaultReasoningEffort: AnthropicReasoningEffortType;
|
|
596
|
+
supportStreaming: boolean;
|
|
597
|
+
contextWindowSize: number;
|
|
598
|
+
maxOutputTokens: number;
|
|
599
|
+
supportFunctionCalling: boolean;
|
|
600
|
+
};
|
|
601
|
+
private tools;
|
|
602
|
+
private streaming;
|
|
532
603
|
private readonly effort;
|
|
604
|
+
setStreaming(streaming: boolean): void;
|
|
605
|
+
getStreaming(): boolean;
|
|
606
|
+
setTools(tools: Tool[]): void;
|
|
607
|
+
getTools(): Tool[];
|
|
533
608
|
setReasoningEffort(effort: AnthropicReasoningEffortType): void;
|
|
534
609
|
getReasoningEffort(): AnthropicReasoningEffortType;
|
|
535
610
|
}
|
|
@@ -567,13 +642,137 @@ declare class ClaudeHaiku45 implements GenerativeModel {
|
|
|
567
642
|
};
|
|
568
643
|
private tools;
|
|
569
644
|
private streaming;
|
|
645
|
+
private readonly effort;
|
|
570
646
|
setStreaming(streaming: boolean): void;
|
|
571
647
|
getStreaming(): boolean;
|
|
572
648
|
setTools(tools: Tool[]): void;
|
|
573
649
|
getTools(): Tool[];
|
|
574
|
-
private readonly effort;
|
|
575
650
|
setReasoningEffort(effort: AnthropicReasoningEffortType): void;
|
|
576
651
|
getReasoningEffort(): AnthropicReasoningEffortType;
|
|
577
652
|
}
|
|
578
653
|
|
|
579
|
-
|
|
654
|
+
/**
|
|
655
|
+
* DeepSeek V4 reasoning levels. `"none"` selects non-thinking mode
|
|
656
|
+
* (`thinking: { type: "disabled" }`); any other value enables thinking
|
|
657
|
+
* mode and is forwarded as the `reasoning_effort` request parameter.
|
|
658
|
+
*/
|
|
659
|
+
type DeepSeekReasoningEffortType = "max" | "high" | "medium" | "low" | "none";
|
|
660
|
+
|
|
661
|
+
declare class DeepSeekV4Flash implements GenerativeModel {
|
|
662
|
+
readonly specification: {
|
|
663
|
+
name: string;
|
|
664
|
+
supportReasoningEffort: boolean;
|
|
665
|
+
defaultReasoningEffort: DeepSeekReasoningEffortType;
|
|
666
|
+
supportStreaming: boolean;
|
|
667
|
+
contextWindowSize: number;
|
|
668
|
+
maxOutputTokens: number;
|
|
669
|
+
supportFunctionCalling: boolean;
|
|
670
|
+
};
|
|
671
|
+
private tools;
|
|
672
|
+
private streaming;
|
|
673
|
+
private readonly effort;
|
|
674
|
+
setStreaming(streaming: boolean): void;
|
|
675
|
+
getStreaming(): boolean;
|
|
676
|
+
setTools(tools: Tool[]): void;
|
|
677
|
+
getTools(): Tool[];
|
|
678
|
+
setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
|
|
679
|
+
getReasoningEffort(): DeepSeekReasoningEffortType;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
declare class DeepSeekV4Pro implements GenerativeModel {
|
|
683
|
+
readonly specification: {
|
|
684
|
+
name: string;
|
|
685
|
+
supportReasoningEffort: boolean;
|
|
686
|
+
defaultReasoningEffort: DeepSeekReasoningEffortType;
|
|
687
|
+
supportStreaming: boolean;
|
|
688
|
+
contextWindowSize: number;
|
|
689
|
+
maxOutputTokens: number;
|
|
690
|
+
supportFunctionCalling: boolean;
|
|
691
|
+
};
|
|
692
|
+
private tools;
|
|
693
|
+
private streaming;
|
|
694
|
+
private readonly effort;
|
|
695
|
+
setStreaming(streaming: boolean): void;
|
|
696
|
+
getStreaming(): boolean;
|
|
697
|
+
setTools(tools: Tool[]): void;
|
|
698
|
+
getTools(): Tool[];
|
|
699
|
+
setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
|
|
700
|
+
getReasoningEffort(): DeepSeekReasoningEffortType;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
|
|
705
|
+
* `generateContentStream`). Unlike an OpenAI-compat shim this maps our
|
|
706
|
+
* domain context to Gemini's native `contents`/`parts` shape, system
|
|
707
|
+
* instruction, `functionDeclarations`, and `thinkingConfig`, and reads
|
|
708
|
+
* thought parts + native usage metadata back out. Another `ModelRuntime`
|
|
709
|
+
* — no runner or port changes.
|
|
710
|
+
*/
|
|
711
|
+
declare class GeminiGenerateContent implements ModelRuntime, StreamingRuntime {
|
|
712
|
+
private readonly client;
|
|
713
|
+
constructor();
|
|
714
|
+
infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
|
|
715
|
+
stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
|
|
716
|
+
private buildRequest;
|
|
717
|
+
extractTokenUsage(response: any): TokenUsage | undefined;
|
|
718
|
+
mapContextToRequest(context: ModelContext): {
|
|
719
|
+
contents: any[];
|
|
720
|
+
systemInstruction?: string;
|
|
721
|
+
};
|
|
722
|
+
extractContextItems(response: any): ContextItem[];
|
|
723
|
+
private parseResponse;
|
|
724
|
+
private addPart;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Gemini reasoning levels, forwarded as the `reasoning_effort` request
|
|
729
|
+
* parameter on the OpenAI-compatible endpoint. `"none"` only disables
|
|
730
|
+
* thinking on Gemini 2.5 models; Gemini 3.x always thinks, so for those
|
|
731
|
+
* the adapter simply omits `reasoning_effort` when set to `"none"` and
|
|
732
|
+
* lets the model use its default thinking level.
|
|
733
|
+
*/
|
|
734
|
+
type GeminiReasoningEffortType = "high" | "medium" | "low" | "minimal" | "none";
|
|
735
|
+
|
|
736
|
+
declare class Gemini35Flash implements GenerativeModel {
|
|
737
|
+
readonly specification: {
|
|
738
|
+
name: string;
|
|
739
|
+
supportReasoningEffort: boolean;
|
|
740
|
+
defaultReasoningEffort: GeminiReasoningEffortType;
|
|
741
|
+
supportStreaming: boolean;
|
|
742
|
+
contextWindowSize: number;
|
|
743
|
+
maxOutputTokens: number;
|
|
744
|
+
supportFunctionCalling: boolean;
|
|
745
|
+
};
|
|
746
|
+
private tools;
|
|
747
|
+
private streaming;
|
|
748
|
+
private readonly effort;
|
|
749
|
+
setStreaming(streaming: boolean): void;
|
|
750
|
+
getStreaming(): boolean;
|
|
751
|
+
setTools(tools: Tool[]): void;
|
|
752
|
+
getTools(): Tool[];
|
|
753
|
+
setReasoningEffort(effort: GeminiReasoningEffortType): void;
|
|
754
|
+
getReasoningEffort(): GeminiReasoningEffortType;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
declare class Gemini31Pro implements GenerativeModel {
|
|
758
|
+
readonly specification: {
|
|
759
|
+
name: string;
|
|
760
|
+
supportReasoningEffort: boolean;
|
|
761
|
+
defaultReasoningEffort: GeminiReasoningEffortType;
|
|
762
|
+
supportStreaming: boolean;
|
|
763
|
+
contextWindowSize: number;
|
|
764
|
+
maxOutputTokens: number;
|
|
765
|
+
supportFunctionCalling: boolean;
|
|
766
|
+
};
|
|
767
|
+
private tools;
|
|
768
|
+
private streaming;
|
|
769
|
+
private readonly effort;
|
|
770
|
+
setStreaming(streaming: boolean): void;
|
|
771
|
+
getStreaming(): boolean;
|
|
772
|
+
setTools(tools: Tool[]): void;
|
|
773
|
+
getTools(): Tool[];
|
|
774
|
+
setReasoningEffort(effort: GeminiReasoningEffortType): void;
|
|
775
|
+
getReasoningEffort(): GeminiReasoningEffortType;
|
|
776
|
+
}
|
|
777
|
+
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -193,8 +193,8 @@ declare class Gpt54Nano implements GenerativeModel {
|
|
|
193
193
|
supportFunctionCalling: boolean;
|
|
194
194
|
};
|
|
195
195
|
private tools;
|
|
196
|
-
private readonly effort;
|
|
197
196
|
private streaming;
|
|
197
|
+
private readonly effort;
|
|
198
198
|
setStreaming(streaming: boolean): void;
|
|
199
199
|
getStreaming(): boolean;
|
|
200
200
|
setTools(tools: Tool[]): void;
|
|
@@ -215,11 +215,11 @@ declare class Gpt54 implements GenerativeModel {
|
|
|
215
215
|
};
|
|
216
216
|
private tools;
|
|
217
217
|
private streaming;
|
|
218
|
+
private readonly effort;
|
|
218
219
|
setStreaming(streaming: boolean): void;
|
|
219
220
|
getStreaming(): boolean;
|
|
220
221
|
setTools(tools: Tool[]): void;
|
|
221
222
|
getTools(): Tool[];
|
|
222
|
-
private readonly effort;
|
|
223
223
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
224
224
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
225
225
|
}
|
|
@@ -235,8 +235,8 @@ declare class Gpt54Mini implements GenerativeModel {
|
|
|
235
235
|
supportFunctionCalling: boolean;
|
|
236
236
|
};
|
|
237
237
|
private tools;
|
|
238
|
-
private readonly effort;
|
|
239
238
|
private streaming;
|
|
239
|
+
private readonly effort;
|
|
240
240
|
setStreaming(streaming: boolean): void;
|
|
241
241
|
getStreaming(): boolean;
|
|
242
242
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
@@ -292,7 +292,9 @@ declare class SemanticEvent<T> {
|
|
|
292
292
|
|
|
293
293
|
declare class AgenticEnvironment {
|
|
294
294
|
protected subscribers: Participant[];
|
|
295
|
+
private name?;
|
|
295
296
|
private isActive;
|
|
297
|
+
constructor(name?: string);
|
|
296
298
|
subscribe(participant: Participant): void;
|
|
297
299
|
unsubscribe(participant: Participant): void;
|
|
298
300
|
deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
|
|
@@ -301,16 +303,21 @@ declare class AgenticEnvironment {
|
|
|
301
303
|
deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
|
|
302
304
|
deliverMessage(source: Participant, message: string): void;
|
|
303
305
|
deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
|
|
306
|
+
private getListeningParticipants;
|
|
307
|
+
private deliverToSubscribers;
|
|
304
308
|
start(): Promise<void>;
|
|
305
309
|
stop(): void;
|
|
306
310
|
}
|
|
307
311
|
|
|
312
|
+
type ParticipantClassConstructor = new (...args: any[]) => Participant;
|
|
308
313
|
declare abstract class Participant {
|
|
309
314
|
private environments;
|
|
315
|
+
protected listens: ParticipantClassConstructor[];
|
|
310
316
|
join(environment: AgenticEnvironment): void;
|
|
311
317
|
leave(environment: AgenticEnvironment): void;
|
|
312
318
|
protected isJoinedTo(environment: AgenticEnvironment): boolean;
|
|
313
319
|
getEnvironments(): AgenticEnvironment[];
|
|
320
|
+
getListeners(): ParticipantClassConstructor[];
|
|
314
321
|
abstract onParticipantJoined(participant: Participant): Promise<void> | void;
|
|
315
322
|
abstract onParticipantLeft(participant: Participant): Promise<void> | void;
|
|
316
323
|
abstract onJoined(): Promise<void> | void;
|
|
@@ -413,16 +420,12 @@ interface ModelRuntime {
|
|
|
413
420
|
|
|
414
421
|
type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>;
|
|
415
422
|
/**
|
|
416
|
-
*
|
|
423
|
+
* Provider-agnostic inference runner: it depends on
|
|
417
424
|
* the {@link ModelRuntime} domain port and receives a concrete
|
|
418
425
|
* infrastructure adapter (OpenAIResponses, AnthropicMessages, …)
|
|
419
|
-
* through its constructor.
|
|
420
|
-
* client itself — wiring happens at the composition root.
|
|
421
|
-
*
|
|
422
|
-
* Name retained for backward compatibility; the runner works with any
|
|
423
|
-
* `ModelRuntime`, not just OpenAI.
|
|
426
|
+
* through its constructor.
|
|
424
427
|
*/
|
|
425
|
-
declare class
|
|
428
|
+
declare class DefaultInferenceRunner implements InferenceRunner {
|
|
426
429
|
private readonly runtime;
|
|
427
430
|
constructor(runtime: ModelRuntime);
|
|
428
431
|
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem>;
|
|
@@ -447,11 +450,11 @@ declare class Gpt55 implements GenerativeModel {
|
|
|
447
450
|
};
|
|
448
451
|
private tools;
|
|
449
452
|
private streaming;
|
|
453
|
+
private readonly effort;
|
|
450
454
|
setStreaming(streaming: boolean): void;
|
|
451
455
|
getStreaming(): boolean;
|
|
452
456
|
setTools(tools: Tool[]): void;
|
|
453
457
|
getTools(): Tool[];
|
|
454
|
-
private readonly effort;
|
|
455
458
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
456
459
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
457
460
|
}
|
|
@@ -498,10 +501,61 @@ declare class OpenAIResponses implements ModelRuntime, StreamingRuntime {
|
|
|
498
501
|
extractContextItems(response: any): ContextItem[];
|
|
499
502
|
}
|
|
500
503
|
|
|
501
|
-
|
|
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 {
|
|
502
554
|
private readonly client;
|
|
503
555
|
constructor();
|
|
504
556
|
infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
|
|
557
|
+
stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
|
|
558
|
+
private buildRequest;
|
|
505
559
|
extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
|
|
506
560
|
mapContextToRequest(context: ModelContext): {
|
|
507
561
|
messages: any[];
|
|
@@ -513,7 +567,7 @@ declare class AnthropicMessages implements ModelRuntime {
|
|
|
513
567
|
|
|
514
568
|
type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
|
|
515
569
|
|
|
516
|
-
declare class
|
|
570
|
+
declare class ClaudeOpus48 implements GenerativeModel {
|
|
517
571
|
readonly specification: {
|
|
518
572
|
name: string;
|
|
519
573
|
supportReasoningEffort: boolean;
|
|
@@ -525,11 +579,32 @@ declare class ClaudeOpus47 implements GenerativeModel {
|
|
|
525
579
|
};
|
|
526
580
|
private tools;
|
|
527
581
|
private streaming;
|
|
582
|
+
private readonly effort;
|
|
528
583
|
setStreaming(streaming: boolean): void;
|
|
529
584
|
getStreaming(): boolean;
|
|
530
585
|
setTools(tools: Tool[]): void;
|
|
531
586
|
getTools(): Tool[];
|
|
587
|
+
setReasoningEffort(effort: AnthropicReasoningEffortType): void;
|
|
588
|
+
getReasoningEffort(): AnthropicReasoningEffortType;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
declare class ClaudeOpus47 implements GenerativeModel {
|
|
592
|
+
readonly specification: {
|
|
593
|
+
name: string;
|
|
594
|
+
supportReasoningEffort: boolean;
|
|
595
|
+
defaultReasoningEffort: AnthropicReasoningEffortType;
|
|
596
|
+
supportStreaming: boolean;
|
|
597
|
+
contextWindowSize: number;
|
|
598
|
+
maxOutputTokens: number;
|
|
599
|
+
supportFunctionCalling: boolean;
|
|
600
|
+
};
|
|
601
|
+
private tools;
|
|
602
|
+
private streaming;
|
|
532
603
|
private readonly effort;
|
|
604
|
+
setStreaming(streaming: boolean): void;
|
|
605
|
+
getStreaming(): boolean;
|
|
606
|
+
setTools(tools: Tool[]): void;
|
|
607
|
+
getTools(): Tool[];
|
|
533
608
|
setReasoningEffort(effort: AnthropicReasoningEffortType): void;
|
|
534
609
|
getReasoningEffort(): AnthropicReasoningEffortType;
|
|
535
610
|
}
|
|
@@ -567,13 +642,137 @@ declare class ClaudeHaiku45 implements GenerativeModel {
|
|
|
567
642
|
};
|
|
568
643
|
private tools;
|
|
569
644
|
private streaming;
|
|
645
|
+
private readonly effort;
|
|
570
646
|
setStreaming(streaming: boolean): void;
|
|
571
647
|
getStreaming(): boolean;
|
|
572
648
|
setTools(tools: Tool[]): void;
|
|
573
649
|
getTools(): Tool[];
|
|
574
|
-
private readonly effort;
|
|
575
650
|
setReasoningEffort(effort: AnthropicReasoningEffortType): void;
|
|
576
651
|
getReasoningEffort(): AnthropicReasoningEffortType;
|
|
577
652
|
}
|
|
578
653
|
|
|
579
|
-
|
|
654
|
+
/**
|
|
655
|
+
* DeepSeek V4 reasoning levels. `"none"` selects non-thinking mode
|
|
656
|
+
* (`thinking: { type: "disabled" }`); any other value enables thinking
|
|
657
|
+
* mode and is forwarded as the `reasoning_effort` request parameter.
|
|
658
|
+
*/
|
|
659
|
+
type DeepSeekReasoningEffortType = "max" | "high" | "medium" | "low" | "none";
|
|
660
|
+
|
|
661
|
+
declare class DeepSeekV4Flash implements GenerativeModel {
|
|
662
|
+
readonly specification: {
|
|
663
|
+
name: string;
|
|
664
|
+
supportReasoningEffort: boolean;
|
|
665
|
+
defaultReasoningEffort: DeepSeekReasoningEffortType;
|
|
666
|
+
supportStreaming: boolean;
|
|
667
|
+
contextWindowSize: number;
|
|
668
|
+
maxOutputTokens: number;
|
|
669
|
+
supportFunctionCalling: boolean;
|
|
670
|
+
};
|
|
671
|
+
private tools;
|
|
672
|
+
private streaming;
|
|
673
|
+
private readonly effort;
|
|
674
|
+
setStreaming(streaming: boolean): void;
|
|
675
|
+
getStreaming(): boolean;
|
|
676
|
+
setTools(tools: Tool[]): void;
|
|
677
|
+
getTools(): Tool[];
|
|
678
|
+
setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
|
|
679
|
+
getReasoningEffort(): DeepSeekReasoningEffortType;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
declare class DeepSeekV4Pro implements GenerativeModel {
|
|
683
|
+
readonly specification: {
|
|
684
|
+
name: string;
|
|
685
|
+
supportReasoningEffort: boolean;
|
|
686
|
+
defaultReasoningEffort: DeepSeekReasoningEffortType;
|
|
687
|
+
supportStreaming: boolean;
|
|
688
|
+
contextWindowSize: number;
|
|
689
|
+
maxOutputTokens: number;
|
|
690
|
+
supportFunctionCalling: boolean;
|
|
691
|
+
};
|
|
692
|
+
private tools;
|
|
693
|
+
private streaming;
|
|
694
|
+
private readonly effort;
|
|
695
|
+
setStreaming(streaming: boolean): void;
|
|
696
|
+
getStreaming(): boolean;
|
|
697
|
+
setTools(tools: Tool[]): void;
|
|
698
|
+
getTools(): Tool[];
|
|
699
|
+
setReasoningEffort(effort: DeepSeekReasoningEffortType): void;
|
|
700
|
+
getReasoningEffort(): DeepSeekReasoningEffortType;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
|
|
705
|
+
* `generateContentStream`). Unlike an OpenAI-compat shim this maps our
|
|
706
|
+
* domain context to Gemini's native `contents`/`parts` shape, system
|
|
707
|
+
* instruction, `functionDeclarations`, and `thinkingConfig`, and reads
|
|
708
|
+
* thought parts + native usage metadata back out. Another `ModelRuntime`
|
|
709
|
+
* — no runner or port changes.
|
|
710
|
+
*/
|
|
711
|
+
declare class GeminiGenerateContent implements ModelRuntime, StreamingRuntime {
|
|
712
|
+
private readonly client;
|
|
713
|
+
constructor();
|
|
714
|
+
infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
|
|
715
|
+
stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
|
|
716
|
+
private buildRequest;
|
|
717
|
+
extractTokenUsage(response: any): TokenUsage | undefined;
|
|
718
|
+
mapContextToRequest(context: ModelContext): {
|
|
719
|
+
contents: any[];
|
|
720
|
+
systemInstruction?: string;
|
|
721
|
+
};
|
|
722
|
+
extractContextItems(response: any): ContextItem[];
|
|
723
|
+
private parseResponse;
|
|
724
|
+
private addPart;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Gemini reasoning levels, forwarded as the `reasoning_effort` request
|
|
729
|
+
* parameter on the OpenAI-compatible endpoint. `"none"` only disables
|
|
730
|
+
* thinking on Gemini 2.5 models; Gemini 3.x always thinks, so for those
|
|
731
|
+
* the adapter simply omits `reasoning_effort` when set to `"none"` and
|
|
732
|
+
* lets the model use its default thinking level.
|
|
733
|
+
*/
|
|
734
|
+
type GeminiReasoningEffortType = "high" | "medium" | "low" | "minimal" | "none";
|
|
735
|
+
|
|
736
|
+
declare class Gemini35Flash implements GenerativeModel {
|
|
737
|
+
readonly specification: {
|
|
738
|
+
name: string;
|
|
739
|
+
supportReasoningEffort: boolean;
|
|
740
|
+
defaultReasoningEffort: GeminiReasoningEffortType;
|
|
741
|
+
supportStreaming: boolean;
|
|
742
|
+
contextWindowSize: number;
|
|
743
|
+
maxOutputTokens: number;
|
|
744
|
+
supportFunctionCalling: boolean;
|
|
745
|
+
};
|
|
746
|
+
private tools;
|
|
747
|
+
private streaming;
|
|
748
|
+
private readonly effort;
|
|
749
|
+
setStreaming(streaming: boolean): void;
|
|
750
|
+
getStreaming(): boolean;
|
|
751
|
+
setTools(tools: Tool[]): void;
|
|
752
|
+
getTools(): Tool[];
|
|
753
|
+
setReasoningEffort(effort: GeminiReasoningEffortType): void;
|
|
754
|
+
getReasoningEffort(): GeminiReasoningEffortType;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
declare class Gemini31Pro implements GenerativeModel {
|
|
758
|
+
readonly specification: {
|
|
759
|
+
name: string;
|
|
760
|
+
supportReasoningEffort: boolean;
|
|
761
|
+
defaultReasoningEffort: GeminiReasoningEffortType;
|
|
762
|
+
supportStreaming: boolean;
|
|
763
|
+
contextWindowSize: number;
|
|
764
|
+
maxOutputTokens: number;
|
|
765
|
+
supportFunctionCalling: boolean;
|
|
766
|
+
};
|
|
767
|
+
private tools;
|
|
768
|
+
private streaming;
|
|
769
|
+
private readonly effort;
|
|
770
|
+
setStreaming(streaming: boolean): void;
|
|
771
|
+
getStreaming(): boolean;
|
|
772
|
+
setTools(tools: Tool[]): void;
|
|
773
|
+
getTools(): Tool[];
|
|
774
|
+
setReasoningEffort(effort: GeminiReasoningEffortType): void;
|
|
775
|
+
getReasoningEffort(): GeminiReasoningEffortType;
|
|
776
|
+
}
|
|
777
|
+
|
|
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 };
|