Skip to content
TypeScript

feat(settings): add and list 1Password secret providers behind T3CODE_FEATURE_SECRETS (#25709)

Yordis Prieto7a4f5b6188fe
diff --git a/apps/server/src/auth/RpcAuthorization.test.ts b/apps/server/src/auth/RpcAuthorization.test.ts
index 0a9f97cc391..24c22280175 100644
--- a/apps/server/src/auth/RpcAuthorization.test.ts
+++ b/apps/server/src/auth/RpcAuthorization.test.ts
@@ -6,6 +6,7 @@ import {
AuthSettingsWriteScope,
DEFAULT_SERVER_SETTINGS,
ProviderInstanceId,
+ SecretProviderId,
ThreadId,
AuthOrchestrationOperateScope,
AuthOrchestrationReadScope,
@@ -173,7 +174,7 @@ describe("settings mutation authorization", () => {
}).pipe(Effect.scoped),
);
- it.effect("does not let a settings grant create or remove providers", () =>
+ it.effect("does not let a settings grant create or remove providers or secret providers", () =>
Effect.gen(function* () {
let handled = false;
const client = yield* RpcTest.makeClient(group).pipe(
@@ -195,6 +196,11 @@ describe("settings mutation authorization", () => {
providerInstanceMutation,
}).pipe(Effect.flip),
).toMatchObject({ requiredPermission: AuthProvidersManageScope });
+ expect(
+ yield* client[WS_METHODS.serverUpdateSettings]({
+ patch: { secretProviders: { [SecretProviderId.make("personal")]: null } },
+ }).pipe(Effect.flip),
+ ).toMatchObject({ requiredPermission: AuthProvidersManageScope });
expect(handled).toBe(false);
}).pipe(Effect.scoped),
);
diff --git a/apps/web/src/components/Icons.tsx b/apps/web/src/components/Icons.tsx
index 551312e23f1..fd1a9f461d7 100644
--- a/apps/web/src/components/Icons.tsx
+++ b/apps/web/src/components/Icons.tsx
@@ -505,3 +505,12 @@ export const MacAccessibilityIcon: Icon = (props) => {
</svg>
);
};
+
+export const OnePasswordIcon: Icon = (props) => (
+ <svg {...props} viewBox="0 0 24 24" fill="none">
+ <path
+ d="M12 0c6.627 0 12 5.373 12 12 0 6.628-5.373 12-12 12S0 18.628 0 12C0 5.373 5.373 0 12 0m-.893 4.86c-.485 0-.727.001-.913.095a.87.87 0 0 0-.378.379c-.094.185-.095.428-.095.912v2.747c0 .12 0 .182.016.238q.02.075.065.138a1 1 0 0 0 .175.162l.695.564c.113.092.17.139.19.194a.22.22 0 0 1 0 .15c-.02.056-.077.102-.19.194l-.695.564a1 1 0 0 0-.175.162.4.4 0 0 0-.065.138 1 1 0 0 0-.016.238v6.019c0 .485 0 .728.095.913a.87.87 0 0 0 .378.378c.186.094.428.094.913.094h1.786c.485 0 .727 0 .913-.094a.87.87 0 0 0 .378-.378c.095-.185.095-.428.095-.913v-2.747c0-.12 0-.182-.016-.238a.4.4 0 0 0-.065-.138 1 1 0 0 0-.175-.162l-.695-.564c-.113-.092-.17-.138-.191-.193a.22.22 0 0 1 0-.152c.02-.055.078-.1.19-.193l.696-.564a1 1 0 0 0 .175-.162.4.4 0 0 0 .065-.138 1 1 0 0 0 .016-.238V6.246c0-.484 0-.727-.095-.912a.87.87 0 0 0-.378-.379c-.186-.094-.428-.094-.913-.094Z"
+ fill="currentColor"
+ />
+ </svg>
+);
diff --git a/apps/web/src/components/settings/SecretProviderDialog.logic.test.ts b/apps/web/src/components/settings/SecretProviderDialog.logic.test.ts
new file mode 100644
index 00000000000..a23ea149d48
--- /dev/null
+++ b/apps/web/src/components/settings/SecretProviderDialog.logic.test.ts
@@ -0,0 +1,51 @@
+import { SecretProviderId } from "@t3tools/contracts";
+import * as Result from "effect/Result";
+import { describe, expect, it } from "vite-plus/test";
+
+import { secretProviderFromDraft } from "./SecretProviderDialog.logic";
+
+describe("secretProviderFromDraft", () => {
+ it("adds a provider keyed by its name and reports every field that blocks it", () => {
+ expect(
+ secretProviderFromDraft({ name: " 1Password! ", account: "my.1password.com" }, new Set(), {
+ mode: "add",
+ }),
+ ).toEqual(
+ Result.succeed({
+ id: "1password",
+ config: {
+ kind: "one_password",
+ label: "1Password!",
+ config: { account: "my.1password.com" },
+ },
+ }),
+ );
+
+ const blocked = secretProviderFromDraft(
+ { name: "1Password", account: "--help" },
+ new Set(["1password"]),
+ { mode: "add" },
+ );
+ expect(Result.isFailure(blocked) && Object.keys(blocked.failure).toSorted()).toEqual([
+ "account",
+ "name",
+ ]);
+ });
+
+ it("keeps the id when an edit renames the provider", () => {
+ const id = SecretProviderId.make("personal");
+ const result = secretProviderFromDraft(
+ { name: "Personal (team)", account: "team.1password.com" },
+ new Set(["personal"]),
+ { mode: "edit", id },
+ );
+ expect(Result.isSuccess(result) && result.success).toEqual({
+ id,
+ config: {
+ kind: "one_password",
+ label: "Personal (team)",
+ config: { account: "team.1password.com" },
+ },
+ });
+ });
+});
diff --git a/apps/web/src/components/settings/SecretProviderDialog.logic.ts b/apps/web/src/components/settings/SecretProviderDialog.logic.ts
new file mode 100644
index 00000000000..11139d9c7aa
--- /dev/null
+++ b/apps/web/src/components/settings/SecretProviderDialog.logic.ts
@@ -0,0 +1,117 @@
+import {
+ OnePasswordSecretProviderConfig,
+ SecretProviderId,
+ SecretProviderKind,
+ SecretProviderLabel,
+ type OnePasswordAccount,
+ type SecretProviderConfig,
+} from "@t3tools/contracts";
+import * as Option from "effect/Option";
+import * as Result from "effect/Result";
+import * as Schema from "effect/Schema";
+
+const decodeSecretProviderId = Schema.decodeOption(SecretProviderId);
+const decodeOnePasswordConfig = Schema.decodeUnknownOption(OnePasswordSecretProviderConfig);
+
+export type ClassifiedSecretProvider =
+ | { readonly kind: "one_password"; readonly account: OnePasswordAccount }
+ | { readonly kind: "unsupported" };
+
+/** Unknown kinds and configs that no longer decode are shown read-only; removal stays available. */
+export function classifySecretProvider(provider: SecretProviderConfig): ClassifiedSecretProvider {
+ if (provider.kind !== "one_password") return { kind: "unsupported" };
+ const decoded = decodeOnePasswordConfig(provider.config);
+ return decoded._tag === "Some"
+ ? { kind: "one_password", account: decoded.value.account }
+ : { kind: "unsupported" };
+}
+
+/** Stable and readable in settings.json, so re-adding a provider under the same name restores its variables. */
+function secretProviderIdFromName(name: string): SecretProviderId | null {
+ const slug = name
+ .toLowerCase()
+ .replace(/[^a-z0-9]+/g, "-")
+ .replace(/^-|-$/g, "")
+ .slice(0, 64)
+ .replace(/-$/, "");
+ return Option.getOrNull(decodeSecretProviderId(slug));
+}
+
+export interface SecretProviderDraft {
+ readonly name: string;
+ readonly account: string;
+}
+
+export function draftFromSecretProvider(provider: SecretProviderConfig): SecretProviderDraft {
+ const classified = classifySecretProvider(provider);
+ return {
+ name: provider.label,
+ account: classified.kind === "one_password" ? classified.account : "",
+ };
+}
+
+export type SecretProviderTarget =
+ | { readonly mode: "add" }
+ | { readonly mode: "edit"; readonly id: SecretProviderId };
+
+export type SecretProviderDraftIssues = {
+ readonly [Field in keyof SecretProviderDraft]?: string;
+};
+
+function decodeField<S extends Schema.ConstraintDecoder<unknown>>(
+ schema: S,
+ value: string,
+ emptyMessage: string,
+): Result.Result<S["Type"], string> {
+ const trimmed = value.trim();
+ if (trimmed.length === 0) return Result.fail(emptyMessage);
+ return Result.mapError(Schema.decodeResult(schema)(trimmed), (error) => error.message);
+}
+
+/** The settings entry a draft adds or replaces, or every field that blocks it, one message each. */
+export function secretProviderFromDraft(
+ draft: SecretProviderDraft,
+ existingIds: ReadonlySet<string>,
+ target: SecretProviderTarget,
+): Result.Result<
+ { readonly id: SecretProviderId; readonly config: SecretProviderConfig },
+ SecretProviderDraftIssues
+> {
+ const label = decodeField(SecretProviderLabel, draft.name, "Enter a name.");
+ const account = decodeField(
+ OnePasswordSecretProviderConfig.fields.account,
+ draft.account,
+ "Enter the 1Password account.",
+ );
+
+ let id: SecretProviderId | null = null;
+ let nameIssue: string | undefined;
+ if (Result.isFailure(label)) {
+ nameIssue = label.failure;
+ } else {
+ id = target.mode === "edit" ? target.id : secretProviderIdFromName(label.success);
+ if (id === null) nameIssue = "The name needs at least one letter or digit.";
+ else if (target.mode === "add" && existingIds.has(id))
+ nameIssue = "A secret provider with this name exists.";
+ }
+
+ if (
+ id === null ||
+ nameIssue !== undefined ||
+ Result.isFailure(label) ||
+ Result.isFailure(account)
+ ) {
+ return Result.fail({
+ ...(nameIssue === undefined ? {} : { name: nameIssue }),
+ ...(Result.isFailure(account) ? { account: account.failure } : {}),
+ });
+ }
+ return Result.succeed({
+ id,
+ config: {
+ kind: SecretProviderKind.make("one_password"),
+ label: label.success,
+ config: { account: account.success },
+ },
+ });
+}
diff --git a/apps/web/src/components/settings/SecretProviderDialog.tsx b/apps/web/src/components/settings/SecretProviderDialog.tsx
new file mode 100644
index 00000000000..9370fcc68b3
--- /dev/null
+++ b/apps/web/src/components/settings/SecretProviderDialog.tsx
@@ -0,0 +1,155 @@
+import type { EnvironmentId, SecretProviderConfig, SecretProviderId } from "@t3tools/contracts";
+import * as Result from "effect/Result";
+import { useState } from "react";
+
+import { useUpdateEnvironmentSettings } from "../../hooks/useSettings";
+import { Button } from "../ui/button";
+import {
+ Dialog,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogPanel,
+ DialogPopup,
+ DialogTitle,
+} from "../ui/dialog";
+import { Input } from "../ui/input";
+import { Label } from "../ui/label";
+import {
+ draftFromSecretProvider,
+ secretProviderFromDraft,
+ type SecretProviderDraft,
+} from "./SecretProviderDialog.logic";
+
+/** Mounted per open, so each open starts from a fresh draft. */
+export function SecretProviderDialog({
+ onClose,
+ environmentId,
+ environmentLabel,
+ existingIds,
+ existing,
+}: {
+ readonly onClose: () => void;
+ readonly environmentId: EnvironmentId;
+ readonly environmentLabel: string;
+ readonly existingIds: ReadonlySet<string>;
+ readonly existing?: { readonly id: SecretProviderId; readonly config: SecretProviderConfig };
+}) {
+ const updateSettings = useUpdateEnvironmentSettings(environmentId);
+ const [draft, setDraft] = useState<SecretProviderDraft>(
+ existing ? draftFromSecretProvider(existing.config) : { name: "", account: "" },
+ );
+ const [submitted, setSubmitted] = useState(false);
+ const result = secretProviderFromDraft(
+ draft,
+ existingIds,
+ existing ? { mode: "edit", id: existing.id } : { mode: "add" },
+ );
+ const issues = Result.isFailure(result) ? result.failure : {};
+ const nameError = submitted ? issues.name : undefined;
+ const accountError = submitted ? issues.account : undefined;
+
+ const update = (patch: Partial<SecretProviderDraft>) => setDraft({ ...draft, ...patch });
+ const save = () => {
+ setSubmitted(true);
+ if (Result.isFailure(result)) return;
+ updateSettings({ secretProviders: { [result.success.id]: result.success.config } });
+ onClose();
+ };
+
+ return (
+ <Dialog
+ open
+ onOpenChange={(next) => {
+ if (!next) onClose();
+ }}
+ >
+ <DialogPopup className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>
+ {existing ? `Edit ${existing.config.label}` : "Add a 1Password provider"}
+ </DialogTitle>
+ <DialogDescription>
+ Provider variables on {environmentLabel} can read values from it by name. Values are
+ read with the op CLI on that server when a provider starts.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogPanel>
+ <form
+ id="secret-provider-form"
+ className="grid gap-4"
+ onSubmit={(event) => {
+ event.preventDefault();
+ save();
+ }}
+ >
+ <div className="grid gap-1.5">
+ <Label htmlFor="secret-provider-name">Name</Label>
+ <Input
+ id="secret-provider-name"
+ placeholder="Personal"
+ value={draft.name}
+ onChange={(event) => update({ name: event.target.value })}
+ maxLength={64}
+ aria-invalid={nameError !== undefined}
+ aria-describedby={
+ nameError !== undefined ? "secret-provider-name-error" : undefined
+ }
+ autoFocus
+ />
+ {nameError !== undefined ? (
+ <p
+ id="secret-provider-name-error"
+ role="alert"
+ className="text-xs text-destructive"
+ >
+ {nameError}
+ </p>
+ ) : null}
+ </div>
+ <div className="grid gap-1.5">
+ <Label htmlFor="secret-provider-account">Account</Label>
+ <Input
+ id="secret-provider-account"
+ placeholder="my.1password.com"
+ value={draft.account}
+ onChange={(event) => update({ account: event.target.value })}
+ maxLength={253}
+ spellCheck={false}
+ aria-invalid={accountError !== undefined}
+ aria-describedby={
+ accountError !== undefined ? "secret-provider-account-error" : undefined
+ }
+ />
+ {accountError !== undefined ? (
+ <p
+ id="secret-provider-account-error"
+ role="alert"
+ className="text-xs text-destructive"
+ >
+ {accountError}
+ </p>
+ ) : null}
+ <p className="text-xs text-muted-foreground">
+ The account shorthand, sign-in address without https://, or ID that op account list
+ shows.
+ </p>
+ </div>
+ </form>
+ </DialogPanel>
+ <DialogFooter variant="bare">
+ <Button variant="outline" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button
+ type="submit"
+ form="secret-provider-form"
+ disabled={submitted && Result.isFailure(result)}
+ >
+ {existing ? "Save changes" : "Add provider"}
+ </Button>
+ </DialogFooter>
+ </DialogPopup>
+ </Dialog>
+ );
+}
diff --git a/apps/web/src/components/settings/SecretsSettings.tsx b/apps/web/src/components/settings/SecretsSettings.tsx
new file mode 100644
index 00000000000..e9efe2d85f6
--- /dev/null
+++ b/apps/web/src/components/settings/SecretsSettings.tsx
@@ -0,0 +1,220 @@
+import type { SecretProviderConfig, SecretProviderId } from "@t3tools/contracts";
+import { PlusIcon } from "lucide-react";
+import { useState } from "react";
+
+import { useEnvironmentSettings, useUpdateEnvironmentSettings } from "../../hooks/useSettings";
+import type { EnvironmentPresentation } from "../../state/environments";
+import { useEnvironmentSessionState } from "../../state/session";
+import { OnePasswordIcon, type Icon } from "../Icons";
+import {
+ AlertDialog,
+ AlertDialogClose,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogPopup,
+ AlertDialogTitle,
+} from "../ui/alert-dialog";
+import { Button } from "../ui/button";
+import { SecretProviderDialog } from "./SecretProviderDialog";
+import { classifySecretProvider } from "./SecretProviderDialog.logic";
+import {
+ classifyProviderEnvironmentAccess,
+ resolveRemoteOperateAccess,
+} from "./ProviderSettingsPanel.logic";
+import { useSettingsScope } from "./SettingsScopeContext";
+import { RedactedSensitiveText } from "./RedactedSensitiveText";
+import { searchableSetting } from "./settingsSearch";
+import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
+
+const SECRET_PROVIDER_KINDS: Readonly<
+ Record<string, { readonly name: string; readonly icon: Icon }>
+> = {
+ one_password: { name: "1Password", icon: OnePasswordIcon },
+};
+
+export function SecretsSettingsPanel() {
+ const { scope, environment } = useSettingsScope();
+ return (
+ <SettingsPageContainer>
+ {environment?.connection.phase === "connected" ? (
+ <EnvironmentSecretProviders
+ key={environment.environmentId}
+ environment={environment}
+ projectScoped={scope.kind === "project" || scope.kind === "checkout"}
+ />
+ ) : (
+ <SettingsSection {...searchableSetting("secret-providers")}>
+ <p className="px-4 py-3 text-sm text-muted-foreground">
+ Connect an environment to manage the secret providers its provider variables read from.
+ </p>
+ </SettingsSection>
+ )}
+ </SettingsPageContainer>
+ );
+}
+
+function EnvironmentSecretProviders({
+ environment,
+ projectScoped,
+}: {
+ readonly environment: EnvironmentPresentation;
+ readonly projectScoped: boolean;
+}) {
+ const environmentId = environment.environmentId;
+ const sessionState = useEnvironmentSessionState(environmentId);
+ // The server requires the same grant for secret providers as for provider settings.
+ const access = classifyProviderEnvironmentAccess({
+ connectionPhase: environment.connection.phase,
+ hasServerConfig: environment.serverConfig !== null,
+ operateAccess: resolveRemoteOperateAccess({
+ session: sessionState.data,
+ isPending: sessionState.isPending,
+ hasError: sessionState.hasError,
+ }),
+ });
+ const readOnly = access.kind !== "editable" || projectScoped;
+ const providers = useEnvironmentSettings(environmentId, (settings) => settings.secretProviders);
+ const updateSettings = useUpdateEnvironmentSettings(environmentId);
+ const [dialog, setDialog] = useState<
+ null | { readonly mode: "add" } | { readonly mode: "edit"; readonly id: SecretProviderId }
+ >(null);
+ const entries = Object.entries(providers) as Array<[SecretProviderId, SecretProviderConfig]>;
+ const editingConfig = dialog?.mode === "edit" ? providers[dialog.id] : undefined;
+ const editing =
+ dialog?.mode === "edit" && editingConfig !== undefined
+ ? { id: dialog.id, config: editingConfig }
+ : undefined;
+ return (
+ <>
+ <SettingsSection
+ {...searchableSetting("secret-providers")}
+ headerAction={
+ !readOnly ? (
+ <Button size="xs" variant="outline" onClick={() => setDialog({ mode: "add" })}>
+ <PlusIcon className="size-3" aria-hidden />
+ Add provider
+ </Button>
+ ) : null
+ }
+ >
+ {projectScoped ? (
+ <p className="px-4 pt-3 text-xs text-muted-foreground">
+ Environment-wide setting. Select an environment to change it.
+ </p>
+ ) : null}
+ {entries.length === 0 ? (
+ <SettingsRow
+ title="No secret providers configured."
+ description="Add a 1Password account, then pick it as the source of a provider variable."
+ />
+ ) : (
+ entries.map(([id, config]) => {
+ const classified = classifySecretProvider(config);
+ const kind =
+ classified.kind === "unsupported"
+ ? undefined
+ : SECRET_PROVIDER_KINDS[classified.kind];
+ return (
+ <SettingsRow
+ key={id}
+ title={
+ <span className="flex min-w-0 items-center gap-2">
+ {kind ? (
+ <kind.icon className="size-4.5 shrink-0 text-foreground/80" aria-hidden />
+ ) : null}
+ <span className="min-w-0 wrap-anywhere">{config.label}</span>
+ </span>
+ }
+ description={
+ classified.kind === "one_password" && kind ? (
+ <span className="flex min-w-0 items-center gap-1">
+ <span className="shrink-0">{kind.name} ·</span>
+ <RedactedSensitiveText
+ value={classified.account}
+ ariaLabel="Toggle account visibility"
+ revealTooltip="Click to reveal account"
+ hideTooltip="Click to hide account"
+ className="max-w-full truncate"
+ />
+ </span>
+ ) : (
+ `Unsupported provider (${config.kind})`
+ )
+ }
+ control={
+ !readOnly ? (
+ <div className="flex items-center gap-1">
+ {kind ? (
+ <Button
+ size="xs"
+ variant="ghost"
+ onClick={() => setDialog({ mode: "edit", id })}
+ >
+ Edit
+ </Button>
+ ) : null}
+ <RemoveSecretProviderButton
+ label={config.label}
+ onConfirm={() => updateSettings({ secretProviders: { [id]: null } })}
+ />
+ </div>
+ ) : null
+ }
+ />
+ );
+ })
+ )}
+ </SettingsSection>
+ {dialog !== null && !readOnly && (dialog.mode === "add" || editing !== undefined) ? (
+ <SecretProviderDialog
+ onClose={() => setDialog(null)}
+ environmentId={environmentId}
+ environmentLabel={environment.label}
+ existingIds={new Set(Object.keys(providers))}
+ {...(editing === undefined ? {} : { existing: editing })}
+ />
+ ) : null}
+ </>
+ );
+}
+
+function RemoveSecretProviderButton({
+ label,
+ onConfirm,
+}: {
+ readonly label: string;
+ readonly onConfirm: () => void;
+}) {
+ const [open, setOpen] = useState(false);
+ return (
+ <>
+ <Button size="xs" variant="ghost" onClick={() => setOpen(true)}>
+ Remove
+ </Button>
+ <AlertDialog open={open} onOpenChange={setOpen}>
+ <AlertDialogPopup>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Remove {label}?</AlertDialogTitle>
+ <AlertDialogDescription>
+ Provider variables that read from {label} stop resolving until a provider with the
+ same name is added again. The secrets themselves are untouched.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
+ <Button
+ variant="destructive"
+ onClick={() => {
+ setOpen(false);
+ onConfirm();
+ }}
+ >
+ Remove provider
+ </Button>
+ </AlertDialogFooter>
+ </AlertDialogPopup>
+ </AlertDialog>
+ </>
+ );
+}
diff --git a/apps/web/src/components/settings/SettingsSidebarNav.tsx b/apps/web/src/components/settings/SettingsSidebarNav.tsx
index b58f56a1623..ee061be1ebf 100644
--- a/apps/web/src/components/settings/SettingsSidebarNav.tsx
+++ b/apps/web/src/components/settings/SettingsSidebarNav.tsx
@@ -22,6 +22,7 @@ import {
MessagesSquareIcon,
PanelsTopLeftIcon,
KeyboardIcon,
+ KeyRoundIcon,
PaletteIcon,
SearchIcon,
ServerIcon,
@@ -102,6 +103,7 @@ const SETTINGS_SECTION_ICONS: Readonly<
"/settings/worktrees": FolderTreeIcon,
"/settings/connections": ServerIcon,
"/settings/access": ShieldCheckIcon,
+ "/settings/secrets": KeyRoundIcon,
"/settings/maintenance": WrenchIcon,
"/settings/labs": FlaskConicalIcon,
"/settings/about": InfoIcon,
diff --git a/apps/web/src/components/settings/settingsSearch.test.ts b/apps/web/src/components/settings/settingsSearch.test.ts
index 3013298c6ec..07d1d5dd6c8 100644
--- a/apps/web/src/components/settings/settingsSearch.test.ts
+++ b/apps/web/src/components/settings/settingsSearch.test.ts
@@ -14,12 +14,18 @@ import {
isSettingsSearchScopeAvailable,
movedSettingsPath,
searchSettings,
+ SETTINGS_NAV_GROUPS,
SETTINGS_SEARCH_ITEMS,
sourceControlHostSearchItems,
sourceControlHostSettingsSearchId,
type SettingsSearchItem,
} from "./settingsSearch";
+vi.mock("~/env", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("~/env")>()),
+ isSecretsFeatureEnabled: false,
+}));
+
const ITEMS: ReadonlyArray<SettingsSearchItem> = [
{
id: "word-wrap",
@@ -60,6 +66,11 @@ describe("searchSettings", () => {
expect(searchSettings("long lines", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
});
+ it("hides the Secrets page from nav and search while the secrets feature is disabled", () => {
+ expect(SETTINGS_NAV_GROUPS.flatMap((group) => group.paths)).not.toContain("/settings/secrets");
+ expect(searchSettings("1password").map((item) => item.to)).not.toContain("/settings/secrets");
+ });
+
it("matches normalized title substrings", () => {
expect(searchSettings(" WORD WRAP ", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
expect(searchSettings("glass").map((item) => item.id)).toEqual(["setting-glass-opacity"]);
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 1d5c13e72a0..dc494caf534 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -1,5 +1,5 @@
import { HOSTED_APP_CHANNEL } from "~/branding";
-import { isElectron } from "~/env";
+import { isElectron, isSecretsFeatureEnabled } from "~/env";
import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/utils";
import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
import type { EnvironmentId } from "@t3tools/contracts";
@@ -33,6 +33,7 @@ export type SettingsPath =
| "/settings/worktrees"
| "/settings/connections"
| "/settings/access"
+ | "/settings/secrets"
| "/settings/maintenance"
| "/settings/labs"
| "/settings/about"
@@ -57,6 +58,7 @@ export interface SettingsSearchItem {
readonly macOnly?: boolean;
readonly windowsOnly?: boolean;
readonly releaseChannelOnly?: boolean;
+ readonly secretsFeatureOnly?: boolean;
readonly cloudOnly?: boolean;
readonly environmentOnly?: boolean;
readonly providerSettingsOnly?: boolean;
@@ -101,6 +103,7 @@ export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
"/settings/worktrees": "Worktrees",
"/settings/connections": "Environments",
"/settings/access": "Sharing & access",
+ "/settings/secrets": "Secrets",
"/settings/maintenance": "Maintenance",
"/settings/labs": "Labs",
"/settings/about": "About",
@@ -137,7 +140,14 @@ export const SETTINGS_NAV_GROUPS: ReadonlyArray<{
heading: "Code",
paths: ["/settings/projects", "/settings/source-control", "/settings/worktrees"],
},
- { heading: "Connections", paths: ["/settings/connections", "/settings/access"] },
+ {
+ heading: "Connections",
+ paths: [
+ "/settings/connections",
+ "/settings/access",
+ ...(isSecretsFeatureEnabled ? (["/settings/secrets"] as const) : []),
+ ],
+ },
{
heading: null,
paths: ["/settings/maintenance", "/settings/labs", "/settings/about", "/settings/archived"],
@@ -1142,6 +1152,21 @@ export const SETTINGS_SEARCH_ITEMS = [
`pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
],
},
+ {
+ id: "secret-providers",
+ title: "Secret providers",
+ to: "/settings/secrets",
+ searchTerms: ["1password vault credentials api key"],
+ secretsFeatureOnly: true,
+ },
+ {
+ id: "secret-providers-add",
+ title: "Add secret provider",
+ to: "/settings/secrets",
+ targetId: "secret-providers",
+ searchTerms: ["new 1password vault op cli account"],
+ secretsFeatureOnly: true,
+ },
{
id: "archive",
title: "Archived threads",
@@ -1171,6 +1196,7 @@ const SETTINGS_CATEGORY_SCOPES: Readonly<Record<SettingsPath, SettingsSearchScop
"/settings/worktrees": "project-defaults",
"/settings/connections": "connections",
"/settings/access": "connections",
+ "/settings/secrets": null,
"/settings/scheduled-tasks": null,
"/settings/maintenance": null,
"/settings/labs": null,
@@ -1313,6 +1339,7 @@ export function settingsForThisPlatform(
(item) =>
(isElectron || item.desktopOnly !== true) &&
(!item.releaseChannelOnly || isElectron || HOSTED_APP_CHANNEL !== null) &&
+ (!item.secretsFeatureOnly || isSecretsFeatureEnabled) &&
(!item.macOnly || isMacPlatform(platform)) &&
(!item.windowsOnly || isWindowsPlatform(platform)),
);
diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts
index be2a563d736..a0a28c5d7fd 100644
--- a/apps/web/src/env.ts
+++ b/apps/web/src/env.ts
@@ -1,2 +1,6 @@
// Preload installs desktopBridge before web code runs, so module-load detection is reliable.
export const isElectron = typeof window !== "undefined" && window.desktopBridge !== undefined;
+
+export const isSecretsFeatureEnabled = ["1", "true"].includes(
+ import.meta.env.T3CODE_FEATURE_SECRETS?.trim().toLowerCase() ?? "",
+);
diff --git a/apps/web/src/routeTree.gen.ts b/apps/web/src/routeTree.gen.ts
index d92ea611086..0e26ab6edd8 100644
--- a/apps/web/src/routeTree.gen.ts
+++ b/apps/web/src/routeTree.gen.ts
@@ -26,6 +26,7 @@ import { Route as ChatSettingsThreadsRouteImport } from './routes/_chat.settings
import { Route as ChatSettingsStorageRouteImport } from './routes/_chat.settings.storage'
import { Route as ChatSettingsSourceControlRouteImport } from './routes/_chat.settings.source-control'
import { Route as ChatSettingsSnapShotRouteImport } from './routes/_chat.settings.snap-shot'
+import { Route as ChatSettingsSecretsRouteImport } from './routes/_chat.settings.secrets'
import { Route as ChatSettingsScheduledTasksRouteImport } from './routes/_chat.settings.scheduled-tasks'
import { Route as ChatSettingsProvidersRouteImport } from './routes/_chat.settings.providers'
import { Route as ChatSettingsProjectsRouteImport } from './routes/_chat.settings.projects'
@@ -134,6 +135,11 @@ const ChatSettingsSnapShotRoute = ChatSettingsSnapShotRouteImport.update({
path: '/snap-shot',
getParentRoute: () => ChatSettingsRoute,
} as any)
+const ChatSettingsSecretsRoute = ChatSettingsSecretsRouteImport.update({
+ id: '/secrets',
+ path: '/secrets',
+ getParentRoute: () => ChatSettingsRoute,
+} as any)
const ChatSettingsScheduledTasksRoute =
ChatSettingsScheduledTasksRouteImport.update({
id: '/scheduled-tasks',
@@ -283,6 +289,7 @@ export interface FileRoutesByFullPath {
'/settings/projects': typeof ChatSettingsProjectsRoute
'/settings/providers': typeof ChatSettingsProvidersRoute
'/settings/scheduled-tasks': typeof ChatSettingsScheduledTasksRoute
+ '/settings/secrets': typeof ChatSettingsSecretsRoute
'/settings/snap-shot': typeof ChatSettingsSnapShotRoute
'/settings/source-control': typeof ChatSettingsSourceControlRoute
'/settings/storage': typeof ChatSettingsStorageRoute
@@ -323,6 +330,7 @@ export interface FileRoutesByTo {
'/settings/projects': typeof ChatSettingsProjectsRoute
'/settings/providers': typeof ChatSettingsProvidersRoute
'/settings/scheduled-tasks': typeof ChatSettingsScheduledTasksRoute
+ '/settings/secrets': typeof ChatSettingsSecretsRoute
'/settings/snap-shot': typeof ChatSettingsSnapShotRoute
'/settings/source-control': typeof ChatSettingsSourceControlRoute
'/settings/storage': typeof ChatSettingsStorageRoute
@@ -365,6 +373,7 @@ export interface FileRoutesById {
'/_chat/settings/projects': typeof ChatSettingsProjectsRoute
'/_chat/settings/providers': typeof ChatSettingsProvidersRoute
'/_chat/settings/scheduled-tasks': typeof ChatSettingsScheduledTasksRoute
+ '/_chat/settings/secrets': typeof ChatSettingsSecretsRoute
'/_chat/settings/snap-shot': typeof ChatSettingsSnapShotRoute
'/_chat/settings/source-control': typeof ChatSettingsSourceControlRoute
'/_chat/settings/storage': typeof ChatSettingsStorageRoute
@@ -407,6 +416,7 @@ export interface FileRouteTypes {
| '/settings/projects'
| '/settings/providers'
| '/settings/scheduled-tasks'
+ | '/settings/secrets'
| '/settings/snap-shot'
| '/settings/source-control'
| '/settings/storage'
@@ -447,6 +457,7 @@ export interface FileRouteTypes {
| '/settings/projects'
| '/settings/providers'
| '/settings/scheduled-tasks'
+ | '/settings/secrets'
| '/settings/snap-shot'
| '/settings/source-control'
| '/settings/storage'
@@ -488,6 +499,7 @@ export interface FileRouteTypes {
| '/_chat/settings/projects'
| '/_chat/settings/providers'
| '/_chat/settings/scheduled-tasks'
+ | '/_chat/settings/secrets'
| '/_chat/settings/snap-shot'
| '/_chat/settings/source-control'
| '/_chat/settings/storage'
@@ -626,6 +638,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ChatSettingsSnapShotRouteImport
parentRoute: typeof ChatSettingsRoute
}
+ '/_chat/settings/secrets': {
+ id: '/_chat/settings/secrets'
+ path: '/secrets'
+ fullPath: '/settings/secrets'
+ preLoaderRoute: typeof ChatSettingsSecretsRouteImport
+ parentRoute: typeof ChatSettingsRoute
+ }
'/_chat/settings/scheduled-tasks': {
id: '/_chat/settings/scheduled-tasks'
path: '/scheduled-tasks'
@@ -804,6 +823,7 @@ interface ChatSettingsRouteChildren {
ChatSettingsProjectsRoute: typeof ChatSettingsProjectsRoute
ChatSettingsProvidersRoute: typeof ChatSettingsProvidersRoute
ChatSettingsScheduledTasksRoute: typeof ChatSettingsScheduledTasksRoute
+ ChatSettingsSecretsRoute: typeof ChatSettingsSecretsRoute
ChatSettingsSnapShotRoute: typeof ChatSettingsSnapShotRoute
ChatSettingsSourceControlRoute: typeof ChatSettingsSourceControlRoute
ChatSettingsStorageRoute: typeof ChatSettingsStorageRoute
@@ -832,6 +852,7 @@ const ChatSettingsRouteChildren: ChatSettingsRouteChildren = {
ChatSettingsProjectsRoute: ChatSettingsProjectsRoute,
ChatSettingsProvidersRoute: ChatSettingsProvidersRoute,
ChatSettingsScheduledTasksRoute: ChatSettingsScheduledTasksRoute,
+ ChatSettingsSecretsRoute: ChatSettingsSecretsRoute,
ChatSettingsSnapShotRoute: ChatSettingsSnapShotRoute,
ChatSettingsSourceControlRoute: ChatSettingsSourceControlRoute,
ChatSettingsStorageRoute: ChatSettingsStorageRoute,
diff --git a/apps/web/src/routes/_chat.settings.secrets.tsx b/apps/web/src/routes/_chat.settings.secrets.tsx
new file mode 100644
index 00000000000..d97e00fda19
--- /dev/null
+++ b/apps/web/src/routes/_chat.settings.secrets.tsx
@@ -0,0 +1,11 @@
+import { createFileRoute, redirect } from "@tanstack/react-router";
+
+import { SecretsSettingsPanel } from "../components/settings/SecretsSettings";
+import { isSecretsFeatureEnabled } from "../env";
+
+export const Route = createFileRoute("/_chat/settings/secrets")({
+ beforeLoad: () => {
+ if (!isSecretsFeatureEnabled) throw redirect({ to: "/settings/general", replace: true });
+ },
+ component: SecretsSettingsPanel,
+});
diff --git a/apps/web/src/routes/_chat.settings.tsx b/apps/web/src/routes/_chat.settings.tsx
index fdc350fe81a..7758c9ca559 100644
--- a/apps/web/src/routes/_chat.settings.tsx
+++ b/apps/web/src/routes/_chat.settings.tsx
@@ -150,7 +150,7 @@ function SettingsRouteLayout() {
return (
<SettingsScopeProvider
search={rawSearch}
- singleEnvironment={pathname === "/settings/providers"}
+ singleEnvironment={pathname === "/settings/providers" || pathname === "/settings/secrets"}
onChange={(next) => {
// Send every axis so retain middleware recognizes "all" as an explicit target.
void navigate({
diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts
index 307b9c5d828..63f7cca9cbf 100644
--- a/apps/web/src/vite-env.d.ts
+++ b/apps/web/src/vite-env.d.ts
@@ -15,6 +15,7 @@ interface ImportMetaEnv {
readonly VITE_RELAY_OTLP_TRACES_DATASET: string;
readonly VITE_RELAY_OTLP_TRACES_TOKEN: string;
readonly T3CODE_DESKTOP_UPDATE_REPOSITORY: string;
+ readonly T3CODE_FEATURE_SECRETS: string;
readonly APP_VERSION: string;
}
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index 501bac5dba0..da07814b29f 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -49,6 +49,7 @@ const configuredDesktopUpdateRepository =
process.env.T3CODE_DESKTOP_UPDATE_REPOSITORY?.trim() ||
process.env.GITHUB_REPOSITORY?.trim() ||
"";
+const configuredFeatureSecrets = process.env.T3CODE_FEATURE_SECRETS?.trim() || "";
const configuredHostedAppUrl = (() => {
const explicitHostedAppUrl = process.env.VITE_HOSTED_APP_URL?.trim();
if (explicitHostedAppUrl) {
@@ -316,6 +317,7 @@ export default defineConfig(() => {
"import.meta.env.T3CODE_DESKTOP_UPDATE_REPOSITORY": JSON.stringify(
configuredDesktopUpdateRepository,
),
+ "import.meta.env.T3CODE_FEATURE_SECRETS": JSON.stringify(configuredFeatureSecrets),
"import.meta.env.VITE_RELEASE_CHANNEL": JSON.stringify(configuredReleaseChannel),
"import.meta.env.APP_VERSION": JSON.stringify(configuredAppVersion),
},
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index 25523c2d0fb..fd25d9bb171 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -15,6 +15,7 @@ import {
resolveProjectProviderInstanceEnabled,
resolveProviderInstanceEnabled,
ServerSettings,
+ OnePasswordSecretProviderConfig,
ServerSettingsPatch,
withIdleCompaction,
} from "./settings.ts";
@@ -25,6 +26,7 @@ const encodeClientSettings = Schema.encodeSync(ClientSettingsSchema);
const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
const encodeServerSettings = Schema.encodeSync(ServerSettings);
+const decodeOnePasswordConfig = Schema.decodeUnknownSync(OnePasswordSecretProviderConfig);
const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings);
describe("storage cleanup settings", () => {
@@ -115,6 +117,54 @@ describe("ServerSettings usage price overrides", () => {
});
});
+describe("ServerSettings secret providers", () => {
+ const onePassword = (account: string) => ({
+ kind: "one_password",
+ label: "Personal",
+ config: { account },
+ });
+
+ it("keeps an unknown kind or a longer label from invalidating the rest of the settings", () => {
+ const openbao = { kind: "openbao", label: "V".repeat(65), config: { address: "https://x" } };
+ const decoded = decodeServerSettings({
+ worktreesDirectory: "/work",
+ secretProviders: { vault: openbao, personal: onePassword("my.1password.com") },
+ });
+ expect(decoded.worktreesDirectory).toBe("/work");
+ expect(encodeServerSettings(decoded).secretProviders).toEqual({
+ vault: openbao,
+ personal: onePassword("my.1password.com"),
+ });
+ });
+
+ it("accepts slug ids and null removals but no id that is not a slug", () => {
+ expect(
+ decodeServerSettingsPatch({
+ secretProviders: { "1password": onePassword("my.1password.com"), work: null },
+ }).secretProviders,
+ ).toEqual({ "1password": onePassword("my.1password.com"), work: null });
+ for (const id of ["", "My Vault", "a/b", "-vault"]) {
+ expect(() =>
+ decodeServerSettingsPatch({ secretProviders: { [id]: onePassword("my.1password.com") } }),
+ ).toThrow();
+ }
+ expect(() =>
+ decodeServerSettingsPatch({
+ secretProviders: { work: { ...onePassword("my.1password.com"), label: "V".repeat(65) } },
+ }),
+ ).toThrow();
+ });
+
+ it("rejects a 1Password account op could misread", () => {
+ for (const account of ["", "my account", "--help"]) {
+ expect(() => decodeOnePasswordConfig({ account })).toThrow();
+ }
+ expect(decodeOnePasswordConfig({ account: "my.1password.com" }).account).toBe(
+ "my.1password.com",
+ );
+ });
+});
+
describe("custom model settings", () => {
const capabilities = {
optionDescriptors: [
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 16eb51aa176..1339a9322fa 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -859,6 +859,56 @@ export const UsageLimitSourceConfig = Schema.Struct({
});
export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type;
+// Final once shipped: a key or field that fails here fails the whole settings decode on older builds.
+// Unlike provider slugs it may start with a digit, so a provider named "1Password" fits.
+const SecretProviderSlug = TrimmedNonEmptyString.check(
+ Schema.isMaxLength(64),
+ Schema.isPattern(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),
+);
+
+export const SecretProviderId = SecretProviderSlug.pipe(Schema.brand("SecretProviderId"));
+export type SecretProviderId = typeof SecretProviderId.Type;
+
+export const SecretProviderKind = SecretProviderSlug.pipe(Schema.brand("SecretProviderKind"));
+export type SecretProviderKind = typeof SecretProviderKind.Type;
+
+const ONE_PASSWORD_ACCOUNT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
+
+/**
+ * Any value `op --account` accepts: shorthand, sign-in address, account ID, or user ID.
+ * It is passed to the CLI as an argument, so it can never start with `-`.
+ */
+export const OnePasswordAccount = Schema.String.check(
+ Schema.isMaxLength(253),
+ Schema.makeFilter((value: string) =>
+ ONE_PASSWORD_ACCOUNT_PATTERN.test(value)
+ ? true
+ : "1Password account must be a shorthand, sign-in address, or ID with no spaces.",
+ ),
+).pipe(Schema.brand("OnePasswordAccount"));
+export type OnePasswordAccount = typeof OnePasswordAccount.Type;
+
+export const SecretProviderLabel = TrimmedNonEmptyString.check(Schema.isMaxLength(64));
+
+export const OnePasswordSecretProviderConfig = Schema.Struct({
+ account: OnePasswordAccount,
+});
+export type OnePasswordSecretProviderConfig = typeof OnePasswordSecretProviderConfig.Type;
+
+/** Kinds decode their own config; unknown-kind envelopes round-trip verbatim across versions. */
+export const SecretProviderConfig = Schema.Struct({
+ kind: SecretProviderKind,
+ label: TrimmedNonEmptyString,
+ config: Schema.optionalKey(Schema.Unknown),
+});
+export type SecretProviderConfig = typeof SecretProviderConfig.Type;
+
+// Limits that may change later are enforced on writes only, never on the stored envelope.
+const SecretProviderConfigWrite = Schema.Struct({
+ ...SecretProviderConfig.fields,
+ label: SecretProviderLabel,
+});
+
export const SourceControlHostSettings = Schema.Record(Schema.String, Schema.Unknown);
export type SourceControlHostSettings = typeof SourceControlHostSettings.Type;
@@ -1313,6 +1363,9 @@ export const ServerSettings = Schema.Struct({
usageLimitSources: Schema.Record(UsageLimitSourceId, UsageLimitSourceConfig).pipe(
Schema.withDecodingDefault(Effect.succeed({})),
),
+ secretProviders: Schema.Record(SecretProviderId, SecretProviderConfig).pipe(
+ Schema.withDecodingDefault(Effect.succeed({})),
+ ),
cursorKeychainUsageEnabled: Schema.Boolean.pipe(
Schema.withDecodingDefault(Effect.succeed(false)),
),
@@ -1626,6 +1679,9 @@ export const ServerSettingsPatch = Schema.Struct({
usageLimitSources: Schema.optionalKey(
Schema.Record(UsageLimitSourceId, Schema.NullOr(UsageLimitSourceConfig)),
),
+ secretProviders: Schema.optionalKey(
+ Schema.Record(SecretProviderId, Schema.NullOr(SecretProviderConfigWrite)),
+ ),
cursorKeychainUsageEnabled: Schema.optionalKey(Schema.Boolean),
usagePriceOverrides: Schema.optionalKey(
@@ -1645,7 +1701,12 @@ export function requiredScopesForServerSettingsPatch(
let changesSettings = false;
for (const [key, value] of Object.entries(patch)) {
if (value === undefined) continue;
- if (key === "providers" || key === "providerInstances" || key === "usageLimitSources") {
+ if (
+ key === "providers" ||
+ key === "providerInstances" ||
+ key === "usageLimitSources" ||
+ key === "secretProviders"
+ ) {
changesProviders = true;
} else {
changesSettings = true;
diff --git a/packages/shared/src/serverSettings.test.ts b/packages/shared/src/serverSettings.test.ts
index f9a43b6123a..bd315271c78 100644
--- a/packages/shared/src/serverSettings.test.ts
+++ b/packages/shared/src/serverSettings.test.ts
@@ -1,8 +1,11 @@
import {
DEFAULT_SERVER_SETTINGS,
+ OnePasswordAccount,
ProjectId,
ProviderDriverKind,
ProviderInstanceId,
+ SecretProviderId,
+ SecretProviderKind,
UsageLimitSourceId,
type ServerProvider,
} from "@t3tools/contracts";
@@ -544,6 +547,28 @@ describe("serverSettings helpers", () => {
expect(Object.keys(removed.usageLimitSources)).toEqual([hubB]);
});
+ it("upserts and removes secretProviders per entry so concurrent edits cannot clobber", () => {
+ const personal = SecretProviderId.make("personal");
+ const work = SecretProviderId.make("work");
+ const onePassword = (label: string, account: string) => ({
+ kind: SecretProviderKind.make("one_password"),
+ label,
+ config: { account: OnePasswordAccount.make(account) },
+ });
+ const current = {
+ ...DEFAULT_SERVER_SETTINGS,
+ secretProviders: { [personal]: onePassword("Personal", "my.1password.com") },
+ };
+
+ const added = applyServerSettingsPatch(current, {
+ secretProviders: { [work]: onePassword("Work", "team.1password.com") },
+ });
+ expect(Object.keys(added.secretProviders)).toEqual([personal, work]);
+
+ const removed = applyServerSettingsPatch(added, { secretProviders: { [personal]: null } });
+ expect(Object.keys(removed.secretProviders)).toEqual([work]);
+ });
+
it("replaces and removes individual usage prices without clobbering other models", () => {
const prices = { inputCostPerMillionTokens: 2, outputCostPerMillionTokens: 8 };
const current = applyServerSettingsPatch(DEFAULT_SERVER_SETTINGS, {
diff --git a/packages/shared/src/serverSettings.ts b/packages/shared/src/serverSettings.ts
index e7c85607065..11eecc6fe3d 100644
--- a/packages/shared/src/serverSettings.ts
+++ b/packages/shared/src/serverSettings.ts
@@ -357,6 +357,7 @@ export function applyServerSettingsPatch(
worktreeCleanup: worktreeCleanupPatch,
// Merged per entry below; its `null` removals must not reach deepMerge.
usageLimitSources: usageLimitSourcesPatch,
+ secretProviders: secretProvidersPatch,
sourceControlHosts: sourceControlHostsPatch,
usagePriceOverrides: usagePriceOverridesPatch,
usageModelAliases: usageModelAliasesPatch,
@@ -554,6 +555,9 @@ export function applyServerSettingsPatch(
),
}
: {}),
+ ...(secretProvidersPatch !== undefined
+ ? { secretProviders: mergeSettingsEntries(current.secretProviders, secretProvidersPatch) }
+ : {}),
...(usagePriceOverridesPatch !== undefined
? {
usagePriceOverrides: mergeSettingsEntries(