{"draft":null,"from":255,"to":256,"files":[{"path":"client/src/api.ts","added":46,"removed":0,"diff":"--- a/client/src/api.ts\n+++ b/client/src/api.ts\n@@ -58,6 +58,10 @@\n \tAttachment,\n \tDraft,\n \tDraftBody,\n+\tGroupEvent,\n+\tGroupShown,\n+\tGroupSummary,\n+\tGroupWrite,\n \tNews as IssueNews,\n \tIssuePage,\n \tIssueRow,\n@@ -685,6 +689,48 @@\n \t\treturn this.#threads(this.#issues(\"POST\", this.agentPath(`reply/${id}`), body));\n \t}\n \n+\t/** A groups call, with a server from before groups named as that rather than a bare 404. */\n+\tasync #groups<T>(call: Promise<T>): Promise<T> {\n+\t\ttry {\n+\t\t\treturn await call;\n+\t\t} catch (err) {\n+\t\t\tif (err instanceof ApiError && err.status === 404 && /no such issues route|reads have no/.test(err.message))\n+\t\t\t\tthrow new ApiError(`${this.config.server} doesn't have groups yet`, 404);\n+\t\t\tthrow err;\n+\t\t}\n+\t}\n+\n+\t/** The project's groups this agent can see. */\n+\tgroupList(): Promise<{ groups: readonly GroupSummary[] }> {\n+\t\treturn this.#groups(this.#issues(\"GET\", this.agentPath(\"groups\")));\n+\t}\n+\n+\t/** One group's settings and roster, by name or id. */\n+\tgroup(ref: string): Promise<GroupShown> {\n+\t\treturn this.#groups(this.#issues(\"GET\", this.agentPath(`group/${encodeURIComponent(ref)}`)));\n+\t}\n+\n+\t/** A page of a group's history, newest first, and the `before` that reads further back (null at the start). */\n+\tgroupEvents(\n+\t\tref: string,\n+\t\tq: { before?: number; limit?: number; kind?: string } = {},\n+\t): Promise<{ events: readonly GroupEvent[]; before: number | null }> {\n+\t\tconst qs = query({ before: q.before, limit: q.limit, kind: q.kind }).toString();\n+\t\treturn this.#groups(\n+\t\t\tthis.#issues(\"GET\", this.agentPath(`group/${encodeURIComponent(ref)}/events${qs ? `?${qs}` : \"\"}`)),\n+\t\t);\n+\t}\n+\n+\t/** Make a group (ref undefined), or post, join, leave, add, remove or change settings in one. */\n+\tgroupWrite(\n+\t\tref: string | undefined,\n+\t\taction: \"post\" | \"join\" | \"leave\" | \"add\" | \"remove\" | \"settings\" | undefined,\n+\t\tbody: Record<string, unknown>,\n+\t): Promise<GroupWrite> {\n+\t\tconst path = ref === undefined ? \"groups\" : `group/${encodeURIComponent(ref)}/${action}`;\n+\t\treturn this.#groups(this.#issues(\"POST\", this.agentPath(path), body));\n+\t}\n+\n \t/** Takes back an ask this agent made, with a note on why; the one asked hears it. */\n \twithdraw(id: number, body: { note?: string }): Promise<{ ask: Ask; news?: IssueNews }> {\n \t\treturn this.#issues(\"POST\", this.agentPath(`withdraw/${id}`), body);"}],"unmatched":[]}