{"file":"src/caller.ts","version":318,"total":75,"from":1,"to":75,"lines":[{"n":1,"text":"// Who is calling a seat: the chat's session, the computer and the folder, so a seat can tell its callers when","atom":"a2738","author":"groups","version":277},{"n":2,"text":"// someone else picks it up. It is information, never authority: the agent key decides who the caller is, and nothing","atom":"a2738","author":"groups","version":277},{"n":3,"text":"// secret goes in it. Sent as one header, base64url of its JSON.","atom":"a2738","author":"groups","version":277},{"n":4,"text":"","atom":"a2738","author":"groups","version":277},{"n":5,"text":"export const CALLER_HEADER = \"x-abso-caller\";","atom":"a2738","author":"groups","version":277},{"n":6,"text":"/** The header's most bytes. A folder that would go over keeps its end, which is the part that tells folders apart. */","atom":"a2738","author":"groups","version":277},{"n":7,"text":"export const CALLER_MAX = 512;","atom":"a2738","author":"groups","version":277},{"n":8,"text":"","atom":"a2738","author":"groups","version":277},{"n":9,"text":"export interface Caller {","atom":"a2738","author":"groups","version":277},{"n":10,"text":"\t/** The chat's session, when abso runs in one: the client sends a short SHA-256 of the id, never the id itself. */","atom":"a2787","author":"pinch","version":282},{"n":11,"text":"\treadonly session?: string;","atom":"a2738","author":"groups","version":277},{"n":12,"text":"\treadonly machine: string;","atom":"a2738","author":"groups","version":277},{"n":13,"text":"\t/** The folder's last part: the client sends no more of its path. */","atom":"a2787","author":"pinch","version":282},{"n":14,"text":"\treadonly folder: string;","atom":"a2738","author":"groups","version":277},{"n":15,"text":"}","atom":"a2738","author":"groups","version":277},{"n":16,"text":"","atom":"a2738","author":"groups","version":277},{"n":17,"text":"const SESSION = /^[A-Za-z0-9_-]{1,64}$/;","atom":"a2738","author":"groups","version":277},{"n":18,"text":"const MACHINE = /^[\\w.-]{1,64}$/;","atom":"a2738","author":"groups","version":277},{"n":19,"text":"const FOLDER_MAX = 300;","atom":"a2738","author":"groups","version":277},{"n":20,"text":"","atom":"a2738","author":"groups","version":277},{"n":21,"text":"const b64u = (text: string): string =>","atom":"a2744","author":"groups","version":277},{"n":22,"text":"\tbtoa(String.fromCodePoint(...new TextEncoder().encode(text)))","atom":"a2744","author":"groups","version":277},{"n":23,"text":"\t\t.replace(/\\+/g, \"-\")","atom":"a2744","author":"groups","version":277},{"n":24,"text":"\t\t.replace(/\\//g, \"_\")","atom":"a2744","author":"groups","version":277},{"n":25,"text":"\t\t.replace(/=+$/, \"\");","atom":"a2744","author":"groups","version":277},{"n":26,"text":"","atom":"a2738","author":"groups","version":277},{"n":27,"text":"function fromB64u(text: string): string {","atom":"a2738","author":"groups","version":277},{"n":28,"text":"\tconst bin = atob(text.replace(/-/g, \"+\").replace(/_/g, \"/\"));","atom":"a2738","author":"groups","version":277},{"n":29,"text":"\treturn new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: false }).decode(","atom":"a2752","author":"capacity","version":279},{"n":30,"text":"\t\tUint8Array.from(bin, (c) => c.codePointAt(0)!),","atom":"a2752","author":"capacity","version":279},{"n":31,"text":"\t);","atom":"a2752","author":"capacity","version":279},{"n":32,"text":"}","atom":"a2738","author":"groups","version":277},{"n":33,"text":"","atom":"a2738","author":"groups","version":277},{"n":34,"text":"/** The header for this caller, or undefined when there's nothing usable to say. */","atom":"a2738","author":"groups","version":277},{"n":35,"text":"export function callerHeader(caller: {","atom":"a2744","author":"groups","version":277},{"n":36,"text":"\tsession?: string | undefined;","atom":"a2744","author":"groups","version":277},{"n":37,"text":"\tmachine: string;","atom":"a2744","author":"groups","version":277},{"n":38,"text":"\tfolder: string;","atom":"a2744","author":"groups","version":277},{"n":39,"text":"}): string | undefined {","atom":"a2744","author":"groups","version":277},{"n":40,"text":"\tconst machine = caller.machine.replace(/[^\\w.-]/g, \"-\").slice(0, 64);","atom":"a2738","author":"groups","version":277},{"n":41,"text":"\tif (!MACHINE.test(machine)) return undefined;","atom":"a2738","author":"groups","version":277},{"n":42,"text":"\tconst session = caller.session !== undefined && SESSION.test(caller.session) ? caller.session : undefined;","atom":"a2738","author":"groups","version":277},{"n":43,"text":"\tlet folder = caller.folder.slice(-FOLDER_MAX);","atom":"a2738","author":"groups","version":277},{"n":44,"text":"\tfor (;;) {","atom":"a2738","author":"groups","version":277},{"n":45,"text":"\t\tconst out = b64u(JSON.stringify({ ...(session === undefined ? {} : { session }), machine, folder }));","atom":"a2738","author":"groups","version":277},{"n":46,"text":"\t\tif (out.length <= CALLER_MAX) return out;","atom":"a2738","author":"groups","version":277},{"n":47,"text":"\t\tif (folder.length === 0) return undefined;","atom":"a2738","author":"groups","version":277},{"n":48,"text":"\t\tfolder = folder.slice(Math.ceil(folder.length / 4));","atom":"a2738","author":"groups","version":277},{"n":49,"text":"\t}","atom":"a2738","author":"groups","version":277},{"n":50,"text":"}","atom":"a2738","author":"groups","version":277},{"n":51,"text":"","atom":"a2738","author":"groups","version":277},{"n":52,"text":"/** The caller a header names, or null when it is missing or isn't one (a bad header never guesses). */","atom":"a2738","author":"groups","version":277},{"n":53,"text":"export function parseCaller(header: string | null | undefined): Caller | null {","atom":"a2738","author":"groups","version":277},{"n":54,"text":"\tif (header === null || header === undefined || header === \"\" || header.length > CALLER_MAX) return null;","atom":"a2738","author":"groups","version":277},{"n":55,"text":"\tif (!/^[A-Za-z0-9_-]+$/.test(header)) return null;","atom":"a2738","author":"groups","version":277},{"n":56,"text":"\tlet raw: unknown;","atom":"a2738","author":"groups","version":277},{"n":57,"text":"\ttry {","atom":"a2738","author":"groups","version":277},{"n":58,"text":"\t\traw = JSON.parse(fromB64u(header));","atom":"a2738","author":"groups","version":277},{"n":59,"text":"\t} catch {","atom":"a2738","author":"groups","version":277},{"n":60,"text":"\t\treturn null;","atom":"a2738","author":"groups","version":277},{"n":61,"text":"\t}","atom":"a2738","author":"groups","version":277},{"n":62,"text":"\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return null;","atom":"a2738","author":"groups","version":277},{"n":63,"text":"\tconst { session, machine, folder, ...rest } = raw as Record<string, unknown>;","atom":"a2738","author":"groups","version":277},{"n":64,"text":"\tif (Object.keys(rest).length > 0) return null;","atom":"a2738","author":"groups","version":277},{"n":65,"text":"\tif (typeof machine !== \"string\" || !MACHINE.test(machine)) return null;","atom":"a2738","author":"groups","version":277},{"n":66,"text":"\tif (typeof folder !== \"string\" || folder.length > FOLDER_MAX || /[\\u0000-\\u001f]/.test(folder)) return null;","atom":"a2738","author":"groups","version":277},{"n":67,"text":"\tif (session !== undefined && (typeof session !== \"string\" || !SESSION.test(session))) return null;","atom":"a2738","author":"groups","version":277},{"n":68,"text":"\treturn { ...(session === undefined ? {} : { session }), machine, folder };","atom":"a2738","author":"groups","version":277},{"n":69,"text":"}","atom":"a2738","author":"groups","version":277},{"n":70,"text":"","atom":"a2738","author":"groups","version":277},{"n":71,"text":"/** How a caller reads in a sentence: \"<folder> on <machine>\", with only the folder's last part. */","atom":"a2738","author":"groups","version":277},{"n":72,"text":"export function callerPlace(caller: Caller): string {","atom":"a2738","author":"groups","version":277},{"n":73,"text":"\tconst parts = caller.folder.split(/[\\\\/]+/).filter((p) => p !== \"\");","atom":"a2738","author":"groups","version":277},{"n":74,"text":"\treturn `${parts.at(-1) ?? \"a folder\"} on ${caller.machine}`;","atom":"a2738","author":"groups","version":277},{"n":75,"text":"}","atom":"a2738","author":"groups","version":277}],"atoms":[{"atom":"a2738","author":"groups","message":"","time":1792106997255,"timeIso":"2026-10-15T23:29:57.255Z","publish":{"draft":null,"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"}},{"atom":"a2744","author":"groups","message":"","time":1792107664909,"timeIso":"2026-10-15T23:41:04.909Z","publish":{"draft":null,"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"}},{"atom":"a2752","author":"capacity","message":"","time":1792112355539,"timeIso":"2026-10-16T00:59:15.539Z","publish":{"draft":null,"version":279,"agent":"capacity","message":"Format src/caller.ts as Biome wants (277's check and 278's failed on it; formatting only, no change in behavior).","time":1792112356220,"timeIso":"2026-10-16T00:59:16.220Z"}},{"atom":"a2787","author":"pinch","message":"","time":1792115819865,"timeIso":"2026-10-16T01:56:59.865Z","publish":{"draft":null,"version":282,"agent":"pinch","message":"The caller header carries a short hash of the chat's session and only the folder's last part\n\nX-Abso-Caller sent the raw CLAUDE_CODE_SESSION_ID and the full folder path, which names the person (C:\\Users\\<name>\\...). The client now sends the first 16 hex digits of the session id's SHA-256 and the folder's last part. The server already showed only \"<folder> on <machine>\", and the same chat hashes the same way, so seat notices still tell chats apart. Neither the raw id nor the path leaves the machine.\n\nTests: client caller (6 pass); tsc clean.","time":1792115821082,"timeIso":"2026-10-16T01:57:01.082Z"}}]}