g1t/packages/contracts/src/runner.ts

122 lines5,202 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.

Agents and memory, checks and conflicts, profiles, slug renames, custom domains1import type { AgentRun } from "./agents";
A free allowance on g1t's models, so anyone can try its agents2import type { Trial } from "./billing";
Hosted agents: sandboxes on Cloudflare Containers started from an intent3import type { User, Viewer } from "./identity";
4import type { Result } from "./result";
Issues and pull requests replace intents and attempts5import type { RepoPath } from "./repos";
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step6import type { DelegateInput, Delegated, Plan, Pull } from "./work";
g1t agents: model menu and optional AI Gateway routing7
Hosted agents: sandboxes on Cloudflare Containers started from an intent8export type RunHostedInput = {
Agents as a team: lifecycle, merge queue, billing and a new shell9 /** Extra guidance given to the agent along with the issue. */
Hosted agents: sandboxes on Cloudflare Containers started from an intent10 instructions?: string;
11};
12
Agents as a team: lifecycle, merge queue, billing and a new shell13/**
Fast pages, required checks on the branch, self-hosted runners, honest incidents14 * Sandboxes on g1t: agents that work on an issue, reviews, and the merge queue.
Agents as a team: lifecycle, merge queue, billing and a new shell15 *
16 * Nobody who assigns a g1t agent picks a model. g1t routes each kind of
17 * work itself, and says in the session which model ran.
18 */
Models per workspace: several providers, routed by kind of work19/**
20 * How a workspace's agents reach a model. The workspace decides: its own
21 * provider (`own` names it), or g1t's hosted models paid from its credit.
22 */
23export type ModelAccess = {
24 /** The workspace's own model connection, by name, if it has one. */
25 own: string | null;
A free allowance on g1t's models, so anyone can try its agents26 /** Whether g1t's hosted models are open to it, on its free allowance or otherwise. */
Models per workspace: several providers, routed by kind of work27 hosted: boolean;
A free allowance on g1t's models, so anyone can try its agents28 /** Its free allowance, when that is how it reaches g1t's hosted models; null when it needs none. */
29 trial: Trial | null;
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily30 /**
31 * True when hosted models are closed to it because billing takes no real
32 * money yet: until then they are open only to the workspaces g1t lists,
33 * and every other workspace uses its own provider.
34 */
35 preview: boolean;
Models per workspace: several providers, routed by kind of work36};
37
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API38/**
39 * The files every g1t agent run in a repository reads as the repository's
40 * instructions, as they are on its default branch.
41 */
42export type RepoInstructions = {
43 branch: string;
44 /** Null when the repository has no commits yet. */
45 commit: string | null;
46 files: {
47 path: string;
48 /** `root` is read by every run, `directory` by runs that touch files under it, `review` by reviews. */
49 role: "root" | "directory" | "review";
50 text: string;
51 /** Longer than agents are given; they get the start of it. */
52 truncated: boolean;
53 lastChanged: { commit: string; message: string; author: string; at: string } | null;
54 }[];
55 /** How much of each file, and of all of them, an agent is given. */
56 limits: { fileChars: number; totalChars: number };
57};
58
Hosted agents: sandboxes on Cloudflare Containers started from an intent59export interface RunnerApi {
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API60 /**
61 * The repository's instructions for agents (`AGENTS.md`, `CLAUDE.md`,
62 * `.g1t/review.md`), as they are on its default branch: what every g1t
63 * agent run there reads. Whoever can see the repository may ask.
64 */
65 instructions(viewer: Viewer, repo: RepoPath): Promise<Result<RepoInstructions>>;
Models per workspace: several providers, routed by kind of work66 /** How `workspace`'s agents would reach a model now. */
67 modelAccess(workspace: string): Promise<ModelAccess>;
Hosted agents: sandboxes on Cloudflare Containers started from an intent68 /**
g1t's agents only for listed workspaces, whatever the state of billing69 * Whether `viewer` may put g1t's agents to work: in `repo`'s workspace,
70 * or with none named, in any of theirs.
71 */
72 enabled(viewer: Viewer, repo?: RepoPath): Promise<boolean>;
73 /**
Agents as a team: lifecycle, merge queue, billing and a new shell74 * Assigns the issue to a g1t agent: opens a draft pull request for it,
75 * made by an agent in a sandbox of its own. Returns as soon as the
76 * sandbox is starting; progress shows up in the pull request's session.
77 * Scale comes from assigning many issues, each to its own agent.
Hosted agents: sandboxes on Cloudflare Containers started from an intent78 */
Agents as a team: lifecycle, merge queue, billing and a new shell79 run(actor: User, repo: RepoPath, issue: number, input?: RunHostedInput): Promise<Result<Pull>>;
Acceptance checks in sandboxes, line comments and review verdicts80 /**
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step81 * Puts an agent on something in one step: opens an issue and assigns it
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent82 * to g1t. Refused, with nothing opened, unless `actor` may put
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step83 * agents to work in `repo` (Write). Once opened, the issue stays whatever
84 * becomes of the agent: `agent` says whether it started, waits for a
85 * free slot, or did not start, why and where to fix it.
86 */
87 delegate(actor: User, repo: RepoPath, input: DelegateInput): Promise<Result<Delegated>>;
88 /**
Agents as a team: lifecycle, merge queue, billing and a new shell89 * Has an agent read the repository and turn an outcome into a plan: the
90 * issues that would get there and the order they have to land in. Returns
91 * the plan's id as soon as the sandbox is starting; the plan fills in when
92 * the agent has written it. Members of the repository's workspace only.
93 */
94 plan(actor: User, repo: RepoPath, brief: string): Promise<Result<{ planId: string }>>;
95 /**
96 * Opens a plan's issues. With `assign`, a g1t agent starts on each that
97 * depends on nothing, and on the others as what they depend on merges.
98 */
99 applyPlan(
100 actor: User,
101 repo: RepoPath,
102 planId: string,
103 options?: { assign?: boolean; keep?: number[] },
104 ): Promise<Result<Plan>>;
105 /**
106 * Brings a pull request up to date with the branch it would merge into,
107 * in a sandbox. A clean merge is pushed as it is; a conflict is resolved
108 * by a g1t agent. Whoever can push to the pull request's source may ask:
109 * its author, or for one from a branch, a workspace member.
110 */
111 update(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
112 /**
113 * Has a g1t agent review a pull request: line comments, a summary and a
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent114 * verdict, posted as `g1t`.
Agents as a team: lifecycle, merge queue, billing and a new shell115 */
116 review(actor: User, repo: RepoPath, number: number): Promise<Result<boolean>>;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains117 /**
118 * Stops an agent run: marks it stopped, destroys its sandbox, and leaves
119 * the pull request it was on for a person. Members of the workspace only.
120 */
121 stopRun(actor: User, repo: RepoPath, runId: string): Promise<Result<AgentRun>>;
Hosted agents: sandboxes on Cloudflare Containers started from an intent122}