@mozaik-ai/core 4.0.0-beta.1 → 4.0.0-beta.3

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
@@ -419,7 +419,102 @@ declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
419
419
  join: (participant: Participant) => void;
420
420
  leave: (participant: Participant) => void;
421
421
  sendMessage: (message: string, senderId: string) => void;
422
+ sendEvent: (event: SemanticEvent, senderId: string) => void;
422
423
  runLoop: (agentId: string, message: string, inferenceInput: InferenceInput) => void;
423
424
  };
424
425
 
425
- export { ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, type InferenceInput, type InferenceOutput, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime };
426
+ declare const supportedModels: GenerativeModel[];
427
+
428
+ declare class OpenAIResponses implements Endpoint {
429
+ endpointMapper: InferenceEndpointMapper;
430
+ private readonly client;
431
+ constructor(endpointMapper?: InferenceEndpointMapper);
432
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
433
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
434
+ }
435
+
436
+ /**
437
+ * Optional connection config. When omitted, the `openai` SDK reads
438
+ * `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
439
+ * default-constructed runtime targets whatever `OPENAI_BASE_URL` points
440
+ * at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
441
+ * explicit base URL + credential.
442
+ */
443
+ interface OpenAICompatibleConfig {
444
+ baseURL?: string;
445
+ apiKey?: string;
446
+ /**
447
+ * Extra request-body fields merged into every `chat.completions`
448
+ * call. This is how provider-specific quirks are handled **without
449
+ * a per-provider subclass in mozaik** — the consumer supplies the
450
+ * vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
451
+ * safety flags, routing hints). Standard fields the runtime already
452
+ * sets (`model`, `messages`, `tools`, `reasoning_effort`) take
453
+ * precedence and are not overwritten.
454
+ */
455
+ extraBody?: Record<string, unknown>;
456
+ }
457
+ /**
458
+ * Generic adapter for any **OpenAI Chat Completions**-compatible
459
+ * endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
460
+ * Ollama, etc. It speaks `/chat/completions` (not the Responses API),
461
+ * which is the dialect third-party OpenAI-compatible providers expose.
462
+ *
463
+ * The base URL and credential are configurable; everything else (the
464
+ * `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
465
+ * usage extraction) is provider-agnostic. Provider-specific request
466
+ * shaping (e.g. DeepSeek's `thinking` field) is supplied by the
467
+ * consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
468
+ * generic and gains no per-provider subclasses.
469
+ *
470
+ * Was `DeepSeekChatCompletions`; generalized so consumers can point it
471
+ * at any OpenAI-compatible endpoint.
472
+ */
473
+ declare class OpenAIChatCompletions implements Endpoint {
474
+ endpointMapper: InferenceEndpointMapper;
475
+ private readonly client;
476
+ private readonly extraBody;
477
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
478
+ private buildRequest;
479
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
480
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
481
+ }
482
+
483
+ interface AnthropicConnectionConfig {
484
+ baseURL?: string;
485
+ apiKey?: string;
486
+ }
487
+ /**
488
+ * Native Anthropic adapter on the `@anthropic-ai/sdk` (`messages.create`).
489
+ * Maps domain context to Anthropic's `messages`/`content` blocks shape,
490
+ * system prompt, tools, adaptive thinking, and structured output config.
491
+ */
492
+ declare class AnthropicMessages implements Endpoint {
493
+ endpointMapper: InferenceEndpointMapper;
494
+ private readonly client;
495
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
496
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
497
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
498
+ }
499
+
500
+ interface GeminiConnectionConfig {
501
+ baseURL?: string;
502
+ apiKey?: string;
503
+ }
504
+ /**
505
+ * Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
506
+ * `generateContentStream`). Unlike an OpenAI-compat shim this maps our
507
+ * domain context to Gemini's native `contents`/`parts` shape, system
508
+ * instruction, `functionDeclarations`, and `thinkingConfig`, and reads
509
+ * thought parts + native usage metadata back out. Another `ModelRuntime`
510
+ * — no runner or port changes.
511
+ */
512
+ declare class GeminiGenerateContent implements Endpoint {
513
+ endpointMapper: InferenceEndpointMapper;
514
+ private readonly client;
515
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
516
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
517
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
518
+ }
519
+
520
+ export { AnthropicMessages, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, type InferenceInput, type InferenceOutput, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };
package/dist/index.d.ts CHANGED
@@ -419,7 +419,102 @@ declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
419
419
  join: (participant: Participant) => void;
