@mozaik-ai/core 3.14.0 → 4.0.0-beta.10

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.ts CHANGED
@@ -3,59 +3,23 @@ declare abstract class ContextItem {
3
3
  getType(): string;
4
4
  }
5
5
 
6
- declare class ModelContext {
7
- readonly id: string;
8
- readonly projectId: string;
9
- readonly items: ContextItem[];
10
- constructor(id: string, projectId: string, items: ContextItem[]);
11
- addContextItem(item: ContextItem): ModelContext;
12
- applyModelOutput(items: ContextItem[]): ModelContext;
13
- getItems(): ContextItem[];
14
- getLastItem(): ContextItem;
15
- static create(projectId: string): ModelContext;
6
+ declare class FunctionCallItem extends ContextItem {
7
+ readonly type = "function_call";
8
+ readonly callId: string;
9
+ readonly name: string;
10
+ readonly args: string;
11
+ private constructor();
16
12
  static rehydrate(data: {
17
- id: string;
18
- projectId: string;
19
- items: ContextItem[];
20
- }): ModelContext;
13
+ callId: string;
14
+ name: string;
15
+ args: string;
16
+ }): FunctionCallItem;
21
17
  }
22
18
 
23
19
  declare abstract class ItemContent {
24
20
  abstract readonly type: string;
25
21
  }
26
22
 
27
- declare class InputText extends ItemContent {
28
- readonly text: string;
29
- readonly type = "input_text";
30
- private constructor();
31
- static create(text: string): InputText;
32
- static rehydrate(data: {
33
- text: string;
34
- }): InputText;
35
- }
36
-
37
- declare class UserMessageItem extends ContextItem {
38
- readonly type = "message";
39
- readonly role = "user";
40
- readonly content: InputText;
41
- private constructor();
42
- static create(text: string): UserMessageItem;
43
- static rehydrate(data: {
44
- text: string;
45
- }): UserMessageItem;
46
- }
47
-
48
- declare class DeveloperMessageItem extends ContextItem {
49
- readonly type = "message";
50
- readonly role = "developer";
51
- readonly content: InputText;
52
- private constructor();
53
- static create(text: string): DeveloperMessageItem;
54
- static rehydrate(data: {
55
- text: string;
56
- }): DeveloperMessageItem;
57
- }
58
-
59
23
  declare class OutputText extends ItemContent {
60
24
  readonly text: string;
61
25
  readonly type = "output_text";
@@ -75,17 +39,14 @@ declare class ModelMessageItem extends ContextItem {
75
39
  }): ModelMessageItem;
76
40
  }
77
41
 
78
- declare class FunctionCallItem extends ContextItem {
79
- readonly type = "function_call";
80
- readonly callId: string;
81
- readonly name: string;
82
- readonly args: string;
42
+ declare class InputText extends ItemContent {
43
+ readonly text: string;
44
+ readonly type = "input_text";
83
45
  private constructor();
46
+ static create(text: string): InputText;
84
47
  static rehydrate(data: {
85
- callId: string;
86
- name: string;
87
- args: string;
88
- }): FunctionCallItem;
48
+ text: string;
49
+ }): InputText;
89
50
  }
90
51
 
91
52
  declare class SummaryText extends ItemContent {
@@ -110,15 +71,41 @@ declare class ReasoningItem extends ContextItem {
110
71
  }): ReasoningItem;
111
72
  }
112
73
 
