Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CodexProvider.ts

700 lines22.7 KB

1import * as DateTime from "effect/DateTime";
2import * as Duration from "effect/Duration";
3import * as Effect from "effect/Effect";
4import * as Layer from "effect/Layer";
5import * as Option from "effect/Option";
6import * as Result from "effect/Result";
7import * as Schema from "effect/Schema";
8import * as Scope from "effect/Scope";
9import * as Types from "effect/Types";
10import * as ChildProcess from "effect/unstable/process/ChildProcess";
11import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
12import * as CodexClient from "effect-codex-app-server/client";
13import * as CodexSchema from "effect-codex-app-server/schema";
14import * as CodexErrors from "effect-codex-app-server/errors";
15​
16import type {
17 CodexSettings,
18 CustomModelSetting,
19 ServerProvider,
20 ServerProviderState,
21 ModelCapabilities,
22 ProviderOptionDescriptor,
23 ServerProviderModel,
24 ServerProviderSkill,
25} from "@t3tools/contracts";
26import { PREFERRED_DEFAULT_CODEX_MODELS, ServerSettingsError } from "@t3tools/contracts";
27​
28import {
29 codexModelFamily,
30 createModelCapabilities,
31 formatCodexModelName,
32 readCustomModelEntries,
33} from "@t3tools/shared/model";
34import { resolveSpawnCommand } from "@t3tools/shared/shell";
35import { codexAppServerArgs, resolveCodexLaunchArgs } from "./codexLaunchArgs.ts";
36import {
37 AUTH_PROBE_TIMEOUT_MS,
38 buildServerProvider,
39 COMPACT_SLASH_COMMAND,
40 type ServerProviderDraft,
41} from "../providerSnapshot.ts";
42import { expandHomePath } from "../../pathExpansion.ts";
43import { makeUnavailableUsageLimits } from "../providerUsageLimits.ts";
44import {
45 codexRateLimitsFailureMessage,
46 codexRateLimitsToLimits,
47 type CodexRateLimitSnapshot,
48 type CodexResetCreditsSummary,
49} from "./codexUsageLimits.ts";
50import packageJson from "../../../package.json" with { type: "json" };
51const isCodexAppServerSpawnError = Schema.is(CodexErrors.CodexAppServerSpawnError);
52const RATE_LIMITS_PROBE_TIMEOUT_MS = 3_000;
53​
54type CodexRateLimitsProbe =
55 | {
56 readonly snapshot: CodexRateLimitSnapshot;
57 readonly rateLimitsByLimitId?:
58 | Readonly<Record<string, CodexRateLimitSnapshot>>
59 | null
60 | undefined;
61 readonly resetCredits: CodexResetCreditsSummary | null | undefined;
62 }
63 | { readonly failure: string };
64​
65const CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER = "2 seconds" as const;
66​
67const CODEX_PRESENTATION = {
68 displayName: "Codex",
69 showInteractionModeToggle: true,
70 reportsContextWindow: true,
71} as const;
72​
73export interface CodexAppServerProviderSnapshot {
74 readonly account: CodexSchema.V2GetAccountResponse;
75 readonly rateLimits?: CodexRateLimitsProbe;
76 readonly version: string | undefined;
77 readonly models: ReadonlyArray<ServerProviderModel>;
78 readonly skills: ReadonlyArray<ServerProviderSkill>;
80​
81const REASONING_EFFORT_LABELS: Readonly<Record<string, string>> = {
82 none: "None",
83 minimal: "Minimal",
84 low: "Low",
85 medium: "Medium",
86 high: "High",
87 xhigh: "Extra High",
88 max: "Max",
89 ultra: "Ultra",
90};
91​
92const DEFAULT_SERVICE_TIER_ID = "default";
93​
94function reasoningEffortLabel(reasoningEffort: string): string {
95 return REASONING_EFFORT_LABELS[reasoningEffort] ?? reasoningEffort;
97​
98function codexAccountAuthLabel(account: CodexSchema.V2GetAccountResponse["account"]) {
99 if (!account) return undefined;
100 if (account.type === "apiKey") return "OpenAI API Key";
101 if (account.type === "amazonBedrock") return "Amazon Bedrock";
102 if (account.type !== "chatgpt") return undefined;
103 return codexPlanLabel(account.planType);
105​
106/** Shared with usage-limit sources, which report the same `planType` slugs. */
107export function codexPlanLabel(planType: string | null | undefined): string | undefined {
108 switch (planType) {
109 case "free":
110 return "ChatGPT Free Subscription";
111 case "go":
112 return "ChatGPT Go Subscription";
113 case "plus":
114 return "ChatGPT Plus Subscription";
115 case "pro":
116 return "ChatGPT Pro 20x Subscription";
117 case "prolite":
118 return "ChatGPT Pro 5x Subscription";
119 case "team":
120 return "ChatGPT Team Subscription";
121 case "self_serve_business_prolite":
122 case "self_serve_business_usage_based":
123 case "business":
124 return "ChatGPT Business Subscription";
125 case "ent26":
126 case "enterprise_cbp_automation":
127 case "enterprise_cbp_usage_based":
128 case "enterprise":
129 return "ChatGPT Enterprise Subscription";
130 case "edu":
131 case "edu_plus":
132 case "edu_pro":
133 return "ChatGPT Edu Subscription";
134 case "unknown":
135 return "ChatGPT Subscription";
136 default:
137 return undefined;
138 }
140​
141function codexAccountEmail(account: CodexSchema.V2GetAccountResponse["account"]) {
142 if (!account || account.type !== "chatgpt") return undefined;
143 return account.email;
145​
146export function mapCodexModelCapabilities(
147 model: CodexSchema.V2ModelListResponse__Model,
148): ModelCapabilities {
149 const reasoningOptions = model.supportedReasoningEfforts.map(({ reasoningEffort }) =>
150 reasoningEffort ===
151 (codexModelFamily(model.model) === "gpt-6-astra" ? "medium" : model.defaultReasoningEffort)
152 ? {
153 id: reasoningEffort,
154 label: reasoningEffortLabel(reasoningEffort),
155 isDefault: true,
156 }
157 : {
158 id: reasoningEffort,
159 label: reasoningEffortLabel(reasoningEffort),
160 },
161 );
162 const defaultReasoning = reasoningOptions.find((option) => option.isDefault)?.id;
163 const serviceTiers =
164 model.serviceTiers && model.serviceTiers.length > 0
165 ? model.serviceTiers
166 : (model.additionalSpeedTiers ?? []).map((id) => ({
167 id,
168 name: id === "fast" ? "Fast" : id,
169 description: "",
170 }));
171 const catalogDefaultServiceTier = serviceTiers.some(
172 (tier) => tier.id === model.defaultServiceTier,
173 )
174 ? model.defaultServiceTier
175 : null;
176 const defaultServiceTier = catalogDefaultServiceTier ?? DEFAULT_SERVICE_TIER_ID;
177 const optionDescriptors: ProviderOptionDescriptor[] = [];
178​
179 if (reasoningOptions.length > 0) {
180 optionDescriptors.push({
181 id: "reasoningEffort",
182 label: "Reasoning",
183 type: "select",
184 options: reasoningOptions,
185 ...(defaultReasoning ? { currentValue: defaultReasoning } : {}),
186 });
187 }
188 if (serviceTiers.length > 0) {
189 optionDescriptors.push({
190 id: "serviceTier",
191 label: "Service Tier",
192 type: "select",
193 options: [
194 {
195 id: DEFAULT_SERVICE_TIER_ID,
196 label: "Standard",
197 ...(defaultServiceTier === DEFAULT_SERVICE_TIER_ID ? { isDefault: true } : {}),
198 },
199 ...serviceTiers.map((tier) => ({
200 id: tier.id,
201 label: tier.name,
202 ...(tier.description ? { description: tier.description } : {}),
203 ...(defaultServiceTier === tier.id ? { isDefault: true } : {}),
204 })),
205 ],
206 currentValue: defaultServiceTier,
207 });
208 }
209​
210 return createModelCapabilities({
211 optionDescriptors,
212 });
214​
215function parseCodexModelListResponse(
216 response: CodexSchema.V2ModelListResponse,
217): ReadonlyArray<ServerProviderModel> {
218 return response.data.map((model) => ({
219 slug: model.model,
220 name: formatCodexModelName(model.displayName),
221 isCustom: false,
222 ...(model.isDefault ? { isDefault: true } : {}),
223 capabilities: mapCodexModelCapabilities(model),
224 }));
226​
227/**
228 * Prefer our own default-model ranking when one of the preferred slugs is in
229 * the live catalog; otherwise keep whatever Codex itself flagged as default.
230 */
231export function applyPreferredCodexDefaultModel(
232 models: ReadonlyArray<ServerProviderModel>,
233): ReadonlyArray<ServerProviderModel> {
234 const preferredSlug = PREFERRED_DEFAULT_CODEX_MODELS.flatMap((slug) =>
235 models.filter((model) => !model.isCustom && codexModelFamily(model.slug) === slug),
236 )[0]?.slug;
237 if (!preferredSlug) {
238 return models;
239 }
240 return models.map((model) => {
241 if (model.slug === preferredSlug) {
242 return model.isDefault ? model : { ...model, isDefault: true };
243 }
244 if (!model.isDefault) {
245 return model;
246 }
247 const { isDefault: _isDefault, ...rest } = model;
248 return rest;
249 });
251​
252/**
253 * Codex has no static default capability set, so a bare custom slug borrows
254 * the first built-in's descriptors; an entry with its own capabilities keeps
255 * them.
256 */
257function appendCustomCodexModels(
258 models: ReadonlyArray<ServerProviderModel>,
259 customModels: ReadonlyArray<CustomModelSetting>,
260): ReadonlyArray<ServerProviderModel> {
261 if (customModels.length === 0) {
262 return models;
263 }
264​
265 const seen = new Set(models.map((model) => model.slug));
266 const fallbackCapabilities = models.find((model) => model.capabilities)?.capabilities ?? null;
267 const customEntries: ServerProviderModel[] = [];
268 for (const entry of readCustomModelEntries(customModels)) {
269 if (seen.has(entry.slug)) {
270 continue;
271 }
272 seen.add(entry.slug);
273 customEntries.push({
274 slug: entry.slug,
275 name: entry.name,
276 isCustom: true,
277 capabilities: entry.capabilities ?? fallbackCapabilities,
278 });
279 }
280 return customEntries.length === 0 ? models : [...models, ...customEntries];
282​
283function parseCodexSkillsListResponse(
284 response: CodexSchema.V2SkillsListResponse,
285 cwd: string,
286): ReadonlyArray<ServerProviderSkill> {
287 const matchingEntry = response.data.find((entry) => entry.cwd === cwd);
288 const skills = matchingEntry
289 ? matchingEntry.skills
290 : response.data.flatMap((entry) => entry.skills);
291​
292 return skills.map((skill) => {
293 const shortDescription =
294 skill.shortDescription ?? skill.interface?.shortDescription ?? undefined;
295​
296 const parsedSkill: Types.Mutable<ServerProviderSkill> = {
297 name: skill.name,
298 path: skill.path,
299 enabled: skill.enabled,
300 };
301​
302 if (skill.description) {
303 parsedSkill.description = skill.description;
304 }
305 if (skill.scope) {
306 parsedSkill.scope = skill.scope;
307 }
308 if (skill.interface?.displayName) {
309 parsedSkill.displayName = skill.interface.displayName;
310 }
311 if (shortDescription) {
312 parsedSkill.shortDescription = shortDescription;
313 }
314​
315 return parsedSkill;
316 });
318​
319const requestAllCodexModels = Effect.fn("requestAllCodexModels")(function* (
320 client: CodexClient.CodexAppServerClient["Service"],
321) {
322 const models: ServerProviderModel[] = [];
323 let cursor: string | null | undefined = undefined;
324​
325 do {
326 const response: CodexSchema.V2ModelListResponse = yield* client.request(
327 "model/list",
328 cursor ? { cursor } : {},
329 );
330 models.push(...parseCodexModelListResponse(response));
331 cursor = response.nextCursor;
332 } while (cursor);
333​
334 return models;
335});
336​
337export function buildCodexInitializeParams(): CodexSchema.V1InitializeParams {
338 return {
339 clientInfo: {
340 name: "t3code_desktop",
341 title: "T3 Code Desktop",
342 version: packageJson.version,
343 },
344 capabilities: {
345 experimentalApi: true,
346 },
347 };
349​
350/**
351 * Spawns a short-lived `codex app-server`, runs the initialize handshake, and
352 * hands the caller a connected client. Scoped: the process is killed when
353 * the caller's scope closes. Shared by the status probe, the skills probe,
354 * and account-level requests such as reset-credit redemption.
355 */
356export const withCodexAppServerClient = Effect.fn("withCodexAppServerClient")(function* (input: {
357 readonly binaryPath: string;
358 readonly homePath?: string | undefined;
359 readonly launchArgs?: string | undefined;
360 readonly cwd: string;
361 readonly environment?: NodeJS.ProcessEnv | undefined;
362}) {
363 // `~` is not shell-expanded when env vars are set via `child_process.spawn`,
364 // so `CODEX_HOME=~/.codex_work` would reach codex verbatim and trip
365 // "CODEX_HOME points to '~/.codex_work', but that path does not exist".
366 // Expand here for parity with `CodexTextGeneration`/`CodexSessionRuntime`.
367 const resolvedHomePath = input.homePath ? expandHomePath(input.homePath) : undefined;
368 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
369 const environment = {
370 ...input.environment,
371 ...(resolvedHomePath ? { CODEX_HOME: resolvedHomePath } : {}),
372 };
373 const spawnCommand = yield* resolveSpawnCommand(
374 input.binaryPath,
375 codexAppServerArgs(input.launchArgs),
376 { env: environment, extendEnv: true },
377 );
378 const child = yield* spawner
379 .spawn(
380 ChildProcess.make(spawnCommand.command, spawnCommand.args, {
381 cwd: input.cwd,
382 env: environment,
383 extendEnv: true,
384 forceKillAfter: CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER,
385 shell: spawnCommand.shell,
386 }),
387 )
388 .pipe(
389 Effect.mapError(
390 (cause) =>
391 new CodexErrors.CodexAppServerSpawnError({
392 command: `${input.binaryPath} app-server`,
393 cause,
394 }),
395 ),
396 );
397 const clientContext = yield* Layer.build(CodexClient.layerChildProcess(child));
398 const client = yield* Effect.service(CodexClient.CodexAppServerClient).pipe(
399 Effect.provide(clientContext),
400 );
401 const initialize = yield* client.request("initialize", buildCodexInitializeParams());
402 yield* client.notify("initialized", undefined);
403 return { client, initialize };
404});
405​
406const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(function* (input: {
407 readonly binaryPath: string;
408 readonly homePath?: string;
409 readonly launchArgs?: string;
410 readonly cwd: string;
411 readonly customModels?: ReadonlyArray<CustomModelSetting>;
412 readonly environment?: NodeJS.ProcessEnv;
413}) {
414 const { client, initialize } = yield* withCodexAppServerClient(input);
415​
416 // Extract the version string after the first '/' in userAgent, up to the next space or the end
417 const versionMatch = initialize.userAgent.match(/\/([^\s]+)/);
418 const version = versionMatch ? versionMatch[1] : undefined;
419​
420 const accountResponse = yield* client.request("account/read", {});
421 if (!accountResponse.account && accountResponse.requiresOpenaiAuth) {
422 return {
423 account: accountResponse,
424 version,
425 models: appendCustomCodexModels([], input.customModels ?? []),
426 skills: [],
427 } satisfies CodexAppServerProviderSnapshot;
428 }
429​
430 const [skillsResponse, models, rateLimits] = yield* Effect.all(
431 [
432 client.request("skills/list", {
433 cwds: [input.cwd],
434 }),
435 requestAllCodexModels(client),
436 // Usage is an enrichment: a failure or a slow answer degrades to "no
437 // usage this probe" rather than costing the account and models.
438 client.request("account/rateLimits/read", undefined).pipe(
439 Effect.map((response): CodexRateLimitsProbe => ({
440 snapshot: response.rateLimits,
441 rateLimitsByLimitId: response.rateLimitsByLimitId,
442 resetCredits: response.rateLimitResetCredits,
443 })),
444 Effect.timeoutOption(Duration.millis(RATE_LIMITS_PROBE_TIMEOUT_MS)),
445 Effect.map(
446 Option.getOrElse((): CodexRateLimitsProbe => ({
447 failure: "Codex did not answer the usage request.",
448 })),
449 ),
450 Effect.catch((error) =>
451 Effect.logDebug("Codex rate-limit read failed.", { cause: error }).pipe(
452 Effect.as<CodexRateLimitsProbe>({ failure: codexRateLimitsFailureMessage(error) }),
453 ),
454 ),
455 ),
456 ],
457 { concurrency: "unbounded" },
458 );
459​
460 return {
461 account: accountResponse,
462 rateLimits,
463 version,
464 models: applyPreferredCodexDefaultModel(
465 appendCustomCodexModels(models, input.customModels ?? []),
466 ),
467 skills: parseCodexSkillsListResponse(skillsResponse, input.cwd),
468 } satisfies CodexAppServerProviderSnapshot;
469});
470​
471export const probeCodexSkillsForCwd = Effect.fn("probeCodexSkillsForCwd")(function* (input: {
472 readonly binaryPath: string;
473 readonly homePath?: string;
474 readonly launchArgs?: string;
475 readonly cwd: string;
476 readonly environment?: NodeJS.ProcessEnv;
477}) {
478 const { client } = yield* withCodexAppServerClient(input);
479 const skillsResponse = yield* client.request("skills/list", { cwds: [input.cwd] });
480 return parseCodexSkillsListResponse(skillsResponse, input.cwd);
481});
482​
483const emptyCodexModelsFromSettings = (codexSettings: CodexSettings): ServerProvider["models"] =>
484 appendCustomCodexModels([], codexSettings.customModels);
485​
486const makePendingCodexProvider = (
487 codexSettings: CodexSettings,
488): Effect.Effect<ServerProviderDraft> =>
489 Effect.gen(function* () {
490 const checkedAt = yield* Effect.map(DateTime.now, DateTime.formatIso);
491 const models = emptyCodexModelsFromSettings(codexSettings);
492​
493 if (!codexSettings.enabled) {
494 return buildServerProvider({
495 presentation: CODEX_PRESENTATION,
496 enabled: false,
497 checkedAt,
498 models,
499 skills: [],
500 probe: {
501 installed: false,
502 version: null,
503 status: "warning",
504 auth: { status: "unknown" },
505 message: "Codex is disabled in T3 Code settings.",
506 },
507 });
508 }
509​
510 return buildServerProvider({
511 presentation: CODEX_PRESENTATION,
512 enabled: true,
513 checkedAt,
514 models,
515 skills: [],
516 probe: {
517 installed: false,
518 version: null,
519 status: "warning",
520 auth: { status: "unknown" },
521 message: "Codex provider status has not been checked in this session yet.",
522 },
523 });
524 });
525​
526function accountProbeStatus(account: CodexAppServerProviderSnapshot["account"]): {
527 readonly status: Exclude<ServerProviderState, "disabled">;
528 readonly auth: ServerProvider["auth"];
529 readonly message?: string;
530} {
531 const authLabel = codexAccountAuthLabel(account.account);
532 const authEmail = codexAccountEmail(account.account);
533 const auth = {
534 status: account.account ? ("authenticated" as const) : ("unknown" as const),
535 ...(account.account?.type ? { type: account.account?.type } : {}),
536 ...(authLabel ? { label: authLabel } : {}),
537 ...(authEmail ? { email: authEmail } : {}),
538 } satisfies ServerProvider["auth"];
539​
540 if (account.account) {
541 return { status: "ready", auth };
542 }
543​
544 if (account.requiresOpenaiAuth) {
545 return {
546 status: "error",
547 auth: { status: "unauthenticated" },
548 message: "Codex CLI is not authenticated. Run `codex login` and try again.",
549 };
550 }
551​
552 return { status: "ready", auth };
554​
555export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(function* (
556 codexSettings: CodexSettings,
557 probe: (input: {
558 readonly binaryPath: string;
559 readonly homePath?: string;
560 readonly launchArgs?: string;
561 readonly cwd: string;
562 readonly customModels: ReadonlyArray<CustomModelSetting>;
563 readonly environment?: NodeJS.ProcessEnv;
564 }) => Effect.Effect<
565 CodexAppServerProviderSnapshot,
566 CodexErrors.CodexAppServerError,
567 ChildProcessSpawner.ChildProcessSpawner | Scope.Scope
568 > = probeCodexAppServerProvider,
569 environment?: NodeJS.ProcessEnv,
570): Effect.fn.Return<
571 ServerProviderDraft,
572 ServerSettingsError,
573 ChildProcessSpawner.ChildProcessSpawner
574> {
575 const resolvedEnvironment = environment ?? process.env;
576 const checkedAt = DateTime.formatIso(yield* DateTime.now);
577 const emptyModels = emptyCodexModelsFromSettings(codexSettings);
578​
579 if (!codexSettings.enabled) {
580 return buildServerProvider({
581 presentation: CODEX_PRESENTATION,
582 enabled: false,
583 checkedAt,
584 models: emptyModels,
585 skills: [],
586 probe: {
587 installed: false,
588 version: null,
589 status: "warning",
590 auth: { status: "unknown" },
591 message: "Codex is disabled in T3 Code settings.",
592 },
593 });
594 }
595​
596 const probeResult = yield* probe({
597 binaryPath: codexSettings.binaryPath,
598 homePath: codexSettings.homePath,
599 launchArgs: resolveCodexLaunchArgs(codexSettings.launchArgs, resolvedEnvironment),
600 cwd: process.cwd(),
601 customModels: codexSettings.customModels,
602 environment: resolvedEnvironment,
603 }).pipe(
604 Effect.scoped,
605 Effect.timeoutOption(Duration.millis(AUTH_PROBE_TIMEOUT_MS)),
606 Effect.result,
607 );
608​
609 if (Result.isFailure(probeResult)) {
610 const error = probeResult.failure;
611 const installed = !isCodexAppServerSpawnError(error);
612 return buildServerProvider({
613 presentation: CODEX_PRESENTATION,
614 enabled: codexSettings.enabled,
615 checkedAt,
616 models: emptyModels,
617 skills: [],
618 probe: {
619 installed,
620 version: null,
621 status: "error",
622 auth: { status: "unknown" },
623 message: installed
624 ? `Codex app-server provider probe failed: ${error.message}.`
625 : `Could not start Codex CLI (\`${codexSettings.binaryPath}\`). Check Settings → Providers → Codex → Binary path on the server.` +
626 (codexSettings.binaryPath === "codex"
627 ? " Installing ChatGPT or Codex desktop may not add codex to PATH."
628 : " Make sure the configured executable exists and can be run."),
629 },
630 });
631 }
632​
633 if (Option.isNone(probeResult.success)) {
634 return buildServerProvider({
635 presentation: CODEX_PRESENTATION,
636 enabled: codexSettings.enabled,
637 checkedAt,
638 models: emptyModels,
639 skills: [],
640 probe: {
641 installed: true,
642 version: null,
643 status: "error",
644 auth: { status: "unknown" },
645 message: "Timed out while checking Codex app-server provider status.",
646 },
647 });
648 }
649​
650 const snapshot = probeResult.success.value;
651 const accountStatus = accountProbeStatus(snapshot.account);
652 const usageLimits =
653 snapshot.account.account?.type === "apiKey"
654 ? makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" })
655 : snapshot.rateLimits === undefined || "failure" in snapshot.rateLimits
656 ? makeUnavailableUsageLimits({
657 checkedAt,
658 reason: "probeFailed",
659 ...(snapshot.rateLimits ? { message: snapshot.rateLimits.failure } : {}),
660 })
661 : codexRateLimitsToLimits({
662 snapshot: snapshot.rateLimits.snapshot,
663 rateLimitsByLimitId: snapshot.rateLimits.rateLimitsByLimitId,
664 resetCredits: snapshot.rateLimits.resetCredits,
665 checkedAt,
666 });
667​
668 return buildServerProvider({
669 presentation: CODEX_PRESENTATION,
670 enabled: codexSettings.enabled,
671 checkedAt,
672 models: snapshot.models,
673 skills: snapshot.skills,
674 slashCommands: [
675 COMPACT_SLASH_COMMAND,
676 {
677 name: "feedback",
678 description: "Send this thread and Codex logs to OpenAI",
679 input: { hint: "Describe the issue (optional)" },
680 },
681 ],
682 probe: {
683 installed: true,
684 version: snapshot.version ?? null,
685 status: accountStatus.status,
686 auth: accountStatus.auth,
687 ...(accountStatus.message ? { message: accountStatus.message } : {}),
688 usageLimits,
689 },
690 });
691});
692​
693// NOTE: the singleton `CodexProviderLive` Layer has been removed as part of
694// the per-instance-driver refactor. `CodexDriver.create()` builds a managed
695// snapshot per instance (each with its own `CodexSettings`) and hands the
696// resulting `ServerProviderShape` back as `ProviderInstance.snapshot`.
697//
698// The `makePendingCodexProvider` and `checkCodexProviderStatus` helpers are
699// re-exported for use by `CodexDriver`.
700export { makePendingCodexProvider };