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 62 to 63

Compare

+44 −0 in 1 place
Lines 277–326 at 63 (were 277–282 at 62)
277277 return { key, id };
278278}
279279
280+/** The agent name abso join takes when none is given (abso issue 351): the box's name, lower-cased. */
281+export function defaultAgentName(): string {
282+ return boxName().toLowerCase();
283+}
285+/**
286+ * abso join with no --agent (abso issue 351): mints a key under `base`, else `base`-2, -3 and so on. Names this
287+ * box already holds in the project are skipped without asking, since minting one again would replace that agent's
288+ * key and cut off its folder. A name the server says is taken (409) moves on to the next; any other refusal, the
289+ * box's agent limit among them, is said as it is.
290+ */
291+export async function mintFreeName(
292+ record: BoxRecord,
293+ project: string,
294+ base: string,
295+ fetcher: typeof fetch = fetch,
296+ tries = 20,
297+): Promise<{ key: string; id: string; agent: string }> {
298+ const box = await boxGet(record, "/box", fetcher);
299+ if (box.status !== 200)
300+ throw new UsageError(
301+ `${originOf(record.server)} refused (${box.status}): ${String(box.body.error ?? "no reason given")}`,
302+ );
303+ const agents = Array.isArray(box.body.agents) ? (box.body.agents as { project?: unknown; agent?: unknown }[]) : [];
304+ const held = new Set(agents.filter((a) => a.project === project).map((a) => String(a.agent)));
305+ for (let n = 1; n <= tries; n++) {
306+ const agent = n === 1 ? base : `${base}-${n}`;
307+ if (held.has(agent)) continue;
308+ try {
309+ return { ...(await mintKey(record, project, agent, fetcher)), agent };
310+ } catch (err) {
311+ if (err instanceof UsageError && /refused \(409\): that agent name/.test(err.message)) continue;
312+ if (err instanceof UsageError && /refused \(409\): this box is at its agent limit/.test(err.message))
313+ throw new UsageError(
314+ `this box is at its agent limit (${record.grant.max_agents}): abso box shows its grant, and an agent can be revoked on the website's Boxes page`,
315+ );
316+ throw err;
317+ }
318+ }
319+ throw new UsageError(
320+ `${base} through ${base}-${tries} are all taken in ${project}: give this agent a name with --agent <name>`,
321+ );
322+}
280324/** Ends the box on the server, then forgets it here. Forgets it even when the server can't be reached. */
281325export async function logout(record: BoxRecord, fetcher: typeof fetch = fetch, home = homedir()): Promise<boolean> {
282326 let ended = true;
MCP
compare on this site's /mcp
CLI
abso diff 62 63 client/src/box.ts --json
JSON
/christopher/abso-core/compare/62..63?file=client%2Fsrc%2Fbox.ts&format=json