Skip to content

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.sh
72 linesCodeBlameRaw
1// A service that is turned off on this installation.
2//
3// Self-hosted phase 1 runs the core forge only. The site and the services
4// still hold bindings to the cloud runner and the deployments' builders;
5// this Worker stands in for each of them, so a page that asks whether the
6// runner is on here is told no instead of failing.
7//
8// - As the runner (RunnerApi in packages/contracts/src/runner.ts): it is
9// not enabled, and starting anything fails with a message that says why.
10// - For the JSON protocol the Rust services speak (`POST /rpc/<method>`):
11// every method answers with a failed Result.
12//
13// OFF_NAME names the feature in those messages, such as "Cloud runners".
14
15import { WorkerEntrypoint } from "cloudflare:workers";
16
17function off(env) {
18 const name = env.OFF_NAME ?? "This feature";
19 return {
20 ok: false,
21 error: { code: "forbidden", message: `${name} are off on this installation of g1t.` },
22 };
23}
24
25export default class Off extends WorkerEntrypoint {
26 // ── The runner's methods, as the site calls them ──
27 async enabled() {
28 return false;
29 }
30 async modelAccess() {
31 return { own: null, hosted: false, trial: null };
32 }
33 async instructions() {
34 return off(this.env);
35 }
36 async run() {
37 return off(this.env);
38 }
39 async plan() {
40 return off(this.env);
41 }
42 async applyPlan() {
43 return off(this.env);
44 }
45 async update() {
46 return off(this.env);
47 }
48 async review() {
49 return off(this.env);
50 }
51 async recheck() {
52 return off(this.env);
53 }
54 async stopRun() {
55 return off(this.env);
56 }
57
58 // ── The JSON protocol ──
59 async fetch(request) {
60 const { pathname } = new URL(request.url);
61 if (request.method === "POST" && pathname.startsWith("/rpc/")) {
62 return Response.json(off(this.env));
63 }
64 return new Response("Off on this installation.", { status: 404 });
65 }
66
67 // Events and schedules for a service that is off are dropped.
68 async queue(batch) {
69 batch.ackAll();
70 }
71 async scheduled() {}
72}