owlmem 0.9.32 → 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.
- package/owlmem.mjs +70 -19
- 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.
|
|
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();
|
|
@@ -517,12 +517,38 @@ async function mcpServe() {
|
|
|
517
517
|
// ── hook: output for a Claude Code hook ──
|
|
518
518
|
// `owlmem hook session-start` prints the SessionStart additionalContext: the first
|
|
519
519
|
// step of every task is kb_find, before reading code. It runs at every session start,
|
|
520
|
-
// so it must be fast and offline: no network, no sign-in, nothing on stderr
|
|
521
|
-
//
|
|
520
|
+
// so it must be fast and offline: no network, no sign-in, nothing on stderr. It reads
|
|
521
|
+
// only the session cwd from stdin (to name this project's handoff key) and ignores
|
|
522
|
+
// anything else Claude Code sends there.
|
|
522
523
|
export const SESSION_START_CONTEXT = "Before reading any code or files, search OwlMem with kb_find: it is the first step of every task. In Claude Code, load it first with ToolSearch select:mcp__owlmem__kb_find. Then read code, run commands, and save reusable findings with kb_write.";
|
|
524
|
+
// The project this session runs in: the folder name of the git repository the cwd sits in
|
|
525
|
+
// (walk up to the first folder holding `.git`, a dir or a worktree's file), else the cwd's
|
|
526
|
+
// own folder name. No git binary, no network: just the filesystem.
|
|
527
|
+
function normalizeProjectName(name) {
|
|
528
|
+
return name.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "project";
|
|
529
|
+
}
|
|
530
|
+
function projectName(cwd) {
|
|
531
|
+
const start = isAbsolute(cwd) ? cwd : join(process.cwd(), cwd);
|
|
532
|
+
let dir = start;
|
|
533
|
+
while (!existsSync(join(dir, ".git"))) {
|
|
534
|
+
const parent = dirname(dir);
|
|
535
|
+
if (parent === dir) return normalizeProjectName(basename(start));
|
|
536
|
+
dir = parent;
|
|
537
|
+
}
|
|
538
|
+
return normalizeProjectName(basename(dir));
|
|
539
|
+
}
|
|
540
|
+
// The hook's stdin JSON carries the session cwd; only read it when stdin isn't a TTY,
|
|
541
|
+
// and tolerate empty or bad input (fall back to the process cwd).
|
|
542
|
+
function hookStdinCwd() {
|
|
543
|
+
if (process.stdin.isTTY) return null;
|
|
544
|
+
try { const p = JSON.parse(readFileSync(0, "utf8")); return typeof p?.cwd === "string" && p.cwd ? p.cwd : null; }
|
|
545
|
+
catch { return null; }
|
|
546
|
+
}
|
|
523
547
|
function hookCmd(sub) {
|
|
524
548
|
if (sub !== "session-start") throw new Fail("Usage: owlmem hook session-start");
|
|
525
|
-
|
|
549
|
+
const key = `<your name>-handoff-${projectName(hookStdinCwd() || process.cwd())}`;
|
|
550
|
+
const ctx = SESSION_START_CONTEXT + ` Handoff key for this project: \`${key}\` (kb_retain to save, kb_find to read; don't read another project's).`;
|
|
551
|
+
console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: ctx } }));
|
|
526
552
|
}
|
|
527
553
|
|
|
528
554
|
// ── install: connect the AI apps on this machine to OwlMem's MCP server ──
|
|
@@ -535,6 +561,7 @@ export const RULES = `## Team memory (OwlMem)
|
|
|
535
561
|
creating a duplicate.
|
|
536
562
|
- Store facts that change (prices, versions, status) with kb_retain and snapshot=true or an
|
|
537
563
|
expiry, so they retire on their own.
|
|
564
|
+
- Save a handoff with kb_retain under \`<your name>-handoff-<project>\`, where <project> is the folder name of the git repo you work in (else the working folder).
|
|
538
565
|
- Never put passwords or API keys in documents or memory. Use the OwlMem vault.`;
|
|
539
566
|
const MARK_START = "<!-- owlmem:start -->", MARK_END = "<!-- owlmem:end -->";
|
|
540
567
|
const DOCS = "https://owlmem.com/docs#";
|
|
@@ -671,8 +698,12 @@ export function withRules(text, uninstall) {
|
|
|
671
698
|
// network on every session start, and the npx cache can be cleaned out. install
|
|
672
699
|
// copies this script there when it adds the hook; --uninstall removes only our
|
|
673
700
|
// entry and leaves the copy (auto-wake runs it too).
|
|
674
|
-
export function sessionStartCommand() {
|
|
675
|
-
|
|
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`;
|
|
676
707
|
}
|
|
677
708
|
function sessionStartFile() {
|
|
678
709
|
return join(process.env.CLAUDE_CONFIG_DIR || join(home(), ".claude"), "settings.json");
|
|
@@ -2098,19 +2129,34 @@ async function claudeQuota(fetchImpl = fetch) {
|
|
|
2098
2129
|
// the command line has only the port.
|
|
2099
2130
|
// 11-21: also the desktop app's own language server (language_server_macos_arm etc. under Antigravity.app), which carries
|
|
2100
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
|
+
}
|
|
2101
2144
|
// agyFind keeps only the ones that answer.
|
|
2102
2145
|
export function agyServers(psOut, daemonDir = join(homedir(), ".gemini", "antigravity", "daemon")) {
|
|
2103
2146
|
const out = [];
|
|
2104
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 }); };
|
|
2105
|
-
for (const
|
|
2106
|
-
|
|
2107
|
-
|
|
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)) {
|
|
2108
2154
|
const port = /--hub-port[= ](\d{2,5})\b/.exec(l);
|
|
2109
2155
|
if (!port) continue;
|
|
2110
2156
|
let token = tok;
|
|
2111
2157
|
if (!token) { try { const d = JSON.parse(readFileSync(join(daemonDir, "hub_" + port[1] + ".json"), "utf8")); token = d?.csrfToken; } catch {} }
|
|
2112
2158
|
add(port[1], token);
|
|
2113
|
-
} else if (/
|
|
2159
|
+
} else if (/language_server[\w.-]*/.test(l) && /antigravity/i.test(l) && tok) {
|
|
2114
2160
|
const before = out.length;
|
|
2115
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);
|
|
2116
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,
|
|
@@ -2128,6 +2174,12 @@ export function agyServers(psOut, daemonDir = join(homedir(), ".gemini", "antigr
|
|
|
2128
2174
|
// its chat panel makes. Found and tested on ori 11-21 (a woken conversation answered OwlMem note #4114 in 26 s by itself).
|
|
2129
2175
|
export function agyAppInstalled(o = {}) {
|
|
2130
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
|
+
}
|
|
2131
2183
|
if (plat !== "darwin") return false;
|
|
2132
2184
|
return ["/Applications/Antigravity.app", join(h, "Applications", "Antigravity.app")].some((p) => exists(p));
|
|
2133
2185
|
}
|
|
@@ -2165,11 +2217,11 @@ export function agyCall(s, fetchImpl = fetch) {
|
|
|
2165
2217
|
return j || {};
|
|
2166
2218
|
};
|
|
2167
2219
|
}
|
|
2168
|
-
// The first running app / agy hub that answers.
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
const ps =
|
|
2172
|
-
for (const s of agyServers(ps
|
|
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 {} }
|
|
2173
2225
|
return null;
|
|
2174
2226
|
}
|
|
2175
2227
|
const AGY_IDLE = "CASCADE_RUN_STATUS_IDLE";
|
|
@@ -2239,14 +2291,13 @@ export function agySummaryWindows(j) {
|
|
|
2239
2291
|
}
|
|
2240
2292
|
return Object.values(by).sort((a, b) => a.minutes - b.minutes).slice(0, 4);
|
|
2241
2293
|
}
|
|
2242
|
-
async function antigravityQuota(fetchImpl = fetch) {
|
|
2243
|
-
|
|
2244
|
-
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);
|
|
2245
2296
|
const ask = (s, method) => fetchImpl("http://127.0.0.1:" + s.port + "/exa.language_server_pb.LanguageServerService/" + method,
|
|
2246
2297
|
{ method: "POST", headers: { "Content-Type": "application/json", "Connect-Protocol-Version": "1", "X-Codeium-Csrf-Token": s.token },
|
|
2247
2298
|
body: JSON.stringify(method === "GetUserStatus" ? { metadata: { ideName: "antigravity" } } : {}), signal: AbortSignal.timeout(10000) })
|
|
2248
2299
|
.then((r) => (r.ok ? r.json() : null));
|
|
2249
|
-
for (const s of agyServers(ps
|
|
2300
|
+
for (const s of agyServers(ps)) {
|
|
2250
2301
|
try { const w = agySummaryWindows(await ask(s, "RetrieveUserQuotaSummary")); if (w.length) return w; } catch {}
|
|
2251
2302
|
try { const w = agyWindows(await ask(s, "GetUserStatus")); if (w.length) return w; } catch {} // older apps without the summary
|
|
2252
2303
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owlmem",
|
|
3
|
-
"version": "0.9.
|
|
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" },
|