@mozaik-ai/core 3.8.0 → 3.8.3

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.
Files changed (2) hide show
  1. package/README.md +29 -70
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ![npm downloads](https://img.shields.io/npm/dt/@mozaik-ai/core) ![npm downloads weekly](https://img.shields.io/npm/dw/@mozaik-ai/core) ![npm version](https://img.shields.io/npm/v/@mozaik-ai/core)
6
6
 
7
- In Mozaik, humans, agents, observers, and tools are all `Participant`s of the same `AgenticEnvironment`. Each participant runs **non-blocking** and produces typed events — function calls, function call outputs, reasoning, model messages, and plain-text messages — into the environment. Every other participant sees those events in real time and can react, intercept, or stay silent — without any central scheduler.
7
+ In Mozaik, humans, agents, observers, and tools are all `Participant`s of the same `AgenticEnvironment`. Each participant runs **non-blocking** and produces events into the environment: plain-text **messages** for conversational input/output, and typed `ContextItem`s for model internals (function calls, function call outputs, reasoning, model messages). Every other participant sees those events in real time and can react, intercept, or stay silent — without any central scheduler.
8
8
 
9
9
  ---
10
10
 
@@ -27,13 +27,13 @@ OPENAI_API_KEY=your-openai-key-here
27
27
 
28
28
  `AgenticEnvironment` is a broadcast bus for typed events. `Participant`s `join()` it, and anything produced by one participant is delivered to every subscriber through a **dedicated typed callback** — one per event kind, with separate handlers for items the participant emitted itself versus items emitted by someone else:
29
29
 
30
- | Producer call | Self handler | External handler |
31
- | ---------------------------------------- | ----------------------- | ----------------------------------------- |
32
- | `deliverFunctionCall(source, item)` | `onFunctionCall` | `onExternalFunctionCall(source, …)` |
33
- | `deliverFunctionCallOutput(source, item)`| `onFunctionCallOutput` | `onExternalFunctionCallOutput(source, …)` |
34
- | `deliverReasoning(source, item)` | `onReasoning` | `onExternalReasoning(source, …)` |
35
- | `deliverModelMessage(source, item)` | `onModelMessage` | `onExternalModelMessage(source, …)` |
36
- | `deliverMessage(source, message)` | _(not delivered)_ | `onMessage(message)` |
30
+ | Producer call | Self handler | External handler |
31
+ | ----------------------------------------- | ---------------------- | ----------------------------------------- |
32
+ | `deliverFunctionCall(source, item)` | `onFunctionCall` | `onExternalFunctionCall(source, …)` |
33
+ | `deliverFunctionCallOutput(source, item)` | `onFunctionCallOutput` | `onExternalFunctionCallOutput(source, …)` |
34
+ | `deliverReasoning(source, item)` | `onReasoning` | `onExternalReasoning(source, …)` |
35
+ | `deliverModelMessage(source, item)` | `onModelMessage` | `onExternalModelMessage(source, …)` |
36
+ | `deliverMessage(source, message)` | _(not delivered)_ | `onMessage(message)` |
37
37
 
38
38
  Messages are plain `string`s exchanged between participants. Every other event flows as a typed `ContextItem` (`FunctionCallItem`, `FunctionCallOutputItem`, `ReasoningItem`, `ModelMessageItem`).
39
39
 
@@ -53,37 +53,10 @@ flowchart LR
53
53
 
54
54
  Mozaik ships two ready-to-use participants:
55
55
 
56
- | Participant | Capabilities | Pulls from |
57
- | ---------------------- | --------------------------------------------------------- | ----------------------------------------------------- |
58
- | `BaseHumanParticipant` | `InputCapable` | `InputStream` |
59
- | `BaseAgentParticipant` | `InputCapable`, `InferenceCapable`, `FunctionCallCapable` | `InputStream`, `InferenceRunner`, `FunctionCallRunner`|
60
-
61
- Each capability method is **non-blocking**: it returns `Promise<void>`, and as the underlying generator yields, items are streamed into the environment one-by-one through the matching typed `deliverX` method. For example, `runInference` dispatches each yielded item to `deliverReasoning`, `deliverFunctionCall`, or `deliverModelMessage`:
62
-
63
- ```81:100:src/application/agent.ts
64
- async runInference(
65
- environment: AgenticEnvironment,
66
- context: ModelContext,
67
- model: GenerativeModel,
68
- signal?: AbortSignal,
69
- ): Promise<void> {
70
- if (!this.isJoinedTo(environment)) return
71
-
72
- const stream = this.inferenceRunner.run(context, model, signal)
73
-
74
- for await (const item of stream) {
75
- if (item.type === "reasoning") {
76
- await environment.deliverReasoning(this, item)
77
- } else if (item.type === "function_call") {
78
- await environment.deliverFunctionCall(this, item)
79
- } else if (item.type === "message" && item.role === "assistant") {
80
- await environment.deliverModelMessage(this, item)
81
- }
82
- }
83
- }
84
- ```
85
-
86
- Because each call is a fresh promise that wraps an async iterable, multiple participants can act on the same environment **concurrently**:
56
+ | Participant | Capabilities | Pulls from |
57
+ | ---------------------- | --------------------------------------------------------- | ------------------------------------------------------ |
58
+ | `BaseHumanParticipant` | `InputCapable` | `InputStream` |
59
+ | `BaseAgentParticipant` | `InputCapable`, `InferenceCapable`, `FunctionCallCapable` | `InputStream`, `InferenceRunner`, `FunctionCallRunner` |
87
60
 
88
61
  ```ts
89
62
  import {
@@ -124,28 +97,6 @@ Instead of a single catch-all callback, `Participant` exposes **one typed handle
124
97
  - **React** to its own outputs via the self handlers (e.g. execute a `FunctionCallItem` it just produced), or to others' outputs via the external handlers.
125
98
  - **Ignore** events it doesn't care about — every handler defaults to a no-op in the bundled participants.
126
99
 
127
- The intercept surface, taken from `Participant`:
128
-
129
- ```38:54:src/domain/agentic-environment/participant.ts
130
- abstract onFunctionCall(item: FunctionCallItem): Promise<void>
131
-
132
- abstract onExternalFunctionCall(source: Participant, item: FunctionCallItem): Promise<void>
133
-
134
- abstract onFunctionCallOutput(item: FunctionCallOutputItem): Promise<void>
135
-
136
- abstract onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): Promise<void>
137
-
138
- abstract onReasoning(item: ReasoningItem): Promise<void>
139
-
140
- abstract onExternalReasoning(source: Participant, item: ReasoningItem): Promise<void>
141
-
142
- abstract onModelMessage(item: ModelMessageItem): Promise<void>
143
-
144
- abstract onExternalModelMessage(source: Participant, item: ModelMessageItem): Promise<void>
145
-
146
- abstract onMessage(message: string): Promise<void>
147
- ```
148
-
149
100
  The typed `ContextItem`s involved are defined in [src/domain/model-context/context-item](src/domain/model-context/context-item):
150
101
 
151
102
  - Client-produced: `FunctionCallOutputItem` (and `UserMessageItem` / `DeveloperMessageItem` / `SystemMessageItem` when building a `ModelContext` directly)
@@ -158,13 +109,7 @@ Plain conversational input flows as a `string` through `onMessage` — participa
158
109
  A passive observer subclasses `Participant` and overrides only the handlers it cares about:
159
110
 
160
111
  ```ts
