@mozaik-ai/core 3.10.3 → 3.11.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
@@ -1,4 +1,5 @@
1
1
  import OpenAI from 'openai';
2
+ import Anthropic from '@anthropic-ai/sdk';
2
3
 
3
4
  declare abstract class ContextItem {
4
5
  abstract readonly type: string;
@@ -385,12 +386,47 @@ declare class BaseHuman extends Human {
385
386
  onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
386
387
  }
387
388
 
389
+ declare class InferenceRequest {
390
+ readonly model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability;
391
+ readonly context: ModelContext;
392
+ constructor(model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext);
393
+ }
394
+
395
+ declare class InferenceResponse {
396
+ readonly contextItems: ContextItem[];
397
+ readonly tokenUsage?: TokenUsage;
398
+ constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
399
+ }
400
+
401
+ /**
402
+ * Provider-agnostic port for a single round of inference.
403
+ *
404
+ * Lives in the domain layer; concrete adapters (OpenAI Responses,
405
+ * Anthropic Messages, DeepSeek Chat Completions, …) live in the
406
+ * infrastructure layer and are injected into application-layer runners
407
+ * through their constructor. The application layer must depend on this
408
+ * interface, never on a concrete provider client.
409
+ */
410
+ interface ModelRuntime {
411
+ infer(request: InferenceRequest): Promise<InferenceResponse>;
412
+ }
413
+
388
414
  type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>;
415
+ /**
416
+ * Application-layer inference runner. Provider-agnostic: it depends on
417
+ * the {@link ModelRuntime} domain port and receives a concrete
418
+ * infrastructure adapter (OpenAIResponses, AnthropicMessages, …)
419
+ * through its constructor. The runner never instantiates a provider
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.
424
+ */
389
425
  declare class OpenAIInferenceRunner implements InferenceRunner {
426
+ private readonly runtime;
427
+ constructor(runtime: ModelRuntime);
390
428
  run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem>;
391
- extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
392
- mapContextToRequest(context: ModelContext): any[];
393
- extractContextItems(response: any): ContextItem[];
429
+ private isStreamingRuntime;
394
430
  }
395
431
 
396
432
  declare class DefaultFunctionCallRunner implements FunctionCallRunner {
@@ -441,4 +477,103 @@ declare class BaseObserver extends Observer {
441
477
  onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
442
478
  }
443
479
 
444
- export { Agent, AgenticEnvironment, BaseAgent, BaseHuman, BaseObserver, ContextItem, DefaultFunctionCallRunner, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type FunctionCallRunner, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, Human, InMemoryModelContextRepository, type InferenceRunner, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, Observer, OpenAIInferenceRunner, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
480
+ /**
481
+ * Optional streaming companion to {@link ModelRuntime}. Adapters whose
482
+ * provider can stream a round implement this in addition to
483
+ * `ModelRuntime`; runners delegate to `stream` only when the model has
484
+ * streaming enabled and the injected runtime actually implements it.
485
+ */
486
+ interface StreamingRuntime {
487
+ stream(request: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
488
+ }
489
+
490
+ declare class OpenAIResponses implements ModelRuntime, StreamingRuntime {
491
+ private readonly client;
492
+ constructor();
493
+ infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
494
+ stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
495
+ private buildRequest;
496
+ extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
497
+ mapContextToRequest(context: ModelContext): any[];
498
+ extractContextItems(response: any): ContextItem[];
499
+ }
500
+
501
+ declare class AnthropicMessages implements ModelRuntime {
502
+ private readonly client;
503
+ constructor();
504
+ infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
505
+ extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
506
+ mapContextToRequest(context: ModelContext): {
507
+ messages: any[];
508
+ system?: string;
509
+ };
510
+ extractContextItems(response: Anthropic.Messages.Message): ContextItem[];
511
+ private addContentBlock;
512
+ }
513
+
514
+ type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
515
+
516
+ declare class ClaudeOpus47 implements GenerativeModel {
517
+ readonly specification: {
518
+ name: string;
519
+ supportReasoningEffort: boolean;
520
+ defaultReasoningEffort: AnthropicReasoningEffortType;
521
+ supportStreaming: boolean;
522
+ contextWindowSize: number;
523
+ maxOutputTokens: number;
524
+ supportFunctionCalling: boolean;
525
+ };
526
+ private tools;
527
+ private streaming;
528
+ setStreaming(streaming: boolean): void;
529
+ getStreaming(): boolean;
530
+ setTools(tools: Tool[]): void;
531
+ getTools(): Tool[];
532
+ private readonly effort;
533
+ setReasoningEffort(effort: AnthropicReasoningEffortType): void;
534
+ getReasoningEffort(): AnthropicReasoningEffortType;
535
+ }
536
+
537
+ declare class ClaudeSonnet46 implements GenerativeModel {
538
+ readonly specification: {
539
+ name: string;
540
+ supportReasoningEffort: boolean;
541
+ defaultReasoningEffort: AnthropicReasoningEffortType;
542
+ supportStreaming: boolean;
543
+ contextWindowSize: number;
544
+ maxOutputTokens: number;
545
+ supportFunctionCalling: boolean;
546
+ };
547
+ private tools;
548
+ private streaming;
549
+ setStreaming(streaming: boolean): void;
550
+ getStreaming(): boolean;
551
+ setTools(tools: Tool[]): void;
552
+ getTools(): Tool[];
553
+ private readonly effort;
554
+ setReasoningEffort(effort: AnthropicReasoningEffortType): void;
555
+ getReasoningEffort(): AnthropicReasoningEffortType;
556
+ }
557
+
558
+ declare class ClaudeHaiku45 implements GenerativeModel {
559
+ readonly specification: {
560
+ name: string;
561
+ supportReasoningEffort: boolean;
562
+ defaultReasoningEffort: AnthropicReasoningEffortType;
563
+ supportStreaming: boolean;
564
+ contextWindowSize: number;
565
+ maxOutputTokens: number;
566
+ supportFunctionCalling: boolean;
567
+ };
568
+ private tools;
569
+ private streaming;
570
+ setStreaming(streaming: boolean): void;
571
+ getStreaming(): boolean;
572
+ setTools(tools: Tool[]): void;
573
+ getTools(): Tool[];
574
+ private readonly effort;
575
+ setReasoningEffort(effort: AnthropicReasoningEffortType): void;
576
+ getReasoningEffort(): AnthropicReasoningEffortType;
577
+ }
578
+
579
+ export { Agent, AgenticEnvironment, AnthropicMessages, BaseAgent, BaseHuman, BaseObserver, ClaudeHaiku45, ClaudeOpus47, ClaudeSonnet46, ContextItem, DefaultFunctionCallRunner, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type FunctionCallRunner, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, Human, InMemoryModelContextRepository, InferenceRequest, InferenceResponse, type InferenceRunner, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, type ModelRuntime, Observer, OpenAIInferenceRunner, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StreamingRuntime, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import OpenAI from 'openai';
2
+ import Anthropic from '@anthropic-ai/sdk';
2
3
 
3
4
  declare abstract class ContextItem {
4
5
  abstract readonly type: string;
@@ -385,12 +386,47 @@ declare class BaseHuman extends Human {
385
386
  onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
386
387
  }
387
388
 
389
+ declare class InferenceRequest {
390
+ readonly model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability;
391
+ readonly context: ModelContext;
392
+ constructor(model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext);
393
+ }
394
+
395
+ declare class InferenceResponse {
396
+ readonly contextItems: ContextItem[];
397
+ readonly tokenUsage?: TokenUsage;
398
+ constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
399
+ }
400
+
401
+ /**
402
+ * Provider-agnostic port for a single round of inference.
403
+ *
404
+ * Lives in the domain layer; concrete adapters (OpenAI Responses,
405
+ * Anthropic Messages, DeepSeek Chat Completions, …) live in the
406
+ * infrastructure layer and are injected into application-layer runners
407
+ * through their constructor. The application layer must depend on this
408
+ * interface, never on a concrete provider client.
409
+ */
410
+ interface ModelRuntime {
411
+ infer(request: InferenceRequest): Promise<InferenceResponse>;
412
+ }
413
+
388
414
  type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>;
415
+ /**
416
+ * Application-layer inference runner. Provider-agnostic: it depends on
417
+ * the {@link ModelRuntime} domain port and receives a concrete
418
+ * infrastructure adapter (OpenAIResponses, AnthropicMessages, …)
419
+ * through its constructor. The runner never instantiates a provider
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.
424
+ */
389
425
  declare class OpenAIInferenceRunner implements InferenceRunner {
426
+ private readonly runtime;
427
+ constructor(runtime: ModelRuntime);
390
428
  run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem>;
391
- extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
392
- mapContextToRequest(context: ModelContext): any[];
393
- extractContextItems(response: any): ContextItem[];
429
+ private isStreamingRuntime;
394
430
  }
395
431
 
396
432
  declare class DefaultFunctionCallRunner implements FunctionCallRunner {
@@ -441,4 +477,103 @@ declare class BaseObserver extends Observer {
441
477
  onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
442
478
  }
443
479
 
444
- export { Agent, AgenticEnvironment, BaseAgent, BaseHuman, BaseObserver, ContextItem, DefaultFunctionCallRunner, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type FunctionCallRunner, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, Human, InMemoryModelContextRepository, type InferenceRunner, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, Observer, OpenAIInferenceRunner, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
480
+ /**
481
+ * Optional streaming companion to {@link ModelRuntime}. Adapters whose
482
+ * provider can stream a round implement this in addition to
483
+ * `ModelRuntime`; runners delegate to `stream` only when the model has
484
+ * streaming enabled and the injected runtime actually implements it.
485
+ */
486
+ interface StreamingRuntime {
487
+ stream(request: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
488
+ }
489
+
490
+ declare class OpenAIResponses implements ModelRuntime, StreamingRuntime {
491
+ private readonly client;
492
+ constructor();
493
+ infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
494
+ stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
495
+ private buildRequest;
496
+ extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
497
+ mapContextToRequest(context: ModelContext): any[];
498
+ extractContextItems(response: any): ContextItem[];
499
+ }
500
+
501
+ declare class AnthropicMessages implements ModelRuntime {
502
+ private readonly client;
503
+ constructor();
504
+ infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
505
+ extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
506
+ mapContextToRequest(context: ModelContext): {
507
+ messages: any[];
508
+ system?: string;
509
+ };
510
+ extractContextItems(response: Anthropic.Messages.Message): ContextItem[];
511
+ private addContentBlock;
512
+ }
513
+
514
+ type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
515
+
516
+ declare class ClaudeOpus47 implements GenerativeModel {
517
+ readonly specification: {
518
+ name: string;
519
+ supportReasoningEffort: boolean;
520
+ defaultReasoningEffort: AnthropicReasoningEffortType;
521
+ supportStreaming: boolean;
522
+ contextWindowSize: number;
523
+ maxOutputTokens: number;
524
+ supportFunctionCalling: boolean;
525
+ };
526
+ private tools;
527
+ private streaming;
528
+ setStreaming(streaming: boolean): void;
529
+ getStreaming(): boolean;
530
+ setTools(tools: Tool[]): void;
531
+ getTools(): Tool[];
532
+ private readonly effort;
533
+ setReasoningEffort(effort: AnthropicReasoningEffortType): void;
534
+ getReasoningEffort(): AnthropicReasoningEffortType;
535
+ }
536
+
537
+ declare class ClaudeSonnet46 implements GenerativeModel {
538
+ readonly specification: {
539
+ name: string;
540
+ supportReasoningEffort: boolean;
541
+ defaultReasoningEffort: AnthropicReasoningEffortType;
542
+ supportStreaming: boolean;
543
+ contextWindowSize: number;
544
+ maxOutputTokens: number;
545
+ supportFunctionCalling: boolean;
546
+ };
547
+ private tools;
548
+ private streaming;
549
+ setStreaming(streaming: boolean): void;
550
+ getStreaming(): boolean;
551
+ setTools(tools: Tool[]): void;
552
+ getTools(): Tool[];
553
+ private readonly effort;
554
+ setReasoningEffort(effort: AnthropicReasoningEffortType): void;
555
+ getReasoningEffort(): AnthropicReasoningEffortType;
556
+ }
557
+
558
+ declare class ClaudeHaiku45 implements GenerativeModel {
559
+ readonly specification: {
560
+ name: string;
561
+ supportReasoningEffort: boolean;
562
+ defaultReasoningEffort: AnthropicReasoningEffortType;
563
+ supportStreaming: boolean;
564
+ contextWindowSize: number;
565
+ maxOutputTokens: number;
566
+ supportFunctionCalling: boolean;
567
+ };
568
+ private tools;
569
+ private streaming;
570
+ setStreaming(streaming: boolean): void;
571
+ getStreaming(): boolean;
572
+ setTools(tools: Tool[]): void;
573
+ getTools(): Tool[];
574
+ private readonly effort;
575
+ setReasoningEffort(effort: AnthropicReasoningEffortType): void;
576
+ getReasoningEffort(): AnthropicReasoningEffortType;
577
+ }
578
+
579
+ export { Agent, AgenticEnvironment, AnthropicMessages, BaseAgent, BaseHuman, BaseObserver, ClaudeHaiku45, ClaudeOpus47, ClaudeSonnet46, ContextItem, DefaultFunctionCallRunner, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type FunctionCallRunner, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, Human, InMemoryModelContextRepository, InferenceRequest, InferenceResponse, type InferenceRunner, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, type ModelRuntime, Observer, OpenAIInferenceRunner, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StreamingRuntime, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };