owlmem 0.9.36 → 0.9.38

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/owlmem.mjs +35 -3
  2. package/package.json +1 -1
package/owlmem.mjs CHANGED
@@ -44,7 +44,7 @@ import { fileURLToPath } from "node:url";
44
44
  import { spawn, spawnSync } from "node:child_process";
45
45
  import { createConnection } from "node:net";
46
46
 
47
- export const VERSION = "0.9.36";
47
+ export const VERSION = "0.9.38";
48
48
  const BASE = (process.env.OWLMEM_URL || "https://owlmem.com").replace(/\/$/, "");
49
49
  const DIR = process.env.OWLMEM_HOME || join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "owlmem");
50
50
  const enc = new TextEncoder(), dec = new TextDecoder();
@@ -772,8 +772,12 @@ function sessionStartFile() {
772
772
  // The context meter (Stop + UserPromptSubmit): ~/.claude/settings.json gets entries that
773
773
  // run `owlmem hook context-meter` after each reply and before each prompt, showing the
774
774
  // measured context length. Same shape as the SessionStart hook, no matcher.
775
- export function contextMeterCommand() {
776
- return `node ${join(wakeDir(), "owlmem.mjs")} hook context-meter`;
775
+ export function contextMeterCommand(o = {}) {
776
+ // Same quoting as sessionStartCommand: a user name with spaces would otherwise split the
777
+ // path. On Windows the hook runs in Git Bash, so the path uses forward slashes there.
778
+ let p = join(o.dir ? join(o.dir, "wake") : wakeDir(), "owlmem.mjs");
779
+ if ((o.platform || platform()) === "win32") p = p.replace(/\\/g, "/");
780
+ return `node "${p}" hook context-meter`;
777
781
  }
778
782
  const isSessionStartOurs = (e) => (e?.hooks || []).some((h) => typeof h?.command === "string" && h.command.includes("owlmem") && h.command.includes("hook session-start"));
779
783
  const isContextMeterOurs = (e) => (e?.hooks || []).some((h) => typeof h?.command === "string" && h.command.includes("owlmem") && h.command.includes("hook context-meter"));
@@ -1469,9 +1473,37 @@ export function foregroundFirst(task) {
1469
1473
  `;
1470
1474
  }
1471
1475
 
1476
+ // A task handed out again after a clean exit while still "doing": the previous session probably started
1477
+ // background tests and its turn ended while waiting. Check whether the work is finished and mark it done,
1478
+ // or finish it — and run tests in the foreground, not the background, because nobody is watching.
1479
+ export function resumePrompt(task, place, o = {}) {
1480
+ const id = task.id, mins = o.timeout_min || WAKE_DEFAULTS.timeout_min;
1481
+ const where = place.worktree
1482
+ ? `Work in ${place.cwd}. It is a separate git worktree of ${place.repo} on the branch ${place.branch}, made for this task so it doesn't collide with other work. Commit your changes on this branch only. Don't merge, rebase or push other branches, and don't touch ${place.repo} itself. Put the branch name in your result so a person can review and merge it.`
1483
+ : place.scratch ? `There is no project directory for this task: you are in an empty folder (${place.cwd}). Use the OwlMem tools.`
1484
+ : `Work in ${place.cwd}. Other tasks wait until you finish here.`;
1485
+ return `${limitedNote(task)}OwlMem auto-wake started you on ${o.machine || "this computer"} to resume a task that is already in doing. A previous session left it in doing and ended cleanly, so check first whether the work is already finished.
1486
+
1487
+ Task #${id}, for ${task.agent}${task.broadcast ? " (sent to every agent; it is yours once you take it)" : ""}, from ${task.from}:
1488
+ Title: ${task.title}
1489
+
1490
+ ${task.body || "(no details)"}
1491
+
1492
+ Rules:
1493
+ 1. The task is already in doing — don't take it again with kb_task_update. First check whether the work is finished: look for the pull request, the branch, and the task thread. If it is finished, call kb_task_update with id=${id}, status="done" and note = the result, then end.
1494
+ 2. If it isn't finished, finish it: ${where}
1495
+ 3. Run tests in the foreground, not in the background: nobody is watching this session, and a background test run ends your turn while the work is still unfinished. Wait for the tests to finish before you end.
1496
+ 4. When you're finished, call kb_task_update with id=${id}, status="done" and note = the result (what you did, where it is).
1497
+ 5. If you can't do it — including anything that needs a person to approve, sign in, enter a code or confirm — call kb_task_update with id=${id}, status="declined" and note = what a person needs to do. Don't try to get around a permission you don't have.
1498
+ 6. Never put passwords, tokens, keys or other secrets in the note or in any message.
1499
+ 7. You have ${mins} minutes. After that this session is stopped and the task is handed to a person.
1500
+ `;
1501
+ }
1502
+
1472
1503
  export function wakePrompt(task, place, o = {}) {
1473
1504
  if (isReply(task)) return limitedNote(task) + foregroundFirst(task) + replyPrompt(task, o);
1474
1505
  if (isNote(task)) return limitedNote(task) + foregroundFirst(task) + notePrompt(task, place, o);
1506
+ if (task.resume) return resumePrompt(task, place, o);
1475
1507
  const id = task.id, mins = o.timeout_min || WAKE_DEFAULTS.timeout_min;
1476
1508
  const where = place.worktree
1477
1509
  ? `Work in ${place.cwd}. It is a separate git worktree of ${place.repo} on the branch ${place.branch}, made for this task so it doesn't collide with other work. Commit your changes on this branch only. Don't merge, rebase or push other branches, and don't touch ${place.repo} itself. Put the branch name in your result so a person can review and merge it.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owlmem",
3
- "version": "0.9.36",
3
+ "version": "0.9.38",
4
4
  "description": "OwlMem command line: connect your AI apps to OwlMem in one command (npx -y owlmem install), an end-to-end encrypted vault for your AI agents, and a local MCP server.",
5
5
  "type": "module",
6
6
  "bin": { "owlmem": "owlmem.mjs" },