420
420
  leave: (participant: Participant) => void;
421
421
  sendMessage: (message: string, senderId: string) => void;
422
+ sendEvent: (event: SemanticEvent, senderId: string) => void;
422
423
  runLoop: (agentId: string, message: string, inferenceInput: InferenceInput) => void;
423
424
  };
424
425
 
425
- export { ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, type InferenceInput, type InferenceOutput, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime };
426
+ declare const supportedModels: GenerativeModel[];
427
+
428
+ declare class OpenAIResponses implements Endpoint {
429
+ endpointMapper: InferenceEndpointMapper;
430
+ private readonly client;
431
+ constructor(endpointMapper?: InferenceEndpointMapper);
432
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
433
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
434
+ }
435
+
436
+ /**
437
+ * Optional connection config. When omitted, the `openai` SDK reads
438
+ * `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
439
+ * default-constructed runtime targets whatever `OPENAI_BASE_URL` points
440
+ * at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
441
+ * explicit base URL + credential.
442
+ */
443
+ interface OpenAICompatibleConfig {
444
+ baseURL?: string;
445
+ apiKey?: string;
446
+ /**
447
+ * Extra request-body fields merged into every `chat.completions`
448
+ * call. This is how provider-specific quirks are handled **without
449
+ * a per-provider subclass in mozaik** — the consumer supplies the
450
+ * vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
451
+ * safety flags, routing hints). Standard fields the runtime already
452
+ * sets (`model`, `messages`, `tools`, `reasoning_effort`) take
453
+ * precedence and are not overwritten.
454
+ */
455
+ extraBody?: Record<string, unknown>;
456
+ }
457
+ /**
458
+ * Generic adapter for any **OpenAI Chat Completions**-compatible
459
+ * endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
460
+ * Ollama, etc. It speaks `/chat/completions` (not the Responses API),
461
+ * which is the dialect third-party OpenAI-compatible providers expose.
462
+ *
463
+ * The base URL and credential are configurable; everything else (the
464
+ * `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
465
+ * usage extraction) is provider-agnostic. Provider-specific request
466
+ * shaping (e.g. DeepSeek's `thinking` field) is supplied by the
467
+ * consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
468
+ * generic and gains no per-provider subclasses.
469
+ *
470
+ * Was `DeepSeekChatCompletions`; generalized so consumers can point it
471
+ * at any OpenAI-compatible endpoint.
472
+ */
473
+ declare class OpenAIChatCompletions implements Endpoint {
474
+ endpointMapper: InferenceEndpointMapper;
475
+ private readonly client;
476
+ private readonly extraBody;
477
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
478
+ private buildRequest;
479
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
480
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
481
+ }
482
+
483
+ interface AnthropicConnectionConfig {
484
+ baseURL?: string;
485
+ apiKey?: string;
486
+ }
487
+ /**
488
+ * Native Anthropic adapter on the `@anthropic-ai/sdk` (`messages.create`).
489
+ * Maps domain context to Anthropic's `messages`/`content` blocks shape,
490
+ * system prompt, tools, adaptive thinking, and structured output config.
491
+ */
492
+ declare class AnthropicMessages implements Endpoint {
493
+ endpointMapper: InferenceEndpointMapper;
494
+ private readonly client;
495
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
496
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
497
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
498
+ }
499
+
500
+ interface GeminiConnectionConfig {
501
+ baseURL?: string;
502
+ apiKey?: string;
503
+ }
504
+ /**
505
+ * Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
506
+ * `generateContentStream`). Unlike an OpenAI-compat shim this maps our
507
+ * domain context to Gemini's native `contents`/`parts` shape, system
508
+ * instruction, `functionDeclarations`, and `thinkingConfig`, and reads
509
+ * thought parts + native usage metadata back out. Another `ModelRuntime`
510
+ * — no runner or port changes.
511
+ */
512
+ declare class GeminiGenerateContent implements Endpoint {
513
+ endpointMapper: InferenceEndpointMapper;
514
+ private readonly client;
515
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
516
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
517
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
518
+ }
519
+
520
+ export { AnthropicMessages, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, type InferenceInput, type InferenceOutput, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };
package/dist/index.js CHANGED
@@ -30,15 +30,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AnthropicMessages: () => AnthropicMessages,
33
34
  ContextItem: () => ContextItem,
