- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/client/src/api-answers.ts?format=json
228 linesFirst import 86% · autosettle 10% · speed 2% · engine 1% · onboard 1% · infra-split 1%Last change onboard in version 225, 8 versions changed it
1// What the server answers for recording, publishing, syncing, notes and status.
3import type { CiStatus, QueueState } from "./ci-answers.ts";
4import type { Modes } from "./modes.ts";
6/** A collision as publish and sync report it. */
7export interface Collision {
8 /**
9 * `lines`: both changed the same lines. `definition`: your draft uses `name`, whose definition they changed.
10 * `attribute`: both set `name` (exec or link). `duplicate`: you and they each define `name` at the top level of `file`.
11 */
12 readonly kind?: "lines" | "definition" | "attribute" | "duplicate";
13 /** A lines collision you synced into and haven't edited since (#37): both sides' lines are in your file. */
14 readonly untouched?: true;
15 /** A lines collision written into the file as a marker block (#11): `lines` is the block's range there. */
16 readonly marked?: true;
17 readonly lines?: readonly [number, number];
18 readonly name?: string;
19 readonly file: string;
20 readonly yours: { readonly lines: unknown; readonly text: string };
21 /** For a definition, `file` is where the definition is, and `text` is "" when it's gone. */
22 readonly theirs: {
23 readonly file?: string;
24 readonly agent: string;
25 readonly message: string;
26 readonly version: number;
27 readonly lines: unknown;
28 readonly text: string;
29 /** Theirs is waiting in the merge queue, not landed yet (#39): its queue id. */
30 readonly queued?: number;
31 };
32}
34/** News arrives as one plain sentence per collision; accept a single string too. */
35export type News = string | readonly string[] | undefined;
37export interface EditBody {
38 readonly file: string;
39 readonly old?: string;
40 readonly new?: string;
41 readonly content?: string;
42 readonly edits?: readonly { readonly old: string; readonly new: string }[];
43 readonly session?: string;
44 readonly subagent?: string;
45}
47/** A path recorded under another spelling of an existing file (#49): one file whatever its case. */
48export interface Spelling {
49 readonly path: string;
50 readonly existing: string;
51}
52export type EditAnswer =
53 | { ok: true; news?: News; spelling?: readonly Spelling[]; uncomposed?: readonly string[] }
54 | { ok: false; reason: string };
55/** A marker block still in an agent's draft (#11). */
56export interface OpenCollision {
57 readonly file: string;
58 readonly lines: readonly [number, number];
59 readonly theirs: { readonly agent: string; readonly version: number; readonly message: string };
60}
61/** What a publish settled, file by file, and which side survived (#11). */
62export interface Settled {
63 readonly file: string;
64 readonly kept: "yours" | "theirs" | "both" | "rewrote";
65 readonly theirs: { readonly agent: string; readonly version: number };
66 /** Lines both sides still had that the settled file no longer has (#37). */
67 readonly lost?: readonly string[];
68 /** The message of the settler's push that was held for this collision. */
69 readonly held?: string;
70}
71export interface RecordAnswer {
72 readonly ok: boolean;
73 readonly changed?: readonly string[] | number;
74 readonly news?: News;
75 readonly reason?: string;
76 readonly spelling?: readonly Spelling[];
77 /** New names not in composed Unicode form (#49): a gentle warning. */
78 readonly uncomposed?: readonly string[];
79}
80export type PublishAnswer =
81 | {
82 ok: true;
83 version: number;
84 changes?: number;
85 settled?: readonly Settled[];
86 /** Others' versions this publish went on top of that the folder hasn't synced yet (#37): nothing of theirs was overwritten. */
87 mergedWith?: readonly { readonly version: number; readonly agent: string; readonly message: string }[];
88 /** Where the project's CI runs, when the server says: off, the project's own Cloudflare account, or the server's own compute. */
89 ciWhere?: string;
90 }
91 /** With the merge queue on (#39): queued, not landed yet; `ahead` publishes wait in front of it. */
92 | { ok: true; queued: number; position: number; ahead: number; changes: number; settled?: readonly Settled[] }
93 | {
94 ok: false;
95 collisions: readonly Collision[];
96 reason?: string;
97 advice?: readonly (Advice | null)[];
98 /** The server runs AUTOSETTLE=act: settle the collisions it advised a side of, and push again (#19). */
99 settle?: boolean;
100 };
101/**
102 * A server's first opinion on one collision of a held push (#19), when it runs AUTOSETTLE: which settle fits,
103 * how sure, and why. `by`: rule (code decided), model (Workers AI), turned down (the model's pick would break
104 * the file, so an agent settles), or unsure (the model leaned to a side under the server's threshold).
105 */
106export interface Advice {
107 readonly pick: "yours" | "theirs" | "both" | "agent";
108 readonly confidence: number;
109 readonly reason: string;
110 readonly by: "rule" | "model" | "turned down" | "unsure";
111 readonly modelPick?: string;
112 readonly model?: string;
113 readonly ms: number;
114}
115/** A note on lines (#44): where its lines are now, or null when they're all gone. */
116export interface NoteAnswer {
117 readonly id: number;
118 readonly agent: string;
119 readonly kind: "comment" | "objection" | "read";
120 readonly file: string;
121 readonly lines: readonly [number, number] | null;
122 readonly text: string;
123 readonly change: number | null;
124 readonly reply: number | null;
125 readonly time: number;
126 readonly state: "open" | "addressed" | "outdated" | "resolved" | "withdrawn";
127}
128/** One change (#44): a start note's work, a named draft's, or a lone publish. Its id is the log position that began it. */
129export interface ChangeAnswer {
130 readonly id: number;
131 readonly agent: string;
132 readonly title: string;
133 readonly kind: "note" | "draft" | "publish";
134 readonly note: { readonly text: string; readonly files: readonly string[] } | null;
135 readonly draft: string | null;
136 readonly time: number;
137 /** Its start note still lasts, or its draft hasn't landed: more versions may come. */
138 readonly open: boolean;
139 readonly versions: readonly {
140 readonly version: number;
141 readonly draft: string | null;
142 readonly message: string;
143 readonly time: number;
144 readonly files: readonly string[];
145 }[];
146 readonly files: readonly string[];
147 readonly settled: readonly (Settled & { readonly version: number })[];
148 readonly refusals: readonly {
149 readonly time: number;
150 readonly kinds: readonly string[];
151 readonly files: readonly string[];
152 /** A held push's message. */
153 readonly message?: string;
154 }[];
155 readonly notes?: readonly NoteAnswer[];
156 readonly reviewers?: readonly { readonly agent: string; readonly files: readonly string[]; readonly read: boolean }[];
157}
158/** The body of a note: on lines, or a reply to one. */
159export type NoteBody =
160 | {
161 readonly file: string;
162 readonly from: number;
163 readonly to: number;
164 readonly text: string;
165 readonly kind?: "comment" | "objection" | "read";
166 readonly of?: string;
167 readonly version?: number;
168 }
169 | { readonly reply: number; readonly text: string };
171export interface SyncAnswer {
172 readonly version: number;
173 readonly files: Readonly<Record<string, string | null>>;
174 /** Files whose executable bit or link changed: {exec, link}. */
175 readonly modes?: Modes;
176 /** Binary files whose bytes changed: path -> sha256, or null when the file is no longer binary. */
177 readonly blobs?: Readonly<Record<string, string | null>>;
178 readonly collisions?: readonly Collision[];
179 /** Lines both sides changed that sync merged item by item (a one-line list both added to): not collisions, but worth a look (#37). */
180 readonly merged?: readonly MergedLine[];
181}
182export interface MergedLine {
183 readonly file: string;
184 readonly line: number;
185 readonly text: string;
186 readonly theirs: { readonly agent: string; readonly message: string; readonly version: number };
187}
188export interface StatusAnswer {
189 readonly version: number;
190 readonly agents: readonly {
191 readonly agent: string;
192 /** The named draft it works in, or null (or absent) for shared. */
193 readonly draft?: string | null;
194 readonly base: number | null;
195 readonly draftChanges: number;
196 readonly files: readonly string[] | number;
197 /** Unpublished work it left parked in other spaces. */
198 readonly parked?: readonly { readonly draft: string | null; readonly draftChanges: number }[];
199 /** Marker blocks still in its draft (#11): collisions to settle. */
200 readonly collisions?: readonly OpenCollision[];
201 /** It reads and records nothing (#37). */
202 readonly reader?: true;
203 /** Its publishes waiting in the merge queue (#39). */
204 readonly queued?: readonly number[];
205 }[];
206 readonly drafts?: readonly {
207 readonly name: string;
208 readonly version: number;
209 readonly sharedBase: number;
210 readonly changes: number;
211 readonly agents: readonly string[];
212 }[];
213 /** The project's CI (#39); absent from servers without it. */
214 readonly ci?: CiStatus;
215 /** The merge queue (#39), while anything waits or it's paused. */
216 readonly queue?: QueueState | null;
217 /** Only when shared has both project files: abso.json counts, avcs.json is ignored. */
218 readonly projectFile?: { readonly used: string; readonly ignored: string };
219}
220/** `POST /a/:agent/draft` answers like a sync, naming the space the agent is now in. */
221export interface SwitchAnswer extends SyncAnswer {
222 readonly draft: string | null;
223}
224export interface DraftSyncAnswer {
225 readonly draft: string;
226 readonly version: number;
227 readonly sharedBase: number;
228}