@mozaik-ai/core 4.0.0-beta.8 → 4.0.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 +267 -231
- package/dist/index.d.mts +47 -37
- package/dist/index.d.ts +47 -37
- package/dist/index.js +17 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -9
package/dist/index.mjs
CHANGED
|
@@ -558,20 +558,20 @@ var AgentLoop = class _AgentLoop {
|
|
|
558
558
|
this.interceptionHandler = interceptionHandler;
|
|
559
559
|
}
|
|
560
560
|
async run(message, loopVisitor) {
|
|
561
|
+
var _a;
|
|
561
562
|
let transition = {
|
|
562
563
|
nextStateId: "context_update",
|
|
563
564
|
input: message
|
|
564
565
|
};
|
|
565
566
|
while (transition.nextStateId !== "idle") {
|
|
566
|
-
const isInterceptionSatisfied = this.interceptionHandler.isSatisfiedBy(transition);
|
|
567
|
-
if (isInterceptionSatisfied) {
|
|
567
|
+
const isInterceptionSatisfied = (_a = this.interceptionHandler) == null ? void 0 : _a.isSatisfiedBy(transition);
|
|
568
|
+
if (isInterceptionSatisfied && this.interceptionHandler) {
|
|
568
569
|
loopVisitor.visitInterceptionStarted(transition);
|
|
569
570
|
transition = await this.interceptionHandler.handle(transition);
|
|
570
571
|
loopVisitor.visitInterceptionFinished(transition);
|
|
571
|
-
} else {
|
|
572
|
-
const execution = await this.stateExecutor.execute(transition, loopVisitor);
|
|
573
|
-
transition = this.transitionResolver.resolve(execution);
|
|
574
572
|
}
|
|
573
|
+
const execution = await this.stateExecutor.execute(transition, loopVisitor);
|
|
574
|
+
transition = this.transitionResolver.resolve(execution);
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
getLoopId() {
|
|
@@ -813,11 +813,13 @@ var ModelMessageToIdleRule = class {
|
|
|
813
813
|
};
|
|
814
814
|
|
|
815
815
|
// src/domain/agentic-environment/loop/event-publisher-visitor.ts
|
|
816
|
+
import { createCloudClient } from "@mozaik-ai/cloud-sdk";
|
|
816
817
|
var EventPublisherLoopVisitor = class {
|
|
817
818
|
constructor(agentId, loopId, runtime) {
|
|
818
819
|
this.agentId = agentId;
|
|
819
820
|
this.loopId = loopId;
|
|
820
821
|
this.runtime = runtime;
|
|
822
|
+
this.cloud = createCloudClient();
|
|
821
823
|
}
|
|
822
824
|
visitContextUpdateStarted(input) {
|
|
823
825
|
this.publish("context_update.started", { ...input, loopId: this.loopId });
|
|
@@ -850,12 +852,11 @@ var EventPublisherLoopVisitor = class {
|
|
|
850
852
|
this.publish("interception.finished", transition);
|
|
851
853
|
}
|
|
852
854
|
publish(type, payload) {
|
|
853
|
-
this.
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
});
|
|
855
|
+
const event = new SemanticEvent(type, this.agentId, /* @__PURE__ */ new Date(), payload);
|
|
856
|
+
this.runtime.publish(event);
|
|
857
|
+
if (this.cloud.enabled) {
|
|
858
|
+
this.cloud.send(event);
|
|
859
|
+
}
|
|
859
860
|
}
|
|
860
861
|
};
|
|
861
862
|
|
|
@@ -1065,7 +1066,7 @@ var AnthropicMessagesMapper = class {
|
|
|
1065
1066
|
);
|
|
1066
1067
|
}
|
|
1067
1068
|
}
|
|
1068
|
-
return { items, rowResponse: response };
|
|
1069
|
+
return { items, tokenUsage: this.extractTokenUsage(response), rowResponse: response };
|
|
1069
1070
|
}
|
|
1070
1071
|
};
|
|
1071
1072
|
|
|
@@ -1253,6 +1254,7 @@ var OpenAIResponsesMapper = class {
|
|
|
1253
1254
|
}
|
|
1254
1255
|
return {
|
|
1255
1256
|
items,
|
|
1257
|
+
tokenUsage: this.extractTokenUsage(response),
|
|
1256
1258
|
rowResponse: response
|
|
1257
1259
|
};
|
|
1258
1260
|
}
|
|
@@ -1441,7 +1443,7 @@ var GeminiGenerateContentMapper = class {
|
|
|
1441
1443
|
);
|
|
1442
1444
|
}
|
|
1443
1445
|
}
|
|
1444
|
-
return { items, rowResponse: response };
|
|
1446
|
+
return { items, tokenUsage: this.extractTokenUsage(response), rowResponse: response };
|
|
1445
1447
|
}
|
|
1446
1448
|
};
|
|
1447
1449
|
|
|
@@ -1564,7 +1566,7 @@ var OpenAIChatCompletionsMapper = class {
|
|
|
1564
1566
|
const items = [];
|
|
1565
1567
|
const message = (_b = (_a = response.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.message;
|
|
1566
1568
|
if (!message) {
|
|
1567
|
-
return { items: [], rowResponse: response };
|
|
1569
|
+
return { items: [], tokenUsage: this.extractTokenUsage(response), rowResponse: response };
|
|
1568
1570
|
}
|
|
1569
1571
|
if (message.reasoning_content) {
|
|
1570
1572
|
items.push(
|
|
@@ -1587,7 +1589,7 @@ var OpenAIChatCompletionsMapper = class {
|
|
|
1587
1589
|
})
|
|
1588
1590
|
);
|
|
1589
1591
|
}
|
|
1590
|
-
return { items, rowResponse: response };
|
|
1592
|
+
return { items, tokenUsage: this.extractTokenUsage(response), rowResponse: response };
|
|
1591
1593
|
}
|
|
1592
1594
|
};
|
|
1593
1595
|
|