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 99 to 318

Compare

+31 −5 in 3 places
Lines 107–128 at 318 (were 107–112 at 99)
107107}
108108
109109/**
110+ * A server's base: its origin and any path, without a trailing slash (https://x.example/issues), or undefined
111+ * for anything else, a query, a fragment or a user name included. Plain string work, as serverOrigin.
112+ */
113+export function serverBase(s: string): string | undefined {
114+ const m = /^(https?):\/\/([^/?#\\]+)((?:\/[^?#\\]*)?)$/i.exec(s.trim());
115+ if (!m || m[2]!.includes("@")) return undefined;
116+ return `${m[1]!.toLowerCase()}://${m[2]!.toLowerCase()}${m[3]!.replace(/\/+$/, "")}`;
117+}
119+/** The origin of a server given with or without a path (serverBase), or undefined. */
120+export function baseOrigin(s: string): string | undefined {
121+ const base = serverBase(s);
122+ return base === undefined ? undefined : serverOrigin(base.replace(/^(https?:\/\/[^/]+).*$/i, "$1"));
123+}
125+/**
110126 * This machine's servers, from ~/.abso/servers.json:
111127 * {"servers": {"<server>": {"issues": "<its Issues Worker>"}}}. Each server
112128 * named there, and each Issues Worker it names, may receive the token, and a
Lines 146–155 at 318 (were 130–139 at 99)
130146 if (o === undefined) continue;
131147 trusted.push(o);
132148 const i = (about as { issues?: unknown } | null)?.issues;
133− const io = typeof i === "string" ? serverOrigin(i) : undefined;
149+ const io = typeof i === "string" ? serverBase(i) : undefined;
134150 if (io !== undefined) {
135151 issues[o] = io;
136− trusted.push(io);
152+ trusted.push(baseOrigin(io)!);
137153 }
138154 }
139155 } catch {}
Lines 162–185 at 318 (were 146–159 at 99)
146162}
147163
148164/**
149− * The Issues Worker beside an avcs server (#54): this machine's servers.json
150− * first, then abso's own. ABSO_ISSUES_SERVER overrides both (issues.ts).
165+ * The Issues Worker beside an avcs server: this machine's servers.json
166+ * first, then abso's own, else the server's own /issues, where the open
167+ * server keeps them. ABSO_ISSUES_SERVER overrides all three (issues.ts).
151168 */
152169export function issuesServerFor(server: string, machine?: MachineServers): string | undefined {
153170 const o = serverOrigin(server);
154− return o === undefined ? undefined : (machine?.issues[o] ?? ISSUES_SERVERS[o]);
171+ return o === undefined ? undefined : (machine?.issues[o] ?? ISSUES_SERVERS[o] ?? `${o}/issues`);
155172}
156173
174+/**
175+ * Whether the token may go to an Issues Worker: as to its origin (tokenGoesTo), since it may sit at a path on
176+ * its server, as the open server's do at <server>/issues. A query, a fragment or a user name is refused.
177+ */
178+export function tokenGoesToIssues(server: string, trusted?: string): boolean {
179+ const o = baseOrigin(server);
180+ return o !== undefined && tokenGoesTo(o, trusted);
181+}
157183/** Whether the token may go to `server`: TOKEN_SERVERS, `trusted` (trustedList), or this machine. Plain string work: the mod has no URL. */
158184export function tokenGoesTo(server: string, trusted?: string): boolean {
159185 const origin = serverOrigin;
MCP
compare on this site's /mcp
CLI
abso diff 99 318 client/src/core.ts --json
JSON
/christopher/abso-core/compare/99..318?file=client%2Fsrc%2Fcore.ts&format=json