flagon-io/g1t

public

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

g1t/packages/contracts/src/runner.ts

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