owlmem 0.9.24 → 0.9.26

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 (3) hide show
  1. package/README.md +3 -2
  2. package/owlmem.mjs +37 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -43,6 +43,8 @@ npx -y owlmem wake disable # also done by npx -y owlmem uninstall
43
43
 
44
44
  - **Pairing.** `wake enable` prints a link: open it, check the code matches, and pick which AI each app on this
45
45
  computer is. Until then nothing starts. The computer is identified by its device key (next to `config.json`).
46
+ 已登录时配对自动批准:if this computer is already logged in (`owlmem login`), pairing is approved automatically
47
+ and the apps are matched to your AIs by their app names — no console step.
46
48
  - **Runs as you.** A systemd user service (Linux), a LaunchAgent (macOS) or a logon task (Windows) — this user
47
49
  only, no admin rights. `--boot` (Linux) turns on lingering so it runs from boot, not just from login.
48
50
  - **One program per computer** for every paired AI. One task at a time per AI, at most 2 at once (`--max`),
@@ -56,8 +58,7 @@ npx -y owlmem wake disable # also done by npx -y owlmem uninstall
56
58
  Claude Code is only additionally allowed the two OwlMem tools it needs to report back (`kb_task_update`,
57
59
  `kb_inbox`). Anything that needs a person — an approval, a sign-in, a code — it declines, saying what to do.
58
60
  It is told never to put secrets in its result.
59
- - **Turning it off.** Each AI has an auto-wake switch in the console (AI agents → Agents), where you can also remove
60
- the computer. When the computer is removed, the AI is disconnected or the account is gone, the program gets a 401,
61
+ - **Turning it off.** Run `npx -y owlmem wake disable` on that computer, or remove the computer in the console (AI agents → Agents, Paired computers). When the computer is removed, the AI is disconnected or the account is gone, the program gets a 401,
61
62
  removes its own autostart entry and exits. The command for each app is in `~/.config/owlmem/wake/wake.json`;
62
63
  logs and worktrees stay in that folder after uninstalling.
63
64
  - **Plan usage.** The waker also reports each app's plan usage to OwlMem. Cursor:自动报套餐用量。
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.24";
47
+ export const VERSION = "0.9.26";
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();
@@ -180,6 +180,8 @@ function token() {
180
180
  if (!t) throw new Fail("No token. Create one for this agent in the console (AI agents & tokens), then run: owlmem login");
181
181
  return t;
182
182
  }
