owlmem 0.9.20 → 0.9.21
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 +14 -5
- 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.21";
|
|
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();
|
|
@@ -423,6 +423,16 @@ async function fetchItem(name, mode = "view") {
|
|
|
423
423
|
const it = await approved("GET", itemPath(name), undefined, "access", mode);
|
|
424
424
|
return open(raw, sp.space, name, it.nonce, it.ciphertext);
|
|
425
425
|
}
|
|
426
|
+
// 「名字:字段」:名字里也可能有冒号(11-14 起名称不限字符)。带冒号时先查条目清单(不用审批):整串就是一条的名字就整串取,
|
|
427
|
+
// 否则按最后一个冒号拆成「名字 + 字段」。不先去试拆出来的名字——那会用错的名字发审批请求(antigravity 审查 #1600)
|
|
428
|
+
async function fetchRef(ref, mode) {
|
|
429
|
+
ref = String(ref); const i = ref.lastIndexOf(":");
|
|
430
|
+
if (i > 0 && i < ref.length - 1) {
|
|
431
|
+
const r = await call("GET", "items"); if (r.status >= 400) throw new Fail(r.data.detail || r.data.error);
|
|
432
|
+
if (!(r.data.items || []).some((it) => it.name === ref)) return pick(await fetchItem(ref.slice(0, i), mode), ref.slice(i + 1));
|
|
433
|
+
}
|
|
434
|
+
return pick(await fetchItem(ref, mode));
|
|
435
|
+
}
|
|
426
436
|
function pick(body, field) {
|
|
427
437
|
if (!field) return body.type === "env" || body.type === "secret" ? String(body.value ?? "") : JSON.stringify(body, null, 2);
|
|
428
438
|
const v = body[field] ?? body.fields?.[field];
|
|
@@ -463,8 +473,7 @@ async function mcpCall(name, a) {
|
|
|
463
473
|
const env = { ...process.env }, secrets = [];
|
|
464
474
|
for (const [k, ref] of Object.entries(a.env || {})) {
|
|
465
475
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) throw new Fail("Bad variable name " + k);
|
|
466
|
-
const
|
|
467
|
-
const v = pick(await fetchItem(item, "run"), field); env[k] = v; if (v && v.length >= 4) secrets.push(v);
|
|
476
|
+
const v = await fetchRef(ref, "run"); env[k] = v; if (v && v.length >= 4) secrets.push(v);
|
|
468
477
|
}
|
|
469
478
|
const mask = (t) => secrets.sort((x, y) => y.length - x.length).reduce((acc, v) => acc.split(v).join("****"), t);
|
|
470
479
|
const out = await new Promise((res) => {
|
|
@@ -1974,9 +1983,9 @@ export async function main(argv) {
|
|
|
1974
1983
|
const opts = argv.slice(1, dash), command = argv.slice(dash + 1), env = { ...process.env };
|
|
1975
1984
|
for (let i = 0; i < opts.length; i++) {
|
|
1976
1985
|
if (opts[i] !== "--env") throw new Fail("Unknown option " + opts[i]);
|
|
1977
|
-
const m = /^([A-Za-z_][A-Za-z0-9_]*)=(
|
|
1986
|
+
const m = /^([A-Za-z_][A-Za-z0-9_]*)=(.+)$/.exec(opts[++i] || "");
|
|
1978
1987
|
if (!m) throw new Fail("Use --env VAR=item or --env VAR=item:field");
|
|
1979
|
-
env[m[1]] =
|
|
1988
|
+
env[m[1]] = await fetchRef(m[2], "run");
|
|
1980
1989
|
}
|
|
1981
1990
|
const child = spawn(command[0], command.slice(1), { stdio: "inherit", env });
|
|
1982
1991
|
await new Promise((res) => child.on("exit", (code, sig) => { process.exitCode = sig ? 1 : code; res(); }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "owlmem",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.21",
|
|
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" },
|