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>
This commit is contained in:
IceCodeNew
2026-10-30 21:37:55 +08:00
committed by GitHub
parent 5b4ef414e2
commit c5dc2e691c
20 changed files with 3279 additions and 0 deletions
+16
View File
@@ -116,6 +116,7 @@ These add a page to magpie's window, in the app and in `magpie web`, under Plugi
|---|---|---|
| [usage](packages/usage) | Usage glance: calls, errors, tokens and cost for today, 7 or 30 days, and the models behind them | `usage:summary` |
| [powercontext](packages/powercontext) | Connection settings for an independently deployed PowerContext service | None |
| [nowledge-mem](packages/nowledge-mem) | Connection settings, recall and capture switches, a real connection test, and the scope of what is sent | None |
| [agent-office](packages/agent-office) | What are my agents doing: live sessions as workers in a voxel office (3D/2D) or a list, with status, current step and resume commands | no `magpie.read`; its host part reads the local session files of Claude Code, Codex, dsh, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy and CodeBuddy, including prompts, replies and tool commands (`text:false` keeps statuses and tool names only) |
| [chat](packages/chat) | Chat with magpie's models, your MCP servers, instructions and skills, by Magic_zero ([Magiczerowxy](https://github.com/Magiczerowxy)). Has a host part: a local service the page goes to | none (its service calls magpie's gateway) |
@@ -137,11 +138,13 @@ Like middleware, these run on the requests agents send, but in magpie's Bun host
| Package | What it does |
|---|---|
| [powercontext](packages/powercontext) | [PowerContext](https://github.com/oceanbase/powercontext) recall and opt-in completed-conversation capture; no client MCP or skill required |
| [nowledge-mem](packages/nowledge-mem) | [Nowledge Mem](https://mem.nowledge.co) recall, Context Bundle or Working Memory, per-harness provenance and opt-in conversation import as Mem Threads, automatic for every harness behind Magpie |
Use the same plugin management commands as middleware:
```sh
magpie plugin add @magpie-community/gateway-powercontext
magpie plugin add @magpie-community/gateway-nowledge-mem
```
Installed plugins use **Plugins › Installed › Options** and the normal on/off
@@ -156,6 +159,19 @@ No Server URL is assumed and capture defaults to off;
remote/shared-key recall and capture each need a separate opt-in. The package calls an existing
Server; it does not provision services or manage processes. See the
[plugin README](packages/powercontext).
Nowledge Mem needs no deployment of its own: the hook takes the endpoint and
key from the plugin page, or from `NMEM_API_URL` and `NMEM_API_KEY` in Magpie's
environment, and falls back to a local Mem at `http://127.0.0.1:14242`. Recall
and the Context Bundle are on; importing conversations is off until enabled.
Tools are Mem's own MCP server, added once in Library › MCP; the package adds
no Library entry. Recall and saving include direct local requests and the
sharing key Magpie writes into your own agents on this computer (`magpie-key`,
Magpie 0.1.2210+); other gateway keys and remote requests stay out. **Test
connection** checks the saved connection from a loopback helper; save changes
first. Harness prompts and commands stay with the harnesses. See the
[plugin README](packages/nowledge-mem).
The asynchronous hook API shipped in Magpie 0.1.1273; see the
[released host contract](https://github.com/yetone/magpie/blob/v0.1.1273/docs/subsystems/gateway-request-hooks.md).