183
+ // wake enable 用的 AI 令牌:环境变量没有就读 config.json(owlmem login 存的),都没有回 null,不抛错。
184
+ export function wakeAiToken() { return process.env.OWLMEM_TOKEN || cfg().token || null; }
183
185
  function spaceKey(space) {
184
186
  const p = join(DIR, "keys", space + ".key");
185
187
  if (!existsSync(p)) throw new Fail("This machine doesn't have the space key yet. Run: owlmem vault unlock");
@@ -813,7 +815,7 @@ function nextSteps(items, out) {
813
815
  // needs a person, it declines with what the person has to do. When a task the agent gave out is done or declined, it is
814
816
  // woken too, to read the result (OwlMem sends those only to 0.7.7 and later).
815
817
  // This computer is identified by its device key (device.json); the pairing is approved in the console, where each AI has an
816
- // auto-wake switch and the computer can be removed. If OwlMem answers 401 (computer removed, AI disconnected, account gone)
818
+ // auto-wake is on by default for computer AIs, and the computer can be removed. If OwlMem answers 401 (computer removed, AI disconnected, account gone)
817
819
  // the program removes its own autostart entry and exits.
818
820
  // The OwlMem tools an unattended wake run may call without asking: answer the task, read its inbox, and send (report the
819
821
  // result to its person, hand work on). 0.7.8 added kb_send (站长 10-28).
@@ -1714,12 +1716,12 @@ export function wakeRestart(o = {}) {
1714
1716
  }
1715
1717
 
1716
1718
  function wakeApi() {
1717
- return async (sub, body) => {
1719
+ return async (sub, body, extra) => {
1718
1720
  const url = BASE + "/v1/wake/" + sub;
1719
1721
  let r;
1720
1722
  try {
1721
1723
  const sh = await signHeaders("POST", url, "other");
1722
- r = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", "User-Agent": "owlmem-cli/" + VERSION, ...sh },
1724
+ r = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", "User-Agent": "owlmem-cli/" + VERSION, ...sh, ...(extra || {}) },
1723
1725
  body: JSON.stringify(body || {}), signal: AbortSignal.timeout(90000) });
1724
1726
  } catch (e) { return { status: 0, data: { detail: e.message } }; }
1725
1727
  return { status: r.status, data: await r.json().catch(() => ({})) };
@@ -2116,6 +2118,18 @@ export async function wakeNoClients(api, items = null) {
2116
2118
  return r.status === 200;
2117
2119
  }
2118
2120
 
2121
+ // #3936:已配对的电脑再配对,打出真实结果:绑上的列表 + 没对上的应用的补配链接(不再说去控制台拨开关,那个开关 0.82.0 就去掉了)。
2122
+ export function wakeActiveText(data) {
2123
+ const bound = (data.agents || []).map((x) => x.agent + " (" + x.client + ")").join(", ");
2124
+ let out = "Bound here: " + (bound || "nothing yet") + ". Auto-wake is on by default for these AIs; to turn it off, run: npx -y owlmem wake disable.";
2125
+ const un = data.unassigned || [];
2126
+ if (un.length && data.url) {
2127
+ out += "\nThese aren't assigned to an AI yet: " + un.join(", ") + ". Choose which AI each is:\n\n " + data.url +
2128
+ "\n\nCheck that the console shows this code: " + data.code;
2129
+ }
2130
+ return out;
2131
+ }
2132
+
2119
2133
  async function wakeEnable(args = []) {
2120
2134
  const boot = args.includes("--boot"), again = args.includes("--again");
2121
2135
  const num = (name, lo, hi) => { const i = args.indexOf(name); if (i < 0) return undefined; const n = Number(args[i + 1]); if (!Number.isInteger(n) || n < lo || n > hi) throw new Fail(`${name} takes a whole number from ${lo} to ${hi}.`); return n; };
@@ -2145,22 +2159,25 @@ async function wakeEnable(args = []) {
2145
2159
  if (h === true) say("Let Hermes report back to OwlMem when nobody is watching (entries under command_allowlist in ~/.hermes/config.yaml).");
2146
2160
  else if (h === "manual") say("Hermes treats OwlMem as untrusted: add mcp:<server>/kb_task_update, mcp:<server>/kb_inbox and mcp:<server>/kb_send to command_allowlist in ~/.hermes/config.yaml, or it can't report back when nobody is watching.");
2147
2161
  }
2148
- const cfg = { v: 1, ...WAKE_DEFAULTS, ...old, machine: process.env.OWLMEM_DEVICE_NAME || hostname(), clients, ...(max ? { max_parallel: max } : {}), ...(timeout ? { timeout_min: timeout } : {}), boot: boot || !!old.boot };
2162
+ const wakeCfg = { v: 1, ...WAKE_DEFAULTS, ...old, machine: process.env.OWLMEM_DEVICE_NAME || hostname(), clients, ...(max ? { max_parallel: max } : {}), ...(timeout ? { timeout_min: timeout } : {}), boot: boot || !!old.boot };
2149
2163
  // OwlMem knows these app names; a command you add yourself to wake.json goes under "gemini" or "custom"
2150
- const r = await wakeApi()("pair", { clients: Object.keys(clients).filter((c) => WAKE_APP_IDS.includes(c)), force: again });
2164
+ // 本机已登录(owlmem login 存了 AI 令牌)就带上:服务端自动批准配对,不用去控制台(令牌只放 Authorization 头,不写日志)
2165
+ const aiToken = wakeAiToken();
2166
+ const r = await wakeApi()("pair", { clients: Object.keys(clients).filter((c) => WAKE_APP_IDS.includes(c)), force: again },
2167
+ aiToken ? { Authorization: "Bearer " + aiToken } : undefined);
2151
2168
  if (r.status !== 200) throw new Fail("OwlMem didn't accept the pairing: " + (r.data.detail || r.data.error || "HTTP " + r.status));
2152
2169
  mkdirSync(wakeDir(), { recursive: true });
2153
2170
  copyFileSync(fileURLToPath(import.meta.url), join(wakeDir(), "owlmem.mjs")); // the service runs this copy (npx's cache can be cleaned out)
2154
- if (r.data.status === "pending") cfg.pair_url = r.data.url; else delete cfg.pair_url;
2155
- saveWake(DIR, cfg);
2156
- const a = installAutostart(autostartOpts(DIR, { boot: cfg.boot }));
2171
+ if (r.data.status === "pending") wakeCfg.pair_url = r.data.url; else delete wakeCfg.pair_url;
2172
+ saveWake(DIR, wakeCfg);
2173
+ const a = installAutostart(autostartOpts(DIR, { boot: wakeCfg.boot }));
2157
2174
  say("Auto-wake is installed (" + a.kind + ": " + tilde(a.file) + ").");
2158
- say("Apps it can start here: " + Object.keys(clients).map((c) => WAKE_CLIENTS[c]?.name || c).join(", ") + ". At most " + cfg.max_parallel + " at once, " + cfg.timeout_min + " minutes per task.");
2175
+ say("Apps it can start here: " + Object.keys(clients).map((c) => WAKE_CLIENTS[c]?.name || c).join(", ") + ". At most " + wakeCfg.max_parallel + " at once, " + wakeCfg.timeout_min + " minutes per task.");
2159
2176
  if (r.data.status === "pending") {
2160
2177
  say("\nApprove this computer in the OwlMem console and pick which AI each app is:\n\n " + r.data.url + "\n\nCheck that the console shows this code: " + r.data.code + "\nUntil then auto-wake waits and starts nothing." +
2161
2178
  "\n(If you're an AI agent running this: send the link and the code to the person who turned auto-wake on, with kb_send.)");
2162
2179
  openBrowser(r.data.url);
2163
- } else say("This computer is already paired (" + r.data.code + "). Turn auto-wake on or off for each AI in the console (AI agents → Agents).");
2180
+ } else say(wakeActiveText(r.data));
2164
2181
  }
2165
2182
 
2166
2183
  function wakeDisable(quiet = false) {
@@ -2176,20 +2193,25 @@ function wakeDisable(quiet = false) {
2176
2193
  });
2177
2194
  }
2178
2195
 
2196
+ // wake status 的「Apps:」那行(0.9.25):只报额度的应用没有 command,写「usage only」,不碰 command。
2197
+ export function wakeAppsLine(clients) {
2198
+ return Object.entries(clients || {}).map(([k, v]) => k + " → " + ((v?.quotaOnly || WAKE_CLIENTS[k]?.quotaOnly) ? "usage only" : (v?.command || []).join(" "))).join("; ");
2199
+ }
2200
+
2179
2201
  async function wakeStatus() {
2180
2202
  const cfg = loadWake(), a = autostart(autostartOpts());
2181
2203
  if (!cfg) { say("Auto-wake isn't set up on this computer. Turn it on: npx -y owlmem wake enable"); return; }
2182
2204
  say("Autostart: " + (existsSync(a.file) ? a.kind + " (" + tilde(a.file) + ")" : "missing"));
2183
- say("Apps: " + Object.entries(cfg.clients || {}).map(([k, v]) => k + " → " + v.command.join(" ")).join("; "));
2205
+ say("Apps: " + wakeAppsLine(cfg.clients || {}));
2184
2206
  say("At most " + cfg.max_parallel + " at once, " + cfg.timeout_min + " minutes per task. Log: " + tilde(join(wakeDir(), "wake.log")));
2185
2207
  const r = await wakeApi()("poll", { wait: 0, slots: 0 });
2186
2208
  if (r.status === 401) say("OwlMem: this computer isn't paired any more. Pair it again: npx -y owlmem wake enable --again");
2187
2209
  else if (r.status !== 200) say("OwlMem: can't reach it (" + (r.data.detail || "HTTP " + r.status) + ")");
2188
2210
  else if (r.data.status === "pending") say("OwlMem: waiting for approval in the console" + (cfg.pair_url ? ": " + cfg.pair_url : "") + " (code " + r.data.code + ")");
2189
- else say("OwlMem: paired as " + r.data.code + ". " + r.data.agents.map((x) => x.agent + " (" + x.client + (x.wake ? "" : ", switched off") + ")").join(", "));
2211
+ else say("OwlMem: paired as " + r.data.code + ". " + r.data.agents.map((x) => x.agent + " (" + x.client + ")").join(", "));
2190
2212
  }
2191
2213
 
2192
- const WAKE_HELP = `Usage: npx -y owlmem wake <enable|disable|status>
2214
+ export const WAKE_HELP = `Usage: npx -y owlmem wake <enable|disable|status>
2193
2215
 
2194
2216
  Auto-wake starts the AI on this computer when it gets an OwlMem task (Claude Code with \`claude -p\`, Codex with
2195
2217
  \`codex exec\`, Antigravity with \`agy -p\`, Hermes with \`hermes -z\`), without you opening it. It runs in the background from login, for this user only.
@@ -2201,7 +2223,7 @@ Auto-wake starts the AI on this computer when it gets an OwlMem task (Claude Cod
2201
2223
  disable remove it from this computer (also done by npx -y owlmem uninstall)
2202
2224
  status show what's set up and what OwlMem says
2203
2225
 
2204
- Turn it off for one AI with the switch in the console (AI agents → Agents). Settings, including the command for
2226
+ Settings, including the command for
2205
2227
  each app ("claude-code", "codex", or your own under "gemini" / "custom"): ~/.config/owlmem/wake/wake.json`;
2206
2228
 
2207
2229
  async function wakeCmd(sub, args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owlmem",
3
- "version": "0.9.24",
3
+ "version": "0.9.26",
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" },