161
- import {
162
- Participant,
163
- FunctionCallItem,
164
- FunctionCallOutputItem,
165
- ReasoningItem,
166
- ModelMessageItem,
167
- } from "@mozaik-ai/core"
112
+ import { Participant, FunctionCallItem, FunctionCallOutputItem, ReasoningItem, ModelMessageItem } from "@mozaik-ai/core"
168
113
 
169
114
  export class TranscriptLogger extends Participant {
170
115
  async onMessage(message: string): Promise<void> {
@@ -296,7 +241,15 @@ const response = await runtime.infer(new InferenceRequest(new Gpt54(), context))
296
241
 
297
242
  ### Custom `InputStream`
298
243
 
299
- An `InputStream` yields plain `string` messages, which are then broadcast to every other participant through `onMessage`:
244
+ An `InputStream` is the minimal text-source contract a participant uses to feed messages into the environment:
245
+
246
+ ```ts
247
+ export interface InputStream {
248
+ stream(signal?: AbortSignal): AsyncIterable<string>
249
+ }
250
+ ```
251
+
252
+ Each yielded string is delivered to every other participant through `onMessage(message: string)`. This keeps the wire format dead simple: participants exchange text, and each one decides how to turn that text into a `ContextItem` for its own `ModelContext`.
300
253
 
301
254
  ```ts
302
255
  import { InputStream } from "@mozaik-ai/core"
@@ -322,7 +275,7 @@ export class QueueInputStream implements InputStream {
322
275
  }
323
276
  ```
324
277
 
325
- Use it for stdin, websockets, an HTTP queue, or anything that produces messages over time. Participants decide for themselves what to do with the string — e.g. wrap it in a `UserMessageItem` before adding it to a `ModelContext`.
278
+ Use it for stdin, websockets, an HTTP queue, or anything that produces text over time. A reactive agent typically wraps the incoming string in a `UserMessageItem` inside `onMessage` before adding it to its `ModelContext` — see the [Reactive agent](#reactive-agent) example above.
326
279
 
327
280
  ### Custom `InferenceRunner`
328
281
 
@@ -394,6 +347,12 @@ You now own input, inference, and tool execution end-to-end while keeping the sa
394
347
 
395
348
  ---
396
349
 
350
+ ## Made with Mozaik
351
+
352
+ - **[baro](https://github.com/Lotus015/baro)** — a Claude agent orchestrator where ten specialized participants (planner, executors, reviewer, fixer, librarian, auditor, and more) work fully concurrently on the same goal, like a team collaborating in real time instead of a single agent doing everything alone.
353
+
354
+ ---
355
+
397
356
  ## Author & License
398
357
 
399
358
  Created by the [JigJoy](https://jigjoy.io) team.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mozaik-ai/core",
3
- "version": "3.8.0",
3
+ "version": "3.8.3",
4
4
  "description": "A TypeScript framework for building reactive agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",