Seats say who is calling, and a seat's earlier chat can hear that another chat picked it up. Version 277 of shared· groups· Oct 15 (2026-10-15 23:41 UTC) · Not checked
The 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.
The 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.
Tests: client caller and visitor, worker/project seat-notice, announce-person, news-*, tells (29 pass); tsc clean.
Version 276 · Files at version 277
8 files, 265 lines added, 5 removed.
--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -4,6 +4,7 @@
5 5 import { randomUUID } from "node:crypto"; 6 6 import { setDefaultResultOrder } from "node:dns"; 7 + import { CALLER_HEADER } from "../../src/caller.ts"; @@ -141,6 +142,23 @@
141 142 | { dryRun: true; plan: CopyPlan } 142 143 | { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } }; 146 + * The server's line when another chat just used this seat (seatNotice on an answer): kept until main() prints it with 147 + * the news, once however many answers carried it. 149 + const seatNotices = new Set<string>(); 150 + function noteSeat(answer: unknown): void { 151 + if (typeof answer !== "object" || answer === null || Array.isArray(answer)) return; 152 + const line = (answer as { seatNotice?: unknown }).seatNotice; 153 + if (typeof line === "string" && line !== "" && line.length <= 300 && !/[\u0000-\u001f]/.test(line)) 154 + seatNotices.add(line); 156 + export function takeSeatNotices(): string[] { 157 + const out = [...seatNotices]; 158 + seatNotices.clear(); 145 163 readonly config: Config; 146 164 readonly timeoutMs: number; @@ -169,6 +187,9 @@
169 187 /** The Issues Worker (#54) this folder's issues calls go to; set by the issues commands (issues.ts). */ 170 188 issuesServer: string | undefined; 190 + /** Who is calling this seat (src/caller.ts): this chat's session, this computer and this folder. Set by open(). */ 191 + caller: string | undefined; 172 193 url(path: string, server = this.config.server): string { 173 194 return `${server.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`; @@ -182,6 +203,8 @@
182 203 // Which client made the call (#29); the mods send theirs too. 183 204 "x-abso-client": `abso-cli/${clientVersion()}`, 184 205 ...(this.config.token && !this.config.visitor ? { authorization: `Bearer ${this.config.token}` } : {}), 206 + // A visitor says nothing about where it's reading from. 207 + ...(this.caller !== undefined && !this.config.visitor ? { [CALLER_HEADER]: this.caller } : {}), 185 208 ...(contentType ? { "content-type": contentType } : {}), @@ -258,7 +281,9 @@
261 − return JSON.parse(text) as T;
284 + const parsed = JSON.parse(text) as T; 263 288 throw new ApiError( 264 289 `${method} ${path} answered with something that isn't JSON: ${text.slice(0, 300)}`, --- a/client/src/command-env.ts
+++ b/client/src/command-env.ts
@@ -1,6 +1,8 @@
1 1 // What every abso command shares: its output, its environment, the folder it opens, and the news it took. 3 − import { Api, type News, newsLines, type RunKind } from "./api.ts";
3 + import { hostname } from "node:os"; 4 + import { callerHeader } from "../../src/caller.ts"; 5 + import { Api, type News, newsLines, type RunKind, takeSeatNotices } from "./api.ts"; 4 6 import { UsageError } from "./args.ts"; 5 7 import { type Config, findRoot, readConfig } from "./config.ts"; 6 8 import { newsBlockLines, newsShown } from "./core.ts"; @@ -45,7 +47,9 @@
45 47 `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.`, 47 49 const config = readConfig(root, env.env, env.tokenFile === true); 48 − return { root, config, api: new Api(config) };
50 + const api = new Api(config); 51 + api.caller = callerHeader({ session: env.env.CLAUDE_CODE_SESSION_ID, machine: hostname(), folder: root }); 52 + return { root, config, api }; @@ -56,7 +60,7 @@
57 61 const takenNews: string[] = []; 58 62 export function takeNews(): string[] { 59 − return takenNews.splice(0);
63 + return [...takeSeatNotices(), ...takenNews.splice(0)]; 62 66 /** News a record answered with: kept in .avcs/news.log, and printed by main(). */ --- /dev/null
+++ b/client/test/caller.test.ts
@@ -0,0 +1,90 @@
1 + // Who is calling a seat: one header with the chat's session, the computer and the folder, read back exactly or not at all. 2 + import assert from "node:assert/strict"; 3 + import { test } from "node:test"; 4 + import { CALLER_HEADER, CALLER_MAX, callerHeader, callerPlace, parseCaller } from "../../src/caller.ts"; 5 + import { Api } from "../src/api.ts"; 7 + const session = "0da5c2b7-ab07-4249-b868-e8f09b6ec7b6"; 9 + test("a caller goes out and comes back as it was", () => { 10 + const header = callerHeader({ session, machine: "DESKTOP-1", folder: "C:\\Users\\sam\\repos\\abso\\groups" })!; 11 + assert.match(header, /^[A-Za-z0-9_-]+$/); 12 + assert.deepEqual(parseCaller(header), { 14 + machine: "DESKTOP-1", 15 + folder: "C:\\Users\\sam\\repos\\abso\\groups", 17 + assert.equal(callerPlace(parseCaller(header)!), "groups on DESKTOP-1"); 18 + // Outside a chat there's no session, and that's still a caller. 19 + assert.deepEqual(parseCaller(callerHeader({ machine: "box", folder: "/work/über" })), { 21 + folder: "/work/über", 25 + test("a session that isn't an id is left out, and a long folder keeps its end", () => { 26 + assert.deepEqual(parseCaller(callerHeader({ session: "not a session!", machine: "m", folder: "/a" })), { 30 + const deep = `/${"very-long-folder-name/".repeat(40)}groups`; 31 + const header = callerHeader({ session, machine: "m", folder: deep })!; 32 + assert.ok(header.length <= CALLER_MAX); 33 + assert.ok(parseCaller(header)!.folder.endsWith("/groups")); 36 + test("a header that isn't a caller is refused, never guessed at", () => { 37 + const enc = (v: unknown) => Buffer.from(JSON.stringify(v)).toString("base64url"); 44 + enc({ machine: "m" }), 45 + enc({ machine: "has space", folder: "/a" }), 46 + enc({ machine: "m", folder: "/a", session: "bad id!" }), 47 + enc({ machine: "m", folder: "/a", token: "x" }), 48 + enc({ machine: "m", folder: "/a\nb" }), 49 + "A".repeat(CALLER_MAX + 1), 51 + assert.equal(parseCaller(bad), null, String(bad)); 54 + test("the Api sends the caller with its calls, except from a visitor folder", () => { 56 + server: "https://abso.test", 60 + } as ConstructorParameters<typeof Api>[0]; 61 + const api = new Api(config); 62 + assert.equal(api.headers()[CALLER_HEADER], undefined); 63 + api.caller = callerHeader({ session, machine: "m", folder: "/a" }); 64 + assert.equal(api.headers()[CALLER_HEADER], api.caller); 65 + const visitor = new Api({ ...config, visitor: true } as ConstructorParameters<typeof Api>[0]); 66 + visitor.caller = api.caller; 67 + assert.equal(visitor.headers()[CALLER_HEADER], undefined); 70 + test("a seat notice on any answer is printed once with the news", async () => { 71 + const { takeNews } = await import("../src/command-env.ts"); 73 + const real = globalThis.fetch; 74 + const line = "ann was used from another chat (groups on DESKTOP-2) in the last 30 minutes"; 75 + globalThis.fetch = (async () => Response.json({ ok: true, seatNotice: line })) as typeof fetch; 77 + const api = new Api({ 78 + server: "https://abso.test", 82 + } as ConstructorParameters<typeof Api>[0]); 83 + await api.json("GET", "/status"); 84 + await api.json("GET", "/status"); 85 + assert.deepEqual(takeNews(), [line]); 86 + assert.deepEqual(takeNews(), []); 88 + globalThis.fetch = real; --- /dev/null
+++ b/src/caller.ts
@@ -0,0 +1,72 @@
1 + // Who is calling a seat: the chat's session, the computer and the folder, so a seat can tell its callers when 2 + // someone else picks it up. It is information, never authority: the agent key decides who the caller is, and nothing 3 + // secret goes in it. Sent as one header, base64url of its JSON. 5 + export const CALLER_HEADER = "x-abso-caller"; 6 + /** The header's most bytes. A folder that would go over keeps its end, which is the part that tells folders apart. */ 7 + export const CALLER_MAX = 512; 9 + export interface Caller { 10 + /** The chat's session id, when abso runs in one (Claude Code's CLAUDE_CODE_SESSION_ID, or the mod's own). */ 11 + readonly session?: string; 12 + readonly machine: string; 13 + readonly folder: string; 16 + const SESSION = /^[A-Za-z0-9_-]{1,64}$/; 17 + const MACHINE = /^[\w.-]{1,64}$/; 18 + const FOLDER_MAX = 300; 20 + const b64u = (text: string): string => 21 + btoa(String.fromCodePoint(...new TextEncoder().encode(text))) 26 + function fromB64u(text: string): string { 27 + const bin = atob(text.replace(/-/g, "+").replace(/_/g, "/")); 28 + return new TextDecoder("utf-8", { fatal: true, ignoreBOM: false }).decode(Uint8Array.from(bin, (c) => c.codePointAt(0)!)); 31 + /** The header for this caller, or undefined when there's nothing usable to say. */ 32 + export function callerHeader(caller: { 33 + session?: string | undefined; 36 + }): string | undefined { 37 + const machine = caller.machine.replace(/[^\w.-]/g, "-").slice(0, 64); 38 + if (!MACHINE.test(machine)) return undefined; 39 + const session = caller.session !== undefined && SESSION.test(caller.session) ? caller.session : undefined; 40 + let folder = caller.folder.slice(-FOLDER_MAX); 42 + const out = b64u(JSON.stringify({ ...(session === undefined ? {} : { session }), machine, folder })); 43 + if (out.length <= CALLER_MAX) return out; 44 + if (folder.length === 0) return undefined; 45 + folder = folder.slice(Math.ceil(folder.length / 4)); 49 + /** The caller a header names, or null when it is missing or isn't one (a bad header never guesses). */ 50 + export function parseCaller(header: string | null | undefined): Caller | null { 51 + if (header === null || header === undefined || header === "" || header.length > CALLER_MAX) return null; 52 + if (!/^[A-Za-z0-9_-]+$/.test(header)) return null; 55 + raw = JSON.parse(fromB64u(header)); 59 + if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null; 60 + const { session, machine, folder, ...rest } = raw as Record<string, unknown>; 61 + if (Object.keys(rest).length > 0) return null; 62 + if (typeof machine !== "string" || !MACHINE.test(machine)) return null; 63 + if (typeof folder !== "string" || folder.length > FOLDER_MAX || /[\u0000-\u001f]/.test(folder)) return null; 64 + if (session !== undefined && (typeof session !== "string" || !SESSION.test(session))) return null; 65 + return { ...(session === undefined ? {} : { session }), machine, folder }; 68 + /** How a caller reads in a sentence: "<folder> on <machine>", with only the folder's last part. */ 69 + export function callerPlace(caller: Caller): string { 70 + const parts = caller.folder.split(/[\\/]+/).filter((p) => p !== ""); 71 + return `${parts.at(-1) ?? "a folder"} on ${caller.machine}`; --- a/worker/project/announce.ts
+++ b/worker/project/announce.ts
@@ -101,3 +101,22 @@
101 101 return how as `key ${string}`; 102 102 return "as claimed"; 106 + * A seat's earlier chat hears that another chat just used the seat (seats notice when someone else picks them up): 107 + * "<agent> was just used from another chat (<place>)". The Worker says where, from the caller it checked; the wording 108 + * is this one only. `key` keeps it to once per pair of chats per window: the same key again adds nothing. 110 + export function seatNotice(host: AnnounceHost, agentName: string, place: string, key: string): boolean { 111 + const agent = host.agents.get(agentName); 112 + if (agent === undefined) return false; 114 + .replace(/[\u0000-\u001f\u007f]+/g, " ") 117 + if (where === "" || !/^seat [\w:.-]{1,200}$/.test(key) || agent.told.has(key)) return false; 118 + const entries: Entry[] = []; 119 + host.queueNews(agent, [{ key, text: `${agent.name} was just used from another chat (${where})` }], entries); 120 + host.flush(entries); 121 + return entries.length > 0; --- a/worker/project/project-api.ts
+++ b/worker/project/project-api.ts
@@ -185,6 +185,8 @@
185 185 announce(agent: string, text: string, to?: string[], how?: string): { id: number; to: string[] }; 186 186 /** A signed-in person's announcement from the website (#41): the Worker has checked the sender. */ 187 187 announcePerson(person: { id: string; name: string }, text: string, to?: string[]): { id: number; to: string[] }; 188 + /** A seat's earlier chat hears that another chat just used the seat; the Worker says where. Once per key. */ 189 + seatNotice(agent: string, place: string, key: string): boolean; 188 190 /** What the agent is starting on (#37, #13), or null to take it back; answers who already works on those files. */ --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -36,7 +36,12 @@
36 36 } from "../../src/engine/state-source.ts"; 37 37 import { type AddDraftHost, addDraft as hostedAddDraft } from "./add-draft.ts"; 38 38 import { type AmendHost, amend as hostedAmend } from "./amend.ts"; 39 − import { type AnnounceHost, announce as hostedAnnounce, announcePerson as hostedAnnouncePerson } from "./announce.ts";
41 + announce as hostedAnnounce, 42 + announcePerson as hostedAnnouncePerson, 43 + seatNotice as hostedSeatNotice, 44 + } from "./announce.ts"; 40 45 import { type ApplyEntryHost, applyEntry as hostedApplyEntry } from "./apply-entry.ts"; @@ -1327,6 +1332,11 @@
1327 1332 return hostedAnnouncePerson(this.#announceHost, ...args); 1335 + /** A seat's earlier chat hears that another chat just used the seat (announce.ts seatNotice). */ 1336 + seatNotice(...args: Tail<Parameters<typeof hostedSeatNotice>>): ReturnType<typeof hostedSeatNotice> { 1337 + return hostedSeatNotice(this.#announceHost, ...args); 1331 1341 * Say what the agent is starting on (#37, #13), before any edit lands: 1332 1342 * `text`, and the files it expects to change if it knows them. Nothing is --- /dev/null
+++ b/worker/project/test/seat-notice.test.ts
@@ -0,0 +1,38 @@
1 + // A seat's earlier chat hears that another chat just used the seat: one line, worded here, once per key, to that seat only. 2 + import assert from "node:assert/strict"; 3 + import { test } from "node:test"; 4 + import { MemoryStore, Project } from "../project.ts"; 7 + const store = new MemoryStore(); 8 + const project = new Project(store); 9 + project.init({ "a.txt": "a\n" }, 0); 10 + for (const a of ["ann", "bob"]) project.sync(a); 13 + return { project, store }; 16 + test("the seat hears it once, as news, and the history keeps it", () => { 17 + const { project, store } = setup(); 18 + assert.equal(project.seatNotice("ann", "groups on DESKTOP-1", "seat ann:s1:s2:0"), true); 20 + project.seatNotice("ann", "groups on DESKTOP-1", "seat ann:s1:s2:0"), 22 + "the same key adds nothing", 24 + assert.deepEqual(project.news("bob").news, [], "only that seat"); 25 + assert.deepEqual(project.news("ann").news, ["ann was just used from another chat (groups on DESKTOP-1)"]); 26 + const replayed = Project.load(store.entries, new MemoryStore()); 27 + assert.deepEqual(replayed.news("ann").news, [], "replay knows it was heard"); 28 + assert.equal(replayed.seatNotice("ann", "groups on DESKTOP-1", "seat ann:s1:s2:0"), false, "and that it was sent"); 31 + test("no seat, no place or a key that isn't a seat's adds nothing; the place stays one line", () => { 32 + const { project } = setup(); 33 + assert.equal(project.seatNotice("cal", "x on m", "seat cal:a:b:0"), false); 34 + assert.equal(project.seatNotice("ann", " \n ", "seat ann:a:b:0"), false); 35 + assert.equal(project.seatNotice("ann", "x on m", "announce 1"), false); 36 + assert.equal(project.seatNotice("ann", "two\nlines on m", "seat ann:a:b:1"), true); 37 + assert.deepEqual(project.news("ann").news, ["ann was just used from another chat (two lines on m)"]);