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

Compare

+13 −8 in 5 places
Lines 3–11 at 318 (were 3–11 at 20)
33
44import { readFileSync } from "node:fs";
55import { homedir } from "node:os";
6−import { join } from "node:path";
76import { UsageError } from "./args.ts";
87import type { Config } from "./config.ts";
8+import { fromEnv } from "./env-names.ts";
99import { homeFile } from "./state-dir.ts";
1010
1111function originOf(server: string): string {
Lines 16–22 at 318 (were 16–22 at 20)
1616 }
1717}
1818
19−/** The admin token goes only to a server named in AVCS_ADMIN_SERVERS (comma-separated): none is built in. */
19+/** The admin token goes only to a server named in ABSO_ADMIN_SERVERS (comma-separated): none is built in. */
2020export function adminGoesTo(server: string, extra = ""): boolean {
2121 const allowed = [
2222 ...extra
Lines 29–48 at 318 (were 29–43 at 20)
2929}
3030
3131export function adminToken(env: Readonly<Record<string, string | undefined>> = process.env): string {
32− const fromEnv = env.AVCS_ADMIN_TOKEN?.trim();
33− if (fromEnv) return fromEnv;
32+ const fromVar = fromEnv(env, "ADMIN_TOKEN")?.trim();
33+ if (fromVar) return fromVar;
3434 try {
3535 const fromFile = readFileSync(homeFile(homedir(), "admin-token"), "utf8").trim();
3636 if (fromFile) return fromFile;
3737 } catch {}
38− throw new UsageError("abso key needs the admin token in AVCS_ADMIN_TOKEN or ~/.abso/admin-token");
38+ throw new UsageError("abso key needs the admin token in ABSO_ADMIN_TOKEN or ~/.abso/admin-token");
3939}
4040
41+/** What an admin command says each time it uses the admin token, and where it came from. Never the token. */
42+export function adminTokenWords(env: Readonly<Record<string, string | undefined>> = process.env): string {
43+ return `Using the admin token, from ${fromEnv(env, "ADMIN_TOKEN")?.trim() ? "ABSO_ADMIN_TOKEN" : "~/.abso/admin-token"}.`;
44+}
4146function scrub(text: string, secrets: readonly string[]): string {
4247 let out = text.replace(/abso_sk_[A-Za-z0-9_-]+/g, "[redacted]");
4348 for (const secret of secrets) if (secret.length > 0) out = out.split(secret).join("[redacted]");
Lines 50–58 at 318 (were 45–53 at 20)
4550}
4651
4752async function call(config: Config, admin: string, method: "GET" | "POST", path: string): Promise<unknown> {
48− if (!adminGoesTo(config.server, process.env.AVCS_ADMIN_SERVERS))
53+ if (!adminGoesTo(config.server, fromEnv(process.env, "ADMIN_SERVERS")))
4954 throw new UsageError(
50− `abso key will not send the admin token to ${config.server}; AVCS_ADMIN_SERVERS names the servers it may go to`,
55+ `abso key will not send the admin token to ${config.server}; ABSO_ADMIN_SERVERS names the servers it may go to`,
5156 );
5257 const secrets = [admin, config.token ?? ""].filter((s) => s.length > 0);
5358 let response: Response;
Lines 61–67 at 318 (were 56–62 at 20)
5661 method,
5762 headers: {
5863 ...(config.token ? { authorization: `Bearer ${config.token}` } : {}),
59− "x-avcs-admin": admin,
64+ "x-abso-admin": admin,
6065 },
6166 signal: AbortSignal.timeout(30_000),
6267 });
MCP
compare on this site's /mcp
CLI
abso diff 20 318 client/src/key-admin.ts --json
JSON
/christopher/abso-core/compare/20..318?file=client%2Fsrc%2Fkey-admin.ts&format=json