Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 268 to 269

Compare

+44 −2 in 2 places
Lines 6–12 at 269 (were 6–11 at 268)
66import { bool, type Parsed, str, UsageError } from "./args.ts";
77import { type Env, type Output, open, plural } from "./commands.ts";
88import { logNews } from "./folder.ts";
9+import { follow, monitorArgs, type Socket, streamText } from "./news-stream.ts";
910import { newsWithTime } from "./times.ts";
1011
1112export async function runAnnounce(args: Parsed, env: Env): Promise<Output> {
Lines 74–122 at 269 (were 73–80 at 268)
7374 return { text: lines.join("\n"), json: { ...answer } };
7475}
7576
76−export async function runNews(_args: Parsed, env: Env): Promise<Output> {
77− const { root, api } = open(env);
77+export async function runNews(args: Parsed, env: Env): Promise<Output> {
78+ const { root, config, api } = open(env);
79+ if (bool(args, "stream") && bool(args, "follow"))
80+ throw new UsageError("abso news takes --stream or --follow, not both");
81+ if (bool(args, "stream")) {
82+ const ticket = await api.newsTicket();
83+ return {
84+ text: streamText(ticket, config.project, config.agent),
85+ json: { monitor: monitorArgs(ticket, config.project, config.agent), expiresAt: ticket.expiresAt },
86+ };
87+ }
88+ if (bool(args, "follow")) {
89+ let stop = false;
90+ const onInt = () => {
91+ stop = true;
92+ };
93+ process.once("SIGINT", onInt);
94+ try {
95+ const ended = await follow({
96+ mint: () => api.newsTicket(),
97+ connect: (url, protocols) => new WebSocket(url, [...protocols]) as unknown as Socket,
98+ write: (line) => {
99+ logNews(root, [line]);
100+ env.write(`${line.replace(/\r?\n/g, " ")}\n`);
101+ },
102+ note: (line) =>
103+ env.write(`${line}
104+`),
105+ sleep: (ms) => new Promise((ok) => setTimeout(ok, ms)),
106+ now: () => Date.now(),
107+ every: (ms, fn) => {
108+ const t = setInterval(fn, ms);
109+ return () => clearInterval(t);
110+ },
111+ stopped: () => stop,
112+ });
113+ return ended.ended === "refused"
114+ ? { text: `The news stream refused this seat: ${ended.reason}`, json: ended, exit: 2 }
115+ : { text: "", json: ended };
116+ } finally {
117+ process.off("SIGINT", onInt);
118+ }
119+ }
78120 const answer = await api.news();
79121 const news = newsLines(answer.news);
80122 logNews(root, news);
MCP
compare on this site's /mcp
CLI
abso diff 268 269 client/src/announce.ts --json
JSON
/christopher/abso-core/compare/268..269?file=client%2Fsrc%2Fannounce.ts&format=json