pr_01m47d24b0e6n91zwymwxg0vpx/packages/contracts/src/runner.ts

61 lines2,575 bytesCodeBlame
1import type { User, Viewer } from "./identity";
2import type { Result } from "./result";
3import type { RepoPath } from "./repos";
4import type { Plan, Pull } from "./work";
5
6export type RunHostedInput = {
7 /** Extra guidance given to the agent along with the issue. */
8 instructions?: string;
9};
10
11/**
12 * Sandboxes on g1t: agents that work on an issue, and acceptance checks.
13 *
14 * Nobody who assigns a g1t agent picks a model. g1t routes each kind of
15 * work itself, and says in the session which model ran.
16 */
17export interface RunnerApi {
18 /** Whether this viewer may put g1t agents to work. */
19 enabled(viewer: Viewer): Promise<boolean>;
20 /**
21 * Assigns the issue to a g1t agent: opens a draft pull request for it,
22 * made by an agent in a sandbox of its own. Returns as soon as the
23 * sandbox is starting; progress shows up in the pull request's session.
24 * Scale comes from assigning many issues, each to its own agent.
25 */
26 run(actor: User, repo: RepoPath, issue: number, input?: RunHostedInput): Promise<Result<Pull>>;
27 /**
28 * Has an agent read the repository and turn an outcome into a plan: the
29 * issues that would get there and the order they have to land in. Returns
30 * the plan's id as soon as the sandbox is starting; the plan fills in when
31 * the agent has written it. Members of the repository's workspace only.
32 */
33 plan(actor: User, repo: RepoPath, brief: string): Promise<Result<{ planId: string }>>;
34 /**
35 * Opens a plan's issues. With `assign`, a g1t agent starts on each that
36 * depends on nothing, and on the others as what they depend on merges.
37 */
38 applyPlan(
39 actor: User,
40 repo: RepoPath,
41 planId: string,
42 options?: { assign?: boolean; keep?: number[] },
43 ): Promise<Result<Plan>>;
44 /**
45 * Runs the acceptance checks of a pull request again. Whoever opened it,
46 * or a member of the repository's workspace, may ask.
47 */
48 recheck(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
49 /**
50 * Brings a pull request up to date with the branch it would merge into,
51 * in a sandbox. A clean merge is pushed as it is; a conflict is resolved
52 * by a g1t agent. Whoever can push to the pull request's source may ask:
53 * its author, or for one from a branch, a workspace member.
54 */
55 update(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
56 /**
57 * Has a g1t agent review a pull request: line comments, a summary and a
58 * verdict, posted as `g1t-agent`.
59 */
60 review(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
61}