The best way to control Claude Code, Codex and more from any computer or phone
feat(codex): choose a cyber access program for Daybreak-eligible models (#27928)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Martin Meredith committed
Nov 12, 2026 at 20:56 UTC
359daaf367e876edace1757fd9a4377be1cb357c
10 files changed
+357
-54
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+63
-4
@@ -31,6 +31,7 @@ import {
31
RunId,
32
ThreadId,
33
TurnItemId,
34
+ type ServerProviderModel,
35
} from "@t3tools/contracts";
36
import { assert, describe, it } from "@effect/vitest";
37
import * as CodexClient from "effect-codex-app-server/client";
@@ -230,6 +231,34 @@ describe("CodexAdapterV2 runtime policy", () => {
231
}),
232
);
233
234
+ it.effect("sends the chosen cyber access program, else the model's default", () =>
235
+ Effect.gen(function* () {
236
+ const build = (value?: string, cyberAccess?: { defaultProgram: string | undefined }) =>
237
+ CodexAdapterV2.buildCodexTurnStartParams({
238
+ nativeThreadId: "native-cyber",
239
+ codexInput: [{ type: "text", text: "test" }],
240
+ runtimePolicy: { runtimeMode: "full-access", interactionMode: "default", cwd: null },
241
+ modelSelection: {
242
+ instanceId: ProviderInstanceId.make("codex"),
243
+ model: "gpt-5.4",
244
+ ...(value === undefined ? {} : { options: [{ id: "cyberAccessProgram", value }] }),
245
+ },
246
+ cyberAccess,
247
+ });
248
+
249
+ // Custom models offer no Cyber Access, so even an explicit choice is dropped.
250
+ assert.notProperty(yield* build(), "cyberAccessProgram");
251
+ assert.notProperty(yield* build("daybreakBlue"), "cyberAccessProgram");
252
+ const daybreak = { defaultProgram: "daybreakBlue" };
253
+ assert.equal((yield* build(undefined, daybreak)).cyberAccessProgram, "daybreakBlue");
254
+ assert.equal((yield* build("standard", daybreak)).cyberAccessProgram, "standard");
255
+ // An unread config leaves no default, but an explicit Standard still goes.
256
+ const unknown = { defaultProgram: undefined };
257
+ assert.notProperty(yield* build(undefined, unknown), "cyberAccessProgram");
258
+ assert.equal((yield* build("standard", unknown)).cyberAccessProgram, "standard");
259
+ }),
260
+ );
261
+
262
it.effect("sends MCP app model context as untrusted Codex context", () =>
263
Effect.gen(function* () {
264
const policy = { runtimeMode: "full-access", interactionMode: "default", cwd: null } as const;
@@ -1302,6 +1331,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
1331
onUsageLimits?: CodexAdapterV2.CodexAdapterV2Options["onUsageLimits"],
1332
promptSuggestions: Effect.Effect<boolean> = Effect.succeed(false),
1333
onNotification: (method: string) => Effect.Effect<void> = () => Effect.void,
1334
+ models?: CodexAdapterV2.CodexAdapterV2Options["models"],
1335
) =>
1336
Effect.gen(function* () {
1337
const fileSystem = yield* FileSystem.FileSystem;
@@ -1364,6 +1394,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
1394
environment: {},
1395
clientFactory,
1396
...(onUsageLimits ? { onUsageLimits } : {}),
1397
+ ...(models ? { models } : {}),
1398
digest: yield* Digest.Digest,
1399
fileSystem,
1400
idAllocator,
@@ -2705,12 +2736,18 @@ describe("CodexAdapterV2 post-settle continuation", () => {
2736
Effect.gen(function* () {
2737
const nativeThreadId = "context-thread";
2738
const nativeTurnId = "context-turn";
2739
+ // An explicit Standard must reach Codex, or Codex falls back to Daybreak.
2740
+ const modelSelection = {
2741
+ ...CODEX_TEST_MODEL_SELECTION,
2742
+ options: [{ id: "cyberAccessProgram", value: "standard" }],
2743
+ };
2744
const params = yield* CodexAdapterV2.buildCodexTurnStartParams({
2745
nativeThreadId,
2746
codexInput: [{ type: "text", text: "work" }],
2747
runtimePolicy: CODEX_TEST_RUNTIME_POLICY,
2712
- modelSelection: CODEX_TEST_MODEL_SELECTION,
2748
+ modelSelection,
2749
hasT3Mcp: true,
2750
+ cyberAccess: { defaultProgram: "daybreakBlue" },
2751
});
2752
assert.include(
2753
params.additionalContext?.t3_code_orchestration_01?.value ?? "",
@@ -2790,6 +2827,27 @@ describe("CodexAdapterV2 post-settle continuation", () => {
2827
if (method === "item/completed" || method === "turn/completed")
2828
wireOrder.push(method);
2829
}),
2830
+ Effect.succeed<ReadonlyArray<ServerProviderModel>>([
2831
+ {
2832
+ slug: modelSelection.model,
2833
+ name: modelSelection.model,
2834
+ isCustom: false,
2835
+ capabilities: {
2836
+ optionDescriptors: [
2837
+ {
2838
+ id: "cyberAccessProgram",
2839
+ label: "Cyber Access",
2840
+ type: "select",
2841
+ options: [
2842
+ { id: "standard", label: "Standard" },
2843
+ { id: "daybreakBlue", label: "Daybreak Blue", isDefault: true },
2844
+ ],
2845
+ currentValue: "daybreakBlue",
2846
+ },
2847
+ ],
2848
+ },
2849
+ },
2850
+ ]),
2851
);
2852
yield* (yield* McpProviderSessions.McpProviderSessions).set({
2853
environmentId: EnvironmentId.make("test"),
@@ -2800,15 +2858,16 @@ describe("CodexAdapterV2 post-settle continuation", () => {
2858
authorizationHeader: "Bearer test",
2859
browserToolsAvailable: true,
2860
});
2803
- yield* harness.runtime.startTurn(
2804
- makeCodexTestTurnInput({
2861
+ yield* harness.runtime.startTurn({
2862
+ ...makeCodexTestTurnInput({
2863
threadId: harness.threadId,
2864
providerThread: harness.providerThread,
2865
now: yield* DateTime.now,
2866
attemptId: RunAttemptId.make("context-attempt"),
2867
text: "work",
2868
}),
2811
- );
2869
+ modelSelection,
2870
+ });
2871
yield* harness.firstTerminal;
2872
yield* Deferred.await(restoreRequested);
2873
assert.equal(harness.terminalEvents()[0]?.status, "completed");
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+37
-19
@@ -38,6 +38,7 @@ import {
38
ProviderDriverKind,
39
ProviderSetupError,
40
type ServerProviderCompatibilityAdvisory,
41
+ type ServerProviderModel,
42
isDelegatedAppThread,
43
} from "@t3tools/contracts";
44
import { SKILL_MENTION_PATTERN } from "@t3tools/shared/composerInlineTokens";
@@ -712,19 +713,8 @@ const decodeTurnReasoningEffort = Schema.decodeUnknownEffect(
713
Schema.Union([CodexSchema.V2TurnStartParams__ReasoningEffort, Schema.Null]),
714
);
715
715
-const CodexTurnStartParamsWithCollaborationMode = CodexSchema.V2TurnStartParams.pipe(
716
- Schema.fieldsAssign({
717
- collaborationMode: Schema.optionalKey(CodexSchema.ClientRequest__CollaborationMode),
718
- additionalContext: Schema.optionalKey(
719
- Schema.Record(Schema.String, CodexSchema.V2TurnStartParams__AdditionalContextEntry),
720
- ),
721
- }),
722
-);
723
-type CodexTurnStartParamsWithCollaborationMode =
724
- typeof CodexTurnStartParamsWithCollaborationMode.Type;
725
-const decodeCodexTurnStartParamsWithCollaborationMode = Schema.decodeUnknownEffect(
726
- CodexTurnStartParamsWithCollaborationMode,
727
-);
716
+type CodexTurnStartParams = typeof CodexClient.V2TurnStartParams.Type;
717
+const decodeCodexTurnStartParams = Schema.decodeUnknownEffect(CodexClient.V2TurnStartParams);
718
const isProviderAdapterRuntimeRequestResponseError = Schema.is(
719
ProviderAdapter.ProviderAdapterRuntimeRequestResponseError,
720
);
@@ -770,6 +760,18 @@ function codexRuntimeModeTurnDefaults(runtimeMode: RuntimeMode): {
760
}
761
}
762
763
+const isCodexCyberAccessProgram = Schema.is(CodexSchema.V2TurnStartParams__CyberAccessProgram);
764
+
765
+function codexCyberAccess(
766
+ models: ReadonlyArray<ServerProviderModel>,
767
+ model: string,
768
+): { readonly defaultProgram: string | undefined } | undefined {
769
+ const descriptor = models
770
+ .find((candidate) => candidate.slug === model)
771
+ ?.capabilities?.optionDescriptors?.find((candidate) => candidate.id === "cyberAccessProgram");
772
+ return descriptor?.type === "select" ? { defaultProgram: descriptor.currentValue } : undefined;
773
+}
774
+
775
export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTurnStartParams")(
776
function* (input: {
777
readonly nativeThreadId: string;
@@ -782,6 +784,8 @@ export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTur
784
/** ChatGPT token sharing does not accept service tiers. */
785
readonly omitServiceTier?: boolean;
786
readonly appContext?: ProviderAdapter.ProviderAdapterV2TurnInput["appContext"];
787
+ /** Set only for a model that offers Cyber Access; custom models never do. */
788
+ readonly cyberAccess?: { readonly defaultProgram: string | undefined } | undefined;
789
/** The user's `model_reasoning_summary` from the Codex config, when set. */
790
readonly configuredReasoningSummary?: CodexSchema.V2TurnStartParams__ReasoningSummary;
791
}) {
@@ -803,6 +807,14 @@ export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTur
807
input.omitServiceTier === true
808
? undefined
809
: getCodexServiceTierOptionValue(input.modelSelection);
810
+ // A chosen program goes as is, even one the model lacks, so Codex rejects it visibly.
811
+ const cyberAccessProgram =
812
+ input.cyberAccess === undefined
813
+ ? undefined
814
+ : [
815
+ getModelSelectionStringOptionValue(input.modelSelection, "cyberAccessProgram"),
816
+ input.cyberAccess.defaultProgram,
817
+ ].find(isCodexCyberAccessProgram);
818
// MCP-written app context must be quoted user input, not developer instructions.
819
const appContext = Object.fromEntries(
820
(input.appContext ?? []).map((entry) => [
@@ -824,7 +836,7 @@ export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTur
836
t3Context === undefined && Object.keys(appContext).length === 0
837
? undefined
838
: { ...t3Context, ...appContext };
827
- return yield* decodeCodexTurnStartParamsWithCollaborationMode({
839
+ return yield* decodeCodexTurnStartParams({
840
threadId: input.nativeThreadId,
841
input: input.codexInput,
842
...(additionalContext ? { additionalContext } : {}),
@@ -839,6 +851,8 @@ export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTur
851
...(sandboxPolicy === undefined ? {} : { sandboxPolicy }),
852
...(effort === undefined ? {} : { effort }),
853
...(serviceTier === undefined ? {} : { serviceTier }),
854
+ // Codex keeps no per-thread choice for this, so every turn must carry it.
855
+ ...(cyberAccessProgram === undefined ? {} : { cyberAccessProgram }),
856
// Codex supplies its own mode instructions; send both modes to clear Plan on exit.
857
collaborationMode: {
858
mode: input.runtimePolicy.interactionMode,
@@ -1683,7 +1697,10 @@ export type CodexAdapterV2DriverEnv =
1697
1698
export const createCodexAdapterV2 = Effect.fn("CodexAdapterV2.createCodexAdapterV2")(function* (
1699
{ instanceId, environment, enabled, config }: ProviderAdapterDriverCreateInput<CodexSettings>,
1686
- hooks: Pick<CodexAdapterV2Options, "onUsageLimits" | "resolveRuntime" | "compatibility"> = {},
1700
+ hooks: Pick<
1701
+ CodexAdapterV2Options,
1702
+ "onUsageLimits" | "resolveRuntime" | "compatibility" | "models"
1703
+ > = {},
1704
) {
1705
const clientFactory = yield* CodexAppServerClientFactory;
1706
const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
@@ -1733,6 +1750,8 @@ export interface CodexAdapterV2Options {
1750
readonly environment: NodeJS.ProcessEnv;
1751
readonly clientFactory: CodexAppServerClientFactoryShape;
1752
readonly onUsageLimits?: ManagedServerProvider["applyUsageLimits"];
1753
+ /** The provider's published models, read per turn for catalog defaults. */
1754
+ readonly models?: Effect.Effect<ReadonlyArray<ServerProviderModel>>;
1755
readonly resolveRuntime?: Effect.Effect<CodexEffectiveRuntime, ProviderSetupError, Scope.Scope>;
1756
readonly compatibility?: (
1757
version: string,
@@ -1792,10 +1811,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
1811
environment: resolvedRuntime?.environment ?? adapterOptions.environment,
1812
});
1813
const additionalContextByThread = yield* Ref.make(
1795
- new Map<
1796
- string,
1797
- NonNullable<CodexTurnStartParamsWithCollaborationMode["additionalContext"]>
1798
- >(),
1814
+ new Map<string, NonNullable<CodexTurnStartParams["additionalContext"]>>(),
1815
);
1816
const threadsAwaitingContextRestore = yield* Ref.make(new Set<string>());
1817
// Codex drops client developer messages during compaction but only resends additionalContext
@@ -7240,6 +7256,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
7256
) {
7257
const threadId = yield* getNativeThreadId(turnInput.providerThread);
7258
const mcpSession = yield* mcpSessions.read(turnInput.threadId);
7259
+ const models = adapterOptions.models === undefined ? [] : yield* adapterOptions.models;
7260
const configuredReasoningSummary = yield* client
7261
.request("config/read", { cwd: turnInput.runtimePolicy.cwd, includeLayers: false })
7262
.pipe(
@@ -7249,6 +7266,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
7266
),
7267
);
7268
const turnStartParams = yield* buildCodexTurnStartParams({
7269
+ cyberAccess: codexCyberAccess(models, turnInput.modelSelection.model),
7270
nativeThreadId: threadId,
7271
codexInput,
7272
runtimePolicy: turnInput.runtimePolicy,
apps/server/src/peer/RemoteDelegation.test.ts
+18
-6
@@ -6,6 +6,7 @@ import {
6
CommandId,
7
EventId,
8
MessageId,
9
+ type ModelSelection,
10
NodeId,
11
type OrchestrationV2Run,
12
ProjectId,
@@ -744,7 +745,10 @@ const parentScope: McpInvocationContext.McpInvocationScope = {
745
};
746
747
/** The laptop's parent thread, mid-turn when its agent delegates. */
747
-const seedParent = (laptopEnv: Effect.Success<ReturnType<typeof makeLaptop>>) =>
748
+const seedParent = (
749
+ laptopEnv: Effect.Success<ReturnType<typeof makeLaptop>>,
750
+ parentModelSelection: ModelSelection = modelSelection,
751
+) =>
752
Effect.gen(function* () {
753
const now = yield* DateTime.now;
754
const providerThreadId = ProviderThreadId.make("provider-thread:laptop-parent");
@@ -756,7 +760,7 @@ const seedParent = (laptopEnv: Effect.Success<ReturnType<typeof makeLaptop>>) =>
760
threadId: parentThreadId,
761
projectId: ProjectId.make("project:laptop"),
762
title: "Laptop parent",
759
- modelSelection,
763
+ modelSelection: parentModelSelection,
764
runtimeMode: "full-access",
765
interactionMode: "default",
766
branch: null,
@@ -830,7 +834,7 @@ const seedParent = (laptopEnv: Effect.Success<ReturnType<typeof makeLaptop>>) =>
834
threadId: parentThreadId,
835
ordinal: 1,
836
providerInstanceId: instanceId,
833
- modelSelection,
837
+ modelSelection: parentModelSelection,
838
providerThreadId,
839
userMessageId: MessageId.make("message:seed-user:laptop-parent"),
840
rootNodeId: parentRootNode,
@@ -1191,16 +1195,24 @@ it.effect("a task named only by environment inherits the parent's model, within
1195
const a = yield* makeLaptop(database, offers);
1196
// The parent runs with full access; the link allows less.
1197
yield* linkTo(a.links, b, "auto-accept-edits");
1194
- yield* seedParent(a);
1198
+ // An explicit Standard must survive, or a Daybreak default there would replace it.
1199
+ const parentModelSelection = {
1200
+ ...modelSelection,
1201
+ options: [
1202
+ { id: "reasoningEffort", value: "high" },
1203
+ { id: "cyberAccessProgram", value: "standard" },
1204
+ ],
1205
+ };
1206
+ yield* seedParent(a, parentModelSelection);
1207
1208
const result = yield* a.call("delegate_task", {
1209
task: "Run the suite on the box.",
1210
target: { environmentId: box.environmentId },
1211
});
1212
expect(result.isError, JSON.stringify(result.content)).toBe(false);
1201
- // The parent's model, and the link's modes rather than the parent's.
1213
+ // The parent's model and options, and the link's modes rather than the parent's.
1214
expect(yield* Ref.get(thread.launchedWith)).toEqual({
1203
- modelSelection,
1215
+ modelSelection: parentModelSelection,
1216
runtimeMode: "auto-accept-edits",
1217
interactionMode: "default",
1218
});
apps/server/src/provider/CodexProvider.test.ts
+11
@@ -16,6 +16,7 @@ it("maps current Codex model capability fields", () => {
16
id: "gpt-test",
17
isDefault: true,
18
model: "gpt-test",
19
+ availableAccessPrograms: { cyber: ["standard", "daybreakBlue"] },
20
defaultServiceTier: "flex",
21
serviceTiers: [
22
{
@@ -65,6 +66,16 @@ it("maps current Codex model capability fields", () => {
66
],
67
currentValue: "flex",
68
},
69
+ {
70
+ id: "cyberAccessProgram",
71
+ label: "Cyber Access",
72
+ type: "select",
73
+ options: [
74
+ { id: "standard", label: "Standard", isDefault: true },
75
+ { id: "daybreakBlue", label: "Daybreak Blue" },
76
+ ],
77
+ currentValue: "standard",
78
+ },
79
]);
80
});
81
apps/server/src/provider/CodexProvider.ts
+126
-21
@@ -82,6 +82,18 @@ const CodexRoutingConfig = Schema.Struct({
82
});
83
const decodeCodexRoutingConfig = Schema.decodeUnknownOption(CodexRoutingConfig);
84
85
+const CodexCyberAccessConfig = Schema.Struct({
86
+ daybreak: Schema.optionalKey(Schema.NullOr(Schema.Boolean)),
87
+ features: Schema.optionalKey(
88
+ Schema.NullOr(
89
+ Schema.Struct({
90
+ api_key_cyber_access_programs: Schema.optionalKey(Schema.NullOr(Schema.Boolean)),
91
+ }),
92
+ ),
93
+ ),
94
+});
95
+const decodeCodexCyberAccessConfig = Schema.decodeUnknownOption(CodexCyberAccessConfig);
96
+
97
function routesToNativeOpenai(config: unknown): boolean {
98
const decoded = decodeCodexRoutingConfig(config);
99
if (Option.isNone(decoded)) return false;
@@ -133,6 +145,9 @@ export interface CodexAppServerProviderSnapshot {
145
readonly version: string | undefined;
146
readonly models: ReadonlyArray<ServerProviderModel> | undefined;
147
readonly serviceTier?: string | undefined;
148
+ /** Undefined when `config/read` failed, so T3 cannot know Codex's default program. */
149
+ readonly daybreakEnabled?: boolean | undefined;
150
+ readonly cyberAccessProgramsUnavailable?: boolean | undefined;
151
readonly skills: ReadonlyArray<ServerProviderSkill>;
152
}
153
@@ -153,6 +168,12 @@ const SERVICE_TIER_DESCRIPTIONS: Readonly<Record<string, string>> = {
168
ultrafast: "Even faster, more expensive",
169
};
170
171
+const CYBER_ACCESS_PROGRAM_LABELS: Readonly<Record<string, string>> = {
172
+ standard: "Standard",
173
+ daybreakBlue: "Daybreak Blue",
174
+ daybreakRed: "Daybreak Red",
175
+};
176
+
177
function reasoningEffortLabel(reasoningEffort: string): string {
178
return REASONING_EFFORT_LABELS[reasoningEffort] ?? reasoningEffort;
179
}
@@ -281,6 +302,25 @@ export function mapCodexModelCapabilities(
302
currentValue: defaultServiceTier,
303
});
304
}
305
+ const cyberAccessPrograms = model.availableAccessPrograms?.cyber ?? [];
306
+ if (cyberAccessPrograms.length > 0) {
307
+ const hasStandard = cyberAccessPrograms.includes("standard");
308
+ const defaultProgram = hasStandard ? "standard" : cyberAccessPrograms[0];
309
+ optionDescriptors.push({
310
+ id: "cyberAccessProgram",
311
+ label: "Cyber Access",
312
+ type: "select",
313
+ // Standard stays selectable as an opt-out; Codex rejects it visibly when the login cannot use it.
314
+ options: (hasStandard ? cyberAccessPrograms : ["standard", ...cyberAccessPrograms]).map(
315
+ (program) => ({
316
+ id: program,
317
+ label: CYBER_ACCESS_PROGRAM_LABELS[program] ?? program,
318
+ ...(program === defaultProgram ? { isDefault: true } : {}),
319
+ }),
320
+ ),
321
+ ...(defaultProgram === undefined ? {} : { currentValue: defaultProgram }),
322
+ });
323
+ }
324
325
return createModelCapabilities({
326
optionDescriptors,
@@ -320,37 +360,95 @@ export function applyPreferredCodexDefaultModel(
360
});
361
}
362
323
-function applyConfiguredCodexServiceTier(
363
+function mapCodexOptionDescriptors(
364
models: ReadonlyArray<ServerProviderModel>,
325
- serviceTier: string | undefined,
365
+ update: (
366
+ descriptors: ReadonlyArray<ProviderOptionDescriptor>,
367
+ model: ServerProviderModel,
368
+ ) => ReadonlyArray<ProviderOptionDescriptor>,
369
): ReadonlyArray<ServerProviderModel> {
327
- if (!serviceTier) return models;
370
return models.map((model) => {
371
if (!model.capabilities?.optionDescriptors) return model;
372
return {
373
...model,
374
capabilities: {
375
...model.capabilities,
334
- optionDescriptors: model.capabilities.optionDescriptors.map((descriptor) => {
335
- if (descriptor.id !== "serviceTier" || descriptor.type !== "select") return descriptor;
336
- const value = descriptor.options.find(
337
- (option) =>
338
- option.id === serviceTier || (serviceTier === "fast" && option.id === "priority"),
339
- )?.id;
340
- if (!value) return descriptor;
341
- return {
342
- ...descriptor,
343
- currentValue: value,
344
- options: descriptor.options.map(({ isDefault: _isDefault, ...option }) =>
345
- option.id === value ? { ...option, isDefault: true } : option,
346
- ),
347
- };
348
- }),
376
+ optionDescriptors: update(model.capabilities.optionDescriptors, model),
377
},
378
};
379
});
380
}
381
382
+function withConfiguredSelectDefault(
383
+ models: ReadonlyArray<ServerProviderModel>,
384
+ descriptorId: string,
385
+ pick: (options: ReadonlyArray<{ readonly id: string }>) => string | undefined,
386
+): ReadonlyArray<ServerProviderModel> {
387
+ return mapCodexOptionDescriptors(models, (descriptors) =>
388
+ descriptors.map((descriptor) => {
389
+ if (descriptor.id !== descriptorId || descriptor.type !== "select") return descriptor;
390
+ const value = pick(descriptor.options);
391
+ if (!value) return descriptor;
392
+ return {
393
+ ...descriptor,
394
+ currentValue: value,
395
+ options: descriptor.options.map(({ isDefault: _isDefault, ...option }) =>
396
+ option.id === value ? { ...option, isDefault: true } : option,
397
+ ),
398
+ };
399
+ }),
400
+ );
401
+}
402
+
403
+function applyConfiguredCodexServiceTier(
404
+ models: ReadonlyArray<ServerProviderModel>,
405
+ serviceTier: string | undefined,
406
+): ReadonlyArray<ServerProviderModel> {
407
+ if (!serviceTier) return models;
408
+ return withConfiguredSelectDefault(
409
+ models,
410
+ "serviceTier",
411
+ (options) =>
412
+ options.find(
413
+ (option) =>
414
+ option.id === serviceTier || (serviceTier === "fast" && option.id === "priority"),
415
+ )?.id,
416
+ );
417
+}
418
+
419
+/** Mirrors Codex: `daybreak = true` prefers a Daybreak program, Blue before Red. */
420
+function applyConfiguredCodexCyberAccess(
421
+ models: ReadonlyArray<ServerProviderModel>,
422
+ snapshot: Pick<
423
+ CodexAppServerProviderSnapshot,
424
+ "daybreakEnabled" | "cyberAccessProgramsUnavailable"
425
+ >,
426
+): ReadonlyArray<ServerProviderModel> {
427
+ // Without a descriptor no turn sends a program; without a default only an explicit choice goes.
428
+ const offered = mapCodexOptionDescriptors(models, (descriptors, model) =>
429
+ descriptors.flatMap((descriptor): ReadonlyArray<ProviderOptionDescriptor> => {
430
+ if (descriptor.id !== "cyberAccessProgram" || descriptor.type !== "select") {
431
+ return [descriptor];
432
+ }
433
+ if (model.isCustom || snapshot.cyberAccessProgramsUnavailable === true) return [];
434
+ if (snapshot.daybreakEnabled !== undefined) return [descriptor];
435
+ const { currentValue: _currentValue, ...withoutDefault } = descriptor;
436
+ return [
437
+ {
438
+ ...withoutDefault,
439
+ options: descriptor.options.map(({ isDefault: _isDefault, ...option }) => option),
440
+ },
441
+ ];
442
+ }),
443
+ );
444
+ if (snapshot.daybreakEnabled !== true) return offered;
445
+ return withConfiguredSelectDefault(offered, "cyberAccessProgram", (options) =>
446
+ ["daybreakBlue", "daybreakRed"].find((program) =>
447
+ options.some((option) => option.id === program),
448
+ ),
449
+ );
450
+}
451
+
452
/**
453
* Codex has no static default capability set, so a bare custom slug borrows
454
* the first built-in's descriptors; an entry with its own capabilities keeps
@@ -619,7 +717,7 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
717
718
// Optional discovery must finish before the outer timeout can discard the account result.
719
const deadlineMs = spawnedAtMs + CODEX_AUTH_PROBE_TIMEOUT_MS - CODEX_DISCOVERY_MARGIN_MS;
622
- const [skillsResponse, models, { serviceTier, nativeUsage, rateLimits }] = yield* Effect.all(
720
+ const [skillsResponse, models, { config, nativeUsage, rateLimits }] = yield* Effect.all(
721
[
722
withCodexDiscoveryDeadline(client.request("skills/list", { cwds: [input.cwd] }), deadlineMs),
723
accountResponse.account?.type === "chatgpt"
@@ -648,7 +746,7 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
746
: Effect.undefined;
747
return readUsage.pipe(
748
Effect.map((rateLimits) => ({
651
- serviceTier: config?.config.service_tier ?? undefined,
749
+ config: config?.config,
750
nativeUsage,
751
rateLimits,
752
})),
@@ -659,13 +757,19 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
757
{ concurrency: "unbounded" },
758
);
759
760
+ const cyberAccess = Option.getOrUndefined(decodeCodexCyberAccessConfig(config));
761
return {
762
account: accountResponse,
763
nativeUsage,
764
...(rateLimits ? { rateLimits } : {}),
765
version,
766
models,
668
- serviceTier,
767
+ serviceTier: config?.service_tier ?? undefined,
768
+ daybreakEnabled: config === undefined ? undefined : cyberAccess?.daybreak === true,
769
+ // An unread config cannot rule out an API key with the programs turned off.
770
+ cyberAccessProgramsUnavailable:
771
+ accountResponse.account?.type === "apiKey" &&
772
+ (config === undefined || cyberAccess?.features?.api_key_cyber_access_programs === false),
773
skills: skillsResponse ? parseCodexSkillsListResponse(skillsResponse, input.cwd) : [],
774
} satisfies CodexAppServerProviderSnapshot;
775
});
@@ -942,6 +1046,7 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
1046
appendCustomCodexModels(snapshot.models ?? [], codexSettings.customModels),
1047
applyPreferredCodexDefaultModel,
1048
(models) => applyConfiguredCodexServiceTier(models, snapshot.serviceTier),
1049
+ (models) => applyConfiguredCodexCyberAccess(models, snapshot),
1050
),
1051
skills: snapshot.skills,
1052
slashCommands: [
apps/server/src/provider/Drivers/CodexDriver.ts
+3
@@ -248,6 +248,9 @@ export const CodexDriver: ProviderDriver<
248
},
249
{
250
onUsageLimits: (update) => snapshot.applyUsageLimits(update),
251
+ models: Effect.suspend(() => snapshot.getSnapshot).pipe(
252
+ Effect.map((value) => value.models),
253
+ ),
254
compatibility: installation.compatibility,
255
},
256
).pipe(
apps/server/src/provider/Drivers/CodexManagedProvider.ts
+3
-1
@@ -242,8 +242,10 @@ export const makeManagedCodexProvider = Effect.fn("makeManagedCodexProvider")(fu
242
const resolveRuntime = runtime.auth.controller.withAccess!(runtime.resolve);
243
// Launch settings bind the refresh command to the signed-in profile. The registry
244
// already wraps openSession in withAccess, so resolve without re-entering it.
245
+ const models = snapshot.getSnapshot.pipe(Effect.map((value) => value.models));
246
const orchestrationAdapter = yield* createCodexAdapterV2(input, {
247
onUsageLimits: (update) => snapshot.applyUsageLimits(update),
248
+ models,
249
resolveRuntime: runtime.resolve,
250
}).pipe(
251
Effect.mapError(
@@ -259,7 +261,7 @@ export const makeManagedCodexProvider = Effect.fn("makeManagedCodexProvider")(fu
261
const nativeGeneration = yield* makeCodexTextGeneration(
262
config,
263
undefined,
262
- snapshot.getSnapshot.pipe(Effect.map((value) => value.models)),
264
+ models,
265
resolveRuntime,
266
);
267
const protect = <A>(operation: string, effect: Effect.Effect<A, TextGenerationError>) =>
apps/server/src/provider/ProviderRegistry.test.ts
+83
-1
@@ -44,7 +44,11 @@ import { deepMerge } from "@t3tools/shared/Struct";
44
import { createModelCapabilities } from "@t3tools/shared/model";
45
import { applyServerSettingsPatch } from "@t3tools/shared/serverSettings";
46
47
-import { checkCodexProviderStatus, type CodexAppServerProviderSnapshot } from "./CodexProvider.ts";
47
+import {
48
+ checkCodexProviderStatus,
49
+ mapCodexModelCapabilities,
50
+ type CodexAppServerProviderSnapshot,
51
+} from "./CodexProvider.ts";
52
import { BUNDLED_CLAUDE_MODEL_CATALOG } from "./ClaudeModelCatalog.ts";
53
import { checkClaudeProviderStatus } from "./ClaudeProvider.ts";
54
import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
@@ -503,6 +507,84 @@ it.layer(
507
}),
508
);
509
510
+ it.effect("offers cyber access only on catalog models that advertise it", () =>
511
+ Effect.gen(function* () {
512
+ const catalogModel = (slug: string, cyber?: Array<"standard" | "daybreakBlue">) => ({
513
+ slug,
514
+ name: slug,
515
+ isCustom: false,
516
+ capabilities: mapCodexModelCapabilities({
517
+ additionalSpeedTiers: [],
518
+ ...(cyber ? { availableAccessPrograms: { cyber } } : {}),
519
+ defaultReasoningEffort: "medium",
520
+ description: slug,
521
+ displayName: slug,
522
+ hidden: false,
523
+ id: slug,
524
+ isDefault: false,
525
+ model: slug,
526
+ supportedReasoningEfforts: [],
527
+ }),
528
+ });
529
+ const defaultPrograms = (snapshot: Partial<CodexAppServerProviderSnapshot>) =>
530
+ checkCodexProviderStatus(decodeCodexSettings({ customModels: ["my-model"] }), () =>
531
+ Effect.succeed(
532
+ makeCodexProbeSnapshot({
533
+ models: [
534
+ catalogModel("both", ["standard", "daybreakBlue"]),
535
+ catalogModel("daybreak-only", ["daybreakBlue"]),
536
+ catalogModel("plain"),
537
+ ],
538
+ ...snapshot,
539
+ }),
540
+ ),
541
+ ).pipe(
542
+ Effect.map((status) =>
543
+ Object.fromEntries(
544
+ status.models.map((model) => {
545
+ const descriptor = model.capabilities?.optionDescriptors?.find(
546
+ (option) => option.id === "cyberAccessProgram",
547
+ );
548
+ return [
549
+ model.slug,
550
+ descriptor?.type === "select"
551
+ ? (descriptor.currentValue ?? "no default")
552
+ : null,
553
+ ];
554
+ }),
555
+ ),
556
+ ),
557
+ );
558
+
559
+ assert.deepStrictEqual(yield* defaultPrograms({ daybreakEnabled: false }), {
560
+ both: "standard",
561
+ "daybreak-only": "daybreakBlue",
562
+ plain: null,
563
+ "my-model": null,
564
+ });
565
+ assert.deepStrictEqual(yield* defaultPrograms({ daybreakEnabled: true }), {
566
+ both: "daybreakBlue",
567
+ "daybreak-only": "daybreakBlue",
568
+ plain: null,
569
+ "my-model": null,
570
+ });
571
+ // An unread config keeps the choice but cannot know Codex's default.
572
+ assert.deepStrictEqual(yield* defaultPrograms({}), {
573
+ both: "no default",
574
+ "daybreak-only": "no default",
575
+ plain: null,
576
+ "my-model": null,
577
+ });
578
+ assert.deepStrictEqual(
579
+ yield* defaultPrograms({
580
+ account: { account: { type: "apiKey" }, requiresOpenaiAuth: false },
581
+ cyberAccessProgramsUnavailable: true,
582
+ }),
583
+ { both: null, "daybreak-only": null, plain: null, "my-model": null },
584
+ );
585
+ }),
586
+ );
587
+
588
it.effect("reads the version of a Codex CLI too old to run app-server (#20351)", () =>
589
Effect.gen(function* () {
590
if ((yield* HostProcess.Platform) === "win32") return;
docs/user/providers-codex.md
+9
@@ -100,6 +100,15 @@ in the thread on web, desktop, or mobile. Some tools offer access for one reques
100
the current session, or permanently. See [Permission modes](./permission-modes.md)
101
for command and file approvals.
102
103
+## Use Daybreak
104
+
105
+Models with cyber access programs show a Cyber Access option in the model
106
+options. It starts on Standard, or on Daybreak when `config.toml` in your Codex
107
+home sets `daybreak = true` or the model only runs under Daybreak. Your choice carries
108
+over to new threads. Custom models do not offer it. If Codex rejects a turn
109
+because your login lacks the program, switch Cyber Access back to Standard or
110
+sign in to Codex with an account that has it.
111
+
112
## Codex says I hit a usage limit
113
114
When Codex stops on a usage limit, the thread names the window that ran out and
packages/effect-codex-app-server/src/client.ts
+4
-2
@@ -86,12 +86,14 @@ type ServerNotificationHandler = (
86
payload: unknown,
87
) => Effect.Effect<void, CodexError.CodexAppServerError>;
88
89
-const V2TurnStartParamsWithCollaborationMode = CodexSchema.V2TurnStartParams.pipe(
89
+/** The generated `turn/start` schema omits these fields; this is what the wire accepts. */
90
+export const V2TurnStartParams = CodexSchema.V2TurnStartParams.pipe(
91
Schema.fieldsAssign({
92
collaborationMode: Schema.optionalKey(CodexSchema.ClientRequest__CollaborationMode),
93
additionalContext: Schema.optionalKey(
94
Schema.Record(Schema.String, CodexSchema.V2TurnStartParams__AdditionalContextEntry),
95
),
96
+ cyberAccessProgram: Schema.optionalKey(CodexSchema.V2TurnStartParams__CyberAccessProgram),
97
}),
98
);
99
@@ -131,7 +133,7 @@ export const make = Effect.fn("effect-codex-app-server/CodexAppServerClient.make
133
| Schema.Codec<CodexRpc.ClientRequestParamsByMethod[M], CodexRpc.ClientRequestParamsByMethod[M]>
134
| undefined =>
135
method === "turn/start"
134
- ? (V2TurnStartParamsWithCollaborationMode as never)
136
+ ? (V2TurnStartParams as never)
137
: (CodexRpc.CLIENT_REQUEST_PARAMS[method] as never);
138
139
const getClientRequestResponseSchema = <M extends CodexRpc.ClientRequestMethod>(