diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx index 049cd28889..6c63791ae4 100644 --- a/apps/mobile/src/Stack.tsx +++ b/apps/mobile/src/Stack.tsx @@ -62,6 +62,7 @@ import { SettingsOpenSourceLicensesRouteScreen, } from "./features/settings/SettingsOpenSourceLicensesRouteScreen"; import { SettingsProjectGroupingRouteScreen } from "./features/settings/SettingsProjectGroupingRouteScreen"; +import { SettingsProvidersRouteScreen } from "./features/settings/SettingsProvidersRouteScreen"; import { UsageLimitAccountScreen } from "./features/usage/UsageLimitsPooled"; import { UsageRouteScreen } from "./features/usage/UsageRouteScreen"; import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen"; @@ -164,6 +165,13 @@ const SettingsContentStack = createNativeStackNavigator({ title: "Environments", }, }), + SettingsProviders: createNativeStackScreen({ + screen: SettingsProvidersRouteScreen, + linking: "providers", + options: { + title: "Providers", + }, + }), SettingsEnvironmentNew: createNativeStackScreen({ screen: ConnectionsNewRouteScreen, linking: "environment-new", diff --git a/apps/mobile/src/components/ProviderIcon.tsx b/apps/mobile/src/components/ProviderIcon.tsx index 374738d0ae..ba9b145cfd 100644 --- a/apps/mobile/src/components/ProviderIcon.tsx +++ b/apps/mobile/src/components/ProviderIcon.tsx @@ -53,6 +53,28 @@ export function ProviderIcon(props: ProviderIconProps) { ); } + if (props.provider === "hermes") { + return ( + + + + + + + + + ); + } + if (props.provider === "cursor") { return ( diff --git a/apps/mobile/src/features/settings/SettingsProvidersRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProvidersRouteScreen.tsx new file mode 100644 index 0000000000..6d0ec2d9de --- /dev/null +++ b/apps/mobile/src/features/settings/SettingsProvidersRouteScreen.tsx @@ -0,0 +1,560 @@ +import { useNavigation } from "@react-navigation/native"; +import { + PROVIDER_DISPLAY_NAMES, + ProviderInstanceId, + resolveProviderInstanceEnabled, + type EnvironmentId, + type ProviderInstanceConfig, + type ServerSettingsPatch, +} from "@t3tools/contracts"; +import { useCallback, useMemo, useState } from "react"; +import { ActivityIndicator, Alert, Platform, Pressable, ScrollView, View } from "react-native"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; + +import { + isAtomCommandInterrupted, + squashAtomCommandFailure, +} from "@t3tools/client-runtime/state/runtime"; +import { AndroidScreenHeader } from "../../components/AndroidScreenHeader"; +import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText"; +import { ProviderIcon } from "../../components/ProviderIcon"; +import { SymbolView } from "../../components/AppSymbol"; +import { ThemedSwitch } from "../../components/ThemedSwitch"; +import { NativeStackScreenOptions } from "../../native/StackHeader"; +import { useEnvironments } from "../../state/environments"; +import { serverEnvironment } from "../../state/server"; +import { useAtomCommand } from "../../state/use-atom-command"; +import { SettingsSection } from "./components/SettingsSection"; +import { + addProviderCustomModel, + buildMobileProviderInstancePatch, + createHermesProviderInstance, + deriveMobileProviderSettingsRows, + HERMES_DRIVER_KIND, + readProviderConfigString, + readProviderCustomModels, + readProviderEnvironmentVariable, + removeProviderCustomModel, + updateProviderConfigString, + updateProviderEnvironmentVariable, + type MobileProviderSettingsRow, +} from "./mobile-provider-settings"; + +function providerLabel(row: MobileProviderSettingsRow): string { + return ( + row.instance.displayName?.trim() || + PROVIDER_DISPLAY_NAMES[row.instance.driver] || + String(row.instanceId) + ); +} + +function providerStatus(row: MobileProviderSettingsRow): string { + if (!resolveProviderInstanceEnabled(row.instance)) return "Disabled"; + const provider = row.liveProvider; + if (!provider) return "Waiting for server"; + if (provider.status === "ready") { + const count = provider.models.length; + return `${count} advertised model${count === 1 ? "" : "s"}`; + } + return provider.status === "error" ? "Needs attention" : "Checking availability"; +} + +function CommittedTextInput(props: { + readonly label: string; + readonly value: string; + readonly placeholder: string; + readonly disabled: boolean; + readonly onCommit: (value: string) => void; +}) { + const commit = (value: string) => { + if (value.trim() !== props.value.trim()) props.onCommit(value); + }; + return ( + + {props.label} + commit(event.nativeEvent.text)} + placeholder={props.placeholder} + returnKeyType="done" + /> + + ); +} + +function SmallAction(props: { + readonly label: string; + readonly destructive?: boolean; + readonly disabled?: boolean; + readonly onPress: () => void; +}) { + return ( + + + {props.label} + + + ); +} + +function ProviderCard(props: { + readonly row: MobileProviderSettingsRow; + readonly saving: boolean; + readonly onCommit: (instance: ProviderInstanceConfig) => void; + readonly onDelete: () => void; +}) { + const { row } = props; + const enabled = resolveProviderInstanceEnabled(row.instance); + const customModels = readProviderCustomModels(row.instance); + const [modelDraft, setModelDraft] = useState(""); + const [modelError, setModelError] = useState(null); + const isHermes = row.instance.driver === HERMES_DRIVER_KIND; + const customModelsSupported = row.instance.driver !== "antigravity"; + + const addModel = () => { + const result = addProviderCustomModel(row.instance, modelDraft); + if (!result.ok) { + setModelError(result.message); + return; + } + setModelDraft(""); + setModelError(null); + props.onCommit(result.instance); + }; + + return ( + + + + + + {providerLabel(row)} + + {providerStatus(row)} + + {props.saving ? ( + + ) : ( + props.onCommit({ ...row.instance, enabled: value })} + value={enabled} + /> + )} + + + {isHermes ? ( + + + props.onCommit(updateProviderConfigString(row.instance, "binaryPath", value)) + } + /> + + props.onCommit(updateProviderEnvironmentVariable(row.instance, "HERMES_HOME", value)) + } + /> + + Hermes runs on the selected T3 environment. Install it and run `hermes setup` on that + machine first. + + + ) : null} + + {customModelsSupported ? ( + + Custom models + {customModels.map((model) => ( + + + {model.slug} + + props.onCommit(removeProviderCustomModel(row.instance, model.slug))} + className="p-1 active:opacity-60" + > + + + + ))} + + { + setModelDraft(value); + setModelError(null); + }} + onSubmitEditing={addModel} + placeholder="provider/model-id" + returnKeyType="done" + value={modelDraft} + /> + + + {modelError ? {modelError} : null} + + Add a model ID that the provider accepts but did not advertise. It will appear in the + thread model picker after the server refreshes. + + + ) : null} + + {!row.isDefault ? ( + + + + ) : null} + + ); +} + +function AddHermesForm(props: { + readonly saving: boolean; + readonly onAdd: (input: { + readonly label: string; + readonly binaryPath: string; + readonly hermesHome: string; + }) => Promise; + readonly onCancel: () => void; +}) { + const [label, setLabel] = useState(""); + const [binaryPath, setBinaryPath] = useState(""); + const [hermesHome, setHermesHome] = useState(""); + return ( + + Add Hermes instance + + + + + + void props.onAdd({ label, binaryPath, hermesHome })} + /> + + + ); +} + +export function SettingsProvidersRouteScreen() { + const navigation = useNavigation(); + const insets = useSafeAreaInsets(); + const { environments } = useEnvironments(); + const configurableEnvironments = useMemo( + () => environments.filter((environment) => environment.serverConfig !== null), + [environments], + ); + const [selectedEnvironmentId, setSelectedEnvironmentId] = useState(null); + const [savingInstanceId, setSavingInstanceId] = useState(null); + const [showAddHermes, setShowAddHermes] = useState(false); + const updateSettings = useAtomCommand(serverEnvironment.updateSettings, { + label: "provider settings update", + reportFailure: false, + }); + const refreshProviders = useAtomCommand(serverEnvironment.refreshProviders, { + label: "provider refresh", + reportFailure: false, + }); + + const selectedEnvironment = + configurableEnvironments.find( + (environment) => environment.environmentId === selectedEnvironmentId, + ) ?? + configurableEnvironments[0] ?? + null; + + const serverConfig = selectedEnvironment?.serverConfig ?? null; + const rows = useMemo( + () => + serverConfig + ? deriveMobileProviderSettingsRows(serverConfig.settings, serverConfig.providers) + : [], + [serverConfig], + ); + + const commitPatch = useCallback( + async (patch: ServerSettingsPatch, savingId: ProviderInstanceId): Promise => { + if (!selectedEnvironment) return false; + setSavingInstanceId(savingId); + const result = await updateSettings({ + environmentId: selectedEnvironment.environmentId, + input: { patch }, + }); + setSavingInstanceId(null); + if (result._tag === "Failure") { + if (!isAtomCommandInterrupted(result)) { + const error = squashAtomCommandFailure(result); + Alert.alert( + "Could not update provider", + error instanceof Error ? error.message : "The T3 server rejected the settings change.", + ); + } + return false; + } + void refreshProviders({ + environmentId: selectedEnvironment.environmentId, + input: { refreshModels: true }, + }); + return true; + }, + [refreshProviders, selectedEnvironment, updateSettings], + ); + + const commitInstance = useCallback( + (row: MobileProviderSettingsRow, instance: ProviderInstanceConfig) => { + if (!serverConfig) return; + void commitPatch( + buildMobileProviderInstancePatch({ settings: serverConfig.settings, row, instance }), + row.instanceId, + ); + }, + [commitPatch, serverConfig], + ); + + const deleteInstance = useCallback( + (row: MobileProviderSettingsRow) => { + if (!serverConfig || row.isDefault) return; + Alert.alert( + "Remove provider instance?", + `${providerLabel(row)} will no longer be available.`, + [ + { text: "Cancel", style: "cancel" }, + { + text: "Remove", + style: "destructive", + onPress: () => { + const providerInstances = { ...serverConfig.settings.providerInstances }; + delete providerInstances[row.instanceId]; + void commitPatch({ providerInstances }, row.instanceId); + }, + }, + ], + ); + }, + [commitPatch, serverConfig], + ); + + const addHermes = useCallback( + async (input: { + readonly label: string; + readonly binaryPath: string; + readonly hermesHome: string; + }): Promise => { + if (!serverConfig) return false; + const created = createHermesProviderInstance({ settings: serverConfig.settings, ...input }); + const added = await commitPatch( + { + providerInstances: { + ...serverConfig.settings.providerInstances, + [created.instanceId]: created.instance, + }, + }, + created.instanceId, + ); + if (added) setShowAddHermes(false); + return added; + }, + [commitPatch, serverConfig], + ); + + return ( + + {Platform.OS === "android" ? ( + <> + + navigation.goBack()} /> + + ) : null} + + {configurableEnvironments.length > 1 ? ( + + {configurableEnvironments.map((environment, index) => ( + setSelectedEnvironmentId(environment.environmentId)} + className={ + index === 0 + ? "flex-row items-center gap-3 p-4" + : "flex-row items-center gap-3 border-t border-border-subtle p-4" + } + > + + {environment.label} + + {environment.environmentId === selectedEnvironment?.environmentId ? ( + + ) : null} + + ))} + + ) : null} + + {selectedEnvironment ? ( + + + Configuring {selectedEnvironment.label} + + + Provider processes run on this environment's machine. Changes made here apply to web, + desktop, and mobile clients connected to it. + + + ) : null} + + {serverConfig ? ( + <> + + + + Add another Hermes instance + + Use a separate binary or HERMES_HOME profile. + + + setShowAddHermes((visible) => !visible)} + /> + + {showAddHermes ? ( + + setShowAddHermes(false)} + /> + + ) : null} + + + + {rows.map((row) => ( + + commitInstance(row, instance)} + onDelete={() => deleteInstance(row)} + /> + + ))} + + + ) : ( + + + + + Connect a T3 environment before configuring its providers. + + + + )} + + + ); +} diff --git a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx index d343f2dc88..7768909150 100644 --- a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx @@ -132,6 +132,7 @@ function LocalSettingsRouteScreen() { value={`${environmentCount}`} target="SettingsEnvironments" /> + @@ -514,6 +515,7 @@ function ConfiguredSettingsRouteScreen() { value={`${environmentCount}`} target="SettingsEnvironments" /> + { + it("surfaces the default Hermes provider even before a live probe appears", () => { + const rows = deriveMobileProviderSettingsRows(DEFAULT_SERVER_SETTINGS, []); + expect(rows[0]?.instanceId).toBe(HERMES_DEFAULT_INSTANCE_ID); + expect(rows[0]?.instance.enabled).toBe(false); + }); + + it("resolves a live Hermes provider through its legacy settings", () => { + const settings = { + ...DEFAULT_SERVER_SETTINGS, + providers: { + ...DEFAULT_SERVER_SETTINGS.providers, + hermes: { + ...DEFAULT_SERVER_SETTINGS.providers.hermes, + enabled: true, + binaryPath: "/opt/hermes/bin/hermes", + }, + }, + }; + const row = deriveMobileProviderSettingsRows(settings, [hermesProvider])[0]; + expect(row?.instance).toMatchObject({ + driver: "hermes", + enabled: true, + config: { binaryPath: "/opt/hermes/bin/hermes" }, + }); + }); + + it("promotes default-provider edits into the instance map", () => { + const instance = { + driver: ProviderDriverKind.make("hermes"), + enabled: true, + config: { binaryPath: "/usr/local/bin/hermes" }, + } satisfies ProviderInstanceConfig; + const patch = buildMobileProviderInstancePatch({ + settings: DEFAULT_SERVER_SETTINGS, + row: { instanceId: HERMES_DEFAULT_INSTANCE_ID, isDefault: true }, + instance, + }); + expect(patch.providerInstances?.[HERMES_DEFAULT_INSTANCE_ID]).toEqual(instance); + expect(patch.providers?.hermes).toEqual(DEFAULT_SERVER_SETTINGS.providers.hermes); + }); + + it("adds, deduplicates, and removes custom model IDs", () => { + const instance = { + driver: ProviderDriverKind.make("hermes"), + enabled: true, + } satisfies ProviderInstanceConfig; + const added = addProviderCustomModel(instance, " anthropic/claude-new "); + expect(added.ok).toBe(true); + if (!added.ok) return; + expect(readProviderCustomModels(added.instance).map((model) => model.slug)).toEqual([ + "anthropic/claude-new", + ]); + expect(addProviderCustomModel(added.instance, "anthropic/claude-new")).toEqual({ + ok: false, + message: "That custom model is already saved.", + }); + expect( + readProviderCustomModels(removeProviderCustomModel(added.instance, "anthropic/claude-new")), + ).toEqual([]); + }); + + it("creates uniquely named Hermes instances with their own profile", () => { + const existingId = ProviderInstanceId.make("hermes_work"); + const settings = { + ...DEFAULT_SERVER_SETTINGS, + providerInstances: { + [existingId]: { + driver: ProviderDriverKind.make("hermes"), + enabled: true, + }, + }, + }; + const created = createHermesProviderInstance({ + settings, + label: "Work", + binaryPath: "/opt/hermes", + hermesHome: "/srv/hermes-work", + }); + expect(created.instanceId).toBe("hermes_work_2"); + expect(created.instance.config).toEqual({ binaryPath: "/opt/hermes" }); + expect(readProviderEnvironmentVariable(created.instance, "HERMES_HOME")).toBe( + "/srv/hermes-work", + ); + }); +}); diff --git a/apps/mobile/src/features/settings/mobile-provider-settings.ts b/apps/mobile/src/features/settings/mobile-provider-settings.ts new file mode 100644 index 0000000000..b1324eb88c --- /dev/null +++ b/apps/mobile/src/features/settings/mobile-provider-settings.ts @@ -0,0 +1,272 @@ +import { + DEFAULT_SERVER_SETTINGS, + defaultInstanceIdForDriver, + ProviderDriverKind, + ProviderInstanceId, + type ProviderInstanceConfig, + type ServerProvider, + type ServerSettings, + type ServerSettingsPatch, +} from "@t3tools/contracts"; +import { + normalizeCustomModelSlug, + readCustomModelEntries, + toCustomModelSetting, + type CustomModelDefinition, +} from "@t3tools/shared/model"; + +export const HERMES_DRIVER_KIND = ProviderDriverKind.make("hermes"); +export const HERMES_DEFAULT_INSTANCE_ID = defaultInstanceIdForDriver(HERMES_DRIVER_KIND); +export const MAX_MOBILE_CUSTOM_MODEL_LENGTH = 256; + +export interface MobileProviderSettingsRow { + readonly instanceId: ProviderInstanceId; + readonly instance: ProviderInstanceConfig; + readonly liveProvider?: ServerProvider | undefined; + readonly isDefault: boolean; +} + +type LegacyProviderSettings = ServerSettings["providers"][keyof ServerSettings["providers"]]; + +function legacyProviderSettings( + settings: ServerSettings, + driver: ProviderDriverKind, +): LegacyProviderSettings | undefined { + return (settings.providers as Record)[driver]; +} + +function instanceFromLegacySettings( + settings: ServerSettings, + driver: ProviderDriverKind, + fallbackEnabled: boolean, +): ProviderInstanceConfig { + const legacy = legacyProviderSettings(settings, driver); + if (legacy === undefined) { + return { driver, enabled: fallbackEnabled }; + } + const { enabled, ...config } = legacy; + return { + driver, + enabled: typeof enabled === "boolean" ? enabled : fallbackEnabled, + config, + }; +} + +export function resolveMobileProviderInstance( + settings: ServerSettings, + provider: Pick, +): ProviderInstanceConfig { + const explicit = settings.providerInstances[provider.instanceId]; + if (explicit !== undefined) return explicit; + if (provider.instanceId === defaultInstanceIdForDriver(provider.driver)) { + return instanceFromLegacySettings(settings, provider.driver, provider.enabled); + } + return { driver: provider.driver, enabled: provider.enabled }; +} + +/** + * Mobile starts from live provider snapshots, then fills settings-only instances + * while provider reconciliation catches up. Hermes is always present on a + * Hermes-capable server even while its default-off probe has no live row yet. + */ +export function deriveMobileProviderSettingsRows( + settings: ServerSettings, + providers: ReadonlyArray, +): ReadonlyArray { + const rows = new Map(); + for (const provider of providers) { + rows.set(provider.instanceId, { + instanceId: provider.instanceId, + instance: resolveMobileProviderInstance(settings, provider), + liveProvider: provider, + isDefault: provider.instanceId === defaultInstanceIdForDriver(provider.driver), + }); + } + for (const [rawInstanceId, instance] of Object.entries(settings.providerInstances)) { + const instanceId = ProviderInstanceId.make(rawInstanceId); + if (rows.has(instanceId)) continue; + rows.set(instanceId, { + instanceId, + instance, + isDefault: instanceId === defaultInstanceIdForDriver(instance.driver), + }); + } + if (!rows.has(HERMES_DEFAULT_INSTANCE_ID)) { + rows.set(HERMES_DEFAULT_INSTANCE_ID, { + instanceId: HERMES_DEFAULT_INSTANCE_ID, + instance: instanceFromLegacySettings(settings, HERMES_DRIVER_KIND, false), + isDefault: true, + }); + } + return [...rows.values()].sort((left, right) => { + const leftHermes = left.instance.driver === HERMES_DRIVER_KIND ? 0 : 1; + const rightHermes = right.instance.driver === HERMES_DRIVER_KIND ? 0 : 1; + if (leftHermes !== rightHermes) return leftHermes - rightHermes; + if (left.isDefault !== right.isDefault) return left.isDefault ? -1 : 1; + return String(left.instanceId).localeCompare(String(right.instanceId)); + }); +} + +export function buildMobileProviderInstancePatch(input: { + readonly settings: ServerSettings; + readonly row: Pick; + readonly instance: ProviderInstanceConfig; +}): ServerSettingsPatch { + const driver = input.instance.driver; + const defaultLegacy = legacyProviderSettings(DEFAULT_SERVER_SETTINGS, driver); + return { + ...(input.row.isDefault && defaultLegacy !== undefined + ? { + providers: { + ...input.settings.providers, + [driver]: defaultLegacy, + } as ServerSettings["providers"], + } + : {}), + providerInstances: { + ...input.settings.providerInstances, + [input.row.instanceId]: input.instance, + }, + }; +} + +function configRecord(config: unknown): Record { + return config !== null && typeof config === "object" && !Array.isArray(config) + ? { ...(config as Record) } + : {}; +} + +export function readProviderCustomModels( + instance: Pick, +): ReadonlyArray { + return readCustomModelEntries(configRecord(instance.config).customModels); +} + +function withCustomModels( + instance: ProviderInstanceConfig, + customModels: ReadonlyArray, +): ProviderInstanceConfig { + return { + ...instance, + config: { + ...configRecord(instance.config), + customModels: customModels.map(toCustomModelSetting), + }, + }; +} + +export function addProviderCustomModel( + instance: ProviderInstanceConfig, + input: string, +): + | { readonly ok: true; readonly instance: ProviderInstanceConfig } + | { readonly ok: false; readonly message: string } { + const slug = normalizeCustomModelSlug(input); + if (!slug) return { ok: false, message: "Enter a model ID." }; + if (slug.length > MAX_MOBILE_CUSTOM_MODEL_LENGTH) { + return { + ok: false, + message: `Model IDs must be ${MAX_MOBILE_CUSTOM_MODEL_LENGTH} characters or less.`, + }; + } + const customModels = readProviderCustomModels(instance); + if (customModels.some((model) => model.slug === slug)) { + return { ok: false, message: "That custom model is already saved." }; + } + return { + ok: true, + instance: withCustomModels(instance, [ + ...customModels, + { slug, name: slug, capabilities: null }, + ]), + }; +} + +export function removeProviderCustomModel( + instance: ProviderInstanceConfig, + slug: string, +): ProviderInstanceConfig { + return withCustomModels( + instance, + readProviderCustomModels(instance).filter((model) => model.slug !== slug), + ); +} + +export function updateProviderConfigString( + instance: ProviderInstanceConfig, + key: string, + value: string, +): ProviderInstanceConfig { + const config = configRecord(instance.config); + const trimmed = value.trim(); + if (trimmed.length === 0) { + delete config[key]; + } else { + config[key] = trimmed; + } + const { config: _config, ...rest } = instance; + return Object.keys(config).length > 0 ? { ...rest, config } : rest; +} + +export function readProviderConfigString( + instance: Pick, + key: string, +): string { + const value = configRecord(instance.config)[key]; + return typeof value === "string" ? value : ""; +} + +export function readProviderEnvironmentVariable( + instance: Pick, + name: string, +): string { + return instance.environment?.find((variable) => variable.name === name)?.value ?? ""; +} + +export function updateProviderEnvironmentVariable( + instance: ProviderInstanceConfig, + name: string, + value: string, +): ProviderInstanceConfig { + const trimmed = value.trim(); + const environment = (instance.environment ?? []).filter((variable) => variable.name !== name); + if (trimmed.length > 0) { + environment.push({ name, value: trimmed, sensitive: false, valueRedacted: false }); + } + const { environment: _environment, ...rest } = instance; + return environment.length > 0 ? { ...rest, environment } : rest; +} + +function normalizedInstanceSuffix(label: string): string { + return ( + label + .trim() + .toLowerCase() + .replace(/[^a-z0-9_-]+/g, "_") + .replace(/^[_-]+|[_-]+$/g, "") || "mobile" + ); +} + +export function createHermesProviderInstance(input: { + readonly settings: ServerSettings; + readonly label: string; + readonly binaryPath: string; + readonly hermesHome: string; +}): { readonly instanceId: ProviderInstanceId; readonly instance: ProviderInstanceConfig } { + const suffix = normalizedInstanceSuffix(input.label); + const base = `hermes_${suffix}`.slice(0, 61).replace(/[_-]+$/g, "") || "hermes_mobile"; + let candidate = base; + let counter = 2; + while (Object.hasOwn(input.settings.providerInstances, candidate)) { + const counterSuffix = `_${counter++}`; + candidate = `${base.slice(0, 64 - counterSuffix.length)}${counterSuffix}`; + } + let instance: ProviderInstanceConfig = { + driver: HERMES_DRIVER_KIND, + displayName: input.label.trim() || "Hermes Agent", + enabled: true, + }; + instance = updateProviderConfigString(instance, "binaryPath", input.binaryPath); + instance = updateProviderEnvironmentVariable(instance, "HERMES_HOME", input.hermesHome); + return { instanceId: ProviderInstanceId.make(candidate), instance }; +} diff --git a/docs/user/install.md b/docs/user/install.md index 0d31e64c97..6a460521f9 100644 --- a/docs/user/install.md +++ b/docs/user/install.md @@ -68,10 +68,9 @@ before sharing. ## Providers -Open **Settings → Providers** in the web or desktop app, select the environment, -and enable the provider you want. Installation, login, and configuration belong -to that environment's machine, even when you connect from a phone or another -computer. +Open **Settings → Providers**, select the environment, and enable the provider +you want. Installation, login, and configuration belong to that environment's +machine, even when you configure it from the mobile app or another computer. | Provider | Install and authenticate | | ----------- | ---------------------------------------------------------------------------------------------- | @@ -90,6 +89,10 @@ Cursor's executable is `cursor-agent`, although its login command is Hermes is experimental — its provider card shows an **Experimental** badge; see [Hermes](./providers-hermes.md) for details. +If a provider accepts a model that it does not advertise, add the exact model ID +under that provider's **Custom models** setting. The model then appears in the +thread model picker on every client connected to that environment. + When a provider CLI is behind its latest release, its provider card shows the available version. **Update now** appears only when T3 Code can tell which installer owns the CLI (its own update command, Homebrew, or a global npm, pnpm, diff --git a/docs/user/providers-hermes.md b/docs/user/providers-hermes.md index 6bb40fddef..f40ea33c45 100644 --- a/docs/user/providers-hermes.md +++ b/docs/user/providers-hermes.md @@ -20,22 +20,23 @@ does not configure Hermes on your behalf. ## Enable Hermes -Hermes is off by default. Turn it on in **Settings** → **Providers** → **Hermes**. +Hermes is off by default. In the web, desktop, or mobile app, open **Settings** → +**Providers**, select the environment, then turn on **Hermes**. The only setting is **Binary path**, which defaults to `hermes`. Set it when a version manager or a non-standard install location keeps the CLI off the `PATH` of the shell that started T3 Code. To use more than one Hermes installation or profile on the same environment, choose **Add provider -instance**, select **Hermes**, and give the instance a name. Each instance can use its own binary -path and environment variables; set `HERMES_HOME` there when the instances should use separate -Hermes profiles. +instance** on web or desktop, or **Add another Hermes instance** on mobile. Give the instance a +name and set `HERMES_HOME` when the instances should use separate Hermes profiles. ## Models Hermes has no model list of its own in T3 Code. T3 Code asks Hermes for the catalog it advertises when a session starts — whatever providers you configured through `hermes setup` or `hermes model`. Pick a model from that list in the model picker for each thread, the same as with any -other provider. +other provider. If Hermes accepts a model that it does not advertise, add its exact ID under +**Custom models** on the Hermes provider card. ## What works