113
- interface FunctionTool {
114
- type: "function";
115
- name: string;
116
- description: string;
117
- parameters: Record<string, any>;
118
- strict: boolean;
119
- invoke: (args: any) => Promise<any>;
74
+ declare class ModelContext {
75
+ readonly id: string;
76
+ readonly items: ContextItem[];
77
+ constructor(id: string, items: ContextItem[]);
78
+ getItems(): ContextItem[];
79
+ addContextItems(contextItems: ContextItem[]): ModelContext;
80
+ addItem(item: ContextItem): ModelContext;
81
+ static create(): ModelContext;
82
+ static rehydrate(data: {
83
+ id: string;
84
+ items: ContextItem[];
85
+ }): ModelContext;
86
+ }
87
+
88
+ declare class UserMessageItem extends ContextItem {
89
+ readonly type = "message";
90
+ readonly role = "user";
91
+ readonly content: InputText;
92
+ private constructor();
93
+ static create(text: string): UserMessageItem;
94
+ static rehydrate(data: {
95
+ text: string;
96
+ }): UserMessageItem;
97
+ }
98
+
99
+ declare class DeveloperMessageItem extends ContextItem {
100
+ readonly type = "message";
101
+ readonly role = "developer";
102
+ readonly content: InputText;
103
+ private constructor();
104
+ static create(text: string): DeveloperMessageItem;
105
+ static rehydrate(data: {
106
+ text: string;
107
+ }): DeveloperMessageItem;
120
108
  }
121
- type Tool = FunctionTool;
122
109
 
123
110
  declare class FunctionCallOutputItem extends ContextItem {
124
111
  readonly type = "function_call_output";
@@ -132,130 +119,185 @@ declare class FunctionCallOutputItem extends ContextItem {
132
119
  }): FunctionCallOutputItem;
133
120
  }
134
121
 
