@eleboucher/opencode-memini 0.4.15 → 0.4.16

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.
Files changed (2) hide show
  1. package/memini.js +15 -4
  2. package/package.json +1 -1
package/memini.js CHANGED
@@ -346,8 +346,19 @@ export const MeminiPlugin = async ({ client, worktree, directory }, options) =>
346
346
  // the same turn don't write duplicates.
347
347
  const captured = new Set();
348
348
 
349
+ // opencode runs chat.message via an unguarded Effect.promise (a throw aborts the
350
+ // turn) and dispatches event hooks fire-and-forget, so a hook must never reject:
351
+ // swallow and log instead.
352
+ const guard = (name, fn) => async (...args) => {
353
+ try {
354
+ return await fn(...args);
355
+ } catch (error) {
356
+ log.warn(`${name} hook failed: ${String(error)}`);
357
+ }
358
+ };
359
+
349
360
  return {
350
- "chat.message": async (input, output) => {
361
+ "chat.message": guard("chat.message", async (input, output) => {
351
362
  if (!cfg.recall) return;
352
363
  const query = extractPartsText(output && output.parts);
353
364
  if (!query) return;
@@ -399,9 +410,9 @@ export const MeminiPlugin = async ({ client, worktree, directory }, options) =>
399
410
  synthetic: true,
400
411
  text: lines.join("\n"),
401
412
  });
402
- },
413
+ }),
403
414
 
404
- event: async ({ event }) => {
415
+ event: guard("event", async ({ event }) => {
405
416
  if (!cfg.capture || !event || event.type !== "session.idle") return;
406
417
  const sessionID = event.properties && event.properties.sessionID;
407
418
  if (!sessionID) return;
@@ -416,7 +427,7 @@ export const MeminiPlugin = async ({ client, worktree, directory }, options) =>
416
427
  metadata: { source: "opencode", session_id: sessionID, format: "turn" },
417
428
  });
418
429
  if (stored !== null && assistantID) captured.add(assistantID);
419
- },
430
+ }),
420
431
  };
421
432
  };
422
433
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleboucher/opencode-memini",
3
- "version": "0.4.15",
3
+ "version": "0.4.16",
4
4
  "description": "Automatic cross-session memory for opencode via memini — recall before each turn, capture after.",
5
5
  "keywords": [
6
6
  "memini",