Open History to see the last commit
1import {
2 AntigravitySettings,
3 ClaudeSettings,
4 CodexSettings,
5 CursorSettings,
6 GrokSettings,
7 OpenCodeSettings,
8 PiSettings,
9 ProviderDriverKind,
10} from "@t3tools/contracts";
11import type * as Schema from "effect/Schema";
12import {
13 AntigravityIcon,
14 ClaudeAI,
15 CursorIcon,
16 GrokIcon,
17 type Icon,
18 OpenAI,
19 OpenCodeIcon,
20 PiAgentIcon,
21} from "../Icons";
22
23type ProviderSettingsSchema = {
24 readonly fields: Readonly<Record<string, Schema.Top>>;
25} & Schema.Top;
26
27/**
28 * Browser-safe provider definition. This is deliberately shaped like the
29 * future provider package client export: the core web app gets a schema with
30 * field annotations plus provider-level presentation metadata, then renders
31 * settings generically.
32 */
33export interface ProviderClientDefinition {
34 readonly value: ProviderDriverKind;
35 readonly label: string;
36 readonly icon: Icon;
37 readonly settingsSchema: ProviderSettingsSchema;
38 /**
39 * Optional short label rendered as a `variant="warning"` badge next to
40 * the instance title. Used to flag drivers that still ship under an
41 * early-access or preview gate — the flag is a property of the driver
42 * kind (not a specific instance), so every instance of that driver —
43 * built-in default or custom — advertises the same marker.
44 */
45 readonly badgeLabel?: string;
46}
47
48const PROVIDER_CLIENT_DEFINITIONS: readonly ProviderClientDefinition[] = [
49 {
50 value: ProviderDriverKind.make("codex"),
51 label: "Codex",
52 icon: OpenAI,
53 settingsSchema: CodexSettings,
54 },
55 {
56 value: ProviderDriverKind.make("claudeAgent"),
57 label: "Claude",
58 icon: ClaudeAI,
59 settingsSchema: ClaudeSettings,
60 },
61 {
62 value: ProviderDriverKind.make("cursor"),
63 label: "Cursor",
64 icon: CursorIcon,
65 badgeLabel: "Early Access",
66 settingsSchema: CursorSettings,
67 },
68 {
69 value: ProviderDriverKind.make("grok"),
70 label: "Grok",
71 icon: GrokIcon,
72 badgeLabel: "Early Access",
73 settingsSchema: GrokSettings,
74 },
75 {
76 value: ProviderDriverKind.make("opencode"),
77 label: "OpenCode",
78 icon: OpenCodeIcon,
79 settingsSchema: OpenCodeSettings,
80 },
81 {
82 value: ProviderDriverKind.make("antigravity"),
83 label: "Antigravity",
84 icon: AntigravityIcon,
85 settingsSchema: AntigravitySettings,
86 },
87 {
88 value: ProviderDriverKind.make("pi"),
89 label: "Pi",
90 icon: PiAgentIcon,
91 badgeLabel: "Early Access",
92 settingsSchema: PiSettings,
93 },
94];
95
96const PROVIDER_CLIENT_DEFINITION_BY_VALUE: Partial<
97 Record<ProviderDriverKind, ProviderClientDefinition>
98> = Object.fromEntries(
99 PROVIDER_CLIENT_DEFINITIONS.map((definition) => [definition.value, definition]),
100);
101
102export const DRIVER_OPTIONS = PROVIDER_CLIENT_DEFINITIONS;
103export const DRIVER_OPTION_BY_VALUE = PROVIDER_CLIENT_DEFINITION_BY_VALUE;
104export type DriverOption = ProviderClientDefinition;
105
106/**
107 * Look up the driver metadata for an instance's `driver` field. Accepts
108 * Returns `undefined` for fork / unknown drivers so callers can decide how
109 * to render them — typically by falling back to a generic card.
110 */
111export function getDriverOption(driver: ProviderDriverKind | undefined): DriverOption | undefined {
112 if (driver === undefined) return undefined;
113 return PROVIDER_CLIENT_DEFINITION_BY_VALUE[driver];
114}