@mozaik-ai/core 3.14.0 → 4.0.0-beta.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.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,74 @@ 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
+ declare class SemanticEvent<TType extends string = string, TPayload = unknown> {
133
+ readonly type: TType;
134
+ readonly producerId: string;
135
+ readonly occurredAt: Date;
136
+ readonly payload: TPayload;
137
+ constructor(type: TType, producerId: string, occurredAt: Date, payload: TPayload);
138
+ static create<TType extends string = string, TPayload = unknown>(type: TType, producerId: string, payload: TPayload): SemanticEvent<TType, TPayload>;
147
139
  }
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;
140
+
141
+ interface FunctionCallRunner {
142
+ run(call: FunctionCallItem, tool: Tool): Promise<FunctionCallOutputItem>;
154
143
  }
155
144
 
156
- type ParticipantClassConstructor = new (...args: any[]) => Participant;
157
- 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;
145
+ type InferenceInput = {
146
+ model: string;
213
147
  maxOutputTokens?: number;
214
148
  reasoningEffort?: string;
215
149
  tools?: Tool[];
216
150
  streaming?: boolean;
217
151
  structuredOutput?: StructuredOutputFormat;
218
152
  context: ModelContext;
219
- caller: Participant;
220
- environment: AgenticEnvironment;
221
- signal?: AbortSignal;
222
153
  };
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);
154
+ type InferenceItem = FunctionCallItem | ReasoningItem | ModelMessageItem;
155
+ type InferenceOutput = {
156
+ items: InferenceItem[];
157
+ rowResponse: any;
158
+ };
159
+ interface InferenceRunner {
160
+ run(request: InferenceInput): Promise<InferenceOutput>;
245
161
  }
246
162
 
247
163
  interface InferenceEndpointMapper {
248
- toRequest(inferenceParams: InferenceParams<ModelName>): any;
249
- toResponse(response: any): InferenceResponse;
164
+ toRequest(inferenceInput: InferenceInput): any;
165
+ toResponse(response: any): InferenceOutput;
250
166
  }
251
167
 
252
168
  interface Endpoint {
253
169
  endpointMapper: InferenceEndpointMapper;
254
- infer(requestParams: InferenceParams<ModelName>): Promise<InferenceResponse>;
255
- stream(requestParams: InferenceParams<ModelName>, signal?: AbortSignal): AsyncIterable<SemanticEvent<unknown>>;
170
+ infer(requestParams: InferenceInput): Promise<InferenceOutput>;
171
+ stream(requestParams: InferenceInput): AsyncIterable<SemanticEvent>;
256
172
  }
257
173
 
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";
174
+ type GenerativeModel = {
175
+ endpoint: Endpoint;
176
+ specification: ModelSpecification;
177
+ };
178
+ type ModelSpecification = {
179
+ name: string;
180
+ provider: string;
181
+ supportsReasoningEffort: boolean;
182
+ supportedReasoningEfforts: string[];
183
+ supportsStreaming: boolean;
184
+ contextWindowSize: number;
185
+ supportedContextItemTypes: string[];
186
+ maxOutputTokens: number;
187
+ supportsFunctionCalling: boolean;
188
+ supportsStructuredOutput: boolean;
189
+ };
259
190
 
