Files
magpie/internal/sessions/testdata/openmausbot
yetone b507b5f692 sessions: OpenMausBot's conversations are read (@qingqingdilaiP on X)
@qingqingdilaiP asked for OpenMausBot's sessions in Sessions. OpenMausBot
(milind-soni/OpenMausBot, npm 0.1.155) is already an agent in magpie,
but its conversations were not read. It keeps its data in $OMB_DATA_DIR,
else ~/.openmausbot on every system (server/config.ts):
- bots.json: bots[].tasks[], one a conversation (threadId, title, "New
  thread" until named, and cwd once a turn pins it);
- messages.db: SQLite in WAL mode (thread_id, at ms, role user|bot, kind
  text|activity|..., text, json; an activity's json holds tool.name, a
  bot text its turnId);
- usage/<YYYY-MM>.jsonl: one row a turn (driverKind, model, input with
  cachedInput and cacheWrite included, output).

internal/sessions/openmausbot.go lists each conversation as a read-only
session, like Alma's and Hermes's rows: prompts, one reply a turn (a
turn says a line before a tool and again after it), tools by name,
title from bots.json (else the first prompt), folder from task.cwd,
times from messages and usage rows. A conversation holding only a bot's
greeting is left out. Its rev joins the thread's count, last time,
bytes, usage rows, title and cwd, so a write to it, or a new title,
reads it again while the database file looks the same. Tokens count
only for API drivers (server/agents-bridge-switch.ts's
CHAT_RUNTIME_DRIVERS): a bot on Claude Code, Codex, Pi or another agent
CLI runs that CLI, which keeps the turn in its own session, so its
tokens are counted there and would be counted twice. Fresh input is
input less cache reads and writes. bots.json and the usage files are
read again only when their size or time change. Dirs() and Reads/access
cover messages.db. Delete refuses it: OpenMausBot keeps the database
open.

Tests (testdata/openmausbot is OpenMausBot 0.1.155's own data folder,
written by the real app in a sandbox on mica with an OpenAI-compatible
fake model, database checkpointed):
- TestOpenMausBotSessions: titles, tokens, times, greeting-only threads
  left out, the Sessions page (2 rows, not deletable, 4 and 2
  messages), Delete refused, stats (1 prompt, 1 reply, agents_list_bots
  once), Dirs(), the database's bytes unchanged.
- TestOpenMausBotCountsCLITurnsOnce: the sample's rows with one turn on
  claudeAgent and one with cache read and write, cwd pinned.
- TestOpenMausBotReadAgainWhenItChanges: a new title alone, then a new
  row with the file's time held.
- skillsCounted: openmausbot says why its skills are not counted (a bot
  reads a SKILL.md with its file tools, and the sample has no such turn).
Broken by hand, each red: CLI rows counted (claude tokens 1202/42),
no turnId dedupe (team 3 messages, 2 replies), no rev check and title
ignored (new title not read), cache left in fresh input (1203), greeting
threads listed (4 rows).

Run: gofmt -l clean. On mote (load ~20 on 18 cores, mica busier with a
GUI run): go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./..., go test -count=1 -timeout 45m ./... at 59c5b59ea (this and the yaml.v3 commit on df2b819c6): 100 packages ok. The first run, at 13cb07fde, was red in internal/sessions' TestEveryAgentSaysItsSkills (openmausbot not in skillsCounted, added here) and the root's TestNoEagerPackageRegexps (main's yaml.v3, the next commit). On Windows
(xiaomi-gpu): go test -run 'OpenMausBot|Alma|Hermes' ./internal/sessions ok.

After a rebase onto ea6470cb7 (01c3efc4f's library change and a GUI
test): vet as above, and go test . ./internal/sessions ./internal/library
./internal/catalog ok. After another onto 79a30eb9c (edit/toml.go and
provider/remote_follow.go perf): go vet ./..., go test . ./internal/sessions
./internal/edit ./internal/provider ok, at the pushed tree.

Not tried: a conversation on a Claude Code or Codex engine in the real
app (its tokens come from that CLI's own session, by design here); the
live GUI (unchanged); OpenMausBot on Windows or Linux. Not covered:
magpie's own engine in OpenMausBot runs Claude Code with its config in
<data>/providers/magpie, a Claude home Sessions doesn't read, so those
turns show nowhere yet.
2026-11-14 15:42:01 +08:00
..