{"version":277,"agent":"groups","message":"Seats say who is calling, and a seat's earlier chat can hear that another chat picked it up.\n\nThe CLI sends X-Abso-Caller on every call: the chat's session id (CLAUDE_CODE_SESSION_ID, when abso runs in a Claude Code chat), the computer's name and the folder, base64url JSON, at most 512 bytes. A folder that reads signed out sends none. src/caller.ts reads it back exactly or not at all. It's information only; the agent key still decides who is calling.\n\nThe engine's seatNotice(agent, place, key) queues one fixed-wording news line to that seat, once per key. An answer carrying seatNotice is printed once with the news.\n\nTests: client caller and visitor, worker/project seat-notice, announce-person, news-*, tells (29 pass); tsc clean.","time":1792107667407,"timeIso":"2026-10-15T23:41:07.407Z","changes":11,"change":4315,"files":["client/src/api.ts","client/src/command-env.ts","client/test/caller.test.ts","src/caller.ts","worker/project/announce.ts","worker/project/project-api.ts","worker/project/project.ts","worker/project/test/seat-notice.test.ts"],"draft":null,"diff":[{"path":"client/src/api.ts","added":26,"removed":1,"diff":"--- a/client/src/api.ts\n+++ b/client/src/api.ts\n@@ -4,6 +4,7 @@\n \n import { randomUUID } from \"node:crypto\";\n import { setDefaultResultOrder } from \"node:dns\";\n+import { CALLER_HEADER } from \"../../src/caller.ts\";\n import type {\n \tChangeAnswer,\n \tDraftSyncAnswer,\n@@ -141,6 +142,23 @@\n \t| { dryRun: true; plan: CopyPlan }\n \t| { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } };\n \n+/**\n+ * The server's line when another chat just used this seat (seatNotice on an answer): kept until main() prints it with\n+ * the news, once however many answers carried it.\n+ */\n+const seatNotices = new Set<string>();\n+function noteSeat(answer: unknown): void {\n+\tif (typeof answer !== \"object\" || answer === null || Array.isArray(answer)) return;\n+\tconst line = (answer as { seatNotice?: unknown }).seatNotice;\n+\tif (typeof line === \"string\" && line !== \"\" && line.length <= 300 && !/[\\u0000-\\u001f]/.test(line))\n+\t\tseatNotices.add(line);\n+}\n+export function takeSeatNotices(): string[] {\n+\tconst out = [...seatNotices];\n+\tseatNotices.clear();\n+\treturn out;\n+}\n+\n export class Api {\n \treadonly config: Config;\n \treadonly timeoutMs: number;\n@@ -169,6 +187,9 @@\n \t/** The Issues Worker (#54) this folder's issues calls go to; set by the issues commands (issues.ts). */\n \tissuesServer: string | undefined;\n \n+\t/** Who is calling this seat (src/caller.ts): this chat's session, this computer and this folder. Set by open(). */\n+\tcaller: string | undefined;\n+\n \turl(path: string, server = this.config.server): string {\n \t\treturn `${server.replace(/\\/+$/, \"\")}/p/${encodeURIComponent(this.config.project)}${path}`;\n \t}\n@@ -182,6 +203,8 @@\n \t\t\t// Which client made the call (#29); the mods send theirs too.\n \t\t\t\"x-abso-client\": `abso-cli/${clientVersion()}`,\n \t\t\t...(this.config.token && !this.config.visitor ? { authorization: `Bearer ${this.config.token}` } : {}),\n+\t\t\t// A visitor says nothing about where it's reading from.\n+\t\t\t...(this.caller !== undefined && !this.config.visitor ? { [CALLER_HEADER]: this.caller } : {}),\n \t\t\t...(contentType ? { \"content-type\": contentType } : {}),\n \t\t};\n \t}\n@@ -258,7 +281,9 @@\n \t\t\t\tres.status,\n \t\t\t);\n \t\ttry {\n-\t\t\treturn JSON.parse(text) as T;\n+\t\t\tconst parsed = JSON.parse(text) as T;\n+\t\t\tnoteSeat(parsed);\n+\t\t\treturn parsed;\n \t\t} catch {\n \t\t\tthrow new ApiError(\n \t\t\t\t`${method} ${path} answered with something that isn't JSON: ${text.slice(0, 300)}`,"},{"path":"client/src/command-env.ts","added":7,"removed":3,"diff":"--- a/client/src/command-env.ts\n+++ b/client/src/command-env.ts\n@@ -1,6 +1,8 @@\n // What every abso command shares: its output, its environment, the folder it opens, and the news it took.\n \n-import { Api, type News, newsLines, type RunKind } from \"./api.ts\";\n+import { hostname } from \"node:os\";\n+import { callerHeader } from \"../../src/caller.ts\";\n+import { Api, type News, newsLines, type RunKind, takeSeatNotices } from \"./api.ts\";\n import { UsageError } from \"./args.ts\";\n import { type Config, findRoot, readConfig } from \"./config.ts\";\n import { newsBlockLines, newsShown } from \"./core.ts\";\n@@ -45,7 +47,9 @@\n \t\t\t`You're not in an abso folder: ${env.cwd} has no .abso/config.json, nor does any folder above it. abso join <project> makes one, or abso init a new project.`,\n \t\t);\n \tconst config = readConfig(root, env.env, env.tokenFile === true);\n-\treturn { root, config, api: new Api(config) };\n+\tconst api = new Api(config);\n+\tapi.caller = callerHeader({ session: env.env.CLAUDE_CODE_SESSION_ID, machine: hostname(), folder: root });\n+\treturn { root, config, api };\n }\n \n /**\n@@ -56,7 +60,7 @@\n  */\n const takenNews: string[] = [];\n export function takeNews(): string[] {\n-\treturn takenNews.splice(0);\n+\treturn [...takeSeatNotices(), ...takenNews.splice(0)];\n }\n \n /** News a record answered with: kept in .avcs/news.log, and printed by main(). */"},{"path":"client/test/caller.test.ts","added":90,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/caller.test.ts\n@@ -0,0 +1,90 @@\n+// Who is calling a seat: one header with the chat's session, the computer and the folder, read back exactly or not at all.\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { CALLER_HEADER, CALLER_MAX, callerHeader, callerPlace, parseCaller } from \"../../src/caller.ts\";\n+import { Api } from \"../src/api.ts\";\n+\n+const session = \"0da5c2b7-ab07-4249-b868-e8f09b6ec7b6\";\n+\n+test(\"a caller goes out and comes back as it was\", () => {\n+\tconst header = callerHeader({ session, machine: \"DESKTOP-1\", folder: \"C:\\\\Users\\\\sam\\\\repos\\\\abso\\\\groups\" })!;\n+\tassert.match(header, /^[A-Za-z0-9_-]+$/);\n+\tassert.deepEqual(parseCaller(header), {\n+\t\tsession,\n+\t\tmachine: \"DESKTOP-1\",\n+\t\tfolder: \"C:\\\\Users\\\\sam\\\\repos\\\\abso\\\\groups\",\n+\t});\n+\tassert.equal(callerPlace(parseCaller(header)!), \"groups on DESKTOP-1\");\n+\t// Outside a chat there's no session, and that's still a caller.\n+\tassert.deepEqual(parseCaller(callerHeader({ machine: \"box\", folder: \"/work/über\" })), {\n+\t\tmachine: \"box\",\n+\t\tfolder: \"/work/über\",\n+\t});\n+});\n+\n+test(\"a session that isn't an id is left out, and a long folder keeps its end\", () => {\n+\tassert.deepEqual(parseCaller(callerHeader({ session: \"not a session!\", machine: \"m\", folder: \"/a\" })), {\n+\t\tmachine: \"m\",\n+\t\tfolder: \"/a\",\n+\t});\n+\tconst deep = `/${\"very-long-folder-name/\".repeat(40)}groups`;\n+\tconst header = callerHeader({ session, machine: \"m\", folder: deep })!;\n+\tassert.ok(header.length <= CALLER_MAX);\n+\tassert.ok(parseCaller(header)!.folder.endsWith(\"/groups\"));\n+});\n+\n+test(\"a header that isn't a caller is refused, never guessed at\", () => {\n+\tconst enc = (v: unknown) => Buffer.from(JSON.stringify(v)).toString(\"base64url\");\n+\tfor (const bad of [\n+\t\tundefined,\n+\t\t\"\",\n+\t\t\"not base64!\",\n+\t\tenc(\"text\"),\n+\t\tenc([1]),\n+\t\tenc({ machine: \"m\" }),\n+\t\tenc({ machine: \"has space\", folder: \"/a\" }),\n+\t\tenc({ machine: \"m\", folder: \"/a\", session: \"bad id!\" }),\n+\t\tenc({ machine: \"m\", folder: \"/a\", token: \"x\" }),\n+\t\tenc({ machine: \"m\", folder: \"/a\\nb\" }),\n+\t\t\"A\".repeat(CALLER_MAX + 1),\n+\t])\n+\t\tassert.equal(parseCaller(bad), null, String(bad));\n+});\n+\n+test(\"the Api sends the caller with its calls, except from a visitor folder\", () => {\n+\tconst config = {\n+\t\tserver: \"https://abso.test\",\n+\t\tproject: \"p\",\n+\t\tagent: \"ann\",\n+\t\ttoken: \"abso_sk_x\",\n+\t} as ConstructorParameters<typeof Api>[0];\n+\tconst api = new Api(config);\n+\tassert.equal(api.headers()[CALLER_HEADER], undefined);\n+\tapi.caller = callerHeader({ session, machine: \"m\", folder: \"/a\" });\n+\tassert.equal(api.headers()[CALLER_HEADER], api.caller);\n+\tconst visitor = new Api({ ...config, visitor: true } as ConstructorParameters<typeof Api>[0]);\n+\tvisitor.caller = api.caller;\n+\tassert.equal(visitor.headers()[CALLER_HEADER], undefined);\n+});\n+\n+test(\"a seat notice on any answer is printed once with the news\", async () => {\n+\tconst { takeNews } = await import(\"../src/command-env.ts\");\n+\ttakeNews();\n+\tconst real = globalThis.fetch;\n+\tconst line = \"ann was used from another chat (groups on DESKTOP-2) in the last 30 minutes\";\n+\tglobalThis.fetch = (async () => Response.json({ ok: true, seatNotice: line })) as typeof fetch;\n+\ttry {\n+\t\tconst api = new Api({\n+\t\t\tserver: \"https://abso.test\",\n+\t\t\tproject: \"p\",\n+\t\t\tagent: \"ann\",\n+\t\t\ttoken: \"abso_sk_x\",\n+\t\t} as ConstructorParameters<typeof Api>[0]);\n+\t\tawait api.json(\"GET\", \"/status\");\n+\t\tawait api.json(\"GET\", \"/status\");\n+\t\tassert.deepEqual(takeNews(), [line]);\n+\t\tassert.deepEqual(takeNews(), []);\n+\t} finally {\n+\t\tglobalThis.fetch = real;\n+\t}\n+});"},{"path":"src/caller.ts","added":72,"removed":0,"diff":"--- /dev/null\n+++ b/src/caller.ts\n@@ -0,0 +1,72 @@\n+// Who is calling a seat: the chat's session, the computer and the folder, so a seat can tell its callers when\n+// someone else picks it up. It is information, never authority: the agent key decides who the caller is, and nothing\n+// secret goes in it. Sent as one header, base64url of its JSON.\n+\n+export const CALLER_HEADER = \"x-abso-caller\";\n+/** The header's most bytes. A folder that would go over keeps its end, which is the part that tells folders apart. */\n+export const CALLER_MAX = 512;\n+\n+export interface Caller {\n+\t/** The chat's session id, when abso runs in one (Claude Code's CLAUDE_CODE_SESSION_ID, or the mod's own). */\n+\treadonly session?: string;\n+\treadonly machine: string;\n+\treadonly folder: string;\n+}\n+\n+const SESSION = /^[A-Za-z0-9_-]{1,64}$/;\n+const MACHINE = /^[\\w.-]{1,64}$/;\n+const FOLDER_MAX = 300;\n+\n+const b64u = (text: string): string =>\n+\tbtoa(String.fromCodePoint(...new TextEncoder().encode(text)))\n+\t\t.replace(/\\+/g, \"-\")\n+\t\t.replace(/\\//g, \"_\")\n+\t\t.replace(/=+$/, \"\");\n+\n+function fromB64u(text: string): string {\n+\tconst bin = atob(text.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n+\treturn new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: false }).decode(Uint8Array.from(bin, (c) => c.codePointAt(0)!));\n+}\n+\n+/** The header for this caller, or undefined when there's nothing usable to say. */\n+export function callerHeader(caller: {\n+\tsession?: string | undefined;\n+\tmachine: string;\n+\tfolder: string;\n+}): string | undefined {\n+\tconst machine = caller.machine.replace(/[^\\w.-]/g, \"-\").slice(0, 64);\n+\tif (!MACHINE.test(machine)) return undefined;\n+\tconst session = caller.session !== undefined && SESSION.test(caller.session) ? caller.session : undefined;\n+\tlet folder = caller.folder.slice(-FOLDER_MAX);\n+\tfor (;;) {\n+\t\tconst out = b64u(JSON.stringify({ ...(session === undefined ? {} : { session }), machine, folder }));\n+\t\tif (out.length <= CALLER_MAX) return out;\n+\t\tif (folder.length === 0) return undefined;\n+\t\tfolder = folder.slice(Math.ceil(folder.length / 4));\n+\t}\n+}\n+\n+/** The caller a header names, or null when it is missing or isn't one (a bad header never guesses). */\n+export function parseCaller(header: string | null | undefined): Caller | null {\n+\tif (header === null || header === undefined || header === \"\" || header.length > CALLER_MAX) return null;\n+\tif (!/^[A-Za-z0-9_-]+$/.test(header)) return null;\n+\tlet raw: unknown;\n+\ttry {\n+\t\traw = JSON.parse(fromB64u(header));\n+\t} catch {\n+\t\treturn null;\n+\t}\n+\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return null;\n+\tconst { session, machine, folder, ...rest } = raw as Record<string, unknown>;\n+\tif (Object.keys(rest).length > 0) return null;\n+\tif (typeof machine !== \"string\" || !MACHINE.test(machine)) return null;\n+\tif (typeof folder !== \"string\" || folder.length > FOLDER_MAX || /[\\u0000-\\u001f]/.test(folder)) return null;\n+\tif (session !== undefined && (typeof session !== \"string\" || !SESSION.test(session))) return null;\n+\treturn { ...(session === undefined ? {} : { session }), machine, folder };\n+}\n+\n+/** How a caller reads in a sentence: \"<folder> on <machine>\", with only the folder's last part. */\n+export function callerPlace(caller: Caller): string {\n+\tconst parts = caller.folder.split(/[\\\\/]+/).filter((p) => p !== \"\");\n+\treturn `${parts.at(-1) ?? \"a folder\"} on ${caller.machine}`;\n+}"},{"path":"worker/project/announce.ts","added":19,"removed":0,"diff":"--- a/worker/project/announce.ts\n+++ b/worker/project/announce.ts\n@@ -101,3 +101,22 @@\n \t\treturn how as `key ${string}`;\n \treturn \"as claimed\";\n }\n+\n+/**\n+ * A seat's earlier chat hears that another chat just used the seat (seats notice when someone else picks them up):\n+ * \"<agent> was just used from another chat (<place>)\". The Worker says where, from the caller it checked; the wording\n+ * is this one only. `key` keeps it to once per pair of chats per window: the same key again adds nothing.\n+ */\n+export function seatNotice(host: AnnounceHost, agentName: string, place: string, key: string): boolean {\n+\tconst agent = host.agents.get(agentName);\n+\tif (agent === undefined) return false;\n+\tconst where = place\n+\t\t.replace(/[\\u0000-\\u001f\\u007f]+/g, \" \")\n+\t\t.trim()\n+\t\t.slice(0, 120);\n+\tif (where === \"\" || !/^seat [\\w:.-]{1,200}$/.test(key) || agent.told.has(key)) return false;\n+\tconst entries: Entry[] = [];\n+\thost.queueNews(agent, [{ key, text: `${agent.name} was just used from another chat (${where})` }], entries);\n+\thost.flush(entries);\n+\treturn entries.length > 0;\n+}"},{"path":"worker/project/project-api.ts","added":2,"removed":0,"diff":"--- a/worker/project/project-api.ts\n+++ b/worker/project/project-api.ts\n@@ -185,6 +185,8 @@\n \tannounce(agent: string, text: string, to?: string[], how?: string): { id: number; to: string[] };\n \t/** A signed-in person's announcement from the website (#41): the Worker has checked the sender. */\n \tannouncePerson(person: { id: string; name: string }, text: string, to?: string[]): { id: number; to: string[] };\n+\t/** A seat's earlier chat hears that another chat just used the seat; the Worker says where. Once per key. */\n+\tseatNotice(agent: string, place: string, key: string): boolean;\n \t/** What the agent is starting on (#37, #13), or null to take it back; answers who already works on those files. */\n \tstarting(\n \t\tagent: string,"},{"path":"worker/project/project.ts","added":11,"removed":1,"diff":"--- a/worker/project/project.ts\n+++ b/worker/project/project.ts\n@@ -36,7 +36,12 @@\n } from \"../../src/engine/state-source.ts\";\n import { type AddDraftHost, addDraft as hostedAddDraft } from \"./add-draft.ts\";\n import { type AmendHost, amend as hostedAmend } from \"./amend.ts\";\n-import { type AnnounceHost, announce as hostedAnnounce, announcePerson as hostedAnnouncePerson } from \"./announce.ts\";\n+import {\n+\ttype AnnounceHost,\n+\tannounce as hostedAnnounce,\n+\tannouncePerson as hostedAnnouncePerson,\n+\tseatNotice as hostedSeatNotice,\n+} from \"./announce.ts\";\n import { type ApplyEntryHost, applyEntry as hostedApplyEntry } from \"./apply-entry.ts\";\n import {\n \ttype ChangeHost,\n@@ -1327,6 +1332,11 @@\n \t\treturn hostedAnnouncePerson(this.#announceHost, ...args);\n \t}\n \n+\t/** A seat's earlier chat hears that another chat just used the seat (announce.ts seatNotice). */\n+\tseatNotice(...args: Tail<Parameters<typeof hostedSeatNotice>>): ReturnType<typeof hostedSeatNotice> {\n+\t\treturn hostedSeatNotice(this.#announceHost, ...args);\n+\t}\n+\n \t/**\n \t * Say what the agent is starting on (#37, #13), before any edit lands:\n \t * `text`, and the files it expects to change if it knows them. Nothing is"},{"path":"worker/project/test/seat-notice.test.ts","added":38,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/test/seat-notice.test.ts\n@@ -0,0 +1,38 @@\n+// A seat's earlier chat hears that another chat just used the seat: one line, worded here, once per key, to that seat only.\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { MemoryStore, Project } from \"../project.ts\";\n+\n+function setup() {\n+\tconst store = new MemoryStore();\n+\tconst project = new Project(store);\n+\tproject.init({ \"a.txt\": \"a\\n\" }, 0);\n+\tfor (const a of [\"ann\", \"bob\"]) project.sync(a);\n+\tproject.news(\"ann\");\n+\tproject.news(\"bob\");\n+\treturn { project, store };\n+}\n+\n+test(\"the seat hears it once, as news, and the history keeps it\", () => {\n+\tconst { project, store } = setup();\n+\tassert.equal(project.seatNotice(\"ann\", \"groups on DESKTOP-1\", \"seat ann:s1:s2:0\"), true);\n+\tassert.equal(\n+\t\tproject.seatNotice(\"ann\", \"groups on DESKTOP-1\", \"seat ann:s1:s2:0\"),\n+\t\tfalse,\n+\t\t\"the same key adds nothing\",\n+\t);\n+\tassert.deepEqual(project.news(\"bob\").news, [], \"only that seat\");\n+\tassert.deepEqual(project.news(\"ann\").news, [\"ann was just used from another chat (groups on DESKTOP-1)\"]);\n+\tconst replayed = Project.load(store.entries, new MemoryStore());\n+\tassert.deepEqual(replayed.news(\"ann\").news, [], \"replay knows it was heard\");\n+\tassert.equal(replayed.seatNotice(\"ann\", \"groups on DESKTOP-1\", \"seat ann:s1:s2:0\"), false, \"and that it was sent\");\n+});\n+\n+test(\"no seat, no place or a key that isn't a seat's adds nothing; the place stays one line\", () => {\n+\tconst { project } = setup();\n+\tassert.equal(project.seatNotice(\"cal\", \"x on m\", \"seat cal:a:b:0\"), false);\n+\tassert.equal(project.seatNotice(\"ann\", \" \\n \", \"seat ann:a:b:0\"), false);\n+\tassert.equal(project.seatNotice(\"ann\", \"x on m\", \"announce 1\"), false);\n+\tassert.equal(project.seatNotice(\"ann\", \"two\\nlines on m\", \"seat ann:a:b:1\"), true);\n+\tassert.deepEqual(project.news(\"ann\").news, [\"ann was just used from another chat (two lines on m)\"]);\n+});"}],"ci":null}