@mozaik-ai/core 4.0.6 → 4.2.0-beta.0
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 +21 -21
- package/dist/index.d.mts +29 -577
- package/dist/index.d.ts +29 -577
- package/dist/index.js +135 -2129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -2092
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,139 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
abstract readonly type: string;
|
|
3
|
-
getType(): string;
|
|
4
|
-
}
|
|
5
|
-
|
|
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();
|
|
12
|
-
static rehydrate(data: {
|
|
13
|
-
callId: string;
|
|
14
|
-
name: string;
|
|
15
|
-
args: string;
|
|
16
|
-
}): FunctionCallItem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare abstract class ItemContent {
|
|
20
|
-
abstract readonly type: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class OutputText extends ItemContent {
|
|
24
|
-
readonly text: string;
|
|
25
|
-
readonly type = "output_text";
|
|
26
|
-
private constructor();
|
|
27
|
-
static rehydrate(data: {
|
|
28
|
-
text: string;
|
|
29
|
-
}): OutputText;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare class ModelMessageItem extends ContextItem {
|
|
33
|
-
readonly type = "message";
|
|
34
|
-
readonly role = "assistant";
|
|
35
|
-
readonly content: OutputText;
|
|
36
|
-
private constructor();
|
|
37
|
-
static rehydrate(data: {
|
|
38
|
-
text: string;
|
|
39
|
-
}): ModelMessageItem;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare class InputText extends ItemContent {
|
|
43
|
-
readonly text: string;
|
|
44
|
-
readonly type = "input_text";
|
|
45
|
-
private constructor();
|
|
46
|
-
static create(text: string): InputText;
|
|
47
|
-
static rehydrate(data: {
|
|
48
|
-
text: string;
|
|
49
|
-
}): InputText;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
declare class SummaryText extends ItemContent {
|
|
53
|
-
readonly text: string;
|
|
54
|
-
readonly type = "summary_text";
|
|
55
|
-
private constructor();
|
|
56
|
-
static rehydrate(data: {
|
|
57
|
-
text: string;
|
|
58
|
-
}): SummaryText;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
declare class ReasoningItem extends ContextItem {
|
|
62
|
-
readonly type = "reasoning";
|
|
63
|
-
readonly content: InputText | undefined;
|
|
64
|
-
readonly encryptedContent: string | undefined;
|
|
65
|
-
readonly summary: SummaryText[];
|
|
66
|
-
private constructor();
|
|
67
|
-
static rehydrate(data: {
|
|
68
|
-
content: InputText | undefined;
|
|
69
|
-
encryptedContent: string | undefined;
|
|
70
|
-
summary: SummaryText[];
|
|
71
|
-
}): ReasoningItem;
|
|
72
|
-
}
|
|
73
|
-
|
|
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
|
-
addContextItem(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;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
declare class FunctionCallOutputItem extends ContextItem {
|
|
111
|
-
readonly type = "function_call_output";
|
|
112
|
-
readonly callId: string;
|
|
113
|
-
readonly output: InputText;
|
|
114
|
-
private constructor();
|
|
115
|
-
static create(callId: string, output: string): FunctionCallOutputItem;
|
|
116
|
-
static rehydrate(data: {
|
|
117
|
-
callId: string;
|
|
118
|
-
output: InputText;
|
|
119
|
-
}): FunctionCallOutputItem;
|
|
120
|
-
}
|
|
121
|
-
|
|
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>;
|
|
129
|
-
}
|
|
130
|
-
type Tool = FunctionTool;
|
|
131
|
-
|
|
132
|
-
type SituationContext$1<TEvent extends SemanticEvent = SemanticEvent> = {
|
|
1
|
+
type SituationContext$1<TEvent extends SpaceEvent = SpaceEvent> = {
|
|
133
2
|
readonly event: TEvent;
|
|
134
3
|
readonly participant: Participant;
|
|
135
4
|
};
|
|
136
|
-
declare abstract class SituationSpecification<TEvent extends
|
|
5
|
+
declare abstract class SituationSpecification<TEvent extends SpaceEvent = SpaceEvent> {
|
|
137
6
|
abstract isSatisfiedBy(situationContext: SituationContext$1<TEvent>): boolean;
|
|
138
7
|
and(other: SituationSpecification<TEvent>): SituationSpecification<TEvent>;
|
|
139
8
|
or(other: SituationSpecification<TEvent>): SituationSpecification<TEvent>;
|
|
@@ -144,7 +13,7 @@ interface SituationHandler {
|
|
|
144
13
|
readonly specification: SituationSpecification;
|
|
145
14
|
readonly processor: SituationProcessor;
|
|
146
15
|
}
|
|
147
|
-
type SituationContext<TEvent extends
|
|
16
|
+
type SituationContext<TEvent extends SpaceEvent = SpaceEvent> = {
|
|
148
17
|
readonly event: TEvent;
|
|
149
18
|
readonly participant: Participant;
|
|
150
19
|
};
|
|
@@ -152,477 +21,60 @@ interface SituationProcessor {
|
|
|
152
21
|
apply(context: SituationContext): void | Promise<void>;
|
|
153
22
|
}
|
|
154
23
|
|
|
155
|
-
type ParticipantRole = "agent" | "
|
|
24
|
+
type ParticipantRole = "agent" | "external";
|
|
156
25
|
type ParticipantManifest = {
|
|
157
26
|
readonly id: string;
|
|
158
27
|
readonly name: string;
|
|
159
28
|
readonly role: ParticipantRole;
|
|
160
29
|
readonly capabilities?: readonly string[];
|
|
161
30
|
};
|
|
162
|
-
declare
|
|
163
|
-
private
|
|
31
|
+
declare class Participant {
|
|
32
|
+
private manifest;
|
|
164
33
|
private handlers;
|
|
165
|
-
|
|
34
|
+
constructor(manifest: ParticipantManifest, handlers: SituationHandler[]);
|
|
166
35
|
getManifest(): ParticipantManifest;
|
|
36
|
+
setManifest(manifest: ParticipantManifest): void;
|
|
167
37
|
getId(): string;
|
|
168
38
|
getHandlers(): SituationHandler[];
|
|
169
39
|
setHandlers(handlers: SituationHandler[]): void;
|
|
170
40
|
}
|
|
171
41
|
|
|
172
|
-
declare class
|
|
42
|
+
declare class SpaceEvent<TType extends string = string, TPayload = unknown> {
|
|
173
43
|
readonly type: TType;
|
|
174
44
|
readonly producerId: string;
|
|
175
45
|
readonly occurredAt: Date;
|
|
176
46
|
readonly payload: TPayload;
|
|
177
47
|
constructor(type: TType, producerId: string, occurredAt: Date, payload: TPayload);
|
|
178
|
-
static create<TType extends string = string, TPayload = unknown>(type: TType, producerId: string, payload: 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
|
-
interface InterceptionHandler {
|
|
190
|
-
isSatisfiedBy(transition: ExecutableTransition): boolean;
|
|
191
|
-
handle(transition: ExecutableTransition): Promise<ExecutableTransition>;
|
|
192
|
-
}
|
|
193
|
-
type InterceptionOutput = {
|
|
194
|
-
type: "continue";
|
|
195
|
-
transition: LoopTransition;
|
|
196
|
-
} | {
|
|
197
|
-
type: "pause";
|
|
198
|
-
pendingTransition: LoopTransition;
|
|
199
|
-
} | {
|
|
200
|
-
type: "stop";
|
|
201
|
-
reason?: string;
|
|
202
|
-
};
|
|
203
|
-
interface InterceptionParams {
|
|
204
|
-
pendingTransition: LoopTransition;
|
|
48
|
+
static create<TType extends string = string, TPayload = unknown>(type: TType, producerId: string, occurredAt: Date, payload: TPayload): SpaceEvent<TType, TPayload>;
|
|
205
49
|
}
|
|
206
50
|
|
|
207
|
-
|
|
208
|
-
type ReceivedMessage = {
|
|
209
|
-
content: string;
|
|
210
|
-
input: InferenceInput;
|
|
211
|
-
};
|
|
212
|
-
interface FunctionCallExecutionOutput {
|
|
213
|
-
item: FunctionCallOutputItem;
|
|
214
|
-
}
|
|
215
|
-
interface ModelMessageParams {
|
|
216
|
-
answer: ModelMessageItem;
|
|
217
|
-
}
|
|
218
|
-
interface LoopStateContract {
|
|
219
|
-
message_received: {
|
|
220
|
-
input: ReceivedMessage;
|
|
221
|
-
output: InferenceInput;
|
|
222
|
-
};
|
|
223
|
-
inference: {
|
|
224
|
-
input: InferenceInput;
|
|
225
|
-
output: InferenceOutput;
|
|
226
|
-
};
|
|
227
|
-
inference_streaming: {
|
|
228
|
-
input: InferenceInput;
|
|
229
|
-
output: InferenceOutput;
|
|
230
|
-
};
|
|
231
|
-
function_call: {
|
|
232
|
-
input: FunctionCallParams;
|
|
233
|
-
output: FunctionCallExecutionOutput;
|
|
234
|
-
};
|
|
235
|
-
model_message: {
|
|
236
|
-
input: ModelMessageParams;
|
|
237
|
-
output: void;
|
|
238
|
-
};
|
|
239
|
-
interception: {
|
|
240
|
-
input: InterceptionParams;
|
|
241
|
-
output: InterceptionOutput;
|
|
242
|
-
};
|
|
243
|
-
idle: {
|
|
244
|
-
input: undefined;
|
|
245
|
-
output: void;
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
type ExecutableLoopStateId = Exclude<LoopStateId, "idle">;
|
|
249
|
-
type ExecutableTransition = LoopTransition<ExecutableLoopStateId>;
|
|
250
|
-
type LoopStateExecution<TStateId extends ExecutableLoopStateId = ExecutableLoopStateId> = {
|
|
251
|
-
[K in TStateId]: {
|
|
252
|
-
stateId: K;
|
|
253
|
-
input: LoopStateContract[K]["input"];
|
|
254
|
-
output: LoopStateContract[K]["output"];
|
|
255
|
-
};
|
|
256
|
-
}[TStateId];
|
|
257
|
-
type LoopTransition<TStateId extends LoopStateId = LoopStateId> = {
|
|
258
|
-
[K in TStateId]: {
|
|
259
|
-
nextStateId: K;
|
|
260
|
-
input: LoopStateContract[K]["input"];
|
|
261
|
-
};
|
|
262
|
-
}[TStateId];
|
|
263
|
-
|
|
264
|
-
declare class InputTokenDetails {
|
|
265
|
-
readonly cached_tokens: number;
|
|
266
|
-
constructor(cached_tokens: number);
|
|
267
|
-
}
|
|
268
|
-
declare class OutputTokenDetails {
|
|
269
|
-
readonly reasoning_tokens: number;
|
|
270
|
-
constructor(reasoning_tokens: number);
|
|
271
|
-
}
|
|
272
|
-
declare class TokenUsage {
|
|
273
|
-
readonly inputTokens: number;
|
|
274
|
-
readonly outputTokens: number;
|
|
275
|
-
readonly totalTokens: number;
|
|
276
|
-
readonly inputTokenDetails: InputTokenDetails;
|
|
277
|
-
readonly outputTokenDetails: OutputTokenDetails;
|
|
278
|
-
constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
|
|
51
|
+
interface SharedState {
|
|
279
52
|
}
|
|
280
53
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
maxOutputTokens?: number;
|
|
284
|
-
reasoningEffort?: string;
|
|
285
|
-
tools?: Tool[];
|
|
286
|
-
streaming?: boolean;
|
|
287
|
-
structuredOutput?: StructuredOutputFormat;
|
|
288
|
-
context: ModelContext;
|
|
289
|
-
};
|
|
290
|
-
type InferenceItem = FunctionCallItem | ReasoningItem | ModelMessageItem;
|
|
291
|
-
type InferenceOutput = {
|
|
292
|
-
items: InferenceItem[];
|
|
293
|
-
tokenUsage: TokenUsage | undefined;
|
|
294
|
-
rowResponse: any;
|
|
295
|
-
};
|
|
296
|
-
interface InferenceRunner {
|
|
297
|
-
run(request: InferenceInput): Promise<InferenceOutput>;
|
|
298
|
-
stream(request: InferenceInput): AsyncGenerator<SemanticEvent>;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
interface InferenceEndpointMapper {
|
|
302
|
-
toRequest(inferenceInput: InferenceInput): any;
|
|
303
|
-
toResponse(response: any): InferenceOutput;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
interface Endpoint {
|
|
307
|
-
endpointMapper: InferenceEndpointMapper;
|
|
308
|
-
infer(requestParams: InferenceInput): Promise<InferenceOutput>;
|
|
309
|
-
stream(requestParams: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
type GenerativeModel = {
|
|
313
|
-
endpoint: Endpoint;
|
|
314
|
-
specification: ModelSpecification;
|
|
315
|
-
};
|
|
316
|
-
type ModelSpecification = {
|
|
317
|
-
name: string;
|
|
318
|
-
provider: string;
|
|
319
|
-
supportsReasoningEffort: boolean;
|
|
320
|
-
supportedReasoningEfforts: string[];
|
|
321
|
-
supportsStreaming: boolean;
|
|
322
|
-
contextWindowSize: number;
|
|
323
|
-
supportedContextItemTypes: string[];
|
|
324
|
-
maxOutputTokens: number;
|
|
325
|
-
supportsFunctionCalling: boolean;
|
|
326
|
-
supportsStructuredOutput: boolean;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
interface RequestValidationRule {
|
|
330
|
-
readonly name: string;
|
|
331
|
-
isValid(inferenceInput: InferenceInput, model: ModelSpecification): boolean;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
type StructuredOutputFormat = {
|
|
335
|
-
name?: string;
|
|
336
|
-
schema: Record<string, any>;
|
|
337
|
-
strict?: boolean;
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
interface ModelContextRepository {
|
|
341
|
-
save(context: ModelContext): Promise<void>;
|
|
342
|
-
get(id: string): Promise<ModelContext>;
|
|
343
|
-
getByProjectId(projectId: string): Promise<ModelContext[]>;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
interface McpServerConfig {
|
|
347
|
-
/** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */
|
|
348
|
-
url: string;
|
|
349
|
-
/** Bearer token sent as `Authorization: Bearer <token>` (e.g. a GitHub token). */
|
|
350
|
-
authToken?: string;
|
|
351
|
-
/** Extra headers merged into every request (overridden by `authToken` for Authorization). */
|
|
352
|
-
headers?: Record<string, string>;
|
|
353
|
-
/** Client name reported to the server (defaults to "mozaik"). */
|
|
354
|
-
name?: string;
|
|
355
|
-
}
|
|
356
|
-
interface McpToolSpec {
|
|
54
|
+
interface FunctionTool {
|
|
55
|
+
type: "function";
|
|
357
56
|
name: string;
|
|
358
57
|
description: string;
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* A thin wrapper over the MCP TypeScript SDK using the Streamable HTTP transport — what
|
|
364
|
-
* remote MCP servers (e.g. GitHub's `api.githubcopilot.com/mcp/`) speak. One client per
|
|
365
|
-
* server; lazily connects on first use. Infrastructure-only: the domain never sees this.
|
|
366
|
-
*/
|
|
367
|
-
declare class McpClient {
|
|
368
|
-
private readonly config;
|
|
369
|
-
private readonly client;
|
|
370
|
-
private readonly transport;
|
|
371
|
-
private connected;
|
|
372
|
-
constructor(config: McpServerConfig);
|
|
373
|
-
connect(): Promise<void>;
|
|
374
|
-
/** The tools this server exposes. */
|
|
375
|
-
listTools(): Promise<McpToolSpec[]>;
|
|
376
|
-
/** Call a tool by name; returns its text output. Throws if the server flags an error. */
|
|
377
|
-
callTool(name: string, args: Record<string, any>): Promise<string>;
|
|
378
|
-
close(): Promise<void>;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** The slice of an MCP client the registry needs — lets tests inject a fake. */
|
|
382
|
-
interface McpClientLike {
|
|
383
|
-
listTools(): Promise<Array<{
|
|
384
|
-
name: string;
|
|
385
|
-
description: string;
|
|
386
|
-
inputSchema: Record<string, any>;
|
|
387
|
-
}>>;
|
|
388
|
-
callTool(name: string, args: Record<string, any>): Promise<string>;
|
|
389
|
-
close(): Promise<void>;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Connects to one or more MCP servers and exposes their tools as mozaik `FunctionTool`s.
|
|
393
|
-
* Each tool's `invoke()` proxies the call back to its MCP server. Because they are plain
|
|
394
|
-
* FunctionTools, every provider mapper and the existing function-call loop handle them
|
|
395
|
-
* with no changes — MCP support adds no new tool type and touches no provider code.
|
|
396
|
-
*
|
|
397
|
-
* `strict` is false: MCP servers publish arbitrary JSON Schemas that won't always satisfy
|
|
398
|
-
* a provider's strict function-calling mode.
|
|
399
|
-
*/
|
|
400
|
-
declare class McpToolRegistry {
|
|
401
|
-
private readonly servers;
|
|
402
|
-
private readonly createClient;
|
|
403
|
-
private readonly clients;
|
|
404
|
-
constructor(servers: McpServerConfig[], createClient?: (config: McpServerConfig) => McpClientLike);
|
|
405
|
-
/** Discover every tool across the configured servers, as FunctionTools ready to pass to a model. */
|
|
406
|
-
discoverTools(): Promise<FunctionTool[]>;
|
|
407
|
-
/** Close all underlying MCP connections. */
|
|
408
|
-
close(): Promise<void>;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
declare class SystemMessageItem extends ContextItem {
|
|
412
|
-
readonly type = "message";
|
|
413
|
-
readonly role = "system";
|
|
414
|
-
readonly content: InputText;
|
|
415
|
-
private constructor();
|
|
416
|
-
static create(text: string): SystemMessageItem;
|
|
417
|
-
static rehydrate(data: {
|
|
418
|
-
text: string;
|
|
419
|
-
}): SystemMessageItem;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
declare class Memory {
|
|
423
|
-
private readonly context;
|
|
424
|
-
private constructor();
|
|
425
|
-
getContext(): ModelContext;
|
|
426
|
-
static create(): Memory;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
declare class Agent extends Participant {
|
|
430
|
-
private memory;
|
|
431
|
-
private developerMessage;
|
|
432
|
-
private tools;
|
|
433
|
-
constructor(manifest: ParticipantManifest, developerMessage: string, tools: Tool[], memory: Memory, handlers: SituationHandler[]);
|
|
434
|
-
static create({ name, instruction, tools, capabilities, handlers, }: {
|
|
435
|
-
instruction: string;
|
|
436
|
-
tools: Tool[];
|
|
437
|
-
name: string;
|
|
438
|
-
capabilities: readonly string[];
|
|
439
|
-
handlers: SituationHandler[];
|
|
440
|
-
}): Agent;
|
|
441
|
-
getTools(): Tool[];
|
|
442
|
-
getDeveloperMessage(): string;
|
|
443
|
-
getMemory(): Memory;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
declare function createAgent({ name, capabilities, instruction, tools, handlers, }: {
|
|
447
|
-
name: string;
|
|
448
|
-
capabilities: readonly string[];
|
|
449
|
-
instruction: string;
|
|
450
|
-
tools: Tool[];
|
|
451
|
-
handlers: SituationHandler[];
|
|
452
|
-
}): Agent;
|
|
453
|
-
|
|
454
|
-
declare class Human extends Participant {
|
|
455
|
-
constructor(manifest: ParticipantManifest, handlers: SituationHandler[]);
|
|
456
|
-
static create({ name, capabilities, handlers, }: {
|
|
457
|
-
name: string;
|
|
458
|
-
capabilities: readonly string[];
|
|
459
|
-
handlers: SituationHandler[];
|
|
460
|
-
}): Human;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
declare function createHuman({ name, capabilities, handlers, }: {
|
|
464
|
-
name: string;
|
|
465
|
-
capabilities: readonly string[];
|
|
466
|
-
handlers: SituationHandler[];
|
|
467
|
-
}): Human;
|
|
468
|
-
|
|
469
|
-
declare abstract class RuntimeState {
|
|
470
|
-
participants: Map<string, Participant>;
|
|
471
|
-
addParticipant(participant: Participant): void;
|
|
472
|
-
removeParticipant(participant: Participant): void;
|
|
473
|
-
getParticipant(id: string): Participant | undefined;
|
|
474
|
-
getParticipants(): readonly Participant[];
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
declare class EventProcessor {
|
|
478
|
-
process(event: SemanticEvent, consumer: Participant): void;
|
|
58
|
+
parameters: Record<string, any>;
|
|
59
|
+
strict: boolean;
|
|
60
|
+
invoke: (args: any) => Promise<any> | any;
|
|
479
61
|
}
|
|
480
62
|
|
|
481
|
-
declare class RuntimeService<
|
|
482
|
-
readonly state:
|
|
483
|
-
|
|
484
|
-
private readonly inferenceRunner;
|
|
485
|
-
private readonly functionCallRunner;
|
|
486
|
-
constructor(state: TRuntimeState, processor: EventProcessor, inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
|
|
487
|
-
join(participant: Participant): void;
|
|
488
|
-
leave(participant: Participant): void;
|
|
489
|
-
publish(event: SemanticEvent): void;
|
|
490
|
-
getParticipant(id: string): Participant | undefined;
|
|
491
|
-
getInferenceRunner(): InferenceRunner;
|
|
492
|
-
getFunctionCallRunner(): FunctionCallRunner;
|
|
63
|
+
declare class RuntimeService<TSharedState extends SharedState> {
|
|
64
|
+
readonly state: TSharedState;
|
|
65
|
+
constructor(state: TSharedState);
|
|
493
66
|
}
|
|
494
67
|
|
|
495
|
-
|
|
496
|
-
supportedModels?: GenerativeModel[];
|
|
497
|
-
runner?: InferenceRunner;
|
|
498
|
-
};
|
|
499
|
-
declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
|
|
68
|
+
declare function defineRuntime<TSharedState extends SharedState>(): {
|
|
500
69
|
initializeRuntime: (config: {
|
|
501
|
-
state:
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
sendEvent: (event: SemanticEvent, senderId: string) => void;
|
|
510
|
-
runLoop: (agentId: string, message: string, inferenceInput: InferenceInput, interceptionHandler?: InterceptionHandler) => void;
|
|
70
|
+
state: TSharedState;
|
|
71
|
+
}) => RuntimeService<TSharedState>;
|
|
72
|
+
resolveRuntime: () => RuntimeService<TSharedState>;
|
|
73
|
+
createParticipant: (name: string, capabilities: readonly string[], handlers: SituationHandler[]) => Promise<Participant>;
|
|
74
|
+
join: (spaceId: string, participantId: string) => Promise<void>;
|
|
75
|
+
leave: (spaceId: string, participantId: string) => Promise<void>;
|
|
76
|
+
sendMessage: (spaceId: string, participantId: string, message: string) => Promise<void>;
|
|
77
|
+
sendMessageTool: FunctionTool;
|
|
511
78
|
};
|
|
512
79
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
declare class OpenAIResponses implements Endpoint {
|
|
516
|
-
endpointMapper: InferenceEndpointMapper;
|
|
517
|
-
private _client?;
|
|
518
|
-
constructor(endpointMapper?: InferenceEndpointMapper);
|
|
519
|
-
private get client();
|
|
520
|
-
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
521
|
-
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Optional connection config. When omitted, the `openai` SDK reads
|
|
526
|
-
* `OPENAI_API_KEY` and `OPENAI_BASE_URL` from the environment, so the
|
|
527
|
-
* default-constructed runtime targets whatever `OPENAI_BASE_URL` points
|
|
528
|
-
* at (real OpenAI when unset). Provider presets (e.g. DeepSeek) pass an
|
|
529
|
-
* explicit base URL + credential.
|
|
530
|
-
*/
|
|
531
|
-
interface OpenAICompatibleConfig {
|
|
532
|
-
baseURL?: string;
|
|
533
|
-
apiKey?: string;
|
|
534
|
-
/**
|
|
535
|
-
* Extra request-body fields merged into every `chat.completions`
|
|
536
|
-
* call. This is how provider-specific quirks are handled **without
|
|
537
|
-
* a per-provider subclass in mozaik** — the consumer supplies the
|
|
538
|
-
* vendor-only fields (e.g. DeepSeek's `{ thinking: { type } }`,
|
|
539
|
-
* safety flags, routing hints). Standard fields the runtime already
|
|
540
|
-
* sets (`model`, `messages`, `tools`, `reasoning_effort`) take
|
|
541
|
-
* precedence and are not overwritten.
|
|
542
|
-
*/
|
|
543
|
-
extraBody?: Record<string, unknown>;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Generic adapter for any **OpenAI Chat Completions**-compatible
|
|
547
|
-
* endpoint — real OpenAI, DeepSeek, Xiaomi MiMo, OpenRouter, vLLM,
|
|
548
|
-
* Ollama, etc. It speaks `/chat/completions` (not the Responses API),
|
|
549
|
-
* which is the dialect third-party OpenAI-compatible providers expose.
|
|
550
|
-
*
|
|
551
|
-
* The base URL and credential are configurable; everything else (the
|
|
552
|
-
* `ModelContext` ⇄ chat-message conversion, tool-call round-trip, token
|
|
553
|
-
* usage extraction) is provider-agnostic. Provider-specific request
|
|
554
|
-
* shaping (e.g. DeepSeek's `thinking` field) is supplied by the
|
|
555
|
-
* consumer via {@link OpenAICompatibleConfig.extraBody} — mozaik stays
|
|
556
|
-
* generic and gains no per-provider subclasses.
|
|
557
|
-
*
|
|
558
|
-
* Was `DeepSeekChatCompletions`; generalized so consumers can point it
|
|
559
|
-
* at any OpenAI-compatible endpoint.
|
|
560
|
-
*/
|
|
561
|
-
declare class OpenAIChatCompletions implements Endpoint {
|
|
562
|
-
endpointMapper: InferenceEndpointMapper;
|
|
563
|
-
private _client?;
|
|
564
|
-
private readonly clientConfig;
|
|
565
|
-
private readonly extraBody;
|
|
566
|
-
constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
|
|
567
|
-
private get client();
|
|
568
|
-
private buildRequest;
|
|
569
|
-
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
570
|
-
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
interface AnthropicConnectionConfig {
|
|
574
|
-
baseURL?: string;
|
|
575
|
-
apiKey?: string;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Native Anthropic adapter on the `@anthropic-ai/sdk` (`messages.create`).
|
|
579
|
-
* Maps domain context to Anthropic's `messages`/`content` blocks shape,
|
|
580
|
-
* system prompt, tools, adaptive thinking, and structured output config.
|
|
581
|
-
*/
|
|
582
|
-
declare class AnthropicMessages implements Endpoint {
|
|
583
|
-
endpointMapper: InferenceEndpointMapper;
|
|
584
|
-
private _client?;
|
|
585
|
-
private readonly clientConfig;
|
|
586
|
-
constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
|
|
587
|
-
private get client();
|
|
588
|
-
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
589
|
-
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
interface GeminiConnectionConfig {
|
|
593
|
-
baseURL?: string;
|
|
594
|
-
apiKey?: string;
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Native Gemini adapter on the `@google/genai` SDK (`generateContent` /
|
|
598
|
-
* `generateContentStream`). Unlike an OpenAI-compat shim this maps our
|
|
599
|
-
* domain context to Gemini's native `contents`/`parts` shape, system
|
|
600
|
-
* instruction, `functionDeclarations`, and `thinkingConfig`, and reads
|
|
601
|
-
* thought parts + native usage metadata back out. Another `ModelRuntime`
|
|
602
|
-
* — no runner or port changes.
|
|
603
|
-
*/
|
|
604
|
-
declare class GeminiGenerateContent implements Endpoint {
|
|
605
|
-
endpointMapper: InferenceEndpointMapper;
|
|
606
|
-
private _client?;
|
|
607
|
-
private readonly clientConfig;
|
|
608
|
-
constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
|
|
609
|
-
private get client();
|
|
610
|
-
infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
|
|
611
|
-
stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
declare class InferenceInputValidator {
|
|
615
|
-
private readonly rules;
|
|
616
|
-
constructor(rules?: RequestValidationRule[]);
|
|
617
|
-
validate(inferenceInput: InferenceInput, model: ModelSpecification): void;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
declare class DefaultInferenceRunner implements InferenceRunner {
|
|
621
|
-
private readonly supportedModels;
|
|
622
|
-
private readonly requestValidator;
|
|
623
|
-
constructor(supportedModels: GenerativeModel[], requestValidator: InferenceInputValidator);
|
|
624
|
-
run(input: InferenceInput): Promise<InferenceOutput>;
|
|
625
|
-
stream(input: InferenceInput): AsyncGenerator<SemanticEvent>;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, type ExecutableLoopStateId, type ExecutableTransition, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, type InterceptionHandler, type LoopStateExecution, type LoopTransition, 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 };
|
|
80
|
+
export { Participant, type SharedState, type SituationContext, type SituationHandler, type SituationProcessor, SituationSpecification, SpaceEvent, defineRuntime };
|