Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/server/src/provider/Layers/CodexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export function codexPlanLabel(planType: string | null | undefined): string | un
return "ChatGPT Pro 20x Subscription";
case "prolite":
return "ChatGPT Pro 5x Subscription";
case "promax":
return "ChatGPT Pro 25x Subscription";
case "team":
return "ChatGPT Team Subscription";
case "self_serve_business_prolite":
Expand Down
8 changes: 7 additions & 1 deletion packages/effect-codex-app-server/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ const ManualSchemas: Record<string, Schema.Json> = {
},
};

// Codex ships new ChatGPT plans between protocol refreshes and reads unknown
// ones as `unknown`. Accept any plan so a new one cannot fail account reads.
const DefinitionSchemaOverrides: Record<string, Schema.Json> = {
PlanType: { type: "string" },
};

const getGeneratedPaths = Effect.fn("getGeneratedPaths")(function* () {
const path = yield* Path.Path;
const generatedDir = path.join(import.meta.dirname, "..", "src", "_generated");
Expand Down Expand Up @@ -643,7 +649,7 @@ const generateFiles = Effect.fn("generateFiles")(function* () {
aggregateSchemas[localDefinitionNames.get(definitionName)!] = stripNullDefaults(
normalizeNullableTypes(
rewriteExternalRefs(
definitionSchema,
DefinitionSchemaOverrides[definitionName] ?? definitionSchema,
localDefinitionNames,
file.namespace,
exportNameByQualifiedName,
Expand Down
205 changes: 20 additions & 185 deletions packages/effect-codex-app-server/src/_generated/schema.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3204,43 +3204,10 @@ export const ServerNotification__AuthMode = Schema.Union(
identifier: "ServerNotification__AuthMode",
});

export type ServerNotification__PlanType =
| "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";
export const ServerNotification__PlanType = Schema.Literals([
"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",
]).annotate({ identifier: "ServerNotification__PlanType" });
export type ServerNotification__PlanType = string;
export const ServerNotification__PlanType = Schema.String.annotate({
identifier: "ServerNotification__PlanType",
});

export type ServerNotification__CreditsSnapshot = {
readonly balance?: string | null;
Expand Down Expand Up @@ -4138,43 +4105,10 @@ export const V2AccountRateLimitsUpdatedNotification__SpendControlLimitSnapshot =
used: Schema.String,
}).annotate({ identifier: "V2AccountRateLimitsUpdatedNotification__SpendControlLimitSnapshot" });

export type V2AccountRateLimitsUpdatedNotification__PlanType =
| "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";
export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.Literals([
"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",
]).annotate({ identifier: "V2AccountRateLimitsUpdatedNotification__PlanType" });
export type V2AccountRateLimitsUpdatedNotification__PlanType = string;
export const V2AccountRateLimitsUpdatedNotification__PlanType = Schema.String.annotate({
identifier: "V2AccountRateLimitsUpdatedNotification__PlanType",
});

export type V2AccountRateLimitsUpdatedNotification__RateLimitWindow = {
readonly resetsAt?: number | null;
Expand Down Expand Up @@ -4260,43 +4194,10 @@ export const V2AccountUpdatedNotification__AuthMode = Schema.Union(
identifier: "V2AccountUpdatedNotification__AuthMode",
});

export type V2AccountUpdatedNotification__PlanType =
| "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";
export const V2AccountUpdatedNotification__PlanType = Schema.Literals([
"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",
]).annotate({ identifier: "V2AccountUpdatedNotification__PlanType" });
export type V2AccountUpdatedNotification__PlanType = string;
export const V2AccountUpdatedNotification__PlanType = Schema.String.annotate({
identifier: "V2AccountUpdatedNotification__PlanType",
});

export type V2AppListUpdatedNotification__AppReview = { readonly status: string };
export const V2AppListUpdatedNotification__AppReview = Schema.Struct({
Expand Down Expand Up @@ -5484,43 +5385,10 @@ export const V2GetAccountRateLimitsResponse__SpendControlLimitSnapshot = Schema.
used: Schema.String,
}).annotate({ identifier: "V2GetAccountRateLimitsResponse__SpendControlLimitSnapshot" });

export type V2GetAccountRateLimitsResponse__PlanType =
| "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";
export const V2GetAccountRateLimitsResponse__PlanType = Schema.Literals([
"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",
]).annotate({ identifier: "V2GetAccountRateLimitsResponse__PlanType" });
export type V2GetAccountRateLimitsResponse__PlanType = string;
export const V2GetAccountRateLimitsResponse__PlanType = Schema.String.annotate({
identifier: "V2GetAccountRateLimitsResponse__PlanType",
});

export type V2GetAccountRateLimitsResponse__RateLimitWindow = {
readonly resetsAt?: number | null;
Expand Down Expand Up @@ -5563,43 +5431,10 @@ export const V2GetAccountRateLimitsResponse__RateLimitReachedType = Schema.Liter
"workspace_member_usage_limit_reached",
]).annotate({ identifier: "V2GetAccountRateLimitsResponse__RateLimitReachedType" });

export type V2GetAccountResponse__PlanType =
| "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";
export const V2GetAccountResponse__PlanType = Schema.Literals([
"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",
]).annotate({ identifier: "V2GetAccountResponse__PlanType" });
export type V2GetAccountResponse__PlanType = string;
export const V2GetAccountResponse__PlanType = Schema.String.annotate({
identifier: "V2GetAccountResponse__PlanType",
});

export type V2GetAccountResponse__AccountRoutingOverride = "NO_CONSTRAINT" | "us" | "us_cr";
export const V2GetAccountResponse__AccountRoutingOverride = Schema.Literals([
Expand Down
18 changes: 8 additions & 10 deletions packages/effect-codex-app-server/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import * as Schema from "effect/Schema";
import * as CodexSchema from "./schema.ts";

const isGetAccountResponse = Schema.is(CodexSchema.V2GetAccountResponse);
const isAccountUpdatedNotification = Schema.is(CodexSchema.V2AccountUpdatedNotification);
const isAccountRateLimitsUpdatedNotification = Schema.is(
CodexSchema.V2AccountRateLimitsUpdatedNotification,
);
const isThreadReadResponse = Schema.is(CodexSchema.V2ThreadReadResponse);
const isThreadResumeResponse = Schema.is(CodexSchema.V2ThreadResumeResponse);
const isThreadForkResponse = Schema.is(CodexSchema.V2ThreadForkResponse);
Expand Down Expand Up @@ -201,16 +205,8 @@ it("accepts Codex misalignment policy errors for thread responses", () => {
);
});

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) {
it("accepts account plans newer than the generated protocol", () => {
for (const planType of ["promax", "a_plan_codex_adds_later"]) {
const accountResponse = {
account: {
email: "user@example.com",
Expand All @@ -221,5 +217,7 @@ it("accepts Codex 0.150 account plan values", () => {
};

assert.equal(isGetAccountResponse(accountResponse), true);
assert.equal(isAccountUpdatedNotification({ authMode: "chatgpt", planType }), true);
assert.equal(isAccountRateLimitsUpdatedNotification({ rateLimits: { planType } }), true);
}
});
Loading