Versions 203 to 318
new file, 204 lines
3+// The server holds a WebSocket per seat on the project's object. Opening one takes a ticket, minted with the seat's
4+// key: it opens that seat's stream once, within a minute, and rides as a subprotocol, never in the URL. A Claude Code
5+// Monitor can't send headers, and whatever its call names is written into the chat, so the key never goes there.
7+// --stream prints the Monitor's arguments with a fresh ticket. --follow holds the socket itself and prints a line per
8+// item, opening a new one (with a new ticket) whenever it closes; the ticket is never printed. On connect the server
10+
11+/** The subprotocol a news stream speaks; the ticket rides beside it as `abso-ticket.<ticket>`. */
13+
21+
22+/** A ticket's expiry in milliseconds, whichever form the server sent; now when it can't be read. */
24+ const at = typeof ticket.expiresAt === "number" ? ticket.expiresAt : Date.parse(ticket.expiresAt);
27+
30+
43+
45+export function streamText(ticket: NewsTicket, project: string, agent: string, now = Date.now()): string {
48+ `Open this with Monitor within ${seconds} seconds (the ticket opens ${agent}'s news stream once). When the Monitor ends or the socket closes, run abso news --stream again; the new socket sends what arrived in between.`,
52+
53+/** The file that says this folder's seat holds its stream, until when: the abso-hooks mod's news poll skips meanwhile. */
55+
56+/** How long --stream's mark holds: the Monitor's 30 minutes, and the minute the ticket waits to be used. */
60+
70+
71+/** A close the server sends for a revoked key or a fifth socket (1008): --follow stops instead of trying again. */
75+
76+/** How long --follow waits before opening a socket again: 1 s doubling to a minute; a socket that lived a minute resets it. */
81+
82+/** The client sends this every PING_MS so an idle socket stays open; the object answers it without waking. */
86+
97+ /** Reads the seat's news, marking it heard (POST news); a frame calls it. Without it, frames are printed as they come. */
99+ /** Called when a socket opens and at each ping: the stream is held until the next ping is due, and a little more. */
104+
105+/** Why a mint failed: a refused key, or a server with no news stream (404), stops --follow; anything else is tried again. */
110+
112+ * A frame is a wake (abso 690): on one, read the seat's news (which marks it heard) and print what that answers, one
113+ * read at a time, with frames that arrive meanwhile folded into one more read. When the read answers nothing (a server
114+ * that counts a frame as heard already, or another chat on the seat took it first), the frames themselves are printed.
136+ deps.note(`(abso news --follow: couldn't read the news: ${(err as Error).message}; showing the frames)`);
139+ // A frame the read didn't cover still shows: on a server that counts a frame as heard, its item never comes back
140+ // from the read. A catch-up frame names several items, so a frame holding a shown item counts as covered.
141+ for (const frame of these) if (!shown.some((line) => frame.includes(line) || line.includes(frame))) show(frame);
154+
156+ * Holds the seat's stream, printing one line per item, until the key is refused or `stopped()`.
159+export async function follow(deps: FollowDeps): Promise<{ ended: "refused" | "stopped"; reason: string }> {
168+ deps.note(`(abso news --follow: no ticket: ${(err as Error).message}; trying again in ${wait / 1000} s)`);
198+ if (isRefusal(closed.code)) return { ended: "refused", reason: closed.reason || `closed ${closed.code}` };
- MCP
- compare on this site's /mcp
- CLI
- abso diff 203 318 client/src/news-stream.ts --json
- JSON
- /christopher/abso-core/compare/203..318?file=client%2Fsrc%2Fnews-stream.ts&format=json