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
MCP
blame on this site's /mcp
CLI
abso blame client/src/orgs.ts --json
JSON
/christopher/abso-core/blame/client/src/orgs.ts?format=json
186 linespinch 88% · box-grants 12%Last change box-grants in version 185,

186 lines from 3 changes in 2 versions.

pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare1// Organizations from the CLI: abso orgs and abso org <name>. They read as the
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare2// person who approved this box's sign-in (abso login). abso org new makes one, and
3// abso init --org makes a project in one, from a box approved for all its
4// person's projects (abso 663). Changing an org (invite, role, remove, leave,
5// settings) stays on the website: a box sits where agents run, so the server takes
6// no other org change from it.
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare7
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare8import { type Parsed, str, UsageError } from "./args.ts";
9import { type Answer, boxCreateOrg, boxGet, originOf, readBox } from "./box.ts";
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare10import type { Output } from "./commands.ts";
12/** The website for an API server: api.<site> serves <site>; any other server serves its own pages. */
13export function siteOf(server: string): string {
14 try {
15 const url = new URL(server);
16 if (url.hostname.startsWith("api.")) url.hostname = url.hostname.slice("api.".length);
17 return url.origin;
18 } catch {
19 return server;
20 }
23/** The flags that change an org, in the order Design wrote them; each names where the website does it. */
24const CHANGES: readonly { flag: string; tab: string }[] = [
25 { flag: "invite", tab: "People" },
26 { flag: "role", tab: "People" },
27 { flag: "remove", tab: "People" },
28 { flag: "leave", tab: "People" },
29 { flag: "members", tab: "Settings" },
30 { flag: "projects-by", tab: "Settings" },
31];
33const WEBSITE_ONLY =
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare34 "Organizations are changed on the website; from the CLI they can be read, and made with abso org new, as the person who approved this box's sign-in";
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare35
36/** Where the box's sign-in is read from and how the server is reached; tests pass their own. */
37export interface OrgIo {
38 readonly home?: string;
39 readonly fetch?: typeof fetch;
42async function read(server: string, path: string, io: OrgIo): Promise<Answer> {
43 const record = io.home === undefined ? readBox(server) : readBox(server, io.home);
44 if (!record)
45 throw new UsageError(
46 `this box isn't signed in to ${originOf(server)}. abso login signs it in; org reads answer as the person who approves it`,
47 );
48 return boxGet(record, path, io.fetch);
51/** What a refusal from an org read means, in words. */
52function refused(a: Answer, what: string, server: string): UsageError {
53 const said = typeof a.body.error === "string" ? a.body.error : `status ${a.status}`;
54 if (a.status === 401)
55 return new UsageError(`${originOf(server)} didn't take this box's sign-in (${said}). abso login renews it`);
56 if (a.status === 404 && /aren't on here/.test(said)) return new UsageError(`${originOf(server)}: ${said}`);
57 if (a.status === 404) return new UsageError(`${what}: ${said}`);
58 return new UsageError(`${originOf(server)} refused ${what} (${a.status}): ${said}`);
61const when = (iso: unknown) => (typeof iso === "string" ? `${iso.slice(0, 16).replace("T", " ")} UTC` : "?");
63interface OrgRow {
64 name: string;
65 displayName: string;
66 role: string;
68interface Invitation {
69 id: string;
70 org: string;
71 role: string;
72 expiresAt: string;
75/** abso orgs: your organizations, your role in each, and invitations waiting for you. */
76export async function runOrgs(server: string, io: OrgIo = {}): Promise<Output> {
77 const a = await read(server, "/orgs", io);
78 if (a.status !== 200) throw refused(a, "the list of your organizations", server);
79 const orgs = (a.body.orgs ?? []) as OrgRow[];
80 const invitations = (a.body.invitations ?? []) as Invitation[];
81 const lines =
82 orgs.length === 0
83 ? ["You're in no organizations."]
84 : [
85 `Your organizations (${orgs.length}):`,
86 ...orgs.map(
87 (o) => ` ${o.name}${o.displayName && o.displayName !== o.name ? ` (${o.displayName})` : ""}: ${o.role}`,
88 ),
89 ];
90 if (invitations.length > 0)
91 lines.push(
92 "Invited to:",
93 ...invitations.map((i) => ` ${i.org} as ${i.role}, until ${when(i.expiresAt)}`),
94 `Accept them on the website, signed in: ${siteOf(server)}.`,
95 );
96 return { text: lines.join("\n"), json: { orgs, invitations } };
99interface Member {
100 id: string;
101 role: string;
102 name: string | null;
103 raised?: { project: string; role: string }[];
105interface Invite {
106 id: string;
107 role: string;
108 kind: "link" | "person";
109 expiresAt: string;
112/** abso org <name>, abso org new <name>, and the change flags, which say where the website does each. */
113export async function runOrg(args: Parsed, server: string, io: OrgIo = {}): Promise<Output> {
114 const [first, second, ...more] = args.positionals;
115 const asked = CHANGES.filter((c) => args.flags.has(c.flag));
116 if (first === "new") {
117 if (second === undefined || more.length > 0) throw new UsageError('abso org new <name> [--name "<shown name>"]');
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare118 if (asked.length > 0) throw new UsageError("abso org new takes --name only");
119 const record = io.home === undefined ? readBox(server) : readBox(server, io.home);
120 if (!record)
121 throw new UsageError(
122 `this box isn't signed in to ${originOf(server)}. abso login signs it in; approve all your projects to make organizations from here`,
123 );
124 const made = await boxCreateOrg(record, second, str(args, "name"), io.fetch);
125 const name = typeof made.name === "string" ? made.name : second;
126 return {
127 text: `Made the organization ${name}; you own it. Its page: ${siteOf(server)}/${name}. abso init --org ${name} --project <name> makes a project in it.`,
128 json: { org: made },
129 };
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare130 }
131 if (first === undefined || second !== undefined)
132 throw new UsageError("abso org <name> [one change], or abso org new <name>");
133 if (args.flags.has("as") && !args.flags.has("invite")) throw new UsageError("--as goes with --invite");
134 if (asked.length > 1)
135 throw new UsageError(`one change at a time: --${asked.map((c) => c.flag).join(" and --")} were given together`);
136 if (asked.length === 1)
137 throw new UsageError(
138 `${WEBSITE_ONLY}. --${asked[0]!.flag} is on ${first}'s ${asked[0]!.tab} tab: ${siteOf(server)}/${first}.`,
139 );
141 const a = await read(server, `/orgs/${encodeURIComponent(first)}`, io);
142 if (a.status !== 200) throw refused(a, first, server);
143 const org = a.body as {
144 name: string;
145 displayName: string;
146 description: string | null;
147 role?: string;
148 membersCan?: string;
149 whoMakesProjects?: string;
150 members?: Member[];
151 projects?: string[];
152 invites?: Invite[];
153 };
154 const lines = [`${org.name}${org.displayName && org.displayName !== org.name ? ` (${org.displayName})` : ""}`];
155 if (org.description) lines.push(` ${org.description.replace(/\r?\n/g, "\n ")}`);
156 if (org.role === undefined) {
157 lines.push("You aren't a member, so its people and settings aren't shown.");
158 return { text: lines.join("\n"), json: { org } };
159 }
160 lines.push(
161 `You're ${org.role === "owner" ? "an owner" : "a member"}. Members can ${org.membersCan ?? "?"} every project; ${org.whoMakesProjects === "owners" ? "only owners make" : "members make"} projects.`,
162 );
163 const projects = org.projects ?? [];
164 lines.push(projects.length === 0 ? "Projects: none yet." : `Projects (${projects.length}): ${projects.join(", ")}`);
165 const members = org.members ?? [];
166 lines.push(`People (${members.length}):`);
167 for (const m of members) {
168 const raised = (m.raised ?? []).map((r) => `${r.role} in ${r.project}`);
169 lines.push(
170 ` ${m.name ?? "(no name yet)"}: ${m.role}${raised.length > 0 ? `, raised to ${raised.join(", ")}` : ""}`,
171 );
172 }
173 if (org.invites !== undefined && org.invites.length > 0) {
174 lines.push("Open invites:");
175 for (const i of org.invites)
176 lines.push(` ${i.kind === "link" ? "a link" : "a person, by name"}, as ${i.role}, until ${when(i.expiresAt)}`);
177 }
178 return { text: lines.join("\n"), json: { org } };
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare181/** abso init --org with no box signed in to the server: an org's project is made as the person who approved one (abso 663). */
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare182export function initInOrg(org: string, server: string): never {
183 throw new UsageError(
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare184 `this box isn't signed in to ${originOf(server)}, and a project in ${org} is made as a signed-in person. abso login, approving all your projects, then abso init --org ${org} again; or New project at ${siteOf(server)}.`,
pinch34Client: abso orgs and abso org <name>, reading as the person who approved this box's sign-in (abso login): your organizations and roles, invitations waiting for you, and an org's projects, people (by name, never id), settings and open invites. Changes (--invite, --role, --remove, --leave, --members, --projects-by), abso org new and abso init --org are made on the website for now; each says where and sends nothing. One change at a time. MCP serves orgs and org. Client tests 283/283, tsc and biome clean.Compare185 );