@mobcode/openclaw-plugin 0.1.12 → 0.1.14
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/package.json +1 -1
- package/src/plugin-tools.js +1 -0
- package/src/state-store.js +13 -5
package/package.json
CHANGED
package/src/plugin-tools.js
CHANGED
|
@@ -183,6 +183,7 @@ export function registerMobcodeTools({ api, store }) {
|
|
|
183
183
|
if (!sessionKey) {
|
|
184
184
|
throw new Error("sessionKey is required for present_artifact.");
|
|
185
185
|
}
|
|
186
|
+
await store.init();
|
|
186
187
|
const document = normalizeArtifactDocument(args.artifact);
|
|
187
188
|
const saved = await store.upsertArtifact({
|
|
188
189
|
sessionKey,
|
package/src/state-store.js
CHANGED
|
@@ -918,8 +918,10 @@ export class MobcodeStateStore {
|
|
|
918
918
|
);
|
|
919
919
|
const now = new Date().toISOString();
|
|
920
920
|
|
|
921
|
-
const
|
|
922
|
-
|
|
921
|
+
const db = this._db();
|
|
922
|
+
db.exec("BEGIN");
|
|
923
|
+
try {
|
|
924
|
+
for (const item of messages) {
|
|
923
925
|
const normalizedMessage = normalizeMessageObject(item, item?.id ?? null);
|
|
924
926
|
const messageId = String(normalizedMessage?.id ?? "").trim() || null;
|
|
925
927
|
const sourceKey = createMessageSourceKey(
|
|
@@ -965,9 +967,15 @@ export class MobcodeStateStore {
|
|
|
965
967
|
}
|
|
966
968
|
}
|
|
967
969
|
touchSession.run(normalizedSessionKey, now);
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
970
|
+
db.exec("COMMIT");
|
|
971
|
+
} catch (error) {
|
|
972
|
+
try {
|
|
973
|
+
db.exec("ROLLBACK");
|
|
974
|
+
} catch {
|
|
975
|
+
// Ignore rollback failures so the original write error is preserved.
|
|
976
|
+
}
|
|
977
|
+
throw error;
|
|
978
|
+
}
|
|
971
979
|
this.logger?.info?.(
|
|
972
980
|
`[mobcode-store] indexed session=${normalizedSessionKey} messages=${messages.length}`,
|
|
973
981
|
);
|