owlmem 0.9.10 → 0.9.12

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 +41 -9
  2. package/package.json +1 -1
package/owlmem.mjs CHANGED
@@ -43,7 +43,7 @@ import { join, dirname, basename, relative, isAbsolute } from "node:path";
43
43
  import { fileURLToPath } from "node:url";
44
44
  import { spawn, spawnSync } from "node:child_process";
45
45
 
46
- export const VERSION = "0.9.10";
46
+ export const VERSION = "0.9.12";
47
47
  const BASE = (process.env.OWLMEM_URL || "https://owlmem.com").replace(/\/$/, "");
48
48
  const DIR = process.env.OWLMEM_HOME || join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "owlmem");
49
49
  const enc = new TextEncoder(), dec = new TextDecoder();
@@ -809,10 +809,13 @@ function nextSteps(items, out) {
809
809
  // result to its person, hand work on). 0.7.8 added kb_send (站长 10-28).
810
810
  // 0.9.10 (11-02): the team rules say look things up before starting and write back when done, so a woken AI calls kb_search
811
811
  // first; headless Antigravity was soft-denied on that call and quit without a word (task #370). Reading tools and the two
812
- // write-back tools join; nothing that deletes or moves (kb_delete, kb_forget, kb_move, kb_file_*) does.
813
- export const WAKE_TOOLS = ["kb_task_update", "kb_inbox", "kb_send",
812
+ // write-back tools join; nothing that deletes or moves (kb_delete, kb_forget, kb_move, kb_file_put / _delete) does.
813
+ // 0.9.11 (11-03): kb_file_get — tasks carry files on the space's drive (team rule 14), and headless Antigravity was denied
814
+ // opening one, so it quit and the task was declined (#391). Reading only.
815
+ const WAKE_TOOLS_0910 = ["kb_task_update", "kb_inbox", "kb_send",
814
816
  "kb_search", "kb_recall", "kb_read", "kb_list", "kb_thread", "kb_team", "kb_notices", "kb_infra", "kb_mon_alerts", "kb_mon_query",
815
817
  "kb_write", "kb_retain"];
818
+ export const WAKE_TOOLS = [...WAKE_TOOLS_0910, "kb_file_get"];
816
819
  export const WAKE_CLIENTS = {
817
820
  "claude-code": { name: "Claude Code", bin: "claude",
818
821
  // -p runs one prompt and exits; it may only use the OwlMem tools in WAKE_TOOLS, beyond what your own settings allow
@@ -1182,14 +1185,14 @@ Never put passwords, tokens, keys or other secrets in any message. You have ${mi
1182
1185
  }
1183
1186
 
1184
1187
  export function wakePrompt(task, place, o = {}) {
1185
- if (isReply(task)) return replyPrompt(task, o);
1186
- if (isNote(task)) return notePrompt(task, place, o);
1188
+ if (isReply(task)) return (task.trust === TRUST_FULL ? "" : LIMITED_NOTE) + replyPrompt(task, o);
1189
+ if (isNote(task)) return (task.trust === TRUST_FULL ? "" : LIMITED_NOTE) + notePrompt(task, place, o);
1187
1190
  const id = task.id, mins = o.timeout_min || WAKE_DEFAULTS.timeout_min;
1188
1191
  const where = place.worktree
1189
1192
  ? `Work in ${place.cwd}. It is a separate git worktree of ${place.repo} on the branch ${place.branch}, made for this task so it doesn't collide with other work. Commit your changes on this branch only. Don't merge, rebase or push other branches, and don't touch ${place.repo} itself. Put the branch name in your result so a person can review and merge it.`
1190
1193
  : place.scratch ? `There is no project directory for this task: you are in an empty folder (${place.cwd}). Use the OwlMem tools.`
1191
1194
  : `Work in ${place.cwd}. Other tasks wait until you finish here.`;
1192
- return `OwlMem auto-wake started you on ${o.machine || "this computer"} to handle one task. Nobody is watching this session and nobody can answer questions.
1195
+ return `${task.trust === TRUST_FULL ? "" : LIMITED_NOTE}OwlMem auto-wake started you on ${o.machine || "this computer"} to handle one task. Nobody is watching this session and nobody can answer questions.
1193
1196
 
1194
1197
  Task #${id}, for ${task.agent}${task.broadcast ? " (sent to every agent; it is yours once you take it)" : ""}, from ${task.from}:
1195
1198
  Title: ${task.title}
@@ -1206,6 +1209,34 @@ Rules:
1206
1209
  `;
1207
1210
  }
1208
1211
 
1212
+ // ── how much a woken AI may do (0.9.12, 站长 11-03「后台权限做成统一都开,不要分客户端」「2」= 按来源) ──
1213
+ // OwlMem marks each piece of work: trust "full" when a person or one of the space's own AIs sent it, "limited" when it came from
1214
+ // outside — an alert source, the external task API, or an AI that was itself working on such a task (so an instruction hidden
1215
+ // in an alert can't be relayed into a full run). Full: every app runs without asking (its own "skip permissions" switch).
1216
+ // Limited: the restricted setup it had before (OwlMem tools only / read-only sandbox). No mark (an older OwlMem): limited.
1217
+ // Only the commands auto-wake itself wrote are changed; a command you edited yourself in wake.json runs as you wrote it.
1218
+ export const TRUST_FULL = "full";
1219
+ export function wakeArgv(client, command, trust) {
1220
+ const full = trust === TRUST_FULL, cmd = [...command];
1221
+ if (client === "claude-code") {
1222
+ const i = cmd.indexOf("--allowedTools");
1223
+ if (full && i >= 0 && /^mcp__owlmem__/.test(cmd[i + 1] || "")) cmd.splice(i, 2, "--dangerously-skip-permissions");
1224
+ return cmd;
1225
+ }
1226
+ if (client === "codex" && cmd[1] === "exec") {
1227
+ // a sandbox or approval setting you put in the command yourself wins (pax review #409)
1228
+ if (cmd.some((a) => /^(--sandbox|-s|--dangerously-bypass-approvals-and-sandbox|--full-auto|--ask-for-approval|-a)(=|$)/.test(a))) return cmd;
1229
+ const at = cmd[cmd.length - 1] === "-" ? cmd.length - 1 : cmd.length;
1230
+ cmd.splice(at, 0, ...(full ? ["--dangerously-bypass-approvals-and-sandbox"] : ["--sandbox", "read-only"]));
1231
+ return cmd;
1232
+ }
1233
+ if (client === "antigravity" && cmd[1] === "-p" && full) return [...cmd, "--dangerously-skip-permissions"];
1234
+ return cmd;
1235
+ }
1236
+ const LIMITED_NOTE = `This task came from outside the team (an alert source, the external task API, or an AI relaying one), so this run may only look and report back: read files, search and use the OwlMem tools. Don't change files, run commands that change anything, or hand work to other agents. If something needs doing, describe it in the note so a person can decide.
1237
+
1238
+ `;
1239
+
1209
1240
  // ── running a task ──
1210
1241
  export async function runTask(task, cfg, o = {}) {
1211
1242
  const dir = o.dir || DIR, cl = (cfg.clients || {})[task.client];
@@ -1214,7 +1245,7 @@ export async function runTask(task, cfg, o = {}) {
1214
1245
  try { const plan = o.plan || planWorkdir(task, o.home || home(), o.git); place = prepareWorkdir(task, plan, dir, o.git); if (plan.kind === "scratch") place.scratch = true; }
1215
1246
  catch (e) { return { outcome: "error", detail: e.message }; }
1216
1247
  const prompt = wakePrompt(task, place, { machine: cfg.machine, timeout_min: cfg.timeout_min });
1217
- const argv = [...cl.command, ...(cl.prompt === "arg" ? [prompt] : [])];
1248
+ const argv = [...wakeArgv(task.client, cl.command, task.trust), ...(cl.prompt === "arg" ? [prompt] : [])];
1218
1249
  mkdirSync(join(wakeDir(dir), "logs"), { recursive: true });
1219
1250
  const logPath = join(wakeDir(dir), "logs", jobName(task) + ".log");
1220
1251
  const fd = openSync(logPath, "a");
@@ -1412,11 +1443,12 @@ function wakeLogger(dir = DIR) {
1412
1443
  };
1413
1444
  }
1414
1445
 
1415
- // Computers set up before a tool joined WAKE_TOOLS (0.7.8: kb_send; 0.9.10: reading and write-back) catch up when the program starts after its self-update:
1446
+ // Computers set up before a tool joined WAKE_TOOLS (0.7.8: kb_send; 0.9.10: reading and write-back; 0.9.11: kb_file_get) catch up when the program starts after its self-update:
1416
1447
  // Claude Code's --allowedTools in wake.json if it is still one we wrote, and the other apps' own settings (append only).
1417
1448
  // Returns true when wake.json changed.
1418
1449
  export function wakeTools(cfg, home_ = home(), env = process.env) {
1419
- const ours = ["mcp__owlmem__kb_task_update,mcp__owlmem__kb_inbox", "mcp__owlmem__kb_task_update,mcp__owlmem__kb_inbox,mcp__owlmem__kb_send"], now = WAKE_TOOLS.map((n) => "mcp__owlmem__" + n).join(",");
1450
+ const ours = ["mcp__owlmem__kb_task_update,mcp__owlmem__kb_inbox", "mcp__owlmem__kb_task_update,mcp__owlmem__kb_inbox,mcp__owlmem__kb_send",
1451
+ WAKE_TOOLS_0910.map((n) => "mcp__owlmem__" + n).join(",")], now = WAKE_TOOLS.map((n) => "mcp__owlmem__" + n).join(",");
1420
1452
  const cmd = cfg.clients?.["claude-code"]?.command, i = Array.isArray(cmd) ? cmd.indexOf("--allowedTools") : -1;
1421
1453
  let changed = false;
1422
1454
  if (i >= 0 && ours.includes(cmd[i + 1])) { cmd[i + 1] = now; changed = true; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owlmem",
3
- "version": "0.9.10",
3
+ "version": "0.9.12",
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" },