TypeScript
fix(codex): accept Codex 0.150 account plans (#8447)
Gianmarco94401d01b956
diff --git a/apps/server/src/provider/Layers/CodexProvider.ts b/apps/server/src/provider/Layers/CodexProvider.tsindex 52a8fdd25dc..776a8e00e1c 100644--- a/apps/server/src/provider/Layers/CodexProvider.ts+++ b/apps/server/src/provider/Layers/CodexProvider.ts@@ -86,13 +86,18 @@ function codexAccountAuthLabel(account: CodexSchema.V2GetAccountResponse["accounreturn "ChatGPT Pro 5x Subscription";case "team":return "ChatGPT Team Subscription";+ case "self_serve_business_prolite":case "self_serve_business_usage_based":case "business":return "ChatGPT Business Subscription";+ case "ent26":+ case "enterprise_cbp_automation":case "enterprise_cbp_usage_based":case "enterprise":return "ChatGPT Enterprise Subscription";case "edu":+ case "edu_plus":+ case "edu_pro":return "ChatGPT Edu Subscription";case "unknown":return "ChatGPT Subscription";diff --git a/packages/effect-codex-app-server/scripts/generate.ts b/packages/effect-codex-app-server/scripts/generate.tsindex 44de61d2816..3622cb8f515 100644--- a/packages/effect-codex-app-server/scripts/generate.ts+++ b/packages/effect-codex-app-server/scripts/generate.ts@@ -166,6 +166,28 @@ const Codex0150DefinitionSchemas: Record<string, Schema.Json> = {type: "string",enum: ["inProgress", "completed", "failed", "interrupted"],},+ PlanType: {+ type: "string",+ enum: [+ "free",+ "go",+ "plus",+ "pro",+ "prolite",+ "team",+ "self_serve_business_prolite",+ "self_serve_business_usage_based",+ "business",+ "ent26",+ "enterprise_cbp_automation",+ "enterprise_cbp_usage_based",+ "enterprise",+ "edu",+ "edu_plus",+ "edu_pro",+ "unknown",+ ],+ },SubAgentActivityKind: {type: "string",enum: ["started", "interacted", "interrupted", "completed"],diff --git a/packages/effect-codex-app-server/src/_generated/schema.gen.ts b/packages/effect-codex-app-server/src/_generated/schema.gen.tsindex 6b200a42084..34df10eb03b 100644--- a/packages/effect-codex-app-server/src/_generated/schema.gen.ts+++ b/packages/effect-codex-app-server/src/_generated/schema.gen.ts@@ -2411,11 +2411,16 @@ export type ServerNotification__PlanType =| "pro"| "prolite"| "team"+ | "self_serve_business_prolite"| "self_serve_business_usage_based"| "business"+ | "ent26"+ | "enterprise_cbp_automation"| "enterprise_cbp_usage_based"| "enterprise"| "edu"+ | "edu_plus"+ | "edu_pro"| "unknown";export const ServerNotification__PlanType = Schema.Literals(["free",@@ -2424,11 +2429,16 @@ export const ServerNotification__PlanType = Schema.Literals(["pro","prolite","team",+ "self_serve_business_prolite","self_serve_business_usage_based","business",+ "ent26",+ "enterprise_cbp_automation","enterprise_cbp_usage_based","enterprise","edu",+ "edu_plus",+ "edu_pro","unknown",]);@@ -3248,11 +3258,16 @@ export type V2AccountRateLimitsUpdatedNotification__PlanType =| "pro"| "prolite"| "team"+ | "self_serve_business_prolite"| "self_serve_business_usage_based"| "business"+ | "ent26"+ | "enterprise_cbp_automation"| "enterprise_cbp_usage_based"| "enterprise"| "edu"+ | "edu_plus"+ | "edu_pro"| "unknown";export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.Literals(["free",@@ -3261,11 +3276,16 @@ export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.Literals("pro","prolite","team",+ "self_serve_business_prolite","self_serve_business_usage_based","business",+ "ent26",+ "enterprise_cbp_automation","enterprise_cbp_usage_based","enterprise","edu",+ "edu_plus",+ "edu_pro","unknown",]);@@ -3336,11 +3356,16 @@ export type V2AccountUpdatedNotification__PlanType =| "pro"| "prolite"| "team"+ | "self_serve_business_prolite"| "self_serve_business_usage_based"| "business"+ | "ent26"+ | "enterprise_cbp_automation"| "enterprise_cbp_usage_based"| "enterprise"| "edu"+ | "edu_plus"+ | "edu_pro"| "unknown";export const V2AccountUpdatedNotification__PlanType = Schema.Literals(["free",@@ -3349,11 +3374,16 @@ export const V2AccountUpdatedNotification__PlanType = Schema.Literals(["pro","prolite","team",+ "self_serve_business_prolite","self_serve_business_usage_based","business",+ "ent26",+ "enterprise_cbp_automation","enterprise_cbp_usage_based","enterprise","edu",+ "edu_plus",+ "edu_pro","unknown",]);@@ -4140,11 +4170,16 @@ export type V2GetAccountRateLimitsResponse__PlanType =| "pro"| "prolite"| "team"+ | "self_serve_business_prolite"| "self_serve_business_usage_based"| "business"+ | "ent26"+ | "enterprise_cbp_automation"| "enterprise_cbp_usage_based"| "enterprise"| "edu"+ | "edu_plus"+ | "edu_pro"| "unknown";export const V2GetAccountRateLimitsResponse__PlanType = Schema.Literals(["free",@@ -4153,11 +4188,16 @@ export const V2GetAccountRateLimitsResponse__PlanType = Schema.Literals(["pro","prolite","team",+ "self_serve_business_prolite","self_serve_business_usage_based","business",+ "ent26",+ "enterprise_cbp_automation","enterprise_cbp_usage_based","enterprise","edu",+ "edu_plus",+ "edu_pro","unknown",]);@@ -4228,11 +4268,16 @@ export type V2GetAccountResponse__PlanType =| "pro"| "prolite"| "team"+ | "self_serve_business_prolite"| "self_serve_business_usage_based"| "business"+ | "ent26"+ | "enterprise_cbp_automation"| "enterprise_cbp_usage_based"| "enterprise"| "edu"+ | "edu_plus"+ | "edu_pro"| "unknown";export const V2GetAccountResponse__PlanType = Schema.Literals(["free",@@ -4241,11 +4286,16 @@ export const V2GetAccountResponse__PlanType = Schema.Literals(["pro","prolite","team",+ "self_serve_business_prolite","self_serve_business_usage_based","business",+ "ent26",+ "enterprise_cbp_automation","enterprise_cbp_usage_based","enterprise","edu",+ "edu_plus",+ "edu_pro","unknown",]);diff --git a/packages/effect-codex-app-server/src/schema.test.ts b/packages/effect-codex-app-server/src/schema.test.tsindex 93935aa19aa..d7afec7db26 100644--- a/packages/effect-codex-app-server/src/schema.test.ts+++ b/packages/effect-codex-app-server/src/schema.test.ts@@ -3,6 +3,8 @@ import * as Schema from "effect/Schema";import * as CodexSchema from "./schema.ts";+const isGetAccountResponse = Schema.is(CodexSchema.V2GetAccountResponse);+it("accepts Codex 0.150 multi-agent values", () => {const schemas = [CodexSchema.ServerNotification__SubAgentActivityKind,@@ -71,3 +73,26 @@ it("accepts Codex 0.150 multi-agent values", () => {assert.equal(Schema.is(CodexSchema.V2ThreadResumeResponse)(resumeResponse), true);});++it("accepts Codex 0.150 account plan values", () => {+ const planTypes = [+ "self_serve_business_prolite",+ "ent26",+ "enterprise_cbp_automation",+ "edu_plus",+ "edu_pro",+ ];++ for (const planType of planTypes) {+ const accountResponse = {+ account: {+ email: "[email protected]",+ planType,+ type: "chatgpt",+ },+ requiresOpenaiAuth: true,+ };++ assert.equal(isGetAccountResponse(accountResponse), true);+ }+});