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

providerDriverMeta.ts

105 lines3.0 KB

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