Commit Graph
10 Commits
Author SHA1 Message Date
yetone e1a2226405 library: EverMe Memory and Nowledge Mem are offered in the market as memory sources, added in one step (OipsAnthony on X)
Both publish an MCP server: EverMe's @everme/memory-mcp (stdio, agent id and evt_ token, managed backend preset) and Nowledge Mem's Streamable HTTP endpoint at 127.0.0.1:14242/mcp (optional Bearer key for a Mem reached over Access Anywhere). Added beside Magpie Memory; their memories stay in their service, and magpie's digest and Memory tab don't read them (docs/subsystems/memory.md).

Run (wsl-run, magpie-wt/memprov at origin/main 032340056): go test -count=1 ./internal/library ok, GOOS=windows go vet ./internal/library, go vet -tags nogui ./internal/library, gofmt -l clean. TestThirdPartyMemoryServers is red without the two entries (the market has no such server). Not tried: a real EverMe token or a running Nowledge Mem; GUI market tests (the page lists servers from the API, no GUI file changed); mote was out of disk, so nothing ran there; full suite not run.
2026-11-11 14:34:30 +08:00
yetone d77eb6d236 memory: search by meaning, on a small model on this computer
A memory search now finds what means the same in other words or another
language ("什么时候上线" finds "Releases go out on Tuesdays"), for the
MCP server's memory_search and the Library's Memory tab alike. It is off
until switched on under Memory → Search by meaning, since it downloads
paraphrase-multilingual-MiniLM-L12-v2 (Xenova's int8 ONNX, ~135 MB,
pinned revision, size and sha256 checked); switched off, the model is
deleted.

- internal/pii/guard: the BERT code runs the embedder too (LoadEmbedder,
  mean pooling; the tokenizer reads 250,002 pieces and WhitespaceSplit).
  Its vectors match ONNX Runtime's int8 to cosine >= 0.995 and are no
  further from fp32 than ORT's own; testdata carries both.
- internal/memembed: the switch, the download, vectors.bin keyed by each
  memory's sha256 (read once, again when the text changes, a cut-short
  file read as none), Keep reading in the backend, the model let go after
  10 minutes unused.
- internal/memory: memory.Semantic fuses the meaning ranking with the word
  ranking by reciprocal rank; a tie goes to the nearer in meaning, since
  a first word hit may hold one common word ("when do we release" had
  "Never delete images when..." first). Near 0.30 / Within 0.15 come from
  97 real memories and 16 queries, half Chinese for English memories:
  12 of 16 sought found with ~4 others each. Rank searches without noting
  memories used.
- GUI: the Search by meaning row (download %, memories read, failures),
  and the tab's search lists what the backend ranked first
  (POST /api/memory/rank), then word matches. zh, zh-TW, ja, de.
- docs/subsystems/memory.md: the section, out of "Not built yet".

Why not multilingual-e5-small, which this was built on first: run for
real, its cosines sat at 0.78-0.89 for everything, and a Chinese search
ranked Chinese memories over the English one it meant. e5-small, e5-base
and MiniLM were compared in ONNX Runtime on the same 97 memories; MiniLM
put the sought one first 9 of 16 and in the top 3 12 of 16, with the
rest at a median cosine of 0.16.

Run before the rebases (mote, on origin/main as of the work):
- gofmt -l internal/ clean; go vet of memembed, memory, pii/..., gui,
  library; GOOS=linux and GOOS=windows vet of memembed and pii/guard.
- MAGPIE_EMBED_DIR=~/models/pml go test -run Embedder ./internal/pii/guard:
  7 texts (CJK, full width, emoji, digits before runs of spaces) at
  0.9962-1.0000 with ORT int8.
