@mozaik-ai/core 3.5.1 → 3.6.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/dist/index.d.mts +47 -185
- package/dist/index.d.ts +47 -185
- package/dist/index.js +77 -587
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -582
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -272,49 +272,6 @@ declare class Gpt54Mini implements GenerativeModel, ReasoningEffort<OpenAIReason
|
|
|
272
272
|
getTools(): Tool[];
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
interface Specification<T> {
|
|
276
|
-
isSatisfiedBy(candidate: T): boolean;
|
|
277
|
-
and(other: Specification<T>): Specification<T>;
|
|
278
|
-
or(other: Specification<T>): Specification<T>;
|
|
279
|
-
not(): Specification<T>;
|
|
280
|
-
}
|
|
281
|
-
declare abstract class BaseSpecification<T> implements Specification<T> {
|
|
282
|
-
abstract isSatisfiedBy(candidate: T): boolean;
|
|
283
|
-
and(other: Specification<T>): Specification<T>;
|
|
284
|
-
or(other: Specification<T>): Specification<T>;
|
|
285
|
-
not(): Specification<T>;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
interface Action<T> {
|
|
289
|
-
apply(candidate: T): T;
|
|
290
|
-
}
|
|
291
|
-
interface AsyncAction<T> {
|
|
292
|
-
apply(candidate: T): Promise<T>;
|
|
293
|
-
}
|
|
294
|
-
interface AsyncRule<T> {
|
|
295
|
-
specification: Specification<T>;
|
|
296
|
-
action: AsyncAction<T>;
|
|
297
|
-
apply(candidate: T): Promise<T>;
|
|
298
|
-
}
|
|
299
|
-
declare class If<T> implements AsyncRule<T> {
|
|
300
|
-
specification: Specification<T>;
|
|
301
|
-
action: AsyncAction<T>;
|
|
302
|
-
constructor({ specification, action }: {
|
|
303
|
-
specification: Specification<T>;
|
|
304
|
-
action: AsyncAction<T>;
|
|
305
|
-
});
|
|
306
|
-
apply(candidate: T): Promise<T>;
|
|
307
|
-
}
|
|
308
|
-
declare class Loop<T> implements AsyncRule<T> {
|
|
309
|
-
specification: Specification<T>;
|
|
310
|
-
action: AsyncAction<T>;
|
|
311
|
-
constructor({ specification, action }: {
|
|
312
|
-
specification: Specification<T>;
|
|
313
|
-
action: AsyncAction<T>;
|
|
314
|
-
});
|
|
315
|
-
apply(candidate: T): Promise<T>;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
275
|
declare class InMemoryModelContextRepository implements ModelContextRepository {
|
|
319
276
|
private readonly store;
|
|
320
277
|
private readonly projectIndex;
|
|
@@ -324,115 +281,6 @@ declare class InMemoryModelContextRepository implements ModelContextRepository {
|
|
|
324
281
|
private clone;
|
|
325
282
|
}
|
|
326
283
|
|
|
327
|
-
declare enum HookId {
|
|
328
|
-
BEFORE_MESSAGE_RECEIVED = "BEFORE_MESSAGE_RECEIVED",
|
|
329
|
-
AFTER_MESSAGE_RECEIVED = "AFTER_MESSAGE_RECEIVED",
|
|
330
|
-
BEFORE_INFERENCE = "BEFORE_INFERENCE",
|
|
331
|
-
AFTER_INFERENCE = "AFTER_INFERENCE",
|
|
332
|
-
BEFORE_FUNCTION_CALL = "BEFORE_FUNCTION_CALL",
|
|
333
|
-
AFTER_FUNCTION_CALL = "AFTER_FUNCTION_CALL",
|
|
334
|
-
BEFORE_MODEL_RESPONDED = "BEFORE_MODEL_RESPONDED",
|
|
335
|
-
AFTER_MODEL_RESPONDED = "AFTER_MODEL_RESPONDED",
|
|
336
|
-
ON_ERROR = "ON_ERROR"
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
interface TransitionRecord {
|
|
340
|
-
fromState: StateId;
|
|
341
|
-
toState: StateId;
|
|
342
|
-
timestamp: Date;
|
|
343
|
-
duration: number;
|
|
344
|
-
error: Error | null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
declare enum StateId {
|
|
348
|
-
MESSAGE_RECEIVED = "MESSAGE_RECEIVED",
|
|
349
|
-
INFERENCE_PENDING = "INFERENCE_PENDING",
|
|
350
|
-
FUNCTION_CALL_PENDING = "FUNCTION_CALL_PENDING",
|
|
351
|
-
MODEL_RESPONDED = "MODEL_RESPONDED"
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
declare enum ExecutionStatus {
|
|
355
|
-
RUNNING = 0,
|
|
356
|
-
COMPLETED = 1,
|
|
357
|
-
FAILED = 2
|
|
358
|
-
}
|
|
359
|
-
declare class Execution {
|
|
360
|
-
executionId: string;
|
|
361
|
-
currentStateId: StateId;
|
|
362
|
-
previousStateId: StateId | null;
|
|
363
|
-
status: ExecutionStatus;
|
|
364
|
-
stepCount: number;
|
|
365
|
-
retryCounts: Map<StateId, number>;
|
|
366
|
-
history: TransitionRecord[];
|
|
367
|
-
constructor(executionId: string, currentStateId: StateId, previousStateId: StateId | null, status: ExecutionStatus, stepCount: number, retryCounts: Map<StateId, number>, history: TransitionRecord[]);
|
|
368
|
-
isTerminal(): boolean;
|
|
369
|
-
static create(): Execution;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
interface RuntimeContext {
|
|
373
|
-
execution: Execution;
|
|
374
|
-
userMessage: UserMessageItem;
|
|
375
|
-
inferenceRequest?: InferenceRequest;
|
|
376
|
-
model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability;
|
|
377
|
-
context: ModelContext;
|
|
378
|
-
inferenceResponse?: InferenceResponse;
|
|
379
|
-
error?: Error;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
declare class AgentRuntime {
|
|
383
|
-
private hooksRegistry;
|
|
384
|
-
private stateHandlerRegistry;
|
|
385
|
-
constructor();
|
|
386
|
-
onMessageReceived(runtimeContext: RuntimeContext): Promise<void>;
|
|
387
|
-
onInferencePending(runtimeContext: RuntimeContext): Promise<void>;
|
|
388
|
-
onFunctionCallPending(runtimeContext: RuntimeContext): Promise<void>;
|
|
389
|
-
onError(context: RuntimeContext): Promise<void>;
|
|
390
|
-
onModelResponded(context: RuntimeContext): Promise<void>;
|
|
391
|
-
on(hookId: HookId, callback: (data: any) => Promise<void>): Promise<void>;
|
|
392
|
-
start(userMessage: UserMessageItem, model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext): Promise<void>;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
interface InferenceVisitor {
|
|
396
|
-
onStart(context: RuntimeContext): Promise<void>;
|
|
397
|
-
afterInference(inferenceResponse: InferenceResponse): Promise<void>;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
interface FunctionCallVisitor {
|
|
401
|
-
beforeFunctionCall(context: RuntimeContext): Promise<void>;
|
|
402
|
-
afterFunctionCall(context: RuntimeContext): Promise<void>;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
declare class Agent {
|
|
406
|
-
private visitor;
|
|
407
|
-
private functionCallVisitor;
|
|
408
|
-
protected runtime: AgentRuntime;
|
|
409
|
-
constructor();
|
|
410
|
-
beforeMessageReceived(context: RuntimeContext): Promise<void>;
|
|
411
|
-
afterMessageReceived(context: RuntimeContext): Promise<void>;
|
|
412
|
-
beforeInference(context: RuntimeContext): Promise<void>;
|
|
413
|
-
afterInference(context: RuntimeContext): Promise<void>;
|
|
414
|
-
beforeFunctionCall(context: RuntimeContext): Promise<void>;
|
|
415
|
-
afterFunctionCall(context: RuntimeContext): Promise<void>;
|
|
416
|
-
beforeModelResponded(context: RuntimeContext): Promise<void>;
|
|
417
|
-
afterModelResponded(context: RuntimeContext): Promise<void>;
|
|
418
|
-
onError(context: RuntimeContext): Promise<void>;
|
|
419
|
-
onStart(context: RuntimeContext): Promise<void>;
|
|
420
|
-
setInferenceVisitor(visitor: InferenceVisitor): void;
|
|
421
|
-
setFunctionCallVisitor(visitor: FunctionCallVisitor): void;
|
|
422
|
-
run(userMessage: string, model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext): Promise<void>;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
declare class AgentSociety {
|
|
426
|
-
name: string;
|
|
427
|
-
private agents;
|
|
428
|
-
private isActive;
|
|
429
|
-
constructor(name: string);
|
|
430
|
-
join(agent: Agent): void;
|
|
431
|
-
enter(messageText: string, model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext): void;
|
|
432
|
-
start(): Promise<void>;
|
|
433
|
-
stop(): void;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
284
|
declare class SystemMessageItem extends ContextItem {
|
|
437
285
|
readonly type = "message";
|
|
438
286
|
readonly role = "system";
|
|
@@ -445,48 +293,62 @@ declare class SystemMessageItem extends ContextItem {
|
|
|
445
293
|
}): SystemMessageItem;
|
|
446
294
|
}
|
|
447
295
|
|
|
448
|
-
interface ToolExecutor {
|
|
449
|
-
produce(functionCallItem: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
interface MessageSender {
|
|
453
|
-
stream(message: string, signal?: AbortSignal): AsyncIterable<string>;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
interface InferenceHandler {
|
|
457
|
-
produce(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem>;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
296
|
declare class AgenticEnvironment {
|
|
461
297
|
protected subscribers: Participant[];
|
|
462
298
|
private isActive;
|
|
463
|
-
start(): Promise<void>;
|
|
464
|
-
stop(): void;
|
|
465
299
|
subscribe(subscriber: Participant): void;
|
|
466
300
|
unsubscribe(user: Participant): void;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
notifyReasoning(user: Participant, item: ReasoningItem): void;
|
|
471
|
-
notifyOutputMessage(user: Participant, item: ModelMessageItem): void;
|
|
301
|
+
deliverContextItem(source: Participant, item: ContextItem): void;
|
|
302
|
+
start(): Promise<void>;
|
|
303
|
+
stop(): void;
|
|
472
304
|
}
|
|
473
305
|
|
|
474
306
|
declare abstract class Participant {
|
|
475
|
-
|
|
476
|
-
protected messageSender: MessageSender;
|
|
477
|
-
protected inferenceHandler: InferenceHandler;
|
|
478
|
-
protected environments: AgenticEnvironment[];
|
|
479
|
-
constructor(toolExecutor: ToolExecutor, messageSender: MessageSender, inferenceHandler: InferenceHandler);
|
|
480
|
-
abstract onFunctionCallOutput(participant: Participant, item: FunctionCallOutputItem): Promise<void>;
|
|
481
|
-
abstract onMessage(participant: Participant, message: string): Promise<void>;
|
|
482
|
-
abstract onFunctionCall(participant: Participant, item: FunctionCallItem): Promise<void>;
|
|
483
|
-
abstract onReasoning(participant: Participant, item: ReasoningItem): Promise<void>;
|
|
484
|
-
abstract onOutputMessage(participant: Participant, item: ModelMessageItem): Promise<void>;
|
|
485
|
-
sendMessage(message: string, environment: AgenticEnvironment): Promise<void>;
|
|
486
|
-
executeFunctionCall(functionCallItem: FunctionCallItem, environment: AgenticEnvironment): Promise<void>;
|
|
487
|
-
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
307
|
+
private environments;
|
|
488
308
|
join(environment: AgenticEnvironment): void;
|
|
489
309
|
leave(environment: AgenticEnvironment): void;
|
|
310
|
+
protected isJoinedTo(environment: AgenticEnvironment): boolean;
|
|
311
|
+
abstract onContextItem(source: Participant, item: ContextItem): Promise<void>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface InputCapable {
|
|
315
|
+
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
316
|
+
}
|
|
317
|
+
interface InferenceCapable {
|
|
318
|
+
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
319
|
+
}
|
|
320
|
+
interface FunctionCallCapable {
|
|
321
|
+
executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface InferenceRunner {
|
|
325
|
+
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
interface FunctionCallRunner {
|
|
329
|
+
run(functionCallItem: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
interface InputItemSource {
|
|
333
|
+
stream(signal?: AbortSignal): AsyncIterable<UserMessageItem | DeveloperMessageItem | SystemMessageItem>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
declare class BaseAgentParticipant extends Participant implements InputCapable, InferenceCapable, FunctionCallCapable {
|
|
337
|
+
private inputSource;
|
|
338
|
+
private inferenceRunner;
|
|
339
|
+
private functionCallRunner;
|
|
340
|
+
constructor(inputSource: InputItemSource, inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
|
|
341
|
+
onContextItem(source: Participant, item: ContextItem): Promise<void>;
|
|
342
|
+
executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
343
|
+
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
344
|
+
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
declare class BaseHumanParticipant extends Participant implements InputCapable {
|
|
348
|
+
private inputSource;
|
|
349
|
+
constructor(inputSource: InputItemSource);
|
|
350
|
+
onContextItem(source: Participant, item: ContextItem): Promise<void>;
|
|
351
|
+
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
490
352
|
}
|
|
491
353
|
|
|
492
|
-
export {
|
|
354
|
+
export { AgenticEnvironment, BaseAgentParticipant, BaseHumanParticipant, ContextItem, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, InMemoryModelContextRepository, InferenceRequest, InferenceResponse, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -272,49 +272,6 @@ declare class Gpt54Mini implements GenerativeModel, ReasoningEffort<OpenAIReason
|
|
|
272
272
|
getTools(): Tool[];
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
interface Specification<T> {
|
|
276
|
-
isSatisfiedBy(candidate: T): boolean;
|
|
277
|
-
and(other: Specification<T>): Specification<T>;
|
|
278
|
-
or(other: Specification<T>): Specification<T>;
|
|
279
|
-
not(): Specification<T>;
|
|
280
|
-
}
|
|
281
|
-
declare abstract class BaseSpecification<T> implements Specification<T> {
|
|
282
|
-
abstract isSatisfiedBy(candidate: T): boolean;
|
|
283
|
-
and(other: Specification<T>): Specification<T>;
|
|
284
|
-
or(other: Specification<T>): Specification<T>;
|
|
285
|
-
not(): Specification<T>;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
interface Action<T> {
|
|
289
|
-
apply(candidate: T): T;
|
|
290
|
-
}
|
|
291
|
-
interface AsyncAction<T> {
|
|
292
|
-
apply(candidate: T): Promise<T>;
|
|
293
|
-
}
|
|
294
|
-
interface AsyncRule<T> {
|
|
295
|
-
specification: Specification<T>;
|
|
296
|
-
action: AsyncAction<T>;
|
|
297
|
-
apply(candidate: T): Promise<T>;
|
|
298
|
-
}
|
|
299
|
-
declare class If<T> implements AsyncRule<T> {
|
|
300
|
-
specification: Specification<T>;
|
|
301
|
-
action: AsyncAction<T>;
|
|
302
|
-
constructor({ specification, action }: {
|
|
303
|
-
specification: Specification<T>;
|
|
304
|
-
action: AsyncAction<T>;
|
|
305
|
-
});
|
|
306
|
-
apply(candidate: T): Promise<T>;
|
|
307
|
-
}
|
|
308
|
-
declare class Loop<T> implements AsyncRule<T> {
|
|
309
|
-
specification: Specification<T>;
|
|
310
|
-
action: AsyncAction<T>;
|
|
311
|
-
constructor({ specification, action }: {
|
|
312
|
-
specification: Specification<T>;
|
|
313
|
-
action: AsyncAction<T>;
|
|
314
|
-
});
|
|
315
|
-
apply(candidate: T): Promise<T>;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
275
|
declare class InMemoryModelContextRepository implements ModelContextRepository {
|
|
319
276
|
private readonly store;
|
|
320
277
|
private readonly projectIndex;
|
|
@@ -324,115 +281,6 @@ declare class InMemoryModelContextRepository implements ModelContextRepository {
|
|
|
324
281
|
private clone;
|
|
325
282
|
}
|
|
326
283
|
|
|
327
|
-
declare enum HookId {
|
|
328
|
-
BEFORE_MESSAGE_RECEIVED = "BEFORE_MESSAGE_RECEIVED",
|
|
329
|
-
AFTER_MESSAGE_RECEIVED = "AFTER_MESSAGE_RECEIVED",
|
|
330
|
-
BEFORE_INFERENCE = "BEFORE_INFERENCE",
|
|
331
|
-
AFTER_INFERENCE = "AFTER_INFERENCE",
|
|
332
|
-
BEFORE_FUNCTION_CALL = "BEFORE_FUNCTION_CALL",
|
|
333
|
-
AFTER_FUNCTION_CALL = "AFTER_FUNCTION_CALL",
|
|
334
|
-
BEFORE_MODEL_RESPONDED = "BEFORE_MODEL_RESPONDED",
|
|
335
|
-
AFTER_MODEL_RESPONDED = "AFTER_MODEL_RESPONDED",
|
|
336
|
-
ON_ERROR = "ON_ERROR"
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
interface TransitionRecord {
|
|
340
|
-
fromState: StateId;
|
|
341
|
-
toState: StateId;
|
|
342
|
-
timestamp: Date;
|
|
343
|
-
duration: number;
|
|
344
|
-
error: Error | null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
declare enum StateId {
|
|
348
|
-
MESSAGE_RECEIVED = "MESSAGE_RECEIVED",
|
|
349
|
-
INFERENCE_PENDING = "INFERENCE_PENDING",
|
|
350
|
-
FUNCTION_CALL_PENDING = "FUNCTION_CALL_PENDING",
|
|
351
|
-
MODEL_RESPONDED = "MODEL_RESPONDED"
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
declare enum ExecutionStatus {
|
|
355
|
-
RUNNING = 0,
|
|
356
|
-
COMPLETED = 1,
|
|
357
|
-
FAILED = 2
|
|
358
|
-
}
|
|
359
|
-
declare class Execution {
|
|
360
|
-
executionId: string;
|
|
361
|
-
currentStateId: StateId;
|
|
362
|
-
previousStateId: StateId | null;
|
|
363
|
-
status: ExecutionStatus;
|
|
364
|
-
stepCount: number;
|
|
365
|
-
retryCounts: Map<StateId, number>;
|
|
366
|
-
history: TransitionRecord[];
|
|
367
|
-
constructor(executionId: string, currentStateId: StateId, previousStateId: StateId | null, status: ExecutionStatus, stepCount: number, retryCounts: Map<StateId, number>, history: TransitionRecord[]);
|
|
368
|
-
isTerminal(): boolean;
|
|
369
|
-
static create(): Execution;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
interface RuntimeContext {
|
|
373
|
-
execution: Execution;
|
|
374
|
-
userMessage: UserMessageItem;
|
|
375
|
-
inferenceRequest?: InferenceRequest;
|
|
376
|
-
model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability;
|
|
377
|
-
context: ModelContext;
|
|
378
|
-
inferenceResponse?: InferenceResponse;
|
|
379
|
-
error?: Error;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
declare class AgentRuntime {
|
|
383
|
-
private hooksRegistry;
|
|
384
|
-
private stateHandlerRegistry;
|
|
385
|
-
constructor();
|
|
386
|
-
onMessageReceived(runtimeContext: RuntimeContext): Promise<void>;
|
|
387
|
-
onInferencePending(runtimeContext: RuntimeContext): Promise<void>;
|
|
388
|
-
onFunctionCallPending(runtimeContext: RuntimeContext): Promise<void>;
|
|
389
|
-
onError(context: RuntimeContext): Promise<void>;
|
|
390
|
-
onModelResponded(context: RuntimeContext): Promise<void>;
|
|
391
|
-
on(hookId: HookId, callback: (data: any) => Promise<void>): Promise<void>;
|
|
392
|
-
start(userMessage: UserMessageItem, model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext): Promise<void>;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
interface InferenceVisitor {
|
|
396
|
-
onStart(context: RuntimeContext): Promise<void>;
|
|
397
|
-
afterInference(inferenceResponse: InferenceResponse): Promise<void>;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
interface FunctionCallVisitor {
|
|
401
|
-
beforeFunctionCall(context: RuntimeContext): Promise<void>;
|
|
402
|
-
afterFunctionCall(context: RuntimeContext): Promise<void>;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
declare class Agent {
|
|
406
|
-
private visitor;
|
|
407
|
-
private functionCallVisitor;
|
|
408
|
-
protected runtime: AgentRuntime;
|
|
409
|
-
constructor();
|
|
410
|
-
beforeMessageReceived(context: RuntimeContext): Promise<void>;
|
|
411
|
-
afterMessageReceived(context: RuntimeContext): Promise<void>;
|
|
412
|
-
beforeInference(context: RuntimeContext): Promise<void>;
|
|
413
|
-
afterInference(context: RuntimeContext): Promise<void>;
|
|
414
|
-
beforeFunctionCall(context: RuntimeContext): Promise<void>;
|
|
415
|
-
afterFunctionCall(context: RuntimeContext): Promise<void>;
|
|
416
|
-
beforeModelResponded(context: RuntimeContext): Promise<void>;
|
|
417
|
-
afterModelResponded(context: RuntimeContext): Promise<void>;
|
|
418
|
-
onError(context: RuntimeContext): Promise<void>;
|
|
419
|
-
onStart(context: RuntimeContext): Promise<void>;
|
|
420
|
-
setInferenceVisitor(visitor: InferenceVisitor): void;
|
|
421
|
-
setFunctionCallVisitor(visitor: FunctionCallVisitor): void;
|
|
422
|
-
run(userMessage: string, model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext): Promise<void>;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
declare class AgentSociety {
|
|
426
|
-
name: string;
|
|
427
|
-
private agents;
|
|
428
|
-
private isActive;
|
|
429
|
-
constructor(name: string);
|
|
430
|
-
join(agent: Agent): void;
|
|
431
|
-
enter(messageText: string, model: GenerativeModel & ReasoningEffort<string> & ToolCallingCapability, context: ModelContext): void;
|
|
432
|
-
start(): Promise<void>;
|
|
433
|
-
stop(): void;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
284
|
declare class SystemMessageItem extends ContextItem {
|
|
437
285
|
readonly type = "message";
|
|
438
286
|
readonly role = "system";
|
|
@@ -445,48 +293,62 @@ declare class SystemMessageItem extends ContextItem {
|
|
|
445
293
|
}): SystemMessageItem;
|
|
446
294
|
}
|
|
447
295
|
|
|
448
|
-
interface ToolExecutor {
|
|
449
|
-
produce(functionCallItem: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
interface MessageSender {
|
|
453
|
-
stream(message: string, signal?: AbortSignal): AsyncIterable<string>;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
interface InferenceHandler {
|
|
457
|
-
produce(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem>;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
296
|
declare class AgenticEnvironment {
|
|
461
297
|
protected subscribers: Participant[];
|
|
462
298
|
private isActive;
|
|
463
|
-
start(): Promise<void>;
|
|
464
|
-
stop(): void;
|
|
465
299
|
subscribe(subscriber: Participant): void;
|
|
466
300
|
unsubscribe(user: Participant): void;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
notifyReasoning(user: Participant, item: ReasoningItem): void;
|
|
471
|
-
notifyOutputMessage(user: Participant, item: ModelMessageItem): void;
|
|
301
|
+
deliverContextItem(source: Participant, item: ContextItem): void;
|
|
302
|
+
start(): Promise<void>;
|
|
303
|
+
stop(): void;
|
|
472
304
|
}
|
|
473
305
|
|
|
474
306
|
declare abstract class Participant {
|
|
475
|
-
|
|
476
|
-
protected messageSender: MessageSender;
|
|
477
|
-
protected inferenceHandler: InferenceHandler;
|
|
478
|
-
protected environments: AgenticEnvironment[];
|
|
479
|
-
constructor(toolExecutor: ToolExecutor, messageSender: MessageSender, inferenceHandler: InferenceHandler);
|
|
480
|
-
abstract onFunctionCallOutput(participant: Participant, item: FunctionCallOutputItem): Promise<void>;
|
|
481
|
-
abstract onMessage(participant: Participant, message: string): Promise<void>;
|
|
482
|
-
abstract onFunctionCall(participant: Participant, item: FunctionCallItem): Promise<void>;
|
|
483
|
-
abstract onReasoning(participant: Participant, item: ReasoningItem): Promise<void>;
|
|
484
|
-
abstract onOutputMessage(participant: Participant, item: ModelMessageItem): Promise<void>;
|
|
485
|
-
sendMessage(message: string, environment: AgenticEnvironment): Promise<void>;
|
|
486
|
-
executeFunctionCall(functionCallItem: FunctionCallItem, environment: AgenticEnvironment): Promise<void>;
|
|
487
|
-
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
307
|
+
private environments;
|
|
488
308
|
join(environment: AgenticEnvironment): void;
|
|
489
309
|
leave(environment: AgenticEnvironment): void;
|
|
310
|
+
protected isJoinedTo(environment: AgenticEnvironment): boolean;
|
|
311
|
+
abstract onContextItem(source: Participant, item: ContextItem): Promise<void>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface InputCapable {
|
|
315
|
+
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
316
|
+
}
|
|
317
|
+
interface InferenceCapable {
|
|
318
|
+
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
319
|
+
}
|
|
320
|
+
interface FunctionCallCapable {
|
|
321
|
+
executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface InferenceRunner {
|
|
325
|
+
run(context: ModelContext, model: GenerativeModel, signal?: AbortSignal): AsyncIterable<ReasoningItem | FunctionCallItem | ModelMessageItem>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
interface FunctionCallRunner {
|
|
329
|
+
run(functionCallItem: FunctionCallItem, signal?: AbortSignal): AsyncIterable<FunctionCallOutputItem>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
interface InputItemSource {
|
|
333
|
+
stream(signal?: AbortSignal): AsyncIterable<UserMessageItem | DeveloperMessageItem | SystemMessageItem>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
declare class BaseAgentParticipant extends Participant implements InputCapable, InferenceCapable, FunctionCallCapable {
|
|
337
|
+
private inputSource;
|
|
338
|
+
private inferenceRunner;
|
|
339
|
+
private functionCallRunner;
|
|
340
|
+
constructor(inputSource: InputItemSource, inferenceRunner: InferenceRunner, functionCallRunner: FunctionCallRunner);
|
|
341
|
+
onContextItem(source: Participant, item: ContextItem): Promise<void>;
|
|
342
|
+
executeFunctionCall(environment: AgenticEnvironment, functionCallItem: FunctionCallItem, signal?: AbortSignal): Promise<void>;
|
|
343
|
+
runInference(environment: AgenticEnvironment, context: ModelContext, model: GenerativeModel, signal?: AbortSignal): Promise<void>;
|
|
344
|
+
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
declare class BaseHumanParticipant extends Participant implements InputCapable {
|
|
348
|
+
private inputSource;
|
|
349
|
+
constructor(inputSource: InputItemSource);
|
|
350
|
+
onContextItem(source: Participant, item: ContextItem): Promise<void>;
|
|
351
|
+
streamInput(environment: AgenticEnvironment): Promise<void>;
|
|
490
352
|
}
|
|
491
353
|
|
|
492
|
-
export {
|
|
354
|
+
export { AgenticEnvironment, BaseAgentParticipant, BaseHumanParticipant, ContextItem, DeveloperMessageItem, FunctionCallItem, FunctionCallOutputItem, type GenerativeModel, Gpt54, Gpt54Mini, Gpt54Nano, InMemoryModelContextRepository, InferenceRequest, InferenceResponse, InputTokenDetails, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, SystemMessageItem, TokenUsage, type Tool, UserMessageItem };
|