Open History to see the last commit
1import {
2 AcpRegistrySettings,
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 ACPRegistryIcon,
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;
44}
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("acpRegistry"),
81 label: "ACP",
82 icon: ACPRegistryIcon,
83 badgeLabel: "Early Access",
84 settingsSchema: AcpRegistrySettings,
85 },
86];
87
88export const PROVIDER_CLIENT_DEFINITION_BY_VALUE: Partial<
89 Record<ProviderDriverKind, ProviderClientDefinition>
90> = Object.fromEntries(
91 PROVIDER_CLIENT_DEFINITIONS.map((definition) => [definition.value, definition]),
92);
93
94export const DRIVER_OPTIONS = PROVIDER_CLIENT_DEFINITIONS;
95export const NATIVE_DRIVER_OPTIONS = PROVIDER_CLIENT_DEFINITIONS.filter(
96 (definition) => definition.value !== ProviderDriverKind.make("acpRegistry"),
97);
98export const DRIVER_OPTION_BY_VALUE = PROVIDER_CLIENT_DEFINITION_BY_VALUE;
99export type DriverOption = ProviderClientDefinition;
100
101/**
102 * Look up the driver metadata for an instance's `driver` field. Accepts
103 * Returns `undefined` for fork / unknown drivers so callers can decide how
104 * to render them — typically by falling back to a generic card.
105 */
106export function getDriverOption(driver: ProviderDriverKind | undefined): DriverOption | undefined {
107 if (driver === undefined) return undefined;
108 return PROVIDER_CLIENT_DEFINITION_BY_VALUE[driver];
109}