owlmem 0.9.11 → 0.9.13
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 +47 -7
- 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.
|
|
46
|
+
export const VERSION = "0.9.13";
|
|
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();
|
|
@@ -830,8 +830,12 @@ export const WAKE_CLIENTS = {
|
|
|
830
830
|
// DeepSeek Harness: the headless profile answers one task (from stdin) and exits. Its own profile needs OwlMem and a model,
|
|
831
831
|
// copied from the web profile (see allowDsh). On NixOS dsh must run on the official Node build: use the dsh wrapper found here.
|
|
832
832
|
dsh: { name: "DeepSeek Harness", bin: "dsh", command: ["dsh", "--profile", "headless"], prompt: "stdin", home: [[".local", "bin", "dsh"]] },
|
|
833
|
+
// opencode run answers one prompt (an argument) and exits (0.9.13, 站长 11-03「加」). It reads stdin until it ends, so runTask
|
|
834
|
+
// closes stdin. Full: --auto; limited: file edits, shell and web fetches denied through OPENCODE_CONFIG_CONTENT (wakeEnv).
|
|
835
|
+
// Tested 11-03 against a local OwlMem with opencode 1.19.5: full did the task; limited refused a shell command and declined.
|
|
836
|
+
opencode: { name: "opencode", bin: "opencode", command: ["opencode", "run"], prompt: "arg", home: [[".opencode", "bin", "opencode"]] },
|
|
833
837
|
};
|
|
834
|
-
export const WAKE_APP_IDS = ["claude-code", "codex", "antigravity", "hermes", "dsh", "gemini", "custom"];
|
|
838
|
+
export const WAKE_APP_IDS = ["claude-code", "codex", "antigravity", "hermes", "dsh", "opencode", "gemini", "custom"];
|
|
835
839
|
// Where an app's command is: on PATH, or the first of its default install places that exists (path parts under your home
|
|
836
840
|
// folder, or an absolute path), used by full path
|
|
837
841
|
export function wakeBin(c, home_ = home(), exists = existsSync, path = onPath) {
|
|
@@ -1185,14 +1189,14 @@ Never put passwords, tokens, keys or other secrets in any message. You have ${mi
|
|
|
1185
1189
|
}
|
|
1186
1190
|
|
|
1187
1191
|
export function wakePrompt(task, place, o = {}) {
|
|
1188
|
-
if (isReply(task)) return replyPrompt(task, o);
|
|
1189
|
-
if (isNote(task)) return notePrompt(task, place, o);
|
|
1192
|
+
if (isReply(task)) return (task.trust === TRUST_FULL ? "" : LIMITED_NOTE) + replyPrompt(task, o);
|
|
1193
|
+
if (isNote(task)) return (task.trust === TRUST_FULL ? "" : LIMITED_NOTE) + notePrompt(task, place, o);
|
|
1190
1194
|
const id = task.id, mins = o.timeout_min || WAKE_DEFAULTS.timeout_min;
|
|
1191
1195
|
const where = place.worktree
|
|
1192
1196
|
? `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.`
|
|
1193
1197
|
: place.scratch ? `There is no project directory for this task: you are in an empty folder (${place.cwd}). Use the OwlMem tools.`
|
|
1194
1198
|
: `Work in ${place.cwd}. Other tasks wait until you finish here.`;
|
|
1195
|
-
return
|
|
1199
|
+
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.
|
|
1196
1200
|
|
|
1197
1201
|
Task #${id}, for ${task.agent}${task.broadcast ? " (sent to every agent; it is yours once you take it)" : ""}, from ${task.from}:
|
|
1198
1202
|
Title: ${task.title}
|
|
@@ -1209,6 +1213,42 @@ Rules:
|
|
|
1209
1213
|
`;
|
|
1210
1214
|
}
|
|
1211
1215
|
|
|
1216
|
+
// ── how much a woken AI may do (0.9.12, 站长 11-03「后台权限做成统一都开,不要分客户端」「2」= 按来源) ──
|
|
1217
|
+
// 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
|
|
1218
|
+
// outside — an alert source, the external task API, or an AI that was itself working on such a task (so an instruction hidden
|
|
1219
|
+
// in an alert can't be relayed into a full run). Full: every app runs without asking (its own "skip permissions" switch).
|
|
1220
|
+
// Limited: the restricted setup it had before (OwlMem tools only / read-only sandbox). No mark (an older OwlMem): limited.
|
|
1221
|
+
// Only the commands auto-wake itself wrote are changed; a command you edited yourself in wake.json runs as you wrote it.
|
|
1222
|
+
export const TRUST_FULL = "full";
|
|
1223
|
+
export function wakeArgv(client, command, trust) {
|
|
1224
|
+
const full = trust === TRUST_FULL, cmd = [...command];
|
|
1225
|
+
if (client === "claude-code") {
|
|
1226
|
+
const i = cmd.indexOf("--allowedTools");
|
|
1227
|
+
if (full && i >= 0 && /^mcp__owlmem__/.test(cmd[i + 1] || "")) cmd.splice(i, 2, "--dangerously-skip-permissions");
|
|
1228
|
+
return cmd;
|
|
1229
|
+
}
|
|
1230
|
+
if (client === "codex" && cmd[1] === "exec") {
|
|
1231
|
+
// a sandbox or approval setting you put in the command yourself wins (pax review #409)
|
|
1232
|
+
if (cmd.some((a) => /^(--sandbox|-s|--dangerously-bypass-approvals-and-sandbox|--full-auto|--ask-for-approval|-a)(=|$)/.test(a))) return cmd;
|
|
1233
|
+
const at = cmd[cmd.length - 1] === "-" ? cmd.length - 1 : cmd.length;
|
|
1234
|
+
cmd.splice(at, 0, ...(full ? ["--dangerously-bypass-approvals-and-sandbox"] : ["--sandbox", "read-only"]));
|
|
1235
|
+
return cmd;
|
|
1236
|
+
}
|
|
1237
|
+
if (client === "antigravity" && cmd[1] === "-p" && full) return [...cmd, "--dangerously-skip-permissions"];
|
|
1238
|
+
if (client === "opencode" && cmd[1] === "run" && full && !cmd.includes("--auto")) return [...cmd, "--auto"];
|
|
1239
|
+
return cmd;
|
|
1240
|
+
}
|
|
1241
|
+
// Settings an app takes from the environment for one run. opencode, limited: no file edits, no shell, no web (its own
|
|
1242
|
+
// permission keys); the OwlMem tools stay allowed, so it can still read and report.
|
|
1243
|
+
export function wakeEnv(client, command, trust) {
|
|
1244
|
+
if (client === "opencode" && command[1] === "run" && trust !== TRUST_FULL)
|
|
1245
|
+
return { OPENCODE_CONFIG_CONTENT: JSON.stringify({ permission: { edit: "deny", bash: "deny", webfetch: "deny" } }) };
|
|
1246
|
+
return {};
|
|
1247
|
+
}
|
|
1248
|
+
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.
|
|
1249
|
+
|
|
1250
|
+
`;
|
|
1251
|
+
|
|
1212
1252
|
// ── running a task ──
|
|
1213
1253
|
export async function runTask(task, cfg, o = {}) {
|
|
1214
1254
|
const dir = o.dir || DIR, cl = (cfg.clients || {})[task.client];
|
|
@@ -1217,7 +1257,7 @@ export async function runTask(task, cfg, o = {}) {
|
|
|
1217
1257
|
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; }
|
|
1218
1258
|
catch (e) { return { outcome: "error", detail: e.message }; }
|
|
1219
1259
|
const prompt = wakePrompt(task, place, { machine: cfg.machine, timeout_min: cfg.timeout_min });
|
|
1220
|
-
const argv = [...cl.command, ...(cl.prompt === "arg" ? [prompt] : [])];
|
|
1260
|
+
const argv = [...wakeArgv(task.client, cl.command, task.trust), ...(cl.prompt === "arg" ? [prompt] : [])];
|
|
1221
1261
|
mkdirSync(join(wakeDir(dir), "logs"), { recursive: true });
|
|
1222
1262
|
const logPath = join(wakeDir(dir), "logs", jobName(task) + ".log");
|
|
1223
1263
|
const fd = openSync(logPath, "a");
|
|
@@ -1228,7 +1268,7 @@ export async function runTask(task, cfg, o = {}) {
|
|
|
1228
1268
|
let ch, timedOut = false, killer = null;
|
|
1229
1269
|
try {
|
|
1230
1270
|
ch = spawn(argv[0], argv.slice(1), { cwd: place.cwd, stdio: ["pipe", fd, fd], detached: !win, shell: win, windowsHide: true,
|
|
1231
|
-
env: { ...Object.fromEntries(Object.entries(process.env).filter(([k]) => !k.startsWith("OWLMEM_WAKE_"))), OWLMEM_NO_BROWSER: "1", [isReply(task) ? "OWLMEM_WAKE_REPLY" : isNote(task) ? "OWLMEM_WAKE_NOTE" : "OWLMEM_WAKE_TASK"]: String(task.id) } });
|
|
1271
|
+
env: { ...Object.fromEntries(Object.entries(process.env).filter(([k]) => !k.startsWith("OWLMEM_WAKE_"))), ...wakeEnv(task.client, cl.command, task.trust), OWLMEM_NO_BROWSER: "1", [isReply(task) ? "OWLMEM_WAKE_REPLY" : isNote(task) ? "OWLMEM_WAKE_NOTE" : "OWLMEM_WAKE_TASK"]: String(task.id) } });
|
|
1232
1272
|
} catch (e) { res({ outcome: "error", detail: "couldn't start " + argv[0] + ": " + e.message }); return; }
|
|
1233
1273
|
const kill = (sig) => { try { if (win) spawnSync("taskkill", ["/T", "/F", "/PID", String(ch.pid)]); else process.kill(-ch.pid, sig); } catch { try { ch.kill(sig); } catch {} } };
|
|
1234
1274
|
const timer = setTimeout(() => { timedOut = true; kill("SIGTERM"); killer = setTimeout(() => kill("SIGKILL"), 10000); }, ms);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owlmem",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.13",
|
|
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" },
|