@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/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Mozaik</h1>
|
|
3
|
+
<p>TypeScript runtime for concurrent AI agents</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<img width="150" height="150" alt="mozaik-avatar-dark" src="https://github.com/user-attachments/assets/e832c359-0581-42f7-96f3-d6e221c5af95" />
|
|
4
6
|
|
|
5
7
|
  
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Mozaik is a TypeScript runtime for non-blocking AI agents that work independently, communicate through semantic events, and coordinate without predefined workflows.
|
|
10
|
+
|
|
11
|
+
</div>
|
|
8
12
|
|
|
9
13
|
---
|
|
10
14
|
|
|
@@ -143,7 +147,6 @@ import {
|
|
|
143
147
|
ModelMessageItem,
|
|
144
148
|
AgenticEnvironment,
|
|
145
149
|
ModelContext,
|
|
146
|
-
ModelName,
|
|
147
150
|
Tool,
|
|
148
151
|
runInference,
|
|
149
152
|
executeFunctionCall,
|
|
@@ -162,7 +165,7 @@ export class ReactiveAgent extends BaseParticipant {
|
|
|
162
165
|
async onMessage(message: string): Promise<void> {
|
|
163
166
|
this.context.addContextItem(UserMessageItem.create(message))
|
|
164
167
|
runInference({
|
|
165
|
-
model:
|
|
168
|
+
model: "gpt-5.5",
|
|
166
169
|
context: this.context,
|
|
167
170
|
tools: this.tools,
|
|
168
171
|
caller: this,
|
|
@@ -181,7 +184,7 @@ export class ReactiveAgent extends BaseParticipant {
|
|
|
181
184
|
async onFunctionCallOutput(item: FunctionCallOutputItem): Promise<void> {
|
|
182
185
|
this.context.addContextItem(item)
|
|
183
186
|
runInference({
|
|
184
|
-
model:
|
|
187
|
+
model: "gpt-5.5",
|
|
185
188
|
context: this.context,
|
|
186
189
|
tools: this.tools,
|
|
187
190
|
caller: this,
|
|
@@ -247,54 +250,6 @@ Requesting streaming for a model whose specification has `supportsStreaming: fal
|
|
|
247
250
|
|
|
248
251
|
---
|
|
249
252
|
|
|
250
|
-
## Structured output
|
|
251
|
-
|
|
252
|
-
When you need the model to respond with a specific JSON shape instead of free-form text, use structured output. Pass a `structuredOutput` (a `StructuredOutputFormat`) on the `runInference` params and the provider will enforce the JSON Schema:
|
|
253
|
-
|
|
254
|
-
```ts
|
|
255
|
-
import { runInference } from "@mozaik-ai/core"
|
|
256
|
-
|
|
257
|
-
runInference({
|
|
258
|
-
model: "gpt-5.4",
|
|
259
|
-
context,
|
|
260
|
-
caller: this,
|
|
261
|
-
environment,
|
|
262
|
-
structuredOutput: {
|
|
263
|
-
name: "weather",
|
|
264
|
-
schema: {
|
|
265
|
-
type: "object",
|
|
266
|
-
properties: {
|
|
267
|
-
city: { type: "string" },
|
|
268
|
-
temperature: { type: "number" },
|
|
269
|
-
condition: { type: "string" },
|
|
270
|
-
},
|
|
271
|
-
required: ["city", "temperature", "condition"],
|
|
272
|
-
additionalProperties: false,
|
|
273
|
-
},
|
|
274
|
-
strict: true,
|
|
275
|
-
},
|
|
276
|
-
})
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
The response comes back as a `ModelMessageItem` with valid JSON in the text field — no new item type, consistent with OpenResponses.
|
|
280
|
-
|
|
281
|
-
Structured output works alongside tools and streaming. When streaming is enabled, partial JSON chunks arrive as `SemanticEvent`s and the final event contains the complete response.
|
|
282
|
-
|
|
283
|
-
To return to free-form text, simply omit `structuredOutput` on the next `runInference` call.
|
|
284
|
-
|
|
285
|
-
### Provider support
|
|
286
|
-
|
|
287
|
-
| Provider | Models | Strict schema enforcement |
|
|
288
|
-
| --------- | --------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
289
|
-
| OpenAI | gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.5 | Yes |
|
|
290
|
-
| Anthropic | claude-opus-4-7, claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5 | Yes |
|
|
291
|
-
| Gemini | gemini-3.1-pro-preview, gemini-3.5-flash | Yes |
|
|
292
|
-
| DeepSeek | deepseek-v4-flash, deepseek-v4-pro | Not supported — use prompt-based JSON guidance instead |
|
|
293
|
-
|
|
294
|
-
Requesting structured output for a model whose specification has `supportsStructuredOutput: false` fails request validation before the API call.
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
253
|
## Lifecycle hooks
|
|
299
254
|
|
|
300
255
|
Every participant receives lifecycle notifications when it or others join/leave an environment:
|
|
@@ -407,69 +362,6 @@ export class TranscriptLogger extends BaseParticipant {
|
|
|
407
362
|
|
|
408
363
|
---
|
|
409
364
|
|
|
410
|
-
## Context and models (reference)
|
|
411
|
-
|
|
412
|
-
`ModelContext` is the ordered list of `ContextItem`s a model is asked to reason over. It is constructed and mutated explicitly — typically inside a participant in response to delivered items.
|
|
413
|
-
|
|
414
|
-
```ts
|
|
415
|
-
import { ModelContext, DeveloperMessageItem, UserMessageItem, InMemoryModelContextRepository } from "@mozaik-ai/core"
|
|
416
|
-
|
|
417
|
-
const context = ModelContext.create("project-id")
|
|
418
|
-
.addContextItem(DeveloperMessageItem.create("You are a helpful assistant."))
|
|
419
|
-
.addContextItem(UserMessageItem.create("What is the capital of France?"))
|
|
420
|
-
|
|
421
|
-
const repo = new InMemoryModelContextRepository()
|
|
422
|
-
await repo.save(context)
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
Implement `ModelContextRepository` to plug in any storage backend.
|
|
426
|
-
|
|
427
|
-
A model is selected by its `ModelName` string. Mozaik resolves the name to a provider `Endpoint` and a `ModelSpecification` internally, maps the `ModelContext` to that provider's API, and returns typed `ContextItem`s (and `SemanticEvent`s when streaming). Bundled model names:
|
|
428
|
-
|
|
429
|
-
| Provider | `ModelName` values |
|
|
430
|
-
| --------- | ------------------------------------------------------------------------------------- |
|
|
431
|
-
| OpenAI | `"gpt-5.4"`, `"gpt-5.4-mini"`, `"gpt-5.4-nano"`, `"gpt-5.5"` |
|
|
432
|
-
| Anthropic | `"claude-haiku-4-5"`, `"claude-sonnet-4-6"`, `"claude-opus-4-7"`, `"claude-opus-4-8"` |
|
|
433
|
-
| Gemini | `"gemini-3.5-flash"`, `"gemini-3.1-pro-preview"` |
|
|
434
|
-
| DeepSeek | `"deepseek-v4-flash"`, `"deepseek-v4-pro"` |
|
|
435
|
-
|
|
436
|
-
You drive inference with the `runInference` capability; it streams the resulting items into the environment for participants to react to:
|
|
437
|
-
|
|
438
|
-
```ts
|
|
439
|
-
import { runInference, ModelContext } from "@mozaik-ai/core"
|
|
440
|
-
|
|
441
|
-
const context = ModelContext.create("demo")
|
|
442
|
-
|
|
443
|
-
runInference({ model: "gpt-5.4", context, caller: this, environment })
|
|
444
|
-
// → environment delivers ReasoningItem | FunctionCallItem | ModelMessageItem (and SemanticEvent when streaming)
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
---
|
|
448
|
-
|
|
449
|
-
### Tools
|
|
450
|
-
|
|
451
|
-
A `Tool` is a function declaration with its own executor: `name`, `description`, JSON Schema `parameters`, `strict`, and an `invoke(args)` that runs the call. Pass tools on the `runInference` params; when the model emits a `FunctionCallItem`, run it with `executeFunctionCall`, which calls the matching tool's `invoke` and emits a `FunctionCallOutputItem`.
|
|
452
|
-
|
|
453
|
-
```ts
|
|
454
|
-
import { Tool } from "@mozaik-ai/core"
|
|
455
|
-
|
|
456
|
-
const getWeather: Tool = {
|
|
457
|
-
type: "function",
|
|
458
|
-
name: "get_weather",
|
|
459
|
-
description: "Get the current weather for a city",
|
|
460
|
-
parameters: {
|
|
461
|
-
type: "object",
|
|
462
|
-
properties: { city: { type: "string" } },
|
|
463
|
-
required: ["city"],
|
|
464
|
-
additionalProperties: false,
|
|
465
|
-
},
|
|
466
|
-
strict: true,
|
|
467
|
-
invoke: async ({ city }: { city: string }) => ({ city, temperature: 21, condition: "sunny" }),
|
|
468
|
-
}
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
---
|
|
472
|
-
|
|
473
365
|
## Examples
|
|
474
366
|
|
|
475
367
|
Working examples are available here: [mozaik-examples](https://github.com/jigjoy-ai/mozaik-examples).
|