135
- declare class SemanticEvent<T> {
136
- readonly type: string;
137
- readonly data: T;
138
- constructor(type: string, data: T);
139
- getType(): string;
122
+ interface FunctionTool {
123
+ type: "function";
124
+ name: string;
125
+ description: string;
126
+ parameters: Record<string, any>;
127
+ strict: boolean;
128
+ invoke: (args: any) => Promise<any>;
140
129
  }
130
+ type Tool = FunctionTool;
141
131
 
142
- interface AgenticErrorOpts {
143
- message: string;
144
- stack?: string;
145
- source?: Participant;
146
- enviornment?: AgenticEnvironment;
132
+ type SituationContext$1<TEvent extends SemanticEvent = SemanticEvent> = {
133
+ readonly event: TEvent;
134
+ readonly participant: Participant;
135
+ };
136
+ declare abstract class SituationSpecification<TEvent extends SemanticEvent = SemanticEvent> {
137
+ abstract isSatisfiedBy(situationContext: SituationContext$1<TEvent>): boolean;
138
+ and(other: SituationSpecification<TEvent>): SituationSpecification<TEvent>;
139
+ or(other: SituationSpecification<TEvent>): SituationSpecification<TEvent>;
140
+ not(): SituationSpecification<TEvent>;
147
141
  }
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;
142
+
143
+ interface SituationHandler {
144
+ readonly specification: SituationSpecification;
145
+ readonly processor: SituationProcessor;
146
+ }
147
+ type SituationContext<TEvent extends SemanticEvent = SemanticEvent> = {
148
+ readonly event: TEvent;
149
+ readonly participant: Participant;
150
+ };
151
+ interface SituationProcessor {
152
+ apply(context: SituationContext): void | Promise<void>;
154
153
  }
155
154
 
156
- type ParticipantClassConstructor = new (...args: any[]) => Participant;
155
+ type ParticipantRole = "agent" | "human";
156
+ type ParticipantManifest = {
157
+ readonly id: string;
158
+ readonly name: string;
159
+ readonly role: ParticipantRole;
160
+ readonly capabilities?: readonly string[];
161
+ };
157
162
  declare abstract class Participant {
158
- private environments;
159
- protected listens: ParticipantClassConstructor[];
160
- private active;
161
- join(environment: AgenticEnvironment): void;
162
- leave(environment: AgenticEnvironment): void;
163
- isJoinedTo(environment: AgenticEnvironment): boolean;
164
- getEnvironments(): AgenticEnvironment[];
165
- getListeners(): ParticipantClassConstructor[];
166
- getEnvironmentState(environment: AgenticEnvironment): boolean | undefined;
167
- markInactive(environment: AgenticEnvironment): void;
168
- markActive(environment: AgenticEnvironment): void;
169
- abstract onParticipantJoined(participant: Participant): Promise<void> | void;
170
- abstract onParticipantLeft(participant: Participant): Promise<void> | void;
171
- abstract onJoined(): Promise<void> | void;
172
- abstract onLeft(): Promise<void> | void;
173
- abstract onFunctionCall(item: FunctionCallItem): Promise<void> | void;
174
- abstract onExternalFunctionCall(source: Participant, item: FunctionCallItem): Promise<void> | void;
175
- abstract onFunctionCallOutput(item: FunctionCallOutputItem): Promise<void> | void;
176
- abstract onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): Promise<void> | void;
177
- abstract onReasoning(item: ReasoningItem): Promise<void> | void;
178
- abstract onExternalReasoning(source: Participant, item: ReasoningItem): Promise<void> | void;
179
- abstract onModelMessage(item: ModelMessageItem): Promise<void> | void;
180
- abstract onExternalModelMessage(source: Participant, item: ModelMessageItem): Promise<void> | void;
181
- abstract onMessage(message: string): Promise<void> | void;
182
- abstract onInternalEvent(item: SemanticEvent<unknown>): Promise<void> | void;
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;
186
- }
187
-
188
- interface AgenticEnvironmentOptions {
189
- silent?: boolean;
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;
163
+ private readonly manifest;
164
+ private handlers;
165
+ protected constructor(manifest: ParticipantManifest, handlers: SituationHandler[]);
166
+ getManifest(): ParticipantManifest;
167
+ getId(): string;
168
+ getHandlers(): SituationHandler[];
169
+ setHandlers(handlers: SituationHandler[]): void;
170
+ }
171
+
172
+ declare class SemanticEvent<TType extends string = string, TPayload = unknown> {
173
+ readonly type: TType;
174
+ readonly producerId: string;
175
+ readonly occurredAt: Date;
176
+ readonly payload: TPayload;
177
+ constructor(type: TType, producerId: string, occurredAt: Date, payload: TPayload);
178
+ static create<TType extends string = string, TPayload = unknown>(type: TType, producerId: string, payload: TPayload): SemanticEvent<TType, TPayload>;
179
+ }
180
+
181
+ interface FunctionCallRunner {
182
+ run(call: FunctionCallItem, tool: Tool): Promise<FunctionCallOutputItem>;
183
+ }
184
+ interface FunctionCallParams {
185
+ call: FunctionCallItem;
186
+ inferenceInput: InferenceInput;
187
+ }
188
+
189
+ type LoopStateId = "context_update" | "inference" | "inference_streaming" | "function_call" | "model_message" | "idle";
190
+ type ReceivedMessage = {
191
+ content: string;
192
+ input: InferenceInput;
193
+ };
194
+ interface FunctionCallExecutionOutput {
195
+ item: FunctionCallOutputItem;
196
+ }
197
+ interface ModelMessageParams {
198
+ answer: ModelMessageItem;
199
+ }
200
+ interface LoopStateContract {
201
+ context_update: {
202
+ input: ReceivedMessage;
203
+ output: InferenceInput;
204
+ };
205
+ inference: {
206
+ input: InferenceInput;
207
+ output: InferenceOutput;
208
+ };
209
+ inference_streaming: {
210
+ input: InferenceInput;
211
+ output: InferenceOutput;
212
+ };
213
+ function_call: {
214
+ input: FunctionCallParams;
215
+ output: FunctionCallExecutionOutput;
216
+ };
217
+ model_message: {
218
+ input: ModelMessageParams;
219
+ output: void;
220
+ };
221
+ interception: {
222
+ input: InterceptionParams;
223
+ output: InterceptionOutput;
224
+ };
225
+ idle: {
226
+ input: undefined;
227
+ output: void;
228
+ };
229
+ }
230
+ type InterceptionOutput = {
231
+ type: "continue";
232
+ transition: LoopTransition;
233
+ } | {
234
+ type: "pause";
235
+ pendingTransition: LoopTransition;
236
+ } | {
237
+ type: "stop";
238
+ reason?: string;
239
+ };
240
+ interface InterceptionParams {
241
+ pendingTransition: LoopTransition;
242
+ }
243
+ type LoopTransition<TStateId extends LoopStateId = LoopStateId> = {
244
+ [K in TStateId]: {
245
+ nextStateId: K;
246
+ input: LoopStateContract[K]["input"];
247
+ };
248
+ }[TStateId];
249
+
250
+ type InferenceInput = {
251
+ model: string;
213
252
  maxOutputTokens?: number;
214
253
  reasoningEffort?: string;
215
254
  tools?: Tool[];
216
255
  streaming?: boolean;
217
256
  structuredOutput?: StructuredOutputFormat;
218
257
  context: ModelContext;
219
- caller: Participant;
220
- environment: AgenticEnvironment;
221
- signal?: AbortSignal;
222
258
  };
223
-
224
- declare class InputTokenDetails {
225
- readonly cached_tokens: number;
226
- constructor(cached_tokens: number);
227
- }
228
- declare class OutputTokenDetails {
229
- readonly reasoning_tokens: number;
230
- constructor(reasoning_tokens: number);
231
- }
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);
239
- }
240
-
241
- declare class InferenceResponse {
242
- readonly contextItems: ContextItem[];
243
- readonly tokenUsage?: TokenUsage;
244
- constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
259
+ type InferenceItem = FunctionCallItem | ReasoningItem | ModelMessageItem;
260
+ type InferenceOutput = {
261
+ items: InferenceItem[];
262
+ rowResponse: any;
263
+ };
264
+ interface InferenceRunner {
265
+ run(request: InferenceInput): Promise<InferenceOutput>;
266
+ stream(request: InferenceInput): AsyncGenerator<SemanticEvent>;
245
267
  }
246
268
 
247
269
  interface InferenceEndpointMapper {
248
- toRequest(inferenceParams: InferenceParams<ModelName>): any;
249
- toResponse(response: any): InferenceResponse;
270
+ toRequest(inferenceInput: InferenceInput): any;
271
+ toResponse(response: any): InferenceOutput;
250
272
  }
251
273
 
252
274
  interface Endpoint {
253
275
  endpointMapper: InferenceEndpointMapper;
254
- infer(requestParams: InferenceParams<ModelName>): Promise<InferenceResponse>;
255
- stream(requestParams: InferenceParams<ModelName>, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
276
+ infer(requestParams: InferenceInput): Promise<InferenceOutput>;
277
+ stream(requestParams: InferenceInput): AsyncIterable<SemanticEvent>;
256
278
  }
257
279
 
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";
280
+ type GenerativeModel = {
281
+ endpoint: Endpoint;
282
+ specification: ModelSpecification;
283
+ };
284
+ type ModelSpecification = {
285
+ name: string;
286
+ provider: string;
287
+ supportsReasoningEffort: boolean;
288
+ supportedReasoningEfforts: string[];
289
+ supportsStreaming: boolean;
290
+ contextWindowSize: number;
291
+ supportedContextItemTypes: string[];
292
+ maxOutputTokens: number;
293
+ supportsFunctionCalling: boolean;
294
+ supportsStructuredOutput: boolean;
295
+ };
296
+
297
+ interface RequestValidationRule {
298
+ readonly name: string;
299
+ isValid(inferenceInput: InferenceInput, model: ModelSpecification): boolean;
300
+ }
259
301
 
260
302
  type StructuredOutputFormat = {
261
303
  name?: string;
@@ -269,6 +311,23 @@ interface ModelContextRepository {
269
311
  getByProjectId(projectId: string): Promise<ModelContext[]>;
270
312
  }
271
313
 
314
+ declare class InputTokenDetails {
315
+ readonly cached_tokens: number;
316
+ constructor(cached_tokens: number);
317
+ }
318
+ declare class OutputTokenDetails {
319
+ readonly reasoning_tokens: number;
320
+ constructor(reasoning_tokens: number);
321
+ }
322
+ declare class TokenUsage {
323
+ readonly inputTokens: number;
324
+ readonly outputTokens: number;
325
+ readonly totalTokens: number;
326
+ readonly inputTokenDetails: InputTokenDetails;
327
+ readonly outputTokenDetails: OutputTokenDetails;
328
+ constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
329
+ }
330
+
272
331
  interface McpServerConfig {
273
332
  /** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */
274
333
  url: string;
@@ -334,15 +393,6 @@ declare class McpToolRegistry {
334
393
  close(): Promise<void>;
335
394
  }
336
395
 
337
- declare class InMemoryModelContextRepository implements ModelContextRepository {
338
- private readonly store;
339
- private readonly projectIndex;
340
- save(context: ModelContext): Promise<void>;
341
- get(id: string): Promise<ModelContext>;
342
- getByProjectId(projectId: string): Promise<ModelContext[]>;
343
- private clone;
344
- }
345
-
346
396
  declare class SystemMessageItem extends ContextItem {
347
397
  readonly type = "message";
348
398
  readonly role = "system";
@@ -354,28 +404,215 @@ declare class SystemMessageItem extends ContextItem {
354
404
  }): SystemMessageItem;
355
405
  }
356
406
 
357
- declare class BaseParticipant extends Participant {
358
- onFunctionCall(_item: FunctionCallItem): void;
359
- onExternalFunctionCall(_source: Participant, _item: FunctionCallItem): void;
360
- onFunctionCallOutput(_item: FunctionCallOutputItem): void;
361
- onExternalFunctionCallOutput(_source: Participant, _item: FunctionCallOutputItem): void;
362
- onReasoning(_item: ReasoningItem): void;
363
- onExternalReasoning(_source: Participant, _item: ReasoningItem): void;
364
- onModelMessage(_item: ModelMessageItem): void;
365
- onExternalModelMessage(_source: Participant, _item: ModelMessageItem): void;
366
- onMessage(_message: string): void;
367
- onJoined(): void;
368
- onLeft(): void;
369
- onParticipantJoined(_participant: Participant): void;
370
- onParticipantLeft(_participant: Participant): void;
371
- onInternalEvent(_item: SemanticEvent<unknown>): void;
372
- onExternalEvent(_source: Participant, _item: SemanticEvent<unknown>): void;
373
- onError(_error: AgenticError): void;
374
- onParticipantError(_source: Participant, _error: AgenticError): void;
375
- }
376
-
377
- declare const runInference: (inferenceParams: InferenceParams<ModelName>) => void;
378
- declare const executeFunctionCall: (environment: AgenticEnvironment, functionCallItem: FunctionCallItem, tool: Tool, caller: Participant) => void;
379
- declare const sendMessage: (environment: AgenticEnvironment, message: string, caller: Participant) => void;
380
-
381
- export { AgenticEnvironment, AgenticError, BaseParticipant, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, InMemoryModelContextRepository, type InferenceParams, InferenceResponse, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, type ModelName, OutputTokenDetails, Participant, ReasoningItem, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, executeFunctionCall, runInference, sendMessage };
407
+ declare class Memory {
408
+ private readonly context;
409
+ private constructor();
410
+ getContext(): ModelContext;
411
+ static create(): Memory;
412
+ }
413
+
414
+ declare class Agent extends Participant {
415
+ private memory;
416
+ private developerMessage;
417
+ private tools;
418
+ constructor(manifest: ParticipantManifest, developerMessage: string, tools: Tool[], memory: Memory, handlers: SituationHandler[]);
419
+ static create({ name, instruction, tools, capabilities, handlers, }: {
420
+ instruction: string;
421
+ tools: Tool[];
422
+ name: string;
423
+ capabilities: readonly string[];
424
+ handlers: SituationHandler[];
425
+ }): Agent;
426
+ getTools(): Tool[];
427
+ getDeveloperMessage(): string;
428
+ getMemory(): Memory;
429
+ }
430
+
431
+ declare function createAgent({ name, capabilities, instruction, tools, handlers, }: {
432
+ name: string;
433
+ capabilities: readonly string[];
434
+ instruction: string;
435
+ tools: Tool[];
436
+ handlers: SituationHandler[];
437
+ }): Agent;
438
+
439
+ declare class Human extends Participant {
440
+ constructor(manifest: ParticipantManifest, handlers: SituationHandler[]);
441
+ static create({ name, capabilities, handlers, }: {
442
+ name: string;
443
+ capabilities: readonly string[];
444
+ handlers: SituationHandler[];
445
+ }): Human;
446
+ }
447
+
448
+ declare function createHuman({ name, capabilities, handlers, }: {
449
+ name: string;
450
+ capabilities: readonly string[];
451
+ handlers: SituationHandler[];
452
+ }): Human;
453
+
454
+ declare abstract class RuntimeState {
455
+ participants: Map<string, Participant>;
456
+ addParticipant(participant: Participant): void;
457
+ removeParticipant(participant: Participant): void;
458
+ getParticipant(id: string): Participant | undefined;
459
+ getParticipants(): readonly Participant[];
460
+ }
461
+
462
+ interface InterceptionHandler {
463
+ isSatisfiedBy(transition: LoopTransition): boolean;
464
+ handle(transition: LoopTransition): Promise<LoopTransition>;
465
+ }
466
+
467
+ declare class EventProcessor {
468
+ process(event: SemanticEvent, consumer: Participant): void;
469
+ }
470
+
471
+ declare class RuntimeService<TRuntimeState extends RuntimeState> {
472
+ readonly state: TRuntimeState;
473
+ private readonly processor;
474
+ private readonly inferenceRunner;
475
+ private readonly functionCallRunner;
476
+ constructor(state: TRuntimeState, processor: EventProcessor, inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
477
+ join(participant: Participant): void;
478
+ leave(participant: Participant): void;
479
+ publish(event: SemanticEvent): void;
480
+ getParticipant(id: string): Participant | undefined;
481
+ getInferenceRunner(): InferenceRunner;
482
+ getFunctionCallRunner(): FunctionCallRunner;
483
+ }
484
+
485
+ type InferenceRunnerConfig = {
486
+ supportedModels?: GenerativeModel[];
487
+ runner?: InferenceRunner;
488
+ };
489
+ declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
490
+ initializeRuntime: (config: {
491
+ state: TRuntimeState;
492
+ inferenceRunnerConfig?: InferenceRunnerConfig;
493
+ }) => RuntimeService<TRuntimeState>;
494
+ resolveRuntime: () => RuntimeService<TRuntimeState>;
495
+ resolveParticipant: (id: string) => Participant;
496
+ join: (participant: Participant) => void;
497
+ leave: (participant: Participant) => void;
498
+ sendMessage: (message: string, senderId: string) => void;
499
+ sendEvent: (event: SemanticEvent, senderId: string) => void;
500
+ runLoop: (agentId: string, message: string, inferenceInput: InferenceInput, interceptionHandler?: InterceptionHandler) => void;
501
+ };
502
+
503
+ declare const supportedModels: GenerativeModel[];
504
+
505
+ declare class OpenAIResponses implements Endpoint {
506
+ endpointMapper: InferenceEndpointMapper;
507
+ private _client?;
508
+ constructor(endpointMapper?: InferenceEndpointMapper);
509
+ private get client();
510
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
511
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
512
+ }
513
+
514
+ /**
515
+ * Optional connection config. When omitted, the `openai` SDK reads
516
+ * `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
517
+ * default-constructed runtime targets whatever `OPENAI_BASE_URL` points
518
+ * at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
519
+ * explicit base URL + credential.
520
+ */
521
+ interface OpenAICompatibleConfig {
522
+ baseURL?: string;
523
+ apiKey?: string;
524
+ /**
525
+ * Extra request-body fields merged into every `chat.completions`
526
+ * call. This is how provider-specific quirks are handled **without
527
+ * a per-provider subclass in mozaik** — the consumer supplies the
528
+ * vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
529
+ * safety flags, routing hints). Standard fields the runtime already
530
+ * sets (`model`, `messages`, `tools`, `reasoning_effort`) take
531
+ * precedence and are not overwritten.
532
+ */
533
+ extraBody?: Record<string, unknown>;
534
+ }
535
+ /**
536
+ * Generic adapter for any **OpenAI Chat Completions**-compatible
537
+ * endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
538
+ * Ollama, etc. It speaks `/chat/completions` (not the Responses API),
539
+ * which is the dialect third-party OpenAI-compatible providers expose.
540
+ *
541
+ * The base URL and credential are configurable; everything else (the
542
+ * `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
543
+ * usage extraction) is provider-agnostic. Provider-specific request
544
+ * shaping (e.g. DeepSeek's `thinking` field) is supplied by the
545
+ * consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
546
+ * generic and gains no per-provider subclasses.
547
+ *
548
+ * Was `DeepSeekChatCompletions`; generalized so consumers can point it
549
+ * at any OpenAI-compatible endpoint.
550
+ */
551
+ declare class OpenAIChatCompletions implements Endpoint {
552
+ endpointMapper: InferenceEndpointMapper;
553
+ private _client?;
554
+ private readonly clientConfig;
555
+ private readonly extraBody;
556
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
557
+ private get client();
558
+ private buildRequest;
559
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
560
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
561
+ }
562
+
563
+ interface AnthropicConnectionConfig {
564
+ baseURL?: string;
565
+ apiKey?: string;
566
+ }
567
+ /**
568
+ * Native Anthropic adapter on the `@anthropic-ai/sdk` (`messages.create`).
569
+ * Maps domain context to Anthropic's `messages`/`content` blocks shape,
570
+ * system prompt, tools, adaptive thinking, and structured output config.
571
+ */
572
+ declare class AnthropicMessages implements Endpoint {
573
+ endpointMapper: InferenceEndpointMapper;
574
+ private _client?;
575
+ private readonly clientConfig;
576
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
577
+ private get client();
578
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
579
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
580
+ }
581
+
582
+ interface GeminiConnectionConfig {
583
+ baseURL?: string;
584
+ apiKey?: string;
585
+ }
586
+ /**
587
+ * Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
588
+ * `generateContentStream`). Unlike an OpenAI-compat shim this maps our
589
+ * domain context to Gemini's native `contents`/`parts` shape, system
590
+ * instruction, `functionDeclarations`, and `thinkingConfig`, and reads
591
+ * thought parts + native usage metadata back out. Another `ModelRuntime`
592
+ * — no runner or port changes.
593
+ */
594
+ declare class GeminiGenerateContent implements Endpoint {
595
+ endpointMapper: InferenceEndpointMapper;
596
+ private _client?;
597
+ private readonly clientConfig;
598
+ constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
599
+ private get client();
600
+ infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
601
+ stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
602
+ }
603
+
604
+ declare class InferenceInputValidator {
605
+ private readonly rules;
606
+ constructor(rules?: RequestValidationRule[]);
607
+ validate(inferenceInput: InferenceInput, model: ModelSpecification): void;
608
+ }
609
+
610
+ declare class DefaultInferenceRunner implements InferenceRunner {
611
+ private readonly supportedModels;
612
+ private readonly requestValidator;
613
+ constructor(supportedModels: GenerativeModel[], requestValidator: InferenceInputValidator);
614
+ run(input: InferenceInput): Promise<InferenceOutput>;
615
+ stream(input: InferenceInput): AsyncGenerator<SemanticEvent>;
616
+ }
617
+
618
+ export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type SituationContext, type SituationHandler, type SituationProcessor, SituationSpecification, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };