@mozaik-ai/core 3.9.5 → 3.10.1
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 +58 -62
- package/dist/index.d.mts +75 -72
- package/dist/index.d.ts +75 -72
- package/dist/index.js +202 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +196 -150
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,13 +56,15 @@ OPENAI_API_KEY=your-openai-key-here
|
|
|
56
56
|
| `onExternalReasoning` | another agent's inference returns a reasoning item |
|
|
57
57
|
| `onModelMessage` | its own inference returns an assistant message |
|
|
58
58
|
| `onExternalModelMessage` | another agent's inference returns an assistant message |
|
|
59
|
+
| `onInternalEvent` | its own inference emits a semantic stream event |
|
|
60
|
+
| `onExternalEvent` | another participant emits a semantic stream event |
|
|
59
61
|
|
|
60
62
|
Every handler defaults to a no-op — override only the ones you care about.
|
|
61
63
|
|
|
62
64
|
```mermaid
|
|
63
65
|
flowchart LR
|
|
64
|
-
Human[
|
|
65
|
-
Agent[
|
|
66
|
+
Human[BaseHuman] -->|sendMessage| Env(("AgenticEnvironment"))
|
|
67
|
+
Agent[BaseAgent] -->|"runInference / executeFunctionCall"| Env
|
|
66
68
|
Observer[Custom Participant] -->|join| Env
|
|
67
69
|
Env -->|"onMessage / onExternal*"| Human
|
|
68
70
|
Env -->|"onFunctionCall / onReasoning / …"| Agent
|
|
@@ -74,26 +76,29 @@ flowchart LR
|
|
|
74
76
|
|
|
75
77
|
## Non-blocking participants
|
|
76
78
|
|
|
77
|
-
Mozaik ships
|
|
79
|
+
Mozaik ships three ready-to-use participants:
|
|
78
80
|
|
|
79
|
-
| Participant
|
|
80
|
-
|
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
81
|
+
| Participant | Role |
|
|
82
|
+
| --------------- | ---- |
|
|
83
|
+
| `BaseHuman` | Sends messages with `sendMessage(environment, text)` |
|
|
84
|
+
| `BaseAgent` | Runs inference and function calls via `InferenceRunner` and `FunctionCallRunner` |
|
|
85
|
+
| `BaseObserver` | Listens only; no inference |
|
|
83
86
|
|
|
84
87
|
```ts
|
|
85
88
|
import {
|
|
86
89
|
AgenticEnvironment,
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
BaseAgent,
|
|
91
|
+
BaseHuman,
|
|
92
|
+
OpenAIInferenceRunner,
|
|
93
|
+
DefaultFunctionCallRunner,
|
|
89
94
|
Gpt54Mini,
|
|
90
95
|
ModelContext,
|
|
91
96
|
} from "@mozaik-ai/core"
|
|
92
97
|
|
|
93
98
|
const environment = new AgenticEnvironment()
|
|
94
99
|
|
|
95
|
-
const human = new
|
|
96
|
-
const agent = new
|
|
100
|
+
const human = new BaseHuman()
|
|
101
|
+
const agent = new BaseAgent(new OpenAIInferenceRunner(), new DefaultFunctionCallRunner())
|
|
97
102
|
|
|
98
103
|
human.join(environment)
|
|
99
104
|
agent.join(environment)
|
|
@@ -104,7 +109,7 @@ const context = ModelContext.create("demo")
|
|
|
104
109
|
const model = new Gpt54Mini()
|
|
105
110
|
|
|
106
111
|
// Both participants produce items in parallel — neither awaits the other.
|
|
107
|
-
human.
|
|
112
|
+
human.sendMessage(environment, "Hello")
|
|
108
113
|
agent.runInference(environment, context, model)
|
|
109
114
|
```
|
|
110
115
|
|
|
@@ -114,32 +119,33 @@ The environment fans every item out to every subscriber synchronously and withou
|
|
|
114
119
|
|
|
115
120
|
## Reactive agent
|
|
116
121
|
|
|
117
|
-
A reactive agent extends `
|
|
122
|
+
A reactive agent extends `BaseAgent` and overrides the handlers it wants to react on. Each handler is already a no-op in the base class, so only the relevant ones need bodies:
|
|
118
123
|
|
|
119
124
|
```ts
|
|
120
125
|
import {
|
|
121
|
-
|
|
126
|
+
BaseAgent,
|
|
122
127
|
Participant,
|
|
123
128
|
UserMessageItem,
|
|
124
129
|
FunctionCallItem,
|
|
130
|
+
FunctionCallOutputItem,
|
|
131
|
+
ReasoningItem,
|
|
132
|
+
ModelMessageItem,
|
|
125
133
|
AgenticEnvironment,
|
|
126
134
|
ModelContext,
|
|
127
135
|
GenerativeModel,
|
|
128
|
-
InputStream,
|
|
129
136
|
InferenceRunner,
|
|
130
137
|
FunctionCallRunner,
|
|
131
138
|
} from "@mozaik-ai/core"
|
|
132
139
|
|
|
133
|
-
export class ReactiveAgent extends
|
|
140
|
+
export class ReactiveAgent extends BaseAgent {
|
|
134
141
|
constructor(
|
|
135
|
-
inputSource: InputStream,
|
|
136
142
|
inferenceRunner: InferenceRunner,
|
|
137
143
|
functionCallRunner: FunctionCallRunner,
|
|
138
144
|
private readonly environment: AgenticEnvironment,
|
|
139
145
|
private readonly context: ModelContext,
|
|
140
146
|
private readonly model: GenerativeModel,
|
|
141
147
|
) {
|
|
142
|
-
super(
|
|
148
|
+
super(inferenceRunner, functionCallRunner)
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
// A message from a human (or any other participant) → record it and think.
|
|
@@ -179,12 +185,29 @@ Three things to note:
|
|
|
179
185
|
|
|
180
186
|
---
|
|
181
187
|
|
|
188
|
+
## Streaming and semantic events
|
|
189
|
+
|
|
190
|
+
Enable streaming on a model that supports it, then run inference as usual:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
const model = new Gpt54Mini()
|
|
194
|
+
model.setStreaming(true)
|
|
195
|
+
|
|
196
|
+
await agent.runInference(environment, context, model)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
With streaming enabled, `OpenAIInferenceRunner` emits **`SemanticEvent`** chunks (provider `type` + `data`) into the environment. The producing agent receives `onInternalEvent`; everyone else receives `onExternalEvent(source, event)`. Use these handlers to drive a live UI—for example, print text deltas from `response.output_text.delta` events.
|
|
200
|
+
|
|
201
|
+
`setStreaming(true)` on a model without `supportStreaming` throws before the API is called.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
182
205
|
## Lifecycle hooks
|
|
183
206
|
|
|
184
207
|
Every participant receives lifecycle notifications when it or others join/leave an environment:
|
|
185
208
|
|
|
186
209
|
```ts
|
|
187
|
-
export class TeamAgent extends
|
|
210
|
+
export class TeamAgent extends BaseAgent {
|
|
188
211
|
// Called when this participant joins an environment.
|
|
189
212
|
onJoined(environment: AgenticEnvironment): void {
|
|
190
213
|
console.log("I joined the environment")
|
|
@@ -270,64 +293,41 @@ await repo.save(context)
|
|
|
270
293
|
|
|
271
294
|
Implement `ModelContextRepository` to plug in any storage backend.
|
|
272
295
|
|
|
273
|
-
The default
|
|
296
|
+
The default inference path is `OpenAIInferenceRunner`, which maps `ModelContext` to the OpenAI Responses API and back into typed `ContextItem`s (and `SemanticEvent`s when streaming). Bundled models: `Gpt54`, `Gpt54Mini`, `Gpt54Nano`, `Gpt55`.
|
|
274
297
|
|
|
275
298
|
```ts
|
|
276
|
-
import {
|
|
299
|
+
import { OpenAIInferenceRunner, DefaultFunctionCallRunner, Gpt54, ModelContext } from "@mozaik-ai/core"
|
|
300
|
+
|
|
301
|
+
const runner = new OpenAIInferenceRunner()
|
|
302
|
+
const context = ModelContext.create("demo")
|
|
277
303
|
|
|
278
|
-
const
|
|
279
|
-
|
|
304
|
+
for await (const item of runner.run(context, new Gpt54())) {
|
|
305
|
+
// ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent
|
|
306
|
+
}
|
|
280
307
|
```
|
|
281
308
|
|
|
282
309
|
---
|
|
283
310
|
|
|
284
311
|
## Overriding Generators
|
|
285
312
|
|
|
286
|
-
Mozaik uses generators for inference
|
|
287
|
-
|
|
288
|
-
### Custom `InputStream`
|
|
289
|
-
|
|
290
|
-
```ts
|
|
291
|
-
import { InputStream } from "@mozaik-ai/core"
|
|
292
|
-
|
|
293
|
-
export class HelloInputStream implements InputStream {
|
|
294
|
-
async *stream(): AsyncIterable<string> {
|
|
295
|
-
yield "Hello"
|
|
296
|
-
yield "World"
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
```
|
|
313
|
+
Mozaik uses async generators for inference and function calls — that's what lets the system emit events incrementally so participants can react to them as they arrive. Swap any runner to change _how_ events are produced.
|
|
300
314
|
|
|
301
|
-
|
|
315
|
+
Humans send text with `sendMessage(environment, message)`; other participants receive it via `onMessage`.
|
|
302
316
|
|
|
303
317
|
### Custom `InferenceRunner`
|
|
304
318
|
|
|
305
|
-
An `InferenceRunner` can yield `ReasoningItem`, `FunctionCallItem`, and `
|
|
319
|
+
An `InferenceRunner` can yield `ReasoningItem`, `FunctionCallItem`, `ModelMessageItem`, and `SemanticEvent` (when streaming).
|
|
306
320
|
|
|
307
321
|
```ts
|
|
308
322
|
import {
|
|
309
323
|
InferenceRunner,
|
|
310
|
-
InferenceRequest,
|
|
311
324
|
ModelContext,
|
|
312
325
|
GenerativeModel,
|
|
313
|
-
|
|
314
|
-
ReasoningItem,
|
|
315
|
-
FunctionCallItem,
|
|
316
|
-
ModelMessageItem,
|
|
326
|
+
OpenAIInferenceRunner,
|
|
317
327
|
} from "@mozaik-ai/core"
|
|
318
328
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
export class OpenAIInferenceRunner implements InferenceRunner {
|
|
322
|
-
private readonly runtime = new OpenAIResponses()
|
|
323
|
-
|
|
324
|
-
async *run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem> {
|
|
325
|
-
const response = await this.runtime.infer(new InferenceRequest(model, context))
|
|
326
|
-
for (const item of response.contextItems) {
|
|
327
|
-
yield item as InferenceItem
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
329
|
+
// Use the bundled runner, or implement InferenceRunner for another provider.
|
|
330
|
+
const runner: InferenceRunner = new OpenAIInferenceRunner()
|
|
331
331
|
```
|
|
332
332
|
|
|
333
333
|
### Custom `FunctionCallRunner`
|
|
@@ -353,13 +353,9 @@ export class ToolRegistryFunctionCallRunner implements FunctionCallRunner {
|
|
|
353
353
|
### Wiring it together
|
|
354
354
|
|
|
355
355
|
```ts
|
|
356
|
-
import {
|
|
356
|
+
import { BaseAgent, AgenticEnvironment, OpenAIInferenceRunner } from "@mozaik-ai/core"
|
|
357
357
|
|
|
358
|
-
const agent = new
|
|
359
|
-
new HelloInputStream(),
|
|
360
|
-
new OpenAIInferenceRunner(),
|
|
361
|
-
new ToolRegistryFunctionCallRunner(tools),
|
|
362
|
-
)
|
|
358
|
+
const agent = new BaseAgent(new OpenAIInferenceRunner(), new ToolRegistryFunctionCallRunner(tools))
|
|
363
359
|
|
|
364
360
|
agent.join(new AgenticEnvironment())
|
|
365
361
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -127,6 +127,11 @@ interface ReasoningEffort<Effort extends string> {
|
|
|
127
127
|
getReasoningEffort(): Effort;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
interface StreamingCapability {
|
|
131
|
+
setStreaming(streaming: boolean): void;
|
|
132
|
+
getStreaming(): boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
130
135
|
interface FunctionTool {
|
|
131
136
|
type: "function";
|
|
132
137
|
name: string;
|
|
@@ -151,7 +156,7 @@ type ModelSpecification = {
|
|
|
151
156
|
maxOutputTokens: number;
|
|
152
157
|
supportFunctionCalling: boolean;
|
|
153
158
|
};
|
|
154
|
-
interface GenerativeModel extends ReasoningEffort<string>, ToolCallingCapability {
|
|
159
|
+
interface GenerativeModel extends ReasoningEffort<string>, ToolCallingCapability, StreamingCapability {
|
|
155
160
|
readonly specification: ModelSpecification;
|
|
156
161
|
}
|
|
157
162
|
|
|
@@ -174,51 +179,9 @@ interface ModelContextRepository {
|
|
|
174
179
|
getByProjectId(projectId: string): Promise<ModelContext[]>;
|
|
175
180
|
}
|
|
176
181
|
|
|
177
|
-
declare class InferenceRequest {
|
|
178
|
-
readonly model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability;
|
|
179
|
-
readonly context: ModelContext;
|
|
180
|
-
constructor(model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
declare class InputTokenDetails {
|
|
184
|
-
readonly cached_tokens: number;
|
|
185
|
-
constructor(cached_tokens: number);
|
|
186
|
-
}
|
|
187
|
-
declare class OutputTokenDetails {
|
|
188
|
-
readonly reasoning_tokens: number;
|
|
189
|
-
constructor(reasoning_tokens: number);
|
|
190
|
-
}
|
|
191
|
-
declare class TokenUsage {
|
|
192
|
-
readonly inputTokens: number;
|
|
193
|
-
readonly outputTokens: number;
|
|
194
|
-
readonly totalTokens: number;
|
|
195
|
-
readonly inputTokenDetails: InputTokenDetails;
|
|
196
|
-
readonly outputTokenDetails: OutputTokenDetails;
|
|
197
|
-
constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
declare class InferenceResponse {
|
|
201
|
-
readonly contextItems: ContextItem[];
|
|
202
|
-
readonly tokenUsage?: TokenUsage;
|
|
203
|
-
constructor(contextItems: ContextItem[], tokenUsage: TokenUsage | undefined);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
interface ModelRuntime {
|
|
207
|
-
infer(request: InferenceRequest): Promise<InferenceResponse>;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
declare class OpenAIResponses implements ModelRuntime {
|
|
211
|
-
private readonly client;
|
|
212
|
-
constructor();
|
|
213
|
-
infer(inferenceRequest: InferenceRequest): Promise<InferenceResponse>;
|
|
214
|
-
extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
|
|
215
|
-
mapContextToRequest(context: ModelContext): any[];
|
|
216
|
-
extractContextItems(response: any): ContextItem[];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
182
|
type OpenAIReasoningEffortType = "xhigh" | "high" | "medium" | "low" | "none";
|
|
220
183
|
|
|
221
|
-
declare class Gpt54Nano implements GenerativeModel
|
|
184
|
+
declare class Gpt54Nano implements GenerativeModel {
|
|
222
185
|
readonly specification: {
|
|
223
186
|
name: string;
|
|
224
187
|
supportReasoningEffort: boolean;
|
|
@@ -230,13 +193,16 @@ declare class Gpt54Nano implements GenerativeModel, ReasoningEffort<OpenAIReason
|
|
|
230
193
|
};
|
|
231
194
|
private tools;
|
|
232
195
|
private readonly effort;
|
|
196
|
+
private streaming;
|
|
197
|
+
setStreaming(streaming: boolean): void;
|
|
198
|
+
getStreaming(): boolean;
|
|
233
199
|
setTools(tools: Tool[]): void;
|
|
234
200
|
getTools(): Tool[];
|
|
235
201
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
236
202
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
237
203
|
}
|
|
238
204
|
|
|
239
|
-
declare class Gpt54 implements GenerativeModel
|
|
205
|
+
declare class Gpt54 implements GenerativeModel {
|
|
240
206
|
readonly specification: {
|
|
241
207
|
name: string;
|
|
242
208
|
supportReasoningEffort: boolean;
|
|
@@ -247,6 +213,9 @@ declare class Gpt54 implements GenerativeModel, ReasoningEffort<OpenAIReasoningE
|
|
|
247
213
|
supportFunctionCalling: boolean;
|
|
248
214
|
};
|
|
249
215
|
private tools;
|
|
216
|
+
private streaming;
|
|
217
|
+
setStreaming(streaming: boolean): void;
|
|
218
|
+
getStreaming(): boolean;
|
|
250
219
|
setTools(tools: Tool[]): void;
|
|
251
220
|
getTools(): Tool[];
|
|
252
221
|
private readonly effort;
|
|
@@ -254,7 +223,7 @@ declare class Gpt54 implements GenerativeModel, ReasoningEffort<OpenAIReasoningE
|
|
|
254
223
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
255
224
|
}
|
|
256
225
|
|
|
257
|
-
declare class Gpt54Mini implements GenerativeModel
|
|
226
|
+
declare class Gpt54Mini implements GenerativeModel {
|
|
258
227
|
readonly specification: {
|
|
259
228
|
name: string;
|
|
260
229
|
supportReasoningEffort: boolean;
|
|
@@ -266,12 +235,32 @@ declare class Gpt54Mini implements GenerativeModel, ReasoningEffort<OpenAIReason
|
|
|
266
235
|
};
|
|
267
236
|
private tools;
|
|
268
237
|
private readonly effort;
|
|
238
|
+
private streaming;
|
|
239
|
+
setStreaming(streaming: boolean): void;
|
|
240
|
+
getStreaming(): boolean;
|
|
269
241
|
setReasoningEffort(effort: OpenAIReasoningEffortType): void;
|
|
270
242
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
271
243
|
setTools(tools: Tool[]): void;
|
|
272
244
|
getTools(): Tool[];
|
|
273
245
|
}
|
|
274
246
|
|
|
247
|
+
declare class InputTokenDetails {
|
|
248
|
+
readonly cached_tokens: number;
|
|
249
|
+
constructor(cached_tokens: number);
|
|
250
|
+
}
|
|
251
|
+
declare class OutputTokenDetails {
|
|
252
|
+
readonly reasoning_tokens: number;
|
|
253
|
+
constructor(reasoning_tokens: number);
|
|
254
|
+
}
|
|
255
|
+
declare class TokenUsage {
|
|
256
|
+
readonly inputTokens: number;
|
|
257
|
+
readonly outputTokens: number;
|
|
258
|
+
readonly totalTokens: number;
|
|
259
|
+
readonly inputTokenDetails: InputTokenDetails;
|
|
260
|
+
readonly outputTokenDetails: OutputTokenDetails;
|
|
261
|
+
constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
|
|
262
|
+
}
|
|
263
|
+
|
|
275
264
|
declare class InMemoryModelContextRepository implements ModelContextRepository {
|
|
276
265
|
private readonly store;
|
|
277
266
|
private readonly projectIndex;
|
|
@@ -293,6 +282,13 @@ declare class SystemMessageItem extends ContextItem {
|
|
|
293
282
|
}): SystemMessageItem;
|
|
294
283
|
}
|
|
295
284
|
|
|
285
|
+
declare class SemanticEvent<T> {
|
|
286
|
+
readonly type: string;
|
|
287
|
+
readonly data: T;
|
|
288
|
+
constructor(type: string, data: T);
|
|
289
|
+
getType(): string;
|
|
290
|
+
}
|
|
291
|
+
|
|
296
292
|
declare class AgenticEnvironment {
|
|
297
293
|
protected subscribers: Participant[];
|
|
298
294
|
private isActive;
|
|
@@ -303,6 +299,7 @@ declare class AgenticEnvironment {
|
|
|
303
299
|
deliverReasoning(source: Participant, item: ReasoningItem): void;
|
|
304
300
|
deliverFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
|
|
305
301
|
deliverMessage(source: Participant, message: string): void;
|
|
302
|
+
deliverSemanticEvent(source: Participant, item: SemanticEvent<unknown>): void;
|
|
306
303
|
start(): Promise<void>;
|
|
307
304
|
stop(): void;
|
|
308
305
|
}
|
|
@@ -326,35 +323,27 @@ declare abstract class Participant {
|
|
|
326
323
|
abstract onModelMessage(item: ModelMessageItem): Promise<void> | void;
|
|
327
324
|
abstract onExternalModelMessage(source: Participant, item: ModelMessageItem): Promise<void> | void;
|
|
328
325
|
abstract onMessage(message: string): Promise<void> | void;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
interface InputCapable {
|
|
332
|
-
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
333
|
-
}
|
|
334
|
-
interface InferenceCapable {
|
|
335
|
-
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
336
|
-
}
|
|
337
|
-
interface FunctionCallCapable {
|
|
338
|
-
executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
326
|
+
abstract onInternalEvent(item: SemanticEvent<unknown>): Promise<void> | void;
|
|
327
|
+
abstract onExternalEvent(source: Participant, item: SemanticEvent<unknown>): Promise<void> | void;
|
|
339
328
|
}
|
|
340
329
|
|
|
341
330
|
interface InferenceRunner {
|
|
342
|
-
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem
|
|
331
|
+
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>>;
|
|
343
332
|
}
|
|
344
333
|
|
|
345
334
|
interface FunctionCallRunner {
|
|
346
335
|
run(functionCallItem: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
|
|
347
336
|
}
|
|
348
337
|
|
|
349
|
-
|
|
350
|
-
|
|
338
|
+
declare abstract class Agent extends Participant {
|
|
339
|
+
abstract executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
340
|
+
abstract runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
351
341
|
}
|
|
352
342
|
|
|
353
|
-
declare class
|
|
354
|
-
private inputSource;
|
|
343
|
+
declare class BaseAgent extends Agent {
|
|
355
344
|
private inferenceRunner;
|
|
356
345
|
private functionCallRunner;
|
|
357
|
-
constructor(
|
|
346
|
+
constructor(inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
|
|
358
347
|
onJoined(): void;
|
|
359
348
|
onLeft(): void;
|
|
360
349
|
onParticipantJoined(participant: Participant): void;
|
|
@@ -368,14 +357,17 @@ declare class BaseAgentParticipant extends Participant implements InputCapable,
|
|
|
368
357
|
onModelMessage(item: ModelMessageItem): void;
|
|
369
358
|
onExternalModelMessage(source: Participant, item: ModelMessageItem): void;
|
|
370
359
|
onMessage(message: string): void;
|
|
360
|
+
onInternalEvent(item: SemanticEvent<unknown>): void;
|
|
361
|
+
onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
|
|
371
362
|
executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
372
363
|
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
373
|
-
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
374
364
|
}
|
|
375
365
|
|
|
376
|
-
declare class
|
|
377
|
-
|
|
378
|
-
|
|
366
|
+
declare abstract class Human extends Participant {
|
|
367
|
+
sendMessage(environment: AgenticEnvironment, message: string): void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
declare class BaseHuman extends Human {
|
|
379
371
|
onJoined(): void;
|
|
380
372
|
onLeft(): void;
|
|
381
373
|
onParticipantJoined(participant: Participant): void;
|
|
@@ -389,13 +381,16 @@ declare class BaseHumanParticipant extends Participant implements InputCapable {
|
|
|
389
381
|
onExternalFunctionCallOutput(source: Participant, item: FunctionCallOutputItem): void;
|
|
390
382
|
onExternalReasoning(source: Participant, item: ReasoningItem): void;
|
|
391
383
|
onExternalModelMessage(source: Participant, item: ModelMessageItem): void;
|
|
392
|
-
|
|
384
|
+
onInternalEvent(item: SemanticEvent<unknown>): void;
|
|
385
|
+
onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
|
|
393
386
|
}
|
|
394
387
|
|
|
395
|
-
type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem
|
|
388
|
+
type InferenceItem = ReasoningItem | FunctionCallItem | ModelMessageItem | SemanticEvent<unknown>;
|
|
396
389
|
declare class OpenAIInferenceRunner implements InferenceRunner {
|
|
397
|
-
private readonly runtime;
|
|
398
390
|
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<InferenceItem>;
|
|
391
|
+
extractTokenUsage(response: OpenAI.Responses.Response): TokenUsage | undefined;
|
|
392
|
+
mapContextToRequest(context: ModelContext): any[];
|
|
393
|
+
extractContextItems(response: any): ContextItem[];
|
|
399
394
|
}
|
|
400
395
|
|
|
401
396
|
declare class DefaultFunctionCallRunner implements FunctionCallRunner {
|
|
@@ -404,7 +399,7 @@ declare class DefaultFunctionCallRunner implements FunctionCallRunner {
|
|
|
404
399
|
run(call: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
|
|
405
400
|
}
|
|
406
401
|
|
|
407
|
-
declare class Gpt55 implements GenerativeModel
|
|
402
|
+
declare class Gpt55 implements GenerativeModel {
|
|
408
403
|
readonly specification: {
|
|
409
404
|
name: string;
|
|
410
405
|
supportReasoningEffort: boolean;
|
|
@@ -415,6 +410,9 @@ declare class Gpt55 implements GenerativeModel, ReasoningEffort<OpenAIReasoningE
|
|
|
415
410
|
supportFunctionCalling: boolean;
|
|
416
411
|
};
|
|
417
412
|
private tools;
|
|
413
|
+
private streaming;
|
|
414
|
+
setStreaming(streaming: boolean): void;
|
|
415
|
+
getStreaming(): boolean;
|
|
418
416
|
setTools(tools: Tool[]): void;
|
|
419
417
|
getTools(): Tool[];
|
|
420
418
|
private readonly effort;
|
|
@@ -422,7 +420,10 @@ declare class Gpt55 implements GenerativeModel, ReasoningEffort<OpenAIReasoningE
|
|
|
422
420
|
getReasoningEffort(): OpenAIReasoningEffortType;
|
|
423
421
|
}
|
|
424
422
|
|
|
425
|
-
declare class
|
|
423
|
+
declare abstract class Observer extends Participant {
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
declare class BaseObserver extends Observer {
|
|
426
427
|
onFunctionCall(item: FunctionCallItem): void;
|
|
427
428
|
onExternalFunctionCall(source: Participant, item: FunctionCallItem): void;
|
|
428
429
|
onFunctionCallOutput(item: FunctionCallOutputItem): void;
|
|
@@ -436,6 +437,8 @@ declare class BaseObserverParticipant extends Participant {
|
|
|
436
437
|
onLeft(): void;
|
|
437
438
|
onParticipantJoined(participant: Participant): void;
|
|
438
439
|
onParticipantLeft(participant: Participant): void;
|
|
440
|
+
onInternalEvent(item: SemanticEvent<unknown>): void;
|
|
441
|
+
onExternalEvent(source: Participant, item: SemanticEvent<unknown>): void;
|
|
439
442
|
}
|
|
440
443
|
|
|
441
|
-
export { AgenticEnvironment,
|
|
444
|
+
export { Agent, AgenticEnvironment, BaseAgent, BaseHuman, BaseObserver, ContextItem, DefaultFunctionCallRunner, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type FunctionCallRunner, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, Gpt55, Human, InMemoryModelContextRepository, type InferenceRunner, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, Observer, OpenAIInferenceRunner, OutputTokenDetails, Participant, ReasoningItem, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
|