g1t/packages/contracts/src/runner.ts

65 lines2,722 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 /**
20 * Whether `viewer` may put g1t's agents to work: in `repo`'s workspace,
21 * or with none named, in any of theirs.
22 */
23 enabled(viewer: Viewer, repo?: RepoPath): Promise<boolean>;
24 /**
25 * Assigns the issue to a g1t agent: opens a draft pull request for it,
26 * made by an agent in a sandbox of its own. Returns as soon as the
27 * sandbox is starting; progress shows up in the pull request's session.
28 * Scale comes from assigning many issues, each to its own agent.
29 */
30 run(actor: User, repo: RepoPath, issue: number, input?: RunHostedInput): Promise<Result<Pull>>;
31 /**
32 * Has an agent read the repository and turn an outcome into a plan: the
33 * issues that would get there and the order they have to land in. Returns
34 * the plan's id as soon as the sandbox is starting; the plan fills in when
35 * the agent has written it. Members of the repository's workspace only.
36 */
37 plan(actor: User, repo: RepoPath, brief: string): Promise<Result<{ planId: string }>>;
38 /**
39 * Opens a plan's issues. With `assign`, a g1t agent starts on each that
40 * depends on nothing, and on the others as what they depend on merges.
41 */
42 applyPlan(
43 actor: User,
44 repo: RepoPath,
45 planId: string,
46 options?: { assign?: boolean; keep?: number[] },
47 ): Promise<Result<Plan>>;
48 /**
49 * Runs the acceptance checks of a pull request again. Whoever opened it,
50 * or a member of the repository's workspace, may ask.
51 */
52 recheck(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
53 /**
54 * Brings a pull request up to date with the branch it would merge into,
55 * in a sandbox. A clean merge is pushed as it is; a conflict is resolved
56 * by a g1t agent. Whoever can push to the pull request's source may ask:
57 * its author, or for one from a branch, a workspace member.
58 */
59 update(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
60 /**
61 * Has a g1t agent review a pull request: line comments, a summary and a
62 * verdict, posted as `g1t-agent`.
63 */
64 review(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
65}