owlmem 0.9.5 → 0.9.7
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 +28 -11
- package/package.json +1 -1
package/owlmem.mjs
CHANGED
|
@@ -41,7 +41,7 @@ import { join, dirname, basename, relative, isAbsolute } from "node:path";
|
|
|
41
41
|
import { fileURLToPath } from "node:url";
|
|
42
42
|
import { spawn, spawnSync } from "node:child_process";
|
|
43
43
|
|
|
44
|
-
export const VERSION = "0.9.
|
|
44
|
+
export const VERSION = "0.9.7";
|
|
45
45
|
const BASE = (process.env.OWLMEM_URL || "https://owlmem.com").replace(/\/$/, "");
|
|
46
46
|
const DIR = process.env.OWLMEM_HOME || join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "owlmem");
|
|
47
47
|
const enc = new TextEncoder(), dec = new TextDecoder();
|
|
@@ -1287,7 +1287,7 @@ export async function wakeLoop(o) {
|
|
|
1287
1287
|
await sleep(backoff); continue;
|
|
1288
1288
|
}
|
|
1289
1289
|
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)
|
|
1290
|
+
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
1291
|
for (const t of r.data.tasks || []) {
|
|
1292
1292
|
const plan = isReply(t) ? { kind: "scratch" } : o.plan ? o.plan(t) : planWorkdir(t); // a reply is read in an empty folder
|
|
1293
1293
|
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 +1426,7 @@ export function wakeTools(cfg, home_ = home(), env = process.env) {
|
|
|
1426
1426
|
// *.jsonl, token_count events). Only the numbers leave the computer — no text, no paths. Files are read from where the last
|
|
1427
1427
|
// scan stopped (usage.json in the wake folder), so a scan only reads what's new.
|
|
1428
1428
|
export const USAGE_EVERY = 10 * 60 * 1000, USAGE_DAYS = 8, USAGE_KEEP = 35;
|
|
1429
|
+
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
1430
|
const usageDay = (ts) => { const d = new Date(ts); return isNaN(d) ? null : d.toISOString().slice(0, 10); };
|
|
1430
1431
|
export function usageRoots(h = home(), env = process.env) {
|
|
1431
1432
|
return { "claude-code": join(env.CLAUDE_CONFIG_DIR || join(h, ".claude"), "projects"), codex: join(env.CODEX_HOME || join(h, ".codex"), "sessions") };
|
|
@@ -1588,18 +1589,30 @@ export function agyWindows(j) {
|
|
|
1588
1589
|
return Object.entries(groups).map(([at, used_percent]) => ({ minutes: null, used_percent, resets_at: Number(at) }))
|
|
1589
1590
|
.sort((a, b) => b.used_percent - a.used_percent || a.resets_at - b.resets_at).slice(0, 4);
|
|
1590
1591
|
}
|
|
1592
|
+
// 0.9.6: the app's quota summary has the real windows — each model group shares a 5-hour and a weekly limit (the per-model
|
|
1593
|
+
// numbers above are only the 5-hour one, and an unused model's reset time keeps moving). Per window length, the group
|
|
1594
|
+
// that has used the most counts.
|
|
1595
|
+
const AGY_WINDOW = { daily: 1440, weekly: 10080, monthly: 43200 };
|
|
1596
|
+
export function agySummaryWindows(j) {
|
|
1597
|
+
const by = {};
|
|
1598
|
+
for (const g of j?.response?.groups || []) for (const b of g?.buckets || []) {
|
|
1599
|
+
const h = /^(\d+)h$/.exec(b?.window || ""), minutes = h ? Number(h[1]) * 60 : AGY_WINDOW[b?.window], t = Date.parse(b?.resetTime);
|
|
1600
|
+
if (!minutes || typeof b?.remainingFraction !== "number" || isNaN(t)) continue;
|
|
1601
|
+
const used = Math.round((1 - Math.max(0, Math.min(1, b.remainingFraction))) * 1000) / 10, at = Math.floor(t / 1000), o = by[minutes];
|
|
1602
|
+
if (!o || used > o.used_percent || (used === o.used_percent && at < o.resets_at)) by[minutes] = { minutes, used_percent: used, resets_at: at };
|
|
1603
|
+
}
|
|
1604
|
+
return Object.values(by).sort((a, b) => a.minutes - b.minutes).slice(0, 4);
|
|
1605
|
+
}
|
|
1591
1606
|
async function antigravityQuota(fetchImpl = fetch) {
|
|
1592
1607
|
if (process.platform === "win32") return null;
|
|
1593
1608
|
const ps = spawnSync("ps", ["-axww", "-o", "args="], { encoding: "utf8", timeout: 10000 });
|
|
1609
|
+
const ask = (s, method) => fetchImpl("http://127.0.0.1:" + s.port + "/exa.language_server_pb.LanguageServerService/" + method,
|
|
1610
|
+
{ method: "POST", headers: { "Content-Type": "application/json", "Connect-Protocol-Version": "1", "X-Codeium-Csrf-Token": s.token },
|
|
1611
|
+
body: JSON.stringify(method === "GetUserStatus" ? { metadata: { ideName: "antigravity" } } : {}), signal: AbortSignal.timeout(10000) })
|
|
1612
|
+
.then((r) => (r.ok ? r.json() : null));
|
|
1594
1613
|
for (const s of agyServers(ps.stdout)) {
|
|
1595
|
-
try {
|
|
1596
|
-
|
|
1597
|
-
{ method: "POST", headers: { "Content-Type": "application/json", "Connect-Protocol-Version": "1", "X-Codeium-Csrf-Token": s.token },
|
|
1598
|
-
body: JSON.stringify({ metadata: { ideName: "antigravity" } }), signal: AbortSignal.timeout(10000) });
|
|
1599
|
-
if (!r.ok) continue;
|
|
1600
|
-
const w = agyWindows(await r.json());
|
|
1601
|
-
if (w.length) return w;
|
|
1602
|
-
} catch {}
|
|
1614
|
+
try { const w = agySummaryWindows(await ask(s, "RetrieveUserQuotaSummary")); if (w.length) return w; } catch {}
|
|
1615
|
+
try { const w = agyWindows(await ask(s, "GetUserStatus")); if (w.length) return w; } catch {} // older apps without the summary
|
|
1603
1616
|
}
|
|
1604
1617
|
return null;
|
|
1605
1618
|
}
|
|
@@ -1619,9 +1632,13 @@ async function usageTick(cfg, api, log, dir = DIR) {
|
|
|
1619
1632
|
scanUsage(state, Object.fromEntries(Object.entries(usageRoots()).filter(([c]) => clients.includes(c))));
|
|
1620
1633
|
try { writeFileSync(file + ".tmp", JSON.stringify(state)); renameSync(file + ".tmp", file); } catch (e) { log("usage: " + e.message); }
|
|
1621
1634
|
const status = usageStatus(state, clients);
|
|
1622
|
-
|
|
1635
|
+
// 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,
|
|
1636
|
+
// before the first poll says read_quota; or a stale sign-in) sends nothing for it rather than wiping the windows it has
|
|
1637
|
+
if (clients.includes("claude-code") && !livePolled) delete status["claude-code"];
|
|
1638
|
+
else if (clients.includes("claude-code") && (cfg.live || []).some((a) => a.client === "claude-code" && a.read_quota)) {
|
|
1623
1639
|
const w = await claudeQuota().catch(() => null);
|
|
1624
1640
|
if (w) status["claude-code"] = { ...status["claude-code"], windows: w, limit_at: Math.floor(Date.now() / 1000) };
|
|
1641
|
+
else if (!status["claude-code"]?.block) delete status["claude-code"];
|
|
1625
1642
|
}
|
|
1626
1643
|
const r = await api("usage", { days: usageReport(state, clients), status });
|
|
1627
1644
|
if (r.status !== 200 && r.status !== 404) log("usage: OwlMem answered " + (r.data?.detail || "HTTP " + r.status));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owlmem",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
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" },
|