@mozaik-ai/core 3.14.0 → 4.0.0-beta.2
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/README.md +9 -117
- package/dist/index.d.mts +338 -200
- package/dist/index.d.ts +338 -200
- package/dist/index.js +748 -585
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +739 -577
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,59 +3,23 @@ declare abstract class ContextItem {
|
|
|
3
3
|
getType(): string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
declare class
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}):
|
|
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
|
|
79
|
-
readonly
|
|
80
|
-
readonly
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
|
157
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
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(
|
|
249
|
-
toResponse(response: any):
|
|
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:
|
|
255
|
-
stream(requestParams:
|
|
170
|
+
infer(requestParams: InferenceInput): Promise<InferenceOutput>;
|
|
171
|
+
stream(requestParams: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
256
172
|
}
|
|
257
173
|
|
|
258
|
-
type
|
|
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,227 @@ declare class SystemMessageItem extends ContextItem {
|
|
|
354
293
|
}): SystemMessageItem;
|
|
355
294
|
}
|
|
356
295
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
declare const supportedModels: GenerativeModel[];
|
|
426
|
+
|
|
427
|
+
declare class OpenAIResponses implements Endpoint {
|
|
428
|
+
endpointMapper: InferenceEndpointMapper;
|
|
429
|
+
private readonly client;
|
|
430
|
+
constructor(endpointMapper?: InferenceEndpointMapper);
|
|
431
|
+
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
432
|
+
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Optional connection config. When omitted, the `openai` SDK reads
|
|
437
|
+
* `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
|
|
438
|
+
* default-constructed runtime targets whatever `OPENAI_BASE_URL` points
|
|
439
|
+
* at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
|
|
440
|
+
* explicit base URL + credential.
|
|
441
|
+
*/
|
|
442
|
+
interface OpenAICompatibleConfig {
|
|
443
|
+
baseURL?: string;
|
|
444
|
+
apiKey?: string;
|
|
445
|
+
/**
|
|
446
|
+
* Extra request-body fields merged into every `chat.completions`
|
|
447
|
+
* call. This is how provider-specific quirks are handled **without
|
|
448
|
+
* a per-provider subclass in mozaik** — the consumer supplies the
|
|
449
|
+
* vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
|
|
450
|
+
* safety flags, routing hints). Standard fields the runtime already
|
|
451
|
+
* sets (`model`, `messages`, `tools`, `reasoning_effort`) take
|
|
452
|
+
* precedence and are not overwritten.
|
|
453
|
+
*/
|
|
454
|
+
extraBody?: Record<string, unknown>;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Generic adapter for any **OpenAI Chat Completions**-compatible
|
|
458
|
+
* endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
|
|
459
|
+
* Ollama, etc. It speaks `/chat/completions` (not the Responses API),
|
|
460
|
+
* which is the dialect third-party OpenAI-compatible providers expose.
|
|
461
|
+
*
|
|
462
|
+
* The base URL and credential are configurable; everything else (the
|
|
463
|
+
* `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
|
|
464
|
+
* usage extraction) is provider-agnostic. Provider-specific request
|
|
465
|
+
* shaping (e.g. DeepSeek's `thinking` field) is supplied by the
|
|
466
|
+
* consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
|
|
467
|
+
* generic and gains no per-provider subclasses.
|
|
468
|
+
*
|
|
469
|
+
* Was `DeepSeekChatCompletions`; generalized so consumers can point it
|
|
470
|
+
* at any OpenAI-compatible endpoint.
|
|
471
|
+
*/
|
|
472
|
+
declare class OpenAIChatCompletions implements Endpoint {
|
|
473
|
+
endpointMapper: InferenceEndpointMapper;
|
|
474
|
+
private readonly client;
|
|
475
|
+
private readonly extraBody;
|
|
476
|
+
constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
|
|
477
|
+
private buildRequest;
|
|
478
|
+
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
479
|
+
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
interface AnthropicConnectionConfig {
|
|
483
|
+
baseURL?: string;
|
|
484
|
+
apiKey?: string;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Native Anthropic adapter on the `@anthropic-ai/sdk` (`messages.create`).
|
|
488
|
+
* Maps domain context to Anthropic's `messages`/`content` blocks shape,
|
|
489
|
+
* system prompt, tools, adaptive thinking, and structured output config.
|
|
490
|
+
*/
|
|
491
|
+
declare class AnthropicMessages implements Endpoint {
|
|
492
|
+
endpointMapper: InferenceEndpointMapper;
|
|
493
|
+
private readonly client;
|
|
494
|
+
constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
|
|
495
|
+
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
496
|
+
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
interface GeminiConnectionConfig {
|
|
500
|
+
baseURL?: string;
|
|
501
|
+
apiKey?: string;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
|
|
505
|
+
* `generateContentStream`). Unlike an OpenAI-compat shim this maps our
|
|
506
|
+
* domain context to Gemini's native `contents`/`parts` shape, system
|
|
507
|
+
* instruction, `functionDeclarations`, and `thinkingConfig`, and reads
|
|
508
|
+
* thought parts + native usage metadata back out. Another `ModelRuntime`
|
|
509
|
+
* — no runner or port changes.
|
|
510
|
+
*/
|
|
511
|
+
declare class GeminiGenerateContent implements Endpoint {
|
|
512
|
+
endpointMapper: InferenceEndpointMapper;
|
|
513
|
+
private readonly client;
|
|
514
|
+
constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
|
|
515
|
+
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
516
|
+
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
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 };
|