@mozaik-ai/core 3.12.0 → 3.13.1

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,10 +1,6 @@
1
- import OpenAI from 'openai';
2
- import Anthropic from '@anthropic-ai/sdk';
3
-
4
1
  declare abstract class ContextItem {
5
2
  abstract readonly type: string;
6
3
  getType(): string;
7
- abstract toJSON(): any;
8
4
  }
9
5
 
10
6
  declare class ModelContext {
@@ -22,7 +18,6 @@ declare class ModelContext {
22
18
  projectId: string;
23
19
  items: ContextItem[];
24
20
  }): ModelContext;
25
- toJSON(): any;
26
21
  }
27
22
 
28
23
  declare abstract class ItemContent {
@@ -37,7 +32,6 @@ declare class InputText extends ItemContent {
37
32
  static rehydrate(data: {
38
33
  text: string;
39
34
  }): InputText;
40
- toJSON(): any[];
41
35
  }
42
36
 
43
37
  declare class UserMessageItem extends ContextItem {
@@ -49,7 +43,6 @@ declare class UserMessageItem extends ContextItem {
49
43
  static rehydrate(data: {
50
44
  text: string;
51
45
  }): UserMessageItem;
52
- toJSON(): any;
53
46
  }
54
47
 
55
48
  declare class DeveloperMessageItem extends ContextItem {
@@ -57,7 +50,6 @@ declare class DeveloperMessageItem extends ContextItem {
57
50
  readonly role = "developer";
58
51
  readonly content: InputText;
59
52
  private constructor();
60
- toJSON(): any;
61
53
  static create(text: string): DeveloperMessageItem;
62
54
  static rehydrate(data: {
63
55
  text: string;
@@ -71,7 +63,6 @@ declare class OutputText extends ItemContent {
71
63
  static rehydrate(data: {
72
64
  text: string;
73
65
  }): OutputText;
74
- toJSON(): any[];
75
66
  }
76
67
 
77
68
  declare class ModelMessageItem extends ContextItem {
@@ -82,7 +73,6 @@ declare class ModelMessageItem extends ContextItem {
82
73
  static rehydrate(data: {
83
74
  text: string;
84
75
  }): ModelMessageItem;
85
- toJSON(): any;
86
76
  }
87
77
 
88
78
  declare class FunctionCallItem extends ContextItem {
@@ -96,7 +86,6 @@ declare class FunctionCallItem extends ContextItem {
96
86
  name: string;
97
87
  args: string;
98
88
  }): FunctionCallItem;
99
- toJSON(): any;
100
89
  }
101
90
 
102
91
  declare class SummaryText extends ItemContent {
@@ -106,7 +95,6 @@ declare class SummaryText extends ItemContent {
106
95
  static rehydrate(data: {
107
96
  text: string;
108
97
  }): SummaryText;
109
- toJSON(): Record<string, any>;
110
98
  }
111
99
 
112
100
  declare class ReasoningItem extends ContextItem {
@@ -120,17 +108,6 @@ declare class ReasoningItem extends ContextItem {
120
108
  encryptedContent: string | undefined;
121
109
  summary: SummaryText[];
122
110
  }): ReasoningItem;
123
- toJSON(): any;
124
- }
125
-
126
- interface ReasoningEffort<Effort extends string> {
127
- setReasoningEffort(effort: Effort): void;
128
- getReasoningEffort(): Effort;
129
- }
130
-
131
- interface StreamingCapability {
132
- setStreaming(streaming: boolean): void;
133
- getStreaming(): boolean;
134
111
  }
135
112
 
136
113
  interface FunctionTool {
@@ -143,24 +120,6 @@ interface FunctionTool {
143
120
  }
144
121
  type Tool = FunctionTool;
145
122
 
146
- interface ToolCallingCapability {
147
- setTools(tools: Tool[]): void;
148
- getTools(): Tool[];
149
- }
150
-
151
- type ModelSpecification = {
152
- name: string;
153
- supportReasoningEffort: boolean;
154
- defaultReasoningEffort: string | undefined;
155
- supportStreaming: boolean;
156
- contextWindowSize: number;
157
- maxOutputTokens: number;
158
- supportFunctionCalling: boolean;
159
- };
160
- interface GenerativeModel extends ReasoningEffort<string>, ToolCallingCapability, StreamingCapability {
161
- readonly specification: ModelSpecification;
162
- }
163
-
164
123
  declare class FunctionCallOutputItem extends ContextItem {
165
124
  readonly type = "function_call_output";
166
125
  readonly callId: string;
@@ -171,116 +130,6 @@ declare class FunctionCallOutputItem extends ContextItem {
171
130
  callId: string;
172
131
  output: InputText;
173
132
  }): FunctionCallOutputItem;
174
- toJSON(): any;
175
- }
176
-
177
- interface ModelContextRepository {
178
- save(context: ModelContext): Promise<void>;
179
- get(id: string): Promise<ModelContext>;
180
- getByProjectId(projectId: string): Promise<ModelContext[]>;
181
- }
182
-
183
- type OpenAIReasoningEffortType = "xhigh" | "high" | "medium" | "low" | "none";
184
-
185
- declare class Gpt54Nano implements GenerativeModel {
186
- readonly specification: {
187
- name: string;
188
- supportReasoningEffort: boolean;
189
- defaultReasoningEffort: OpenAIReasoningEffortType;
190
- supportStreaming: boolean;
191
- contextWindowSize: number;
192
- maxOutputTokens: number;
193
- supportFunctionCalling: boolean;
194
- };
195
- private tools;
196
- private streaming;
197
- private readonly effort;
198
- setStreaming(streaming: boolean): void;
199
- getStreaming(): boolean;
200
- setTools(tools: Tool[]): void;
201
- getTools(): Tool[];
202
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
203
- getReasoningEffort(): OpenAIReasoningEffortType;
204
- }
205
-
206
- declare class Gpt54 implements GenerativeModel {
207
- readonly specification: {
208
- name: string;
209
- supportReasoningEffort: boolean;
210
- defaultReasoningEffort: OpenAIReasoningEffortType;
211
- supportStreaming: boolean;
212
- contextWindowSize: number;
213
- maxOutputTokens: number;
214
- supportFunctionCalling: boolean;
215
- };
216
- private tools;
217
- private streaming;
218
- private readonly effort;
219
- setStreaming(streaming: boolean): void;
220
- getStreaming(): boolean;
221
- setTools(tools: Tool[]): void;
222
- getTools(): Tool[];
223
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
224
- getReasoningEffort(): OpenAIReasoningEffortType;
225
- }
226
-
227
- declare class Gpt54Mini implements GenerativeModel {
228
- readonly specification: {
229
- name: string;
230
- supportReasoningEffort: boolean;
231
- defaultReasoningEffort: OpenAIReasoningEffortType;
232
- supportStreaming: boolean;
233
- contextWindowSize: number;
234
- maxOutputTokens: number;
235
- supportFunctionCalling: boolean;
236
- };
237
- private tools;
238
- private streaming;
239
- private readonly effort;
240
- setStreaming(streaming: boolean): void;
241
- getStreaming(): boolean;
242
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
243
- getReasoningEffort(): OpenAIReasoningEffortType;
244
- setTools(tools: Tool[]): void;
245
- getTools(): Tool[];
246
- }
247
-
248
- declare class InputTokenDetails {
249
- readonly cached_tokens: number;
250
- constructor(cached_tokens: number);
251
- }
252
- declare class OutputTokenDetails {
253
- readonly reasoning_tokens: number;
254
- constructor(reasoning_tokens: number);
255
- }
256
- declare class TokenUsage {
257
- readonly inputTokens: number;
258
- readonly outputTokens: number;
259
- readonly totalTokens: number;
260
- readonly inputTokenDetails: InputTokenDetails;
261
- readonly outputTokenDetails: OutputTokenDetails;
262
- constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
263
- }
264
-
265
- declare class InMemoryModelContextRepository implements ModelContextRepository {
266
- private readonly store;
267
- private readonly projectIndex;
268
- save(context: ModelContext): Promise<void>;
269
- get(id: string): Promise<ModelContext>;
270
- getByProjectId(projectId: string): Promise<ModelContext[]>;
271
- private clone;
272
- }
273
-
274
- declare class SystemMessageItem extends ContextItem {
275
- readonly type = "message";
276
- readonly role = "system";
277
- readonly content: InputText;
278
- private constructor();
279
- toJSON(): any;
280
- static create(text: string): SystemMessageItem;
281
- static rehydrate(data: {
282
- text: string;
283
- }): SystemMessageItem;
284
133
  }
285
134
 
286
135
  declare class SemanticEvent<T> {
@@ -290,34 +139,33 @@ declare class SemanticEvent<T> {
290
139
  getType(): string;
291
140
  }
292
141
 
293
- declare class AgenticEnvironment {
294
- protected subscribers: Participant[];
295
- private name?;
296
- private isActive;
297
- constructor(name?: string);
298
- subscribe(participant: Participant): void;
299
- unsubscribe(participant: Participant): void;
300
- deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
301
- deliverModelMessage(source: Participant, item: ModelMessageItem): void;
302
- deliverReasoning(source: Participant, item: ReasoningItem): void;
303
- deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
304
- deliverMessage(source: Participant, message: string): void;
305
- deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
306
- private getListeningParticipants;
307
- private deliverToSubscribers;
308
- start(): Promise<void>;
309
- stop(): void;
142
+ interface AgenticErrorOpts {
143
+ message: string;
144
+ stack?: string;
145
+ source?: Participant;
146
+ enviornment?: AgenticEnvironment;
147
+ }
148
+ declare class AgenticError extends Error {
149
+ private source?;
150
+ private environment?;
151
+ constructor({ message, stack, source, enviornment }: AgenticErrorOpts);
152
+ getSource(): Participant | undefined;
153
+ getEnvironment(): AgenticEnvironment | undefined;
310
154
  }
311
155
 
312
156
  type ParticipantClassConstructor = new (...args: any[]) => Participant;
313
157
  declare abstract class Participant {
314
158
  private environments;
315
159
  protected listens: ParticipantClassConstructor[];
160
+ private active;
316
161
  join(environment: AgenticEnvironment): void;
317
162
  leave(environment: AgenticEnvironment): void;
318
- protected isJoinedTo(environment: AgenticEnvironment): boolean;
163
+ isJoinedTo(environment: AgenticEnvironment): boolean;
319
164
  getEnvironments(): AgenticEnvironment[];
320
165
  getListeners(): ParticipantClassConstructor[];
166
+ getEnvironmentState(environment: AgenticEnvironment): boolean | undefined;
167
+ markInactive(environment: AgenticEnvironment): void;
168
+ markActive(environment: AgenticEnvironment): void;
321
169
  abstract onParticipantJoined(participant: Participant): Promise<void> | void;
322
170
  abstract onParticipantLeft(participant: Participant): Promise<void> | void;
323
171
  abstract onJoined(): Promise<void> | void;
@@ -333,70 +181,61 @@ declare abstract class Participant {
333
181
  abstract onMessage(message: string): Promise<void> | void;
334
182
  abstract onInternalEvent(item: SemanticEvent<unknown>): Promise<void> | void;
335
183
  abstract onExternalEvent(source: Participant, item: SemanticEvent<unknown>): Promise<void> | void;
184
+ abstract onError(error: AgenticError): void;
185
+ abstract onParticipantError(source: Participant, error: AgenticError): void;
336
186
  }
337
187
 
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>;
188
+ interface AgenticEnvironmentOptions {
189
+ silent?: boolean;
372
190
  }
191
+ declare class AgenticEnvironment {
192
+ protected subscribers: Participant[];
193
+ private name?;
194
+ private options?;
195
+ private showLogs?;
196
+ constructor(name?: string, opts?: AgenticEnvironmentOptions);
197
+ subscribe(participant: Participant): void;
198
+ unsubscribe(participant: Participant): void;
199
+ deliverFunctionCall(source: Participant, item: FunctionCallItem): void;
200
+ deliverModelMessage(source: Participant, item: ModelMessageItem): void;
201
+ deliverReasoning(source: Participant, item: ReasoningItem): void;
202
+ deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
203
+ deliverMessage(source: Participant, message: string): void;
204
+ deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
205
+ deliverError(source: Participant, error: AgenticError): void;
206
+ private getListeningParticipants;
207
+ private deliverToSubscribers;
208
+ private handleError;
209
+ }
210
+
211
+ type InferenceParams<TModel extends string> = {
212
+ model: TModel;
213
+ maxOutputTokens?: number;
214
+ reasoningEffort?: string;
215
+ tools?: Tool[];
216
+ streaming?: boolean;
217
+ structuredOutput?: StructuredOutputFormat;
218
+ context: ModelContext;
219
+ caller: Participant;
220
+ environment: AgenticEnvironment;
221
+ signal?: AbortSignal;
222
+ };
373
223
 
374
- declare abstract class Human extends Participant {
375
- sendMessage(environment: AgenticEnvironment, message: string): void;
224
+ declare class InputTokenDetails {
225
+ readonly cached_tokens: number;
226
+ constructor(cached_tokens: number);
376
227
  }
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;
228
+ declare class OutputTokenDetails {
229
+ readonly reasoning_tokens: number;
230
+ constructor(reasoning_tokens: number);
394
231
  }
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);
232
+ declare class TokenUsage {
233
+ readonly inputTokens: number;
234
+ readonly outputTokens: number;
235
+ readonly totalTokens: number;
236
+ readonly inputTokenDetails: InputTokenDetails;
237
+ readonly outputTokenDetails: OutputTokenDetails;
238
+ constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
400
239
  }
401
240
 
402
241
  declare class InferenceResponse {
@@ -405,64 +244,52 @@ declare class InferenceResponse {
405
244
  constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
406
245
  }
407
246
 
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>;
247
+ interface InferenceEndpointMapper {
248
+ toRequest(inferenceParams: InferenceParams<ModelName>): any;
249
+ toResponse(response: any): InferenceResponse;
419
250
  }
420
251
 
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;
252
+ interface Endpoint {
253
+ endpointMapper: InferenceEndpointMapper;
254
+ infer(requestParams: InferenceParams<ModelName>): Promise<InferenceResponse>;
255
+ stream(requestParams: InferenceParams<ModelName>, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
433
256
  }
434
257
 
435
- declare class DefaultFunctionCallRunner implements FunctionCallRunner {
436
- private readonly tools;
437
- constructor(tools: Tool[]);
438
- run(call: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
258
+ type ModelName = "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-nano" | "gpt-5.5" | "claude-haiku-4-5" | "claude-sonnet-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "gemini-3.5-flash" | "gemini-3.1-pro-preview" | "deepseek-v4-flash" | "deepseek-v4-pro";
259
+
260
+ type StructuredOutputFormat = {
261
+ name?: string;
262
+ schema: Record<string, any>;
263
+ strict?: boolean;
264
+ };
265
+
266
+ interface ModelContextRepository {
267
+ save(context: ModelContext): Promise<void>;
268
+ get(id: string): Promise<ModelContext>;
269
+ getByProjectId(projectId: string): Promise<ModelContext[]>;
439
270
  }
440
271
 
441
- declare class Gpt55 implements GenerativeModel {
442
- readonly specification: {
443
- name: string;
444
- supportReasoningEffort: boolean;
445
- defaultReasoningEffort: OpenAIReasoningEffortType;
446
- supportStreaming: boolean;
447
- contextWindowSize: number;
448
- maxOutputTokens: number;
449
- supportFunctionCalling: boolean;
450
- };
451
- private tools;
452
- private streaming;
453
- private readonly effort;
454
- setStreaming(streaming: boolean): void;
455
- getStreaming(): boolean;
456
- setTools(tools: Tool[]): void;
457
- getTools(): Tool[];
458
- setReasoningEffort(effort: OpenAIReasoningEffortType): void;
459
- getReasoningEffort(): OpenAIReasoningEffortType;
272
+ declare class InMemoryModelContextRepository implements ModelContextRepository {
273
+ private readonly store;
274
+ private readonly projectIndex;
275
+ save(context: ModelContext): Promise<void>;
276
+ get(id: string): Promise<ModelContext>;
277
+ getByProjectId(projectId: string): Promise<ModelContext[]>;
278
+ private clone;
460
279
  }
461
280
 
462
- declare abstract class Observer extends Participant {
281
+ declare class SystemMessageItem extends ContextItem {
282
+ readonly type = "message";
283
+ readonly role = "system";
284
+ readonly content: InputText;
285
+ private constructor();
286
+ static create(text: string): SystemMessageItem;
287
+ static rehydrate(data: {
288
+ text: string;
289
+ }): SystemMessageItem;
463
290
  }
464
291
 
465
- declare class BaseObserver extends Observer {
292
+ declare class BaseParticipant extends Participant {
466
293
  onFunctionCall(item: FunctionCallItem): void;
467
294
  onExternalFunctionCall(source: Participant, item: FunctionCallItem): void;
468
295
  onFunctionCallOutput(item: FunctionCallOutputItem): void;
@@ -478,301 +305,12 @@ declare class BaseObserver extends Observer {
478
305
  onParticipantLeft(participant: Participant): void;
479
306
  onInternalEvent(item: SemanticEvent<unknown>): void;
480
307
  onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
308
+ onError(error: AgenticError): void;
309
+ onParticipantError(source: Participant, error: AgenticError): void;
481
310
  }
482
311
 
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>>;
491
- }
492
-
493
- declare class OpenAIResponses implements ModelRuntime, StreamingRuntime {
494
- private readonly client;
495
- constructor();
496
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
497
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
498
- private buildRequest;
499
- extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
500
- mapContextToRequest(context: ModelContext): any[];
501
- extractContextItems(response: any): ContextItem[];
502
- }
503
-
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 {
554
- private readonly client;
555
- constructor();
556
- infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
557
- stream(inferenceRequest: InferenceRequest, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
558
- private buildRequest;
559
- extractTokenUsage(response: Anthropic.Messages.Message): TokenUsage | undefined;
560
- mapContextToRequest(context: ModelContext): {
561
- messages: any[];
562
- system?: string;
563
- };
564
- extractContextItems(response: Anthropic.Messages.Message): ContextItem[];
565
- private addContentBlock;
566
- }
567
-
568
- type AnthropicReasoningEffortType = "high" | "medium" | "low" | "none";
569
-
570
- declare class ClaudeOpus48 implements GenerativeModel {
571
- readonly specification: {
572
- name: string;
573
- supportReasoningEffort: boolean;
574
- defaultReasoningEffort: AnthropicReasoningEffortType;
575
- supportStreaming: boolean;
576
- contextWindowSize: number;
577
- maxOutputTokens: number;
578
- supportFunctionCalling: boolean;
579
- };
580
- private tools;
581
- private streaming;
582
- private readonly effort;
583
- setStreaming(streaming: boolean): void;
584
- getStreaming(): boolean;
585
- setTools(tools: Tool[]): void;
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;
603
- private readonly effort;
604
- setStreaming(streaming: boolean): void;
605
- getStreaming(): boolean;
606
- setTools(tools: Tool[]): void;
607
- getTools(): Tool[];
608
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
609
- getReasoningEffort(): AnthropicReasoningEffortType;
610
- }
611
-
612
- declare class ClaudeSonnet46 implements GenerativeModel {
613
- readonly specification: {
614
- name: string;
615
- supportReasoningEffort: boolean;
616
- defaultReasoningEffort: AnthropicReasoningEffortType;
617
- supportStreaming: boolean;
618
- contextWindowSize: number;
619
- maxOutputTokens: number;
620
- supportFunctionCalling: boolean;
621
- };
622
- private tools;
623
- private streaming;
624
- setStreaming(streaming: boolean): void;
625
- getStreaming(): boolean;
626
- setTools(tools: Tool[]): void;
627
- getTools(): Tool[];
628
- private readonly effort;
629
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
630
- getReasoningEffort(): AnthropicReasoningEffortType;
631
- }
632
-
633
- declare class ClaudeHaiku45 implements GenerativeModel {
634
- readonly specification: {
635
- name: string;
636
- supportReasoningEffort: boolean;
637
- defaultReasoningEffort: AnthropicReasoningEffortType;
638
- supportStreaming: boolean;
639
- contextWindowSize: number;
640
- maxOutputTokens: number;
641
- supportFunctionCalling: boolean;
642
- };
643
- private tools;
644
- private streaming;
645
- private readonly effort;
646
- setStreaming(streaming: boolean): void;
647
- getStreaming(): boolean;
648
- setTools(tools: Tool[]): void;
649
- getTools(): Tool[];
650
- setReasoningEffort(effort: AnthropicReasoningEffortType): void;
651
- getReasoningEffort(): AnthropicReasoningEffortType;
652
- }
653
-
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
- }
312
+ declare const runInference: (inferenceParams: InferenceParams<ModelName>) => void;
313
+ declare const executeFunctionCall: (environment: AgenticEnvironment, functionCallItem: FunctionCallItem, tool: Tool, caller: Participant) => void;
314
+ declare const sendMessage: (environment: AgenticEnvironment, message: string, caller: Participant) => void;
777
315
 
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 };
316
+ export { AgenticEnvironment, AgenticError, BaseParticipant, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, InMemoryModelContextRepository, type InferenceParams, InferenceResponse, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, type ModelName, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, executeFunctionCall, runInference, sendMessage };