packages/conversation is a library with no server: safe-fs, the Pi session parser, CHAT-01 pages, pinned snapshots, cursors and follow. The control board adds GET /api/conversations and /api/conversation behind the Host and Origin guard. Both are read-only, their queries are validated, and each refusal code maps to a status. Dewey authored it (packet 0cf177b1, revision 2). Filbert reviewed the code: R1 revise (branch ids moving on append, the assumed-link bridge merging branches, one unreadable seat directory turning the catalogue into a 500), then R2 approve (3b14d66c). Darkwing reviewed the routes: R1 approve (07b10ad1), R2 approve (b9d92003). The package lands with the routes, because serve.mjs imports the reader at load. On an index export: the eight suites 24/90/43/17/14/15/63/18, conversation and control-board 153/153, webui 9/9. Co-Authored-By: Claude Opus 5.5 <[email protected]>
21 lines
1.5 KiB
JavaScript
21 lines
1.5 KiB
JavaScript
import { startServer } from "/mnt/storage/src/mosaic-stack/packages/control-board/src/serve.mjs";
|
|
import { discoverRepoAgents } from "/mnt/storage/src/mosaic-stack/packages/control-board/src/scan.mjs";
|
|
import { homedir } from "node:os";
|
|
import { mkdtempSync } from "node:fs";
|
|
const specs = discoverRepoAgents("/mnt/storage/src/mosaic-stack");
|
|
const server = await startServer({ host: "127.0.0.1", port: 0, specs, boardDir: mkdtempSync("/tmp/dewey-chat02/board-"), seatsDir: homedir() + "/.mosaic-dev/seats", isAlive: () => true, page: "x" });
|
|
const base = `http://127.0.0.1:${server.address().port}`;
|
|
const cat = await (await fetch(base + "/api/conversations")).json();
|
|
console.log("rows", cat.conversations.length, cat.conversations.map(c => `${c.seat}:${c.availability}`).join(" "));
|
|
const big = cat.conversations.filter(c => c.availability === "available");
|
|
let pages = 0, t = Date.now();
|
|
for (const c of big) {
|
|
let r = await (await fetch(`${base}/api/conversation?id=${c.conversation}`)).json();
|
|
pages++;
|
|
while (r.page?.hasMore) { r = await (await fetch(`${base}/api/conversation?id=${c.conversation}&branch=${r.page.branch}&cursor=${r.page.nextCursor}`)).json(); pages++; if (!r.ok) { console.log("refused", r); break; } }
|
|
}
|
|
console.log("pages", pages, "ms", Date.now() - t);
|
|
const u = cat.conversations.find(c => c.availability === "unsupported");
|
|
const ur = await fetch(`${base}/api/conversation?id=${u.conversation}`); console.log("unsupported", ur.status, JSON.stringify(await ur.json()));
|
|
server.close();
|