11 Commits
Author SHA1 Message Date
zhou.han 6059fb1990 nowledge-mem: the layout test gives a slow Chrome launch 90 s under CI (#1076)
A layout test whose Chrome launch is slow under CI's full suite gets a 90 s launch bound when CI is set (25 s locally), and the test's own timeout follows the bound plus 10 s for cleanup. Fixes #1071.

Reviewed at df016967. Run (WSL, Bun 1.4.2, CI=1): bun test packages/nowledge-mem 161 pass, 2 skip (no Chrome on that box, so the layout test itself skipped); the author ran a fake Chrome that answers at 26 s, red at 25 s on d24fd5d and green with CI=1. Not tried: a real Chrome on ubuntu CI, which this PR's merge run is.

Co-authored-by: yetihan <yetihan@users.noreply.github.com>
2026-11-13 15:08:56 +08:00
yetone b6741cc159 nowledge-mem: the layout test stops Chrome at a bound and says what it wrote (#972)
The test waited for Chrome to print the DOM and exit, with nothing bounding the launch. On CI it takes 5 to 13s (0.4s in WSL), and a few times it ran into the 30s test timeout with no word on why.

Now the results are read as soon as Chrome prints them and Chrome's whole process group (setsid) is stopped then. A launch that prints nothing in 25s is stopped, and the test fails with Chrome's stderr instead of a bare timeout. The cause of the slow CI launches is still unknown; the next red will carry it.

Run in WSL magpie-desktop (Playwright Chromium 1234 as chromium, Bun 1.4.2, temp HOME): 5 of 5 pass at about 450ms.
Broken by hand: a fake chromium that only sleeps fails at 25.0s with "Chrome gave no results within 25000ms; stderr: starting", and its sleeps are gone afterwards.
Not tried: google-chrome on an ubuntu runner, other than through CI.
2026-11-12 12:09:56 +08:00
yetone 234e073c60 nowledge-mem test: headless Chrome no longer hangs on its component updater (#972)
The "narrow settings footer" test spawns Chrome with --dump-dom. Chrome 151
(Chrome for Testing, and the runner's stable) intermittently never exits:
its SODA on-demand component update and the component updater/breakpad
start-up stall, so the process outlived the test's 30s and was killed.
This failed the publish run 43122260448 (page-chat 0.1.14) and 52e31c4a.

Cause fixed, not the timeout: the test now starts Chrome with the speech
(SODA), component-update, breakpad, field-trial and default-app start-up
work turned off, so --dump-dom exits as soon as the page is dumped.

Run (WSL magpie-desktop via wsl-run, Chrome for Testing 151 as `chromium`,
HOME=$(mktemp -d), bun 1.4.2):
- old code: red, timed out at 30s (reproduced; plain chrome --dump-dom of a
  trivial page hung 15s in 4 of 4 runs with only the SODA flag)
- with the flags: green 3 of 3, ~0.8s each; the flag set exited in 0.4-1s in
  8 of 8 bare chrome runs
Not run: the full bun test suite; GitHub's own runner.
2026-11-12 08:06:44 +08:00
yetone dda4afdc36 nowledge-mem 0.1.6: requestTimeoutMs and the hook budget go up to 30s (#926)
A deep Mem search can take longer than 5s, and the page refused any
requestTimeoutMs over 5000 or gatewayTimeoutMs over 10000. Both now go up
to 30000; the defaults (1500 and magpie's 1000) are unchanged. magpie
v0.1.3538 (yetone/magpie#5890) runs a hook up to its own 30s budget;
the README says an older magpie cuts anything over 10s.

- validate.js, settings page and labels (en, zh, zh-TW, ja, de): 50-30000
  and 100-30000.
- nowledge-mem-agent checked: its 10000 ms values are fixed internal
  timeouts, not user options with a cap; unchanged.
- slow-recall.test.mjs: a fixture server answers /memories/search after
  6100 ms; requestTimeoutMs 15000 recalls it, 30001 is invalid, and a
  caller abort stops the fetch at once (the server sees the abort) and
  keeps the request as it came.

Run (wsl-run, magpie-desktop): bun test packages/nowledge-mem
packages/nowledge-mem-agent: 161 pass, 2 skip (live Mem and the
Playwright layout check, skipped as on main), 0 fail; bun
scripts/check.mjs: rc 0. The README's magpie version was filled in after
that run.
Not tried: a real Nowledge Mem server with a slow deep search.

Reported-by: aboat0625-cpu
2026-11-10 15:31:40 +08:00
SadWood 5b370f3e62 nowledge-mem 0.1.5: one Settings dialog for every option on released hosts (#588, SadWood)
The Nowledge Mem page's dialog now sets every option the hook reads, on Magpie's released bridge (options.get/set only), by SadWood.

- One Settings dialog: connection, key (an empty field keeps the saved key; Remove saved key / Undo), API key variable, recall and remote recall, Context Bundle, apps without memory, capture and remote capture, the human-dialogue filter (a switch, Cindy only with it on, tool results only with it off) and the advanced numbers. Remote HTTP needs the Advanced exception.
- A × beside a field that holds an explicit value returns it to the default. Saving re-reads the options, writes only edited fields, and refuses (keeping the draft) when one of them, or a gate's remote grant or the endpoint behind a newly allowed HTTP exception, changed elsewhere.
- page/validate.js is shared by the page and resolveOptions, so both refuse the same values.
- The footer wraps at narrow widths (German Save was cut off at 380px).
- No native select. Every language has every key; the English fallback loop is gone.

Reviewed at 75a09d19e, run merged onto main 04f3608 (main's later 24cd0b9 touches packages/cursor only). Mac mini, Bun 1.4.2, temp HOME:
- packages/nowledge-mem: 130 pass, 2 skip (live Mem, Linux-only Chrome layout), 0 fail.
- whole repo bun test: 4699 pass, 12 skip, 0 fail. bun scripts/check.mjs: exit 0.
- PR CI at this head ran the Linux Chrome layout test (pass, 30 layouts) and 4587 pass.
- Browser harness: page/ framed with sandbox="allow-scripts", magpie's CSP and magpie's real pagebridge.js; Chromium and WebKit, en/zh/zh-TW/ja/de, 320/380/900px, light/dark (60 runs). No request beyond the page's own files, no console or page errors, the key never in the DOM, no select, no overflow, key field password again after show/close/reopen, recallRemote shown but disabled while recall is off. Flows (en 380, both engines): editing Space gives one options.set keeping custom, apiKey, requestTimeoutMs:900, skipAgents and recallRemote; http://100.64.0.5 refused until the HTTP exception is on, then saved; a Space changed elsewhere conflicts and writes nothing; Bearer key replaces and empties the field; Remove saved key deletes apiKey; turning recall on keeps recallRemote.

Broken by hand:
- Main's footer CSS back: the harness flags 12 runs (en 320, de 320/380, both engines).
- settings.js dependency check off: "enabling a global gate conflicts…" and "enabling HTTP exception conflicts…" go red.
- validateExplicitOptions removed from resolveOptions: two hook option tests go red.

Not tried: a real Mem server.
2026-11-02 05:14:03 +08:00
yetone debc0f7b53 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.
2026-11-02 02:38:06 +08:00
yetone df98bf6fb2 nowledge-mem 0.1.3: skipAgents leaves the apps you name without memory (#597)
QingZ11 relayed a user whose Doubao translator, behind magpie, had Mem
recall added to every translation. The plugin had one global recall
switch, so the only way out was turning memory off for every agent.

skipAgents (option, and "Apps without memory" on the plugin page) lists
apps by the agent name magpie gives a request (ctx.agent, the Agent
column on magpie's Usage page). A listed app's request is treated like
another machine's: no search, no Context Bundle, no capture, nothing
sent to Mem, request unchanged, reported "skipped". Names compare
without case, spaces or punctuation, so "Claude Code" matches
claude-code. A list or a comma-separated string (ASCII or full-width
comma). Default empty: nothing changes for anyone who doesn't set it.

Run (mote, at this tree on origin/main 1a3a138):
- HOME=$(mktemp -d) bun test: 4529 pass, 0 fail, 9 skip (live checks).
- bun scripts/check.mjs: ok.
- Broken by hand: without the skipAgents check in run(), the new test
  goes red (1 fail), green with it.
Not tried: a real magpie with a real translator app; the hook's ctx is
driven as magpie's host calls it, and the page script through its test.
2026-11-01 18:39:03 +08:00
SadWood 5067a29772 nowledge-mem: the README says the package adds no Library entry, and requestTimeoutMs defaults to 1500 (#584)
nowledge-mem's README says what the package does: it adds no Library entry or skill (the user adds Mem's MCP server), and requestTimeoutMs defaults to 1500 (900 is the package's example options).

Docs only, no runtime change. Reviewed at bb4aa074: checked against origin/main's mem.mjs:101 (`integer("requestTimeoutMs", 1500, 50, 5000)`), package.json's example options (900) and the README's own Tools section (no Library entry, no skill). CI test and on-npm green at this head. No version bump: the package's behaviour is unchanged.
2026-11-01 10:36:51 +08:00
SadWood 5b1ae40256 nowledge-mem 0.1.2: opt-in capture filtering, by SadWood (#567)
nowledge-mem 0.1.2 (SadWood): opt-in capture filtering. `captureFilter: "off"|"human"`
(default "off") and `captureCindy` (default false). Human mode imports only user/assistant
text (tool results dropped, commentary on tool calls kept); with captureCindy and
ctx.agent === "cindy" it removes complete, recognized leading Cindy host notes and keeps
anything unknown, incomplete, fenced, quoted or carrying a scheduled-run/handoff marker
verbatim. Only the copy sent to POST /threads/import changes; external IDs still hash the
original text and occurrence index, so off-mode IDs are unchanged. No new network route.

Reviewed head fed33102005d118507ab14cdc2765a2761254329, merged locally onto origin/main
8b01396 (0fb659a), all on mote:
- node --test packages/nowledge-mem/capture-filter.test.mjs: 52/52.
- bun test packages/nowledge-mem: 105 pass, 1 skip (live).
- Differential test of 0.1.1 vs 0.1.2 hooks (9 requests over chat/responses/anthropic/
  gemini, Cindy notes, tools, images, repeats; 6 off-mode option sets incl. recall and
  captureTools false): import payloads, returned request and reports byte-identical
  (tool_version aside). Human+Cindy mode returns the same request to the model as 0.1.1.
- Full bun test, HOME=$(mktemp -d): 4419 pass, 9 skip, 0 fail. bun scripts/check.mjs: ok.
- Broken by hand, each red: request mutated in capture (34 red); unclosed directory tag
  stripped, truncated UI-language note matched, unterminated context note stripped,
  fences ignored (quoted/fenced/incomplete test red each); default "human" (defaults +
  off-diff red); filtered index in IDs; no trim in off mode; mixed-source guard removed;
  Cindy cleanup for any agent or without opt-in.
Not tried: a real Mem server or a real Cindy session.
2026-10-31 22:39:34 +08:00
IceCodeNew c38a364e6a nowledge-mem 0.1.1: return from the connection test page, by IceCodeNew (#537)
The connection test page no longer depends on window.name, which the app's frame navigation drops. The language travels as `/test?lang=xx` and the page always shows Back to settings, which calls history.back() in the frame. The page takes no return address. Host (loopback:<port>), the per-process token and Origin null/self are unchanged in handle(). 0.1.1: package.json and mem.mjs's User-Agent version were bumped together.

Reviewed at 390130262eaaff2bf4bfd16b3483626c0c730d7c (every changed line in packages/nowledge-mem).

Run at that head:
- mote: `HOME=$(mktemp -d) bun test packages/nowledge-mem`: 53 pass, 1 skip (live), 0 fail. `bun scripts/check.mjs`: exit 0.
- Broken by hand: dropping `history.back()` from the test page turned "the running service answers 403 ..." red. Dropping the `lang` query from settings.js turned "configuration page saves the Mem connection ..." red. Both passed again once restored.
- Browser harness: a window frames the real page/settings.html under magpie's plugin-page CSP in an `<iframe sandbox="allow-scripts">` and runs the package's real service. Chromium ran on mote and WebKit on the Linux VM, because WebKit launches time out on mote right now. In both engines: Test connection opened /test?lang=zh, Back read 返回设置, and Back returned the frame to settings.html while the top window stayed at its own URL (it had a pushState entry before). The settings page was usable again afterwards. `lang` set to `"><img onerror>`, `__proto__` and `constructor` injected nothing. `lang` is only used as a key into a fixed table, and the label is set through textContent.

Not tried: the real magpie app (its bridge.js was stubbed) and a real Nowledge Mem server. Nit, not blocking: `?lang=__proto__` or `?lang=constructor` gives empty button labels, because the lookup isn't Object.hasOwn. Only a hand-typed URL can do this.

npm: @magpie-community/gateway-nowledge-mem has never been on npm. Its first version needs an owner (trusted publishing can't create a package), so magpie installs it from dist.
2026-10-31 01:08:33 +08:00
IceCodeNew c5dc2e691c nowledge-mem 0.1.0: recall and opt-in capture from your Nowledge Mem, by IceCodeNew (#526)
Adds @magpie-community/gateway-nowledge-mem, an asynchronous gateway hook by
IceCodeNew (#526): before each request it recalls from the user's Nowledge
Mem (and the Context Bundle / Working Memory on a session's first turn), and,
only when `capture` is turned on, imports completed conversations as Mem
Threads. It applies to direct local requests and the `magpie-key` sharing
key this computer writes into the user's own agents; other gateway keys,
remote and unknown origins are never included. A page sets the connection
and runs a real connection test through a loopback service guarded by Host,
Origin and a per-start token. The package writes nothing into magpie's
Library. registry.json gains one compact entry.

Reviewed head 3f4ba91 (f9eb686 plus a maintainer commit adding a test that
starts the service and expects 403 for a foreign Host, Origin and token).
Run at 3f4ba91's tree on mote (macOS, Bun 1.4.2, HOME=$(mktemp -d)):
repo `bun test` 3861 pass, 9 skip, 0 fail; `bun scripts/check.mjs` exit 0;
packages/nowledge-mem 53 pass, 1 skip.
Broken by hand: each of the service's four guards in handle() turns the new
test red; earlier rounds broke the origin gate, the block escaping, the
secret check and the cleartext-HTTP guard, each red.
Not tried: a real Mem server, a real magpie with the plugin installed,
Windows.

Co-authored-by: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com>
2026-10-30 21:37:55 +08:00