260
191
  type StructuredOutputFormat = {
261
192
  name?: string;
@@ -269,6 +200,23 @@ interface ModelContextRepository {
269
200
  getByProjectId(projectId: string): Promise<ModelContext[]>;
270
201
  }
271
202
 
203
+ declare class InputTokenDetails {
204
+ readonly cached_tokens: number;
205
+ constructor(cached_tokens: number);
206
+ }
207
+ declare class OutputTokenDetails {
208
+ readonly reasoning_tokens: number;
209
+ constructor(reasoning_tokens: number);
210
+ }
211
+ declare class TokenUsage {
212
+ readonly inputTokens: number;
213
+ readonly outputTokens: number;
214
+ readonly totalTokens: number;
215
+ readonly inputTokenDetails: InputTokenDetails;
216
+ readonly outputTokenDetails: OutputTokenDetails;
217
+ constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
218
+ }
219
+
272
220
  interface McpServerConfig {
273
221
  /** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */
274
222
  url: string;
@@ -334,15 +282,6 @@ declare class McpToolRegistry {
334
282
  close(): Promise<void>;
335
283
  }
336
284
 
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
285
  declare class SystemMessageItem extends ContextItem {
347
286
  readonly type = "message";
348
287
  readonly role = "system";
@@ -354,28 +293,133 @@ declare class SystemMessageItem extends ContextItem {
354
293
  }): SystemMessageItem;
355
294
  }
356
295
 
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 };
296
+ type SituationContext$1<TEvent extends SemanticEvent = SemanticEvent> = {
297
+ readonly event: TEvent;
298
+ readonly participant: Participant;
299
+ };
300
+ declare abstract class SituationSpecification<TEvent extends SemanticEvent = SemanticEvent> {
301
+ abstract isSatisfiedBy(situationContext: SituationContext$1<TEvent>): boolean;
302
+ and(other: SituationSpecification<TEvent>): SituationSpecification<TEvent>;
303
+ or(other: SituationSpecification<TEvent>): SituationSpecification<TEvent>;
304
+ not(): SituationSpecification<TEvent>;
305
+ }
306
+
307
+ interface SituationHandler {
308
+ readonly specification: SituationSpecification;
309
+ readonly processor: SituationProcessor;
310
+ }
311
+ type SituationContext<TEvent extends SemanticEvent = SemanticEvent> = {
312
+ readonly event: TEvent;
313
+ readonly participant: Participant;
314
+ };
315
+ interface SituationProcessor {
316
+ apply(context: SituationContext): void | Promise<void>;
317
+ }
318
+
319
+ type ParticipantRole = "agent" | "human";
320
+ type ParticipantManifest = {
321
+ readonly id: string;
322
+ readonly name: string;
323
+ readonly role: ParticipantRole;
324
+ readonly capabilities?: readonly string[];
325
+ };
326
+ declare abstract class Participant {
327
+ private readonly manifest;
328
+ private handlers;
329
+ protected constructor(manifest: ParticipantManifest, handlers: SituationHandler[]);
330
+ getManifest(): ParticipantManifest;
331
+ getId(): string;
332
+ getHandlers(): SituationHandler[];
333
+ }
334
+
335
+ declare class Memory {
336
+ private readonly context;
337
+ private constructor();
338
+ getContext(): ModelContext;
339
+ static create(): Memory;
340
+ }
341
+
342
+ declare class Agent extends Participant {
343
+ private memory;
344
+ private developerMessage;
345
+ private tools;
346
+ constructor(manifest: ParticipantManifest, developerMessage: string, tools: Tool[], memory: Memory, handlers: SituationHandler[]);
347
+ static create({ name, instruction, tools, capabilities, handlers, }: {
348
+ instruction: string;
349
+ tools: Tool[];
350
+ name: string;
351
+ capabilities: readonly string[];
352
+ handlers: SituationHandler[];
353
+ }): Agent;
354
+ getTools(): Tool[];
355
+ getDeveloperMessage(): string;
356
+ getMemory(): Memory;
357
+ }
358
+
359
+ declare function createAgent({ name, capabilities, instruction, tools, handlers, }: {
360
+ name: string;
361
+ capabilities: readonly string[];
362
+ instruction: string;
363
+ tools: Tool[];
364
+ handlers: SituationHandler[];
365
+ }): Agent;
366
+
367
+ declare class Human extends Participant {
368
+ constructor(manifest: ParticipantManifest, handlers: SituationHandler[]);
369
+ static create({ name, capabilities, handlers, }: {
370
+ name: string;
371
+ capabilities: readonly string[];
372
+ handlers: SituationHandler[];
373
+ }): Human;
374
+ }
375
+
376
+ declare function createHuman({ name, capabilities, handlers, }: {
377
+ name: string;
378
+ capabilities: readonly string[];
379
+ handlers: SituationHandler[];
380
+ }): Human;
381
+
382
+ declare abstract class RuntimeState {
383
+ participants: Map<string, Participant>;
384
+ addParticipant(participant: Participant): void;
385
+ removeParticipant(participant: Participant): void;
386
+ getParticipant(id: string): Participant | undefined;
387
+ getParticipants(): readonly Participant[];
388
+ }
389
+
390
+ declare class EventProcessor {
391
+ process(event: SemanticEvent, consumer: Participant): void;
392
+ }
393
+
394
+ declare class RuntimeService<TRuntimeState extends RuntimeState> {
395
+ readonly state: TRuntimeState;
396
+ private readonly processor;
397
+ private readonly inferenceRunner;
398
+ private readonly functionCallRunner;
399
+ constructor(state: TRuntimeState, processor: EventProcessor, inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
400
+ join(participant: Participant): void;
401
+ leave(participant: Participant): void;
402
+ publish(event: SemanticEvent): void;
403
+ getParticipant(id: string): Participant | undefined;
404
+ getInferenceRunner(): InferenceRunner;
405
+ getFunctionCallRunner(): FunctionCallRunner;
406
+ }
407
+
408
+ type InferenceRunnerConfig = {
409
+ supportedModels: GenerativeModel[];
410
+ runner: InferenceRunner;
411
+ };
412
+ declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
413
+ initializeRuntime: (config: {
414
+ state: TRuntimeState;
415
+ inferenceRunnerConfig?: InferenceRunnerConfig;
416
+ }) => RuntimeService<TRuntimeState>;
417
+ resolveRuntime: () => RuntimeService<TRuntimeState>;
418
+ resolveParticipant: (id: string) => Participant;
419
+ join: (participant: Participant) => void;
420
+ leave: (participant: Participant) => void;
421
+ sendMessage: (message: string, senderId: string) => void;
422
+ runLoop: (agentId: string, message: string, inferenceInput: InferenceInput) => void;
423
+ };
424
+
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 };