@mozaik-ai/core 4.0.3 → 4.0.5
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 +15 -15
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var ModelContext = class _ModelContext {
|
|
|
11
11
|
this.items.push(...contextItems);
|
|
12
12
|
return this;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
addContextItem(item) {
|
|
15
15
|
this.items.push(item);
|
|
16
16
|
return this;
|
|
17
17
|
}
|
|
@@ -401,7 +401,7 @@ var Agent = class _Agent extends Participant {
|
|
|
401
401
|
const memory = Memory.create();
|
|
402
402
|
const manifest = { id, name, capabilities, role: "agent" };
|
|
403
403
|
const developerMessage = DeveloperMessageItem.create(instruction);
|
|
404
|
-
memory.getContext().
|
|
404
|
+
memory.getContext().addContextItem(developerMessage);
|
|
405
405
|
return new _Agent(manifest, instruction, tools, memory, handlers);
|
|
406
406
|
}
|
|
407
407
|
getTools() {
|
|
@@ -560,7 +560,7 @@ var AgentLoop = class _AgentLoop {
|
|
|
560
560
|
async run(message, loopVisitor) {
|
|
561
561
|
var _a;
|
|
562
562
|
let transition = {
|
|
563
|
-
nextStateId: "
|
|
563
|
+
nextStateId: "message_received",
|
|
564
564
|
input: message
|
|
565
565
|
};
|
|
566
566
|
while (transition.nextStateId !== "idle") {
|
|
@@ -585,8 +585,8 @@ var AgentLoop = class _AgentLoop {
|
|
|
585
585
|
|
|
586
586
|
// src/domain/agentic-environment/loop/state-executor.ts
|
|
587
587
|
var LoopStateExecutor = class {
|
|
588
|
-
constructor(
|
|
589
|
-
this.
|
|
588
|
+
constructor(messageReceivedState, inferenceState, inferenceStreamingState, functionCallState, modelMessageState) {
|
|
589
|
+
this.messageReceivedState = messageReceivedState;
|
|
590
590
|
this.inferenceState = inferenceState;
|
|
591
591
|
this.inferenceStreamingState = inferenceStreamingState;
|
|
592
592
|
this.functionCallState = functionCallState;
|
|
@@ -594,8 +594,8 @@ var LoopStateExecutor = class {
|
|
|
594
594
|
}
|
|
595
595
|
async execute(transition, loopVisitor) {
|
|
596
596
|
switch (transition.nextStateId) {
|
|
597
|
-
case "
|
|
598
|
-
return await this.
|
|
597
|
+
case "message_received":
|
|
598
|
+
return await this.messageReceivedState.run(transition.input, loopVisitor);
|
|
599
599
|
case "inference":
|
|
600
600
|
return await this.inferenceState.run(transition.input, loopVisitor);
|
|
601
601
|
case "inference_streaming":
|
|
@@ -640,19 +640,19 @@ var FunctionCallState = class {
|
|
|
640
640
|
}
|
|
641
641
|
};
|
|
642
642
|
|
|
643
|
-
// src/application/states/
|
|
644
|
-
var
|
|
643
|
+
// src/application/states/message-received.ts
|
|
644
|
+
var MessageReceivedState = class {
|
|
645
645
|
constructor() {
|
|
646
|
-
this.id = "
|
|
646
|
+
this.id = "message_received";
|
|
647
647
|
}
|
|
648
648
|
async run(input, loopVisitor) {
|
|
649
|
-
loopVisitor.
|
|
649
|
+
loopVisitor.visitMessageReceivedStarted(input);
|
|
650
650
|
const userMessage = UserMessageItem.create(input.content);
|
|
651
651
|
const output = {
|
|
652
652
|
...input.input,
|
|
653
653
|
context: input.input.context.addContextItems([userMessage])
|
|
654
654
|
};
|
|
655
|
-
loopVisitor.
|
|
655
|
+
loopVisitor.visitMessageReceivedCompleted(output);
|
|
656
656
|
return {
|
|
657
657
|
stateId: this.id,
|
|
658
658
|
input,
|
|
@@ -693,7 +693,7 @@ var TransitionResolver = class {
|
|
|
693
693
|
// src/domain/agentic-environment/loop/transition-specification.ts
|
|
694
694
|
var MessageReceivedSpecification = class {
|
|
695
695
|
isSatisfiedBy(execution) {
|
|
696
|
-
return execution.stateId === "
|
|
696
|
+
return execution.stateId === "message_received";
|
|
697
697
|
}
|
|
698
698
|
};
|
|
699
699
|
function isInferenceExecution(execution) {
|
|
@@ -726,7 +726,7 @@ var ContextPreparationToInferenceRule = class {
|
|
|
726
726
|
this.specification = new MessageReceivedSpecification();
|
|
727
727
|
}
|
|
728
728
|
createTransition(execution) {
|
|
729
|
-
if (execution.stateId !== "
|
|
729
|
+
if (execution.stateId !== "message_received") {
|
|
730
730
|
throw new Error("Expected context_preparation execution");
|
|
731
731
|
}
|
|
732
732
|
const nextStateId = execution.output.streaming ? "inference_streaming" : "inference";
|
|
@@ -771,6 +771,7 @@ var InferenceToModelMessageRule = class {
|
|
|
771
771
|
if (!modelMessageItem) {
|
|
772
772
|
throw new Error("Expected inference model-message output");
|
|
773
773
|
}
|
|
774
|
+
execution.input.context.addContextItem(modelMessageItem);
|
|
774
775
|
return {
|
|
775
776
|
nextStateId: "model_message",
|
|
776
777
|
input: {
|
|
@@ -821,11 +822,11 @@ var EventPublisherLoopVisitor = class {
|
|
|
821
822
|
this.runtime = runtime;
|
|
822
823
|
this.cloud = createCloudClient();
|
|
823
824
|
}
|
|
824
|
-
|
|
825
|
-
this.publish("
|
|
825
|
+
visitMessageReceivedStarted(input) {
|
|
826
|
+
this.publish("message_received.started", input);
|
|
826
827
|
}
|
|
827
|
-
|
|
828
|
-
this.publish("
|
|
828
|
+
visitMessageReceivedCompleted(output) {
|
|
829
|
+
this.publish("message_received.completed", output);
|
|
829
830
|
}
|
|
830
831
|
visitInferenceStarted(input) {
|
|
831
832
|
this.publish("inference.started", input);
|
|
@@ -921,7 +922,7 @@ function createRunLoop(resolveRuntime) {
|
|
|
921
922
|
new ModelMessageToIdleRule()
|
|
922
923
|
]);
|
|
923
924
|
const stateExecutor = new LoopStateExecutor(
|
|
924
|
-
new
|
|
925
|
+
new MessageReceivedState(),
|
|
925
926
|
new InferenceState(inferenceRunner),
|
|
926
927
|
new InferenceStreamingState(inferenceRunner),
|
|
927
928
|
new FunctionCallState(functionCallRunner),
|