An open-source, faster Devin alternative
TypeScript
Gate the Codex connect on the computer's codexAvailable
Igor Zalutski via Computerd6cf6326f056
diff --git a/cloudflare-workers/api-edge/src/computer.ts b/cloudflare-workers/api-edge/src/computer.tsindex 5e1bd77e..692f8ee2 100644--- a/cloudflare-workers/api-edge/src/computer.ts+++ b/cloudflare-workers/api-edge/src/computer.ts@@ -46,6 +46,7 @@ export const COMPUTER_ERROR_MESSAGES: Record<string, string> = {"That's not a ChatGPT login. Paste the auth.json that codex login wrote.",computer_connect_code_invalid:"That connect code is not valid. Get a new one from the dashboard.",+ computer_codex_unavailable: "Codex isn't available on this computer yet.",invalid_request: "That choice isn't valid.",};@@ -183,6 +184,9 @@ export function publicComputerAgent(...(linkedSlackUser ? { linkedSlackUser } : {}),subscription,managedModel: agent.managedModel,+ // Rollout gate and kill switch (work 082): an older blue that does not+ // send it keeps Codex hidden.+ codexAvailable: agent.codexAvailable === true,};}diff --git a/cloudflare-workers/api-edge/src/managed_agents.test.ts b/cloudflare-workers/api-edge/src/managed_agents.test.tsindex 8106be79..00aad394 100644--- a/cloudflare-workers/api-edge/src/managed_agents.test.ts+++ b/cloudflare-workers/api-edge/src/managed_agents.test.ts@@ -6693,6 +6693,7 @@ describe("organization computer (work 052)", () => {setAt: "2026-10-22T10:00:00.000Z",},managedModel: "Claude Opus 5.5",+ codexAvailable: false,};it("passes the agent block of GET /computer field by field", async () => {@@ -6728,12 +6729,31 @@ describe("organization computer (work 052)", () => {"/computer",Response.json({ ...computerStatus, agent: minimal }),);+ // An older blue sends no codexAvailable: Codex stays hidden.await expect(response.json()).resolves.toEqual({...computerStatus,- agent: minimal,+ agent: { ...minimal, codexAvailable: false },});});+ it.each([+ [true, true],+ [false, false],+ ["true", false],+ [1, false],+ ])("passes codexAvailable %j as %j", async (value, expected) => {+ const { response } = await call(+ "GET",+ "/computer",+ Response.json({+ ...computerStatus,+ agent: { ...agent, codexAvailable: value },+ }),+ );+ const body = (await response.json()) as { agent: { codexAvailable: unknown } };+ expect(body.agent.codexAvailable).toBe(expected);+ });+it.each([["an unknown choice", { ...agent, choice: "gemini" }],["an unknown health", { ...agent, subscription: { ...agent.subscription, health: "great" } }],@@ -6976,6 +6996,7 @@ describe("organization computer (work 052)", () => {[403, "computer_agent_not_member", "You're not a member of this organization's Slack workspace."],[422, "computer_agent_codex_auth", "That's not a ChatGPT login. Paste the auth.json that codex login wrote."],[401, "computer_connect_code_invalid", "That connect code is not valid. Get a new one from the dashboard."],+ [409, "computer_codex_unavailable", "Codex isn't available on this computer yet."],])("maps %s %s to fixed copy", async (status, code, message) => {const { response } = await call("PUT",diff --git a/web/src/api/mock.ts b/web/src/api/mock.tsindex bcd91727..f6b93d78 100644--- a/web/src/api/mock.ts+++ b/web/src/api/mock.ts@@ -1300,8 +1300,10 @@ let previewBootSince: number | null = null// `?agent=codex` is a connected ChatGPT plan. The one-command connect (work// 082) mints a placeholder code; with `?connect=auto` the preview plays the// person running it: about six seconds later the card's subscription (Codex-// when Codex is chosen, else Claude) is connected.+// when Codex is chosen, else Claude) is connected. Codex shows as coming+// unless `?codex=available` (or `?agent=codex`) says the computer can run it.type PreviewAgent = {+ codexAvailable: booleanchoice: 'claude' | 'codex' | 'credits' | nulllinked: booleanlinkedSlackUser?: { id: string; name: string; teamName: string }@@ -1331,7 +1333,12 @@ function previewAgent(): PreviewAgent | null {: {}),setAt: new Date(BASE).toISOString(),})- const base = { managedModel: 'Claude Opus 5.5' }+ const base = {+ managedModel: 'Claude Opus 5.5',+ codexAvailable:+ param === 'codex' ||+ new URLSearchParams(window.location.search).get('codex') === 'available',+ }// The seat binds to a Slack user through the install: before it, nobody// is linked and no Slack user is named.const link = setup ? { linked: false } : { linked: true, linkedSlackUser }diff --git a/web/src/managed-agents/AgentStep.test.tsx b/web/src/managed-agents/AgentStep.test.tsxindex 34ca44da..f3f9c9b6 100644--- a/web/src/managed-agents/AgentStep.test.tsx+++ b/web/src/managed-agents/AgentStep.test.tsx@@ -50,6 +50,8 @@ const fresh: ComputerAgent = {subscription: null,managedModel: 'Claude Opus 5.5',}+// The rollout gate: blue says this computer can run Codex.+const withCodex: ComputerAgent = { ...fresh, codexAvailable: true }const subscription = (health: NonNullable<ComputerAgent['subscription']>['health'],) => ({ provider: 'claude' as const, health, setAt: '2026-10-22T10:00:00Z' })@@ -408,8 +410,11 @@ describe('choosing the coding agent', () => {})it('connects Codex with one command and moves on once signed in', async () => {- await show({ ...empty, agent: fresh }, 'Choose your coding agent')- computerApi.setAgentChoice.mockResolvedValue({ ...fresh, choice: 'codex' })+ await show({ ...empty, agent: withCodex }, 'Choose your coding agent')+ computerApi.setAgentChoice.mockResolvedValue({+ ...withCodex,+ choice: 'codex',+ })act(() => codexCard().click())await settle(() => command()?.includes(' codex ') === true, 'codex command')expect(command()).toBe(@@ -436,7 +441,7 @@ describe('choosing the coding agent', () => {computerApi.getComputer.mockResolvedValue({...empty,agent: {- ...fresh,+ ...withCodex,choice: 'codex',subscription: {provider: 'codex',@@ -626,7 +631,7 @@ describe('choosing the coding agent', () => {it('lands on the step again with Codex chosen, Codex selected', async () => {await show(- { ...empty, agent: { ...fresh, choice: 'codex' } },+ { ...empty, agent: { ...withCodex, choice: 'codex' } },'Choose your coding agent',)expect(text()).toContain('Step 1 of 4')@@ -634,6 +639,67 @@ describe('choosing the coding agent', () => {expect(computerApi.setAgentChoice).not.toHaveBeenCalled()})+ describe('where this computer cannot run Codex yet', () => {+ it.each([+ ['an older backend that does not say', fresh],+ ['the gate switched off', { ...fresh, codexAvailable: false }],+ ])('only records Codex on %s', async (_, agent: ComputerAgent) => {+ await show({ ...empty, agent }, 'Choose your coding agent')+ await settle(() => command() !== undefined, 'claude command')+ computerApi.setAgentChoice.mockResolvedValue({+ ...agent,+ choice: 'codex',+ })+ act(() => codexCard().click())+ await settle(+ () => text().includes("Codex is coming. We'll let you know."),+ 'coming line',+ )+ expect(computerApi.setAgentChoice).toHaveBeenCalledWith('codex')+ expect(command()).toBeUndefined()+ expect(text()).not.toContain('it opens ChatGPT to sign in')+ // The Claude command was minted for the first card; Codex mints none.+ expect(computerApi.createConnectCode).toHaveBeenCalledTimes(1)+ })++ it('lands on the coming line with Codex chosen, and mints nothing', async () => {+ await show(+ { ...empty, agent: { ...fresh, choice: 'codex' } },+ "Codex is coming. We'll let you know.",+ )+ expect(command()).toBeUndefined()+ expect(computerApi.createConnectCode).not.toHaveBeenCalled()+ expect(computerApi.setAgentChoice).not.toHaveBeenCalled()+ })++ it('offers only Claude Code on the agent card', async () => {+ await show(+ {+ ...onboarded,+ agent: { ...fresh, choice: 'credits', linked: true },+ },+ 'Your agent',+ )+ expect(button('Connect Claude Code')).toBeDefined()+ expect(button('Use Codex instead')).toBeUndefined()+ expect(button('Connect Codex')).toBeUndefined()+ })+ })++ it('offers Codex on the agent card where this computer can run it', async () => {+ await show(+ {+ ...onboarded,+ agent: { ...withCodex, choice: 'credits', linked: true },+ },+ 'Your agent',+ )+ expect(button('Connect Claude Code')).toBeDefined()+ act(() => button('Use Codex instead')!.click())+ act(() => button('Connect Codex')!.click())+ await settle(() => command()?.includes(' codex ') === true, 'codex command')+ })+it('starts on free credits', async () => {await show({ ...empty, agent: fresh }, 'Choose your coding agent')computerApi.setAgentChoice.mockResolvedValue({diff --git a/web/src/managed-agents/AgentStep.tsx b/web/src/managed-agents/AgentStep.tsxindex 4c60bcab..b0e6d58a 100644--- a/web/src/managed-agents/AgentStep.tsx+++ b/web/src/managed-agents/AgentStep.tsx@@ -249,13 +249,21 @@ export function AgentSetup({mark={<span className="bg-foreground text-background">◎</span>}/></div>- <SubscriptionConnect- // A new card is a new command: its own sign-in and wait.- key={selected}- provider={selected}- replacing={agent.subscription?.provider === selected}- onDone={onDone}- />+ {selected === 'codex' && !agent.codexAvailable ? (+ // Not rolled out to this computer (or switched off): the card only+ // records the interest, no code is minted.+ <p className="bg-muted/60 text-foreground rounded-lg px-4 py-3">+ Codex is coming. We'll let you know.+ </p>+ ) : (+ <SubscriptionConnect+ // A new card is a new command: its own sign-in and wait.+ key={selected}+ provider={selected}+ replacing={agent.subscription?.provider === selected}+ onDone={onDone}+ />+ )}<div className="flex flex-wrap items-center justify-between gap-4 rounded-lg border border-dashed px-4 py-3"><div><p className="text-foreground font-semibold">@@ -867,9 +875,12 @@ export function AgentManage({const [replacing, setReplacing] = useState(false)const [confirmDisconnect, setConfirmDisconnect] = useState(false)// Which subscription to connect when there is none.- const [connecting, setConnecting] = useState<SubscriptionProvider>(+ const codex = agent.codexAvailable === true+ const [picked, setConnecting] = useState<SubscriptionProvider>(agent.choice === 'codex' ? 'codex' : 'claude',)+ // Codex only where this computer can run it (the rollout gate).+ const connecting: SubscriptionProvider = codex ? picked : 'claude'const resume = useMutation({mutationFn: resumeClaudeSubscription,onSuccess: async (next) => {@@ -917,14 +928,16 @@ export function AgentManage({provider={connecting}mintOnShow={false}/>- <Button- variant="link"- size="sm"- className="text-muted-foreground h-auto px-0"- onClick={() => setConnecting(other)}- >- Use {PROVIDER_NAME[other]} instead- </Button>+ {codex ? (+ <Button+ variant="link"+ size="sm"+ className="text-muted-foreground h-auto px-0"+ onClick={() => setConnecting(other)}+ >+ Use {PROVIDER_NAME[other]} instead+ </Button>+ ) : null}</div>)}@@ -968,13 +981,17 @@ export function AgentManage({Resume</Button>) : null}- <Button- size="sm"- variant="outline"- onClick={() => setReplacing(true)}- >- {subscription.provider === 'codex' ? 'Reconnect' : 'Replace'}- </Button>+ {subscription.provider === 'claude' || codex ? (+ // A Codex login switched off by the gate can still be+ // disconnected, not signed in again.+ <Button+ size="sm"+ variant="outline"+ onClick={() => setReplacing(true)}+ >+ {subscription.provider === 'codex' ? 'Reconnect' : 'Replace'}+ </Button>+ ) : null}<Buttonsize="sm"variant="ghost"diff --git a/web/src/managed-agents/computer-api.ts b/web/src/managed-agents/computer-api.tsindex 6d5d50a6..17b1e02c 100644--- a/web/src/managed-agents/computer-api.ts+++ b/web/src/managed-agents/computer-api.ts@@ -61,6 +61,11 @@ export const computerAgentSchema = z.object({.nullable(),/** The model free credits run, e.g. "Claude Opus 5.5". */managedModel: z.string(),+ /**+ * This computer can run Codex (work 082 rollout gate and kill switch).+ * Absent reads as false: Codex stays "coming".+ */+ codexAvailable: z.boolean().optional(),})export const computerStatusSchema = z.object({