owlmem 0.9.33 → 0.9.34

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 +40 -16
  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.33";
47
+ export const VERSION = "0.9.34";
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();
@@ -698,8 +698,12 @@ export function withRules(text, uninstall) {
698
698
  // network on every session start, and the npx cache can be cleaned out. install
699
699
  // copies this script there when it adds the hook; --uninstall removes only our
700
700
  // entry and leaves the copy (auto-wake runs it too).
701
- export function sessionStartCommand() {
702
- return `node ${join(wakeDir(), "owlmem.mjs")} hook session-start`;
701
+ export function sessionStartCommand(o = {}) {
702
+ // The script path is quoted: a user name with spaces would otherwise split it. On Windows the hook runs in
703
+ // Git Bash, so the path uses forward slashes there. o.dir is the config dir (the script lives in its wake/).
704
+ let p = join(o.dir ? join(o.dir, "wake") : wakeDir(), "owlmem.mjs");
705
+ if ((o.platform || platform()) === "win32") p = p.replace(/\\/g, "/");
706
+ return `node "${p}" hook session-start`;
703
707
  }
704
708
  function sessionStartFile() {
705
709
  return join(process.env.CLAUDE_CONFIG_DIR || join(home(), ".claude"), "settings.json");
@@ -2125,19 +2129,34 @@ async function claudeQuota(fetchImpl = fetch) {
2125
2129
  // the command line has only the port.
2126
2130
  // 11-21: also the desktop app's own language server (language_server_macos_arm etc. under Antigravity.app), which carries
2127
2131
  // --csrf_token and its ports on the command line; that's how a Mac without agy is found (fabric's Cirila.local).
2132
+ // The command lines of running processes, one per line (0.9.33, #4611). Windows has no ps: PowerShell reads
2133
+ // Win32_Process CommandLine instead. o.run(cmd, args) → { stdout } is injectable; tests never read the real
2134
+ // process list. A failing command → "" (never throws), the same as a computer with nothing running.
2135
+ export function agyProcesses(o = {}) {
2136
+ const run = o.run || ((cmd, args) => spawnSync(cmd, args, { encoding: "utf8", timeout: 10000 }));
2137
+ try {
2138
+ const r = (o.platform || process.platform) === "win32"
2139
+ ? run("powershell", ["-NoProfile", "-NonInteractive", "-Command", "Get-CimInstance Win32_Process | ForEach-Object { $_.CommandLine }"])
2140
+ : run("ps", ["-axww", "-o", "args="]);
2141
+ return !r || r.error ? "" : (r.stdout || "");
2142
+ } catch { return ""; }
2143
+ }
2128
2144
  // agyFind keeps only the ones that answer.
2129
2145
  export function agyServers(psOut, daemonDir = join(homedir(), ".gemini", "antigravity", "daemon")) {
2130
2146
  const out = [];
2131
2147
  const add = (port, token) => { port = Number(port); if (port > 0 && /^[\w-]{8,}$/.test(token || "") && !out.some((s) => s.port === port)) out.push({ port, token }); };
2132
- for (const l of String(psOut || "").split("\n")) {
2133
- const exe = l.trim().split(/\s/)[0] || "", tok = /--csrf_token[= ]([\w-]{8,})/.exec(l)?.[1];
2134
- if (/(^|\/)agy$/.test(exe)) {
2148
+ for (const raw of String(psOut || "").split("\n")) {
2149
+ // trim() also drops the \r of Windows CRLF output. The program may be a quoted Windows path, or an unquoted
2150
+ // one with spaces in it (C:\Users\Ann Lee\...), so classify by the program name wherever it sits in the
2151
+ // line, not by the first word.
2152
+ const l = raw.trim(), tok = /--csrf_token[= ]([\w-]{8,})/.exec(l)?.[1];
2153
+ if (/(?:^|[\s"\\/])agy(?:\.exe)?(?=[\s"]|$)/.test(l)) {
2135
2154
  const port = /--hub-port[= ](\d{2,5})\b/.exec(l);
2136
2155
  if (!port) continue;
2137
2156
  let token = tok;
2138
2157
  if (!token) { try { const d = JSON.parse(readFileSync(join(daemonDir, "hub_" + port[1] + ".json"), "utf8")); token = d?.csrfToken; } catch {} }
2139
2158
  add(port[1], token);
2140
- } else if (/(^|\/)language_server[\w.-]*$/.test(exe) && /antigravity/i.test(l) && tok) {
2159
+ } else if (/language_server[\w.-]*/.test(l) && /antigravity/i.test(l) && tok) {
2141
2160
  const before = out.length;
2142
2161
  for (const m of l.matchAll(/--(?:server_port|extension_server_port|http_server_port|lsp_port)[= ](\d{2,5})\b/g)) add(m[1], tok);
2143
2162
  // macOS app 2.33 (Cirila.local 11-21): no http port flag (only --https_server_port 0); the port is in its daemon file,
@@ -2155,6 +2174,12 @@ export function agyServers(psOut, daemonDir = join(homedir(), ".gemini", "antigr
2155
2174
  // its chat panel makes. Found and tested on ori 11-21 (a woken conversation answered OwlMem note #4114 in 26 s by itself).
2156
2175
  export function agyAppInstalled(o = {}) {
2157
2176
  const plat = o.platform || platform(), h = o.home || home(), exists = o.exists || existsSync;
2177
+ if (plat === "win32") {
2178
+ // %LOCALAPPDATA%\Programs\Antigravity\Antigravity.exe; joined with backslashes by hand — path.join on the
2179
+ // (possibly non-Windows) machine writing wake.json would use the wrong separator.
2180
+ const local = (o.env || process.env).LOCALAPPDATA || (h + "\\AppData\\Local");
2181
+ return exists(local + "\\Programs\\Antigravity\\Antigravity.exe");
2182
+ }
2158
2183
  if (plat !== "darwin") return false;
2159
2184
  return ["/Applications/Antigravity.app", join(h, "Applications", "Antigravity.app")].some((p) => exists(p));
2160
2185
  }
@@ -2192,11 +2217,11 @@ export function agyCall(s, fetchImpl = fetch) {
2192
2217
  return j || {};
2193
2218
  };
2194
2219
  }
2195
- // The first running app / agy hub that answers.
2196
- export async function agyFind(fetchImpl = fetch) {
2197
- if (process.platform === "win32") return null;
2198
- const ps = spawnSync("ps", ["-axww", "-o", "args="], { encoding: "utf8", timeout: 10000 });
2199
- for (const s of agyServers(ps.stdout)) { try { if ((await agyCall(s, fetchImpl)("GetUserStatus"))?.userStatus) return s; } catch {} }
2220
+ // The first running app / agy hub that answers. o.ps injects the process list; otherwise agyProcesses(o)
2221
+ // reads it (PowerShell on Windows, ps elsewhere), so Windows finds the app the same way (0.9.33, #4611).
2222
+ export async function agyFind(fetchImpl = fetch, o = {}) {
2223
+ const ps = o.ps !== undefined ? o.ps : agyProcesses(o);
2224
+ for (const s of agyServers(ps)) { try { if ((await agyCall(s, fetchImpl)("GetUserStatus"))?.userStatus) return s; } catch {} }
2200
2225
  return null;
2201
2226
  }
2202
2227
  const AGY_IDLE = "CASCADE_RUN_STATUS_IDLE";
@@ -2266,14 +2291,13 @@ export function agySummaryWindows(j) {
2266
2291
  }
2267
2292
  return Object.values(by).sort((a, b) => a.minutes - b.minutes).slice(0, 4);
2268
2293
  }
2269
- async function antigravityQuota(fetchImpl = fetch) {
2270
- if (process.platform === "win32") return null;
2271
- const ps = spawnSync("ps", ["-axww", "-o", "args="], { encoding: "utf8", timeout: 10000 });
2294
+ export async function antigravityQuota(fetchImpl = fetch, o = {}) {
2295
+ const ps = o.ps !== undefined ? o.ps : agyProcesses(o);
2272
2296
  const ask = (s, method) => fetchImpl("http://127.0.0.1:" + s.port + "/exa.language_server_pb.LanguageServerService/" + method,
2273
2297
  { method: "POST", headers: { "Content-Type": "application/json", "Connect-Protocol-Version": "1", "X-Codeium-Csrf-Token": s.token },
2274
2298
  body: JSON.stringify(method === "GetUserStatus" ? { metadata: { ideName: "antigravity" } } : {}), signal: AbortSignal.timeout(10000) })
2275
2299
  .then((r) => (r.ok ? r.json() : null));
2276
- for (const s of agyServers(ps.stdout)) {
2300
+ for (const s of agyServers(ps)) {
2277
2301
  try { const w = agySummaryWindows(await ask(s, "RetrieveUserQuotaSummary")); if (w.length) return w; } catch {}
2278
2302
  try { const w = agyWindows(await ask(s, "GetUserStatus")); if (w.length) return w; } catch {} // older apps without the summary
2279
2303
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owlmem",
3
- "version": "0.9.33",
3
+ "version": "0.9.34",
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" },