@camox/api-contract 0.76.0 → 0.76.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/router.d.ts +629 -411
  2. package/package.json +1 -1
package/dist/router.d.ts CHANGED
@@ -7,8 +7,6 @@ import { WebSockets } from "agents/websockets";
7
7
  import "@earendil-works/pi-ai";
8
8
  import "@earendil-works/pi-ai/models";
9
9
  import "@earendil-works/pi-durable/tools";
10
- import { FileErrorCode } from "@earendil-works/pi-durable/env";
11
- import "camox/_internal/sdkBundleName";
12
10
  import "@camox/ai-tools";
13
11
  import { AgentEvent } from "@earendil-works/pi-durable";
14
12
  import "effect";
@@ -18,6 +16,8 @@ import "drizzle-orm";
18
16
  import "drizzle-orm/sqlite-core";
19
17
  import { SpecialistId } from "@camox/api-contract/specialists";
20
18
  import { DrizzleD1Database } from "drizzle-orm/d1";
19
+ import { FileErrorCode } from "@earendil-works/pi-durable/env";
20
+ import { SdkBundleNames } from "camox/_internal/sdkBundleName";
21
21
  import { CIWorkflow, CiContext, CiParams, CloudflareArtifacts } from "@cloudflare/ci";
22
22
  import { CiBindings } from "@cloudflare/ci/worker";
23
23
  import { ProjectRoomMessage } from "@camox/api-contract/query-keys";
@@ -233,34 +233,6 @@ type Attachment = typeof attachments.$inferSelect;
233
233
  */
234
234
  type MessageAttachment = Pick<Attachment, "id" | "filename" | "mimeType" | "url" | "blobKey">;
235
235
  //#endregion
236
- //#region ../../apps/api/src/domains/code/remote-env.d.ts
237
- /** The operations sent as they are: every argument but the context is plain data. */
238
- declare const SENT: ["absolutePath", "joinPath", "readTextFile", "readTextLines", "readBinaryFile", "writeFile", "appendFile", "truncateFile", "flushFile", "renameFile", "fileInfo", "listDir", "canonicalPath", "exists", "createDir", "remove"];
239
- /** What a remote environment asks of the one it reaches. */
240
- type EnvCall = {
241
- operation: (typeof SENT)[number];
242
- args: unknown[];
243
- } |
244
- /** Opens a binary reader there and reads the whole file it opened. */
245
- {
246
- operation: "openBinaryReader";
247
- args: [path: string, options?: {
248
- noFollow?: boolean;
249
- }];
250
- };
251
- /** An operation's result as it crosses: its value, or its error as plain data. */
252
- type EnvAnswer = {
253
- ok: true;
254
- value: unknown;
255
- } | {
256
- ok: false;
257
- error: {
258
- code: FileErrorCode;
259
- message: string;
260
- path?: string;
261
- };
262
- };
263
- //#endregion
264
236
  //#region ../../apps/api/src/domains/revisions/result.d.ts
265
237
  /** A revision's ID: a UUIDv7. */
266
238
  type RevisionId = string;
@@ -301,347 +273,19 @@ type BuildResult = {
301
273
  };
302
274
  };
303
275
  //#endregion
