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 attempts | 1 | import type { User, Viewer } from "./identity"; |
| Catching up with main takes seconds when the two sides touched different files | 2 | import type { PullBranchUpdate, RepoPath } from "./repos"; |
| Initial g1t: services, event bus, intents and attempts | 3 | import type { Result } from "./result"; |
| 4 | ||
| Issues and pull requests replace intents and attempts | 5 | /** |
| 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 | */ | |
| 10 | export type State = "open" | "closed"; | |
| 11 | ||
| 12 | /** Why an issue was closed. */ | |
| 13 | export type IssueReason = "completed" | "not_planned"; | |
| Initial g1t: services, event bus, intents and attempts | 14 | |
| Issues and pull requests replace intents and attempts | 15 | /** |
| 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 | */ | |
| 22 | export type Issue = { | |
| Initial g1t: services, event bus, intents and attempts | 23 | id: string; |
| 24 | repoId: string; | |
| Issues and pull requests replace intents and attempts | 25 | /** Shown as `#12`. */ |
| Initial g1t: services, event bus, intents and attempts | 26 | number: number; |
| 27 | title: string; | |
| Issues and pull requests replace intents and attempts | 28 | /** Markdown. Also what an agent is given to work from. */ |
| 29 | body: string; | |
| 30 | labels: string[]; | |
| 31 | state: State; | |
| 32 | /** Set when closed. */ | |
| 33 | reason: IssueReason | null; | |
| 34 | /** The number of the pull request whose merge closed this issue. */ | |
| 35 | resolvedBy: number | null; | |
| Initial g1t: services, event bus, intents and attempts | 36 | author: User; |
| Work service in Rust, with RFC 3339 timestamps | 37 | /** RFC 3339. */ |
| 38 | createdAt: string; | |
| Issues and pull requests replace intents and attempts | 39 | /** RFC 3339. */ |
| 40 | updatedAt: string; | |
| 41 | /** RFC 3339. */ | |
| 42 | closedAt: string | null; | |
| 43 | /** Pull requests made against this issue, in any state. */ | |
| 44 | pullCount: number; | |
| 45 | commentCount: number; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 46 | /** Usernames of the people it is assigned to. */ |
| 47 | assignees: string[]; | |
| 48 | /** The numbers of the issues that have to be merged before this one is worked on. */ | |
| 49 | blockedBy: number[]; | |
| 50 | /** | |
| 51 | * Whether a g1t agent takes it as soon as it can: at once, or when what it | |
| 52 | * is blocked by has merged. | |
| 53 | */ | |
| 54 | queued: boolean; | |
| 55 | /** | |
| 56 | * The agent working on it now: the one behind its newest pull request | |
| 57 | * that is still in progress in a fork, such as `g1t-agent`. | |
| 58 | */ | |
| 59 | agent: string | null; | |
| Initial g1t: services, event bus, intents and attempts | 60 | }; |
| 61 | ||
| Issues and pull requests replace intents and attempts | 62 | /** `draft` is still being worked on; `open` is ready for review. */ |
| 63 | export type PullStatus = "draft" | "open" | "merged" | "closed"; | |
| Initial g1t: services, event bus, intents and attempts | 64 | |
| 65 | /** Where the agent runs: on g1t's sandboxes, or in someone's own session. */ | |
| Issues and pull requests replace intents and attempts | 66 | export type Runtime = "hosted" | "external"; |
| Initial g1t: services, event bus, intents and attempts | 67 | |
| Pull requests from branches | 68 | /** |
| 69 | * A proposed change. It is made either in a fork created for it, which is | |
| 70 | * how agents work, or on a branch pushed to the repository itself. | |
| 71 | */ | |
| Issues and pull requests replace intents and attempts | 72 | export type Pull = { |
| Initial g1t: services, event bus, intents and attempts | 73 | id: string; |
| 74 | repoId: string; | |
| Issues and pull requests replace intents and attempts | 75 | /** Shown as `#12`. */ |
| Initial g1t: services, event bus, intents and attempts | 76 | number: number; |
| Issues and pull requests replace intents and attempts | 77 | /** The number of the issue this is for, if any. */ |
| 78 | issue: number | null; | |
| 79 | title: string; | |
| 80 | /** Markdown: what changed and why. Set when marked ready. */ | |
| 81 | body: string | null; | |
| Initial g1t: services, event bus, intents and attempts | 82 | /** A label for the agent doing the work, e.g. `claude-code`. */ |
| 83 | agent: string; | |
| Issues and pull requests replace intents and attempts | 84 | runtime: Runtime; |
| 85 | status: PullStatus; | |
| Pull requests from branches | 86 | /** The fork holding the change, unless it is on a branch. */ |
| 87 | fork: RepoPath | null; | |
| Diffs on attempts; hosted agent presented as the g1t agent | 88 | /** The fork's repository id. */ |
| Pull requests from branches | 89 | forkRepoId: string | null; |
| 90 | /** The branch of the repository holding the change, unless it is in a fork. */ | |
| 91 | branch: string | null; | |
| Initial g1t: services, event bus, intents and attempts | 92 | headCommit: string | null; |
| Diffs on attempts; hosted agent presented as the g1t agent | 93 | /** |
| Issues and pull requests replace intents and attempts | 94 | * For a merged pull request, what the branch pointed to before the merge. |
| 95 | * Comparing against it shows what the pull request changed. | |
| 96 | */ | |
| 97 | mergeBase: string | null; | |
| 98 | /** Username of whoever merged it. */ | |
| 99 | mergedBy: string | null; | |
| 100 | /** RFC 3339. */ | |
| 101 | mergedAt: string | null; | |
| 102 | /** | |
| 103 | * Set on a pull request closed because another one for the same issue was | |
| 104 | * merged: that one's number. | |
| Diffs on attempts; hosted agent presented as the g1t agent | 105 | */ |
| Issues and pull requests replace intents and attempts | 106 | supersededBy: number | null; |
| Acceptance checks in sandboxes, line comments and review verdicts | 107 | /** |
| 108 | * Where the latest run of the issue's acceptance checks stands, if there | |
| 109 | * has been one against the current head. | |
| 110 | */ | |
| 111 | checkStatus: CheckStatus | null; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 112 | /** The files it changes, as of its latest push. */ |
| 113 | files: ChangedFile[]; | |
| 114 | /** Usernames of the people it is assigned to. */ | |
| 115 | assignees: string[]; | |
| 116 | /** | |
| 117 | * Those whose review was asked for: usernames, and `g1t-agent` when a g1t | |
| 118 | * agent was asked. | |
| 119 | */ | |
| 120 | reviewers: string[]; | |
| Issues and pull requests replace intents and attempts | 121 | author: User; |
| Work service in Rust, with RFC 3339 timestamps | 122 | /** RFC 3339. */ |
| 123 | createdAt: string; | |
| 124 | /** RFC 3339. */ | |
| 125 | updatedAt: string; | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 126 | /** |
| 127 | * How sure g1t is of a g1t agent's change, from what it can observe, once | |
| 128 | * the agent has finished it. Absent before then, and on changes g1t is | |
| 129 | * not seeing through. | |
| 130 | */ | |
| 131 | confidence?: Confidence | null; | |
| 132 | }; | |
| 133 | ||
| 134 | /** How sure g1t is that an agent's change is right. */ | |
| 135 | export type ConfidenceLevel = "low" | "medium" | "high"; | |
| 136 | ||
| 137 | /** | |
| 138 | * How sure g1t is of a change an agent made, worked out from what can be | |
| 139 | * observed: its checks, how often it was sent back, the reviewer agent's | |
| 140 | * verdict, whether it touched tests, its size, where it reached, how close | |
| 141 | * it came to its guardrails, and what it asked without an answer. The | |
| 142 | * agent's own word can only lower it. | |
| 143 | */ | |
| 144 | export type Confidence = { | |
| 145 | level: ConfidenceLevel; | |
| 146 | /** A few words each, most telling first: what lowered it, or for `high`, what it rests on. */ | |
| 147 | reasons: string[]; | |
| 148 | /** What the agent said of its own change, if it said. */ | |
| 149 | selfReported: ConfidenceLevel | null; | |
| 150 | /** What the agent said it was unsure about. */ | |
| 151 | uncertainAbout: string[]; | |
| 152 | /** The agent run it was worked out after. */ | |
| 153 | runId: string | null; | |
| 154 | /** RFC 3339. */ | |
| 155 | assessedAt: string; | |
| 156 | }; | |
| 157 | ||
| 158 | /** What became of the agent when an issue was opened and handed to it in one step. */ | |
| 159 | export type AgentStartStatus = "started" | "queued" | "not_started"; | |
| 160 | ||
| 161 | /** Whether the agent started, and if not, why and what fixes it. */ | |
| 162 | export type AgentStart = { | |
| 163 | status: AgentStartStatus; | |
| 164 | /** | |
| 165 | * Why it did not start: `not_paid`, `trial_used`, `limit`, `paused`, | |
| 166 | * `issue_cap`, `billing_unavailable` or `no_model`; `waiting` when queued. | |
| 167 | */ | |
| 168 | code: string | null; | |
| 169 | /** What happened, in a sentence or two, with what to do. */ | |
| 170 | message: string | null; | |
| 171 | /** Where the fix is: the workspace's billing or model settings. */ | |
| 172 | fixUrl: string | null; | |
| Initial g1t: services, event bus, intents and attempts | 173 | }; |
| 174 | ||
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 175 | /** An issue opened and handed to g1t-agent in one step. The issue exists whatever became of the agent. */ |
| 176 | export type Delegated = { | |
| 177 | issue: Issue; | |
| 178 | /** The pull request the agent opened, when it started. */ | |
| 179 | pull: Pull | null; | |
| 180 | agent: AgentStart; | |
| 181 | }; | |
| 182 | ||
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 183 | /** |
| 184 | * What to put an agent on: an issue's title, and what to do in plain words, | |
| 185 | * with what done means if you like (a "Definition of done" section). What | |
| 186 | * has to pass before it merges is the branch's required checks. | |
| 187 | */ | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 188 | export type DelegateInput = { |
| 189 | title: string; | |
| 190 | body: string; | |
| 191 | labels?: string[]; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 192 | /** Deprecated: commands, added to the body under "Definition of done". */ |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 193 | checks?: string[]; |
| 194 | }; | |
| 195 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 196 | /** One file a pull request changes, and by how much. */ |
| 197 | export type ChangedFile = { path: string; additions: number; deletions: number }; | |
| 198 | ||
| 199 | /** | |
| 200 | * Another pull request in progress that changes some of the same files. Two | |
| 201 | * for the same issue are alternatives; two for different issues are heading | |
| 202 | * for a conflict. | |
| 203 | */ | |
| 204 | export type Overlap = { | |
| 205 | number: number; | |
| 206 | title: string; | |
| 207 | /** The number of the issue the other pull request is for. */ | |
| 208 | issue: number | null; | |
| 209 | /** The files both change. */ | |
| 210 | paths: string[]; | |
| 211 | }; | |
| 212 | ||
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 213 | /** |
| 214 | * On a pull request, `failed` means the merge queue took it out, until its | |
| 215 | * head moves. The other states are from runs of commands written on issues, | |
| 216 | * which g1t no longer runs. | |
| 217 | */ | |
| Acceptance checks in sandboxes, line comments and review verdicts | 218 | export type CheckStatus = "queued" | "running" | "passed" | "failed" | "errored"; |
| 219 | ||
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 220 | /** How one command went, in a run recorded before checks were workflows. */ |
| Acceptance checks in sandboxes, line comments and review verdicts | 221 | export type CheckResult = { |
| 222 | command: string; | |
| 223 | passed: boolean; | |
| 224 | /** Null when the command was stopped for taking too long. */ | |
| 225 | exitCode: number | null; | |
| 226 | /** What the command printed; the end of it, when there was a lot. */ | |
| 227 | output: string; | |
| 228 | durationMs: number; | |
| 229 | }; | |
| 230 | ||
| 231 | /** | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 232 | * A record against a pull request's head: the merge queue taking it out, |
| 233 | * with why, or an earlier run of commands written on its issue. | |
| Acceptance checks in sandboxes, line comments and review verdicts | 234 | */ |
| 235 | export type CheckRun = { | |
| 236 | id: string; | |
| 237 | /** The commit that was checked. */ | |
| 238 | headCommit: string; | |
| 239 | status: CheckStatus; | |
| 240 | results: CheckResult[]; | |
| 241 | /** Why the checks could not be run, when `status` is `errored`. */ | |
| 242 | error: string | null; | |
| 243 | /** RFC 3339. */ | |
| 244 | createdAt: string; | |
| 245 | /** RFC 3339. */ | |
| 246 | finishedAt: string | null; | |
| 247 | }; | |
| 248 | ||
| 249 | /** A reviewer's decision on a pull request. */ | |
| 250 | export type Verdict = "approve" | "request_changes"; | |
| 251 | ||
| 252 | /** | |
| 253 | * A comment on an issue or a pull request. On a pull request it can sit on | |
| 254 | * one line of the change, and it can carry a reviewer's verdict. | |
| 255 | */ | |
| Issues and pull requests replace intents and attempts | 256 | export type Comment = { |
| 257 | id: string; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 258 | /** |
| 259 | * Something a person or an agent wrote, or something that happened: an | |
| 260 | * assignment, a review asked for, a close. | |
| 261 | */ | |
| 262 | kind: "comment" | "event"; | |
| Issues and pull requests replace intents and attempts | 263 | author: User; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 264 | /** |
| 265 | * Markdown. For an event, what its author did, as the rest of a sentence | |
| 266 | * that starts with their name: "assigned ana". | |
| 267 | */ | |
| Issues and pull requests replace intents and attempts | 268 | body: string; |
| Acceptance checks in sandboxes, line comments and review verdicts | 269 | /** The file commented on, for a comment on a line. */ |
| 270 | path: string | null; | |
| 271 | /** The line of that file, as numbered after the change. */ | |
| 272 | line: number | null; | |
| 273 | verdict: Verdict | null; | |
| Issues and pull requests replace intents and attempts | 274 | /** RFC 3339. */ |
| 275 | createdAt: string; | |
| 276 | }; | |
| 277 | ||
| Acceptance checks in sandboxes, line comments and review verdicts | 278 | export type NewComment = { |
| 279 | /** May be empty when approving. */ | |
| 280 | body: string; | |
| 281 | path?: string; | |
| 282 | line?: number; | |
| 283 | verdict?: Verdict; | |
| 284 | }; | |
| 285 | ||
| 286 | /** What a sandbox needs to carry out a check run. */ | |
| 287 | export type CheckJob = { | |
| 288 | runId: string; | |
| 289 | /** Lets the sandbox, and nothing else, report this run's results. */ | |
| 290 | token: string; | |
| 291 | commands: string[]; | |
| 292 | /** The repository holding the commit: the fork, or the repository itself. */ | |
| 293 | source: RepoPath; | |
| 294 | commit: string; | |
| 295 | /** Who opened the pull request, and so can read its source. */ | |
| 296 | author: User; | |
| 297 | /** Username of whoever wrote the checks: the issue's author. */ | |
| 298 | requestedBy: string; | |
| 299 | repo: RepoPath; | |
| 300 | number: number; | |
| 301 | }; | |
| 302 | ||
| 303 | export type CheckReport = { results?: CheckResult[]; error?: string; skip?: boolean }; | |
| 304 | ||
| Initial g1t: services, event bus, intents and attempts | 305 | export type SessionEntryKind = "prompt" | "message" | "tool_call" | "tool_result" | "note"; |
| 306 | ||
| Issues and pull requests replace intents and attempts | 307 | /** One step of an agent's session: the "why" behind a pull request's commits. */ |
| Initial g1t: services, event bus, intents and attempts | 308 | export type SessionEntry = { |
| 309 | seq: number; | |
| 310 | kind: SessionEntryKind; | |
| 311 | text: string; | |
| 312 | /** For tool calls and results. */ | |
| 313 | tool: string | null; | |
| 314 | /** The fork's head commit when this entry was recorded, if known. */ | |
| 315 | commit: string | null; | |
| Work service in Rust, with RFC 3339 timestamps | 316 | /** RFC 3339. */ |
| 317 | at: string; | |
| Initial g1t: services, event bus, intents and attempts | 318 | }; |
| 319 | ||
| 320 | export type NewSessionEntry = Pick<SessionEntry, "kind" | "text"> & | |
| Work service in Rust, with RFC 3339 timestamps | 321 | Partial<Pick<SessionEntry, "tool" | "commit">>; |
| Initial g1t: services, event bus, intents and attempts | 322 | |
| Issues and pull requests replace intents and attempts | 323 | export type IssueDetail = { |
| 324 | issue: Issue; | |
| 325 | /** Every pull request made against it, oldest first. */ | |
| 326 | pulls: Pull[]; | |
| 327 | comments: Comment[]; | |
| 328 | }; | |
| Initial g1t: services, event bus, intents and attempts | 329 | |
| Issues and pull requests replace intents and attempts | 330 | export type PullDetail = { |
| 331 | pull: Pull; | |
| 332 | /** The issue it is for, if any. */ | |
| 333 | issue: Issue | null; | |
| 334 | comments: Comment[]; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 335 | /** The latest record against its head: the merge queue taking it out. */ |
| Acceptance checks in sandboxes, line comments and review verdicts | 336 | checks: CheckRun | null; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 337 | /** Other pull requests in progress that change the same files. */ |
| 338 | overlaps: Overlap[]; | |
| 339 | /** | |
| 340 | * Whether the branch it would merge into has moved on without it, so that | |
| 341 | * it has to catch up before it can merge. | |
| 342 | */ | |
| 343 | behind: boolean; | |
| 344 | /** Whether a g1t agent is reviewing it right now. */ | |
| 345 | reviewPending: boolean; | |
| 346 | /** | |
| 347 | * Where it stands on its way to being merged, for a pull request g1t is | |
| 348 | * seeing through. Null on anyone else's. | |
| 349 | */ | |
| 350 | lifecycle: Lifecycle | null; | |
| 351 | /** | |
| 352 | * A merge was asked for while it was behind: g1t is bringing it up to | |
| 353 | * date and will then land it. | |
| 354 | */ | |
| 355 | landing: boolean; | |
| 356 | /** Why g1t stopped working on it, if it did. */ | |
| 357 | stalled: string | null; | |
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 358 | /** Messages people sent the agent while it worked, oldest first. */ |
| 359 | messages: AgentMessage[]; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 360 | /** What workflow runs said about its head commit, one per workflow. */ |
| 361 | statuses?: CommitStatus[]; | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 362 | /** |
| 363 | * Whether it merges cleanly into the branch it targets, worked out ahead | |
| 364 | * of time whenever either side moves. | |
| 365 | */ | |
| 366 | mergeable?: Mergeable; | |
| 367 | /** When `mergeable` is `conflicting`: the files that conflict. */ | |
| 368 | conflicts?: string[]; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 369 | /** Earlier records like `checks`, newest first, without their output. */ |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 370 | earlierChecks?: CheckRun[]; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 371 | /** |
| 372 | * The checks the default branch's protection requires, each as it stands | |
| 373 | * on the head commit. Empty when none are required. | |
| 374 | */ | |
| 375 | requiredChecks?: RequiredCheck[]; | |
| 376 | }; | |
| 377 | ||
| 378 | /** Where a required check stands on a commit; `expected` when nothing has reported it yet. */ | |
| 379 | export type RequiredState = "success" | "failure" | "pending" | "expected"; | |
| 380 | ||
| 381 | /** One check a branch's protection requires, as it stands on a commit. */ | |
| 382 | export type RequiredCheck = { | |
| 383 | /** A workflow's name, such as `CI`, or another status's context. */ | |
| 384 | name: string; | |
| 385 | state: RequiredState; | |
| 386 | description: string | null; | |
| 387 | /** Where to see more: the workflow run, for one a workflow reported. */ | |
| 388 | targetUrl: string | null; | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 389 | }; |
| 390 | ||
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 391 | /** A check name reported on a repository's commits lately, for choosing required checks. */ |
| 392 | export type SeenCheck = { | |
| 393 | name: string; | |
| 394 | /** The events it was reported for, such as `pull_request`; empty for a status that names none. */ | |
| 395 | events: string[]; | |
| 396 | /** RFC 3339. */ | |
| 397 | lastSeen: string; | |
| 398 | }; | |
| 399 | ||
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 400 | /** |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 401 | * A status context's check name: `CI / pull_request` is the `CI` check, |
| 402 | * reported for a `pull_request` event. A context that does not end in an | |
| 403 | * event, such as `g1t / deploy`, is its own name. As the work service reads it. | |
| 404 | */ | |
| 405 | export function checkName(context: string): string { | |
| 406 | const at = context.lastIndexOf(" / "); | |
| 407 | if (at <= 0) return context; | |
| 408 | return STATUS_EVENTS.has(context.slice(at + 3)) ? context.slice(0, at) : context; | |
| 409 | } | |
| 410 | ||
| 411 | const STATUS_EVENTS = new Set([ | |
| 412 | "push", | |
| 413 | "pull_request", | |
| 414 | "pull_request_target", | |
| 415 | "pull_request_review", | |
| 416 | "merge_group", | |
| 417 | "workflow_dispatch", | |
| 418 | "workflow_run", | |
| 419 | "workflow_call", | |
| 420 | "schedule", | |
| 421 | "release", | |
| 422 | "issues", | |
| 423 | "issue_comment", | |
| 424 | "repository_dispatch", | |
| 425 | ]); | |
| 426 | ||
| 427 | /** | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 428 | * Whether a pull request merges cleanly into the branch it targets: |
| 429 | * `unknown` when it was never worked out or could not be, `checking` while | |
| 430 | * a probe merges the two. | |
| 431 | */ | |
| 432 | export type Mergeable = "clean" | "conflicting" | "unknown" | "checking"; | |
| 433 | ||
| 434 | /** What a sandbox needs to find out whether a pull request merges cleanly. */ | |
| 435 | export type MergecheckJob = { | |
| 436 | pullId: string; | |
| 437 | /** Lets the sandbox, and nothing else, report this probe. */ | |
| 438 | token: string; | |
| 439 | repo: RepoPath; | |
| 440 | number: number; | |
| 441 | defaultBranch: string; | |
| 442 | /** The default branch's commit to merge into. */ | |
| 443 | base: string; | |
| 444 | /** The repository holding the change: its fork, or the repository. */ | |
| 445 | source: RepoPath; | |
| 446 | /** The branch of `source` holding it. */ | |
| 447 | branch: string; | |
| 448 | /** The change's commit. */ | |
| 449 | head: string; | |
| 450 | /** Who opened the pull request, and so can read its source. */ | |
| 451 | author: User; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 452 | }; |
| 453 | ||
| 454 | /** What a workflow run (or another tool) says about a commit. */ | |
| 455 | export type CommitStatus = { | |
| 456 | /** What reported it, such as `CI / push`. */ | |
| 457 | context: string; | |
| 458 | state: "pending" | "success" | "failure" | "error"; | |
| 459 | description: string | null; | |
| 460 | targetUrl: string | null; | |
| 461 | updatedAt: string; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 462 | }; |
| 463 | ||
| 464 | /** | |
| 465 | * A step on the way from an assigned issue to a pull request that is ready | |
| 466 | * to merge. g1t takes each one without being asked: `working` (the agent is | |
| 467 | * making the change), `checking`, `reviewing`, `revising` (the agent is | |
| 468 | * addressing failed checks or a review), `catching_up` (merging in the | |
| Agents asked while not at work are woken to answer | 469 | * branch it would land on), `answering` (woken to answer another agent), |
| 470 | * then `ready` for a person to merge. `needs_you` | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 471 | * means g1t has stopped and a person decides what happens next. |
| 472 | */ | |
| 473 | export type Stage = | |
| 474 | | "working" | |
| 475 | | "checking" | |
| 476 | | "reviewing" | |
| 477 | | "revising" | |
| 478 | | "catching_up" | |
| Agents asked while not at work are woken to answer | 479 | | "answering" |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 480 | | "queued" |
| 481 | | "ready" | |
| 482 | | "needs_you"; | |
| 483 | ||
| 484 | export type Lifecycle = { | |
| 485 | stage: Stage; | |
| 486 | /** One sentence saying what is happening, or why it stopped. */ | |
| 487 | detail: string; | |
| 488 | /** How many times the agent has been sent back to revise it. */ | |
| 489 | revisions: number; | |
| 490 | }; | |
| 491 | ||
| 492 | /** What the runner needs to carry out a step of a pull request's lifecycle. */ | |
| 493 | export type LifecycleJob = { | |
| 494 | pullId: string; | |
| 495 | repo: RepoPath; | |
| 496 | number: number; | |
| 497 | /** Who the pull request belongs to. Sandboxes act as them. */ | |
| 498 | author: User; | |
| 499 | /** The repository holding the change: its fork, or the repository itself. */ | |
| 500 | source: RepoPath; | |
| 501 | /** The branch of the source holding the change; its default branch when null. */ | |
| 502 | branch: string | null; | |
| 503 | defaultBranch: string; | |
| 504 | title: string; | |
| 505 | description: string; | |
| 506 | issue: Issue | null; | |
| 507 | /** For a revision: the failed checks or the review to address. */ | |
| 508 | feedback: string; | |
| 509 | /** For a revision: which one this is, from 1. */ | |
| 510 | round: number; | |
| 511 | }; | |
| 512 | ||
| Agents asked while not at work are woken to answer | 513 | /** An agent woken to answer what other agents sent it while it was not at work. */ |
| 514 | export type Wake = { job: LifecycleJob; messages: AgentMessage[] }; | |
| 515 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 516 | /** |
| 517 | * `planning` while an agent reads the repository and writes it; `ready` for | |
| 518 | * a person to read and apply; `failed` if it could not be written; | |
| 519 | * `applied` once its issues are open. | |
| 520 | */ | |
| 521 | export type PlanStatus = "planning" | "ready" | "failed" | "applied"; | |
| 522 | ||
| 523 | /** One issue a plan proposes. */ | |
| 524 | export type PlannedIssue = { | |
| 525 | title: string; | |
| 526 | /** Markdown: what to change, where, and why. */ | |
| 527 | body: string; | |
| 528 | labels: string[]; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 529 | /** What is true once it is done, in plain words; added to the issue's body under "Definition of done". */ |
| 530 | done: string[]; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 531 | /** The files it will most likely change. */ |
| 532 | files: string[]; | |
| 533 | /** | |
| 534 | * The positions, counting from 1, of earlier issues in the plan that have | |
| 535 | * to be merged first. | |
| 536 | */ | |
| 537 | dependsOn: number[]; | |
| 538 | /** Its number, once the plan has been applied and it was kept. */ | |
| 539 | number: number | null; | |
| 540 | }; | |
| 541 | ||
| 542 | /** An outcome someone wrote, and the issues an agent proposes to get there. */ | |
| 543 | export type Plan = { | |
| 544 | id: string; | |
| 545 | repoId: string; | |
| 546 | /** The outcome wanted, as written. */ | |
| 547 | brief: string; | |
| 548 | status: PlanStatus; | |
| 549 | /** The agent's account of how it split the work. */ | |
| 550 | summary: string; | |
| 551 | issues: PlannedIssue[]; | |
| 552 | /** Why it could not be written, when `status` is `failed`. */ | |
| 553 | error: string | null; | |
| 554 | author: User; | |
| 555 | /** RFC 3339. */ | |
| 556 | createdAt: string; | |
| 557 | /** RFC 3339. */ | |
| 558 | finishedAt: string | null; | |
| Dark gray base with lavender as an accent, and a live outcome view for plans | 559 | /** Once applied: where each issue it opened stands now, in plan order. */ |
| 560 | progress: IssueProgress[]; | |
| Agents ask each other, hand each other work, and answer | 561 | /** Questions and handoffs between its pull requests' agents, newest first. */ |
| 562 | exchanges: AgentMessage[]; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 563 | }; |
| 564 | ||
| 565 | /** What a sandbox needs to write a plan. */ | |
| 566 | export type PlanJob = { | |
| 567 | planId: string; | |
| 568 | /** Lets the sandbox, and nothing else, report this plan. */ | |
| 569 | token: string; | |
| 570 | brief: string; | |
| 571 | repo: RepoPath; | |
| Issues and pull requests replace intents and attempts | 572 | }; |
| Initial g1t: services, event bus, intents and attempts | 573 | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 574 | /** An issue waiting for a g1t agent that can be given one now. */ |
| 575 | export type ReadyIssue = { | |
| 576 | repo: RepoPath; | |
| 577 | number: number; | |
| 578 | /** Who queued it, on whose say-so the agent works. */ | |
| 579 | actor: User; | |
| 580 | }; | |
| 581 | ||
| 582 | /** | |
| 583 | * How a repository wants its pull requests handled. A repository that has | |
| 584 | * changed nothing has the defaults. | |
| 585 | */ | |
| 586 | export type RepoSettings = { | |
| 587 | /** | |
| 588 | * Land a g1t agent's pull request without a person once it is ready: | |
| 589 | * checks passed and approved as the settings below require. | |
| 590 | */ | |
| 591 | autoMerge: boolean; | |
| 592 | /** | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 593 | * The checks that must pass on a pull request's head before it may merge |
| 594 | * into the default branch, by name: a workflow's name (`CI`) or another | |
| 595 | * status's context (`g1t / deploy`). The same for people and agents, and | |
| 596 | * for the merge queue. | |
| 597 | */ | |
| 598 | requiredChecks: string[]; | |
| 599 | /** | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 600 | * Refuse to merge a pull request that does not contain the default |
| 601 | * branch's latest commits, so that what merges is what was checked. When | |
| 602 | * off, merging one that is behind brings it up to date first. | |
| 603 | */ | |
| 604 | requireUpToDate: boolean; | |
| 605 | /** | |
| 606 | * How many approving reviews a pull request needs before it may merge. A | |
| 607 | * reviewer who has since asked for changes blocks it. | |
| 608 | */ | |
| 609 | requiredApprovals: number; | |
| 610 | /** Whether a g1t agent's approval counts towards `requiredApprovals`. */ | |
| 611 | countAgentApprovals: boolean; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 612 | /** Whether someone who may merge can bypass required checks that have not passed. */ |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 613 | allowIgnoringChecks: boolean; |
| 614 | /** Whether a g1t agent's pull request is reviewed by a second agent unasked. */ | |
| 615 | agentReview: boolean; | |
| 616 | /** | |
| 617 | * How many times a g1t agent is sent back to its pull request before a | |
| 618 | * person is asked instead. | |
| 619 | */ | |
| 620 | maxRevisions: number; | |
| 621 | /** | |
| 622 | * Merge through a queue: pull requests are tested together with those | |
| 623 | * ahead of them, and only a combination that passed reaches the default | |
| 624 | * branch. | |
| 625 | */ | |
| 626 | mergeQueue: boolean; | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 627 | /** |
| 628 | * Ask a person before merging a g1t agent's change whose confidence is | |
| 629 | * low: auto-merge and the merge queue leave it until a person approves it. | |
| 630 | */ | |
| 631 | holdLowConfidence: boolean; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 632 | /** Username of the member who last changed the settings, if anyone has. */ |
| 633 | updatedBy: string | null; | |
| 634 | /** RFC 3339. */ | |
| 635 | updatedAt: string | null; | |
| 636 | }; | |
| 637 | ||
| 638 | /** The settings a member can change. */ | |
| 639 | export type RepoSettingsInput = Omit<RepoSettings, "updatedBy" | "updatedAt">; | |
| 640 | ||
| 641 | /** The next step for a pull request g1t is seeing through, already claimed. */ | |
| 642 | export type Advance = | |
| 643 | | { action: "none" } | |
| 644 | | { action: "review" | "revise" | "catch_up"; job: LifecycleJob }; | |
| 645 | ||
| 646 | /** What a sandbox needs to review a pull request. */ | |
| 647 | export type ReviewJob = { | |
| 648 | runId: string; | |
| 649 | /** Lets the sandbox, and nothing else, report this review. */ | |
| 650 | token: string; | |
| 651 | /** The repository holding the commit: the fork, or the repository itself. */ | |
| 652 | source: RepoPath; | |
| 653 | commit: string; | |
| 654 | repo: RepoPath; | |
| 655 | defaultBranch: string; | |
| 656 | number: number; | |
| 657 | title: string; | |
| 658 | description: string; | |
| 659 | /** The issue the pull request is for, which says what it should achieve. */ | |
| 660 | issue: Issue | null; | |
| 661 | /** Who opened the pull request, and so can read its source. */ | |
| 662 | author: User; | |
| 663 | }; | |
| 664 | ||
| Issues and pull requests replace intents and attempts | 665 | export type OpenIssueInput = { |
| 666 | title: string; | |
| 667 | body: string; | |
| 668 | labels?: string[]; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 669 | /** Deprecated: commands, added to the body under "Definition of done". */ |
| Issues and pull requests replace intents and attempts | 670 | checks?: string[]; |
| 671 | }; | |
| 672 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 673 | export type UpdateIssueInput = { |
| 674 | title?: string; | |
| 675 | body?: string; | |
| 676 | labels?: string[]; | |
| 677 | /** Usernames of the people it is assigned to; replaces the whole set. */ | |
| 678 | assignees?: string[]; | |
| 679 | }; | |
| Issues and pull requests replace intents and attempts | 680 | |
| 681 | export type OpenPullInput = { | |
| 682 | /** The number of the issue this is for. */ | |
| 683 | issue?: number; | |
| 684 | /** Defaults to the issue's title; required without an issue. */ | |
| 685 | title?: string; | |
| Pull requests from branches | 686 | /** What changed and why. Usually set later, when a draft is marked ready. */ |
| 687 | body?: string; | |
| 688 | /** | |
| 689 | * A branch of the repository that already holds the change. The pull | |
| 690 | * request is then ready for review at once and has no fork. | |
| 691 | */ | |
| 692 | branch?: string; | |
| Issues and pull requests replace intents and attempts | 693 | agent: string; |
| 694 | runtime: Runtime; | |
| 695 | }; | |
| Initial g1t: services, event bus, intents and attempts | 696 | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 697 | /** One repository's pull requests from `pullsForRepos`, newest first. */ |
| 698 | export type RepoPulls = { | |
| 699 | repoId: string; | |
| 700 | /** Draft and open. */ | |
| 701 | open: Pull[]; | |
| 702 | /** Merged and closed. */ | |
| 703 | closed: Pull[]; | |
| 704 | }; | |
| 705 | ||
| Issues and pull requests replace intents and attempts | 706 | /** Issues, pull requests, comments and sessions. */ |
| Work service in Rust, with RFC 3339 timestamps | 707 | export interface WorkApi { |
| Issues and pull requests replace intents and attempts | 708 | openIssue(actor: User, repo: RepoPath, input: OpenIssueInput): Promise<Result<Issue>>; |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 709 | /** |
| 710 | * Opens an issue to put g1t-agent on at once: refused, with nothing | |
| 711 | * opened, unless `actor` may put agents to work in `repo`. The runner's | |
| 712 | * `delegate` calls it, then starts the agent. | |
| 713 | */ | |
| 714 | delegateIssue(actor: User, repo: RepoPath, input: DelegateInput): Promise<Result<Issue>>; | |
| Issues and pull requests replace intents and attempts | 715 | /** Newest first. */ |
| 716 | listIssues( | |
| 717 | repo: RepoPath, | |
| 718 | viewer: Viewer, | |
| 719 | filter?: { state?: State; label?: string }, | |
| 720 | ): Promise<Result<Issue[]>>; | |
| 721 | getIssue(repo: RepoPath, number: number, viewer: Viewer): Promise<Result<IssueDetail>>; | |
| 722 | /** The author or a member of the workspace may. */ | |
| 723 | updateIssue(actor: User, repo: RepoPath, number: number, input: UpdateIssueInput): Promise<Result<Issue>>; | |
| 724 | closeIssue(actor: User, repo: RepoPath, number: number, reason?: IssueReason): Promise<Result<Issue>>; | |
| 725 | reopenIssue(actor: User, repo: RepoPath, number: number): Promise<Result<Issue>>; | |
| 726 | /** The default labels, then every other label in use on the repository. */ | |
| 727 | listLabels(repo: RepoPath, viewer: Viewer): Promise<Result<string[]>>; | |
| 728 | /** How many issues and pull requests are open. */ | |
| 729 | counts(repo: RepoPath, viewer: Viewer): Promise<Result<{ issues: number; pulls: number }>>; | |
| Initial g1t: services, event bus, intents and attempts | 730 | |
| Acceptance checks in sandboxes, line comments and review verdicts | 731 | /** |
| 732 | * On an issue or a pull request. On a pull request it may name a line of | |
| 733 | * the change and carry a verdict; nobody can give a verdict on their own. | |
| 734 | */ | |
| 735 | addComment(actor: User, repo: RepoPath, number: number, comment: NewComment): Promise<Result<Comment>>; | |
| 736 | ||
| 737 | /** | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 738 | * Always refused now: a pull request's checks are the workflows run on |
| 739 | * it. Kept for a runner from before. | |
| Acceptance checks in sandboxes, line comments and review verdicts | 740 | */ |
| 741 | startChecks(pullId: string): Promise<Result<CheckJob>>; | |
| 742 | /** | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 743 | * What a sandbox says about a run from before checks were workflows: so |
| 744 | * one still finishing is recorded. | |
| Acceptance checks in sandboxes, line comments and review verdicts | 745 | */ |
| 746 | reportChecks(runId: string, token: string, report: CheckReport): Promise<Result<CheckRun>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 747 | /** Begins a review by a g1t agent. For the runner service. */ |
| 748 | startReview(pullId: string): Promise<Result<ReviewJob>>; | |
| 749 | /** Records that a review could not be written. For the runner service. */ | |
| 750 | failReview(runId: string, token: string, error: string): Promise<Result<boolean>>; | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 751 | /** |
| 752 | * Claims the probe of whether a pull request merges cleanly that a | |
| 753 | * `pull.mergecheck` event asked for. Refused when it is no longer wanted | |
| 754 | * or the repository has as many running as it may. For the runner service. | |
| 755 | */ | |
| 756 | startMergecheck(pullId: string): Promise<Result<MergecheckJob>>; | |
| 757 | /** Records that a probe could not be carried out. For the runner service. */ | |
| 758 | failMergecheck(pullId: string, token: string, error: string): Promise<Result<Mergeable>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 759 | |
| 760 | /** | |
| 761 | * Works out the next step for a pull request g1t is seeing through and, | |
| 762 | * if there is one to take now, claims it, so that it is taken once | |
| 763 | * however often this is called. For the runner service. | |
| 764 | */ | |
| 765 | advance(pullId: string): Promise<Advance>; | |
| 766 | /** Records that a step could not be carried out, so a person is asked. */ | |
| 767 | stall(pullId: string, reason: string): Promise<boolean>; | |
| 768 | /** Ids of the open pull requests g1t is seeing through. */ | |
| 769 | managedPulls(repoId?: string): Promise<string[]>; | |
| Issues and pull requests replace intents and attempts | 770 | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 771 | /** A repository's merge queue: what is in it, in order, and what recently left. */ |
| 772 | queue(repo: RepoPath, viewer: Viewer): Promise<Result<QueueView>>; | |
| Pull requests from branches | 773 | /** |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 774 | * The next batch of combined states to test for a repository, one per |
| 775 | * entry; empty while a batch is being tested or nothing waits. | |
| 776 | */ | |
| 777 | queueBuild(repoId: string): Promise<QueueJob[]>; | |
| 778 | /** Reports that a combined state could not be built or checked. */ | |
| 779 | 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 request | 780 | /** Sends the agent working on a pull request a message, for its next step. */ |
| 781 | messageAgent(actor: User, repo: RepoPath, number: number, body: string): Promise<Result<AgentMessage>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 782 | /** Takes a pull request out of the merge queue. Members only. */ |
| 783 | removeFromQueue(actor: User, repo: RepoPath, number: number): Promise<Result<Pull>>; | |
| 784 | ||
| 785 | getSettings(repo: RepoPath, viewer: Viewer): Promise<Result<RepoSettings>>; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 786 | /** The check names reported on the repository's commits in the last 30 days, most recent first. */ |
| 787 | seenChecks(repo: RepoPath, viewer: Viewer): Promise<Result<SeenCheck[]>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 788 | /** Members of the repository's workspace only. */ |
| 789 | updateSettings(actor: User, repo: RepoPath, settings: RepoSettingsInput): Promise<Result<RepoSettings>>; | |
| 790 | /** | |
| 791 | * What the runner needs to bring a pull request up to date because a | |
| 792 | * merge of it was asked for. Null if none was. | |
| 793 | */ | |
| 794 | catchUpJob(pullId: string): Promise<LifecycleJob | null>; | |
| Agents asked while not at work are woken to answer | 795 | /** |
| 796 | * Claims a short step for the agent on a pull request to answer the | |
| 797 | * questions and handoffs it was sent while not at work, and hands them | |
| 798 | * over, marked read. Null when there is nothing waiting or it cannot | |
| 799 | * take a step now. | |
| 800 | */ | |
| 801 | wakeForMessages(pullId: string): Promise<Wake | null>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 802 | |
| 803 | /** | |
| Pull requests from branches | 804 | * Opens a pull request: a draft with a fork to push to, or, given a |
| 805 | * branch, one ready for review. | |
| 806 | */ | |
| Issues and pull requests replace intents and attempts | 807 | openPull(actor: User, repo: RepoPath, input: OpenPullInput): Promise<Result<Pull>>; |
| 808 | /** Newest first. */ | |
| 809 | listPulls(repo: RepoPath, viewer: Viewer, state?: State): Promise<Result<Pull[]>>; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 810 | /** |
| 811 | * The newest `limit` open and closed pull requests of each repository, | |
| 812 | * in one call. Repositories the viewer cannot read, and forks, are left | |
| 813 | * out: ask those with `listPulls`. | |
| 814 | */ | |
| 815 | pullsForRepos(repoIds: string[], viewer: Viewer, limit: number): Promise<RepoPulls[]>; | |
| Issues and pull requests replace intents and attempts | 816 | getPull(repo: RepoPath, number: number, viewer: Viewer): Promise<Result<PullDetail>>; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 817 | /** |
| 818 | * Changes who a pull request is assigned to and whose review is asked | |
| 819 | * for; each list given replaces the whole set. Asking for `g1t-agent`'s | |
| 820 | * review does not by itself start one: the runner's `review` does. | |
| 821 | */ | |
| 822 | updatePull( | |
| 823 | actor: User, | |
| 824 | repo: RepoPath, | |
| 825 | number: number, | |
| 826 | changes: { assignees?: string[]; reviewers?: string[] }, | |
| 827 | ): Promise<Result<Pull>>; | |
| Catching up with main takes seconds when the two sides touched different files | 828 | /** |
| 829 | * Brings a pull request up to date with the default branch in seconds, | |
| 830 | * without a sandbox, when the two changed different files: the merge | |
| 831 | * commit is pushed to its branch as `actor`, who must be whoever opened | |
| 832 | * it (for a fork) or a member (for a branch). Otherwise `needs_agent`, and | |
| 833 | * nothing is pushed: the runner's `update` is the way on. | |
| 834 | */ | |
| 835 | catchUpPull(actor: User, repo: RepoPath, number: number): Promise<Result<PullBranchUpdate>>; | |
| Issues and pull requests replace intents and attempts | 836 | /** Marks a draft ready for review and sets its description. */ |
| 837 | readyPull(actor: User, repo: RepoPath, number: number, summary: string): Promise<Result<Pull>>; | |
| 838 | closePull(actor: User, repo: RepoPath, number: number): Promise<Result<Pull>>; | |
| Rust repos service with shipping; pull requests kept in the model | 839 | /** |
| Issues and pull requests replace intents and attempts | 840 | * Lands the pull request on the repository's default branch. Unless |
| 841 | * `keepIssueOpen`, that resolves the issue it was for: the issue closes | |
| 842 | * naming this pull request, and the others still in progress for it close | |
| 843 | * as superseded. Only members of the repository's workspace may merge. | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 844 | * |
| 845 | * If the default branch has moved, the pull request is brought up to date | |
| 846 | * first and lands when that is done; it comes back still open, and | |
| 847 | * `PullDetail.landing` is true meanwhile. A repository that requires pull | |
| 848 | * requests to be up to date refuses instead. | |
| Rust repos service with shipping; pull requests kept in the model | 849 | */ |
| Acceptance checks in sandboxes, line comments and review verdicts | 850 | mergePull( |
| 851 | actor: User, | |
| 852 | repo: RepoPath, | |
| 853 | number: number, | |
| 854 | options?: { | |
| 855 | keepIssueOpen?: boolean; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 856 | /** Merge although required checks have not passed, where the repository allows bypassing them. */ |
| Acceptance checks in sandboxes, line comments and review verdicts | 857 | ignoreChecks?: boolean; |
| 858 | }, | |
| 859 | ): Promise<Result<Pull>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 860 | /** |
| 861 | * Drafts and open pull requests the viewer started, most recently active | |
| 862 | * first, each with where it stands if g1t is seeing it through. | |
| 863 | */ | |
| 864 | listActivePulls( | |
| 865 | viewer: Viewer, | |
| 866 | ): Promise<{ pull: Pull; issue: Issue | null; lifecycle: Lifecycle | null }[]>; | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 867 | /** |
| 868 | * The issues and pull requests a person opened, a page at a time, only | |
| 869 | * on repositories the viewer may read. Not found for no such account. | |
| 870 | */ | |
| 871 | byAuthor(username: string, viewer: Viewer, filter?: AuthoredFilter): Promise<Result<Authored>>; | |
| Initial g1t: services, event bus, intents and attempts | 872 | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 873 | /** |
| 874 | * Records an outcome to plan for. Members only. For the runner service, | |
| 875 | * which starts the sandbox in which an agent writes the plan. | |
| 876 | */ | |
| 877 | startPlan(actor: User, repo: RepoPath, brief: string): Promise<Result<PlanJob>>; | |
| 878 | /** Records that a plan could not be written. For the runner service. */ | |
| 879 | failPlan(planId: string, token: string, error: string): Promise<Result<boolean>>; | |
| 880 | /** Members only. */ | |
| 881 | getPlan(repo: RepoPath, viewer: Viewer, id: string): Promise<Result<Plan>>; | |
| 882 | /** Newest first. Members only. */ | |
| 883 | listPlans(repo: RepoPath, viewer: Viewer): Promise<Result<Plan[]>>; | |
| 884 | /** | |
| 885 | * Opens a plan's issues, each blocked by the ones it depends on. With | |
| 886 | * `assign`, each is queued for a g1t agent. `keep` holds the positions, | |
| 887 | * from 1, of the issues to open; all of them when absent. Once. | |
| 888 | */ | |
| 889 | applyPlan( | |
| 890 | actor: User, | |
| 891 | repo: RepoPath, | |
| 892 | id: string, | |
| 893 | options?: { assign?: boolean; keep?: number[] }, | |
| 894 | ): Promise<Result<Plan>>; | |
| 895 | /** Asks for a g1t agent to take an issue as soon as it can, or withdraws that. */ | |
| 896 | queueIssue(actor: User, repo: RepoPath, number: number, queued: boolean): Promise<Result<boolean>>; | |
| 897 | /** Issues waiting for a g1t agent that can be given one now. For the runner. */ | |
| 898 | readyIssues(repoId?: string): Promise<ReadyIssue[]>; | |
| 899 | ||
| 900 | /** Open issues assigned to the viewer, most recently changed first. */ | |
| 901 | listAssignedIssues(viewer: Viewer): Promise<Issue[]>; | |
| 902 | ||
| Issues and pull requests replace intents and attempts | 903 | appendSession(actor: User, repo: RepoPath, number: number, entries: NewSessionEntry[]): Promise<Result<{ count: number }>>; |
| 904 | readSession(repo: RepoPath, number: number, viewer: Viewer, afterSeq?: number): Promise<Result<SessionEntry[]>>; | |
| Initial g1t: services, event bus, intents and attempts | 905 | } |
| Pull requests from branches | 906 | |
| 907 | /** | |
| 908 | * What to pass `ReposApi.compare` to see what a pull request changes. | |
| 909 | * | |
| 910 | * A fork is compared as a whole. A branch is compared by name while the | |
| 911 | * pull request is open, and by the commit it was merged or closed at | |
| 912 | * afterwards, so later pushes to the branch do not change the record. | |
| 913 | */ | |
| 914 | export function pullComparison(pull: Pull): { | |
| 915 | repoId: string; | |
| 916 | base: string | null; | |
| 917 | head: string | null; | |
| 918 | } { | |
| 919 | if (pull.forkRepoId) return { repoId: pull.forkRepoId, base: pull.mergeBase, head: null }; | |
| 920 | const settled = pull.status === "merged" || pull.status === "closed"; | |
| 921 | return { | |
| 922 | repoId: pull.repoId, | |
| 923 | base: pull.mergeBase, | |
| 924 | head: (settled && pull.headCommit) || pull.branch, | |
| 925 | }; | |
| 926 | } | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 927 | |
| 928 | ||
| 929 | /** Where a pull request in a merge queue stands. */ | |
| Dark gray base with lavender as an accent, and a live outcome view for plans | 930 | /** Where one issue of an applied plan stands. */ |
| 931 | export type IssueProgress = { | |
| 932 | number: number; | |
| 933 | title: string; | |
| 934 | /** | |
| 935 | * `blocked`, `waiting` (for an agent), `open`, a lifecycle stage, | |
| 936 | * `landed` or `closed`. | |
| 937 | */ | |
| 938 | state: string; | |
| 939 | detail: string; | |
| 940 | /** The issues it is waiting on that are still open. */ | |
| 941 | blockedBy: number[]; | |
| 942 | pull: number | null; | |
| 943 | agent: string | null; | |
| 944 | }; | |
| 945 | ||
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 946 | /** A message a person sent an agent at work on a pull request. */ |
| 947 | export type AgentMessage = { | |
| 948 | id: string; | |
| 949 | author: string; | |
| 950 | body: string; | |
| 951 | createdAt: string; | |
| 952 | /** When the agent received it; null until then. */ | |
| 953 | deliveredAt: string | null; | |
| Agents ask each other, hand each other work, and answer | 954 | /** `message` from a person; from an agent a `question`, `handoff` or `answer`. */ |
| 955 | kind: "message" | "question" | "handoff" | "answer"; | |
| 956 | /** The pull request whose agent sent it, when an agent did. */ | |
| 957 | fromNumber: number | null; | |
| 958 | /** The pull request it was sent to. */ | |
| 959 | toNumber: number; | |
| 960 | /** The reply to a question or handoff, once there is one. */ | |
| 961 | answer: string | null; | |
| 962 | declined: boolean; | |
| 963 | /** For the sending agent: what to expect when the one it asked is not at work. */ | |
| 964 | hint?: string; | |
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 965 | }; |
| 966 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 967 | export type QueueState = "waiting" | "testing" | "passed" | "failed" | "landed" | "removed"; |
| 968 | ||
| 969 | /** One pull request's place in a merge queue. */ | |
| 970 | export type QueueEntry = { | |
| 971 | id: string; | |
| 972 | number: number; | |
| 973 | title: string; | |
| 974 | agent: string; | |
| 975 | state: QueueState; | |
| 976 | /** The pull requests merged ahead of it in the state being tested, in order. */ | |
| 977 | ahead: number[]; | |
| 978 | baseCommit: string | null; | |
| 979 | combinedCommit: string | null; | |
| 980 | error: string | null; | |
| 981 | results: CheckResult[]; | |
| 982 | /** Username of whoever merged it into the queue: a person, or `g1t`. */ | |
| 983 | enqueuedBy: string; | |
| 984 | /** RFC 3339. */ | |
| 985 | createdAt: string; | |
| 986 | /** RFC 3339. */ | |
| 987 | finishedAt: string | null; | |
| 988 | }; | |
| 989 | ||
| 990 | /** A repository's merge queue: what is in it, in order, and what recently left. */ | |
| 991 | export type QueueView = { | |
| 992 | enabled: boolean; | |
| 993 | active: QueueEntry[]; | |
| 994 | /** Newest first. */ | |
| 995 | recent: QueueEntry[]; | |
| 996 | }; | |
| 997 | ||
| 998 | export type QueueStackItem = { | |
| 999 | number: number; | |
| 1000 | title: string; | |
| 1001 | /** The repository holding the change, and its branch. */ | |
| 1002 | source: RepoPath; | |
| 1003 | branch: string; | |
| 1004 | commit: string; | |
| 1005 | }; | |
| 1006 | ||
| 1007 | /** What a sandbox needs to build and check one combined state. */ | |
| 1008 | export type QueueJob = { | |
| 1009 | entryId: string; | |
| 1010 | token: string; | |
| 1011 | repo: RepoPath; | |
| 1012 | defaultBranch: string; | |
| 1013 | baseCommit: string; | |
| 1014 | branch: string; | |
| 1015 | stack: QueueStackItem[]; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 1016 | /** Always empty: the state is checked by the merge_group workflows run on it. */ |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 1017 | checks: string[]; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 1018 | /** Always empty, as `checks`. */ |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 1019 | contractChecks: string[]; |
| 1020 | actor: User; | |
| 1021 | }; | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 1022 | |
| 1023 | // --- A person's work --------------------------------------------------------- | |
| 1024 | // Mirrors the `Authored*` types in `crates/contracts/src/work.rs`. | |
| 1025 | ||
| 1026 | export type AuthoredKind = "issue" | "pull"; | |
| 1027 | /** `closed` takes in merged pull requests too; `merged` is only those. */ | |
| 1028 | export type AuthoredState = "open" | "closed" | "merged"; | |
| 1029 | /** `created` is newest first, `updated` most recently changed, `oldest` oldest first. */ | |
| 1030 | export type AuthoredSort = "created" | "updated" | "oldest"; | |
| 1031 | ||
| 1032 | /** The most items one `byAuthor` page holds. */ | |
| 1033 | export const AUTHORED_PAGE = 25; | |
| 1034 | ||
| 1035 | export type AuthoredFilter = { | |
| 1036 | kind?: AuthoredKind; | |
| 1037 | state?: AuthoredState; | |
| 1038 | /** `namespace/name`. */ | |
| 1039 | repo?: string; | |
| 1040 | sort?: AuthoredSort; | |
| 1041 | /** The `next` of the page before. */ | |
| 1042 | before?: string; | |
| 1043 | limit?: number; | |
| 1044 | }; | |
| 1045 | ||
| 1046 | export type AuthoredItem = { | |
| 1047 | kind: AuthoredKind; | |
| 1048 | repo: RepoPath; | |
| 1049 | number: number; | |
| 1050 | title: string; | |
| 1051 | /** A merged pull request is closed. */ | |
| 1052 | state: State; | |
| 1053 | /** A pull request's own status; null on an issue. */ | |
| 1054 | status: PullStatus | null; | |
| 1055 | /** Why an issue was closed. */ | |
| 1056 | reason: IssueReason | null; | |
| 1057 | draft: boolean; | |
| 1058 | merged: boolean; | |
| 1059 | /** RFC 3339. */ | |
| 1060 | createdAt: string; | |
| 1061 | /** RFC 3339. */ | |
| 1062 | updatedAt: string; | |
| 1063 | /** RFC 3339. */ | |
| 1064 | mergedAt: string | null; | |
| 1065 | }; | |
| 1066 | ||
| 1067 | /** Over every repository the viewer may read, whatever the filters. */ | |
| 1068 | export type AuthoredCounts = { | |
| 1069 | pullsMerged: number; | |
| 1070 | pullsOpen: number; | |
| 1071 | pulls: number; | |
| 1072 | issues: number; | |
| 1073 | issuesOpen: number; | |
| 1074 | }; | |
| 1075 | ||
| 1076 | export type Authored = { | |
| 1077 | items: AuthoredItem[]; | |
| 1078 | /** Pass as `before` for the next page; null on the last. */ | |
| 1079 | next: string | null; | |
| 1080 | counts: AuthoredCounts; | |
| 1081 | /** The repositories they worked in that the viewer may read, most work first. */ | |
| 1082 | repos: { repo: RepoPath; count: number }[]; | |
| 1083 | }; |