flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/packages/contracts/src/work.ts

914 lines31,308 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Initial g1t: services, event bus, intents and attempts1import type { User, Viewer } from "./identity";
2import type { RepoPath } from "./repos";
3import type { Result } from "./result";
4
Issues and pull requests replace intents and attempts5/**
6 * The filter on lists of issues and pull requests. An open pull request is
7 * a draft or one ready for review; a closed one was merged or closed
8 * without merging.
9 */
10export type State = "open" | "closed";
11
12/** Why an issue was closed. */
13export type IssueReason = "completed" | "not_planned";
Initial g1t: services, event bus, intents and attempts14
Issues and pull requests replace intents and attempts15/**
16 * Something that should change in a repository: a bug, a feature, a
17 * question. Opened by a person, an agent or an integration. Pull requests
18 * are made against it; the one that is merged resolves it.
19 *
20 * Issues and pull requests share one sequence of numbers per repository.
21 */
22export type Issue = {
Initial g1t: services, event bus, intents and attempts23 id: string;
24 repoId: string;
Issues and pull requests replace intents and attempts25 /** Shown as `#12`. */
Initial g1t: services, event bus, intents and attempts26 number: number;
27 title: string;
Issues and pull requests replace intents and attempts28 /** Markdown. Also what an agent is given to work from. */
29 body: string;
30 labels: string[];
31 /** Commands that must pass for a pull request to be accepted. */
Initial g1t: services, event bus, intents and attempts32 checks: string[];
Issues and pull requests replace intents and attempts33 state: State;
34 /** Set when closed. */
35 reason: IssueReason | null;
36 /** The number of the pull request whose merge closed this issue. */
37 resolvedBy: number | null;
Initial g1t: services, event bus, intents and attempts38 author: User;
Work service in Rust, with RFC 3339 timestamps39 /** RFC 3339. */
40 createdAt: string;
Issues and pull requests replace intents and attempts41 /** RFC 3339. */
42 updatedAt: string;
43 /** RFC 3339. */
44 closedAt: string | null;
45 /** Pull requests made against this issue, in any state. */
46 pullCount: number;
47 commentCount: number;
Agents as a team: lifecycle, merge queue, billing and a new shell48 /** Usernames of the people it is assigned to. */
49 assignees: string[];
50 /** The numbers of the issues that have to be merged before this one is worked on. */
51 blockedBy: number[];
52 /**
53 * Whether a g1t agent takes it as soon as it can: at once, or when what it
54 * is blocked by has merged.
55 */
56 queued: boolean;
57 /**
58 * The agent working on it now: the one behind its newest pull request
59 * that is still in progress in a fork, such as `g1t-agent`.
60 */
61 agent: string | null;
Initial g1t: services, event bus, intents and attempts62};
63
Issues and pull requests replace intents and attempts64/** `draft` is still being worked on; `open` is ready for review. */
65export type PullStatus = "draft" | "open" | "merged" | "closed";
Initial g1t: services, event bus, intents and attempts66
67/** Where the agent runs: on g1t's sandboxes, or in someone's own session. */
Issues and pull requests replace intents and attempts68export type Runtime = "hosted" | "external";
Initial g1t: services, event bus, intents and attempts69
Pull requests from branches70/**
71 * A proposed change. It is made either in a fork created for it, which is
72 * how agents work, or on a branch pushed to the repository itself.
73 */
Issues and pull requests replace intents and attempts74export type Pull = {
Initial g1t: services, event bus, intents and attempts75 id: string;
76 repoId: string;
Issues and pull requests replace intents and attempts77 /** Shown as `#12`. */
Initial g1t: services, event bus, intents and attempts78 number: number;
Issues and pull requests replace intents and attempts79 /** The number of the issue this is for, if any. */
80 issue: number | null;
81 title: string;
82 /** Markdown: what changed and why. Set when marked ready. */
83 body: string | null;
Initial g1t: services, event bus, intents and attempts84 /** A label for the agent doing the work, e.g. `claude-code`. */
85 agent: string;
Issues and pull requests replace intents and attempts86 runtime: Runtime;
87 status: PullStatus;
Pull requests from branches88 /** The fork holding the change, unless it is on a branch. */
89 fork: RepoPath | null;
Diffs on attempts; hosted agent presented as the g1t agent90 /** The fork's repository id. */
Pull requests from branches91 forkRepoId: string | null;
92 /** The branch of the repository holding the change, unless it is in a fork. */
93 branch: string | null;
Initial g1t: services, event bus, intents and attempts94 headCommit: string | null;
Diffs on attempts; hosted agent presented as the g1t agent95 /**
Issues and pull requests replace intents and attempts96 * For a merged pull request, what the branch pointed to before the merge.
97 * Comparing against it shows what the pull request changed.
98 */
99 mergeBase: string | null;
100 /** Username of whoever merged it. */
101 mergedBy: string | null;
102 /** RFC 3339. */
103 mergedAt: string | null;
104 /**
105 * Set on a pull request closed because another one for the same issue was
106 * merged: that one's number.
Diffs on attempts; hosted agent presented as the g1t agent107 */
Issues and pull requests replace intents and attempts108 supersededBy: number | null;
Acceptance checks in sandboxes, line comments and review verdicts109 /**
110 * Where the latest run of the issue's acceptance checks stands, if there
111 * has been one against the current head.
112 */
113 checkStatus: CheckStatus | null;
Agents as a team: lifecycle, merge queue, billing and a new shell114 /** The files it changes, as of its latest push. */
115 files: ChangedFile[];
116 /** Usernames of the people it is assigned to. */
117 assignees: string[];
118 /**
119 * Those whose review was asked for: usernames, and `g1t-agent` when a g1t
120 * agent was asked.
121 */
122 reviewers: string[];
Issues and pull requests replace intents and attempts123 author: User;
Work service in Rust, with RFC 3339 timestamps124 /** RFC 3339. */
125 createdAt: string;
126 /** RFC 3339. */
127 updatedAt: string;
Initial g1t: services, event bus, intents and attempts128};
129
Agents as a team: lifecycle, merge queue, billing and a new shell130/** One file a pull request changes, and by how much. */
131export type ChangedFile = { path: string; additions: number; deletions: number };
132
133/**
134 * Another pull request in progress that changes some of the same files. Two
135 * for the same issue are alternatives; two for different issues are heading
136 * for a conflict.
137 */
138export type Overlap = {
139 number: number;
140 title: string;
141 /** The number of the issue the other pull request is for. */
142 issue: number | null;
143 /** The files both change. */
144 paths: string[];
145};
146
Acceptance checks in sandboxes, line comments and review verdicts147/** `queued` waits for a sandbox; `errored` means the checks could not be run. */
148export type CheckStatus = "queued" | "running" | "passed" | "failed" | "errored";
149
150/** How one acceptance check went. */
151export type CheckResult = {
152 command: string;
153 passed: boolean;
154 /** Null when the command was stopped for taking too long. */
155 exitCode: number | null;
156 /** What the command printed; the end of it, when there was a lot. */
157 output: string;
158 durationMs: number;
159};
160
161/**
162 * One run of an issue's acceptance checks against a pull request's head, in
163 * a sandbox that holds nothing but that commit.
164 */
165export type CheckRun = {
166 id: string;
167 /** The commit that was checked. */
168 headCommit: string;
169 status: CheckStatus;
170 results: CheckResult[];
171 /** Why the checks could not be run, when `status` is `errored`. */
172 error: string | null;
173 /** RFC 3339. */
174 createdAt: string;
175 /** RFC 3339. */
176 finishedAt: string | null;
177};
178
179/** A reviewer's decision on a pull request. */
180export type Verdict = "approve" | "request_changes";
181
182/**
183 * A comment on an issue or a pull request. On a pull request it can sit on
184 * one line of the change, and it can carry a reviewer's verdict.
185 */
Issues and pull requests replace intents and attempts186export type Comment = {
187 id: string;
Agents as a team: lifecycle, merge queue, billing and a new shell188 /**
189 * Something a person or an agent wrote, or something that happened: an
190 * assignment, a review asked for, a close.
191 */
192 kind: "comment" | "event";
Issues and pull requests replace intents and attempts193 author: User;
Agents as a team: lifecycle, merge queue, billing and a new shell194 /**
195 * Markdown. For an event, what its author did, as the rest of a sentence
196 * that starts with their name: "assigned ana".
197 */
Issues and pull requests replace intents and attempts198 body: string;
Acceptance checks in sandboxes, line comments and review verdicts199 /** The file commented on, for a comment on a line. */
200 path: string | null;
201 /** The line of that file, as numbered after the change. */
202 line: number | null;
203 verdict: Verdict | null;
Issues and pull requests replace intents and attempts204 /** RFC 3339. */
205 createdAt: string;
206};
207
Acceptance checks in sandboxes, line comments and review verdicts208export type NewComment = {
209 /** May be empty when approving. */
210 body: string;
211 path?: string;
212 line?: number;
213 verdict?: Verdict;
214};
215
216/** What a sandbox needs to carry out a check run. */
217export type CheckJob = {
218 runId: string;
219 /** Lets the sandbox, and nothing else, report this run's results. */
220 token: string;
221 commands: string[];
222 /** The repository holding the commit: the fork, or the repository itself. */
223 source: RepoPath;
224 commit: string;
225 /** Who opened the pull request, and so can read its source. */
226 author: User;
227 /** Username of whoever wrote the checks: the issue's author. */
228 requestedBy: string;
229 repo: RepoPath;
230 number: number;
231};
232
233export type CheckReport = { results?: CheckResult[]; error?: string; skip?: boolean };
234
Initial g1t: services, event bus, intents and attempts235export type SessionEntryKind = "prompt" | "message" | "tool_call" | "tool_result" | "note";
236
Issues and pull requests replace intents and attempts237/** One step of an agent's session: the "why" behind a pull request's commits. */
Initial g1t: services, event bus, intents and attempts238export type SessionEntry = {
239 seq: number;
240 kind: SessionEntryKind;
241 text: string;
242 /** For tool calls and results. */
243 tool: string | null;
244 /** The fork's head commit when this entry was recorded, if known. */
245 commit: string | null;
Work service in Rust, with RFC 3339 timestamps246 /** RFC 3339. */
247 at: string;
Initial g1t: services, event bus, intents and attempts248};
249
250export type NewSessionEntry = Pick<SessionEntry, "kind" | "text"> &
Work service in Rust, with RFC 3339 timestamps251 Partial<Pick<SessionEntry, "tool" | "commit">>;
Initial g1t: services, event bus, intents and attempts252
Issues and pull requests replace intents and attempts253export type IssueDetail = {
254 issue: Issue;
255 /** Every pull request made against it, oldest first. */
256 pulls: Pull[];
257 comments: Comment[];
258};
Initial g1t: services, event bus, intents and attempts259
Issues and pull requests replace intents and attempts260export type PullDetail = {
261 pull: Pull;
262 /** The issue it is for, if any. */
263 issue: Issue | null;
264 comments: Comment[];
Acceptance checks in sandboxes, line comments and review verdicts265 /** The latest run of the issue's acceptance checks. */
266 checks: CheckRun | null;
Agents as a team: lifecycle, merge queue, billing and a new shell267 /** Other pull requests in progress that change the same files. */
268 overlaps: Overlap[];
269 /**
270 * Whether the branch it would merge into has moved on without it, so that
271 * it has to catch up before it can merge.
272 */
273 behind: boolean;
274 /** Whether a g1t agent is reviewing it right now. */
275 reviewPending: boolean;
276 /**
277 * Where it stands on its way to being merged, for a pull request g1t is
278 * seeing through. Null on anyone else's.
279 */
280 lifecycle: Lifecycle | null;
281 /**
282 * A merge was asked for while it was behind: g1t is bringing it up to
283 * date and will then land it.
284 */
285 landing: boolean;
286 /** Why g1t stopped working on it, if it did. */
287 stalled: string | null;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request288 /** Messages people sent the agent while it worked, oldest first. */
289 messages: AgentMessage[];
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs290 /** What workflow runs said about its head commit, one per workflow. */
291 statuses?: CommitStatus[];
Agents and memory, checks and conflicts, profiles, slug renames, custom domains292 /**
293 * Whether it merges cleanly into the branch it targets, worked out ahead
294 * of time whenever either side moves.
295 */
296 mergeable?: Mergeable;
297 /** When `mergeable` is `conflicting`: the files that conflict. */
298 conflicts?: string[];
299 /** Earlier runs of its acceptance checks, newest first, without their output. */
300 earlierChecks?: CheckRun[];
301};
302
303/**
304 * Whether a pull request merges cleanly into the branch it targets:
305 * `unknown` when it was never worked out or could not be, `checking` while
306 * a probe merges the two.
307 */
308export type Mergeable = "clean" | "conflicting" | "unknown" | "checking";
309
310/** What a sandbox needs to find out whether a pull request merges cleanly. */
311export type MergecheckJob = {
312 pullId: string;
313 /** Lets the sandbox, and nothing else, report this probe. */
314 token: string;
315 repo: RepoPath;
316 number: number;
317 defaultBranch: string;
318 /** The default branch's commit to merge into. */
319 base: string;
320 /** The repository holding the change: its fork, or the repository. */
321 source: RepoPath;
322 /** The branch of `source` holding it. */
323 branch: string;
324 /** The change's commit. */
325 head: string;
326 /** Who opened the pull request, and so can read its source. */
327 author: User;
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs328};
329
330/** What a workflow run (or another tool) says about a commit. */
331export type CommitStatus = {
332 /** What reported it, such as `CI / push`. */
333 context: string;
334 state: "pending" | "success" | "failure" | "error";
335 description: string | null;
336 targetUrl: string | null;
337 updatedAt: string;
Agents as a team: lifecycle, merge queue, billing and a new shell338};
339
340/**
341 * A step on the way from an assigned issue to a pull request that is ready
342 * to merge. g1t takes each one without being asked: `working` (the agent is
343 * making the change), `checking`, `reviewing`, `revising` (the agent is
344 * addressing failed checks or a review), `catching_up` (merging in the
Agents asked while not at work are woken to answer345 * branch it would land on), `answering` (woken to answer another agent),
346 * then `ready` for a person to merge. `needs_you`
Agents as a team: lifecycle, merge queue, billing and a new shell347 * means g1t has stopped and a person decides what happens next.
348 */
349export type Stage =
350 | "working"
351 | "checking"
352 | "reviewing"
353 | "revising"
354 | "catching_up"
Agents asked while not at work are woken to answer355 | "answering"
Agents as a team: lifecycle, merge queue, billing and a new shell356 | "queued"
357 | "ready"
358 | "needs_you";
359
360export type Lifecycle = {
361 stage: Stage;
362 /** One sentence saying what is happening, or why it stopped. */
363 detail: string;
364 /** How many times the agent has been sent back to revise it. */
365 revisions: number;
366};
367
368/** What the runner needs to carry out a step of a pull request's lifecycle. */
369export type LifecycleJob = {
370 pullId: string;
371 repo: RepoPath;
372 number: number;
373 /** Who the pull request belongs to. Sandboxes act as them. */
374 author: User;
375 /** The repository holding the change: its fork, or the repository itself. */
376 source: RepoPath;
377 /** The branch of the source holding the change; its default branch when null. */
378 branch: string | null;
379 defaultBranch: string;
380 title: string;
381 description: string;
382 issue: Issue | null;
383 /** For a revision: the failed checks or the review to address. */
384 feedback: string;
385 /** For a revision: which one this is, from 1. */
386 round: number;
387};
388
Agents asked while not at work are woken to answer389/** An agent woken to answer what other agents sent it while it was not at work. */
390export type Wake = { job: LifecycleJob; messages: AgentMessage[] };
391
Agents as a team: lifecycle, merge queue, billing and a new shell392/**
393 * `planning` while an agent reads the repository and writes it; `ready` for
394 * a person to read and apply; `failed` if it could not be written;
395 * `applied` once its issues are open.
396 */
397export type PlanStatus = "planning" | "ready" | "failed" | "applied";
398
399/** One issue a plan proposes. */
400export type PlannedIssue = {
401 title: string;
402 /** Markdown: what to change, where, and why. */
403 body: string;
404 labels: string[];
405 /** Commands that must pass once the change is made. */
406 checks: string[];
407 /** The files it will most likely change. */
408 files: string[];
409 /**
410 * The positions, counting from 1, of earlier issues in the plan that have
411 * to be merged first.
412 */
413 dependsOn: number[];
414 /** Its number, once the plan has been applied and it was kept. */
415 number: number | null;
416};
417
418/** An outcome someone wrote, and the issues an agent proposes to get there. */
419export type Plan = {
420 id: string;
421 repoId: string;
422 /** The outcome wanted, as written. */
423 brief: string;
424 status: PlanStatus;
425 /** The agent's account of how it split the work. */
426 summary: string;
427 issues: PlannedIssue[];
428 /** Why it could not be written, when `status` is `failed`. */
429 error: string | null;
430 author: User;
431 /** RFC 3339. */
432 createdAt: string;
433 /** RFC 3339. */
434 finishedAt: string | null;
Dark gray base with lavender as an accent, and a live outcome view for plans435 /** Once applied: where each issue it opened stands now, in plan order. */
436 progress: IssueProgress[];
Agents ask each other, hand each other work, and answer437 /** Questions and handoffs between its pull requests' agents, newest first. */
438 exchanges: AgentMessage[];
Agents as a team: lifecycle, merge queue, billing and a new shell439};
440
441/** What a sandbox needs to write a plan. */
442export type PlanJob = {
443 planId: string;
444 /** Lets the sandbox, and nothing else, report this plan. */
445 token: string;
446 brief: string;
447 repo: RepoPath;
Issues and pull requests replace intents and attempts448};
Initial g1t: services, event bus, intents and attempts449
Agents as a team: lifecycle, merge queue, billing and a new shell450/** An issue waiting for a g1t agent that can be given one now. */
451export type ReadyIssue = {
452 repo: RepoPath;
453 number: number;
454 /** Who queued it, on whose say-so the agent works. */
455 actor: User;
456};
457
458/**
459 * How a repository wants its pull requests handled. A repository that has
460 * changed nothing has the defaults.
461 */
462export type RepoSettings = {
463 /**
464 * Land a g1t agent's pull request without a person once it is ready:
465 * checks passed and approved as the settings below require.
466 */
467 autoMerge: boolean;
468 /**
469 * Refuse to merge a pull request that does not contain the default
470 * branch's latest commits, so that what merges is what was checked. When
471 * off, merging one that is behind brings it up to date first.
472 */
473 requireUpToDate: boolean;
474 /**
475 * How many approving reviews a pull request needs before it may merge. A
476 * reviewer who has since asked for changes blocks it.
477 */
478 requiredApprovals: number;
479 /** Whether a g1t agent's approval counts towards `requiredApprovals`. */
480 countAgentApprovals: boolean;
481 /** Whether a member may merge although the acceptance checks did not pass. */
482 allowIgnoringChecks: boolean;
483 /** Whether a g1t agent's pull request is reviewed by a second agent unasked. */
484 agentReview: boolean;
485 /**
486 * How many times a g1t agent is sent back to its pull request before a
487 * person is asked instead.
488 */
489 maxRevisions: number;
490 /**
491 * Merge through a queue: pull requests are tested together with those
492 * ahead of them, and only a combination that passed reaches the default
493 * branch.
494 */
495 mergeQueue: boolean;
496 /** Username of the member who last changed the settings, if anyone has. */
497 updatedBy: string | null;
498 /** RFC 3339. */
499 updatedAt: string | null;
500};
501
502/** The settings a member can change. */
503export type RepoSettingsInput = Omit<RepoSettings, "updatedBy" | "updatedAt">;
504
505/** The next step for a pull request g1t is seeing through, already claimed. */
506export type Advance =
507 | { action: "none" }
508 | { action: "review" | "revise" | "catch_up"; job: LifecycleJob };
509
510/** What a sandbox needs to review a pull request. */
511export type ReviewJob = {
512 runId: string;
513 /** Lets the sandbox, and nothing else, report this review. */
514 token: string;
515 /** The repository holding the commit: the fork, or the repository itself. */
516 source: RepoPath;
517 commit: string;
518 repo: RepoPath;
519 defaultBranch: string;
520 number: number;
521 title: string;
522 description: string;
523 /** The issue the pull request is for, which says what it should achieve. */
524 issue: Issue | null;
525 /** Who opened the pull request, and so can read its source. */
526 author: User;
527};
528
Issues and pull requests replace intents and attempts529export type OpenIssueInput = {
530 title: string;
531 body: string;
532 labels?: string[];
533 checks?: string[];
534};
535
Agents as a team: lifecycle, merge queue, billing and a new shell536export type UpdateIssueInput = {
537 title?: string;
538 body?: string;
539 labels?: string[];
540 /** Usernames of the people it is assigned to; replaces the whole set. */
541 assignees?: string[];
542};
Issues and pull requests replace intents and attempts543
544export type OpenPullInput = {
545 /** The number of the issue this is for. */
546 issue?: number;
547 /** Defaults to the issue's title; required without an issue. */
548 title?: string;
Pull requests from branches549 /** What changed and why. Usually set later, when a draft is marked ready. */
550 body?: string;
551 /**
552 * A branch of the repository that already holds the change. The pull
553 * request is then ready for review at once and has no fork.
554 */
555 branch?: string;
Issues and pull requests replace intents and attempts556 agent: string;
557 runtime: Runtime;
558};
Initial g1t: services, event bus, intents and attempts559
Issues and pull requests replace intents and attempts560/** Issues, pull requests, comments and sessions. */
Work service in Rust, with RFC 3339 timestamps561export interface WorkApi {
Issues and pull requests replace intents and attempts562 openIssue(actor: User, repo: RepoPath, input: OpenIssueInput): Promise<Result<Issue>>;
563 /** Newest first. */
564 listIssues(
565 repo: RepoPath,
566 viewer: Viewer,
567 filter?: { state?: State; label?: string },
568 ): Promise<Result<Issue[]>>;
569 getIssue(repo: RepoPath, number: number, viewer: Viewer): Promise<Result<IssueDetail>>;
570 /** The author or a member of the workspace may. */
571 updateIssue(actor: User, repo: RepoPath, number: number, input: UpdateIssueInput): Promise<Result<Issue>>;
572 closeIssue(actor: User, repo: RepoPath, number: number, reason?: IssueReason): Promise<Result<Issue>>;
573 reopenIssue(actor: User, repo: RepoPath, number: number): Promise<Result<Issue>>;
574 /** The default labels, then every other label in use on the repository. */
575 listLabels(repo: RepoPath, viewer: Viewer): Promise<Result<string[]>>;
576 /** How many issues and pull requests are open. */
577 counts(repo: RepoPath, viewer: Viewer): Promise<Result<{ issues: number; pulls: number }>>;
Initial g1t: services, event bus, intents and attempts578
Acceptance checks in sandboxes, line comments and review verdicts579 /**
580 * On an issue or a pull request. On a pull request it may name a line of
581 * the change and carry a verdict; nobody can give a verdict on their own.
582 */
583 addComment(actor: User, repo: RepoPath, number: number, comment: NewComment): Promise<Result<Comment>>;
584
585 /**
586 * Begins a run of the acceptance checks for a pull request that is ready
587 * for review. For the runner service, which starts the sandbox.
588 */
589 startChecks(pullId: string): Promise<Result<CheckJob>>;
590 /**
591 * What a sandbox says about its run. With no results and no error it has
592 * started; `skip` forgets a run that will not be carried out.
593 */
594 reportChecks(runId: string, token: string, report: CheckReport): Promise<Result<CheckRun>>;
Agents as a team: lifecycle, merge queue, billing and a new shell595 /** Begins a review by a g1t agent. For the runner service. */
596 startReview(pullId: string): Promise<Result<ReviewJob>>;
597 /** Records that a review could not be written. For the runner service. */
598 failReview(runId: string, token: string, error: string): Promise<Result<boolean>>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains599 /**
600 * Claims the probe of whether a pull request merges cleanly that a
601 * `pull.mergecheck` event asked for. Refused when it is no longer wanted
602 * or the repository has as many running as it may. For the runner service.
603 */
604 startMergecheck(pullId: string): Promise<Result<MergecheckJob>>;
605 /** Records that a probe could not be carried out. For the runner service. */
606 failMergecheck(pullId: string, token: string, error: string): Promise<Result<Mergeable>>;
Agents as a team: lifecycle, merge queue, billing and a new shell607
608 /**
609 * Works out the next step for a pull request g1t is seeing through and,
610 * if there is one to take now, claims it, so that it is taken once
611 * however often this is called. For the runner service.
612 */
613 advance(pullId: string): Promise<Advance>;
614 /** Records that a step could not be carried out, so a person is asked. */
615 stall(pullId: string, reason: string): Promise<boolean>;
616 /** Ids of the open pull requests g1t is seeing through. */
617 managedPulls(repoId?: string): Promise<string[]>;
Issues and pull requests replace intents and attempts618
Agents as a team: lifecycle, merge queue, billing and a new shell619 /** A repository's merge queue: what is in it, in order, and what recently left. */
620 queue(repo: RepoPath, viewer: Viewer): Promise<Result<QueueView>>;
Pull requests from branches621 /**
Agents as a team: lifecycle, merge queue, billing and a new shell622 * The next batch of combined states to test for a repository, one per
623 * entry; empty while a batch is being tested or nothing waits.
624 */
625 queueBuild(repoId: string): Promise<QueueJob[]>;
626 /** Reports that a combined state could not be built or checked. */
627 failQueue(entryId: string, token: string, error: string): Promise<Result<QueueState>>;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request628 /** Sends the agent working on a pull request a message, for its next step. */
629 messageAgent(actor: User, repo: RepoPath, number: number, body: string): Promise<Result<AgentMessage>>;
Agents as a team: lifecycle, merge queue, billing and a new shell630 /** Takes a pull request out of the merge queue. Members only. */
631 removeFromQueue(actor: User, repo: RepoPath, number: number): Promise<Result<Pull>>;
632
633 getSettings(repo: RepoPath, viewer: Viewer): Promise<Result<RepoSettings>>;
634 /** Members of the repository's workspace only. */
635 updateSettings(actor: User, repo: RepoPath, settings: RepoSettingsInput): Promise<Result<RepoSettings>>;
636 /**
637 * What the runner needs to bring a pull request up to date because a
638 * merge of it was asked for. Null if none was.
639 */
640 catchUpJob(pullId: string): Promise<LifecycleJob | null>;
Agents asked while not at work are woken to answer641 /**
642 * Claims a short step for the agent on a pull request to answer the
643 * questions and handoffs it was sent while not at work, and hands them
644 * over, marked read. Null when there is nothing waiting or it cannot
645 * take a step now.
646 */
647 wakeForMessages(pullId: string): Promise<Wake | null>;
Agents as a team: lifecycle, merge queue, billing and a new shell648
649 /**
Pull requests from branches650 * Opens a pull request: a draft with a fork to push to, or, given a
651 * branch, one ready for review.
652 */
Issues and pull requests replace intents and attempts653 openPull(actor: User, repo: RepoPath, input: OpenPullInput): Promise<Result<Pull>>;
654 /** Newest first. */
655 listPulls(repo: RepoPath, viewer: Viewer, state?: State): Promise<Result<Pull[]>>;
656 getPull(repo: RepoPath, number: number, viewer: Viewer): Promise<Result<PullDetail>>;
Agents as a team: lifecycle, merge queue, billing and a new shell657 /**
658 * Changes who a pull request is assigned to and whose review is asked
659 * for; each list given replaces the whole set. Asking for `g1t-agent`'s
660 * review does not by itself start one: the runner's `review` does.
661 */
662 updatePull(
663 actor: User,
664 repo: RepoPath,
665 number: number,
666 changes: { assignees?: string[]; reviewers?: string[] },
667 ): Promise<Result<Pull>>;
Issues and pull requests replace intents and attempts668 /** Marks a draft ready for review and sets its description. */
669 readyPull(actor: User, repo: RepoPath, number: number, summary: string): Promise<Result<Pull>>;
670 closePull(actor: User, repo: RepoPath, number: number): Promise<Result<Pull>>;
Rust repos service with shipping; pull requests kept in the model671 /**
Issues and pull requests replace intents and attempts672 * Lands the pull request on the repository's default branch. Unless
673 * `keepIssueOpen`, that resolves the issue it was for: the issue closes
674 * naming this pull request, and the others still in progress for it close
675 * as superseded. Only members of the repository's workspace may merge.
Agents as a team: lifecycle, merge queue, billing and a new shell676 *
677 * If the default branch has moved, the pull request is brought up to date
678 * first and lands when that is done; it comes back still open, and
679 * `PullDetail.landing` is true meanwhile. A repository that requires pull
680 * requests to be up to date refuses instead.
Rust repos service with shipping; pull requests kept in the model681 */
Acceptance checks in sandboxes, line comments and review verdicts682 mergePull(
683 actor: User,
684 repo: RepoPath,
685 number: number,
686 options?: {
687 keepIssueOpen?: boolean;
688 /** Merge although the acceptance checks have not passed. */
689 ignoreChecks?: boolean;
690 },
691 ): Promise<Result<Pull>>;
Agents as a team: lifecycle, merge queue, billing and a new shell692 /**
693 * Drafts and open pull requests the viewer started, most recently active
694 * first, each with where it stands if g1t is seeing it through.
695 */
696 listActivePulls(
697 viewer: Viewer,
698 ): Promise<{ pull: Pull; issue: Issue | null; lifecycle: Lifecycle | null }[]>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains699 /**
700 * The issues and pull requests a person opened, a page at a time, only
701 * on repositories the viewer may read. Not found for no such account.
702 */
703 byAuthor(username: string, viewer: Viewer, filter?: AuthoredFilter): Promise<Result<Authored>>;
Initial g1t: services, event bus, intents and attempts704
Agents as a team: lifecycle, merge queue, billing and a new shell705 /**
706 * Records an outcome to plan for. Members only. For the runner service,
707 * which starts the sandbox in which an agent writes the plan.
708 */
709 startPlan(actor: User, repo: RepoPath, brief: string): Promise<Result<PlanJob>>;
710 /** Records that a plan could not be written. For the runner service. */
711 failPlan(planId: string, token: string, error: string): Promise<Result<boolean>>;
712 /** Members only. */
713 getPlan(repo: RepoPath, viewer: Viewer, id: string): Promise<Result<Plan>>;
714 /** Newest first. Members only. */
715 listPlans(repo: RepoPath, viewer: Viewer): Promise<Result<Plan[]>>;
716 /**
717 * Opens a plan's issues, each blocked by the ones it depends on. With
718 * `assign`, each is queued for a g1t agent. `keep` holds the positions,
719 * from 1, of the issues to open; all of them when absent. Once.
720 */
721 applyPlan(
722 actor: User,
723 repo: RepoPath,
724 id: string,
725 options?: { assign?: boolean; keep?: number[] },
726 ): Promise<Result<Plan>>;
727 /** Asks for a g1t agent to take an issue as soon as it can, or withdraws that. */
728 queueIssue(actor: User, repo: RepoPath, number: number, queued: boolean): Promise<Result<boolean>>;
729 /** Issues waiting for a g1t agent that can be given one now. For the runner. */
730 readyIssues(repoId?: string): Promise<ReadyIssue[]>;
731
732 /** Open issues assigned to the viewer, most recently changed first. */
733 listAssignedIssues(viewer: Viewer): Promise<Issue[]>;
734
Issues and pull requests replace intents and attempts735 appendSession(actor: User, repo: RepoPath, number: number, entries: NewSessionEntry[]): Promise<Result<{ count: number }>>;
736 readSession(repo: RepoPath, number: number, viewer: Viewer, afterSeq?: number): Promise<Result<SessionEntry[]>>;
Initial g1t: services, event bus, intents and attempts737}
Pull requests from branches738
739/**
740 * What to pass `ReposApi.compare` to see what a pull request changes.
741 *
742 * A fork is compared as a whole. A branch is compared by name while the
743 * pull request is open, and by the commit it was merged or closed at
744 * afterwards, so later pushes to the branch do not change the record.
745 */
746export function pullComparison(pull: Pull): {
747 repoId: string;
748 base: string | null;
749 head: string | null;
750} {
751 if (pull.forkRepoId) return { repoId: pull.forkRepoId, base: pull.mergeBase, head: null };
752 const settled = pull.status === "merged" || pull.status === "closed";
753 return {
754 repoId: pull.repoId,
755 base: pull.mergeBase,
756 head: (settled && pull.headCommit) || pull.branch,
757 };
758}
Agents as a team: lifecycle, merge queue, billing and a new shell759
760
761/** Where a pull request in a merge queue stands. */
Dark gray base with lavender as an accent, and a live outcome view for plans762/** Where one issue of an applied plan stands. */
763export type IssueProgress = {
764 number: number;
765 title: string;
766 /**
767 * `blocked`, `waiting` (for an agent), `open`, a lifecycle stage,
768 * `landed` or `closed`.
769 */
770 state: string;
771 detail: string;
772 /** The issues it is waiting on that are still open. */
773 blockedBy: number[];
774 pull: number | null;
775 agent: string | null;
776};
777
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request778/** A message a person sent an agent at work on a pull request. */
779export type AgentMessage = {
780 id: string;
781 author: string;
782 body: string;
783 createdAt: string;
784 /** When the agent received it; null until then. */
785 deliveredAt: string | null;
Agents ask each other, hand each other work, and answer786 /** `message` from a person; from an agent a `question`, `handoff` or `answer`. */
787 kind: "message" | "question" | "handoff" | "answer";
788 /** The pull request whose agent sent it, when an agent did. */
789 fromNumber: number | null;
790 /** The pull request it was sent to. */
791 toNumber: number;
792 /** The reply to a question or handoff, once there is one. */
793 answer: string | null;
794 declined: boolean;
795 /** For the sending agent: what to expect when the one it asked is not at work. */
796 hint?: string;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request797};
798
Agents as a team: lifecycle, merge queue, billing and a new shell799export type QueueState = "waiting" | "testing" | "passed" | "failed" | "landed" | "removed";
800
801/** One pull request's place in a merge queue. */
802export type QueueEntry = {
803 id: string;
804 number: number;
805 title: string;
806 agent: string;
807 state: QueueState;
808 /** The pull requests merged ahead of it in the state being tested, in order. */
809 ahead: number[];
810 baseCommit: string | null;
811 combinedCommit: string | null;
812 error: string | null;
813 results: CheckResult[];
814 /** Username of whoever merged it into the queue: a person, or `g1t`. */
815 enqueuedBy: string;
816 /** RFC 3339. */
817 createdAt: string;
818 /** RFC 3339. */
819 finishedAt: string | null;
820};
821
822/** A repository's merge queue: what is in it, in order, and what recently left. */
823export type QueueView = {
824 enabled: boolean;
825 active: QueueEntry[];
826 /** Newest first. */
827 recent: QueueEntry[];
828};
829
830export type QueueStackItem = {
831 number: number;
832 title: string;
833 /** The repository holding the change, and its branch. */
834 source: RepoPath;
835 branch: string;
836 commit: string;
837};
838
839/** What a sandbox needs to build and check one combined state. */
840export type QueueJob = {
841 entryId: string;
842 token: string;
843 repo: RepoPath;
844 defaultBranch: string;
845 baseCommit: string;
846 branch: string;
847 stack: QueueStackItem[];
848 checks: string[];
849 /** The checks of issues already completed: the default branch's contract. */
850 contractChecks: string[];
851 actor: User;
852};
Agents and memory, checks and conflicts, profiles, slug renames, custom domains853
854// --- A person's work ---------------------------------------------------------
855// Mirrors the `Authored*` types in `crates/contracts/src/work.rs`.
856
857export type AuthoredKind = "issue" | "pull";
858/** `closed` takes in merged pull requests too; `merged` is only those. */
859export type AuthoredState = "open" | "closed" | "merged";
860/** `created` is newest first, `updated` most recently changed, `oldest` oldest first. */
861export type AuthoredSort = "created" | "updated" | "oldest";
862
863/** The most items one `byAuthor` page holds. */
864export const AUTHORED_PAGE = 25;
865
866export type AuthoredFilter = {
867 kind?: AuthoredKind;
868 state?: AuthoredState;
869 /** `namespace/name`. */
870 repo?: string;
871 sort?: AuthoredSort;
872 /** The `next` of the page before. */
873 before?: string;
874 limit?: number;
875};
876
877export type AuthoredItem = {
878 kind: AuthoredKind;
879 repo: RepoPath;
880 number: number;
881 title: string;
882 /** A merged pull request is closed. */
883 state: State;
884 /** A pull request's own status; null on an issue. */
885 status: PullStatus | null;
886 /** Why an issue was closed. */
887 reason: IssueReason | null;
888 draft: boolean;
889 merged: boolean;
890 /** RFC 3339. */
891 createdAt: string;
892 /** RFC 3339. */
893 updatedAt: string;
894 /** RFC 3339. */
895 mergedAt: string | null;
896};
897
898/** Over every repository the viewer may read, whatever the filters. */
899export type AuthoredCounts = {
900 pullsMerged: number;
901 pullsOpen: number;
902 pulls: number;
903 issues: number;
904 issuesOpen: number;
905};
906
907export type Authored = {
908 items: AuthoredItem[];
909 /** Pass as `before` for the next page; null on the last. */
910 next: string | null;
911 counts: AuthoredCounts;
912 /** The repositories they worked in that the viewer may read, most work first. */
913 repos: { repo: RepoPath; count: number }[];
914};