- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/worker/project/project-api.ts?version=100&format=json
197 linesFirst import 99% · infra-split 1%Last change infra-split in version 37, 2 versions changed it
You're reading version 100. The newest is 318, and 5 versions since then changed this file.
1// The calls a server makes into a project, over the engine (#20): answer()
2// in http.ts takes a route to one of these. Any server built on the engine
3// implements them; the hosted Worker's is EngineProject (abso issue 141).
5/** An Edit, a Write or a MultiEdit, as the hook sends it. */
6export type EditBody = {
7 file: string;
8 session?: string;
9 subagent?: string;
10} & ({ old: string; new: string } | { content: string } | { edits: { old: string; new: string }[] });
12/** Files that aren't plain: executable, or a symbolic link to `link` (#27). */
13export type FileModes = Record<string, { exec?: boolean; link?: string | null }>;
15export interface Collision {
16 file: string;
17 yours: { lines: [number, number]; text: string };
18 theirs: { agent: string; message: string; version: number; lines: [number, number]; text: string };
19}
21export interface ProjectCalls {
22 /** blobs (#27): binary files, path -> the SHA-256 of bytes already uploaded to PUT /p/:project/blobs/<sha256>. */
23 init(
24 files: Record<string, string>,
25 modes?: Record<string, { exec?: boolean; link?: string | null }>,
26 blobs?: Record<string, string>,
27 ): { version: number; skipped?: string[] };
28 edit(agent: string, body: EditBody): { ok: true; news: string[] } | { ok: false; reason: "out of step" };
29 record(
30 agent: string,
31 files: Record<string, string | null>,
32 modes?: Record<string, { exec?: boolean; link?: string | null }>,
33 blobs?: Record<string, string>,
34 meta?: { session?: string; subagent?: string; client?: string },
35 ): { ok: true; changed: string[]; news: string[] };
36 publish(
37 agent: string,
38 message: string,
39 asIs?: boolean,
40 ):
41 | { ok: true; version: number; changes?: number }
42 | { ok: true; queued: number; position: number; ahead: number; changes: number }
43 | { ok: false; collisions: unknown[] };
44 sync(agent: string): { version: number; files: Record<string, string | null>; collisions: unknown[] };
45 status(): {
46 version: number;
47 agents: {
48 agent: string;
49 draft?: string | null;
50 base: number;
51 draftChanges: number;
52 files: string[];
53 parked?: { draft: string | null; draftChanges: number }[];
54 }[];
55 drafts?: { name: string; version: number; sharedBase: number; changes: number; agents: string[] }[];
56 };
57 /** Named drafts (#10): move to a named draft, or back to shared with null, parking unpublished changes; carry takes them into a new draft. Answers like a sync. */
58 switchTo(
59 agent: string,
60 name: string | null,
61 carry?: boolean,
62 ): { draft: string | null; version: number; files: Record<string, string | null>; collisions: unknown[] };
63 /** Lands the agent's named draft in shared as one unit. Answers like publish. */
64 land(
65 agent: string,
66 message: string,
67 ): { ok: true; version: number; changes?: number } | { ok: false; collisions: unknown[] };
68 /** Moves the agent's named draft onto shared's newest version. */
69 syncDraft(agent: string): { draft: string; version: number; sharedBase: number };
70 /** Commits pushed to the project's repo with plain git (#8). See the engine's ingest. */
71 ingest(
72 input: {
73 author: string;
74 base: number;
75 commits: {
76 sha: string;
77 message: string;
78 files: Record<string, string>;
79 modes?: FileModes;
80 blobs?: Record<string, string>;
81 }[];
82 },
83 time: number,
84 ): { landed: boolean; version: number; draft: string };
85 /** Shared's files now, for the push out to Artifacts. A link's text is "" and its target is in modes. */
86 /** Shared's text files at an earlier version (#31: pinning a reviewed harness). */
87 filesAt(version: number): Record<string, string>;
88 /** Shared's binary files at `version`: path -> SHA-256. */
89 blobsAt(version: number): Record<string, string>;
90 shared(): {
91 version: number;
92 files: Record<string, string>;
93 modes?: FileModes;
94 blobs?: Record<string, string>;
95 last?: { agent: string; message: string };
96 };
97 /** Whether init has run. */
98 exists(): boolean;
99}
101/** Reading shared's history (slice 2): blame for a file, why for one line. See blame.ts. */
102export interface ProjectHistory {
103 /** draft: a named draft's view (at version); agent: an agent's view now, its unpublished changes included. */
104 blame(file: string, from?: number, to?: number, version?: number, draft?: string, agent?: string): unknown;
105 why(file: string, line: number, draft?: string, agent?: string): unknown;
106 /** Who wrote a folder: its lines counted by author (#41, F33). */
107 folderBlame(folder: string, version?: number, draft?: string, agent?: string): unknown;
108 /** One folder's entries with each one's last change (#41, F2, F34). */
109 tree(folder: string, version?: number, draft?: string | null, agent?: string, authors?: boolean): unknown;
110 /** A path's life: its last change, and the versions that made it and took it out (#41, F10, F30). */
111 pathLife(path: string, version?: number, draft?: string | null): unknown;
112 /** Lines at one version followed by their ids to a later one (#41, F15). */
113 follow(path: string, version: number, from: number, to: number, at?: number, draft?: string | null): unknown;
114 /** An agent's paths for a reader: an unknown agent is not found, and nothing is made (#41, F25). */
115 pathsOf(agent: string): unknown;
116 /** Whether agents' unpublished changes would collide, by the publish rule (#41, F22). */
117 collisions(file?: string, folder?: string): unknown;
118 draftState(name: string): unknown;
119 /** Who is working where: each file, the agents whose drafts touch it, and which lines. */
120 where(): unknown;
121 /** The versions of shared (or a named draft), newest first (#27); follow: a path's history back through abso mv (#41, F27). */
122 log(draft: string | null, limit?: number, path?: string, agent?: string, before?: number, follow?: boolean): unknown;
123 /** The project's events from a log position (#41, the website): reading consumes nothing. */
124 feed(from: number, limit?: number): { next: number; end: number; events: unknown[] };
125 /** How many entries the log holds: what a feed long-poll waits to see grow. */
126 logLength(): number;
127 /** An agent's draft diff for a reader: never creates the agent (#41). */
128 diffOf(agent: string): unknown;
129 /** Every agent with unpublished changes (#41). */
130 drafts(): unknown;
131 /** One change (#44): its start note or draft, versions, files, settles and refusals. */
132 change(id: number): unknown;
133 /** The changes with anything new at or after a log position (#44, "since you last looked"). */
134 changes(since: number, limit: number, before?: number, issue?: number): unknown;
135 /** Move a file in the agent's draft, its lines keeping their ids (#49). */
136 move(agent: string, from: string, to: string): unknown;
137 /** A note on lines, or a reply to one (#44). */
138 note(agent: string, body: Record<string, unknown>): unknown;
139 /** A signed-in person's note from the website (#41); the Worker has checked who it is. No HTTP route. */
140 notePerson(person: { id: string; name: string }, body: Record<string, unknown>): unknown;
141 /** Close a person's own note (#41). No HTTP route. */
142 closeNotePerson(person: { id: string; name: string }, id: number, how: unknown): unknown;
143 /** Close a note; only its writer can (#44). */
144 closeNote(agent: string, id: number, how: unknown): unknown;
145 /** Notes on a file or a change, or only the open ones (#44). */
146 notes(options: { file?: string; change?: number; open?: boolean }): unknown;
147 /** The log position for a time (ms since 1970) or a version of shared (#41). */
148 position(q: { time?: number; version?: number }): { position: number; end: number };
149 /** Shared's versions as authors only, for the website's ribbon (#43). */
150 ribbon(): { version: number; agents: string[]; authors: number[] };
151 /** status and where as they stood with the first `at` log entries (#41, replay). */
152 statusAt(at: number): unknown;
153 whereAt(at: number): unknown;
154 /** Refused publishes and lands, newest first, with counts over all of them. */
155 refusals(agent?: string, limit?: number): unknown;
156 /** A file as it was at a version (#27). */
157 fileAt(path: string, version: number, draft: string | null, agent?: string): unknown;
158 /** Every file that differs between two versions (#27). */
159 compare(from: number, to: number, draft: string | null, agent?: string): unknown;
160 /** One version: who, why, and each file before and after (#27). */
161 show(version: number, draft: string | null, agent?: string): unknown;
162 /** What an agent's unpublished changes do, file by file (#27). */
163 diff(agent: string): unknown;
164 /** A sync whose answer holds every file in the agent's view, as a first sync's does (#37). */
165 syncFull(agent: string, label?: string): unknown;
166 /** The paths in the agent's view now; changes nothing (#37). */
167 agentPaths(agent: string): unknown;
168 /** The paths in shared (or a named draft) at a version, the newest by default (#37). */
169 pathsAt(version?: number, draft?: string | null): unknown;
170 /** Sync to the newest version of shared with a label (#10). */
171 syncTo(agent: string, label: string): unknown;
172 /** Put a label on a version of shared (the newest by default), or take it off. */
173 label(agent: string, name: string, version?: number, remove?: boolean): unknown;
174 /** Every label, with the versions it marks, newest first. */
175 labels(): unknown;
176 /** Correct the message of the agent's newest publish (#27). */
177 amend(agent: string, message: string): unknown;
178 /** Take some versions of a named draft into shared, checked like a land (#27). */
179 pluck(agent: string, draft: string, versions: number[], message: string, withDependencies?: boolean): unknown;
180 /** Drop published versions of shared (#10): a new version whose set leaves them out, with what built on them. */
181 drop(agent: string, versions: number[], message: string, withDependents?: boolean): unknown;
182 /** News for other agents: "Announcement from <agent>: <text>"; `to` defaults to every other agent. */
183 announce(agent: string, text: string, to?: string[], how?: string): { id: number; to: string[] };
184 /** A signed-in person's announcement from the website (#41): the Worker has checked the sender. */
185 announcePerson(person: { id: string; name: string }, text: string, to?: string[]): { id: number; to: string[] };
186 /** What the agent is starting on (#37, #13), or null to take it back; answers who already works on those files. */
187 starting(
188 agent: string,
189 text: string | null,
190 files?: string[],
191 options?: { issue?: unknown; done?: unknown },
192 ): unknown;
193 /** Hands over the news waiting for an agent, once. */
194 news(agent: string): { news: string[] };
195 /** Discard an agent's unpublished changes to some files, or all (#27). */
196 restore(agent: string, files: string[] | null): unknown;
197}