Lines 4–10 at 318 (were 4–9 at 273)
55import { randomUUID } from "node:crypto"; 66import { setDefaultResultOrder } from "node:dns"; 7+import { CALLER_HEADER } from "../../src/caller.ts"; Lines 20–26 at 318 (were 19–24 at 273)
2021} from "./api-answers.ts"; 2122import { ApiError, errorSentence, neverSent } from "./api-error.ts"; 23+import { UsageError } from "./args.ts"; 2224import type { AutosettleAnswer, AutosettleMode } from "./autosettle-commands.ts"; Lines 69–75 at 318 (were 67–72 at 273)
6971} from "./issues-wire.ts"; 72+import { isLocal, LOCAL_BASE, localFetch, NO_STORE } from "./local-store.ts"; 7073import type { Modes } from "./modes.ts"; 7275export * from "./api-answers.ts"; Lines 144–166 at 318 (were 141–146 at 273)
141144 | { dryRun: true; plan: CopyPlan } 142145 | { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } }; 148+ * The server's line when another chat just used this seat (seatNotice on an answer): kept until main() prints it with 149+ * the news, once however many answers carried it. 151+const seatNotices = new Set<string>(); 152+function noteSeat(answer: unknown): void { 153+ if (typeof answer !== "object" || answer === null || Array.isArray(answer)) return; 154+ const line = (answer as { seatNotice?: unknown }).seatNotice; 155+ if (typeof line === "string" && line !== "" && line.length <= 300 && !/[\u0000-\u001f]/.test(line)) 156+ seatNotices.add(line); 158+export function takeSeatNotices(): string[] { 159+ const out = [...seatNotices]; 160+ seatNotices.clear(); 145165 readonly config: Config; 146166 readonly timeoutMs: number; Lines 189–205 at 318 (were 169–178 at 273)
169189 /** The Issues Worker (#54) this folder's issues calls go to; set by the issues commands (issues.ts). */ 170190 issuesServer: string | undefined; 192+ /** Who is calling this seat (src/caller.ts): this chat's session, this computer and this folder. Set by open(). */ 193+ caller: string | undefined; 172195 url(path: string, server = this.config.server): string { 173− return `${server.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`;
196+ const base = isLocal(server) ? LOCAL_BASE : server; 197+ return `${base.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`; 200+ /** A local project's calls: answered in this process (local-store.ts). */ 201+ private local: ((input: string, init?: RequestInit) => Promise<Response>) | undefined; 176203 agentPath(action: string): string { 177204 return `/a/${encodeURIComponent(this.config.agent)}/${action}`; Lines 209–216 at 318 (were 182–187 at 273)
182209 // Which client made the call (#29); the mods send theirs too. 183210 "x-abso-client": `abso-cli/${clientVersion()}`, 184211 ...(this.config.token && !this.config.visitor ? { authorization: `Bearer ${this.config.token}` } : {}), 212+ // A visitor says nothing about where it's reading from. 213+ ...(this.caller !== undefined && !this.config.visitor ? { [CALLER_HEADER]: this.caller } : {}), 185214 ...(contentType ? { "content-type": contentType } : {}), Lines 220–231 at 318 (were 191–196 at 273)
191220 * and follows no redirect, so nothing it sends goes anywhere it didn't name (headers() adds no sign-in). 193222 send(url: string, init: RequestInit = {}): Promise<Response> { 223+ if (isLocal(this.config.server)) { 224+ const dir = this.config.localStore; 225+ if (dir === undefined) return Promise.reject(new UsageError(NO_STORE)); 226+ this.local ??= localFetch(dir); 227+ return this.local(url, init); 194229 if (!this.config.visitor) return fetch(url, init); 195230 if ((init.method ?? "GET") !== "GET") 196231 return Promise.reject(new ApiError("a folder that reads signed out sends only reads")); Lines 260–267 at 318 (were 225–230 at 273)
225260 signal: AbortSignal.timeout(timeoutMs), 263+ // A local project's refusal (no store, a Node without SQLite) says itself. 264+ if (err instanceof UsageError) throw err; 228265 const e = err as Error; 230267 e.name === "TimeoutError" Lines 295–303 at 318 (were 258–264 at 273)
261− return JSON.parse(text) as T;
298+ const parsed = JSON.parse(text) as T; 263302 throw new ApiError( 264303 `${method} ${path} answered with something that isn't JSON: ${text.slice(0, 300)}`, Lines 1017–1023 at 318 (were 978–984 at 273)
9801019 /** A ticket that opens this agent's news stream once, within a minute (abso 690; news-stream.ts). */ 981− newsTicket(): Promise<{ url: string; protocols: string[]; expiresAt: number }> {
1020+ newsTicket(): Promise<{ url: string; protocols: string[]; expiresAt: number | string }> { 9821021 return this.json("POST", this.agentPath("news/ticket"), {});