diff --git a/packages/nowledge-mem/README.md b/packages/nowledge-mem/README.md index 682f777..b08267c 100644 --- a/packages/nowledge-mem/README.md +++ b/packages/nowledge-mem/README.md @@ -256,21 +256,21 @@ not show. has `connect-src 'none'`, so the page cannot call Mem itself; the package's small host part serves a loopback page on `127.0.0.1:` and the frame navigates to it. The **Test connection** button tests the saved options, so -save changes first. The page passes only the way back and the language in -`window.name`; the test page asks for a click, then the service reads the saved -plugin options itself and makes one public health request and one authenticated -Working Memory request. No URL, key or Space travels through the page. It +save changes first. The language travels in the test URL's query; the test +page asks for a click, then the service reads the saved plugin options itself +and makes one public health request and one authenticated Working Memory +request. No URL, key, Space or return address travels through the page. It writes nothing and shows reachability, the key and the Space with a fixed code -and milliseconds. **Back to settings** returns to the page; the test saves -nothing and changes no form values. +and milliseconds. **Back to settings** uses the frame's history to return to +the plugin page; the test saves nothing and changes no form values. The helper binds `127.0.0.1`, answers only when `Host` is `127.0.0.1:` or `localhost:`, and needs the page's per-process token. Its JSON endpoint accepts `Origin: null` from the sandboxed page and nothing else, and returns no `access-control-allow-origin: *`; `POST` and the page's `fetch` are therefore -closed to other sites. The back link is accepted only for a loopback -`/_magpie/plugin/` page. Because the `Host` must be loopback, the test works in -the desktop app, not through a remote `magpie web` proxy. +closed to other sites. The test page takes no return address; its Back button +only walks the frame's history. Because the `Host` must be loopback, the test +works in the desktop app, not through a remote `magpie web` proxy. The test needs the plugin host, which the gateway hook already starts; a page-only install of an older Magpie version shows the test page failing to diff --git a/packages/nowledge-mem/mem.mjs b/packages/nowledge-mem/mem.mjs index 2b421c0..fd64e0a 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.0"; +export const version = "0.1.1"; // The only report codes magpie's Plugins page shows; tools turn these into // messages, never the service's own text. diff --git a/packages/nowledge-mem/nowledge-mem.test.mjs b/packages/nowledge-mem/nowledge-mem.test.mjs index 4737910..061fb7e 100644 --- a/packages/nowledge-mem/nowledge-mem.test.mjs +++ b/packages/nowledge-mem/nowledge-mem.test.mjs @@ -763,9 +763,7 @@ test("configuration page saves the Mem connection for the shipped hook", async ( // The main page's Test button tests the saved connection; the test page // reads only the way back and the language. elements["test-saved"].onclick() - expect(location.assigned).toBe("http://127.0.0.1:3479/test") - expect(JSON.parse(window.name)).toEqual({ returnTo: location.href, lang: "en" }) - window.name = "" + expect(location.assigned).toBe("http://127.0.0.1:3479/test?lang=en") expect(options.apiKey).toBeUndefined() expect(options.spaceId).toBeUndefined() expect(options.agentId).toBeUndefined() diff --git a/packages/nowledge-mem/package.json b/packages/nowledge-mem/package.json index af1a6b9..bea6688 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.0", + "version": "0.1.1", "description": "Nowledge Mem recall, Context Bundle and optional conversation capture at the Magpie gateway, for every connected harness", "type": "module", "files": [ diff --git a/packages/nowledge-mem/page/settings.js b/packages/nowledge-mem/page/settings.js index ce5b3d8..7bd659d 100644 --- a/packages/nowledge-mem/page/settings.js +++ b/packages/nowledge-mem/page/settings.js @@ -1,7 +1,7 @@ // Only the official configuration bridge is used. The connection test is a // local loopback page the frame navigates to, because the page's sandbox has -// no network (connect-src 'none'); it receives this form's values in -// window.name and never saves them. +// no network (connect-src 'none'). It tests the saved options; the language +// travels in the query and the test page's Back button uses history.back(). const {languageFor, languageTags, translate} = nowledgeMemI18n; const $ = (id) => document.getElementById(id); let language = 'en', busy = false, savedOptions = null, pendingCapture = null; @@ -118,8 +118,9 @@ $("test-saved").onclick = () => { if (!savedOptions) return; const url = validUrl(savedOptions.serverUrl || "http://127.0.0.1:14242"); if (!url) { message("configured", "invalidUrl", true); return } - window.name = JSON.stringify({ returnTo: location.href.split("?")[0], lang: language }); - location.assign(testService() + "/test"); + const target = new URL(testService() + "/test"); + target.searchParams.set("lang", language); + location.assign(target.href); }; $("save").onclick = save; diff --git a/packages/nowledge-mem/probe.mjs b/packages/nowledge-mem/probe.mjs index 3c4ddfb..cf86663 100644 --- a/packages/nowledge-mem/probe.mjs +++ b/packages/nowledge-mem/probe.mjs @@ -5,11 +5,11 @@ import { MemFailure, request, resolveOptions } from "./mem.mjs"; const texts = { - en: { testing: "Testing the connection…", connected: "Connected", failed: "Connection failed", back: "Back to settings", noReturn: "No settings page to return to.", noService: "The local test service did not answer.", unauthorized: "key rejected", unbound: "Space not found", unavailable: "unreachable", invalid: "invalid address", notfound: "Working Memory not supported", empty: "no answer", run: "Test" }, - zh: { testing: "正在测试连接…", connected: "连接正常", failed: "连接失败", back: "返回设置", noReturn: "没有可返回的设置页面。", noService: "本地测试服务没有响应。", unauthorized: "密钥被拒绝", unbound: "Space 不存在", unavailable: "无法连接", invalid: "地址无效", notfound: "不支持 Working Memory", empty: "没有返回内容", run: "测试" }, - "zh-TW": { testing: "正在測試連線…", connected: "連線正常", failed: "連線失敗", back: "返回設定", noReturn: "沒有可返回的設定頁面。", noService: "本機測試服務沒有回應。", unauthorized: "金鑰被拒絕", unbound: "Space 不存在", unavailable: "無法連線", invalid: "位址無效", notfound: "不支援 Working Memory", empty: "沒有傳回內容", run: "測試" }, - ja: { testing: "接続を確認しています…", connected: "接続できました", failed: "接続に失敗しました", back: "設定に戻る", noReturn: "戻る設定ページがありません。", noService: "ローカルのテストサービスが応答しません。", unauthorized: "キーが拒否されました", unbound: "Space が見つかりません", unavailable: "接続できません", invalid: "アドレスが無効です", notfound: "Working Memory 非対応", empty: "応答がありません", run: "テスト" }, - de: { testing: "Verbindung wird geprüft…", connected: "Verbunden", failed: "Verbindung fehlgeschlagen", back: "Zurück zu den Einstellungen", noReturn: "Keine Einstellungsseite zum Zurückkehren.", noService: "Der lokale Testdienst antwortet nicht.", unauthorized: "Schlüssel abgelehnt", unbound: "Space nicht gefunden", unavailable: "nicht erreichbar", invalid: "ungültige Adresse", notfound: "Working Memory nicht unterstützt", empty: "keine Antwort", run: "Test" }, + en: { testing: "Testing the connection…", connected: "Connected", failed: "Connection failed", back: "Back to settings", noService: "The local test service did not answer.", unauthorized: "key rejected", unbound: "Space not found", unavailable: "unreachable", invalid: "invalid address", notfound: "Working Memory not supported", empty: "no answer", run: "Test" }, + zh: { testing: "正在测试连接…", connected: "连接正常", failed: "连接失败", back: "返回设置", noService: "本地测试服务没有响应。", unauthorized: "密钥被拒绝", unbound: "Space 不存在", unavailable: "无法连接", invalid: "地址无效", notfound: "不支持 Working Memory", empty: "没有返回内容", run: "测试" }, + "zh-TW": { testing: "正在測試連線…", connected: "連線正常", failed: "連線失敗", back: "返回設定", noService: "本機測試服務沒有回應。", unauthorized: "金鑰被拒絕", unbound: "Space 不存在", unavailable: "無法連線", invalid: "位址無效", notfound: "不支援 Working Memory", empty: "沒有傳回內容", run: "測試" }, + ja: { testing: "接続を確認しています…", connected: "接続できました", failed: "接続に失敗しました", back: "設定に戻る", noService: "ローカルのテストサービスが応答しません。", unauthorized: "キーが拒否されました", unbound: "Space が見つかりません", unavailable: "接続できません", invalid: "アドレスが無効です", notfound: "Working Memory 非対応", empty: "応答がありません", run: "テスト" }, + de: { testing: "Verbindung wird geprüft…", connected: "Verbunden", failed: "Verbindung fehlgeschlagen", back: "Zurück zu den Einstellungen", noService: "Der lokale Testdienst antwortet nicht.", unauthorized: "Schlüssel abgelehnt", unbound: "Space nicht gefunden", unavailable: "nicht erreichbar", invalid: "ungültige Adresse", notfound: "Working Memory nicht unterstützt", empty: "keine Antwort", run: "Test" }, }; export function textsFor(lang) { diff --git a/packages/nowledge-mem/service.mjs b/packages/nowledge-mem/service.mjs index 78d9d89..d66484b 100644 --- a/packages/nowledge-mem/service.mjs +++ b/packages/nowledge-mem/service.mjs @@ -32,30 +32,22 @@ function page() { h1 { margin: 0 0 10px; font-size: 17px; } p { margin: 0 0 14px; font-size: 14px; line-height: 1.5; } button { font: inherit; font-size: 13px; padding: 5px 12px; margin: 0 0 18px; } - a { display: block; font-size: 13px; color: #0a6cff; } - @media (prefers-color-scheme: dark) { body { color: #f5f5f7; background: #1c1c1e; } a { color: #6ea8ff; } } + @media (prefers-color-scheme: dark) { body { color: #f5f5f7; background: #1c1c1e; } }

Nowledge Mem

- +