@mozaik-ai/core 4.2.0-beta.8 → 4.2.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 CHANGED
@@ -88,15 +88,15 @@ initializeRuntime({ state: new AppState() })
88
88
 
89
89
  `defineRuntime` returns the functions you use for the rest of the session. They are **not** top-level package exports — keep them in module scope (or re-export them yourself):
90
90
 
91
- | Function | Role |
92
- | ------------------------------------------------------------------- | --------------------------------------------- |
93
- | `initializeRuntime({ state, inferenceRunnerConfig? })` | Create the runtime. Throws if called twice. |
94
- | `resolveRuntime()` | The initialized runtime (including `.state`). |
95
- | `resolveParticipant(id)` | Look up a joined participant by id. |
96
- | `join(participant)` / `leave(participant)` | Membership. |
97
- | `sendMessage(message, senderId)` | Publish a `message.sent` event. |
98
- | `sendEvent(event, senderId)` | Publish any `SpaceEvent`. |
99
- | `runLoop(agentId, message, inferenceRequest, interceptionHandler?)` | Start an agent loop. |
91
+ | Function | Role |
92
+ | ----------------------------------------------------------------- | --------------------------------------------- |
93
+ | `initializeRuntime({ state, inferenceRunnerConfig? })` | Create the runtime. Throws if called twice. |
94
+ | `resolveRuntime()` | The initialized runtime (including `.state`). |
95
+ | `resolveParticipant(id)` | Look up a joined participant by id. |
96
+ | `join(participant)` / `leave(participant)` | Membership. |
97
+ | `sendMessage(message, senderId)` | Publish a `message.sent` event. |
98
+ | `sendEvent(event, senderId)` | Publish any `SemanticEvent`. |
99
+ | `runLoop(agentId, message, inferenceInput, interceptionHandler?)` | Start an agent loop. |
100
100
 
101
101
  Calling `initializeRuntime` a second time throws `"Runtime already initialized"`. Calling any of the other functions before `initializeRuntime` throws `"Runtime not initialized"`.
102
102
 
@@ -192,7 +192,7 @@ An agent can wait until a collaborator has joined (`participant.joined`) before
192
192
 
193
193
  ## Semantic events
194
194
 
195
- The runtime is an event bus. Everything interesting is a **`SpaceEvent`**:
195
+ The runtime is an event bus. Everything interesting is a **`SemanticEvent`**:
196
196
 
197
197
  | Field | Meaning |
198
198
  | ------------ | ------------------------------------------------------------------------ |
@@ -221,19 +221,19 @@ Producer is the agent whose loop is running:
221
221
  | Event | Published when | Payload |
222
222
  | ---------------------------- | -------------------------------------------------- | -------------------------------------------------------- |
223
223
  | `message_received.started` | The loop begins appending the user message | Received message plus `loopId` |
224
- | `message_received.completed` | Context is ready for inference | `InferenceRequest` plus `loopId` |
225
- | `inference.started` | The model call begins | `InferenceRequest` |
224
+ | `message_received.completed` | Context is ready for inference | `InferenceInput` plus `loopId` |
225
+ | `inference.started` | The model call begins | `InferenceInput` |
226
226
  | `inference.stream` | Each streaming chunk (only when `streaming: true`) | The inner provider event |
227
- | `inference.completed` | The model call finished | `InferenceResult` (`items`, `tokenUsage`, `rowResponse`) |
228
- | `function_call.started` | A tool is about to run | `{ call, inferenceRequest }` |
229
- | `function_call.completed` | The tool returned | `ToolOutput` |
227
+ | `inference.completed` | The model call finished | `InferenceOutput` (`items`, `tokenUsage`, `rowResponse`) |
228
+ | `function_call.started` | A tool is about to run | `{ call, inferenceInput }` |
229
+ | `function_call.completed` | The tool returned | `FunctionCallOutputItem` |
230
230
  | `model.answer` | The assistant message is committed | `{ answer: ModelMessageItem }` |
231
231
  | `interception.started` | An `InterceptionHandler` matched a transition | The pending `LoopTransition` |
232
232
  | `interception.finished` | The handler returned (possibly rewritten) | The transition that will execute |
233
233
 
234
234
  ### Streaming
235
235
 
236
- Pass `streaming: true` on the `InferenceRequest` you give `runLoop`. The loop takes the `inference_streaming` path and publishes each provider chunk as `inference.stream` (the inner event is the payload). Requesting streaming for a model whose specification has `supportsStreaming: false` fails validation before the API is called.
236
+ Pass `streaming: true` on the `InferenceInput` you give `runLoop`. The loop takes the `inference_streaming` path and publishes each provider chunk as `inference.stream` (the inner event is the payload). Requesting streaming for a model whose specification has `supportsStreaming: false` fails validation before the API is called.
237
237
 
238
238
  ---
239
239
 
@@ -249,9 +249,9 @@ flowchart LR
249
249
  Human[Participant] -->|"sendMessage(text, senderId)"| Runtime(("Runtime"))
250
250
  Agent[Participant] -->|"runLoop"| Runtime
251
251
  Observer[Participant] -->|join| Runtime
252
- Runtime -->|"SpaceEvent"| Human
253
- Runtime -->|"SpaceEvent"| Agent
254
- Runtime -->|"SpaceEvent"| Observer
252
+ Runtime -->|"SemanticEvent"| Human
253
+ Runtime -->|"SemanticEvent"| Agent
254
+ Runtime -->|"SemanticEvent"| Observer
255
255
  ```
256
256
 
257
257
  Fan-out is synchronous and does not await processors, so a slow listener never blocks producers or other listeners. Participants start receiving events as soon as they `join()`.
@@ -345,7 +345,7 @@ Three things to note:
345
345
 
346
346
  ## The agent loop
347
347
 
348
- `runLoop(agentId, message, inferenceRequest, interceptionHandler?)` drives one agent turn as a state machine. It starts at `message_received` and runs until `idle`. Tool execution and the follow-up inference live inside the loop — you do not call a separate function-call runner.
348
+ `runLoop(agentId, message, inferenceInput, interceptionHandler?)` drives one agent turn as a state machine. It starts at `message_received` and runs until `idle`. Tool execution and the follow-up inference live inside the loop — you do not call a separate function-call runner.
349
349
 
350
350
  Each step: optionally intercept the pending transition, execute the state, then resolve the next transition.
351
351
 
@@ -399,7 +399,7 @@ const inspectFunctionCalls: InterceptionHandler = {
399
399
  },
400
400
  }
401
401
 
402
- runLoop(agent.getId(), message, inferenceRequest, inspectFunctionCalls)
402
+ runLoop(agent.getId(), message, inferenceInput, inspectFunctionCalls)
403
403
  ```
404
404
 
405
405
  Use it to steer loop execution by rewriting the next state — for example, swapping a tool call’s input — without putting that logic inside the agent’s situation handlers. That is how you keep a human in the loop, or another agent, to control what runs next.