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