g1t/packages/contracts/src/work.ts

1,117 lines39,204 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";
Catching up with main takes seconds when the two sides touched different files2import type { PullBranchUpdate, RepoPath } from "./repos";
Initial g1t: services, event bus, intents and attempts3import 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 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;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights36 /** Who opened it: a person, an integration, or g1t (`kind` `agent`) for one its agent filed while at work. */
Initial g1t: services, event bus, intents and attempts37 author: User;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights38 /**
39 * For an issue g1t's agent filed: the person it was working for. They may
40 * manage it as its author could. See `workOwner`.
41 */
42 requestedBy: User | null;
Work service in Rust, with RFC 3339 timestamps43 /** RFC 3339. */
44 createdAt: string;
Issues and pull requests replace intents and attempts45 /** RFC 3339. */
46 updatedAt: string;
47 /** RFC 3339. */
48 closedAt: string | null;
49 /** Pull requests made against this issue, in any state. */
50 pullCount: number;
51 commentCount: number;
Agents as a team: lifecycle, merge queue, billing and a new shell52 /** Usernames of the people it is assigned to. */
53 assignees: string[];
54 /** The numbers of the issues that have to be merged before this one is worked on. */
55 blockedBy: number[];
56 /**
57 * Whether a g1t agent takes it as soon as it can: at once, or when what it
58 * is blocked by has merged.
59 */
60 queued: boolean;
61 /**
62 * The agent working on it now: the one behind its newest pull request
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent63 * that is still in progress in a fork, such as `g1t`.
Agents as a team: lifecycle, merge queue, billing and a new shell64 */
65 agent: string | null;
Initial g1t: services, event bus, intents and attempts66};
67
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights68/**
69 * Whose an issue or a pull request is to answer for: whoever asked g1t for
70 * it, or its author. They may change, close and steer it, are never asked to
71 * review it and cannot approve it, and see it as theirs. Mirrors
72 * `Pull::owner` in the Rust contracts.
73 */
74export function workOwner(item: Pick<Pull, "author" | "requestedBy">): User {
75 return item.requestedBy ?? item.author;
76}
77
Issues and pull requests replace intents and attempts78/** `draft` is still being worked on; `open` is ready for review. */
79export type PullStatus = "draft" | "open" | "merged" | "closed";
Initial g1t: services, event bus, intents and attempts80
81/** Where the agent runs: on g1t's sandboxes, or in someone's own session. */
Issues and pull requests replace intents and attempts82export type Runtime = "hosted" | "external";
Initial g1t: services, event bus, intents and attempts83
Pull requests from branches84/**
85 * A proposed change. It is made either in a fork created for it, which is
86 * how agents work, or on a branch pushed to the repository itself.
87 */
Issues and pull requests replace intents and attempts88export type Pull = {
Initial g1t: services, event bus, intents and attempts89 id: string;
90 repoId: string;
Issues and pull requests replace intents and attempts91 /** Shown as `#12`. */
Initial g1t: services, event bus, intents and attempts92 number: number;
Issues and pull requests replace intents and attempts93 /** The number of the issue this is for, if any. */
94 issue: number | null;
95 title: string;
96 /** Markdown: what changed and why. Set when marked ready. */
97 body: string | null;
Initial g1t: services, event bus, intents and attempts98 /** A label for the agent doing the work, e.g. `claude-code`. */
99 agent: string;
Issues and pull requests replace intents and attempts100 runtime: Runtime;
101 status: PullStatus;
Pull requests from branches102 /** The fork holding the change, unless it is on a branch. */
103 fork: RepoPath | null;
Diffs on attempts; hosted agent presented as the g1t agent104 /** The fork's repository id. */
Pull requests from branches105 forkRepoId: string | null;
106 /** The branch of the repository holding the change, unless it is in a fork. */
107 branch: string | null;
Initial g1t: services, event bus, intents and attempts108 headCommit: string | null;
Diffs on attempts; hosted agent presented as the g1t agent109 /**
Issues and pull requests replace intents and attempts110 * For a merged pull request, what the branch pointed to before the merge.
111 * Comparing against it shows what the pull request changed.
112 */
113 mergeBase: string | null;
114 /** Username of whoever merged it. */
115 mergedBy: string | null;
116 /** RFC 3339. */
117 mergedAt: string | null;
118 /**
119 * Set on a pull request closed because another one for the same issue was
120 * merged: that one's number.
Diffs on attempts; hosted agent presented as the g1t agent121 */
Issues and pull requests replace intents and attempts122 supersededBy: number | null;
Acceptance checks in sandboxes, line comments and review verdicts123 /**
124 * Where the latest run of the issue's acceptance checks stands, if there
125 * has been one against the current head.
126 */
127 checkStatus: CheckStatus | null;
Agents as a team: lifecycle, merge queue, billing and a new shell128 /** The files it changes, as of its latest push. */
129 files: ChangedFile[];
130 /** Usernames of the people it is assigned to. */
131 assignees: string[];
132 /**
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent133 * Those whose review was asked for: usernames, and `g1t` when a g1t
Agents as a team: lifecycle, merge queue, billing and a new shell134 * agent was asked.
135 */
136 reviewers: string[];
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights137 /** Who opened it: a person, or g1t (`kind` `agent`, username `g1t`) for a change g1t made. */
Issues and pull requests replace intents and attempts138 author: User;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights139 /**
140 * For a change g1t made: the person who asked for it, by assigning an issue
141 * or handing g1t the work. They answer for it as its author would. See
142 * `workOwner`.
143 */
144 requestedBy: User | null;
Work service in Rust, with RFC 3339 timestamps145 /** RFC 3339. */
146 createdAt: string;
147 /** RFC 3339. */
148 updatedAt: string;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step149 /**
150 * How sure g1t is of a g1t agent's change, from what it can observe, once
151 * the agent has finished it. Absent before then, and on changes g1t is
152 * not seeing through.
153 */
154 confidence?: Confidence | null;
155};
156
157/** How sure g1t is that an agent's change is right. */
158export type ConfidenceLevel = "low" | "medium" | "high";
159
160/**
161 * How sure g1t is of a change an agent made, worked out from what can be
162 * observed: its checks, how often it was sent back, the reviewer agent's
163 * verdict, whether it touched tests, its size, where it reached, how close
164 * it came to its guardrails, and what it asked without an answer. The
165 * agent's own word can only lower it.
166 */
167export type Confidence = {
168 level: ConfidenceLevel;
169 /** A few words each, most telling first: what lowered it, or for `high`, what it rests on. */
170 reasons: string[];
171 /** What the agent said of its own change, if it said. */
172 selfReported: ConfidenceLevel | null;
173 /** What the agent said it was unsure about. */
174 uncertainAbout: string[];
175 /** The agent run it was worked out after. */
176 runId: string | null;
177 /** RFC 3339. */
178 assessedAt: string;
179};
180
181/** What became of the agent when an issue was opened and handed to it in one step. */
182export type AgentStartStatus = "started" | "queued" | "not_started";
183
184/** Whether the agent started, and if not, why and what fixes it. */
185export type AgentStart = {
186 status: AgentStartStatus;
187 /**
188 * Why it did not start: `not_paid`, `trial_used`, `limit`, `paused`,
189 * `issue_cap`, `billing_unavailable` or `no_model`; `waiting` when queued.
190 */
191 code: string | null;
192 /** What happened, in a sentence or two, with what to do. */
193 message: string | null;
194 /** Where the fix is: the workspace's billing or model settings. */
195 fixUrl: string | null;
Initial g1t: services, event bus, intents and attempts196};
197
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent198/** An issue opened and handed to g1t in one step. The issue exists whatever became of the agent. */
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step199export type Delegated = {
200 issue: Issue;
201 /** The pull request the agent opened, when it started. */
202 pull: Pull | null;
203 agent: AgentStart;
204};
205
Fast pages, required checks on the branch, self-hosted runners, honest incidents206/**
207 * What to put an agent on: an issue's title, and what to do in plain words,
208 * with what done means if you like (a "Definition of done" section). What
209 * has to pass before it merges is the branch's required checks.
210 */
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step211export type DelegateInput = {
212 title: string;
213 body: string;
214 labels?: string[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents215 /** 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 step216 checks?: string[];
217};
218
Agents as a team: lifecycle, merge queue, billing and a new shell219/** One file a pull request changes, and by how much. */
220export type ChangedFile = { path: string; additions: number; deletions: number };
221
222/**
223 * Another pull request in progress that changes some of the same files. Two
224 * for the same issue are alternatives; two for different issues are heading
225 * for a conflict.
226 */
227export type Overlap = {
228 number: number;
229 title: string;
230 /** The number of the issue the other pull request is for. */
231 issue: number | null;
232 /** The files both change. */
233 paths: string[];
234};
235
Fast pages, required checks on the branch, self-hosted runners, honest incidents236/**
237 * On a pull request, `failed` means the merge queue took it out, until its
238 * head moves. The other states are from runs of commands written on issues,
239 * which g1t no longer runs.
240 */
Acceptance checks in sandboxes, line comments and review verdicts241export type CheckStatus = "queued" | "running" | "passed" | "failed" | "errored";
242
Fast pages, required checks on the branch, self-hosted runners, honest incidents243/** How one command went, in a run recorded before checks were workflows. */
Acceptance checks in sandboxes, line comments and review verdicts244export type CheckResult = {
245 command: string;
246 passed: boolean;
247 /** Null when the command was stopped for taking too long. */
248 exitCode: number | null;
249 /** What the command printed; the end of it, when there was a lot. */
250 output: string;
251 durationMs: number;
252};
253
254/**
Fast pages, required checks on the branch, self-hosted runners, honest incidents255 * A record against a pull request's head: the merge queue taking it out,
256 * with why, or an earlier run of commands written on its issue.
Acceptance checks in sandboxes, line comments and review verdicts257 */
258export type CheckRun = {
259 id: string;
260 /** The commit that was checked. */
261 headCommit: string;
262 status: CheckStatus;
263 results: CheckResult[];
264 /** Why the checks could not be run, when `status` is `errored`. */
265 error: string | null;
266 /** RFC 3339. */
267 createdAt: string;
268 /** RFC 3339. */
269 finishedAt: string | null;
270};
271
272/** A reviewer's decision on a pull request. */
273export type Verdict = "approve" | "request_changes";
274
275/**
276 * A comment on an issue or a pull request. On a pull request it can sit on
277 * one line of the change, and it can carry a reviewer's verdict.
278 */
Issues and pull requests replace intents and attempts279export type Comment = {
280 id: string;
Agents as a team: lifecycle, merge queue, billing and a new shell281 /**
282 * Something a person or an agent wrote, or something that happened: an
283 * assignment, a review asked for, a close.
284 */
285 kind: "comment" | "event";
Issues and pull requests replace intents and attempts286 author: User;
Agents as a team: lifecycle, merge queue, billing and a new shell287 /**
288 * Markdown. For an event, what its author did, as the rest of a sentence
289 * that starts with their name: "assigned ana".
290 */
Issues and pull requests replace intents and attempts291 body: string;
Acceptance checks in sandboxes, line comments and review verdicts292 /** The file commented on, for a comment on a line. */
293 path: string | null;
294 /** The line of that file, as numbered after the change. */
295 line: number | null;
296 verdict: Verdict | null;
Issues and pull requests replace intents and attempts297 /** RFC 3339. */
298 createdAt: string;
299};
300
Acceptance checks in sandboxes, line comments and review verdicts301export type NewComment = {
302 /** May be empty when approving. */
303 body: string;
304 path?: string;
305 line?: number;
306 verdict?: Verdict;
307};
308
309/** What a sandbox needs to carry out a check run. */
310export type CheckJob = {
311 runId: string;
312 /** Lets the sandbox, and nothing else, report this run's results. */
313 token: string;
314 commands: string[];
315 /** The repository holding the commit: the fork, or the repository itself. */
316 source: RepoPath;
317 commit: string;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights318 /** Who the pull request is for (`workOwner`: whoever asked g1t for it, or its author), and so can read its source. */
Acceptance checks in sandboxes, line comments and review verdicts319 author: User;
320 /** Username of whoever wrote the checks: the issue's author. */
321 requestedBy: string;
322 repo: RepoPath;
323 number: number;
324};
325
326export type CheckReport = { results?: CheckResult[]; error?: string; skip?: boolean };
327
Initial g1t: services, event bus, intents and attempts328export type SessionEntryKind = "prompt" | "message" | "tool_call" | "tool_result" | "note";
329
Issues and pull requests replace intents and attempts330/** One step of an agent's session: the "why" behind a pull request's commits. */
Initial g1t: services, event bus, intents and attempts331export type SessionEntry = {
332 seq: number;
333 kind: SessionEntryKind;
334 text: string;
335 /** For tool calls and results. */
336 tool: string | null;
337 /** The fork's head commit when this entry was recorded, if known. */
338 commit: string | null;
Work service in Rust, with RFC 3339 timestamps339 /** RFC 3339. */
340 at: string;
Initial g1t: services, event bus, intents and attempts341};
342
343export type NewSessionEntry = Pick<SessionEntry, "kind" | "text"> &
Work service in Rust, with RFC 3339 timestamps344 Partial<Pick<SessionEntry, "tool" | "commit">>;
Initial g1t: services, event bus, intents and attempts345
Issues and pull requests replace intents and attempts346export type IssueDetail = {
347 issue: Issue;
348 /** Every pull request made against it, oldest first. */
349 pulls: Pull[];
350 comments: Comment[];
351};
Initial g1t: services, event bus, intents and attempts352
Issues and pull requests replace intents and attempts353export type PullDetail = {
354 pull: Pull;
355 /** The issue it is for, if any. */
356 issue: Issue | null;
357 comments: Comment[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents358 /** The latest record against its head: the merge queue taking it out. */
Acceptance checks in sandboxes, line comments and review verdicts359 checks: CheckRun | null;
Agents as a team: lifecycle, merge queue, billing and a new shell360 /** Other pull requests in progress that change the same files. */
361 overlaps: Overlap[];
362 /**
363 * Whether the branch it would merge into has moved on without it, so that
364 * it has to catch up before it can merge.
365 */
366 behind: boolean;
367 /** Whether a g1t agent is reviewing it right now. */
368 reviewPending: boolean;
369 /**
370 * Where it stands on its way to being merged, for a pull request g1t is
371 * seeing through. Null on anyone else's.
372 */
373 lifecycle: Lifecycle | null;
374 /**
375 * A merge was asked for while it was behind: g1t is bringing it up to
376 * date and will then land it.
377 */
378 landing: boolean;
379 /** Why g1t stopped working on it, if it did. */
380 stalled: string | null;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request381 /** Messages people sent the agent while it worked, oldest first. */
382 messages: AgentMessage[];
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs383 /** What workflow runs said about its head commit, one per workflow. */
384 statuses?: CommitStatus[];
Agents and memory, checks and conflicts, profiles, slug renames, custom domains385 /**
386 * Whether it merges cleanly into the branch it targets, worked out ahead
387 * of time whenever either side moves.
388 */
389 mergeable?: Mergeable;
390 /** When `mergeable` is `conflicting`: the files that conflict. */
391 conflicts?: string[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents392 /** Earlier records like `checks`, newest first, without their output. */
Agents and memory, checks and conflicts, profiles, slug renames, custom domains393 earlierChecks?: CheckRun[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents394 /**
395 * The checks the default branch's protection requires, each as it stands
396 * on the head commit. Empty when none are required.
397 */
398 requiredChecks?: RequiredCheck[];
399};
400
401/** Where a required check stands on a commit; `expected` when nothing has reported it yet. */
402export type RequiredState = "success" | "failure" | "pending" | "expected";
403
404/** One check a branch's protection requires, as it stands on a commit. */
405export type RequiredCheck = {
406 /** A workflow's name, such as `CI`, or another status's context. */
407 name: string;
408 state: RequiredState;
409 description: string | null;
410 /** Where to see more: the workflow run, for one a workflow reported. */
411 targetUrl: string | null;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains412};
413
Fast pages, required checks on the branch, self-hosted runners, honest incidents414/** A check name reported on a repository's commits lately, for choosing required checks. */
415export type SeenCheck = {
416 name: string;
417 /** The events it was reported for, such as `pull_request`; empty for a status that names none. */
418 events: string[];
419 /** RFC 3339. */
420 lastSeen: string;
421};
422
Agents and memory, checks and conflicts, profiles, slug renames, custom domains423/**
Fast pages, required checks on the branch, self-hosted runners, honest incidents424 * A status context's check name: `CI / pull_request` is the `CI` check,
425 * reported for a `pull_request` event. A context that does not end in an
426 * event, such as `g1t / deploy`, is its own name. As the work service reads it.
427 */
428export function checkName(context: string): string {
429 const at = context.lastIndexOf(" / ");
430 if (at <= 0) return context;
431 return STATUS_EVENTS.has(context.slice(at + 3)) ? context.slice(0, at) : context;
432}
433
434const STATUS_EVENTS = new Set([
435 "push",
436 "pull_request",
437 "pull_request_target",
438 "pull_request_review",
439 "merge_group",
440 "workflow_dispatch",
441 "workflow_run",
442 "workflow_call",
443 "schedule",
444 "release",
445 "issues",
446 "issue_comment",
447 "repository_dispatch",
448]);
449
450/**
Agents and memory, checks and conflicts, profiles, slug renames, custom domains451 * Whether a pull request merges cleanly into the branch it targets:
452 * `unknown` when it was never worked out or could not be, `checking` while
453 * a probe merges the two.
454 */
455export type Mergeable = "clean" | "conflicting" | "unknown" | "checking";
456
457/** What a sandbox needs to find out whether a pull request merges cleanly. */
458export type MergecheckJob = {
459 pullId: string;
460 /** Lets the sandbox, and nothing else, report this probe. */
461 token: string;
462 repo: RepoPath;
463 number: number;
464 defaultBranch: string;
465 /** The default branch's commit to merge into. */
466 base: string;
467 /** The repository holding the change: its fork, or the repository. */
468 source: RepoPath;
469 /** The branch of `source` holding it. */
470 branch: string;
471 /** The change's commit. */
472 head: string;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights473 /** Who the pull request is for (`workOwner`: whoever asked g1t for it, or its author), and so can read its source. */
Agents and memory, checks and conflicts, profiles, slug renames, custom domains474 author: User;
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs475};
476
477/** What a workflow run (or another tool) says about a commit. */
478export type CommitStatus = {
479 /** What reported it, such as `CI / push`. */
480 context: string;
481 state: "pending" | "success" | "failure" | "error";
482 description: string | null;
483 targetUrl: string | null;
484 updatedAt: string;
Agents as a team: lifecycle, merge queue, billing and a new shell485};
486
487/**
488 * A step on the way from an assigned issue to a pull request that is ready
489 * to merge. g1t takes each one without being asked: `working` (the agent is
490 * making the change), `checking`, `reviewing`, `revising` (the agent is
491 * addressing failed checks or a review), `catching_up` (merging in the
Agents asked while not at work are woken to answer492 * branch it would land on), `answering` (woken to answer another agent),
493 * then `ready` for a person to merge. `needs_you`
Agents as a team: lifecycle, merge queue, billing and a new shell494 * means g1t has stopped and a person decides what happens next.
495 */
496export type Stage =
497 | "working"
498 | "checking"
499 | "reviewing"
500 | "revising"
501 | "catching_up"
Agents asked while not at work are woken to answer502 | "answering"
Agents as a team: lifecycle, merge queue, billing and a new shell503 | "queued"
504 | "ready"
505 | "needs_you";
506
507export type Lifecycle = {
508 stage: Stage;
509 /** One sentence saying what is happening, or why it stopped. */
510 detail: string;
511 /** How many times the agent has been sent back to revise it. */
512 revisions: number;
513};
514
515/** What the runner needs to carry out a step of a pull request's lifecycle. */
516export type LifecycleJob = {
517 pullId: string;
518 repo: RepoPath;
519 number: number;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights520 /** Who the pull request belongs to (`workOwner`: whoever asked g1t for it, or its author). Sandboxes act as them. */
Agents as a team: lifecycle, merge queue, billing and a new shell521 author: User;
522 /** The repository holding the change: its fork, or the repository itself. */
523 source: RepoPath;
524 /** The branch of the source holding the change; its default branch when null. */
525 branch: string | null;
526 defaultBranch: string;
527 title: string;
528 description: string;
529 issue: Issue | null;
530 /** For a revision: the failed checks or the review to address. */
531 feedback: string;
532 /** For a revision: which one this is, from 1. */
533 round: number;
534};
535
Agents asked while not at work are woken to answer536/** An agent woken to answer what other agents sent it while it was not at work. */
537export type Wake = { job: LifecycleJob; messages: AgentMessage[] };
538
Agents as a team: lifecycle, merge queue, billing and a new shell539/**
540 * `planning` while an agent reads the repository and writes it; `ready` for
541 * a person to read and apply; `failed` if it could not be written;
542 * `applied` once its issues are open.
543 */
544export type PlanStatus = "planning" | "ready" | "failed" | "applied";
545
546/** One issue a plan proposes. */
547export type PlannedIssue = {
548 title: string;
549 /** Markdown: what to change, where, and why. */
550 body: string;
551 labels: string[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents552 /** What is true once it is done, in plain words; added to the issue's body under "Definition of done". */
553 done: string[];
Agents as a team: lifecycle, merge queue, billing and a new shell554 /** The files it will most likely change. */
555 files: string[];
556 /**
557 * The positions, counting from 1, of earlier issues in the plan that have
558 * to be merged first.
559 */
560 dependsOn: number[];
561 /** Its number, once the plan has been applied and it was kept. */
562 number: number | null;
563};
564
565/** An outcome someone wrote, and the issues an agent proposes to get there. */
566export type Plan = {
567 id: string;
568 repoId: string;
569 /** The outcome wanted, as written. */
570 brief: string;
571 status: PlanStatus;
572 /** The agent's account of how it split the work. */
573 summary: string;
574 issues: PlannedIssue[];
575 /** Why it could not be written, when `status` is `failed`. */
576 error: string | null;
577 author: User;
578 /** RFC 3339. */
579 createdAt: string;
580 /** RFC 3339. */
581 finishedAt: string | null;
Dark gray base with lavender as an accent, and a live outcome view for plans582 /** Once applied: where each issue it opened stands now, in plan order. */
583 progress: IssueProgress[];
Agents ask each other, hand each other work, and answer584 /** Questions and handoffs between its pull requests' agents, newest first. */
585 exchanges: AgentMessage[];
Agents as a team: lifecycle, merge queue, billing and a new shell586};
587
588/** What a sandbox needs to write a plan. */
589export type PlanJob = {
590 planId: string;
591 /** Lets the sandbox, and nothing else, report this plan. */
592 token: string;
593 brief: string;
594 repo: RepoPath;
Issues and pull requests replace intents and attempts595};
Initial g1t: services, event bus, intents and attempts596
Agents as a team: lifecycle, merge queue, billing and a new shell597/** An issue waiting for a g1t agent that can be given one now. */
598export type ReadyIssue = {
599 repo: RepoPath;
600 number: number;
601 /** Who queued it, on whose say-so the agent works. */
602 actor: User;
603};
604
605/**
606 * How a repository wants its pull requests handled. A repository that has
607 * changed nothing has the defaults.
608 */
609export type RepoSettings = {
610 /**
611 * Land a g1t agent's pull request without a person once it is ready:
612 * checks passed and approved as the settings below require.
613 */
614 autoMerge: boolean;
615 /**
Fast pages, required checks on the branch, self-hosted runners, honest incidents616 * The checks that must pass on a pull request's head before it may merge
617 * into the default branch, by name: a workflow's name (`CI`) or another
618 * status's context (`g1t / deploy`). The same for people and agents, and
619 * for the merge queue.
620 */
621 requiredChecks: string[];
622 /**
Agents as a team: lifecycle, merge queue, billing and a new shell623 * Refuse to merge a pull request that does not contain the default
624 * branch's latest commits, so that what merges is what was checked. When
625 * off, merging one that is behind brings it up to date first.
626 */
627 requireUpToDate: boolean;
628 /**
629 * How many approving reviews a pull request needs before it may merge. A
630 * reviewer who has since asked for changes blocks it.
631 */
632 requiredApprovals: number;
633 /** Whether a g1t agent's approval counts towards `requiredApprovals`. */
634 countAgentApprovals: boolean;
Fast pages, required checks on the branch, self-hosted runners, honest incidents635 /** Whether someone who may merge can bypass required checks that have not passed. */
Agents as a team: lifecycle, merge queue, billing and a new shell636 allowIgnoringChecks: boolean;
637 /** Whether a g1t agent's pull request is reviewed by a second agent unasked. */
638 agentReview: boolean;
639 /**
640 * How many times a g1t agent is sent back to its pull request before a
641 * person is asked instead.
642 */
643 maxRevisions: number;
644 /**
645 * Merge through a queue: pull requests are tested together with those
646 * ahead of them, and only a combination that passed reaches the default
647 * branch.
648 */
649 mergeQueue: boolean;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step650 /**
651 * Ask a person before merging a g1t agent's change whose confidence is
652 * low: auto-merge and the merge queue leave it until a person approves it.
653 */
654 holdLowConfidence: boolean;
Agents as a team: lifecycle, merge queue, billing and a new shell655 /** Username of the member who last changed the settings, if anyone has. */
656 updatedBy: string | null;
657 /** RFC 3339. */
658 updatedAt: string | null;
659};
660
661/** The settings a member can change. */
662export type RepoSettingsInput = Omit<RepoSettings, "updatedBy" | "updatedAt">;
663
664/** The next step for a pull request g1t is seeing through, already claimed. */
665export type Advance =
666 | { action: "none" }
667 | { action: "review" | "revise" | "catch_up"; job: LifecycleJob };
668
669/** What a sandbox needs to review a pull request. */
670export type ReviewJob = {
671 runId: string;
672 /** Lets the sandbox, and nothing else, report this review. */
673 token: string;
674 /** The repository holding the commit: the fork, or the repository itself. */
675 source: RepoPath;
676 commit: string;
677 repo: RepoPath;
678 defaultBranch: string;
679 number: number;
680 title: string;
681 description: string;
682 /** The issue the pull request is for, which says what it should achieve. */
683 issue: Issue | null;
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights684 /** Who the pull request is for (`workOwner`: whoever asked g1t for it, or its author), and so can read its source. */
Agents as a team: lifecycle, merge queue, billing and a new shell685 author: User;
Auto model routing: the cheapest tier that can do each piece of work, a retry goes up a tier, and each run records its tier686 /**
687 * The files it changes, as of its latest push: how large the change is,
688 * which decides the model that reviews it.
689 */
690 files: ChangedFile[];
691 /**
692 * What among them runs, configures or guards things (CI workflows,
693 * secrets, infrastructure), once each. Any sends the review to the
694 * larger model.
695 */
696 sensitive: string[];
Agents as a team: lifecycle, merge queue, billing and a new shell697};
698
Issues and pull requests replace intents and attempts699export type OpenIssueInput = {
700 title: string;
701 body: string;
702 labels?: string[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents703 /** Deprecated: commands, added to the body under "Definition of done". */
Issues and pull requests replace intents and attempts704 checks?: string[];
705};
706
Agents as a team: lifecycle, merge queue, billing and a new shell707export type UpdateIssueInput = {
708 title?: string;
709 body?: string;
710 labels?: string[];
711 /** Usernames of the people it is assigned to; replaces the whole set. */
712 assignees?: string[];
713};
Issues and pull requests replace intents and attempts714
715export type OpenPullInput = {
716 /** The number of the issue this is for. */
717 issue?: number;
718 /** Defaults to the issue's title; required without an issue. */
719 title?: string;
Pull requests from branches720 /** What changed and why. Usually set later, when a draft is marked ready. */
721 body?: string;
722 /**
723 * A branch of the repository that already holds the change. The pull
724 * request is then ready for review at once and has no fork.
725 */
726 branch?: string;
Issues and pull requests replace intents and attempts727 agent: string;
728 runtime: Runtime;
729};
Initial g1t: services, event bus, intents and attempts730
Fast pages, required checks on the branch, self-hosted runners, honest incidents731/** One repository's pull requests from `pullsForRepos`, newest first. */
732export type RepoPulls = {
733 repoId: string;
734 /** Draft and open. */
735 open: Pull[];
736 /** Merged and closed. */
737 closed: Pull[];
738};
739
Issues and pull requests replace intents and attempts740/** Issues, pull requests, comments and sessions. */
Work service in Rust, with RFC 3339 timestamps741export interface WorkApi {
Issues and pull requests replace intents and attempts742 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 step743 /**
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent744 * Opens an issue to put g1t on at once: refused, with nothing
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step745 * opened, unless `actor` may put agents to work in `repo`. The runner's
746 * `delegate` calls it, then starts the agent.
747 */
748 delegateIssue(actor: User, repo: RepoPath, input: DelegateInput): Promise<Result<Issue>>;
Issues and pull requests replace intents and attempts749 /** Newest first. */
750 listIssues(
751 repo: RepoPath,
752 viewer: Viewer,
753 filter?: { state?: State; label?: string },
754 ): Promise<Result<Issue[]>>;
755 getIssue(repo: RepoPath, number: number, viewer: Viewer): Promise<Result<IssueDetail>>;
756 /** The author or a member of the workspace may. */
757 updateIssue(actor: User, repo: RepoPath, number: number, input: UpdateIssueInput): Promise<Result<Issue>>;
758 closeIssue(actor: User, repo: RepoPath, number: number, reason?: IssueReason): Promise<Result<Issue>>;
759 reopenIssue(actor: User, repo: RepoPath, number: number): Promise<Result<Issue>>;
760 /** The default labels, then every other label in use on the repository. */
761 listLabels(repo: RepoPath, viewer: Viewer): Promise<Result<string[]>>;
762 /** How many issues and pull requests are open. */
763 counts(repo: RepoPath, viewer: Viewer): Promise<Result<{ issues: number; pulls: number }>>;
Initial g1t: services, event bus, intents and attempts764
Acceptance checks in sandboxes, line comments and review verdicts765 /**
766 * On an issue or a pull request. On a pull request it may name a line of
767 * the change and carry a verdict; nobody can give a verdict on their own.
768 */
769 addComment(actor: User, repo: RepoPath, number: number, comment: NewComment): Promise<Result<Comment>>;
770
771 /**
Fast pages, required checks on the branch, self-hosted runners, honest incidents772 * Always refused now: a pull request's checks are the workflows run on
773 * it. Kept for a runner from before.
Acceptance checks in sandboxes, line comments and review verdicts774 */
775 startChecks(pullId: string): Promise<Result<CheckJob>>;
776 /**
Fast pages, required checks on the branch, self-hosted runners, honest incidents777 * What a sandbox says about a run from before checks were workflows: so
778 * one still finishing is recorded.
Acceptance checks in sandboxes, line comments and review verdicts779 */
780 reportChecks(runId: string, token: string, report: CheckReport): Promise<Result<CheckRun>>;
Agents as a team: lifecycle, merge queue, billing and a new shell781 /** Begins a review by a g1t agent. For the runner service. */
782 startReview(pullId: string): Promise<Result<ReviewJob>>;
783 /** Records that a review could not be written. For the runner service. */
784 failReview(runId: string, token: string, error: string): Promise<Result<boolean>>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains785 /**
786 * Claims the probe of whether a pull request merges cleanly that a
787 * `pull.mergecheck` event asked for. Refused when it is no longer wanted
788 * or the repository has as many running as it may. For the runner service.
789 */
790 startMergecheck(pullId: string): Promise<Result<MergecheckJob>>;
791 /** Records that a probe could not be carried out. For the runner service. */
792 failMergecheck(pullId: string, token: string, error: string): Promise<Result<Mergeable>>;
Agents as a team: lifecycle, merge queue, billing and a new shell793
794 /**
795 * Works out the next step for a pull request g1t is seeing through and,
796 * if there is one to take now, claims it, so that it is taken once
797 * however often this is called. For the runner service.
798 */
799 advance(pullId: string): Promise<Advance>;
800 /** Records that a step could not be carried out, so a person is asked. */
801 stall(pullId: string, reason: string): Promise<boolean>;
802 /** Ids of the open pull requests g1t is seeing through. */
803 managedPulls(repoId?: string): Promise<string[]>;
Issues and pull requests replace intents and attempts804
Agents as a team: lifecycle, merge queue, billing and a new shell805 /** A repository's merge queue: what is in it, in order, and what recently left. */
806 queue(repo: RepoPath, viewer: Viewer): Promise<Result<QueueView>>;
Pull requests from branches807 /**
Agents as a team: lifecycle, merge queue, billing and a new shell808 * The next batch of combined states to test for a repository, one per
809 * entry; empty while a batch is being tested or nothing waits.
810 */
811 queueBuild(repoId: string): Promise<QueueJob[]>;
812 /** Reports that a combined state could not be built or checked. */
813 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 request814 /** Sends the agent working on a pull request a message, for its next step. */
815 messageAgent(actor: User, repo: RepoPath, number: number, body: string): Promise<Result<AgentMessage>>;
Agents as a team: lifecycle, merge queue, billing and a new shell816 /** Takes a pull request out of the merge queue. Members only. */
817 removeFromQueue(actor: User, repo: RepoPath, number: number): Promise<Result<Pull>>;
818
819 getSettings(repo: RepoPath, viewer: Viewer): Promise<Result<RepoSettings>>;
Fast pages, required checks on the branch, self-hosted runners, honest incidents820 /** The check names reported on the repository's commits in the last 30 days, most recent first. */
821 seenChecks(repo: RepoPath, viewer: Viewer): Promise<Result<SeenCheck[]>>;
Agents as a team: lifecycle, merge queue, billing and a new shell822 /** Members of the repository's workspace only. */
823 updateSettings(actor: User, repo: RepoPath, settings: RepoSettingsInput): Promise<Result<RepoSettings>>;
824 /**
825 * What the runner needs to bring a pull request up to date because a
826 * merge of it was asked for. Null if none was.
827 */
828 catchUpJob(pullId: string): Promise<LifecycleJob | null>;
Agents asked while not at work are woken to answer829 /**
830 * Claims a short step for the agent on a pull request to answer the
831 * questions and handoffs it was sent while not at work, and hands them
832 * over, marked read. Null when there is nothing waiting or it cannot
833 * take a step now.
834 */
835 wakeForMessages(pullId: string): Promise<Wake | null>;
Agents as a team: lifecycle, merge queue, billing and a new shell836
837 /**
Pull requests from branches838 * Opens a pull request: a draft with a fork to push to, or, given a
839 * branch, one ready for review.
840 */
Issues and pull requests replace intents and attempts841 openPull(actor: User, repo: RepoPath, input: OpenPullInput): Promise<Result<Pull>>;
842 /** Newest first. */
843 listPulls(repo: RepoPath, viewer: Viewer, state?: State): Promise<Result<Pull[]>>;
Fast pages, required checks on the branch, self-hosted runners, honest incidents844 /**
845 * The newest `limit` open and closed pull requests of each repository,
846 * in one call. Repositories the viewer cannot read, and forks, are left
847 * out: ask those with `listPulls`.
848 */
849 pullsForRepos(repoIds: string[], viewer: Viewer, limit: number): Promise<RepoPulls[]>;
Issues and pull requests replace intents and attempts850 getPull(repo: RepoPath, number: number, viewer: Viewer): Promise<Result<PullDetail>>;
Agents as a team: lifecycle, merge queue, billing and a new shell851 /**
852 * Changes who a pull request is assigned to and whose review is asked
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent853 * for; each list given replaces the whole set. Asking for `g1t`'s
Agents as a team: lifecycle, merge queue, billing and a new shell854 * review does not by itself start one: the runner's `review` does.
855 */
856 updatePull(
857 actor: User,
858 repo: RepoPath,
859 number: number,
860 changes: { assignees?: string[]; reviewers?: string[] },
861 ): Promise<Result<Pull>>;
Catching up with main takes seconds when the two sides touched different files862 /**
863 * Brings a pull request up to date with the default branch in seconds,
864 * without a sandbox, when the two changed different files: the merge
865 * commit is pushed to its branch as `actor`, who must be whoever opened
866 * it (for a fork) or a member (for a branch). Otherwise `needs_agent`, and
867 * nothing is pushed: the runner's `update` is the way on.
868 */
869 catchUpPull(actor: User, repo: RepoPath, number: number): Promise<Result<PullBranchUpdate>>;
Issues and pull requests replace intents and attempts870 /** Marks a draft ready for review and sets its description. */
871 readyPull(actor: User, repo: RepoPath, number: number, summary: string): Promise<Result<Pull>>;
872 closePull(actor: User, repo: RepoPath, number: number): Promise<Result<Pull>>;
Rust repos service with shipping; pull requests kept in the model873 /**
Issues and pull requests replace intents and attempts874 * Lands the pull request on the repository's default branch. Unless
875 * `keepIssueOpen`, that resolves the issue it was for: the issue closes
876 * naming this pull request, and the others still in progress for it close
877 * as superseded. Only members of the repository's workspace may merge.
Agents as a team: lifecycle, merge queue, billing and a new shell878 *
879 * If the default branch has moved, the pull request is brought up to date
880 * first and lands when that is done; it comes back still open, and
881 * `PullDetail.landing` is true meanwhile. A repository that requires pull
882 * requests to be up to date refuses instead.
Rust repos service with shipping; pull requests kept in the model883 */
Acceptance checks in sandboxes, line comments and review verdicts884 mergePull(
885 actor: User,
886 repo: RepoPath,
887 number: number,
888 options?: {
889 keepIssueOpen?: boolean;
Fast pages, required checks on the branch, self-hosted runners, honest incidents890 /** Merge although required checks have not passed, where the repository allows bypassing them. */
Acceptance checks in sandboxes, line comments and review verdicts891 ignoreChecks?: boolean;
892 },
893 ): Promise<Result<Pull>>;
Agents as a team: lifecycle, merge queue, billing and a new shell894 /**
895 * Drafts and open pull requests the viewer started, most recently active
896 * first, each with where it stands if g1t is seeing it through.
897 */
898 listActivePulls(
899 viewer: Viewer,
900 ): Promise<{ pull: Pull; issue: Issue | null; lifecycle: Lifecycle | null }[]>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains901 /**
902 * The issues and pull requests a person opened, a page at a time, only
903 * on repositories the viewer may read. Not found for no such account.
904 */
905 byAuthor(username: string, viewer: Viewer, filter?: AuthoredFilter): Promise<Result<Authored>>;
Initial g1t: services, event bus, intents and attempts906
Agents as a team: lifecycle, merge queue, billing and a new shell907 /**
908 * Records an outcome to plan for. Members only. For the runner service,
909 * which starts the sandbox in which an agent writes the plan.
910 */
911 startPlan(actor: User, repo: RepoPath, brief: string): Promise<Result<PlanJob>>;
912 /** Records that a plan could not be written. For the runner service. */
913 failPlan(planId: string, token: string, error: string): Promise<Result<boolean>>;
914 /** Members only. */
915 getPlan(repo: RepoPath, viewer: Viewer, id: string): Promise<Result<Plan>>;
916 /** Newest first. Members only. */
917 listPlans(repo: RepoPath, viewer: Viewer): Promise<Result<Plan[]>>;
918 /**
919 * Opens a plan's issues, each blocked by the ones it depends on. With
920 * `assign`, each is queued for a g1t agent. `keep` holds the positions,
921 * from 1, of the issues to open; all of them when absent. Once.
922 */
923 applyPlan(
924 actor: User,
925 repo: RepoPath,
926 id: string,
927 options?: { assign?: boolean; keep?: number[] },
928 ): Promise<Result<Plan>>;
929 /** Asks for a g1t agent to take an issue as soon as it can, or withdraws that. */
930 queueIssue(actor: User, repo: RepoPath, number: number, queued: boolean): Promise<Result<boolean>>;
931 /** Issues waiting for a g1t agent that can be given one now. For the runner. */
932 readyIssues(repoId?: string): Promise<ReadyIssue[]>;
933
934 /** Open issues assigned to the viewer, most recently changed first. */
935 listAssignedIssues(viewer: Viewer): Promise<Issue[]>;
936
Issues and pull requests replace intents and attempts937 appendSession(actor: User, repo: RepoPath, number: number, entries: NewSessionEntry[]): Promise<Result<{ count: number }>>;
938 readSession(repo: RepoPath, number: number, viewer: Viewer, afterSeq?: number): Promise<Result<SessionEntry[]>>;
Initial g1t: services, event bus, intents and attempts939}
Pull requests from branches940
941/**
942 * What to pass `ReposApi.compare` to see what a pull request changes.
943 *
944 * A fork is compared as a whole. A branch is compared by name while the
945 * pull request is open, and by the commit it was merged or closed at
946 * afterwards, so later pushes to the branch do not change the record.
947 */
948export function pullComparison(pull: Pull): {
949 repoId: string;
950 base: string | null;
951 head: string | null;
952} {
953 if (pull.forkRepoId) return { repoId: pull.forkRepoId, base: pull.mergeBase, head: null };
954 const settled = pull.status === "merged" || pull.status === "closed";
955 return {
956 repoId: pull.repoId,
957 base: pull.mergeBase,
958 head: (settled && pull.headCommit) || pull.branch,
959 };
960}
Agents as a team: lifecycle, merge queue, billing and a new shell961
962
963/** Where a pull request in a merge queue stands. */
Dark gray base with lavender as an accent, and a live outcome view for plans964/** Where one issue of an applied plan stands. */
965export type IssueProgress = {
966 number: number;
967 title: string;
968 /**
969 * `blocked`, `waiting` (for an agent), `open`, a lifecycle stage,
970 * `landed` or `closed`.
971 */
972 state: string;
973 detail: string;
974 /** The issues it is waiting on that are still open. */
975 blockedBy: number[];
976 pull: number | null;
977 agent: string | null;
978};
979
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request980/** A message a person sent an agent at work on a pull request. */
981export type AgentMessage = {
982 id: string;
983 author: string;
984 body: string;
985 createdAt: string;
986 /** When the agent received it; null until then. */
987 deliveredAt: string | null;
Agents ask each other, hand each other work, and answer988 /** `message` from a person; from an agent a `question`, `handoff` or `answer`. */
989 kind: "message" | "question" | "handoff" | "answer";
990 /** The pull request whose agent sent it, when an agent did. */
991 fromNumber: number | null;
992 /** The pull request it was sent to. */
993 toNumber: number;
994 /** The reply to a question or handoff, once there is one. */
995 answer: string | null;
996 declined: boolean;
997 /** For the sending agent: what to expect when the one it asked is not at work. */
998 hint?: string;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request999};
1000
Agents as a team: lifecycle, merge queue, billing and a new shell1001export type QueueState = "waiting" | "testing" | "passed" | "failed" | "landed" | "removed";
1002
1003/** One pull request's place in a merge queue. */
1004export type QueueEntry = {
1005 id: string;
1006 number: number;
1007 title: string;
1008 agent: string;
1009 state: QueueState;
1010 /** The pull requests merged ahead of it in the state being tested, in order. */
1011 ahead: number[];
1012 baseCommit: string | null;
1013 combinedCommit: string | null;
1014 error: string | null;
1015 results: CheckResult[];
1016 /** Username of whoever merged it into the queue: a person, or `g1t`. */
1017 enqueuedBy: string;
1018 /** RFC 3339. */
1019 createdAt: string;
1020 /** RFC 3339. */
1021 finishedAt: string | null;
1022};
1023
1024/** A repository's merge queue: what is in it, in order, and what recently left. */
1025export type QueueView = {
1026 enabled: boolean;
1027 active: QueueEntry[];
1028 /** Newest first. */
1029 recent: QueueEntry[];
1030};
1031
1032export type QueueStackItem = {
1033 number: number;
1034 title: string;
1035 /** The repository holding the change, and its branch. */
1036 source: RepoPath;
1037 branch: string;
1038 commit: string;
1039};
1040
1041/** What a sandbox needs to build and check one combined state. */
1042export type QueueJob = {
1043 entryId: string;
1044 token: string;
1045 repo: RepoPath;
1046 defaultBranch: string;
1047 baseCommit: string;
1048 branch: string;
1049 stack: QueueStackItem[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents1050 /** 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 shell1051 checks: string[];
Fast pages, required checks on the branch, self-hosted runners, honest incidents1052 /** Always empty, as `checks`. */
Agents as a team: lifecycle, merge queue, billing and a new shell1053 contractChecks: string[];
1054 actor: User;
1055};
Agents and memory, checks and conflicts, profiles, slug renames, custom domains1056
1057// --- A person's work ---------------------------------------------------------
1058// Mirrors the `Authored*` types in `crates/contracts/src/work.rs`.
1059
1060export type AuthoredKind = "issue" | "pull";
1061/** `closed` takes in merged pull requests too; `merged` is only those. */
1062export type AuthoredState = "open" | "closed" | "merged";
1063/** `created` is newest first, `updated` most recently changed, `oldest` oldest first. */
1064export type AuthoredSort = "created" | "updated" | "oldest";
1065
1066/** The most items one `byAuthor` page holds. */
1067export const AUTHORED_PAGE = 25;
1068
1069export type AuthoredFilter = {
1070 kind?: AuthoredKind;
1071 state?: AuthoredState;
1072 /** `namespace/name`. */
1073 repo?: string;
1074 sort?: AuthoredSort;
1075 /** The `next` of the page before. */
1076 before?: string;
1077 limit?: number;
1078};
1079
1080export type AuthoredItem = {
1081 kind: AuthoredKind;
1082 repo: RepoPath;
1083 number: number;
1084 title: string;
1085 /** A merged pull request is closed. */
1086 state: State;
1087 /** A pull request's own status; null on an issue. */
1088 status: PullStatus | null;
1089 /** Why an issue was closed. */
1090 reason: IssueReason | null;
1091 draft: boolean;
1092 merged: boolean;
1093 /** RFC 3339. */
1094 createdAt: string;
1095 /** RFC 3339. */
1096 updatedAt: string;
1097 /** RFC 3339. */
1098 mergedAt: string | null;
1099};
1100
1101/** Over every repository the viewer may read, whatever the filters. */
1102export type AuthoredCounts = {
1103 pullsMerged: number;
1104 pullsOpen: number;
1105 pulls: number;
1106 issues: number;
1107 issuesOpen: number;
1108};
1109
1110export type Authored = {
1111 items: AuthoredItem[];
1112 /** Pass as `before` for the next page; null on the last. */
1113 next: string | null;
1114 counts: AuthoredCounts;
1115 /** The repositories they worked in that the viewer may read, most work first. */
1116 repos: { repo: RepoPath; count: number }[];
1117};