304
- //#region ../../apps/api/src/lib/timing.d.ts
305
- /** What a span's line says beside its name and duration. Undefined fields are left out. */
306
- type SpanFields = Record<string, string | number | boolean | null | undefined>;
307
- //#endregion
308
- //#region ../../apps/api/src/durable-objects/draft-code.d.ts
309
- /** A revision of the draft whose build goes up as its publish script. */
310
- type PublishUpload = {
311
- /** The project's Project ID. */
312
- project: string;
313
- revision: string;
314
- /** Its build in `REVISION_BUILDS`. */
315
- archiveKey: string;
316
- };
317
- /** A commit `prepareCommit` made, not on the branch yet. */
318
- type PreparedCommit = {
319
- commit: string;
320
- tree: string;
321
- /** The tree's files, as a tar archive. */
322
- files: Uint8Array;
323
- /** The tree's `pnpm-lock.yaml`, if it has one. */
324
- lockfile: string | null;
325
- };
326
- /**
327
- * A merge of `main` that doesn't land as a revision as it is: it conflicts, or its tree doesn't
328
- * build or type check. Recorded for Camox's reconcile turn, which tries once for each move of
329
- * `main`, until code holding that `main` builds without errors (`settleClash`): the draft has
330
- * the "doesn't merge with Live's" blocker until then.
331
- */
332
- type MergeClash = {
333
- /** The commit of `main` that clashed. */
334
- main: string;
335
- /** The files both sides changed in ways that don't merge, for a merge that conflicts. */
336
- conflicts?: string[];
337
- /** The merged tree's build, for a merge that doesn't build or type check. */
338
- result?: BuildResult;
339
- };
340
- /** What merging `main` into the working copy found. */
341
- type MergeOutcome =
342
- /** The draft holds the current `main` already. */
343
- {
344
- outcome: "upToDate";
345
- } |
346
- /** The working copy has changes no revision holds yet: the merge waits for them. */
347
- {
348
- outcome: "unsettled";
349
- } |
350
- /** This move of `main` clashed already, and isn't merged again until `main` moves again. */
351
- {
352
- outcome: "clashedBefore";
353
- main: string;
354
- } | {
355
- outcome: "conflicts";
356
- main: string;
357
- conflicts: string[];
358
- } |
359
- /** A merge commit of `main`, not on the branch yet, for a build to commit. */
360
- {
361
- outcome: "merged";
362
- main: string;
363
- prepared: PreparedCommit;
276
+ //#region ../../apps/api/src/domains/layouts/schema.d.ts
277
+ /** Which collection a layout's record pages render, and the field they're found by. */
278
+ type RecordPages = {
279
+ collectionId: string;
280
+ field: string;
364
281
  };
282
+ //#endregion
283
+ //#region ../../apps/api/src/domains/pages/schema.d.ts
365
284
  /**
366
- * The working copy of one draft with code, addressed by the draft's ID (`getByName`): a depth-1
367
- * clone of the draft's branch, held in memory, which the agent's code tools read and write over
368
- * RPC, through the write line. Every change is saved to its SQLite as it's made, Git's own
369
- * directory included, so an eviction restores it without cloning again. The skills of its `camox`
370
- * version are mounted beside the files and never saved, nor committed.
371
- *
372
- * It stores nothing until `start` made it, and nothing once `delete` deleted it.
373
- */
374
- declare class DraftCode extends DurableObject<Bindings> {
375
- #private;
376
- /** Whether the draft has code: its branch was made, and not deleted since. */
377
- held(): Promise<boolean>;
378
- /**
379
- * The commit of `main` the draft's code holds: the one its branch last merged, or forked from,
380
- * once it has code.
381
- */
382
- mergedMain(): Promise<string | undefined>;
383
- /**
384
- * Where the draft's merges of `main` stand: the branch's head, the `main` it holds, and the
385
- * last merge that clashed, read at once, as a commit moves them together.
386
- */
387
- merges(): Promise<{
388
- head: string;
389
- mergedMain: string;
390
- clash: MergeClash | undefined;
391
- }>;
392
- /** The last merge of `main` that clashed, until a merge of `main` lands. */
393
- clash(): Promise<MergeClash | undefined>;
394
- /**
395
- * Records that the merge of `main` at `clash.main` clashed (see `MergeClash`), for Camox's
396
- * reconcile turn. A merge that didn't land is left in the files, uncommitted, conflict markers
397
- * included, and the next revision is its merge commit: see `merging`.
398
- */
399
- recordClash(clash: MergeClash): Promise<void>;
400
- /**
401
- * The commit of `main` whose merge the files hold, uncommitted, if they do: Camox's reconcile
402
- * turn fixes it, and its build commits the merge commit.
403
- */
404
- merging(): Promise<string | undefined>;
405
- /**
406
- * Forgets the clash, once the draft's code built without errors and holds the `main` that
407
- * clashed: unless the files still hold a merge no commit landed.
408
- */
409
- settleClash(): Promise<void>;
410
- /**
411
- * Uploads the build of the draft's revision `revision` as the draft's publish script, ahead of
412
- * its publish, unless the script holds it already: its publish then only checks it's there
413
- * (`uploadForPublish`). Nothing once a publish took the script, until that publish ends, nor
414
- * once the draft ended. A draft that ended during the upload, deleted, loses the script.
415
- */
416
- prepareUpload(toUpload: PublishUpload): Promise<void>;
417
- /**
418
- * The draft's publish script holding the build of `revision`, which the publish `instanceId`
419
- * ships, taking it: no upload ahead replaces it until that publish ends. Uploads it unless the
420
- * script holds it already, as the upload ahead left it. Returns its name, and whether this
421
- * uploaded it.
422
- */
423
- uploadForPublish(toUpload: PublishUpload, instanceId: string, span?: SpanFields): Promise<{
424
- script: string;
425
- uploaded: boolean;
426
- }>;
427
- /** The publish of the draft going now, if any: its Workflow instance. */
428
- publishGoing(): Promise<string | null>;
429
- /**
430
- * Records that a member's push landed during the publish `instanceId`: the revision it waits
431
- * for a build to leave changed under it, so it goes back to the review (ADR 0043).
432
- */
433
- notePushDuring(instanceId: string): Promise<void>;
434
- /** Whether a member's push landed during the publish `instanceId`. */
435
- pushedDuring(instanceId: string): Promise<boolean>;
436
- /** Records that a build of the draft's code started, or ended. */
437
- markBuilding(building: boolean): Promise<void>;
438
- /**
439
- * Whether a build of the draft's code is going (see `BUILD_GOING_FOR_AT_MOST_MS`), or owed:
440
- * Camox's infrastructure failed the last one, and Camox retries it. A type check, going or
441
- * owed, isn't building (ADR 0043).
442
- */
443
- building(): Promise<boolean>;
444
- /**
445
- * Records that the thread `threadId` couldn't build the draft's code because of Camox's own
446
- * infrastructure, or with `typesOnly`, only check the types of a revision that built, and has
447
- * it retry later (`alarm`), each retry waiting longer.
448
- */
449
- oweBuild({ threadId, typesOnly }: {
450
- threadId: string;
451
- typesOnly?: boolean;
452
- }): Promise<void>;
453
- /** Forgets the build Camox owed the draft, once one ended without Camox's failing. */
454
- settleOwedBuild(): Promise<void>;
455
- /** Retries the build Camox owes the draft, in its thread's build queue, until one lands. */
456
- alarm(): Promise<void>;
457
- /**
458
- * Makes the draft's branch and working copy, from `commit` of `main` in the project's repo
459
- * `repo`, unless they were made already. Returns the commit the branch forked from.
460
- */
461
- start({ repo, commit }: {
462
- repo: string;
463
- commit: string;
464
- }): Promise<string>;
465
- /**
466
- * Makes the branch and working copy of a draft reverting a Publication, unless they were made
467
- * already: forked from `commit`, the Publication's commit on `main`, with one commit on top,
468
- * `message`, putting back the tree `main` had before it. Merging the current `main` then
469
- * applies that undo to Live's latest code, as a merge of `main` into any draft (`mergeMain`):
470
- * code a later publish changed since clashes as merges do. Returns whether `main` moved since
471
- * `commit`, which a merge then brings in, or null, making nothing, when `commit` is `main`'s
472
- * first: there's no code before it to put back.
473
- */
474
- startReverting({ repo, commit, message }: {
475
- repo: string;
476
- commit: string;
477
- message: string;
478
- }): Promise<{
479
- mainMoved: boolean;
480
- } | null>;
481
- /** Runs one operation of the agent's environment on the working copy, and saves what it changed. */
482
- call(call: EnvCall): Promise<EnvAnswer>;
483
- /**
484
- * The files that have merge conflict markers, as a merge of `main` that conflicts leaves them:
485
- * only files the branch's head doesn't hold as they are, since no commit holds markers.
486
- */
487
- conflicts(): Promise<string[]>;
488
- /**
489
- * The paths of the working copy's files that differ from the commit `since`, added or changed
490
- * since, without those deleted: since the branch's head when the working copy doesn't hold it,
491
- * or without `since`.
492
- */
493
- changedFiles({ since }?: {
494
- since?: string;
495
- }): Promise<string[]>;
496
- /**
497
- * The working copy's files that installing its dependencies reads, as a tar archive, with its
498
- * lockfile: what its sandbox needs to install ahead of a build, which `prepareCommit` would
499
- * give only once it staged and committed every change.
500
- */
501
- installFiles(): Promise<Pick<PreparedCommit, "files" | "lockfile">>;
502
- /**
503
- * Stages the working copy's every change and makes, without moving the branch, the commit it
504
- * would be: `message` on top of the branch's head. Returns the commit and its tree, with the
505
- * tree's files as a tar archive, which a build streams into its sandbox, and the lockfile.
506
- * Neither Git's directory nor the references mounted beside the files are in the tree.
507
- */
508
- prepareCommit({ message }: {
509
- message: string;
510
- }): Promise<PreparedCommit>;
511
- /**
512
- * Adds a member's pushed commits to the working copy, without moving the branch: the objects of
513
- * `pack`, a bundle's packfile, which may build on the objects of `prerequisites`, commits of
514
- * `main` fetched for it when the working copy doesn't hold them. A build then commits the
515
- * pushed head (`commit`, with `checkout`).
516
- */
517
- receive({ pack, prerequisites }: {
518
- pack: Uint8Array;
519
- prerequisites: string[];
520
- }): Promise<void>;
521
- /**
522
- * Moves the draft's branch to `commit`, which `prepareCommit` made, or a member pushed on top
523
- * of the branch's head, and pushes it. A commit of the tree the branch's head already has, such
524
- * as one prepared again after the push of the first, leaves the head as it is. With
525
- * `checkout`, for a commit made beside the files, the files take its tree. A member's pushed
526
- * head names `mergedMain`, the newest commit of `main` it holds, which the draft's next merge of
527
- * `main` merges from. Returns the branch's head and its parents.
528
- */
529
- commit({ commit, checkout, mergedMain }: {
530
- commit: string;
531
- checkout?: boolean;
532
- mergedMain?: string;
533
- }): Promise<{
534
- commit: string;
535
- parents: string[];
536
- }>;
537
- /** Whether `commit` is the branch's head or one of its descendants: it includes the head. */
538
- includesHead(commit: string): Promise<boolean>;
539
- /**
540
- * Pushes the draft's code to `main` as one squashed commit, as a publish lands: the tree of
541
- * `commit`, a revision on the branch, with the current tip of `main` as its only parent. A
542
- * `main` that already has that tree, as after a retried push that landed, is left as it is.
543
- * Returns the commit `main` points to.
544
- */
545
- publishToMain({ commit, message }: {
546
- commit: string;
547
- message: string;
548
- }): Promise<string>;
549
- /**
550
- * Merges the current `main` into the branch, without moving it: fetches `main` shallowly, its
551
- * history down to the `main` commit the branch last merged or forked from, which is then the
552
- * merge base, and merges it into the branch's head. A clean merge is returned as a merge commit
553
- * whose parents are the head and `main`, for a build to commit (`commit`): the files stay as
554
- * they are until then. A merge that conflicts changes nothing either.
555
- *
556
- * It waits while the files have changes no commit holds, and doesn't merge again a move of
557
- * `main` that clashed. Files holding the merge of an earlier `main` that Camox's reconcile
558
- * turn didn't fix (`merging`) are put back to the branch's head first, to merge this one.
559
- */
560
- mergeMain(): Promise<MergeOutcome>;
561
- /** Deletes the draft's branch and everything the working copy stored, as the draft ends. */
562
- delete(): Promise<void>;
563
- }
564
- //#endregion
565
- //#region ../../apps/api/src/domains/code-pushes/checks.d.ts
566
- /** Why a push was refused: each reason is a stable code the CLI and its users can rely on. */
567
- type PushRefusalReason =
568
- /** What was sent isn't a Git bundle of one branch's commits. */
569
- "invalidBundle" |
570
- /** The pushed tree changes a platform-owned file, which only Upgrades change. */
571
- "platformFile" |
572
- /** The pushed tree adds or changes a file under `src/` that isn't TypeScript or CSS. */
573
- "notCode" |
574
- /** `main` changed a platform-owned file since the branch last merged it. */
575
- "mergeMainFirst" |
576
- /** The branch starts from a commit that was never on `main`. */
577
- "baseNotOnMain" |
578
- /** The branch doesn't merge cleanly with the current `main`. */
579
- "conflictsWithMain" |
580
- /** The pushed head doesn't build. */
581
- "doesNotBuild" |
582
- /** The pushed head doesn't include the draft's current head. */
583
- "pullDraftFirst" |
584
- /** The draft the push names was published or deleted. */
585
- "draftEnded";
586
- type PushRefusal = {
587
- reason: PushRefusalReason;
588
- message: string;
589
- data?: Record<string, unknown>;
590
- };
591
- /** A push that passed the checks: its head, as a commit to build, and what landing it needs. */
592
- type CheckedPush = {
593
- /** The pushed head, as a commit to build. */
594
- prepared: PreparedCommit;
595
- /**
596
- * The commits of `main` or of the draft's branch the pushed commits build on: the bundle's
597
- * prerequisites.
598
- */
599
- prerequisites: string[];
600
- /** The newest commit of `main` the pushed head holds, which a draft it opens forks from. */
601
- base: string;
602
- pack: Uint8Array;
603
- /** The subject of each pushed commit, oldest first. */
604
- subjects: string[];
605
- };
606
- //#endregion
607
- //#region ../../apps/api/src/domains/code-pushes/land.d.ts
608
- /** A push that passed its checks, as the draft it lands on receives it. */
609
- type CheckedLanding = CheckedPush & {
610
- /** The project's Project ID, which names its repo. */
611
- repo: string;
612
- };
613
- /** Whether the push landed, with its head's build, or why it was refused. */
614
- type Landing = {
615
- refused: PushRefusal;
616
- } | {
617
- result: BuildResult;
618
- };
619
- //#endregion
620
- //#region ../../apps/api/src/domains/revisions/merge.d.ts
621
- /** How a merge of `main` into a draft ended. */
622
- type MergeEnd =
623
- /** The draft holds the current `main`, or will once its changes are committed. */
624
- "upToDate" |
625
- /** A merge revision landed, built, and the draft previews it. */
626
- "merged" |
627
- /** The merge clashed: it's left for Camox's reconcile turn (`DraftCode.clash`), to start. */
628
- "clashed" |
629
- /** This move of `main` clashed already: Camox's reconcile turn had its one try. */
630
- "clashedBefore";
631
- //#endregion
632
- //#region ../../apps/api/src/domains/layouts/schema.d.ts
633
- /** Which collection a layout's record pages render, and the field they're found by. */
634
- type RecordPages = {
635
- collectionId: string;
636
- field: string;
637
- };
638
- //#endregion
639
- //#region ../../apps/api/src/domains/pages/schema.d.ts
640
- /**
641
- * A page. Live and every draft store pages side by side (ADR 0005), like blocks: a Live row has
642
- * no draft, a draft row is the draft's copy of a page, a page the draft created, or a tombstone.
643
- * An id is unique within each locale of Live and of each draft (ADR 0015). Read and write pages
644
- * through the draft overlay.
285
+ * A page. Live and every draft store pages side by side (ADR 0005), like blocks: a Live row has
286
+ * no draft, a draft row is the draft's copy of a page, a page the draft created, or a tombstone.
287
+ * An id is unique within each locale of Live and of each draft (ADR 0015). Read and write pages
288
+ * through the draft overlay.
645
289
  */
646
290
  declare const pages: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
647
291
  name: "pages";
@@ -1994,6 +1638,14 @@ type DraftRequest = {
1994
1638
  declare const ENTITY_KINDS: readonly ["locale", "page", "block", "sharedContent", "repeatableItem", "file", "record", "exclusion"];
1995
1639
  type EntityKind = (typeof ENTITY_KINDS)[number];
1996
1640
  //#endregion
1641
+ //#region ../../apps/api/src/domains/revisions/schema.d.ts
1642
+ /**
1643
+ * What left a revision: the agent's `build`, the end of its turn, a merge of `main`, a
1644
+ * member's `push` from their own checkout (ADR 0026), or the undo of a Publication's code
1645
+ * starting the draft reverting it (ADR 0045).
1646
+ */
1647
+ type RevisionSource = "build" | "turn" | "merge" | "push" | "revert";
1648
+ //#endregion
1997
1649
  //#region ../../apps/api/src/db.d.ts
1998
1650
  declare const schema: {
1999
1651
  projects: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
@@ -6831,7 +6483,14 @@ declare const schema: {
6831
6483
  dialect: 'sqlite';
6832
6484
  }>;
6833
6485
  };
6834
- declare function createDb(d1: D1Database): DrizzleD1Database<typeof schema> & {
6486
+ /**
6487
+ * A database on `d1` whose reads issued together share one round trip (`coalescingReads`). A
6488
+ * database kept beyond one request must not: a batch would answer each request's reads from
6489
+ * another's I/O. Pass `coalesce: false` for it.
6490
+ */
6491
+ declare function createDb(d1: D1Database, { coalesce }?: {
6492
+ coalesce?: boolean;
6493
+ }): DrizzleD1Database<typeof schema> & {
6835
6494
  $client: D1Database;
6836
6495
  };
6837
6496
  type Database = ReturnType<typeof createDb>;
@@ -10015,22 +9674,6 @@ declare class Thread extends DurableObject<Bindings> {
10015
9674
  readonly harness: UntilStartedPiHarness;
10016
9675
  readonly webSockets: WebSockets;
10017
9676
  readonly lifecycle: Lifecycle<object, object>;
10018
- /**
10019
- * Builds the code of the draft `draftId`, the thread's, in its build queue, as a publish of a
10020
- * head revision whose build is gone asks: the head's tree finds its revision, built again.
10021
- */
10022
- buildForPublish(draftId: string): Promise<BuildResult | null>;
10023
- /**
10024
- * Lands a member's checked push `push` on the thread's draft, in its build queue, as `pusher`
10025
- * pushed it (ADR 0026): once the agent's turn going, if any, made its last commit, and before
10026
- * the next message. Starts the thread, if nobody messaged it yet, so Camox's merges of `main`
10027
- * reach the draft. `waiting` hears that the push waits for the turn. A push that landed adds
10028
- * its entry to the thread: the agent reads it, and doesn't answer it.
10029
- */
10030
- landPush(push: CheckedLanding & {
10031
- identity: ThreadIdentity;
10032
- pusher: ThreadSender;
10033
- }, waiting?: () => Promise<void> | void): Promise<Landing>;
10034
9677
  /**
10035
9678
  * Adds the entry of a member's push that landed on the thread's draft, starting the thread if
10036
9679
  * nobody messaged it yet: who pushed, their commits, and how the pushed head built. The model
@@ -10043,31 +9686,10 @@ declare class Thread extends DurableObject<Bindings> {
10043
9686
  result: BuildResult;
10044
9687
  }): Promise<void>;
10045
9688
  /**
10046
- * Merges the current `main` into the thread's draft, when it has code, as a push to `main`
10047
- * asks: right away when the agent is idle, or else right after its turn's last commit, before
10048
- * the next message (`#onYield`). Nothing of it shows in the thread.
10049
- */
10050
- mergeMain(): Promise<MergeEnd | "afterTheTurn" | "noCode">;
10051
- /**
10052
- * Lands the undo of a Publication's code on the thread's draft, which reverts it (ADR 0045),
10053
- * starting the thread: the draft's branch, made by `DraftCode.startReverting`, holds the undo
10054
- * on top of the Publication's commit. When `main` moved since, its merge applies the undo to
10055
- * Live's latest code, a clash starting Camox's reconcile turn, as any merge of `main` does
10056
- * (ADR 0020). Otherwise the undo is built as the draft's revision. Either goes on in the
10057
- * background: the draft shows it's building, or not holding Live's code, until it lands.
10058
- */
10059
- revertCode({ identity, mainMoved }: {
10060
- identity: ThreadIdentity;
10061
- mainMoved: boolean;
10062
- }): Promise<void>;
10063
- /**
10064
- * Builds the code of the thread's draft, as the end of a turn would on its last try, when
10065
- * Camox's infrastructure failed the last build: changes that don't build are committed as a
10066
- * revision that isn't built, which blocks publishing. Nothing of it shows in the thread. A
10067
- * failure on Camox's side again owes the next retry. `busy` while the agent's turn runs: its
10068
- * end builds.
9689
+ * Starts Camox's reconcile turn in the thread of the draft `identity` names, as a merge of
9690
+ * `main` into its code clashed, starting the thread if nobody messaged it yet.
10069
9691
  */
10070
- retryBuild(): Promise<"built" | "failed" | "busy" | "noCode">;
9692
+ reconcile(identity: ThreadIdentity): Promise<void>;
10071
9693
  /**
10072
9694
  * Lifecycle's alarm, which wakes Pi's runs, unless the thread ended: an alarm already on its
10073
9695
  * way when it did would look for the jobs its storage no longer has. A published draft's
@@ -10202,6 +9824,602 @@ declare class ProjectCode extends DurableObject<Bindings> {
10202
9824
  snapshot(known?: string): Promise<MainSnapshot>;
10203
9825
  }
10204
9826
  //#endregion
9827
+ //#region ../../apps/api/src/lib/timing.d.ts
9828
+ /** What a span's line says beside its name and duration. Undefined fields are left out. */
9829
+ type SpanFields = Record<string, string | number | boolean | null | undefined>;
9830
+ //#endregion
9831
+ //#region ../../apps/api/src/domains/revisions/sandbox.d.ts
9832
+ /** A type check's outcome, with what it printed: its errors when it failed. */
9833
+ type SandboxTypeCheck = {
9834
+ ok: boolean;
9835
+ output: string;
9836
+ };
9837
+ /**
9838
+ * A build's outcome: its output as one gzipped tar archive, with the SDK Bundle it names (null
9839
+ * for a whole-app build) and the type check of the same tree, which may still be running, or the
9840
+ * log of its failure. Either way, `lint` has the findings of the lint that ran beside it: null
9841
+ * when it was asked for none, or Camox couldn't lint.
9842
+ */
9843
+ type SandboxBuild = {
9844
+ lint: Promise<LintError[] | null>;
9845
+ } & ({
9846
+ ok: true;
9847
+ archive: Uint8Array;
9848
+ sdkBundle: SdkBundleNames | null;
9849
+ typeCheck: Promise<SandboxTypeCheck>;
9850
+ } | {
9851
+ ok: false;
9852
+ log: string;
9853
+ });
9854
+ //#endregion
9855
+ //#region ../../apps/api/src/domains/code-pushes/checks.d.ts
9856
+ /** Why a push was refused: each reason is a stable code the CLI and its users can rely on. */
9857
+ type PushRefusalReason =
9858
+ /** What was sent isn't a Git bundle of one branch's commits. */
9859
+ "invalidBundle" |
9860
+ /** The pushed tree changes a platform-owned file, which only Upgrades change. */
9861
+ "platformFile" |
9862
+ /** The pushed tree adds or changes a file under `src/` that isn't TypeScript or CSS. */
9863
+ "notCode" |
9864
+ /** `main` changed a platform-owned file since the branch last merged it. */
9865
+ "mergeMainFirst" |
9866
+ /** The branch starts from a commit that was never on `main`. */
9867
+ "baseNotOnMain" |
9868
+ /** The branch doesn't merge cleanly with the current `main`. */
9869
+ "conflictsWithMain" |
9870
+ /** The pushed head doesn't build. */
9871
+ "doesNotBuild" |
9872
+ /** The pushed head doesn't include the draft's current head. */
9873
+ "pullDraftFirst" |
9874
+ /** The draft the push names was published or deleted. */
9875
+ "draftEnded";
9876
+ type PushRefusal = {
9877
+ reason: PushRefusalReason;
9878
+ message: string;
9879
+ data?: Record<string, unknown>;
9880
+ };
9881
+ /** A push that passed the checks: its head, as a commit to build, and what landing it needs. */
9882
+ type CheckedPush = {
9883
+ /** The pushed head, as a commit to build. */
9884
+ prepared: PreparedCommit;
9885
+ /**
9886
+ * The commits of `main` or of the draft's branch the pushed commits build on: the bundle's
9887
+ * prerequisites.
9888
+ */
9889
+ prerequisites: string[];
9890
+ /** The newest commit of `main` the pushed head holds, which a draft it opens forks from. */
9891
+ base: string;
9892
+ pack: Uint8Array;
9893
+ /** The subject of each pushed commit, oldest first. */
9894
+ subjects: string[];
9895
+ };
9896
+ //#endregion
9897
+ //#region ../../apps/api/src/domains/code-pushes/land.d.ts
9898
+ /** A push that passed its checks, as the draft it lands on receives it. */
9899
+ type CheckedLanding = CheckedPush & {
9900
+ /** The project's Project ID, which names its repo. */
9901
+ repo: string;
9902
+ };
9903
+ /** Whether the push landed, with its head's build, or why it was refused. */
9904
+ type Landing = {
9905
+ refused: PushRefusal;
9906
+ } | {
9907
+ result: BuildResult;
9908
+ };
9909
+ //#endregion
9910
+ //#region ../../apps/api/src/domains/code/remote-env.d.ts
9911
+ /** The operations sent as they are: every argument but the context is plain data. */
9912
+ declare const SENT: ["absolutePath", "joinPath", "readTextFile", "readTextLines", "readBinaryFile", "writeFile", "appendFile", "truncateFile", "flushFile", "renameFile", "fileInfo", "listDir", "canonicalPath", "exists", "createDir", "remove"];
9913
+ /** What a remote environment asks of the one it reaches. */
9914
+ type EnvCall = {
9915
+ operation: (typeof SENT)[number];
9916
+ args: unknown[];
9917
+ } |
9918
+ /** Opens a binary reader there and reads the whole file it opened. */
9919
+ {
9920
+ operation: "openBinaryReader";
9921
+ args: [path: string, options?: {
9922
+ noFollow?: boolean;
9923
+ }];
9924
+ };
9925
+ /** An operation's result as it crosses: its value, or its error as plain data. */
9926
+ type EnvAnswer = {
9927
+ ok: true;
9928
+ value: unknown;
9929
+ } | {
9930
+ ok: false;
9931
+ error: {
9932
+ code: FileErrorCode;
9933
+ message: string;
9934
+ path?: string;
9935
+ };
9936
+ };
9937
+ //#endregion
9938
+ //#region ../../apps/api/src/domains/revisions/build.d.ts
9939
+ /** What left a revision, and the thread run that did, if one did. */
9940
+ type RevisionOrigin = {
9941
+ leftBy: RevisionSource;
9942
+ run?: {
9943
+ threadId: string;
9944
+ runId: string;
9945
+ };
9946
+ /**
9947
+ * The commit to build, made beside the working copy's files, such as a merge of `main`
9948
+ * (`DraftCode.prepareMerge`) or a member's pushed head (`DraftCode.receive`). Without it, the
9949
+ * build is of the files.
9950
+ */
9951
+ prepared?: PreparedCommit;
9952
+ /**
9953
+ * The build of `prepared` made already, which a push's checks make before anything is
9954
+ * written: it's committed as it is rather than built again.
9955
+ */
9956
+ built?: Extract<SandboxBuild, {
9957
+ ok: true;
9958
+ }>;
9959
+ /** For a member's pushed head, the newest commit of `main` it holds. */
9960
+ mergedMain?: string;
9961
+ /**
9962
+ * The files whose lint findings the result lists, linted beside the build. A lint Camox can't
9963
+ * run finds nothing: it never fails the build.
9964
+ */
9965
+ lint?: string[];
9966
+ };
9967
+ //#endregion
9968
+ //#region ../../apps/api/src/domains/revisions/end-of-turn.d.ts
9969
+ /** What the end of a turn did about the code the turn changed. */
9970
+ type TurnBuild =
9971
+ /** The turn's code already is a revision: nothing changed since the last one. */
9972
+ {
9973
+ outcome: "unchanged";
9974
+ } | {
9975
+ outcome: "built";
9976
+ result: BuildResult;
9977
+ } |
9978
+ /**
9979
+ * The turn's code builds, but lint found problems in the files it changed: the agent is handed
9980
+ * `result` to fix them. Once it had them too often, the turn ends `built`, with them.
9981
+ */
9982
+ {
9983
+ outcome: "linted";
9984
+ result: BuildResult;
9985
+ } |
9986
+ /** The build failed: the agent is handed `result` to fix it. */
9987
+ {
9988
+ outcome: "failed";
9989
+ result: BuildResult;
9990
+ } |
9991
+ /** The build failed once too often: the changes are committed anyway, as a revision not built. */
9992
+ {
9993
+ outcome: "committedUnbuilt";
9994
+ result: BuildResult;
9995
+ } |
9996
+ /**
9997
+ * The changes built, committed, but had errors once too often: type errors, or definitions the
9998
+ * draft can't use. They stay as they are.
9999
+ */
10000
+ {
10001
+ outcome: "keptErrors";
10002
+ result: BuildResult;
10003
+ } |
10004
+ /**
10005
+ * The build failed once too often, but its changes can't be committed as they are: the files
10006
+ * hold a merge of Live's code that Camox's reconcile turn didn't fix, or conflict markers.
10007
+ * Nothing is committed: `merging` says whether the files hold a merge.
10008
+ */
10009
+ {
10010
+ outcome: "uncommitted";
10011
+ result: BuildResult;
10012
+ merging: boolean;
10013
+ };
10014
+ /**
10015
+ * Builds what a turn changed in the code of the draft `draftId`, which has code, as the turn
10016
+ * ends: whatever changed since its last revision, nothing when the agent's last `build` already
10017
+ * covered it without errors. A passing build leaves a revision, even with type errors. A build
10018
+ * fails when it, its type check or its definitions have errors. `failedInARow` is how many
10019
+ * end-of-turn builds of this turn failed before this one: once this one makes
10020
+ * `END_OF_TURN_BUILD_FAILURES`, changes that didn't build are committed anyway, as a revision
10021
+ * that isn't built, and ones that did stay with their errors. `building` runs before a build
10022
+ * starts.
10023
+ *
10024
+ * The files the turn changed since `base`, the commit its code was at as it started, are linted
10025
+ * too, beside the build, or alone when the agent's builds covered its changes: findings in code
10026
+ * that builds hand the agent a `linted` result, and count as a failure, and the findings of a
10027
+ * build that fails come with its errors. Lint never fails a build, and the turn ends with
10028
+ * findings it had once too often.
10029
+ */
10030
+ declare function buildAtEndOfTurn(env: Bindings, draftId: string, { run, failedInARow, building, base }: {
10031
+ run?: RevisionOrigin["run"];
10032
+ failedInARow: number;
10033
+ building: () => Promise<void>;
10034
+ base?: string;
10035
+ }): Promise<TurnBuild>;
10036
+ //#endregion
10037
+ //#region ../../apps/api/src/domains/revisions/merge.d.ts
10038
+ /** How a merge of `main` into a draft ended. */
10039
+ type MergeEnd =
10040
+ /** The draft holds the current `main`, or will once its changes are committed. */
10041
+ "upToDate" |
10042
+ /** A merge revision landed, built, and the draft previews it. */
10043
+ "merged" |
10044
+ /** The merge clashed: it's left for Camox's reconcile turn (`DraftCode.clash`), to start. */
10045
+ "clashed" |
10046
+ /** This move of `main` clashed already: Camox's reconcile turn had its one try. */
10047
+ "clashedBefore";
10048
+ //#endregion
10049
+ //#region ../../apps/api/src/domains/revisions/code-queue.d.ts
10050
+ /** What the code queue asks of the draft's thread. */
10051
+ type DraftThread = {
10052
+ /** Whether the agent is mid-turn in the draft's thread. */
10053
+ turnGoing(): Promise<boolean>;
10054
+ /** Starts Camox's turn reconciling the draft's code with Live's, whose merge clashed. */
10055
+ reconcile(): Promise<void>;
10056
+ };
10057
+ /** What the code queue needs of the `DraftCode` holding it. */
10058
+ type CodeQueueHost = {
10059
+ env: Bindings;
10060
+ storage: DurableObjectStorage;
10061
+ draftId: () => string;
10062
+ /** Whether the draft has code. */
10063
+ held: () => boolean;
10064
+ /** The files its sandbox installs from, ahead of a build (`DraftCode.installFiles`). */
10065
+ installFiles: () => Promise<Pick<PreparedCommit, "files" | "lockfile">>;
10066
+ thread: () => DraftThread;
10067
+ waitUntil: (promise: Promise<unknown>) => void;
10068
+ };
10069
+ /** The draft's code queue (see above), for its `DraftCode` to answer with. */
10070
+ declare class CodeQueue {
10071
+ #private;
10072
+ constructor(host: CodeQueueHost);
10073
+ /** Builds the files as a revision, as the agent's `build` or a publish asks. None without code. */
10074
+ build({ run }?: {
10075
+ run?: RevisionOrigin["run"];
10076
+ }): Promise<BuildResult | null>;
10077
+ /**
10078
+ * Builds what the agent's turn changed, as it ends (`buildAtEndOfTurn`). A build Camox's
10079
+ * infrastructure failed is owed, and retried later: the turn ends on it.
10080
+ */
10081
+ buildAtTurnEnd(turn: Omit<Parameters<typeof buildAtEndOfTurn>[2], "building"> & {
10082
+ building: () => Promise<void> | void;
10083
+ }): Promise<TurnBuild | {
10084
+ outcome: "owed";
10085
+ }>;
10086
+ /**
10087
+ * Starts the draft's sandbox and installs its dependencies, in the queue, so the next build
10088
+ * finds them. Doesn't count as building.
10089
+ */
10090
+ warmSandbox(span: SpanFields): Promise<void>;
10091
+ /**
10092
+ * Merges the current `main` into the draft, as a push to `main` asks: right away unless the
10093
+ * agent is mid-turn, or else once its turn ended (`turnEnded`).
10094
+ */
10095
+ mergeMain(): Promise<MergeEnd | "afterTheTurn" | "noCode">;
10096
+ /**
10097
+ * Lands the member's checked push `push`, once the agent's turn going, if any, made its last
10098
+ * commit. `waiting` hears that it waits for the turn.
10099
+ */
10100
+ landPush(push: CheckedLanding, waiting?: () => Promise<void> | void): Promise<Landing>;
10101
+ /**
10102
+ * Lands what waited for the agent's turn, as it ends: the merge of the `main` that moved
10103
+ * during it, then the members' pushes, one after the other.
10104
+ */
10105
+ turnEnded(): Promise<void>;
10106
+ /**
10107
+ * Lands the undo of a Publication's code, which `DraftCode.startReverting` put on the
10108
+ * draft's branch, in the background: merged with Live's latest code when `main` moved since,
10109
+ * or else built as the draft's revision. The draft shows it's building from now, so a publish
10110
+ * asked meanwhile waits for it.
10111
+ */
10112
+ landRevert({ mainMoved }: {
10113
+ mainMoved: boolean;
10114
+ }): void;
10115
+ /** Waits for the merge of `main` or the member's push landing now, if any: it lands beside the files. */
10116
+ untilLanded(): Promise<void>;
10117
+ /**
10118
+ * Whether a build of the draft's code is going (see `BUILD_GOING_FOR_AT_MOST_MS`), or owed:
10119
+ * Camox's infrastructure failed the last one, and Camox retries it. A type check, going or
10120
+ * owed, isn't building (ADR 0043).
10121
+ */
10122
+ building(): boolean;
10123
+ /**
10124
+ * Records that the build going ended, or is previewed, its type check going on: the draft no
10125
+ * longer shows it's building, and a publish waiting for it ships what it left.
10126
+ */
10127
+ buildEnded(): Promise<void>;
10128
+ /**
10129
+ * Retries the build Camox owes the draft, as the end of a turn would on its last try: changes
10130
+ * that don't build are committed as a revision that isn't built. A turn going builds at its
10131
+ * end, so the retry waits for the next one.
10132
+ */
10133
+ retryOwed(): Promise<void>;
10134
+ }
10135
+ //#endregion
10136
+ //#region ../../apps/api/src/durable-objects/draft-code.d.ts
10137
+ /** A revision of the draft whose build goes up as its publish script. */
10138
+ type PublishUpload = {
10139
+ /** The project's Project ID. */
10140
+ project: string;
10141
+ revision: string;
10142
+ /** Its build in `REVISION_BUILDS`. */
10143
+ archiveKey: string;
10144
+ };
10145
+ /** A commit `prepareCommit` made, not on the branch yet. */
10146
+ type PreparedCommit = {
10147
+ commit: string;
10148
+ tree: string;
10149
+ /** The tree's files, as a tar archive. */
10150
+ files: Uint8Array;
10151
+ /** The tree's `pnpm-lock.yaml`, if it has one. */
10152
+ lockfile: string | null;
10153
+ };
10154
+ /**
10155
+ * A merge of `main` that doesn't land as a revision as it is: it conflicts, or its tree doesn't
10156
+ * build or type check. Recorded for Camox's reconcile turn, which tries once for each move of
10157
+ * `main`, until code holding that `main` builds without errors (`settleClash`): the draft has
10158
+ * the "doesn't merge with Live's" blocker until then.
10159
+ */
10160
+ type MergeClash = {
10161
+ /** The commit of `main` that clashed. */
10162
+ main: string;
10163
+ /** The files both sides changed in ways that don't merge, for a merge that conflicts. */
10164
+ conflicts?: string[];
10165
+ /** The merged tree's build, for a merge that doesn't build or type check. */
10166
+ result?: BuildResult;
10167
+ };
10168
+ /** What merging `main` into the working copy found. */
10169
+ type MergeOutcome =
10170
+ /** The draft holds the current `main` already. */
10171
+ {
10172
+ outcome: "upToDate";
10173
+ } |
10174
+ /** The working copy has changes no revision holds yet: the merge waits for them. */
10175
+ {
10176
+ outcome: "unsettled";
10177
+ } |
10178
+ /** This move of `main` clashed already, and isn't merged again until `main` moves again. */
10179
+ {
10180
+ outcome: "clashedBefore";
10181
+ main: string;
10182
+ } | {
10183
+ outcome: "conflicts";
10184
+ main: string;
10185
+ conflicts: string[];
10186
+ } |
10187
+ /** A merge commit of `main`, not on the branch yet, for a build to commit. */
10188
+ {
10189
+ outcome: "merged";
10190
+ main: string;
10191
+ prepared: PreparedCommit;
10192
+ };
10193
+ /**
10194
+ * The working copy of one draft with code, addressed by the draft's ID (`getByName`): a depth-1
10195
+ * clone of the draft's branch, held in memory, which the agent's code tools read and write over
10196
+ * RPC, through the write line. Every change is saved to its SQLite as it's made, Git's own
10197
+ * directory included, so an eviction restores it without cloning again. The skills of its `camox`
10198
+ * version are mounted beside the files and never saved, nor committed.
10199
+ *
10200
+ * It stores nothing until `start` made it, and nothing once `delete` deleted it.
10201
+ */
10202
+ declare class DraftCode extends DurableObject<Bindings> {
10203
+ #private;
10204
+ /** Whether the draft has code: its branch was made, and not deleted since. */
10205
+ held(): Promise<boolean>;
10206
+ /**
10207
+ * The commit of `main` the draft's code holds: the one its branch last merged, or forked from,
10208
+ * once it has code.
10209
+ */
10210
+ mergedMain(): Promise<string | undefined>;
10211
+ /**
10212
+ * Where the draft's merges of `main` stand: the branch's head, the `main` it holds, and the
10213
+ * last merge that clashed, read at once, as a commit moves them together.
10214
+ */
10215
+ merges(): Promise<{
10216
+ head: string;
10217
+ mergedMain: string;
10218
+ clash: MergeClash | undefined;
10219
+ }>;
10220
+ /** The last merge of `main` that clashed, until a merge of `main` lands. */
10221
+ clash(): Promise<MergeClash | undefined>;
10222
+ /**
10223
+ * Records that the merge of `main` at `clash.main` clashed (see `MergeClash`), for Camox's
10224
+ * reconcile turn. A merge that didn't land is left in the files, uncommitted, conflict markers
10225
+ * included, and the next revision is its merge commit: see `merging`.
10226
+ */
10227
+ recordClash(clash: MergeClash): Promise<void>;
10228
+ /**
10229
+ * The commit of `main` whose merge the files hold, uncommitted, if they do: Camox's reconcile
10230
+ * turn fixes it, and its build commits the merge commit.
10231
+ */
10232
+ merging(): Promise<string | undefined>;
10233
+ /**
10234
+ * Forgets the clash, once the draft's code built without errors and holds the `main` that
10235
+ * clashed: unless the files still hold a merge no commit landed.
10236
+ */
10237
+ settleClash(): Promise<void>;
10238
+ /**
10239
+ * Uploads the build of the draft's revision `revision` as the draft's publish script, ahead of
10240
+ * its publish, unless the script holds it already: its publish then only checks it's there
10241
+ * (`uploadForPublish`). Nothing once a publish took the script, until that publish ends, nor
10242
+ * once the draft ended. A draft that ended during the upload, deleted, loses the script.
10243
+ */
10244
+ prepareUpload(toUpload: PublishUpload): Promise<void>;
10245
+ /**
10246
+ * The draft's publish script holding the build of `revision`, which the publish `instanceId`
10247
+ * ships, taking it: no upload ahead replaces it until that publish ends. Uploads it unless the
10248
+ * script holds it already, as the upload ahead left it. Returns its name, and whether this
10249
+ * uploaded it.
10250
+ */
10251
+ uploadForPublish(toUpload: PublishUpload, instanceId: string, span?: SpanFields): Promise<{
10252
+ script: string;
10253
+ uploaded: boolean;
10254
+ }>;
10255
+ /** The publish of the draft going now, if any: its Workflow instance. */
10256
+ publishGoing(): Promise<string | null>;
10257
+ /**
10258
+ * Records that a member's push landed during the publish `instanceId`: the revision it waits
10259
+ * for a build to leave changed under it, so it goes back to the review (ADR 0043).
10260
+ */
10261
+ notePushDuring(instanceId: string): Promise<void>;
10262
+ /** Whether a member's push landed during the publish `instanceId`. */
10263
+ pushedDuring(instanceId: string): Promise<boolean>;
10264
+ /**
10265
+ * The draft's thread, as its code queue asks it whether a turn is going: the one the draft's
10266
+ * row names. Tests put a fake in its place.
10267
+ */
10268
+ draftThread: DraftThread;
10269
+ /** Builds the files as a revision, as the agent's `build` or a publish asks. None without code. */
10270
+ build(options?: Parameters<CodeQueue["build"]>[0]): Promise<BuildResult | null>;
10271
+ /**
10272
+ * Builds what the agent's turn changed, as it ends: `building` runs before a build starts. A
10273
+ * build Camox's infrastructure failed is owed, and retried later: the turn ends on it.
10274
+ */
10275
+ buildAtTurnEnd(turn: Parameters<CodeQueue["buildAtTurnEnd"]>[0]): Promise<TurnBuild | {
10276
+ outcome: "owed";
10277
+ }>;
10278
+ /** Starts the draft's sandbox ahead of its next build, in the queue. */
10279
+ warmSandbox(span: SpanFields): Promise<void>;
10280
+ /**
10281
+ * Merges the current `main` into the draft, as a push to `main` asks: right away unless the
10282
+ * agent is mid-turn, or else once its turn ended (`turnEnded`). Nothing of it shows in the
10283
+ * thread, unless it clashes: Camox's reconcile turn then starts there.
10284
+ */
10285
+ mergeMain(): Promise<MergeEnd | "afterTheTurn" | "noCode">;
10286
+ /**
10287
+ * Lands a member's checked push on the draft (ADR 0026), once the agent's turn going, if any,
10288
+ * made its last commit. `waiting` hears that the push waits for the turn. A draft without
10289
+ * code gets its branch from the push.
10290
+ */
10291
+ landPush(push: CheckedLanding, waiting?: () => Promise<void> | void): Promise<Landing>;
10292
+ /** Lands what waited for the agent's turn, as it ends: a merge of `main`, then pushes. */
10293
+ turnEnded(): Promise<void>;
10294
+ /**
10295
+ * Lands the undo of a Publication's code, which `startReverting` made, in the background
10296
+ * (ADR 0045). The draft shows it's building from now, so its publish waits for it.
10297
+ */
10298
+ landRevert({ mainMoved }: {
10299
+ mainMoved: boolean;
10300
+ }): Promise<void>;
10301
+ /** Waits for the merge of `main` or the push landing now, if any: code writes wait for it. */
10302
+ untilLanded(): Promise<void>;
10303
+ /**
10304
+ * Whether a build of the draft's code is going, or owed: Camox's infrastructure failed the
10305
+ * last one, and Camox retries it. A type check, going or owed, isn't building (ADR 0043).
10306
+ */
10307
+ building(): Promise<boolean>;
10308
+ /**
10309
+ * Records that the build going is previewed: the draft no longer shows it's building, though
10310
+ * its type check goes on.
10311
+ */
10312
+ buildPreviewed(): Promise<void>;
10313
+ /** Retries the build Camox owes the draft, until one lands. */
10314
+ alarm(): Promise<void>;
10315
+ /**
10316
+ * Makes the draft's branch and working copy, from `commit` of `main` in the project's repo
10317
+ * `repo`, unless they were made already. Returns the commit the branch forked from.
10318
+ */
10319
+ start({ repo, commit }: {
10320
+ repo: string;
10321
+ commit: string;
10322
+ }): Promise<string>;
10323
+ /**
10324
+ * Makes the branch and working copy of a draft reverting a Publication, unless they were made
10325
+ * already: forked from `commit`, the Publication's commit on `main`, with one commit on top,
10326
+ * `message`, putting back the tree `main` had before it. Merging the current `main` then
10327
+ * applies that undo to Live's latest code, as a merge of `main` into any draft (`prepareMerge`):
10328
+ * code a later publish changed since clashes as merges do. Returns whether `main` moved since
10329
+ * `commit`, which a merge then brings in, or null, making nothing, when `commit` is `main`'s
10330
+ * first: there's no code before it to put back.
10331
+ */
10332
+ startReverting({ repo, commit, message }: {
10333
+ repo: string;
10334
+ commit: string;
10335
+ message: string;
10336
+ }): Promise<{
10337
+ mainMoved: boolean;
10338
+ } | null>;
10339
+ /** Runs one operation of the agent's environment on the working copy, and saves what it changed. */
10340
+ call(call: EnvCall): Promise<EnvAnswer>;
10341
+ /**
10342
+ * The files that have merge conflict markers, as a merge of `main` that conflicts leaves them:
10343
+ * only files the branch's head doesn't hold as they are, since no commit holds markers.
10344
+ */
10345
+ conflicts(): Promise<string[]>;
10346
+ /**
10347
+ * The paths of the working copy's files that differ from the commit `since`, added or changed
10348
+ * since, without those deleted: since the branch's head when the working copy doesn't hold it,
10349
+ * or without `since`.
10350
+ */
10351
+ changedFiles({ since }?: {
10352
+ since?: string;
10353
+ }): Promise<string[]>;
10354
+ /**
10355
+ * The working copy's files that installing its dependencies reads, as a tar archive, with its
10356
+ * lockfile: what its sandbox needs to install ahead of a build, which `prepareCommit` would
10357
+ * give only once it staged and committed every change.
10358
+ */
10359
+ installFiles(): Promise<Pick<PreparedCommit, "files" | "lockfile">>;
10360
+ /**
10361
+ * Stages the working copy's every change and makes, without moving the branch, the commit it
10362
+ * would be: `message` on top of the branch's head. Returns the commit and its tree, with the
10363
+ * tree's files as a tar archive, which a build streams into its sandbox, and the lockfile.
10364
+ * Neither Git's directory nor the references mounted beside the files are in the tree.
10365
+ */
10366
+ prepareCommit({ message }: {
10367
+ message: string;
10368
+ }): Promise<PreparedCommit>;
10369
+ /**
10370
+ * Adds a member's pushed commits to the working copy, without moving the branch: the objects of
10371
+ * `pack`, a bundle's packfile, which may build on the objects of `prerequisites`, commits of
10372
+ * `main` fetched for it when the working copy doesn't hold them. A build then commits the
10373
+ * pushed head (`commit`, with `checkout`).
10374
+ */
10375
+ receive({ pack, prerequisites }: {
10376
+ pack: Uint8Array;
10377
+ prerequisites: string[];
10378
+ }): Promise<void>;
10379
+ /**
10380
+ * Moves the draft's branch to `commit`, which `prepareCommit` made, or a member pushed on top
10381
+ * of the branch's head, and pushes it. A commit of the tree the branch's head already has, such
10382
+ * as one prepared again after the push of the first, leaves the head as it is. With
10383
+ * `checkout`, for a commit made beside the files, the files take its tree. A member's pushed
10384
+ * head names `mergedMain`, the newest commit of `main` it holds, which the draft's next merge of
10385
+ * `main` merges from. Returns the branch's head and its parents.
10386
+ */
10387
+ commit({ commit, checkout, mergedMain }: {
10388
+ commit: string;
10389
+ checkout?: boolean;
10390
+ mergedMain?: string;
10391
+ }): Promise<{
10392
+ commit: string;
10393
+ parents: string[];
10394
+ }>;
10395
+ /** Whether `commit` is the branch's head or one of its descendants: it includes the head. */
10396
+ includesHead(commit: string): Promise<boolean>;
10397
+ /**
10398
+ * Pushes the draft's code to `main` as one squashed commit, as a publish lands: the tree of
10399
+ * `commit`, a revision on the branch, with the current tip of `main` as its only parent. A
10400
+ * `main` that already has that tree, as after a retried push that landed, is left as it is.
10401
+ * Returns the commit `main` points to.
10402
+ */
10403
+ publishToMain({ commit, message }: {
10404
+ commit: string;
10405
+ message: string;
10406
+ }): Promise<string>;
10407
+ /**
10408
+ * Merges the current `main` into the branch, without moving it: fetches `main` shallowly, its
10409
+ * history down to the `main` commit the branch last merged or forked from, which is then the
10410
+ * merge base, and merges it into the branch's head. A clean merge is returned as a merge commit
10411
+ * whose parents are the head and `main`, for a build to commit (`commit`): the files stay as
10412
+ * they are until then. A merge that conflicts changes nothing either.
10413
+ *
10414
+ * It waits while the files have changes no commit holds, and doesn't merge again a move of
10415
+ * `main` that clashed. Files holding the merge of an earlier `main` that Camox's reconcile
10416
+ * turn didn't fix (`merging`) are put back to the branch's head first, to merge this one.
10417
+ */
10418
+ prepareMerge(): Promise<MergeOutcome>;
10419
+ /** Deletes the draft's branch and everything the working copy stored, as the draft ends. */
10420
+ delete(): Promise<void>;
10421
+ }
10422
+ //#endregion
10205
10423
  //#region ../../apps/api/src/domains/project-creation/workflow.d.ts
10206
10424
  type ProjectCreationParams = {
10207
10425
  /** The new project's Project ID, which names its repo. */
@@ -10388,7 +10606,7 @@ type Dispatch = {
10388
10606
  * `archive` when the API sends it, as it does while it stores it, or else from R2:
10389
10607
  * dispatch serves its client assets from then on, and has loaded and rendered it once. Returns
10390
10608
  * its Definition Set (JSON, not yet checked), with what each part took, for the API's timing
10391
- * logs.
10609
+ * logs. Fails as `REVISION_CODE_THREW` says when the revision's own code throws.
10392
10610
  */
10393
10611
  prepare(revision: RevisionToLoad, archive?: Uint8Array): Promise<PreparedRevision>;
10394
10612
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camox/api-contract",
3
- "version": "0.76.0",
3
+ "version": "0.76.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "src",