@mozaik-ai/core 4.0.2 → 4.0.4
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -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";
|
|
@@ -821,11 +821,11 @@ var EventPublisherLoopVisitor = class {
|
|
|
821
821
|
this.runtime = runtime;
|
|
822
822
|
this.cloud = createCloudClient();
|
|
823
823
|
}
|
|
824
|
-
|
|
825
|
-
this.publish("
|
|
824
|
+
visitMessageReceivedStarted(input) {
|
|
825
|
+
this.publish("message_received.started", input);
|
|
826
826
|
}
|
|
827
|
-
|
|
828
|
-
this.publish("
|
|
827
|
+
visitMessageReceivedCompleted(output) {
|
|
828
|
+
this.publish("message_received.completed", output);
|
|
829
829
|
}
|
|
830
830
|
visitInferenceStarted(input) {
|
|
831
831
|
this.publish("inference.started", input);
|
|
@@ -852,7 +852,10 @@ var EventPublisherLoopVisitor = class {
|
|
|
852
852
|
this.publish("interception.finished", transition);
|
|
853
853
|
}
|
|
854
854
|
publish(type, payload) {
|
|
855
|
-
const event = new SemanticEvent(type, this.agentId, /* @__PURE__ */ new Date(),
|
|
855
|
+
const event = new SemanticEvent(type, this.agentId, /* @__PURE__ */ new Date(), {
|
|
856
|
+
...payload,
|
|
857
|
+
loopId: this.loopId
|
|
858
|
+
});
|
|
856
859
|
this.runtime.publish(event);
|
|
857
860
|
if (this.cloud.enabled) {
|
|
858
861
|
const participant = this.runtime.getParticipant(this.agentId);
|
|
@@ -864,7 +867,7 @@ var EventPublisherLoopVisitor = class {
|
|
|
864
867
|
...payload,
|
|
865
868
|
loopId: this.loopId,
|
|
866
869
|
agent: {
|
|
867
|
-
|
|
870
|
+
manifest: agent.getManifest(),
|
|
868
871
|
developerMessage: agent.getDeveloperMessage(),
|
|
869
872
|
tools: agent.getTools(),
|
|
870
873
|
memory: agent.getMemory().getContext().getItems()
|
|
@@ -918,7 +921,7 @@ function createRunLoop(resolveRuntime) {
|
|
|
918
921
|
new ModelMessageToIdleRule()
|
|
919
922
|
]);
|
|
920
923
|
const stateExecutor = new LoopStateExecutor(
|
|
921
|
-
new
|
|
924
|
+
new MessageReceivedState(),
|
|
922
925
|
new InferenceState(inferenceRunner),
|
|
923
926
|
new InferenceStreamingState(inferenceRunner),
|
|
924
927
|
new FunctionCallState(functionCallRunner),
|