e4e9eb0928becfa4e48484dde85ef5032671d582
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |