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>
42 lines
7.0 KiB
HTML
42 lines
7.0 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||
<title>Nowledge Mem</title><link rel="stylesheet" href="style.css">
|
||
<script src="_magpie/bridge.js" defer></script><script src="i18n.js" defer></script><script src="settings.js" defer></script></head>
|
||
<body><main>
|
||
<header class="page-head"><img class="brand" src="icon.svg" width="30" height="30" alt=""><div><h1>Nowledge Mem</h1><p data-t="intro">Recall your Mem memory in every agent behind Magpie.</p></div><div class="header-actions"><button id="configure" type="button" disabled data-t="configure">Configure connection</button><button id="test-saved" class="secondary" type="button" disabled data-t="testConnection">Test connection</button></div></header>
|
||
<section class="panel"><div class="section-heading"><h2 data-t="connection">Connection</h2><span id="configured" role="status"></span></div>
|
||
<dl class="connection-summary"><div><dt data-t="url">Server URL</dt><dd id="summary-url">—</dd></div><div><dt data-t="space">Space ID</dt><dd id="summary-space">—</dd></div><div><dt data-t="recall">Memory recall</dt><dd id="summary-recall">—</dd></div><div><dt id="summary-capture-label" data-t="capture">Save conversations</dt><dd class="capture-status"><input id="summary-capture" class="slide-switch" type="checkbox" role="switch" disabled aria-labelledby="summary-capture-label" aria-describedby="capture-feedback"><span id="capture-state"></span></dd></div></dl>
|
||
<p id="capture-feedback" role="status" aria-live="polite" hidden></p></section>
|
||
<dialog id="settings" aria-labelledby="dialog-title" aria-describedby="dialog-description">
|
||
<div class="dialog-head">
|
||
<img class="brand" src="icon.svg" width="24" height="24" alt="">
|
||
<div><h2 id="dialog-title" data-t="dialogTitle">Connection settings</h2><p id="dialog-description" data-t="settingsIntro">Connect Magpie to your Nowledge Mem.</p></div>
|
||
<button id="close" class="icon-button" type="button" aria-label="Close">×</button>
|
||
</div>
|
||
<form id="form" novalidate><div class="dialog-body">
|
||
<fieldset class="settings-section"><legend><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="6" rx="2"/><rect x="3" y="14" width="18" height="6" rx="2"/><path d="M7 7h.01M7 17h.01M16 7h2M16 17h2"/></svg><span data-t="serviceSection">Mem service</span></legend>
|
||
<div class="fields">
|
||
<label for="url"><span data-t="url">Server URL</span><input id="url" type="url" placeholder="http://127.0.0.1:14242" autocomplete="off" spellcheck="false" aria-describedby="url-help"><small id="url-help" data-t="urlHelp">Local HTTP or remote HTTPS. No credentials in the URL.</small></label>
|
||
<label for="space"><span data-t="space">Space ID</span><input id="space" placeholder="default" autocomplete="off" spellcheck="false" aria-describedby="space-help"><small id="space-help" data-t="spaceHelp">Optional. Leave empty for the default Space.</small></label>
|
||
<label for="agent"><span data-t="agent">Agent ID</span><input id="agent" placeholder="default" autocomplete="off" spellcheck="false" aria-describedby="agent-help"><small id="agent-help" data-t="agentHelp">Optional. Selects an agent profile and its default Space in Mem.</small></label>
|
||
</div></fieldset>
|
||
<fieldset class="settings-section"><legend><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="9" r="5"/><path d="m12 12 8 8h2v-4h-3v-3h-3"/></svg><span data-t="authSection">Authentication</span></legend>
|
||
<label for="key"><span data-t="key">API key</span></label><div class="secret-input"><input id="key" type="password" autocomplete="off" spellcheck="false" autocapitalize="off" aria-describedby="key-help"><button id="show-key" type="button" class="secret-toggle" aria-controls="key" aria-pressed="false" aria-label="Show key" title="Show key"><svg class="eye-show" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/></svg><svg class="eye-hide" viewBox="0 0 24 24" aria-hidden="true"><path d="m3 3 18 18M10.6 5.1A12 12 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.1 4.1M6.5 6.5A20 20 0 0 0 2 12s3.5 7 10 7a12 12 0 0 0 5.5-1.5M9.9 9.9a3 3 0 0 0 4.2 4.2"/></svg></button></div><small id="key-help" data-t="keyHelp">Leave empty when your Mem does not require a key. Saved in Magpie’s local plugin configuration.</small><small data-t="keyFallback">With this field empty, Magpie reads the variable named in apiKeyEnv (NMEM_API_KEY by default).</small>
|
||
</fieldset>
|
||
<fieldset class="settings-section"><legend><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8"/></svg><span data-t="behaviorSection">What Magpie sends</span></legend>
|
||
<label class="switch-field" for="recall"><input id="recall" type="checkbox" role="switch"><span><strong data-t="recall">Memory recall</strong><small data-t="recallHelp">Search Mem with the latest user turn and add what it recalls to the request.</small></span></label>
|
||
<label class="switch-field" for="context"><input id="context" type="checkbox" role="switch"><span><strong data-t="contextLabel">Context Bundle</strong><small data-t="contextHelp">On a session’s first turn, also send your profile, rules and Working Memory.</small></span></label>
|
||
<label class="switch-field" for="capture"><input id="capture" type="checkbox" role="switch"><span><strong data-t="capture">Save conversations</strong><small data-t="captureHelp">Off by default. Import completed conversations as Mem Threads, which Mem distills into Memory.</small></span></label>
|
||
</fieldset>
|
||
<p id="result" role="status" aria-live="polite" hidden></p>
|
||
</div><footer><span data-t="saveHelp">Advanced options are preserved.</span><div class="actions"><button id="cancel" class="secondary" type="button" data-t="cancel">Cancel</button><button id="save" type="button" disabled data-t="save">Save configuration</button></div></footer>
|
||
</form></dialog>
|
||
<section class="panel tools-panel" aria-labelledby="tools-title">
|
||
<h2 id="tools-title" data-t="toolsTitle">Memory tools</h2>
|
||
<p data-t="toolsIntro">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.</p>
|
||
</section>
|
||
<section class="data-notice" aria-labelledby="data-title"><h2 id="data-title" data-t="dataTitle">What is sent</h2><p data-t="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.</p><p data-t="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.</p>
|
||
<p data-t="scopeDisclosure">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.</p></section>
|
||
</main></body></html>
|