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

CodexProvider.ts

697 lines22.5 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 { createModelCapabilities, readCustomModelEntries } from "@t3tools/shared/model";
29import { resolveSpawnCommand } from "@t3tools/shared/shell";
30import { codexAppServerArgs, resolveCodexLaunchArgs } from "./codexLaunchArgs.ts";
31import {
32 AUTH_PROBE_TIMEOUT_MS,
33 buildServerProvider,
34 COMPACT_SLASH_COMMAND,
35 type ServerProviderDraft,
36} from "../providerSnapshot.ts";
37import { expandHomePath } from "../../pathExpansion.ts";
38import { makeUnavailableUsageLimits } from "../providerUsageLimits.ts";
39import {
40 codexRateLimitsFailureMessage,
41 codexRateLimitsToLimits,
42 type CodexRateLimitSnapshot,
43 type CodexResetCreditsSummary,
44} from "./codexUsageLimits.ts";
45import packageJson from "../../../package.json" with { type: "json" };
46const isCodexAppServerSpawnError = Schema.is(CodexErrors.CodexAppServerSpawnError);
47const RATE_LIMITS_PROBE_TIMEOUT_MS = 3_000;
48​
49type CodexRateLimitsProbe =
50 | {
51 readonly snapshot: CodexRateLimitSnapshot;
52 readonly rateLimitsByLimitId?:
53 | Readonly<Record<string, CodexRateLimitSnapshot>>
54 | null
55 | undefined;
56 readonly resetCredits: CodexResetCreditsSummary | null | undefined;
57 }
58 | { readonly failure: string };
59​
60const CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER = "2 seconds" as const;
61​
62const CODEX_PRESENTATION = {
63 displayName: "Codex",
64 showInteractionModeToggle: true,
65} as const;
66​
67export interface CodexAppServerProviderSnapshot {
68 readonly account: CodexSchema.V2GetAccountResponse;
69 readonly rateLimits?: CodexRateLimitsProbe;
70 readonly version: string | undefined;
71 readonly models: ReadonlyArray<ServerProviderModel>;
72 readonly skills: ReadonlyArray<ServerProviderSkill>;
74​
75const REASONING_EFFORT_LABELS: Readonly<Record<string, string>> = {
76 none: "None",
77 minimal: "Minimal",
78 low: "Low",
79 medium: "Medium",
80 high: "High",
81 xhigh: "Extra High",
82 max: "Max",
83 ultra: "Ultra",
84};
85​
86const DEFAULT_SERVICE_TIER_ID = "default";
87​
88function reasoningEffortLabel(reasoningEffort: string): string {
89 return REASONING_EFFORT_LABELS[reasoningEffort] ?? reasoningEffort;
91​
92function codexAccountAuthLabel(account: CodexSchema.V2GetAccountResponse["account"]) {
93 if (!account) return undefined;
94 if (account.type === "apiKey") return "OpenAI API Key";
95 if (account.type === "amazonBedrock") return "Amazon Bedrock";
96 if (account.type !== "chatgpt") return undefined;
97 return codexPlanLabel(account.planType);
99​
100/** Shared with usage-limit sources, which report the same `planType` slugs. */
101export function codexPlanLabel(planType: string | null | undefined): string | undefined {
102 switch (planType) {
103 case "free":
104 return "ChatGPT Free Subscription";
105 case "go":
106 return "ChatGPT Go Subscription";
107 case "plus":
108 return "ChatGPT Plus Subscription";
109 case "pro":
110 return "ChatGPT Pro 20x Subscription";
111 case "prolite":
112 return "ChatGPT Pro 5x Subscription";
113 case "team":
114 return "ChatGPT Team Subscription";
115 case "self_serve_business_prolite":
116 case "self_serve_business_usage_based":
117 case "business":
118 return "ChatGPT Business Subscription";
119 case "ent26":
120 case "enterprise_cbp_automation":
121 case "enterprise_cbp_usage_based":
122 case "enterprise":
123 return "ChatGPT Enterprise Subscription";
124 case "edu":
125 case "edu_plus":
126 case "edu_pro":
127 return "ChatGPT Edu Subscription";
128 case "unknown":
129 return "ChatGPT Subscription";
130 default:
131 return undefined;
132 }
134​
135function codexAccountEmail(account: CodexSchema.V2GetAccountResponse["account"]) {
136 if (!account || account.type !== "chatgpt") return undefined;
137 return account.email;
139​
140export function mapCodexModelCapabilities(
141 model: CodexSchema.V2ModelListResponse__Model,
142): ModelCapabilities {
143 const reasoningOptions = model.supportedReasoningEfforts.map(({ reasoningEffort }) =>
144 reasoningEffort === model.defaultReasoningEffort
145 ? {
146 id: reasoningEffort,
147 label: reasoningEffortLabel(reasoningEffort),
148 isDefault: true,
149 }
150 : {
151 id: reasoningEffort,
152 label: reasoningEffortLabel(reasoningEffort),
153 },
154 );
155 const defaultReasoning = reasoningOptions.find((option) => option.isDefault)?.id;
156 const serviceTiers =
157 model.serviceTiers && model.serviceTiers.length > 0
158 ? model.serviceTiers
159 : (model.additionalSpeedTiers ?? []).map((id) => ({
160 id,
161 name: id === "fast" ? "Fast" : id,
162 description: "",
163 }));
164 const catalogDefaultServiceTier = serviceTiers.some(
165 (tier) => tier.id === model.defaultServiceTier,
166 )
167 ? model.defaultServiceTier
168 : null;
169 const defaultServiceTier = catalogDefaultServiceTier ?? DEFAULT_SERVICE_TIER_ID;
170 const optionDescriptors: ProviderOptionDescriptor[] = [];
171​
172 if (reasoningOptions.length > 0) {
173 optionDescriptors.push({
174 id: "reasoningEffort",
175 label: "Reasoning",
176 type: "select",
177 options: reasoningOptions,
178 ...(defaultReasoning ? { currentValue: defaultReasoning } : {}),
179 });
180 }
181 if (serviceTiers.length > 0) {
182 optionDescriptors.push({
183 id: "serviceTier",
184 label: "Service Tier",
185 type: "select",
186 options: [
187 {
188 id: DEFAULT_SERVICE_TIER_ID,
189 label: "Standard",
190 ...(defaultServiceTier === DEFAULT_SERVICE_TIER_ID ? { isDefault: true } : {}),
191 },
192 ...serviceTiers.map((tier) => ({
193 id: tier.id,
194 label: tier.name,
195 ...(tier.description ? { description: tier.description } : {}),
196 ...(defaultServiceTier === tier.id ? { isDefault: true } : {}),
197 })),
198 ],
199 currentValue: defaultServiceTier,
200 });
201 }
202​
203 return createModelCapabilities({
204 optionDescriptors,
205 });
207​
208const toDisplayName = (model: CodexSchema.V2ModelListResponse__Model): string => {
209 // Capitalize 'gpt' to 'GPT-' and capitalize any letter following a dash
210 return model.displayName
211 .replace(/^gpt/i, "GPT") // Handle start with 'gpt' or 'GPT'
212 .replace(/-([a-z])/g, (_, c) => "-" + c.toUpperCase());
213};
214​
215function parseCodexModelListResponse(
216 response: CodexSchema.V2ModelListResponse,
217): ReadonlyArray<ServerProviderModel> {
218 return response.data.map((model) => ({
219 slug: model.model,
220 name: toDisplayName(model),
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.find((slug) =>
235 models.some((model) => model.slug === slug && !model.isCustom),
236 );
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 : "Codex CLI (`codex`) was not found on PATH.",
626 },
627 });
628 }
629​
630 if (Option.isNone(probeResult.success)) {
631 return buildServerProvider({
632 presentation: CODEX_PRESENTATION,
633 enabled: codexSettings.enabled,
634 checkedAt,
635 models: emptyModels,
636 skills: [],
637 probe: {
638 installed: true,
639 version: null,
640 status: "error",
641 auth: { status: "unknown" },
642 message: "Timed out while checking Codex app-server provider status.",
643 },
644 });
645 }
646​
647 const snapshot = probeResult.success.value;
648 const accountStatus = accountProbeStatus(snapshot.account);
649 const usageLimits =
650 snapshot.account.account?.type === "apiKey"
651 ? makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" })
652 : snapshot.rateLimits === undefined || "failure" in snapshot.rateLimits
653 ? makeUnavailableUsageLimits({
654 checkedAt,
655 reason: "probeFailed",
656 ...(snapshot.rateLimits ? { message: snapshot.rateLimits.failure } : {}),
657 })
658 : codexRateLimitsToLimits({
659 snapshot: snapshot.rateLimits.snapshot,
660 rateLimitsByLimitId: snapshot.rateLimits.rateLimitsByLimitId,
661 resetCredits: snapshot.rateLimits.resetCredits,
662 checkedAt,
663 });
664​
665 return buildServerProvider({
666 presentation: CODEX_PRESENTATION,
667 enabled: codexSettings.enabled,
668 checkedAt,
669 models: snapshot.models,
670 skills: snapshot.skills,
671 slashCommands: [
672 COMPACT_SLASH_COMMAND,
673 {
674 name: "feedback",
675 description: "Send this thread and Codex logs to OpenAI",
676 input: { hint: "Describe the issue (optional)" },
677 },
678 ],
679 probe: {
680 installed: true,
681 version: snapshot.version ?? null,
682 status: accountStatus.status,
683 auth: accountStatus.auth,
684 ...(accountStatus.message ? { message: accountStatus.message } : {}),
685 usageLimits,
686 },
687 });
688});
689​
690// NOTE: the singleton `CodexProviderLive` Layer has been removed as part of
691// the per-instance-driver refactor. `CodexDriver.create()` builds a managed
692// snapshot per instance (each with its own `CodexSettings`) and hands the
693// resulting `ServerProviderShape` back as `ProviderInstance.snapshot`.
694//
695// The `makePendingCodexProvider` and `checkCodexProviderStatus` helpers are
696// re-exported for use by `CodexDriver`.
697export { makePendingCodexProvider };