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