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 267 to 268

Compare

+26 −5 in 5 places
Lines 48–58 at 268 (were 48–54 at 267)
4848 }
4949}
5050
51−export function readConfig(root: string, env: Readonly<Record<string, string | undefined>> = process.env): Config {
51+export function readConfig(
52+ root: string,
53+ env: Readonly<Record<string, string | undefined>> = process.env,
54+ tokenFileOk = true,
55+): Config {
5256 const raw = JSON.parse(readFileSync(configPath(root), "utf8")) as Partial<Settings>;
5357 if (raw.visitor === true) {
5458 for (const key of ["server", "project"] as const) {
Lines 64–70 at 268 (were 60–66 at 267)
6064 for (const key of ["server", "project", "agent"] as const) {
6165 if (typeof raw[key] !== "string" || raw[key] === "") throw new Error(`${configPath(root)} has no "${key}"`);
6266 }
63− const token = tokenFor(raw.server!, env, root);
67+ const token = tokenFor(raw.server!, env, root, tokenFileOk);
6468 return {
6569 server: raw.server!,
6670 project: raw.project!,
Lines 182–188 at 268 (were 178–183 at 267)
178182 server: string,
179183 env: Readonly<Record<string, string | undefined>> = process.env,
180184 root?: string,
185+ tokenFileOk = true,
181186): string | undefined {
182187 if (root) {
183188 const key = readKeyFile(root);
Lines 192–211 at 268 (were 187–195 at 267)
187192 return key.key;
188193 }
189194 }
190− const token = fromEnv(env, "TOKEN")?.trim() || runKey(env) || readToken(env);
191− const trusted = trustedServers(env);
192− if (token === undefined || tokenGoesTo(server, trusted)) return token;
195+ return trustedToken(
196+ server,
197+ env,
198+ fromEnv(env, "TOKEN")?.trim() || runKey(env) || (tokenFileOk ? readToken(env) : undefined),
199+ );
200+}
202+/** The token as given, if abso may send it to this server; refused, in words, if not. */
203+export function trustedToken(
204+ server: string,
205+ env: Readonly<Record<string, string | undefined>>,
206+ token: string | undefined,
207+): string | undefined {
208+ if (token === undefined || tokenGoesTo(server, trustedServers(env))) return token;
193209 throw new UsageError(
194210 `this folder's server is ${server}, and abso sends your token only to ${[...TOKEN_SERVERS, "this machine"].join(", ")}, and the servers ~/.abso/servers.json or ABSO_TRUSTED_SERVERS name. ` +
195211 `If ${server} is yours, name it in ~/.abso/servers.json or ABSO_TRUSTED_SERVERS (comma-separated); if you didn't set it, someone else wrote .abso/config.json.`,
Lines 251–261 at 268 (were 235–240 at 267)
235251 return key;
236252}
237253
254+/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. abso init and join read it only with --token-file. */
255+export function tokenFile(): string | undefined {
256+ return readToken({});
257+}
238259/** ABSO_TOKEN if set, else ~/.abso/token, else ~/.avcs/token, else none. */
239260export function readToken(env: Readonly<Record<string, string | undefined>> = process.env): string | undefined {
240261 const fromVar = fromEnv(env, "TOKEN");
MCP
compare on this site's /mcp
CLI
abso diff 267 268 client/src/config.ts --json
JSON
/christopher/abso-core/compare/267..268?file=client%2Fsrc%2Fconfig.ts&format=json