From debc0f7b531c79a7c13fa74d53e928b4d31d8740 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 2 Nov 2026 02:38:06 +0800 Subject: [PATCH] nowledge-mem 0.1.4: a tailnet HTTP server from the page, and recallRemote/captureRemote opt-ins (#608) pluoki (on X) runs Mem on a Mac Studio reached over Tailscale. Two limits: - page/settings.js validUrl() refused any http: URL to a non-loopback host whatever allowInsecureHttp said, while mem.mjs honoured it, so http://mac-studio.tailnet.ts.net:14242 could only be set by hand in Options JSON and the page's Save and Test refused it. The dialog now has an "Allow HTTP to another machine" switch (Mem service section, same switch-field component as the others; help text: only on a network you trust, e.g. Tailscale) that reads and writes allowInsecureHttp, and validUrl follows it exactly as mem.mjs does; Test checks the saved option. Turning it off removes the option. All five languages (en, zh, zh-TW, ja, de) get the new strings; urlHelp and invalidUrl name the switch. - The hook took only origin local / magpie-key. recallRemote and captureRemote (default false, typed booleans, in package.json's options and the README) let remote and gateway-key requests in, each on its own, as powercontext's do: captureRemote saves the conversation but recalls nothing, and neither turns capture on. Unlike powercontext's, a missing or unknown origin stays out even with both on. powercontext's page has no switches for these, so this page doesn't either; its "What is sent" text names the options. Sticky blocks were already keyed by origin. Run (mote, at this tree on origin/main 53e3820): - HOME=$(mktemp -d) bun test: 4557 pass, 0 fail, 9 skip (live checks). - bun scripts/check.mjs: ok. - The page in Playwright 1.62 chromium and webkit, served over local HTTP with a stub bridge, in en/zh/zh-TW/ja/de: the tailnet URL is refused with the switch off and saved with allowInsecureHttp: true with it on; screenshots checked (en webkit, de chromium). - Broken by hand, each red then green: validUrl ignoring the option, and the page never writing it (tailnet page test red); captureRemote granting recall, the old local-only line, unknown origins counted as remote (new origin test red); both opt-ins on by default (new test plus "remote and unknown origins stay out" and the gateway-key test red). Not tried: a real Mem over a real tailnet, or in the real magpie app; the hook is driven as magpie's host calls it, and the page through its test and the Playwright stub. --- packages/nowledge-mem/README.md | 24 +++- packages/nowledge-mem/mem.mjs | 4 +- packages/nowledge-mem/nowledge-mem.hooks.mjs | 14 ++- packages/nowledge-mem/nowledge-mem.test.mjs | 114 +++++++++++++++++++ packages/nowledge-mem/package.json | 4 +- packages/nowledge-mem/page/i18n.js | 40 ++++--- packages/nowledge-mem/page/settings.html | 5 +- packages/nowledge-mem/page/settings.js | 13 ++- 8 files changed, 186 insertions(+), 32 deletions(-) diff --git a/packages/nowledge-mem/README.md b/packages/nowledge-mem/README.md index f5565af..78241b6 100644 --- a/packages/nowledge-mem/README.md +++ b/packages/nowledge-mem/README.md @@ -77,7 +77,10 @@ advanced settings. Saving conversations remains a separate opt-in. `serverUrl` must be HTTPS, or HTTP only for `localhost`, `127.0.0.1` and `[::1]`. Credentials, a query or a fragment in the URL are refused. Set -`allowInsecureHttp` only for a trusted LAN server. +`allowInsecureHttp` (the page's **Allow HTTP to another machine** switch) only +on a network you trust, such as a Tailscale tailnet, whose link is already +encrypted: then `http://mac-studio.tailnet.ts.net:14242` or +`http://100.x.y.z:14242` is accepted by the page and the hook alike. ## One gateway, several harnesses @@ -150,7 +153,17 @@ derived value for all of them. the protocol role does not establish authorship. It does not infer native Side Chat boundaries. Configure both options in Plugins → Options. - `allowInsecureHttp`: default **false**. Permits plain HTTP to a server that - is not a loopback address. Prefer HTTPS. + is not a loopback address, for a network you trust such as Tailscale. Prefer + HTTPS elsewhere. The page has a switch for it. +- `recallRemote`: default **false**. Recall and the Context Bundle go only to + direct local requests and `magpie-key` from this computer. Set it to give + recall also to `remote` requests (another machine) and `gateway-key` + requests (other gateway keys), which then receive what Mem recalls. It does + not turn on saving. A missing or unknown origin never gets recall. +- `captureRemote`: default **false**. With `capture` on, also save + conversations from `remote` and `gateway-key` requests. It does not grant + recall: without `recallRemote` those requests are saved but get nothing from + Mem. Set these two in Plugins → Options; the page does not show them. - `port`: the loopback port of the page's connection test, default 3479. Change it only when another program holds that port; the page reads the same value. @@ -267,10 +280,11 @@ own: the offline tests replace `globalThis.fetch` to keep Cursor's token local The page uses only Magpie's released `magpie.options` and theme bridge. It declares no reads and saving stores configuration without probing the connection or writing Memory. It shows the Server, API key, Space, Agent, the -apps without memory (`skipAgents`), and the recall, Context Bundle and capture -switches. Its **What is sent** section says +apps without memory (`skipAgents`), the recall, Context Bundle and capture +switches, and **Allow HTTP to another machine** (`allowInsecureHttp`). Its **What is sent** section says the scope: direct local requests and `magpie-key` from this computer; other -gateway keys and remote requests are never included. It follows Magpie's language (English, Simplified and +gateway keys and remote requests are included only through `recallRemote` and +`captureRemote`. It follows Magpie's language (English, Simplified and Traditional Chinese, Japanese, German) and theme, and preserves options it does not show. diff --git a/packages/nowledge-mem/mem.mjs b/packages/nowledge-mem/mem.mjs index 3ab2bb0..d6937a3 100644 --- a/packages/nowledge-mem/mem.mjs +++ b/packages/nowledge-mem/mem.mjs @@ -6,7 +6,7 @@ import { createHash } from "node:crypto"; // Bumped with package.json: Mem's own clients record it on imported Threads. -export const version = "0.1.3"; +export const version = "0.1.4"; // The only report codes magpie's Plugins page shows; tools turn these into // messages, never the service's own text. @@ -102,6 +102,8 @@ export function resolveOptions(raw = {}, env = process.env) { recall: bool("recall", true), contextBundle: bool("contextBundle", true), capture: bool("capture", false), + recallRemote: bool("recallRemote", false), + captureRemote: bool("captureRemote", false), captureTools: bool("captureTools", true), captureFilter, captureCindy: bool("captureCindy", false), diff --git a/packages/nowledge-mem/nowledge-mem.hooks.mjs b/packages/nowledge-mem/nowledge-mem.hooks.mjs index 04af412..68e52c8 100644 --- a/packages/nowledge-mem/nowledge-mem.hooks.mjs +++ b/packages/nowledge-mem/nowledge-mem.hooks.mjs @@ -14,7 +14,8 @@ // "contextBundle": true, "maxMemories": 5, "maxBytes": 6000, // "requestTimeoutMs": 900, "recallBackoffMs": 30000, "capture": false, // "captureTools": true, "captureFilter": "off", "captureCindy": false, -// "allowInsecureHttp": false, "skipAgents": []} +// "allowInsecureHttp": false, "recallRemote": false, "captureRemote": false, +// "skipAgents": []} // // A turn keeps the block it was given for the rest of the conversation, so what // the agent sends stays the same from one request to the next and the @@ -67,9 +68,14 @@ async function run(body, ctx) { const o = resolveOptions(ctx.options); // An app the user listed in skipAgents (a translator, say) gets neither // recall nor capture: its requests go as they came, and Mem hears nothing. - const own = (ctx.origin === "local" || ctx.origin === "magpie-key") && !o.skipAgents.has(agentKey(ctx.agent)); - const recall = o.recall && own; - const capture = o.capture && own; + const listed = o.skipAgents.has(agentKey(ctx.agent)); + const own = ctx.origin === "local" || ctx.origin === "magpie-key"; + // Another machine, or a gateway key other than this computer's own, gets + // in only by the user's opt-in, one for each: permission to capture does + // not grant recall of what Mem holds. A missing or unknown origin never does. + const other = ctx.origin === "remote" || ctx.origin === "gateway-key"; + const recall = o.recall && !listed && (own || (other && o.recallRemote)); + const capture = o.capture && !listed && (own || (other && o.captureRemote)); if (!recall && !capture) { ctx.report?.("skipped"); return; diff --git a/packages/nowledge-mem/nowledge-mem.test.mjs b/packages/nowledge-mem/nowledge-mem.test.mjs index b9d13f9..231de96 100644 --- a/packages/nowledge-mem/nowledge-mem.test.mjs +++ b/packages/nowledge-mem/nowledge-mem.test.mjs @@ -314,6 +314,8 @@ test("options it can't use are invalid, before anything is sent", async () => { { serverUrl: "http://127.0.0.1:14242", requestTimeoutMs: 10_000 }, { serverUrl: "http://127.0.0.1:14242", recallBackoffMs: 10 }, { serverUrl: "http://127.0.0.1:14242", capture: "yes" }, + { serverUrl: "http://127.0.0.1:14242", recallRemote: "yes" }, + { serverUrl: "http://127.0.0.1:14242", captureRemote: 1 }, { serverUrl: "http://127.0.0.1:14242", skipAgents: 5 }, { serverUrl: "http://127.0.0.1:14242", skipAgents: ["Mozilla", 1] }, { serverUrl: "http://127.0.0.1:14242", apiKey: "bad key" }, @@ -708,6 +710,46 @@ test("a canceled request keeps its reason and does not back off the service", as }) // The official sandbox page may configure options, but has no network or custom host API. +test("remote and gateway-key requests get recall and capture only by their own opt-in (#608)", async () => { + for (const origin of ["remote", "gateway-key"]) { + for (const [recallRemote, captureRemote] of [[false, false], [true, false], [false, true], [true, true]]) { + mock() + calls.length = 0 + const [reports, context] = capturing("chat", { origin, options: { recallRemote, captureRemote } }) + const body = structuredClone(chat) + const out = await onRequest(body, context) + await onResponse(reply, { ...context, success: true }) + expect(of("memories/search")).toHaveLength(recallRemote ? 1 : 0) + expect(of("threads/import")).toHaveLength(captureRemote ? 1 : 0) + // capture permission alone saves the conversation but recalls nothing + if (!recallRemote) { + expect(out).toBeUndefined() + expect(body).toEqual(chat) + expect(reports[0]).toEqual(["skipped"]) + } else expect(JSON.stringify(out)).toContain("QUARTZ-8413") + reset() + } + // captureRemote does not turn capture on + mock() + calls.length = 0 + const [, off] = capturing("chat", { origin, options: { capture: false, captureRemote: true } }) + await onRequest(structuredClone(chat), off) + await onResponse(reply, { ...off, success: true }) + expect(calls).toHaveLength(0) + reset() + } + // a missing or unknown origin stays out even with both opt-ins + for (const origin of [undefined, "unrecognized"]) { + mock() + calls.length = 0 + const [, context] = capturing("chat", { origin, options: { recallRemote: true, captureRemote: true } }) + await onRequest(structuredClone(chat), context) + await onResponse(reply, { ...context, success: true }) + expect(calls).toHaveLength(0) + reset() + } +}) + test("configuration page uses only the released options and theme bridge", async () => { const source = await Bun.file(new URL("./page/settings.js", import.meta.url)).text() const calls = [...source.matchAll(/magpie\.([\w.]+)/g)].map((match) => match[1]) @@ -815,6 +857,78 @@ test("configuration page saves the Mem connection for the shipped hook", async ( expect(elements["summary-space"].textContent).toBe("Default Space") }) +test("configuration page takes a tailnet HTTP server only with Allow HTTP to another machine (#608)", async () => { + const read = (file) => Bun.file(new URL(`./page/${file}`, import.meta.url)).text() + const [dictionary, source, html] = await Promise.all([read("i18n.js"), read("settings.js"), read("settings.html")]) + const elements = Object.fromEntries([...html.matchAll(/\bid="([^"]+)"/g)].map(([, id]) => [id, { + dataset: {}, value: "", type: id === "key" ? "password" : "text", checked: false, + setAttribute(name, value) { this[name] = value }, focus() {}, showModal() {}, close() {}, + }])) + expect(elements["insecure-http"]).toBeDefined() + const document = { documentElement: {}, getElementById: (id) => elements[id], querySelectorAll: () => [] } + const location = { href: "http://127.0.0.1:3425/_magpie/plugin/t/page/settings.html", assign(url) { this.assigned = url } } + let options = { serverUrl: "http://mac-studio.tailnet.ts.net:14242", recall: true, maxBytes: 6000 } + let writes = 0 + const magpie = { + theme: { lang: "en" }, ready: Promise.resolve(), onTheme() {}, + options: { get: async () => ({ ...options }), set: async (next) => { options = { ...next }; writes++ } }, + } + runInNewContext(`${dictionary}\n${source}`, { document, magpie, window: { name: "" }, location, navigator: { language: "en" }, URL }) + await new Promise(setImmediate) + const save = () => elements.save.onclick({ preventDefault() {} }) + + // without the option, a saved tailnet HTTP URL can't be tested or saved + expect(elements["insecure-http"].checked).toBe(false) + elements["test-saved"].onclick() + expect(location.assigned).toBeUndefined() + expect(elements.configured.dataset.message).toBe("invalidUrl") + for (const url of ["http://mac-studio.tailnet.ts.net:14242", "http://100.101.102.103:14242"]) { + elements.url.value = url + await save() + expect(writes).toBe(0) + expect(elements.result.dataset.message).toBe("invalidUrl") + } + + // with it, the page saves what the hook then uses + elements["insecure-http"].checked = true + for (const url of ["http://100.101.102.103:14242", "http://mac-studio.tailnet.ts.net:14242"]) { + elements.url.value = url + await save() + expect(elements.result.dataset.message).toBe("saveSucceeded") + expect(options).toMatchObject({ serverUrl: `${url}/`, allowInsecureHttp: true, maxBytes: 6000 }) + expect(resolveOptions(options).server.href).toBe(`${url}/`) + } + expect(writes).toBe(2) + elements["test-saved"].onclick() + expect(location.assigned).toBe("http://127.0.0.1:3479/test?lang=en") + mock() + calls.length = 0 + await onRequest(structuredClone(chat), ctx("chat", { options })) + expect(of("memories/search")[0].url.href).toBe("http://mac-studio.tailnet.ts.net:14242/memories/search") + + // the dialog shows the saved option; the rest of the URL rules still hold + elements["insecure-http"].checked = false + elements.configure.onclick() + expect(elements["insecure-http"].checked).toBe(true) + for (const invalid of ["ftp://mem.example.com", "http://user:pw@mac-studio.tailnet.ts.net:14242", "http://mac-studio.tailnet.ts.net:14242?token=x"]) { + elements.url.value = invalid + await save() + expect(writes).toBe(2) + expect(elements.result.dataset.message).toBe("invalidUrl") + } + + // turning it off drops the option, so the tailnet URL is refused again + elements["insecure-http"].checked = false + elements.url.value = "https://mem.example.com" + await save() + expect(writes).toBe(3) + expect(options.allowInsecureHttp).toBeUndefined() + elements.url.value = "http://mac-studio.tailnet.ts.net:14242" + await save() + expect(writes).toBe(3) + expect(elements.result.dataset.message).toBe("invalidUrl") +}) + test("configuration page follows the host language without losing edits or messages", async () => { const read = (file) => Bun.file(new URL(`./page/${file}`, import.meta.url)).text() const [dictionary, source, html] = await Promise.all([read("i18n.js"), read("settings.js"), read("settings.html")]) diff --git a/packages/nowledge-mem/package.json b/packages/nowledge-mem/package.json index 5926857..366d186 100644 --- a/packages/nowledge-mem/package.json +++ b/packages/nowledge-mem/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/gateway-nowledge-mem", - "version": "0.1.3", + "version": "0.1.4", "description": "Nowledge Mem recall, Context Bundle and optional conversation capture at the Magpie gateway, for every connected harness", "type": "module", "files": [ @@ -41,6 +41,8 @@ "captureTools": true, "captureFilter": "off", "captureCindy": false, + "recallRemote": false, + "captureRemote": false, "port": 3479 }, "page": { diff --git a/packages/nowledge-mem/page/i18n.js b/packages/nowledge-mem/page/i18n.js index 1b0a045..1d7acc1 100644 --- a/packages/nowledge-mem/page/i18n.js +++ b/packages/nowledge-mem/page/i18n.js @@ -14,7 +14,9 @@ const messages = { "dialogTitle": "Connection settings", "settingsIntro": "Connect Magpie to your Nowledge Mem.", "serviceSection": "Mem service", - "urlHelp": "Local HTTP or remote HTTPS. No credentials in the URL.", + "urlHelp": "Local HTTP or remote HTTPS; HTTP to another machine needs the switch below. No credentials in the URL.", + "insecureHttp": "Allow HTTP to another machine", + "insecureHttpHelp": "Only on a network you trust, e.g. Tailscale. Elsewhere your conversations and API key would cross the network unencrypted.", "spaceHelp": "Optional. Leave empty for the default Space.", "agentHelp": "Optional. Selects the Mem agent profile used for the Context Bundle.", "authSection": "Authentication", @@ -37,7 +39,7 @@ const messages = { "dataTitle": "What is sent", "recallDisclosure": "Recall sends the latest user turn to the configured Mem URL (NMEM_API_URL when Server URL is empty, else the local default), even when saving conversations is off.", "captureDisclosure": "Saving conversations is off by default. When enabled, completed user and assistant turns are imported to that Mem, plus client tool results unless captureTools is off.", - "scopeDisclosure": "By default, recall and saving apply to direct local requests and to the Magpie sharing key this computer writes into your own agents (magpie-key). Other gateway keys, a sharing key from another machine, and remote requests are not included.", + "scopeDisclosure": "By default, recall and saving apply to direct local requests and to the Magpie sharing key this computer writes into your own agents (magpie-key). Other gateway keys, a sharing key from another machine, and remote requests are not included. The recallRemote and captureRemote options let them in, each separately; saving does not grant recall.", "localDefault": "NMEM_API_URL if set, else http://127.0.0.1:14242", "defaultSpace": "Default Space", "on": "On", @@ -51,7 +53,7 @@ const messages = { "notConfigured": "Not configured", "loadFailed": "Could not load configuration. Reopen this page to retry.", "bridgeFailed": "Magpie configuration bridge unavailable.", - "invalidUrl": "Use local HTTP or remote HTTPS without credentials, query or fragment.", + "invalidUrl": "Use local HTTP or remote HTTPS (HTTP too with “Allow HTTP to another machine” on), without credentials, query or fragment.", "invalidKey": "Enter an API key without spaces or line breaks.", "configurationSaved": "Configuration saved", "saveSucceeded": "Saved. Connectivity has not been checked and no conversation was written.", @@ -73,7 +75,9 @@ const messages = { "dialogTitle": "连接设置", "settingsIntro": "把 Magpie 连接到你的 Nowledge Mem。", "serviceSection": "Mem 服务", - "urlHelp": "本机用 HTTP,远端用 HTTPS。地址里不要带凭据。", + "urlHelp": "本机用 HTTP,远端用 HTTPS;远端用 HTTP 需打开下方开关。地址里不要带凭据。", + "insecureHttp": "允许用 HTTP 连接另一台机器", + "insecureHttpHelp": "仅在你信任的网络中开启,例如 Tailscale。在其他网络中,你的对话和 API 密钥会以明文经过网络。", "spaceHelp": "可选。留空使用默认 Space。", "agentHelp": "可选。选择 Context Bundle 使用的 Mem agent 档案。", "authSection": "认证", @@ -96,7 +100,7 @@ const messages = { "dataTitle": "发送的内容", "recallDisclosure": "即使关闭对话保存,召回也会把最新用户消息发送到配置的 Mem 地址(Server URL 留空时用 NMEM_API_URL,否则用本机默认值)。", "captureDisclosure": "对话保存默认关闭。启用后,已完成的用户与助手消息会导入该 Mem;除非关闭 captureTools,客户端工具结果也会一并导入。", - "scopeDisclosure": "默认情况下,召回和保存适用于本机直连请求,以及 Magpie 写入你自己 agent 的本机共享密钥(magpie-key)。其他人的网关密钥、来自另一台机器的共享密钥和远端请求都不包含。", + "scopeDisclosure": "默认情况下,召回和保存适用于本机直连请求,以及 Magpie 写入你自己 agent 的本机共享密钥(magpie-key)。其他人的网关密钥、来自另一台机器的共享密钥和远端请求都不包含。选项 recallRemote 和 captureRemote 可分别让它们加入;允许保存不等于允许召回。", "localDefault": "已设置 NMEM_API_URL 时用它,否则 http://127.0.0.1:14242", "defaultSpace": "默认 Space", "on": "开", @@ -110,7 +114,7 @@ const messages = { "notConfigured": "尚未配置", "loadFailed": "无法读取配置。请重新打开此页面重试。", "bridgeFailed": "Magpie 配置桥不可用。", - "invalidUrl": "请使用本机 HTTP 或远端 HTTPS,且不含凭据、查询参数或片段。", + "invalidUrl": "请使用本机 HTTP 或远端 HTTPS(打开“允许用 HTTP 连接另一台机器”后也可用 HTTP),且不含凭据、查询参数或片段。", "invalidKey": "请输入不含空格或换行的 API 密钥。", "configurationSaved": "配置已保存", "saveSucceeded": "已保存。未检测连通性,也没有写入对话。", @@ -132,7 +136,9 @@ const messages = { "dialogTitle": "連線設定", "settingsIntro": "把 Magpie 連接到你的 Nowledge Mem。", "serviceSection": "Mem 服務", - "urlHelp": "本機用 HTTP,遠端用 HTTPS。位址裡不要帶憑證。", + "urlHelp": "本機用 HTTP,遠端用 HTTPS;遠端用 HTTP 需開啟下方開關。位址裡不要帶憑證。", + "insecureHttp": "允許用 HTTP 連線到另一台機器", + "insecureHttpHelp": "僅在你信任的網路中開啟,例如 Tailscale。在其他網路中,你的對話和 API 金鑰會以明文經過網路。", "spaceHelp": "選填。留空使用預設 Space。", "agentHelp": "選填。選擇 Context Bundle 使用的 Mem agent 設定檔。", "authSection": "驗證", @@ -155,7 +161,7 @@ const messages = { "dataTitle": "傳送的內容", "recallDisclosure": "即使關閉對話儲存,召回也會把最新使用者訊息傳送到設定的 Mem 位址(Server URL 留空時用 NMEM_API_URL,否則用本機預設值)。", "captureDisclosure": "對話儲存預設關閉。啟用後,已完成的用戶與助手訊息會匯入該 Mem;除非關閉 captureTools,用戶端工具結果也會一併匯入。", - "scopeDisclosure": "預設情況下,召回與儲存適用於本機直連請求,以及 Magpie 寫入你自己 agent 的本機共享金鑰(magpie-key)。其他人的閘道金鑰、來自另一台機器的共享金鑰和遠端請求都不包含。", + "scopeDisclosure": "預設情況下,召回與儲存適用於本機直連請求,以及 Magpie 寫入你自己 agent 的本機共享金鑰(magpie-key)。其他人的閘道金鑰、來自另一台機器的共享金鑰和遠端請求都不包含。選項 recallRemote 和 captureRemote 可分別讓它們加入;允許儲存不等於允許召回。", "localDefault": "已設定 NMEM_API_URL 時用它,否則 http://127.0.0.1:14242", "defaultSpace": "預設 Space", "on": "開", @@ -169,7 +175,7 @@ const messages = { "notConfigured": "尚未設定", "loadFailed": "無法讀取設定。請重新開啟此頁面重試。", "bridgeFailed": "Magpie 設定橋不可用。", - "invalidUrl": "請使用本機 HTTP 或遠端 HTTPS,且不含憑證、查詢參數或片段。", + "invalidUrl": "請使用本機 HTTP 或遠端 HTTPS(開啟「允許用 HTTP 連線到另一台機器」後也可用 HTTP),且不含憑證、查詢參數或片段。", "invalidKey": "請輸入不含空格或換行的 API 金鑰。", "configurationSaved": "設定已儲存", "saveSucceeded": "已儲存。未偵測連線,也沒有寫入對話。", @@ -191,7 +197,9 @@ const messages = { "dialogTitle": "接続設定", "settingsIntro": "Magpie を Nowledge Mem に接続します。", "serviceSection": "Mem サービス", - "urlHelp": "ローカルは HTTP、リモートは HTTPS。URL に認証情報を含めないでください。", + "urlHelp": "ローカルは HTTP、リモートは HTTPS。リモートに HTTP を使うには下のスイッチを有効にします。URL に認証情報を含めないでください。", + "insecureHttp": "別のコンピューターへの HTTP を許可", + "insecureHttpHelp": "信頼できるネットワーク(Tailscale など)でのみ有効にしてください。それ以外では、会話と API キーが暗号化されずにネットワークを通ります。", "spaceHelp": "任意。空欄なら既定の Space を使います。", "agentHelp": "任意。Context Bundle に使う Mem の agent プロファイルを選びます。", "authSection": "認証", @@ -214,7 +222,7 @@ const messages = { "dataTitle": "送信される内容", "recallDisclosure": "会話の保存がオフでも、呼び出しは最新のユーザーの発話を設定した Mem の URL(Server URL が空なら NMEM_API_URL、なければローカル既定値)に送ります。", "captureDisclosure": "会話の保存は既定でオフです。有効にすると、完了したユーザーとアシスタントの発話をその Mem に取り込みます。captureTools をオフにしない限り、クライアントのツール結果も含みます。", - "scopeDisclosure": "既定では、呼び出しと保存は直接のローカル要求と、Magpie があなた自身の agent に書き込むこのコンピューターの共有キー(magpie-key)に適用されます。他のゲートウェイキー、別のコンピューターからの共有キー、リモート要求は含まれません。", + "scopeDisclosure": "既定では、呼び出しと保存は直接のローカル要求と、Magpie があなた自身の agent に書き込むこのコンピューターの共有キー(magpie-key)に適用されます。他のゲートウェイキー、別のコンピューターからの共有キー、リモート要求は含まれません。オプション recallRemote と captureRemote で、それぞれ個別に含められます。保存の許可は呼び出しの許可を含みません。", "localDefault": "NMEM_API_URL があればそれ、なければ http://127.0.0.1:14242", "defaultSpace": "既定の Space", "on": "オン", @@ -228,7 +236,7 @@ const messages = { "notConfigured": "未設定", "loadFailed": "設定を読み込めませんでした。このページを開き直してください。", "bridgeFailed": "Magpie の設定ブリッジを利用できません。", - "invalidUrl": "ローカル HTTP またはリモート HTTPS を、認証情報・クエリ・フラグメントなしで指定してください。", + "invalidUrl": "ローカル HTTP またはリモート HTTPS(「別のコンピューターへの HTTP を許可」が有効なら HTTP も可)を、認証情報・クエリ・フラグメントなしで指定してください。", "invalidKey": "空白や改行を含まない API キーを入力してください。", "configurationSaved": "設定を保存しました", "saveSucceeded": "保存しました。接続確認はしておらず、会話も書き込んでいません。", @@ -250,7 +258,9 @@ const messages = { "dialogTitle": "Verbindungseinstellungen", "settingsIntro": "Verbinde Magpie mit deiner Nowledge Mem.", "serviceSection": "Mem-Dienst", - "urlHelp": "Lokales HTTP oder entferntes HTTPS. Keine Zugangsdaten in der URL.", + "urlHelp": "Lokales HTTP oder entferntes HTTPS; HTTP zu einem anderen Computer braucht den Schalter unten. Keine Zugangsdaten in der URL.", + "insecureHttp": "HTTP zu einem anderen Computer erlauben", + "insecureHttpHelp": "Nur in einem Netz, dem du vertraust, z. B. Tailscale. Anderswo gingen deine Gespräche und dein API-Schlüssel unverschlüsselt durchs Netz.", "spaceHelp": "Optional. Leer lassen für den Standard-Space.", "agentHelp": "Optional. Wählt das Mem-Agent-Profil für das Context Bundle.", "authSection": "Authentifizierung", @@ -273,7 +283,7 @@ const messages = { "dataTitle": "Was gesendet wird", "recallDisclosure": "Der Abruf sendet den letzten Benutzerbeitrag an die konfigurierte Mem-URL (NMEM_API_URL, wenn Server URL leer ist, sonst der lokale Standard), auch wenn das Speichern von Gesprächen aus ist.", "captureDisclosure": "Das Speichern von Gesprächen ist standardmäßig aus. Wenn aktiviert, werden abgeschlossene Benutzer- und Assistentenbeiträge an diese Mem importiert, dazu Tool-Ergebnisse des Clients, sofern captureTools nicht aus ist.", - "scopeDisclosure": "Standardmäßig gelten Abruf und Speichern für direkte lokale Anfragen und für den Magpie-Sharing-Schlüssel, den dieser Computer in deine eigenen Agenten schreibt (magpie-key). Andere Gateway-Schlüssel, ein Sharing-Schlüssel von einem anderen Computer und entfernte Anfragen sind nicht enthalten.", + "scopeDisclosure": "Standardmäßig gelten Abruf und Speichern für direkte lokale Anfragen und für den Magpie-Sharing-Schlüssel, den dieser Computer in deine eigenen Agenten schreibt (magpie-key). Andere Gateway-Schlüssel, ein Sharing-Schlüssel von einem anderen Computer und entfernte Anfragen sind nicht enthalten. Die Optionen recallRemote und captureRemote lassen sie jeweils einzeln zu; Speichern erlaubt keinen Abruf.", "localDefault": "NMEM_API_URL, falls gesetzt, sonst http://127.0.0.1:14242", "defaultSpace": "Standard-Space", "on": "An", @@ -287,7 +297,7 @@ const messages = { "notConfigured": "Nicht konfiguriert", "loadFailed": "Konfiguration konnte nicht geladen werden. Seite zum Wiederholen neu öffnen.", "bridgeFailed": "Magpies Konfigurationsschnittstelle ist nicht verfügbar.", - "invalidUrl": "Lokales HTTP oder entferntes HTTPS ohne Zugangsdaten, Abfrage oder Fragment verwenden.", + "invalidUrl": "Lokales HTTP oder entferntes HTTPS (HTTP auch, wenn „HTTP zu einem anderen Computer erlauben“ an ist) ohne Zugangsdaten, Abfrage oder Fragment verwenden.", "invalidKey": "API-Schlüssel ohne Leerzeichen oder Zeilenumbrüche eingeben.", "configurationSaved": "Konfiguration gespeichert", "saveSucceeded": "Gespeichert. Die Verbindung wurde nicht geprüft und kein Gespräch geschrieben.", diff --git a/packages/nowledge-mem/page/settings.html b/packages/nowledge-mem/page/settings.html index 5f48153..d10e243 100644 --- a/packages/nowledge-mem/page/settings.html +++ b/packages/nowledge-mem/page/settings.html @@ -17,7 +17,8 @@
Mem service
- + +
@@ -38,5 +39,5 @@

This plugin does not add a Library entry. To give agents Mem’s tools, add Mem’s own MCP server once in Magpie’s Library › MCP, using the Server URL below (NMEM_API_URL when it is empty) and its key.

What is sent

Recall sends the latest user turn to the configured Mem URL (NMEM_API_URL when Server URL is empty, else the local default), even when saving conversations is off.

Saving conversations is off by default. When enabled, completed user and assistant turns are imported to that Mem, plus client tool results unless captureTools is off.

-

Recall and saving apply to direct local requests and to the Magpie sharing key this computer writes into your own agents (magpie-key). Other gateway keys, a sharing key from another machine, and remote requests are not included.

+

Recall and saving apply to direct local requests and to the Magpie sharing key this computer writes into your own agents (magpie-key). Other gateway keys, a sharing key from another machine, and remote requests are not included. The recallRemote and captureRemote options let them in, each separately; saving does not grant recall.

diff --git a/packages/nowledge-mem/page/settings.js b/packages/nowledge-mem/page/settings.js index 086af27..81a939b 100644 --- a/packages/nowledge-mem/page/settings.js +++ b/packages/nowledge-mem/page/settings.js @@ -30,15 +30,17 @@ function skipList(value) { const names = Array.isArray(value) ? value : typeof value === "string" ? value.split(/[,,\n]/) : []; return names.filter((name) => typeof name === "string").map((name) => name.trim()).filter(Boolean); } -function validUrl(raw) { +// The same rule as mem.mjs: plain HTTP to another machine only with +// allowInsecureHttp, as on a tailnet, whose link is already encrypted. +function validUrl(raw, insecure = false) { let url; try { url = new URL(raw); } catch { return null } const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname); - if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || (url.protocol === "http:" && !loopback)) return null; + if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || (url.protocol === "http:" && !loopback && insecure !== true)) return null; return url; } function formUrl(fallback = "") { - return validUrl($("url").value.trim() || fallback); + return validUrl($("url").value.trim() || fallback, $("insecure-http").checked); } function testService() { const service = window.magpie?.service; @@ -53,6 +55,7 @@ function fill(options) { $("skip-agents").value = skipList(options.skipAgents).join(", "); $("key").value = (options.apiKey || "").replace(/^Bearer\s+/i, ""); $("key").type = "password"; + $("insecure-http").checked = options.allowInsecureHttp === true; $("recall").checked = options.recall !== false; $("context").checked = options.contextBundle !== false; $("capture").checked = options.capture === true; @@ -116,6 +119,8 @@ const save = async (event) => { else delete next.skipAgents; if (key) next.apiKey = key; else delete next.apiKey; + if ($("insecure-http").checked) next.allowInsecureHttp = true; + else delete next.allowInsecureHttp; await magpie.options.set(next); savedOptions = next; summary(); message("configured", "configurationSaved"); @@ -126,7 +131,7 @@ const save = async (event) => { $("test-saved").onclick = () => { if (!savedOptions) return; - const url = validUrl(savedOptions.serverUrl || "http://127.0.0.1:14242"); + const url = validUrl(savedOptions.serverUrl || "http://127.0.0.1:14242", savedOptions.allowInsecureHttp === true); if (!url) { message("configured", "invalidUrl", true); return } const target = new URL(testService() + "/test"); target.searchParams.set("lang", language);