- go test memembed, memory, memdistill, pii/..., library, browsermcp.
- Linux (magpie-desktop, -tags nogui, mote's disk was full): go test
  memembed, memory, pii/guard, gui (461s), cli (1228s, past the default
  10m timeout, so -timeout 30m); gateway -run 'MemoryMCP|OwnMCP'.
- Rebased on origin/main 3ebb1ba2c, on mote at this tree: gofmt -l
  internal/ clean; go vet of memembed, memory, pii/..., library, gui,
  gateway, and GOOS=linux and GOOS=windows vet of the first four; go
  test memembed, memory, pii/..., library, browsermcp (Embedder test on
  ~/models/pml); gateway -run 'MemoryMCP|OwnMCP'; cli -run
  'Settings|Parity|Budget'.
- Rebased again on origin/main 5d6935b11 (title bar, cli parity,
  account export, provider catalog): go vet of gui and cli; go test -run
  'Settings|Parity|Budget' of cli and gui, ok with the Bark test fix two
  commits up (TestSettingsSaveKeepsWhatItDoesNotSend, red on main).
- GUI on mote, this commit plus the next (90f4a377b, which fixes
  library-bar-more for #5982): every library-*.test.cjs, i18n-keys and
  i18n-en-no-cjk, BROWSER=chromium and webkit, 701/702 each. The red is
  library-loading's tab list, which has no "Claude plugins" (6af54dc9a)
  and is red alone at origin/main faffb1e95 (#5997). library-bili's
  webkit saved count times out about 1 run in 3, on main too (#6015).
- A real switch-on: the pinned files downloaded from Hugging Face and
  checked in 11s, 5 memories read; 什么时候上线, 端口被占用怎么办, 清理磁盘,
  回复用什么语言 and "when do we release" each find their memory first.
  缩进用什么 finds nothing (0.23 to the tabs memory, under Near).
- Broken by hand: without the tie rule, TestSearchFindsByMeaning's new
  case is red (images first).

Not run: the whole Go suite and the whole GUI suite; go test of
internal/gui and the whole of internal/cli after the rebases (WSL kept
restarting, and they passed on Linux before).
2026-11-11 04:14:58 +08:00
yetone 6a253f8af7 memory: pick several memories and keep, archive or delete them at once (RealZeroP27 on X)
Library -> Memory reviewed one memory at a time: To review held
candidates that had to be opened and kept or deleted one by one.

- Select (beside the filters, shown when two or more are listed) puts a
  box on each memory. A click picks one, Shift-click the range from the
  last one clicked, up/down move between the boxes (Shift picks as it
  goes), Cmd/Ctrl+A picks all shown, Escape ends it. A search or filter
  unpicks what it hides.
- The bar under the list (the library's lib-pickbar, as Skills' Select)
  keeps (To review), archives (In use) or restores (Archived) the picked
  ones, and deletes them on a second click.
- POST /api/memory/status {ids, status}: memory.SetStatus changes them in
  one write, each as Edit by the user (an archived inferred memory is
  dismissed, so it isn't proposed again). Unknown ids are skipped; none
  found, or a bad status, is a 400 and changes nothing.
  Delete reuses POST /api/memory/remove {ids}.

Run (mote, at this head):
- go test ./internal/memory ./internal/memdistill ./internal/library: ok
- go test -run 'Memory|Distill|Dream' ./internal/gui: ok
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., and the three builds: ok. gofmt -l: clean.
- library-memory-select.test.cjs (new): 22/22, chromium and webkit,
  en/zh/zh-TW/ja/de at 980 and 420 wide (no native select, no sideways
  overflow).
- Every library-*, i18n-* and gui-* GUI file (67), both engines: 1309 of 1309 pass.
- Rebased on 2219fdd49: i18n-keys, library-memory, library-memory-select
  and library-bili 132/132; go test ./internal/memory and -run Memory
  ./internal/gui ok (at d374168d0; only a
  client_icons test changed in those packages since).

Broken by hand:
- SetStatus without editIn: TestSetStatusOfSome red ("after keeping two:
  candidate candidate candidate candidate"), and
  TestMemoryStatusRouteActsOnSome red.
- memPick with no Shift range: the GUI test red (got [c1, c4], wanted
  c1..c4).

Not tried: the real app with a real memory.json, the WebKitGTK Linux app,
Windows' WebView2.
2026-11-10 16:00:30 +08:00
yetone 350856f512 memory: read a backlog of conversations at once, with progress and a Stop (RealZeroP27 on X)
Every run, the hourly one and Read now alike, read at most 10
conversations (PerRun), so a backlog of 400 (All) took 40 hours.

- A run the user asks for reads every conversation due
  (memdistill.ReadAll, through distillNow): switching on, picking a
  model or a longer range, and Read now. Still one request at a time,
  at the picked model and reasoning level.
- The hourly run reads up to 30 (PerRun, was 10), more than a busy
  hour brings, so only a backlog left by a stop or a failure waits for
  it.
- The row shows how far a run has gone ("Reading conversations… 37 of
  400", Progress -> doing/of in GET /api/memory/distill), with a Stop
  (memdistill.Stop, POST /api/memory/distill/stop); switching off stops
  it too. A stop drops the request in flight, which is read next time,
  and isn't an error.
- After a run the row says how many it left unread (State.Left), and
  Read now reads them. All's menu note no longer says "10 an hour".

docs/subsystems/memory.md says all of this.

Run (mote; all at base bb4dd8679, then the Go tests again at this head
on 53280aa08, which touches sessions stats only: ok):
- go test -count=1 ./internal/memdistill ./internal/memory: ok;
  -race -count=3 ./internal/memdistill: ok
- go test -count=1 -run 'Distill|Dream|Budget' ./internal/gui: ok
- node --test library-memory.test.cjs i18n-keys.test.cjs, chromium and
  webkit, 980 and 420 wide, every language: 26 pass, 0 fail
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (memdistill,
  gui): ok. gofmt -l: clean.

A sandbox backlog: TestBacklogReadAtOnce lists 400 (Listed)
conversations under All; the hourly run reads 30 and leaves 370,
ReadAll reads all 370 with progress 1 of 370 to 370 of 370, and reads
none again.

Broken by hand:
- ReadAll capped at PerRun again: TestBacklogReadAtOnce red (read 30)
- Stop without cancelling the run: TestStopEndsTheRun times out

Not tried: a real run of a 400-conversation backlog against a real
model and account (how long it takes depends on the model; one request
each); the full suite (started after the tag).
2026-11-10 14:01:23 +08:00
yetone 0e68455863 memory: pick how far back conversations are read, and the model's reasoning level (RealZeroP27 on X)
Learn from conversations read the last 7 days only (Back, fixed at
switch-on) and asked its model with no reasoning level. Its row now has
two more pickers, beside the model:

- How far back it reads: 7 days (default), 30, 90, 1 year or All
  (State.Days; 0 stays 7 days, so an existing distill.json keeps its own
  Since until a range is picked). A longer range reads at once. Every
  range reads from the latest 400 conversations (memdistill.Listed) at
  10 an hour (PerRun), so All is ~240 requests a day at most until the
  backlog is read; All's menu note says so.
- Thinking: Default (none sent, as before) or one of the model's own
  levels, fitted and sent with room to think the way Vision and Searcher
  do (gateway.WithSideEffort over sideEffort/replyRoom/withFixedEffort).
  The nightly tidy uses the same level, and its row shows the picker
  when distilling is off.

Fixed on the way, as the longer ranges depend on it: a conversation's
mark was dropped after 30 days while Since stayed put, so anything
older than 30 days inside Since was read again every hour. A mark is now
dropped once it is before Since, or older than 30 days and past the
oldest conversation listed.

POST /api/memory/distill takes effort and days; a bad one is a 400.
docs/subsystems/memory.md says all of this.

Run (mote; first at base 4bfac1268, then memdistill, gui Distill|Dream|Budget and both GUI files again at this head on e697e7ddf: ok, 26 pass):
- go test -count=1 ./internal/memdistill ./internal/memory ./internal/gui: ok
- go test -count=1 -run 'Distill|Dream|Effort' ./internal/gateway: ok
- node --test library-memory.test.cjs i18n-keys.test.cjs, chromium and
  webkit, 980 and 420 wide, every language: 26 pass, 0 fail
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (memdistill, gui,
  gateway): ok. gofmt -l: clean.
- win-run go test ./internal/memdistill: ok

Broken by hand:
- the old 30-day mark prune: TestOldConversationReadOnce red
- distillComplete without WithSideEffort: TestDistillCompleteThroughGateway
  red (high sent with thinking disabled, max_tokens 4096)

Not tried: a real distill run with a real account at a picked level or
over All; the full suite (started after the tag).
2026-11-10 12:16:51 +08:00
yetone 547585cd9c gateway: memory answers the agents on this computer alone
/mcp/magpie/memory (a28744c32) was served like the search server: from
another computer, while magpie is shared, with any enabled gateway key.
A key uses every MCP server unless it is held to some, and keys are
given to other people. Such a key could read every memory (who the user
is, their preferences), forget them, and save a global "rule" that the
digest (79decfe71) writes into every agent's instructions on this
computer, so a friend's key could plant instructions in the owner's own
agents. The hub already gave memory to this computer only (HereOnly,
isMemory); this direct route didn't.

memoryMCP now refuses !local(r) || fromBrowser(r) before serveMCP: no
other computer, keyed or not, and no web page, one Settings lists and
that sends a key included. `magpie mcp memory` (stdio, posts to loopback)
and the hub are unchanged. docs/subsystems/memory.md says so.

Run: on mote at b4a0a2a1a + this change: go test -count=1 -timeout 45m
./internal/gateway/ (ok 1169s) ./internal/library/ (ok 193s)
./internal/browsermcp/ (ok); go vet of the three, and GOOS=linux and
GOOS=windows go vet ./internal/gateway/; gofmt -l clean. Rebased onto
795cab91f, whose commits touch no file here; at the rebased head,
go test -run 'TestMemoryMCP|TestSearchMCPGuarded|TestHub'
./internal/gateway/ is ok.

Broken by hand: with memoryMCP's check reverted, TestMemoryMCPGuarded is
red: "shared, with its key: 200 ... The user's bank PIN hint is the cat's
name". The test covers another computer unshared and shared with its key,
an unlisted page, a listed page with a key and a Chrome fetch with no
Origin, each for memory_search and memory_save, checks nothing was saved,
and that an agent here still finds the memory.

Not tried: the real app with a second computer on the LAN.
2026-11-10 04:07:34 +08:00
yetone 2c2bd15d71 memory: Tidy up every night, a switch in the Memory tab
The Memory tab gets a second row under Learn from conversations. It is
off by default. Switched on, the first tidy is due at the next 03:00.
Tidy now runs one at once, and Undo puts the last one back. While
distillation is off, the row has its own model picker; both rows share
one model.
Routes: POST /api/memory/dream {on}, /dream/run and /dream/undo.
GET /api/memory/distill carries "dreaming", so a tidy no longer shows
as conversations being read.

The prompt's stale rule is narrower. On the first real run it set aside
two decisions because "the work is done". Now only a note that later
notes contradict, one past its date, or one about a finished one-off
task is stale; a decision, direction or preference stays.
docs/subsystems/memory.md gets a Dreaming section.

Real run: a sandbox memory.json of 62 real distilled memories, 12 active
and one each user-written and pinned, with auto/claude-haiku-5-5 through
the live gateway.
- Before the prompt change: 12 changes in 48s, 10 merges and 2 set aside.
  Both set-aside notes were decisions.
- After: 12 merges in 46s, none set aside. Each merge joins real
  duplicates (three ~/.codex/sessions cleanup rules into one, the
  TestFlight 1.66/1.68 pair). One went into the fixed memory, whose text
  was kept word for word.
- Undo: 25 restored. memory.json's ids and statuses equal the backup
  taken before the run, and every merged memory is gone.

Broken by hand, each red:
- Undo not reloading the list: library-memory 22 failed.
- Ignoring DreamSince: TestDreamsOnceANight.
- A plan applied after an error: TestDreamFailureChangesNothing.
- Tidy's fixed guard and Untidy's status check: their memory tests.

Run on mote at this tree:
- go test internal/memory, memdistill, library: ok.
- internal/gui -run 'Distill|Dream|I18n|Budget': ok.
- library-memory.test.cjs: 22/22 in both engines.
- i18n-keys and i18n-en-no-cjk: 4/4 each.
- go vet (darwin), GOOS=linux -tags nogui, GOOS=windows: ok.
Not run yet: the full suite at this head.
2026-11-10 03:25:45 +08:00
yetone 3445d8384e memdistill: a proposal stands on words the user wrote
A real run (Haiku through the live gateway, 10 of this Mac's Claude Code
conversations, magpie's config/cache/state in a sandbox, HOME real)
proposed 38 candidates. The ones without a quote were the assistant's
own standing instructions said back (run heavy commands on mote, no
git add -A, ask before deleting), not anything the user said. Now the
prompt asks for the user's words copied exactly and leaves out what
only the assistant said, and keep drops a proposal whose quote is
missing or isn't in the user's text (letters and digits compared,
case aside).

Same 10 conversations again: 24 candidates, every one quoting the
user, none of the echoes.

Run (mote): go test ./internal/memdistill: ok. Broken by hand: the
check off, TestReadsQuietSessionsOnce red (Added 5, want 3).
2026-11-10 03:25:45 +08:00
yetone 4d12d44163 memory: Learn from conversations, a switch in the Memory tab
The Memory tab gets a row that reads finished conversations into
candidate memories (To review). It is off until switched on; switched
on it reads at once, then hourly (5 minutes after start, then every
hour), through the gateway this process serves under the agent
"memory", with the automatic model unless one is picked through the
app's menu. Read now runs it again; a run that stopped says why.

- memdistill: Keep (the hourly loop) and Running.
- gui: /api/memory/distill (GET, POST {on, model}), /distill/run;
  distillComplete posts /v1/messages to the served gateway's handler
  with the memory agent's token.
- library client: the row, its poll while a run goes, and the
  memories reloaded when it ends; strings in zh, zh-TW, ja, de.
- docs/subsystems/memory.md: a Distillation section.

Run (mote, at this tree):
- go vet ./internal/gui ./internal/memdistill ./internal/memory; GOOS=linux
  -tags nogui and GOOS=windows vet of gui and memdistill: clean.
- go test ./internal/gui ./internal/memdistill ./internal/memory
  ./internal/library: ok.
- node --test internal/gui/tests/library-memory.test.cjs: 22/22, Chromium
  and WebKit, 5 languages, 980 and 420.

Broken by hand:
- the memories not reloaded after a run: the GUI test is red waiting
  for the proposed memory.
- the token not the memory agent's (earlier): TestDistillCompleteThroughGateway
  red on the Trace's agent.

Not tried yet: a real model's run (next), the whole GUI suite (queued
behind the suite lock on mote), the full Go suite.
2026-11-10 03:25:45 +08:00
yetone 2b2ee49ded gui: the Library's Memory tab
A tab after Instructions lists what the agents remember, in use, to
review (what an agent only guessed) and archived, pinned first then
newest; searches it, narrows it by where it applies, and adds, edits,
pins, keeps, archives and deletes memories (Delete asks with a second
click). Kind and scope are picked from the app's menu, never a <select>.
A card on top switches the digest in the ticked agents' instructions on
or off and names those agents, and offers Magpie Memory while it isn't
in the Library.

/api/memory (GET; POST saves the user's own or edits by id),
/api/memory/remove and /api/memory/digest; a change publishes the digest
at once and its reply carries `problem` when that failed.

Words other code also says (Archived, Pin, Keep, the kinds…) are in core
i18n.js; the rest in the library plugin's, in zh, zh-TW, ja and de.
docs/subsystems/memory.md describes the layer.

Run (mote-run):
- node --test internal/gui/tests/library-memory.test.cjs, Chromium and
  WebKit, 5 languages, 980 and 420 wide: ok
- whole GUI suite: not run at this commit; it is queued on mote for the stack head (034f249af before the rebase)
- go vet ./internal/gui, GOOS darwin, linux, windows: ok
Broken by hand: the pinned sort read `b.pinned - a.pinned` (NaN for an
unpinned one) and the test was red in every language until `!!`.
Looked at: screenshots en light 980, zh dark 980, en 420.
2026-11-10 03:25:44 +08:00