opencode-mastra-om 0.1.6 → 0.1.7
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.js +9 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -180056,24 +180056,23 @@ ${OBSERVATION_CONTINUATION_HINT}`);
|
|
|
180056
180056
|
return "No messages to observe.";
|
|
180057
180057
|
const mastraMessages = convertMessages2(resp.data, threadId);
|
|
180058
180058
|
await backupObservations(threadId, "pre-observe");
|
|
180059
|
-
const
|
|
180060
|
-
if (!
|
|
180059
|
+
const chunkBytes = config2.chunkBytes;
|
|
180060
|
+
if (!chunkBytes) {
|
|
180061
180061
|
await runObserve(threadId, mastraMessages);
|
|
180062
180062
|
return "Observation cycle triggered. Check om_status for results.";
|
|
180063
180063
|
}
|
|
180064
|
-
const tokenCounter = new TokenCounter;
|
|
180065
180064
|
const chunks = [];
|
|
180066
180065
|
let currentChunk = [];
|
|
180067
|
-
let
|
|
180066
|
+
let currentBytes = 0;
|
|
180068
180067
|
for (const msg of mastraMessages) {
|
|
180069
|
-
const
|
|
180070
|
-
if (
|
|
180068
|
+
const msgBytes = Buffer.byteLength(JSON.stringify(msg), "utf8");
|
|
180069
|
+
if (currentBytes + msgBytes > chunkBytes && currentChunk.length > 0) {
|
|
180071
180070
|
chunks.push(currentChunk);
|
|
180072
180071
|
currentChunk = [msg];
|
|
180073
|
-
|
|
180072
|
+
currentBytes = msgBytes;
|
|
180074
180073
|
} else {
|
|
180075
180074
|
currentChunk.push(msg);
|
|
180076
|
-
|
|
180075
|
+
currentBytes += msgBytes;
|
|
180077
180076
|
}
|
|
180078
180077
|
}
|
|
180079
180078
|
if (currentChunk.length > 0)
|
|
@@ -180082,9 +180081,9 @@ ${OBSERVATION_CONTINUATION_HINT}`);
|
|
|
180082
180081
|
await runObserve(threadId, mastraMessages);
|
|
180083
180082
|
return "Observation cycle triggered (single chunk). Check om_status for results.";
|
|
180084
180083
|
}
|
|
180085
|
-
omLog(`[observe] chunked into ${chunks.length} chunks of ~${
|
|
180084
|
+
omLog(`[observe] chunked into ${chunks.length} chunks of ~${Math.round(chunkBytes / 1024)}KB each`);
|
|
180086
180085
|
ctx.client.tui.showToast({
|
|
180087
|
-
body: { title: "Mastra OM", message: `Observing in ${chunks.length} chunks...`, variant: "info", duration: 5000 }
|
|
180086
|
+
body: { title: "Mastra OM", message: `Observing in ${chunks.length} chunks (~${Math.round(chunkBytes / 1024)}KB each)...`, variant: "info", duration: 5000 }
|
|
180088
180087
|
});
|
|
180089
180088
|
const refThreshold = resolveThreshold(omOptions.reflection?.observationTokens ?? 60000);
|
|
180090
180089
|
const reflectAt = Math.floor(refThreshold * 0.8);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "opencode-mastra-om",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Enhanced Mastra Observational Memory plugin for OpenCode — persistent cross-session memory with observation, reflection, and manual trigger tools",
|