owlmem 0.9.6 → 0.9.8

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 +20 -3
  2. package/package.json +1 -1
package/owlmem.mjs CHANGED
@@ -10,6 +10,8 @@
10
10
  // Claude Desktop on this computer to OwlMem (npx -y owlmem install)
11
11
  // owlmem wake enable|disable|status auto-wake: start the AI on this computer when it gets a task (runs from login)
12
12
  // owlmem login save this agent's token (from the console)
13
+ // owlmem inbox [--check] how many tasks / notes wait for this AI, without reading them; --check exits 0
14
+ // when something waits, 1 when nothing does (for a scheduled script: start the AI only then)
13
15
  // owlmem vault unlock paste the recovery code once per machine
14
16
  // owlmem vault ls
15
17
  // owlmem vault get <name> [field] prints the item (or one field) to stdout
@@ -41,7 +43,7 @@ import { join, dirname, basename, relative, isAbsolute } from "node:path";
41
43
  import { fileURLToPath } from "node:url";
42
44
  import { spawn, spawnSync } from "node:child_process";
43
45
 
44
- export const VERSION = "0.9.6";
46
+ export const VERSION = "0.9.8";
45
47
  const BASE = (process.env.OWLMEM_URL || "https://owlmem.com").replace(/\/$/, "");
46
48
  const DIR = process.env.OWLMEM_HOME || join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "owlmem");
47
49
  const enc = new TextEncoder(), dec = new TextDecoder();
@@ -1287,7 +1289,7 @@ export async function wakeLoop(o) {
1287
1289
  await sleep(backoff); continue;
1288
1290
  }
1289
1291
  backoff = 0;
1290
- if (Array.isArray(r.data.agents)) cfg.live = r.data.agents; // which AIs the owner lets us read Claude quota for (read_quota)
1292
+ if (Array.isArray(r.data.agents)) { cfg.live = r.data.agents; livePolled = true; } // which AIs the owner lets us read Claude quota for (read_quota)
1291
1293
  for (const t of r.data.tasks || []) {
1292
1294
  const plan = isReply(t) ? { kind: "scratch" } : o.plan ? o.plan(t) : planWorkdir(t); // a reply is read in an empty folder
1293
1295
  log((isReply(t) ? "Reply #" + t.id + " (task #" + t.task_id + ")" : jobLabel(t)) + " for " + t.agent + ": starting " + t.client + (plan.dir ? " in " + plan.dir : "") + ".");
@@ -1426,6 +1428,7 @@ export function wakeTools(cfg, home_ = home(), env = process.env) {
1426
1428
  // *.jsonl, token_count events). Only the numbers leave the computer — no text, no paths. Files are read from where the last
1427
1429
  // scan stopped (usage.json in the wake folder), so a scan only reads what's new.
1428
1430
  export const USAGE_EVERY = 10 * 60 * 1000, USAGE_DAYS = 8, USAGE_KEEP = 35;
1431
+ let livePolled = false; // OwlMem has answered a poll since this run started, so cfg.live (read_quota) is current, not what wake.json kept
1429
1432
  const usageDay = (ts) => { const d = new Date(ts); return isNaN(d) ? null : d.toISOString().slice(0, 10); };
1430
1433
  export function usageRoots(h = home(), env = process.env) {
1431
1434
  return { "claude-code": join(env.CLAUDE_CONFIG_DIR || join(h, ".claude"), "projects"), codex: join(env.CODEX_HOME || join(h, ".codex"), "sessions") };
@@ -1631,9 +1634,13 @@ async function usageTick(cfg, api, log, dir = DIR) {
1631
1634
  scanUsage(state, Object.fromEntries(Object.entries(usageRoots()).filter(([c]) => clients.includes(c))));
1632
1635
  try { writeFileSync(file + ".tmp", JSON.stringify(state)); renameSync(file + ".tmp", file); } catch (e) { log("usage: " + e.message); }
1633
1636
  const status = usageStatus(state, clients);
1634
- if (clients.includes("claude-code") && (cfg.live || []).some((a) => a.client === "claude-code" && a.read_quota)) {
1637
+ // 0.9.6: OwlMem keeps only the newest status per app, so a round that couldn't read Claude's quota (right after a restart,
1638
+ // before the first poll says read_quota; or a stale sign-in) sends nothing for it rather than wiping the windows it has
1639
+ if (clients.includes("claude-code") && !livePolled) delete status["claude-code"];
1640
+ else if (clients.includes("claude-code") && (cfg.live || []).some((a) => a.client === "claude-code" && a.read_quota)) {
1635
1641
  const w = await claudeQuota().catch(() => null);
1636
1642
  if (w) status["claude-code"] = { ...status["claude-code"], windows: w, limit_at: Math.floor(Date.now() / 1000) };
1643
+ else if (!status["claude-code"]?.block) delete status["claude-code"];
1637
1644
  }
1638
1645
  const r = await api("usage", { days: usageReport(state, clients), status });
1639
1646
  if (r.status !== 200 && r.status !== 404) log("usage: OwlMem answered " + (r.data?.detail || "HTTP " + r.status));
@@ -1791,6 +1798,16 @@ export async function main(argv) {
1791
1798
  if (cmd === "uninstall") { await install(["--uninstall", ...argv.slice(1)]); return; }
1792
1799
  if (cmd === "mcp") { await mcpServe(); return; }
1793
1800
  if (cmd === "wake") { await wakeCmd(sub, rest); return; }
1801
+ if (cmd === "inbox") { // for a scheduled script (11-02): how many notes / tasks wait for this AI, without reading them (nothing is marked read)
1802
+ const check = argv.includes("--check");
1803
+ let r, data = {};
1804
+ try { r = await fetch(BASE + "/v1/inbox", { headers: { Authorization: "Bearer " + token(), "User-Agent": "owlmem-cli/" + VERSION } }); data = await r.json().catch(() => ({})); }
1805
+ catch (e) { say("Can't reach OwlMem (" + BASE + "): " + e.message); process.exitCode = 2; return; }
1806
+ if (r.status >= 400) { say(data.detail || data.error || "HTTP " + r.status); process.exitCode = 2; return; }
1807
+ if (!check || data.work) console.log(data.work ? `${data.tasks} task(s), ${data.notes} unread note(s) waiting.` : "Nothing waiting.");
1808
+ if (check) process.exitCode = data.work ? 0 : 1; // owlmem inbox --check && <start your AI>
1809
+ return;
1810
+ }
1794
1811
  if (cmd === "device") { // show this machine's fingerprint (the console lists approved computers with it)
1795
1812
  const r = await call("POST", "device", {});
1796
1813
  if (r.status >= 400) throw new Fail(r.data.detail || r.data.error || "HTTP " + r.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owlmem",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
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" },