@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/README.md +18 -118
- package/dist/index.d.mts +436 -199
- package/dist/index.d.ts +436 -199
- package/dist/index.js +939 -589
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +926 -581
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Mozaik</h1>
|
|
3
|
+
<p>Mozaik is a TypeScript runtime for interoperable AI agents.</p>
|
|
4
4
|
|
|
5
5
|
  
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<img width="512" height="512" alt="agent-interoperability" src="https://github.com/user-attachments/assets/4b24bf27-afe2-4520-a396-5c46da6dab17" />
|
|
8
|
+
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
## Agent Interoperability
|
|
12
|
+
|
|
13
|
+
Our main goal is to unlock agent interoperability across projects, so Mozaik is built around three core attributes:
|
|
14
|
+
|
|
15
|
+
- **Concurrency** - Agents work independently without blocking one another.
|
|
16
|
+
- **Awareness** - Agents understand other participants, events, and their shared environment.
|
|
17
|
+
- **Adaptivity** - Agents change their behavior based on runtime state and emerging needs.
|
|
18
|
+
|
|
19
|
+
Together, these capabilities free AI agents from specific harnesses, allowing them to work across projects - so every newly created agent adds value to the entire ecosystem.
|
|
8
20
|
|
|
9
21
|
---
|
|
10
22
|
|
|
@@ -143,7 +155,6 @@ import {
|
|
|
143
155
|
ModelMessageItem,
|
|
144
156
|
AgenticEnvironment,
|
|
145
157
|
ModelContext,
|
|
146
|
-
ModelName,
|
|
147
158
|
Tool,
|
|
148
159
|
runInference,
|
|
149
160
|
executeFunctionCall,
|
|
@@ -162,7 +173,7 @@ export class ReactiveAgent extends BaseParticipant {
|
|
|
162
173
|
async onMessage(message: string): Promise<void> {
|
|
163
174
|
this.context.addContextItem(UserMessageItem.create(message))
|
|
164
175
|
runInference({
|
|
165
|
-
model:
|
|
176
|
+
model: "gpt-5.5",
|
|
166
177
|
context: this.context,
|
|
167
178
|
tools: this.tools,
|
|
168
179
|
caller: this,
|
|
@@ -181,7 +192,7 @@ export class ReactiveAgent extends BaseParticipant {
|
|
|
181
192
|
async onFunctionCallOutput(item: FunctionCallOutputItem): Promise<void> {
|
|
182
193
|
this.context.addContextItem(item)
|
|
183
194
|
runInference({
|
|
184
|
-
model:
|
|
195
|
+
model: "gpt-5.5",
|
|
185
196
|
context: this.context,
|
|
186
197
|
tools: this.tools,
|
|
187
198
|
caller: this,
|
|
@@ -247,54 +258,6 @@ Requesting streaming for a model whose specification has `supportsStreaming: fal
|
|
|
247
258
|
|
|
248
259
|
---
|
|
249
260
|
|
|
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
261
|
## Lifecycle hooks
|
|
299
262
|
|
|
300
263
|
Every participant receives lifecycle notifications when it or others join/leave an environment:
|
|
@@ -407,69 +370,6 @@ export class TranscriptLogger extends BaseParticipant {
|
|
|
407
370
|
|
|
408
371
|
---
|
|
409
372
|
|
|
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
373
|
## Examples
|
|
474
374
|
|
|
475
375
|
Working examples are available here: [mozaik-examples](https://github.com/jigjoy-ai/mozaik-examples).
|