Skip to content
23 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

The docs service answers every artifacts call: docs can be made, listed, shared, moved, trashed, restored, searched, versioned and edited live in their own rooms, agents read, write and recall them only where their person and everyone in the conversation can, and folio events go out on the bus, while Docs' pages keep working as before.1import assert from "node:assert/strict";
2import { readFileSync } from "node:fs";
3import { test } from "node:test";
4
5import { FOLIO_RPC, folioHandler } from "./rpc.ts";
6
7/** FOLIO_RPC_METHODS as the contract lists them (read from the source: Node can't load the contracts package itself). */
8function contractMethods(): string[] {
9 const source = readFileSync(new URL("../../../../packages/contracts/src/folios.ts", import.meta.url), "utf8");
10 const block = source.slice(source.indexOf("export const FOLIO_RPC_METHODS = ["), source.indexOf("] as const;"));
11 return [...block.matchAll(/^\s*"([a-z_]+)",/gm)].map((m) => m[1]!);
12}
13
14test("every folio RPC method in the contract is answered, and nothing else", () => {
15 const methods = contractMethods();
16 assert.ok(methods.length >= 40);
17 assert.deepEqual(Object.keys(FOLIO_RPC).sort(), [...methods].sort());
18 for (const m of methods) assert.equal(typeof folioHandler(m), "function", m);
19});
20
21test("Docs' own methods fall through to the legacy switch", () => {
22 for (const m of ["sidebar", "page", "create_page", "recall_for_agent", "toString", "__proto__", "constructor"]) assert.equal(folioHandler(m), null, m);
23});