34
35
  DeveloperMessageItem: () => DeveloperMessageItem,
35
36
  FunctionCallItem: () => FunctionCallItem,
36
37
  FunctionCallOutputItem: () => FunctionCallOutputItem,
38
+ GeminiGenerateContent: () => GeminiGenerateContent,
37
39
  InputTokenDetails: () => InputTokenDetails,
38
40
  McpClient: () => McpClient,
39
41
  McpToolRegistry: () => McpToolRegistry,
40
42
  ModelContext: () => ModelContext,
41
43
  ModelMessageItem: () => ModelMessageItem,
44
+ OpenAIChatCompletions: () => OpenAIChatCompletions,
45
+ OpenAIResponses: () => OpenAIResponses,
42
46
  OutputTokenDetails: () => OutputTokenDetails,
43
47
  Participant: () => Participant,
44
48
  ReasoningItem: () => ReasoningItem,
@@ -49,7 +53,8 @@ __export(index_exports, {
49
53
  UserMessageItem: () => UserMessageItem,
50
54
  createAgent: () => createAgent,
51
55
  createHuman: () => createHuman,
52
- defineRuntime: () => defineRuntime
56
+ defineRuntime: () => defineRuntime,
57
+ supportedModels: () => supportedModels
53
58
  });
54
59
  module.exports = __toCommonJS(index_exports);
55
60
 
@@ -2008,6 +2013,18 @@ var DefaultFunctionCallRunner = class {
2008
2013
  }
2009
2014
  };
2010
2015
 
2016
+ // src/application/use-cases/send-event.ts
2017
+ function createSendEvent(resolveRuntime) {
2018
+ return function sendEvent(event, senderId) {
2019
+ const runtime = resolveRuntime();
2020
+ const participant = runtime.getParticipant(senderId);
2021
+ if (!participant) {
2022
+ throw new Error(`Participant ${senderId} not found`);
2023
+ }
2024
+ runtime.publish(event);
2025
+ };
2026
+ }
2027
+
2011
2028
  // src/define-runtime.ts
2012
2029
  function defineRuntime() {
2013
2030
  let runtime = null;
@@ -2044,6 +2061,7 @@ function defineRuntime() {
2044
2061
  const join = createJoin(resolveRuntime);
2045
2062
  const leave = createLeave(resolveRuntime);
2046
2063
  const sendMessage = createSendMessage(resolveRuntime);
2064
+ const sendEvent = createSendEvent(resolveRuntime);
2047
2065
  const runLoop = createRunLoop(resolveRuntime);
2048
2066
  return {
2049
2067
  initializeRuntime,
@@ -2052,20 +2070,25 @@ function defineRuntime() {
2052
2070
  join,
2053
2071
  leave,
2054
2072
  sendMessage,
2073
+ sendEvent,
2055
2074
  runLoop
2056
2075
  };
2057
2076
  }
2058
2077
  // Annotate the CommonJS export names for ESM import in node:
2059
2078
  0 && (module.exports = {
2079
+ AnthropicMessages,
2060
2080
  ContextItem,
2061
2081
  DeveloperMessageItem,
2062
2082
  FunctionCallItem,
2063
2083
  FunctionCallOutputItem,
2084
+ GeminiGenerateContent,
2064
2085
  InputTokenDetails,
2065
2086
  McpClient,
2066
2087
  McpToolRegistry,
2067
2088
  ModelContext,
2068
2089
  ModelMessageItem,
2090
+ OpenAIChatCompletions,
2091
+ OpenAIResponses,
2069
2092
  OutputTokenDetails,
2070
2093
  Participant,
2071
2094
  ReasoningItem,
@@ -2076,6 +2099,7 @@ function defineRuntime() {
2076
2099
  UserMessageItem,
2077
2100
  createAgent,
2078
2101
  createHuman,
2079
- defineRuntime
2102
+ defineRuntime,
2103
+ supportedModels
2080
2104
  });
2081
2105
  //# sourceMappingURL=index.js.map