Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(plugins): add plugin providers to Add Service

vastsa2cb61a50f064
diff --git a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts b/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts
index 37128b80b..39abaea4f 100644
--- a/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts
+++ b/apps/desktop/electron/main/ipc/plugin-ui-ipc.ts
@@ -10,6 +10,7 @@ import { PluginViewHost, pluginViewKey } from "../plugin-view-host";
import { PluginPanelHost } from "../plugin-panel-host";
import type { PluginPanelTheme } from "../../shared/plugin-panel-chrome";
import type { IpcRegistrar } from "./types";
+import { pluginProviderCatalogEntries } from "../plugin-provider-catalog";
export type PluginUiIpcDependencies = {
registrar: IpcRegistrar;
@@ -276,6 +277,13 @@ export function registerPluginUiIpc({
// how the app looks.
handle(IPC.invoke.pluginThemes, async () => plugins.getThemes());
+ // Add Service offers only API-key rows that are declared by a loaded plugin
+ // with the existing provider.register grant. The credential is still entered
+ // and stored by the Host's provider path.
+ handle(IPC.invoke.pluginProviderCatalog, async () =>
+ pluginProviderCatalogEntries(plugins.listLoaded(), getUpdaterLocale()),
+ );
+
// Resident service supervision state; refreshed on the pluginChanged event.
handle(IPC.invoke.pluginServices, async () => plugins.getServiceStates());
}
diff --git a/apps/desktop/electron/main/plugin-provider-catalog.ts b/apps/desktop/electron/main/plugin-provider-catalog.ts
new file mode 100644
index 000000000..a85e5102f
--- /dev/null
+++ b/apps/desktop/electron/main/plugin-provider-catalog.ts
@@ -0,0 +1,44 @@
+import type { PluginProviderCatalogMeta } from "@pi-desktop/shared";
+import {
+ resolvePluginLocalizedString,
+ type PluginManifest,
+} from "@pi-desktop/plugin-sdk";
+
+type PluginProviderCatalogSource = {
+ manifest: PluginManifest;
+ permissions: ReadonlySet<string>;
+};
+
+/** Resolve the static Add Service entries declared by currently loaded plugins. */
+export function pluginProviderCatalogEntries(
+ plugins: readonly PluginProviderCatalogSource[],
+ locale: string,
+): PluginProviderCatalogMeta[] {
+ const entries: PluginProviderCatalogMeta[] = [];
+ for (const plugin of plugins) {
+ if (!plugin.permissions.has("provider.register")) continue;
+ const providers = plugin.manifest.contributes?.providers ?? [];
+ for (const provider of providers) {
+ if ((provider.authKind ?? "api_key") !== "api_key" || !provider.baseUrl) continue;
+ entries.push({
+ pluginId: plugin.manifest.id,
+ providerId: `plugin:${plugin.manifest.id}:${provider.id}`,
+ pluginName: plugin.manifest.name,
+ category: resolvePluginLocalizedString(
+ provider.category,
+ locale,
+ plugin.manifest.name,
+ ),
+ ...(provider.description
+ ? { description: resolvePluginLocalizedString(provider.description, locale, "") }
+ : {}),
+ });
+ }
+ }
+ return entries.sort(
+ (a, b) =>
+ a.category.localeCompare(b.category) ||
+ a.pluginName.localeCompare(b.pluginName) ||
+ a.providerId.localeCompare(b.providerId),
+ );
+}
diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsx
index 0d95754e0..5811e88b9 100644
--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx
+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx
@@ -93,6 +93,10 @@ export function ModelConfigPage() {
// null = closed, "" = add flow, provider id = edit flow.
const [copyDraft, setCopyDraft] = useState<ProviderCopyDraft | null>(null);
const [setupFor, setSetupFor] = useState<string | null>(null);
+ const [pluginCatalogSetup, setPluginCatalogSetup] = useState<{
+ providerId: string;
+ pluginName: string;
+ } | null>(null);
// The Jev card opens the same dialog, straight on the Jev service.
const [jevSetup, setJevSetup] = useState(false);
@@ -169,10 +173,30 @@ export function ModelConfigPage() {
settings.defaultProviderId === saved.id && firstModelId &&
!models.some((model) => sameWireId(model.id, settings.defaultModelId ?? "") &&
!selectedImageIds.some((id) => sameWireId(id, model.id)))
- ? firstModelId
- : undefined;
+ ? firstModelId
+ : undefined;
try {
- if (imageModelIds !== undefined) {
+ if (pluginCatalogSetup?.providerId === saved.id) {
+ const defaultsProviders = [...providers.filter((provider) => provider.id !== saved.id), saved];
+ const currentDefault = defaultsProviders.find(
+ (provider) => provider.id === settings.defaultProviderId,
+ );
+ const keepsCurrentDefault = !!currentDefault &&
+ providerServesChatModels(currentDefault, imageGenerationCandidates) &&
+ chatModelOptions([currentDefault], imageGenerationCandidates).some(
+ ({ modelId }) => sameWireId(modelId, settings.defaultModelId ?? ""),
+ );
+ if (!keepsCurrentDefault && firstModelId) {
+ const nextSettings = {
+ ...settings,
+ defaultProviderId: saved.id,
+ defaultModelId: firstModelId,
+ };
+ await api.setSettings(nextSettings);
+ useAppStore.setState({ settings: nextSettings });
+ }
+ showToast(t("settings.pluginProviderKeySaved"), { variant: "success" });
+ } else if (imageModelIds !== undefined) {
const current = await api.getSettings();
const plan = planImageGenerationDefaults(
current,
@@ -220,6 +244,7 @@ export function ModelConfigPage() {
}
setSetupFor(null);
setCopyDraft(null);
+ setPluginCatalogSetup(null);
await refreshProviders();
} catch (error) {
showToast(error instanceof Error ? error.message : String(error), {
@@ -524,12 +549,16 @@ export function ModelConfigPage() {
{setupFor !== null ? (
<ProviderSetupDialog
+ key={setupFor}
provider={editingProvider}
+ pluginCatalogSetup={pluginCatalogSetup?.providerId === editingProvider?.id}
+ pluginCatalogPluginName={pluginCatalogSetup?.pluginName}
initialDraft={copyDraft}
initialService={jevSetup ? JEV_SERVICE : undefined}
onClose={() => {
setSetupFor(null);
setCopyDraft(null);
+ setPluginCatalogSetup(null);
setJevSetup(false);
}}
imageModelIds={editingProvider
@@ -549,10 +578,17 @@ export function ModelConfigPage() {
onPickSubscription={(vendor) => {
setSetupFor(null);
setCopyDraft(null);
+ setPluginCatalogSetup(null);
// Started here, not in the dialog: a click happens once, where
// StrictMode would run a mount effect twice and open two browsers.
startLogin(vendor);
}}
+ onPickPluginProvider={(providerId, pluginName) => {
+ setPluginCatalogSetup({ providerId, pluginName });
+ setCopyDraft(null);
+ setJevSetup(false);
+ setSetupFor(providerId);
+ }}
/>
) : null}
diff --git a/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx b/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx
new file mode 100644
index 000000000..38eb47443
--- /dev/null
+++ b/apps/desktop/src/components/settings/PluginProviderKeySetupForm.tsx
@@ -0,0 +1,122 @@
+/** Host-owned API-key setup for a provider selected from a plugin catalog. */
+import { useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { bindingFromModelInfo, normalizeApiStyle, type ProviderPublic } from "@pi-desktop/shared";
+import { api } from "../../lib/api";
+import { useAppStore } from "../../stores/app-store";
+import { Button } from "../ui";
+import { ProviderConnectionFields } from "./ProviderConnectionFields";
+
+export type PluginProviderKeySetupFormProps = {
+ provider: ProviderPublic;
+ pluginName: string;
+ onClose: () => void;
+ onSaved: (provider: ProviderPublic) => void | Promise<void>;
+};
+
+export function PluginProviderKeySetupForm({
+ provider,
+ pluginName,
+ onClose,
+ onSaved,
+}: PluginProviderKeySetupFormProps) {
+ const { t } = useTranslation();
+ const [apiKey, setApiKey] = useState("");
+ const [saving, setSaving] = useState(false);
+ const showToast = useAppStore((state) => state.showToast);
+ const apiKeyRef = useRef<HTMLInputElement>(null);
+ const nameRef = useRef<HTMLInputElement>(null);
+
+ const save = async () => {
+ if (!apiKey.trim() || saving) return;
+ setSaving(true);
+ try {
+ const result = await api.setProviderSecret({ id: provider.id, secretValue: apiKey });
+ if (!result.provider) {
+ showToast(t("settings.providerUnavailable"), { variant: "error" });
+ return;
+ }
+ let savedProvider = result.provider;
+ let modelDiscoveryMessage: string | null = null;
+ try {
+ const discovery = await api.listProviderModels({
+ providerId: provider.id,
+ source: "refresh",
+ });
+ if (discovery.source === "remote" && discovery.models.length > 0) {
+ savedProvider = {
+ ...savedProvider,
+ models: discovery.models.map(bindingFromModelInfo),
+ };
+ } else {
+ modelDiscoveryMessage = t("settings.modelsFetchNotFound");
+ }
+ } catch {
+ modelDiscoveryMessage = t("settings.modelsFetchFailed");
+ }
+ await onSaved(savedProvider);
+ if (modelDiscoveryMessage) {
+ showToast(modelDiscoveryMessage, { variant: "warning" });
+ }
+ } catch (error) {
+ showToast(error instanceof Error ? error.message : String(error), {
+ variant: "error",
+ });
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <>
+ <div className="provider-setup-head">
+ <h3 id="provider-setup-title" className="provider-setup-title">
+ {t("settings.addProviderTitle")}
+ </h3>
+ <div className="provider-setup-head-actions">
+ <Button variant="ghost" size="sm" disabled={saving} onClick={onClose}>
+ {t("settings.cancel")}
+ </Button>
+ <Button
+ variant="primary"
+ size="sm"
+ disabled={saving || !apiKey.trim()}
+ onClick={() => void save()}
+ >
+ {saving ? t("settings.saving") : t("settings.saveProvider")}
+ </Button>
+ </div>
+ </div>
+
+ <div className="provider-setup-body">
+ <div className="text-sm text-text-secondary">
+ {t("settings.pluginProviderBy", { plugin: pluginName })}
+ </div>
+ <ProviderConnectionFields
+ named
+ custom={false}
+ editing={false}
+ saving={saving}
+ serviceLabel={provider.name}
+ serviceBaseUrl={provider.baseUrl ?? ""}
+ apiKeyHint={t("settings.pluginProviderKeyHint")}
+ lockedService
+ onChangeService={() => {}}
+ apiKeyRef={apiKeyRef}
+ nameRef={nameRef}
+ apiKey={apiKey}
+ onApiKeyChange={setApiKey}
+ name={provider.name}
+ onNameChange={() => {}}
+ baseUrl={provider.baseUrl ?? ""}
+ onBaseUrlChange={() => {}}
+ commitBaseUrl={() => {}}
+ apiStyle={normalizeApiStyle(provider.apiStyle)}
+ onApiStyleChange={() => {}}
+ accountOnlyApiStyle={false}
+ requiresApiStyleChoice={false}
+ />
+ </div>
+ </>
+ );
+}
diff --git a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
index 9072f474a..5b3e81f9f 100644
--- a/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
+++ b/apps/desktop/src/components/settings/ProviderConnectionFields.tsx
@@ -22,8 +22,12 @@ export type ProviderConnectionFieldsProps = {
editing: boolean;
saving: boolean;
serviceLabel: string;
+ /** Optional hint for a key that belongs to a Host-owned plugin row. */
+ apiKeyHint?: string;
/** Endpoint the named preset talks to; empty on a custom endpoint. */
serviceBaseUrl: string;
+ /** Hides service switching when the manifest owns this provider row. */
+ lockedService?: boolean;
onChangeService: () => void;
apiKeyRef: RefObject<HTMLInputElement | null>;
nameRef: RefObject<HTMLInputElement | null>;
@@ -49,7 +53,9 @@ export function ProviderConnectionFields({
editing,
saving,
serviceLabel,
+ apiKeyHint,
serviceBaseUrl,
+ lockedService = false,
onChangeService,
apiKeyRef,
nameRef,
@@ -90,20 +96,22 @@ export function ProviderConnectionFields({
</span>
) : null}
</span>
- <button
- type="button"
- className="provider-service-chip-change"
- disabled={saving}
- onClick={onChangeService}
- >
- {t("settings.changeService")}
- </button>
+ {!lockedService ? (
+ <button
+ type="button"
+ className="provider-service-chip-change"
+ disabled={saving}
+ onClick={onChangeService}
+ >
+ {t("settings.changeService")}
+ </button>
+ ) : null}
</div>
</div>
{named ? (
<div className="provider-setup-key">
- <Field label={t("settings.apiKey")} hint={keyHint}>
+ <Field label={t("settings.apiKey")} hint={apiKeyHint ?? keyHint}>
<Input
ref={apiKeyRef}
type="password"
diff --git a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
index c28d5b40b..169660092 100644
--- a/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
+++ b/apps/desktop/src/components/settings/ProviderSetupDialog.tsx
@@ -14,6 +14,7 @@ import {
NAMED_ENDPOINT_PRESETS,
OPENCODE_GO_API_STYLE,
normalizeApiStyle,
+ type PluginProviderCatalogMeta,
type CatalogApiStyle,
type ModelBinding,
type OAuthVendor,
@@ -29,7 +30,13 @@ import { ModelSelectionPanes, useModelSelection } from "./ModelSelectionPanes";
import { ProviderConnectionFields } from "./ProviderConnectionFields";
import { useProbeFeedback } from "./useProbeFeedback";
import { ServiceChooser } from "./ServiceChooser";
-import { CUSTOM_SERVICE, JEV_SERVICE } from "./service-catalog";
+import { PluginProviderKeySetupForm } from "./PluginProviderKeySetupForm";
+import {
+ CUSTOM_SERVICE,
+ JEV_SERVICE,
+ pluginProviderServiceOptions,
+ type PluginProviderServiceOption,
+} from "./service-catalog";
import { JevServiceForm } from "./JevServiceForm";
import { useRecommendedModelSelection } from "./useRecommendedModelSelection";
import type { ProviderCopyDraft } from "./provider-copy";
@@ -92,6 +99,11 @@ export type ProviderSetupDialogProps = {
initialService?: string | null;
/** Jev was configured from inside this dialog. */
onJevConfigured?: () => void;
+ /** Chooses an existing API-key provider contributed by a plugin. */
+ onPickPluginProvider?: (providerId: string, pluginName: string) => void;
+ /** The dialog is configuring a row selected from the plugin catalog. */
+ pluginCatalogSetup?: boolean;
+ pluginCatalogPluginName?: string;
};
export function ProviderSetupDialog({
@@ -104,6 +116,9 @@ export function ProviderSetupDialog({
onPickSubscription,
initialService,
onJevConfigured,
+ onPickPluginProvider,
+ pluginCatalogSetup = false,
+ pluginCatalogPluginName,
}: ProviderSetupDialogProps) {
const { t } = useTranslation();
const [imageModelDraft, setImageModelDraft] = useState<string[] | undefined>();
@@ -124,12 +139,36 @@ export function ProviderSetupDialog({
const [saving, setSaving] = useState(false);
const [testing, setTesting] = useState(false);
const showToast = useAppStore((state) => state.showToast);
+ const providerRows = useAppStore((state) => state.providers);
+ const [pluginProviderCatalog, setPluginProviderCatalog] = useState<PluginProviderCatalogMeta[]>([]);
const [baseUrlTouched, setBaseUrlTouched] = useState(false);
// A format the user picked by hand outranks every inference about this row.
const [apiStyleTouched, setApiStyleTouched] = useState(false);
const [choosing, setChoosing] = useState(false);
const chooserOpen = choosing || !service;
+ useEffect(() => {
+ if (editing || !chooserOpen) return;
+ let current = true;
+ void api.listPluginProviderCatalog().then((entries) => {
+ if (current) setPluginProviderCatalog(entries);
+ }).catch((error) => {
+ if (current) {
+ showToast(error instanceof Error ? error.message : String(error), {
+ variant: "error",
+ });
+ }
+ });
+ return () => {
+ current = false;
+ };
+ }, [chooserOpen, editing, showToast]);
+
+ const pluginProviderOptions: PluginProviderServiceOption[] = pluginProviderServiceOptions(
+ pluginProviderCatalog,
+ providerRows,
+ );
+
const namedPreset = NAMED_ENDPOINT_PRESETS.find((preset) => preset.id === service);
const named = Boolean(namedPreset);
const custom = service === CUSTOM_SERVICE;
@@ -166,6 +205,7 @@ export function ProviderSetupDialog({
// Named add-path waits for a key so picking a vendor does not 401-probe.
// Editing reuses the stored secret. Custom still probes a valid URL alone.
const discoveryActive =
+ !pluginCatalogSetup &&
Boolean(service) &&
!requiresApiStyleChoice &&
!baseUrlIssue &&
@@ -529,6 +569,8 @@ export function ProviderSetupDialog({
onPickService={pickService}
onPickSubscription={editing ? undefined : onPickSubscription}
showClassifiers={!editing}
+ pluginProviders={editing ? [] : pluginProviderOptions}
+ onPickPluginProvider={editing ? undefined : onPickPluginProvider}
/>
</>
);
@@ -558,7 +600,23 @@ export function ProviderSetupDialog({
aria-labelledby="provider-setup-title"
onClick={(event) => event.stopPropagation()}
>
- {chooserOpen ? chooserView : jevService ? jevView : formView}
+ {chooserOpen ? chooserView : pluginCatalogSetup ? (
+ provider ? (
+ <PluginProviderKeySetupForm
+ provider={provider}
+ pluginName={pluginCatalogPluginName ?? provider.ownerPluginId ?? ""}
+ onClose={onClose}
+ onSaved={(saved) => onSaved(saved, saved.models)}
+ />
+ ) : (
+ <div className="provider-setup-body">
+ <p role="alert">{t("settings.providerUnavailable")}</p>
+ <Button variant="ghost" size="sm" onClick={onClose}>
+ {t("settings.cancel")}
+ </Button>
+ </div>
+ )
+ ) : jevService ? jevView : formView}
</div>
{advancedOpen && (named || custom) ? (
diff --git a/apps/desktop/src/components/settings/ServiceChooser.tsx b/apps/desktop/src/components/settings/ServiceChooser.tsx
index 14856be04..22fa0f4c4 100644
--- a/apps/desktop/src/components/settings/ServiceChooser.tsx
+++ b/apps/desktop/src/components/settings/ServiceChooser.tsx
@@ -12,7 +12,7 @@
import { useMemo, useRef, useState, type KeyboardEvent } from "react";
import { useTranslation } from "react-i18next";
import type { OAuthVendor } from "@pi-desktop/shared";
-import { cx, Input } from "../ui";
+import { cx, Input, TooltipButton } from "../ui";
import { IconPlus, IconSearch } from "../icons";
import { ServiceMonogram } from "./ServiceMonogram";
import {
@@ -21,6 +21,7 @@ import {
filterServiceOptions,
jevServiceOption,
namedServiceOptions,
+ type PluginProviderServiceOption,
} from "./service-catalog";
export type ServiceChooserProps = {
@@ -33,6 +34,10 @@ export type ServiceChooserProps = {
onPickSubscription?: (vendor: OAuthVendor) => void;
/** Offers the classifier group; a new service, never an existing row. */
showClassifiers?: boolean;
+ /** API-key providers contributed by enabled plugins, grouped by category. */
+ pluginProviders?: readonly PluginProviderServiceOption[];
+ /** Selects an existing plugin-owned provider row for key setup. */
+ onPickPluginProvider?: (providerId: string, pluginName: string) => void;
};
type SubscriptionOption = { vendor: OAuthVendor; haystack: string };
@@ -46,6 +51,8 @@ export function ServiceChooser({
onPickService,
onPickSubscription,
showClassifiers = false,
+ pluginProviders = [],
+ onPickPluginProvider,
}: ServiceChooserProps) {
const { t } = useTranslation();
const [query, setQuery] = useState("");
@@ -87,17 +94,33 @@ export function ServiceChooser({
() => filterServiceOptions(classifierOptions, query),
[classifierOptions, query],
);
+ const visiblePluginProviders = useMemo(
+ () => filterServiceOptions(pluginProviders, query),
+ [pluginProviders, query],
+ );
+ const pluginProviderGroups = useMemo(() => {
+ const groups = new Map<string, PluginProviderServiceOption[]>();
+ for (const option of visiblePluginProviders) {
+ const group = groups.get(option.category) ?? [];
+ group.push(option);
+ groups.set(option.category, group);
+ }
+ return [...groups].map(([category, options]) => ({ category, options }));
+ }, [visiblePluginProviders]);
const nothingMatches =
visibleServices.length === 0 &&
visibleSubscriptions.length === 0 &&
- visibleClassifiers.length === 0;
+ visibleClassifiers.length === 0 &&
+ visiblePluginProviders.length === 0;
// Enter prefers a service the pick only moves to the key field for: the
// classifier keeps the same dialog, while a subscription leaves it.
const enterTarget = query.trim()
? visibleServices[0]
? `service:${visibleServices[0].id}`
- : visibleClassifiers[0]
+ : visiblePluginProviders[0]
+ ? `plugin:${visiblePluginProviders[0].id}`
+ : visibleClassifiers[0]
? `service:${visibleClassifiers[0].id}`
: visibleSubscriptions[0]
? `subscription:${visibleSubscriptions[0].vendor.vendorId}`
@@ -107,12 +130,17 @@ export function ServiceChooser({
const pickService = (id: string) => {
if (!disabled) onPickService(id);
};
+ const pickPluginProvider = (providerId: string) => {
+ const option = visiblePluginProviders.find((candidate) => candidate.id === providerId);
+ if (!disabled && option) onPickPluginProvider?.(providerId, option.pluginName);
+ };
const pickSubscription = (vendor: OAuthVendor) => {
if (!disabled) onPickSubscription?.(vendor);
};
const pickEnterTarget = () => {
if (visibleServices[0]) pickService(visibleServices[0].id);
+ else if (visiblePluginProviders[0]) pickPluginProvider(visiblePluginProviders[0].id);
else if (visibleClassifiers[0]) pickService(visibleClassifiers[0].id);
else if (visibleSubscriptions[0]) pickSubscription(visibleSubscriptions[0].vendor);
else pickService(CUSTOM_SERVICE);
@@ -287,6 +315,48 @@ export function ServiceChooser({
</section>
) : null}
+ {pluginProviderGroups.map(({ category, options }, index) => (
+ <section
+ key={`${category}-${index}`}
+ className="service-chooser-group"
+ aria-labelledby={`service-chooser-plugin-category-${index}`}
+ data-plugin-provider-category={category}
+ >
+ <h4
+ id={`service-chooser-plugin-category-${index}`}
+ className="service-chooser-group-title"
+ >
+ {category}
+ </h4>
+ <div className="service-chooser-grid">
+ {options.map((option) => (
+ <TooltipButton
+ key={option.id}
+ type="button"
+ data-service-tile
+ data-plugin-provider-id={option.id}
+ tooltip={option.description}
+ tooltipClassName="ui-tooltip-help"
+ ariaLabel={option.label}
+ aria-description={option.description || undefined}
+ className={cx(
+ "service-chooser-tile",
+ enterTarget === `plugin:${option.id}` && "is-active",
+ )}
+ disabled={disabled || !onPickPluginProvider}
+ onKeyDown={onTileKeyDown}
+ onClick={() => pickPluginProvider(option.id)}
+ >
+ <ServiceMonogram name={option.label} />
+ <span className="service-chooser-tile-copy">
+ <span className="service-chooser-tile-name">{option.label}</span>
+ </span>
+ </TooltipButton>
+ ))}
+ </div>
+ </section>
+ ))}
+
{visibleClassifiers.length > 0 ? (
<section className="service-chooser-group" aria-labelledby="service-chooser-classifiers">
<h4 id="service-chooser-classifiers" className="service-chooser-group-title">
diff --git a/apps/desktop/src/components/settings/service-catalog.ts b/apps/desktop/src/components/settings/service-catalog.ts
index b0eeb8a51..96057279a 100644
--- a/apps/desktop/src/components/settings/service-catalog.ts
+++ b/apps/desktop/src/components/settings/service-catalog.ts
@@ -8,6 +8,8 @@
import {
NAMED_ENDPOINT_PRESETS,
TYPESAFE_SYSTEM_ONE_URL,
+ type PluginProviderCatalogMeta,
+ type ProviderPublic,
type NamedEndpointPreset,
} from "@pi-desktop/shared";
@@ -30,6 +32,13 @@ export type ServiceOption = {
haystack: string;
};
+/** A declared API-key provider shown in the plugin's Add Service category. */
+export type PluginProviderServiceOption = ServiceOption & {
+ category: string;
+ pluginName: string;
+ description: string;
+};
+
export function endpointLabel(url: string): string {
try {
const parsed = new URL(url);
@@ -93,3 +102,52 @@ export function jevServiceOption(translate: Translate): ServiceOption {
`${label} jev typesafe classifier ${endpoint} ${TYPESAFE_SYSTEM_ONE_URL}`.toLowerCase(),
};
}
+
+/**
+ * Resolve catalog declarations to their Host-owned provider rows. Rows with a
+ * stored key are already configured and stay in the provider list rather than
+ * being offered as a second add action.
+ */
+export function pluginProviderServiceOptions(
+ declarations: readonly PluginProviderCatalogMeta[],
+ providers: readonly ProviderPublic[],
+): PluginProviderServiceOption[] {
+ const rowsById = new Map(providers.map((provider) => [provider.id, provider]));
+ return declarations.flatMap((declaration) => {
+ const provider = rowsById.get(declaration.providerId);
+ if (
+ !provider ||
+ provider.ownerPluginId !== declaration.pluginId ||
+ !provider.enabled ||
+ provider.authKind !== "api_key" ||
+ provider.hasSecret ||
+ !provider.baseUrl
+ ) {
+ return [];
+ }
+ const endpoint = endpointLabel(provider.baseUrl);
+ const models = provider.models.map((model) => `${model.id} ${model.alias ?? ""}`).join(" ");
+ return [{
+ id: provider.id,
+ label: provider.name,
+ endpoint: `${endpoint} · ${declaration.pluginName}`,
+ category: declaration.category.trim() || declaration.pluginName,
+ pluginName: declaration.pluginName,
+ description: declaration.description ?? "",
+ haystack: [
+ provider.name,
+ provider.id,
+ provider.baseUrl,
+ endpoint,
+ declaration.category,
+ declaration.pluginName,
+ declaration.description ?? "",
+ models,
+ ].join(" ").toLowerCase(),
+ }];
+ }).sort((a, b) =>
+ a.category.localeCompare(b.category) ||
+ a.label.localeCompare(b.label) ||
+ a.pluginName.localeCompare(b.pluginName),
+ );
+}
diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.ts
index 128356947..26da9d526 100644
--- a/apps/desktop/src/lib/api.ts
+++ b/apps/desktop/src/lib/api.ts
@@ -62,6 +62,7 @@ import type {
PluginPermissionReview,
PluginSettingDefinition,
PluginServiceStatus,
+ PluginProviderCatalogMeta,
PluginViewMeta,
PluginScenicThemesDestinationMeta,
PluginTheme,
@@ -1271,6 +1272,8 @@ export const api = {
togglePluginLauncher: () => invoke(IPC.invoke.pluginLauncherToggle),
dismissPluginLauncher: () => invoke(IPC.invoke.pluginLauncherDismiss),
listPluginThemes: () => invoke<PluginTheme[]>(IPC.invoke.pluginThemes),
+ listPluginProviderCatalog: () =>
+ invoke<PluginProviderCatalogMeta[]>(IPC.invoke.pluginProviderCatalog),
listPluginScenicThemesDestinations: () => invoke<PluginScenicThemesDestinationMeta[]>(IPC.invoke.pluginScenicThemesDestinations),
setPluginScenicThemeBlur: (pluginId: string, themeId: string, blur: number) => invoke(IPC.invoke.pluginScenicThemesSetBlur, { pluginId, themeId, blur }),
listPluginServices: () => invoke<PluginServiceStatus[]>(IPC.invoke.pluginServices),
diff --git a/apps/desktop/test/plugin-provider-catalog-ipc.test.mjs b/apps/desktop/test/plugin-provider-catalog-ipc.test.mjs
new file mode 100644
index 000000000..34fc89ce3
--- /dev/null
+++ b/apps/desktop/test/plugin-provider-catalog-ipc.test.mjs
@@ -0,0 +1,92 @@
+import assert from "node:assert/strict";
+import * as fs from "node:fs";
+import test from "node:test";
+import ts from "typescript";
+import { IPC } from "../../../packages/shared/src/protocol.ts";
+import { pluginProviderCatalogEntries } from "../electron/main/plugin-provider-catalog.ts";
+
+/** Load the real main-process registration function with unrelated hosts stubbed. */
+function loadPluginUiIpc() {
+ const file = new URL("../electron/main/ipc/plugin-ui-ipc.ts", import.meta.url);
+ const { outputText } = ts.transpileModule(fs.readFileSync(file, "utf8"), {
+ compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS },
+ fileName: file.pathname,
+ });
+ const module = { exports: {} };
+ const dependencies = {
+ "node:fs": { existsSync: () => true },
+ "node:path": { join: (...parts) => parts.join("/") },
+ "@pi-desktop/shared": { IPC },
+ "@pi-desktop/plugin-sdk": {
+ normalizeThemeAssetPath: (path) => path,
+ pluginThemeId: (...parts) => parts.join(":"),
+ resolvePluginLocalizedString: (value) => value,
+ themeAssetUrl: (value) => value,
+ },
+ "../browser-host": { BROWSER_PLUGIN_ID: "pi.browser", BROWSER_VIEW_ID: "browser" },
+ "../plugin-runtime": { resolveInsidePlugin: () => "/plugin/index.html" },
+ "../plugin-view-host": { pluginViewKey: (...parts) => parts.join("/") },
+ "../plugin-panel-host": {},
+ "../plugin-provider-catalog": { pluginProviderCatalogEntries },
+ };
+ new Function("require", "exports", "module", outputText)(
+ (id) => {
+ assert.ok(Object.hasOwn(dependencies, id), `unexpected plugin UI dependency: ${id}`);
+ return dependencies[id];
+ },
+ module.exports,
+ module,
+ );
+ return module.exports.registerPluginUiIpc;
+}
+
+test("the plugin Add Service IPC returns declared categories through the Host handler", async () => {
+ const handlers = new Map();
+ const plugin = (id, name, permissions, category) => ({
+ permissions: new Set(permissions),
+ manifest: {
+ id,
+ name,
+ contributes: {
+ providers: [{
+ id: "primary",
+ name: "Primary",
+ baseUrl: "https://api.example/v1",
+ category,
+ description: { en: "A short English introduction.", "zh-CN": "一句话中文简介。" },
+ models: [{ id: "model-1" }],
+ }],
+ },
+ },
+ });
+
+ loadPluginUiIpc()({
+ registrar: { handle: (channel, handler) => handlers.set(channel, handler) },
+ plugins: {
+ listLoaded: () => [
+ plugin("community.sites", "Community Sites", ["provider.register"], {
+ en: "Community API Sites",
+ "zh-CN": "公益站",
+ }),
+ plugin("unapproved.sites", "Unapproved", [], "Hidden"),
+ ],
+ },
+ browserHost: {},
+ pluginViews: {},
+ pluginPanels: {},
+ pluginActiveInProject: () => true,
+ currentWorkspacePath: () => null,
+ getUpdaterLocale: () => "zh-CN",
+ getPluginPanelTheme: () => ({}),
+ });
+
+ const handler = handlers.get(IPC.invoke.pluginProviderCatalog);
+ assert.equal(typeof handler, "function", "Add Service metadata IPC handler is registered");
+ assert.deepEqual(await handler(), [{
+ pluginId: "community.sites",
+ providerId: "plugin:community.sites:primary",
+ pluginName: "Community Sites",
+ category: "公益站",
+ description: "一句话中文简介。",
+ }]);
+});
diff --git a/apps/desktop/test/plugin-provider-catalog-user-path.test.mjs b/apps/desktop/test/plugin-provider-catalog-user-path.test.mjs
new file mode 100644
index 000000000..b5c3957ec
--- /dev/null
+++ b/apps/desktop/test/plugin-provider-catalog-user-path.test.mjs
@@ -0,0 +1,300 @@
+/** Add a Host-owned plugin provider from its custom category in Add Service. */
+import assert from "node:assert/strict";
+import { spawn } from "node:child_process";
+import { createRequire } from "node:module";
+import { mkdtemp, rm, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+import test from "node:test";
+import { repositoryRoot, resolveElectronBinary } from "../../../scripts/e2e/boot.mjs";
+
+const root = repositoryRoot();
+const { build } = createRequire(join(root, "packages/agent-runtime/package.json"))("esbuild");
+
+const fixtureSource = String.raw`
+import React from "react";
+import { createRoot } from "react-dom/client";
+import { flushSync } from "react-dom";
+import i18n from "i18next";
+import { initReactI18next } from "react-i18next";
+import { catalogs, flattenCatalog } from "@pi-desktop/i18n";
+import { ProviderSetupDialog } from "../../apps/desktop/src/components/settings/ProviderSetupDialog";
+import { useAppStore } from "../../apps/desktop/src/stores/app-store";
+
+const calls = [];
+window.addEventListener("error", (event) => {
+ console.error("PLUGIN_PROVIDER_CATALOG_WINDOW_ERROR", event.error?.stack ?? event.message);
+});
+window.addEventListener("unhandledrejection", (event) => {
+ console.error("PLUGIN_PROVIDER_CATALOG_REJECTION", event.reason?.stack ?? event.reason);
+});
+const providerId = "plugin:community.ai-sites:demo";
+const remainingProviderId = "plugin:community.ai-sites:second";
+let saved = false;
+let providers = [{
+ id: providerId,
+ name: "Community Demo",
+ vendorKey: "custom",
+ type: "openai_compatible",
+ protocol: "openai_compatible",
+ enabled: true,
+ baseUrl: "https://api.example.org/v1",
+ authKind: "api_key",
+ hasSecret: false,
+ models: [],
+ supportsReasoning: false,
+ supportedThinkingLevels: [],
+ ownerPluginId: "community.ai-sites",
+ createdAt: "2026-10-08T00:00:00.000Z",
+ updatedAt: "2026-10-08T00:00:00.000Z",
+}];
+providers.push({
+ ...providers[0],
+ id: remainingProviderId,
+ name: "Community Second",
+ baseUrl: "https://second.example.org/v1",
+ models: [],
+});
+
+window.piDesktop = {
+ platform: "darwin",
+ on() { return () => {}; },
+ async invoke(channel, ...args) {
+ const input = args[0];
+ calls.push({ channel, input });
+ if (channel === "pi-desktop/plugin/providerCatalog") {
+ return { ok: true, data: [{
+ pluginId: "community.ai-sites",
+ providerId,
+ pluginName: "PI Community AI Sites",
+ category: "公益 AI 站",
+ description: "通过签到获取额度的公益 API 服务。",
+ }, {
+ pluginId: "community.ai-sites",
+ providerId: remainingProviderId,
+ pluginName: "PI Community AI Sites",
+ category: "公益 AI 站",
+ description: "面向社区用户开放的模型 API 服务。",
+ }] };
+ }
+ if (channel === "pi-desktop/providers/setSecret") {
+ if (input.id !== providerId) throw new Error("wrong provider row");
+ providers = providers.map((provider) => provider.id === providerId
+ ? { ...provider, hasSecret: true }
+ : provider);
+ useAppStore.setState({ providers });
+ return { ok: true, data: { provider: providers[0] } };
+ }
+ if (channel === "pi-desktop/providers/listModels") {
+ if (input.providerId !== providerId || input.source !== "refresh") {
+ throw new Error("model discovery must follow saving the selected key");
+ }
+ return { ok: true, data: { models: [{
+ modelId: "demo-chat",
+ displayName: "Demo Chat",
+ providerId,
+ capabilities: ["text"],
+ contextWindow: 128000,
+ maxTokens: 8192,
+ source: "discovered",
+ }], source: "remote" } };
+ }
+ throw new Error("Unexpected fixture IPC: " + channel);
+ },
+};
+
+await i18n.use(initReactI18next).init({
+ lng: "en",
+ fallbackLng: "en",
+ keySeparator: false,
+ resources: { en: { translation: flattenCatalog(catalogs.en) } },
+ interpolation: { escapeValue: false },
+});
+useAppStore.setState({ providers });
+
+const frame = () => new Promise(requestAnimationFrame);
+async function settle() { await frame(); await frame(); }
+async function waitFor(predicate, message) {
+ for (let attempt = 0; attempt < 120; attempt += 1) {
+ await settle();
+ const value = predicate();
+ if (value) return value;
+ }
+ throw new Error(message);
+}
+function setValue(input, value) {
+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
+ setter.call(input, value);
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+}
+
+const rootNode = createRoot(document.getElementById("root"));
+function mount(element) { flushSync(() => rootNode.render(element)); }
+
+function PluginCatalogSurface() {
+ const [selected, setSelected] = React.useState(null);
+ const provider = selected ? providers.find((row) => row.id === selected.providerId) ?? null : null;
+ return React.createElement(ProviderSetupDialog, {
+ key: selected?.providerId ?? "add",
+ provider,
+ pluginCatalogSetup: !!selected,
+ pluginCatalogPluginName: selected?.pluginName,
+ onClose: () => mount(null),
+ onSaved: () => { saved = true; mount(null); },
+ onPickPluginProvider: (providerId, pluginName) => setSelected({ providerId, pluginName }),
+ });
+}
+
+window.pluginProviderCatalogProbe = async () => {
+ mount(React.createElement(PluginCatalogSurface));
+ const category = await waitFor(
+ () => document.querySelector('[data-plugin-provider-category="公益 AI 站"]'),
+ "the plugin's declared category was not shown",
+ );
+ const tile = document.querySelector('[data-plugin-provider-id="' + providerId + '"]');
+ if (!tile) throw new Error("the declared API-key provider tile was not shown");
+ const publisherShown = tile.textContent.includes("PI Community AI Sites");
+ const tileEndpointShown = tile.textContent.includes("api.example.org/v1");
+ const access = tile.getAttribute("aria-label");
+ tile.dispatchEvent(new PointerEvent("pointerover", { bubbles: true, pointerType: "mouse" }));
+ const tooltip = await waitFor(
+ () => document.querySelector('[role="tooltip"]'),
+ "hovering a station did not show its introduction",
+ );
+ const introductionShown = tooltip.textContent === "通过签到获取额度的公益 API 服务。";
+ flushSync(() => tile.click());
+
+ const input = await waitFor(
+ () => document.querySelector('input[type="password"]'),
+ "selecting a plugin provider did not open its key form",
+ );
+ const endpointShown = document.documentElement.innerText.includes("api.example.org/v1");
+ setValue(input, "community-key-fixture");
+ await settle();
+ const saveButton = [...document.querySelectorAll("button")]
+ .find((button) => button.textContent.trim() === "Save provider");
+ if (!saveButton) throw new Error("the key form save action was missing");
+ flushSync(() => saveButton.click());
+ await waitFor(() => saved, "the provider key was not saved through the Host API");
+
+ const secretCall = calls.find((call) => call.channel === "pi-desktop/providers/setSecret");
+ const modelCall = calls.find((call) => call.channel === "pi-desktop/providers/listModels");
+ mount(React.createElement(PluginCatalogSurface));
+ const remainingTile = await waitFor(
+ () => document.querySelector('[data-plugin-provider-id="' + remainingProviderId + '"]'),
+ "saving one key hid another unconfigured provider",
+ );
+ return {
+ categoryShown: !!category,
+ publisherShown,
+ tileEndpointShown,
+ introductionShown,
+ tileAccessibleName: access,
+ endpointShown,
+ saved,
+ modelsDiscoveredAfterSavingKey: !!modelCall && secretCall && calls.indexOf(secretCall) < calls.indexOf(modelCall),
+ secretStayedOnHostPath: secretCall?.input.id === providerId
+ && secretCall?.input.secretValue === "community-key-fixture",
+ configuredTileHidden: !document.querySelector('[data-plugin-provider-id="' + providerId + '"]'),
+ remainingTileShown: !!remainingTile,
+ dialogClosed: !document.querySelector('input[type="password"]'),
+ };
+};
+`;
+
+test("Add Service shows a plugin category and saves the chosen provider key through Host IPC", {
+ timeout: 60_000,
+ skip:
+ process.platform === "linux" && !process.env.DISPLAY
+ ? "Isolated Electron UI test requires a display"
+ : false,
+}, async () => {
+ const temp = await mkdtemp(join(root, "apps/desktop/.plugin-provider-catalog-ui-"));
+ try {
+ await build({
+ stdin: {
+ contents: fixtureSource,
+ resolveDir: join(root, "scripts", "e2e"),
+ sourcefile: join(root, "scripts", "e2e", "plugin-provider-catalog.jsx"),
+ loader: "tsx",
+ },
+ outfile: join(temp, "renderer.js"),
+ bundle: true,
+ platform: "browser",
+ format: "esm",
+ jsx: "automatic",
+ define: { "process.env.NODE_ENV": '"production"' },
+ alias: {
+ "@pi-desktop/i18n": join(root, "packages/i18n/src"),
+ react: join(root, "apps/desktop/node_modules/react"),
+ "react-dom": join(root, "apps/desktop/node_modules/react-dom"),
+ i18next: join(root, "apps/desktop/node_modules/i18next"),
+ "react-i18next": join(root, "apps/desktop/node_modules/react-i18next"),
+ },
+ nodePaths: [join(root, "apps/desktop/node_modules")],
+ });
+ await writeFile(
+ join(temp, "index.html"),
+ '<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src \'self\'; style-src \'self\' \'unsafe-inline\'"><body><div id="root"></div><script type="module" src="renderer.js"></script>',
+ );
+ await writeFile(
+ join(temp, "main.cjs"),
+ `
+const { app, BrowserWindow } = require("electron");
+const path = require("node:path");
+app.setPath("userData", path.join(__dirname, "profile"));
+app.whenReady().then(async () => {
+ const win = new BrowserWindow({ show: false, width: 1000, height: 760,
+ webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });
+ win.webContents.on("console-message", (event) => console.error(event.message));
+ try {
+ await win.loadFile(path.join(__dirname, "index.html"));
+ const result = await win.webContents.executeJavaScript("window.pluginProviderCatalogProbe()");
+ console.log("PLUGIN_PROVIDER_CATALOG_PROBE " + JSON.stringify(result));
+ app.exit(0);
+ } catch (error) { console.error(error?.stack ?? error); app.exit(1); }
+});
+`,
+ );
+
+ const env = { ...process.env };
+ delete env.ELECTRON_RUN_AS_NODE;
+ const child = spawn(resolveElectronBinary(root).electronBinary, [join(temp, "main.cjs")], {
+ env,
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ let output = "";
+ for (const stream of [child.stdout, child.stderr]) {
+ stream.setEncoding("utf8");
+ stream.on("data", (chunk) => { output += chunk; });
+ }
+ const timer = setTimeout(() => child.kill("SIGKILL"), 45_000);
+ let code;
+ try {
+ code = await new Promise((resolve, reject) => {
+ child.once("error", reject);
+ child.once("close", resolve);
+ });
+ } finally {
+ clearTimeout(timer);
+ }
+ assert.equal(code, 0, output.slice(-6000));
+ const line = output.split(/\r?\n/).find((item) => item.startsWith("PLUGIN_PROVIDER_CATALOG_PROBE "));
+ assert(line, output.slice(-6000));
+ assert.deepEqual(JSON.parse(line.slice("PLUGIN_PROVIDER_CATALOG_PROBE ".length)), {
+ categoryShown: true,
+ publisherShown: false,
+ tileEndpointShown: false,
+ introductionShown: true,
+ tileAccessibleName: "Community Demo",
+ endpointShown: true,
+ saved: true,
+ modelsDiscoveredAfterSavingKey: true,
+ secretStayedOnHostPath: true,
+ configuredTileHidden: true,
+ remainingTileShown: true,
+ dialogClosed: true,
+ });
+ } finally {
+ await rm(temp, { recursive: true, force: true });
+ }
+});
diff --git a/apps/desktop/test/plugin-provider-catalog.test.mjs b/apps/desktop/test/plugin-provider-catalog.test.mjs
new file mode 100644
index 000000000..cc03877b8
--- /dev/null
+++ b/apps/desktop/test/plugin-provider-catalog.test.mjs
@@ -0,0 +1,116 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { pluginProviderCatalogEntries } from "../electron/main/plugin-provider-catalog.ts";
+
+function plugin(id, name, permissions, providers) {
+ return {
+ permissions: new Set(permissions),
+ manifest: { id, name, contributes: { providers } },
+ };
+}
+
+test("the provider catalog is permission-filtered, API-key-only, localized and stable", () => {
+ const entries = pluginProviderCatalogEntries([
+ plugin("community.sites", "Community Sites", ["provider.register"], [
+ {
+ id: "second",
+ name: "Second",
+ baseUrl: "https://second.example/v1",
+ category: { en: "Community", "zh-CN": "公益站" },
+ description: { en: "A community API with check-in credits.", "zh-CN": "通过签到获取额度的公益 API 服务。" },
+ models: [{ id: "second-model" }],
+ },
+ {
+ id: "oauth",
+ name: "Subscription",
+ baseUrl: "https://oauth.example/v1",
+ authKind: "oauth",
+ models: [{ id: "oauth-model" }],
+ },
+ {
+ id: "no-auth",
+ name: "No authentication",
+ baseUrl: "https://local.example/v1",
+ authKind: "none",
+ models: [{ id: "local-model" }],
+ },
+ {
+ id: "missing-endpoint",
+ name: "No endpoint",
+ models: [{ id: "local-model" }],
+ },
+ ]),
+ plugin("community.first", "First Plugin", ["provider.register"], [
+ {
+ id: "first",
+ name: "First",
+ baseUrl: "https://first.example/v1",
+ category: "公益站",
+ models: [{ id: "first-model" }],
+ },
+ ]),
+ plugin("unapproved.plugin", "Unapproved", [], [
+ {
+ id: "hidden",
+ name: "Hidden",
+ baseUrl: "https://hidden.example/v1",
+ models: [{ id: "hidden-model" }],
+ },
+ ]),
+ ], "zh-CN");
+
+ assert.deepEqual(entries, [
+ {
+ pluginId: "community.sites",
+ providerId: "plugin:community.sites:second",
+ pluginName: "Community Sites",
+ category: "公益站",
+ description: "通过签到获取额度的公益 API 服务。",
+ },
+ {
+ pluginId: "community.first",
+ providerId: "plugin:community.first:first",
+ pluginName: "First Plugin",
+ category: "公益站",
+ },
+ ]);
+});
+
+test("a missing category falls back to the plugin name", () => {
+ const entries = pluginProviderCatalogEntries([
+ plugin("demo.providers", "Demo Providers", ["provider.register"], [{
+ id: "demo",
+ name: "Demo",
+ baseUrl: "https://demo.example/v1",
+ models: [{ id: "demo-model" }],
+ }]),
+ ], "en");
+
+ assert.equal(entries[0]?.category, "Demo Providers");
+});
+
+test("a localized provider category follows the active app locale", () => {
+ const sources = [plugin("demo.providers", "Demo Providers", ["provider.register"], [{
+ id: "demo",
+ name: "Demo",
+ baseUrl: "https://demo.example/v1",
+ category: { en: "Community", "zh-CN": "公益站" },
+ models: [{ id: "demo-model" }],
+ }])];
+
+ assert.equal(pluginProviderCatalogEntries(sources, "en")[0]?.category, "Community");
+ assert.equal(pluginProviderCatalogEntries(sources, "zh-CN")[0]?.category, "公益站");
+});
+
+test("the provider catalog resolves a localized one-sentence introduction", () => {
+ const sources = [plugin("demo.providers", "Demo Providers", ["provider.register"], [{
+ id: "demo",
+ name: "Demo",
+ baseUrl: "https://demo.example/v1",
+ description: { en: "A short introduction.", "zh-CN": "一句话简介。" },
+ models: [{ id: "demo-model" }],
+ }])];
+
+ assert.equal(pluginProviderCatalogEntries(sources, "en")[0]?.description, "A short introduction.");
+ assert.equal(pluginProviderCatalogEntries(sources, "zh-CN")[0]?.description, "一句话简介。");
+});
diff --git a/apps/desktop/test/service-catalog.test.mjs b/apps/desktop/test/service-catalog.test.mjs
index 692eb8d95..7d05c0e42 100644
--- a/apps/desktop/test/service-catalog.test.mjs
+++ b/apps/desktop/test/service-catalog.test.mjs
@@ -12,6 +12,7 @@ import {
filterServiceOptions,
endpointLabel,
namedServiceOptions,
+ pluginProviderServiceOptions,
} from "../src/components/settings/service-catalog.ts";
// Stands in for i18next with localized labels, so a label-only match is
@@ -87,3 +88,92 @@ test("endpoint labels retain routes and ports without showing credentials or que
"api.example:8443/plan/v1");
assert.equal(endpointLabel("https://api.example/"), "api.example");
});
+
+test("plugin provider categories show only unconfigured API-key rows and search introductions", () => {
+ const provider = (id, ownerPluginId, hasSecret) => ({
+ id,
+ name: id.endsWith("hcnsec") ? "幻城网安公益 API" : "ChatAnywhere Free API",
+ vendorKey: "custom",
+ type: "openai_compatible",
+ protocol: "openai_compatible",
+ enabled: true,
+ baseUrl: id.endsWith("hcnsec")
+ ? "https://api.ifivem.com/v1"
+ : "https://api.chatanywhere.tech/v1",
+ authKind: "api_key",
+ hasSecret,
+ models: [{ id: "deepseek-chat" }],
+ supportsReasoning: false,
+ supportedThinkingLevels: [],
+ ownerPluginId,
+ createdAt: "2026-10-08T00:00:00.000Z",
+ updatedAt: "2026-10-08T00:00:00.000Z",
+ });
+ const providers = [
+ provider("plugin:community.ai-sites:hcnsec", "community.ai-sites", false),
+ provider("plugin:community.ai-sites:chatanywhere", "community.ai-sites", true),
+ { ...provider("plugin:community.ai-sites:disabled", "community.ai-sites", false), enabled: false },
+ provider("plugin:other:wrong-owner", "other", false),
+ { ...provider("plugin:community.ai-sites:oauth", "community.ai-sites", false), authKind: "oauth" },
+ { ...provider("plugin:community.ai-sites:no-endpoint", "community.ai-sites", false), baseUrl: undefined },
+ ];
+ const declarations = [
+ {
+ pluginId: "community.ai-sites",
+ providerId: "plugin:community.ai-sites:hcnsec",
+ pluginName: "PI Community AI Sites",
+ category: "公益站",
+ description: "签到获得额度的公益 API 服务。",
+ },
+ {
+ pluginId: "community.ai-sites",
+ providerId: "plugin:community.ai-sites:chatanywhere",
+ pluginName: "PI Community AI Sites",
+ category: "公益站",
+ description: "签到获得额度的公益 API 服务。",
+ },
+ {
+ pluginId: "community.ai-sites",
+ providerId: "plugin:community.ai-sites:disabled",
+ pluginName: "PI Community AI Sites",
+ category: "公益站",
+ description: "已停用的站点。",
+ },
+ {
+ pluginId: "community.ai-sites",
+ providerId: "plugin:other:wrong-owner",
+ pluginName: "PI Community AI Sites",
+ category: "公益站",
+ description: "其他站点。",
+ },
+ {
+ pluginId: "community.ai-sites",
+ providerId: "plugin:community.ai-sites:oauth",
+ pluginName: "PI Community AI Sites",
+ category: "公益站",
+ description: "OAuth 站点。",
+ },
+ {
+ pluginId: "community.ai-sites",
+ providerId: "plugin:community.ai-sites:no-endpoint",
+ pluginName: "PI Community AI Sites",
+ category: "公益站",
+ description: "缺少地址。",
+ },
+ ];
+
+ const options = pluginProviderServiceOptions(declarations, providers);
+ assert.equal(options.length, 1);
+ assert.equal(options[0].category, "公益站");
+ assert.equal(options[0].endpoint, "api.ifivem.com/v1 · PI Community AI Sites");
+ assert.equal(options[0].description, "签到获得额度的公益 API 服务。");
+ assert.deepEqual(filterServiceOptions(options, "deepseek-chat").map((option) => option.id), [
+ "plugin:community.ai-sites:hcnsec",
+ ]);
+ assert.deepEqual(filterServiceOptions(options, "公益站").map((option) => option.id), [
+ "plugin:community.ai-sites:hcnsec",
+ ]);
+ assert.deepEqual(filterServiceOptions(options, "签到获得额度").map((option) => option.id), [
+ "plugin:community.ai-sites:hcnsec",
+ ]);
+});
diff --git a/apps/desktop/test/service-chooser.test.mjs b/apps/desktop/test/service-chooser.test.mjs
index 7794d1180..ff8da057b 100644
--- a/apps/desktop/test/service-chooser.test.mjs
+++ b/apps/desktop/test/service-chooser.test.mjs
@@ -27,7 +27,7 @@ const rule = (selector) => {
test("a new service starts on a searchable chooser, not a closed menu (D625)", () => {
assert.match(setupSource, /<ServiceChooser/);
assert.match(setupSource, /const chooserOpen = choosing \|\| !service/);
- assert.match(setupSource, /\{chooserOpen \? chooserView : jevService \? jevView : formView\}/);
+ assert.match(setupSource, /chooserOpen \? chooserView : pluginCatalogSetup/);
assert.doesNotMatch(setupSource, /<ServicePicker/);
assert.doesNotMatch(setupSource, /<optgroup/);
assert.match(chooserSource, /settings\.searchService/);
@@ -35,6 +35,16 @@ test("a new service starts on a searchable chooser, not a closed menu (D625)", (
// Matching itself is covered behaviorally in service-catalog.test.mjs.
assert.match(chooserSource, /filterServiceOptions\(serviceOptions, query\)/);
assert.match(chooserSource, /filterServiceOptions\(subscriptionOptions, query\)/);
+ assert.match(chooserSource, /filterServiceOptions\(pluginProviders, query\)/);
+ assert.match(chooserSource, /data-plugin-provider-category=\{category\}/);
+ assert.match(chooserSource, /tooltip=\{option\.description\}/);
+ assert.match(chooserSource, /aria-description=\{option\.description/);
+ const pluginChooserSource = chooserSource.slice(
+ chooserSource.indexOf("{pluginProviderGroups.map"),
+ chooserSource.indexOf("{visibleClassifiers.length > 0"),
+ );
+ assert.doesNotMatch(pluginChooserSource, /service-chooser-tile-detail|option\.endpoint/);
+ assert.match(setupSource, /api\.listPluginProviderCatalog\(\)/);
// Filtering stays in the renderer; a keystroke must not IPC.
assert.doesNotMatch(chooserSource, /\bapi\./);
assert.doesNotMatch(catalogSource, /\bapi\.\w+\(/);
@@ -81,6 +91,7 @@ test("the chooser answers the keyboard and never dead-ends", () => {
assert.match(chooserSource, /settings\.useCustomEndpoint/);
assert.match(chooserSource, /pickService\(CUSTOM_SERVICE\)/);
assert.match(chooserSource, /data-service-id=\{option\.id\}/);
+ assert.match(chooserSource, /data-plugin-provider-id=\{option\.id\}/);
});
test("chooser tiles are toned in-flow surfaces without strokes (D297)", () => {
diff --git a/crates/host-core/src/plugins.rs b/crates/host-core/src/plugins.rs
index 8fecad444..a0dadc555 100644
--- a/crates/host-core/src/plugins.rs
+++ b/crates/host-core/src/plugins.rs
@@ -73,8 +73,7 @@ pub(crate) use provider_validation::validate_declared_provider_oauth;
pub(crate) use providers::{
declared_providers, is_known_api_style, is_known_auth_kind, owned_provider_ids,
plugin_provider_row_id, reconcile_all, reconcile_plugin, remove_plugin_providers,
- set_plugin_providers_enabled, sync_plugin_providers, MAX_PLUGIN_PROVIDERS,
- MAX_PLUGIN_PROVIDER_MODELS,
+ set_plugin_providers_enabled, sync_plugin_providers, MAX_PLUGIN_PROVIDER_MODELS,
};
pub(crate) use renderer::validate_renderer;
pub(crate) use validation::{is_local_package_url, package_host_allowed, validate_contributions};
diff --git a/crates/host-core/src/plugins/providers.rs b/crates/host-core/src/plugins/providers.rs
index f42465373..2fa9ed15d 100644
--- a/crates/host-core/src/plugins/providers.rs
+++ b/crates/host-core/src/plugins/providers.rs
@@ -7,8 +7,6 @@ use crate::providers::{
};
use crate::secrets::SecretStore;
-/// Upper bound on `contributes.providers` entries. Matches the SDK constant.
-pub(crate) const MAX_PLUGIN_PROVIDERS: usize = 8;
/// Upper bound on one declaration's model list.
pub(crate) const MAX_PLUGIN_PROVIDER_MODELS: usize = 64;
@@ -123,7 +121,6 @@ pub(crate) fn declared_providers(manifest: &PluginManifest) -> Vec<DeclaredPlugi
};
entries
.iter()
- .take(MAX_PLUGIN_PROVIDERS)
.filter_map(|entry| {
let obj = entry.as_object()?;
let id = obj.get("id")?.as_str()?.trim().to_string();
diff --git a/crates/host-core/src/plugins/providers/tests.rs b/crates/host-core/src/plugins/providers/tests.rs
index 7472c8174..ff306aef2 100644
--- a/crates/host-core/src/plugins/providers/tests.rs
+++ b/crates/host-core/src/plugins/providers/tests.rs
@@ -60,6 +60,12 @@ fn manifest_with_providers(ids: &[&str]) -> PluginManifest {
serde_json::from_value(value).unwrap()
}
+fn manifest_with_dynamic_provider() -> PluginManifest {
+ let mut value = serde_json::to_value(manifest()).unwrap();
+ value["contributes"]["providers"][0]["models"] = json!([]);
+ serde_json::from_value(value).unwrap()
+}
+
fn write_plugin(root: &std::path::Path, manifest: Value) {
fs::create_dir_all(root).unwrap();
fs::write(root.join("main.js"), "export function onLoad() {}").unwrap();
@@ -138,6 +144,61 @@ fn declared_providers_reads_the_manifest() {
assert_eq!(provider.models[1].context_window, 0);
}
+#[test]
+fn provider_declarations_have_no_eight_row_cap() {
+ let ids: Vec<String> = (0..18).map(|index| format!("site-{index}")).collect();
+ let borrowed: Vec<&str> = ids.iter().map(String::as_str).collect();
+ let declared = declared_providers(&manifest_with_providers(&borrowed));
+ assert_eq!(declared.len(), 18);
+
+ let temp = tempfile::tempdir().unwrap();
+ let root = temp.path().join("plugin");
+ write_plugin(
+ &root,
+ serde_json::to_value(manifest_with_providers(&borrowed)).unwrap(),
+ );
+ assert!(PluginManager::read_manifest(&root).is_ok());
+}
+
+#[test]
+fn empty_api_key_model_list_uses_the_cached_endpoint_discovery() {
+ let (_dir, db, secrets) = test_context();
+ let declared = declared_providers(&manifest_with_dynamic_provider());
+ assert!(declared[0].models.is_empty());
+ let temp = tempfile::tempdir().unwrap();
+ let root = temp.path().join("plugin");
+ write_plugin(
+ &root,
+ serde_json::to_value(manifest_with_dynamic_provider()).unwrap(),
+ );
+ assert!(PluginManager::read_manifest(&root).is_ok());
+ sync_plugin_providers(&db, &secrets, "demo.provider", &declared, true).unwrap();
+ providers::set_provider_secret(
+ &db,
+ &secrets,
+ "plugin:demo.provider:demo",
+ Some("fixture-key"),
+ )
+ .unwrap();
+ providers::cache_discovered_models(
+ &db,
+ "plugin:demo.provider:demo",
+ &[providers::DiscoveredModelInput {
+ model_id: "demo-chat".to_string(),
+ display_name: "Demo Chat".to_string(),
+ capabilities: vec!["text".to_string()],
+ context_window: Some(128_000),
+ }],
+ )
+ .unwrap();
+
+ let listed = providers::list_providers(&db, &secrets, true).unwrap();
+ assert_eq!(listed[0].models.len(), 1);
+ assert_eq!(listed[0].models[0].id, "demo-chat");
+ assert_eq!(listed[0].models[0].alias.as_deref(), Some("Demo Chat"));
+ assert_eq!(listed[0].default_model_id.as_deref(), Some("demo-chat"));
+}
+
#[test]
fn sync_writes_rows_owned_by_the_plugin() {
let (_dir, db, secrets) = test_context();
@@ -513,7 +574,42 @@ fn the_declaration_shape_is_validated() {
);
assert!(read_manifest_err(&root).contains("http(s) URL"));
- // A model list is required and bounded.
+ // Localized labels are bounded by characters, including full-width text.
+ let long_localized_provider = json!([{
+ "id": "demo",
+ "name": "Demo",
+ "category": { "en": "C".repeat(128), "zh-CN": "公".repeat(128) },
+ "description": { "en": "A".repeat(280), "zh-CN": "公益".repeat(140) },
+ "baseUrl": "https://api.example.com/v1",
+ "models": [{ "id": "m" }]
+ }]);
+ write_plugin(
+ &root,
+ declaration_manifest(long_localized_provider, permissions.clone()),
+ );
+ assert!(PluginManager::read_manifest(&root).is_ok());
+
+ write_plugin(
+ &root,
+ declaration_manifest(
+ json!([{ "id": "demo", "name": "Demo", "category": { "en": "Community" },
+ "baseUrl": "https://api.example.com/v1", "models": [{ "id": "m" }] }]),
+ permissions.clone(),
+ ),
+ );
+ assert!(read_manifest_err(&root).contains("category must be a string or localized strings"));
+
+ write_plugin(
+ &root,
+ declaration_manifest(
+ json!([{ "id": "demo", "name": "Demo", "description": "公".repeat(281),
+ "baseUrl": "https://api.example.com/v1", "models": [{ "id": "m" }] }]),
+ permissions.clone(),
+ ),
+ );
+ assert!(read_manifest_err(&root).contains("description must be a string or localized strings"));
+
+ // Dynamic discovery needs an endpoint when an API-key model list is empty.
write_plugin(
&root,
declaration_manifest(
@@ -521,7 +617,8 @@ fn the_declaration_shape_is_validated() {
permissions.clone(),
),
);
- assert!(read_manifest_err(&root).contains("1 to 64 models"));
+ assert!(read_manifest_err(&root)
+ .contains("may omit models only for an API-key provider with a baseUrl"));
write_plugin(
&root,
diff --git a/crates/host-core/src/plugins/validation.rs b/crates/host-core/src/plugins/validation.rs
index d39f38466..ebd2a3ec8 100644
--- a/crates/host-core/src/plugins/validation.rs
+++ b/crates/host-core/src/plugins/validation.rs
@@ -1,5 +1,20 @@
use super::*;
+fn valid_provider_catalog_text(value: &Value, max_chars: usize) -> bool {
+ let valid_text =
+ |text: &str| !text.trim().is_empty() && text.encode_utf16().count() <= max_chars;
+ match value {
+ Value::String(text) => valid_text(text),
+ Value::Object(localized) => ["en", "zh-CN"].iter().all(|locale| {
+ localized
+ .get(*locale)
+ .and_then(Value::as_str)
+ .is_some_and(valid_text)
+ }),
+ _ => false,
+ }
+}
+
pub(crate) fn validate_contributions(root: &Path, manifest: &PluginManifest) -> Result<()> {
let Some(contributes) = manifest.contributes.as_ref() else {
return Ok(());
@@ -217,11 +232,6 @@ pub(crate) fn validate_contributions(root: &Path, manifest: &PluginManifest) ->
if let Some(providers) = map.get("providers") {
let entries = array_of(providers, "contributes.providers")?;
- if entries.len() > MAX_PLUGIN_PROVIDERS {
- bail!(
- "PLUGIN_INVALID: contributes.providers allows at most {MAX_PLUGIN_PROVIDERS} entries"
- );
- }
if !entries.is_empty() {
require_permission(manifest, "provider.register", "contributes.providers")?;
}
@@ -249,6 +259,16 @@ pub(crate) fn validate_contributions(root: &Path, manifest: &PluginManifest) ->
{
bail!("PLUGIN_INVALID: provider {id} requires a name");
}
+ if let Some(category) = obj.get("category") {
+ if !valid_provider_catalog_text(category, 128) {
+ bail!("PLUGIN_INVALID: provider {id} category must be a string or localized strings of at most 128 characters");
+ }
+ }
+ if let Some(description) = obj.get("description") {
+ if !valid_provider_catalog_text(description, 280) {
+ bail!("PLUGIN_INVALID: provider {id} description must be a string or localized strings of at most 280 characters");
+ }
+ }
if let Some(style) = obj.get("apiStyle") {
let style = style.as_str().ok_or_else(|| {
anyhow!("PLUGIN_INVALID: provider {id} apiStyle must be a string")
@@ -276,11 +296,18 @@ pub(crate) fn validate_contributions(root: &Path, manifest: &PluginManifest) ->
Some(value) => array_of(value, "contributes.providers.models")?,
None => bail!("PLUGIN_INVALID: provider {id} requires models"),
};
- if models.is_empty() || models.len() > MAX_PLUGIN_PROVIDER_MODELS {
+ if models.len() > MAX_PLUGIN_PROVIDER_MODELS {
bail!(
- "PLUGIN_INVALID: provider {id} declares 1 to {MAX_PLUGIN_PROVIDER_MODELS} models"
+ "PLUGIN_INVALID: provider {id} declares more than {MAX_PLUGIN_PROVIDER_MODELS} models"
);
}
+ let has_base_url = obj
+ .get("baseUrl")
+ .and_then(Value::as_str)
+ .is_some_and(|value| !value.trim().is_empty());
+ if models.is_empty() && (auth_kind != "api_key" || !has_base_url) {
+ bail!("PLUGIN_INVALID: provider {id} may omit models only for an API-key provider with a baseUrl");
+ }
let mut seen_models: Vec<&str> = Vec::new();
for model in models {
let model = model.as_object().ok_or_else(|| {
diff --git a/crates/host-core/src/providers/repository.rs b/crates/host-core/src/providers/repository.rs
index 60eac0509..34a450469 100644
--- a/crates/host-core/src/providers/repository.rs
+++ b/crates/host-core/src/providers/repository.rs
@@ -75,10 +75,56 @@ pub fn list_providers(
let mut stmt = db.conn().prepare_cached(&sql)?;
let rows = stmt.query_map([], |row| provider_from_row(row, secrets))?;
let mut providers = rows.collect::<rusqlite::Result<Vec<_>>>()?;
+ for provider in &mut providers {
+ hydrate_dynamic_plugin_models(db, provider)?;
+ }
super::order::apply_saved_order(db, &mut providers)?;
Ok(providers)
}
+/// An empty model declaration opts an API-key plugin provider into using the
+/// endpoint's cached discovery results. Static manifest models stay authoritative
+/// whenever the plugin declares at least one.
+fn hydrate_dynamic_plugin_models(db: &Database, provider: &mut ProviderPublic) -> Result<()> {
+ if provider.owner_plugin_id.is_none() || !provider.models.is_empty() {
+ return Ok(());
+ }
+ provider.models = list_models(db, Some(&provider.id))?
+ .into_iter()
+ .map(|model| {
+ let alias = (model.display_name != model.model_id).then_some(model.display_name);
+ ModelBinding {
+ id: model.model_id,
+ alias,
+ context_window_source: None,
+ max_tokens_source: None,
+ context_window: model.context_window.unwrap_or(DEFAULT_CONTEXT_WINDOW),
+ max_tokens: DEFAULT_MAX_TOKENS,
+ thinking_levels: Vec::new(),
+ default_thinking_level: None,
+ thinking_protocol: None,
+ supports_images: model
+ .capabilities
+ .iter()
+ .any(|value| value == "vision")
+ .then_some(true),
+ supports_documents: None,
+ available_for_subagents: None,
+ native_web_search: None,
+ }
+ })
+ .collect();
+ if provider
+ .default_model_id
+ .as_deref()
+ .map(|value| value.is_empty())
+ .unwrap_or(true)
+ {
+ provider.default_model_id = provider.models.first().map(|model| model.id.clone());
+ }
+ Ok(())
+}
+
pub fn create_provider(
db: &Database,
secrets: &SecretStore,
@@ -513,11 +559,15 @@ pub fn get_provider(
id: &str,
) -> Result<Option<ProviderPublic>> {
let sql = format!("{PROVIDER_SELECT} WHERE id = ?1");
- db.conn()
+ let mut provider = db
+ .conn()
.prepare_cached(&sql)?
.query_row(params![id], |row| provider_from_row(row, secrets))
- .optional()
- .map_err(Into::into)
+ .optional()?;
+ if let Some(provider) = provider.as_mut() {
+ hydrate_dynamic_plugin_models(db, provider)?;
+ }
+ Ok(provider)
}
/// Whether `id` names a row, whoever owns it.
diff --git a/docs/adr/0322-plugin-providers-in-add-service.md b/docs/adr/0322-plugin-providers-in-add-service.md
new file mode 100644
index 000000000..583b76c24
--- /dev/null
+++ b/docs/adr/0322-plugin-providers-in-add-service.md
@@ -0,0 +1,73 @@
+# ADR 0322: Plugin providers appear in Add Service
+
+- Status: Accepted for implementation
+- Date: 2026-10-08
+- Decision: D650
+- Related: ADR 0259, ADR 0320, `07-plugins/02-plugin-manifest-schema.md`, `07-plugins/03-plugin-api.md`, `07-plugins/04-plugin-security.md`, `07-plugins/13-plugin-permissions-matrix.md`, `04-ux/06-settings-ia.md`
+
+## Context
+
+ADR 0259 lets plugins declare Host-owned provider rows, but a user must leave
+the ordinary Add Service flow and find each row in the provider list before
+entering its API key. Community catalogs need to group several API services
+under a category and make them discoverable in the same place as built-in
+services. Plugin providers already have stable row ids, Host-owned credentials,
+and an explicit high-risk `provider.register` grant.
+
+## Decision
+
+1. Add an optional `category` field to `PluginProviderContrib`. It accepts a
+ non-empty string or an `{ en, "zh-CN" }` pair, with each label limited to
+ 128 characters. A missing category uses the plugin name.
+2. The Host projects metadata from loaded plugins whose `provider.register`
+ grant is active. Only API-key declarations with an endpoint and no saved key
+ appear in Add Service. OAuth and no-auth rows do not appear.
+3. The chooser groups rows under the declared category. Tiles show the provider
+ name; an optional one-sentence `description` appears in a tooltip on hover or
+ keyboard focus. Search includes category, provider name, plugin name,
+ endpoint, model ids, and description. The provider count is not capped per
+ plugin; the existing package size cap bounds the manifest.
+4. Selecting a row opens a Host-owned key form for the existing provider row.
+ It stores the key through the current provider secret API. If the provider's
+ `models` list is empty, saving the key triggers Host-owned endpoint model
+ discovery and caches the response for the provider row. Plugin code receives
+ no key and no new permission or runtime API is added.
+5. Once a key is saved, the row stays in the provider list and is removed from
+ Add Service. Provider ownership, row reconciliation, credential retention,
+ and uninstall cleanup stay as defined by ADR 0259 and ADR 0320. The optional
+ category is display metadata and does not alter existing rows or credentials.
+
+## Consequences
+
+- Users can discover community provider entries during ordinary service setup
+ and group them with localized custom categories.
+- Existing manifests remain valid because the new field is optional. An
+ omitted category falls back to the plugin name.
+- A provider may omit model declarations only when it is an API-key provider
+ with a `baseUrl`. Endpoint discovery starts only after the user explicitly
+ saves a key; failure leaves the key saved and reports that models could not
+ be loaded.
+- The same Host-owned row and secret lifecycle remains authoritative; saving a
+ key does not create a duplicate provider or require data migration.
+- A category or description does not make an endpoint trustworthy. The key
+ form keeps the plugin and endpoint visible for review, and users still decide
+ whether to send prompts and code to that service.
+
+## Alternatives considered
+
+### Let plugins inject arbitrary chooser UI
+
+Rejected: executing plugin UI in the provider setup dialog would add a new
+renderer boundary and duplicate the Host's credential and validation flow. The
+manifest already contains the data needed for a safe Host-rendered tile.
+
+### Create another provider row when a user selects a catalog tile
+
+Rejected: that would fork row identity, credential migration, model selection,
+and uninstall cleanup from the existing manifest-owned provider lifecycle.
+
+### Require a new permission for chooser visibility
+
+Rejected: `provider.register` already approves the plugin's authority to
+contribute provider rows. A separate display permission would not narrow what
+the plugin can do and would create a second approval state for the same rows.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 7a1b35696..93805909d 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -363,3 +363,4 @@ Each ADR includes:
| 0319 | [Inline external imports in owning Settings destinations](0319-settings-inline-imports.md) | Accepted (D645) |
| 0320 | [Host-owned OAuth lifecycle for plugin providers](0320-plugin-oauth-provider-callbacks.md) | Accepted for implementation (D647; amends ADR 0259) |
| 0321 | [Pin an acceptable address for mixed direct DNS answers](0321-skill-market-direct-dns-pinning.md) | Accepted (D648; amends ADR 0272) |
+| 0322 | [Plugin providers appear in Add Service](0322-plugin-providers-in-add-service.md) | Accepted for implementation (D650; amends ADR 0259) |
diff --git a/docs/spec/00-baseline.md b/docs/spec/00-baseline.md
index 6a1869a13..a6c502e63 100644
--- a/docs/spec/00-baseline.md
+++ b/docs/spec/00-baseline.md
@@ -1,8 +1,8 @@
# PI-Desktop Baseline Freeze
-- Baseline Version: `0.4.21`
-- Date: `2026-10-04`
-- Status: `Frozen for implementation details (indefinite local permission approvals + Plan checkpoint artifact + approval/execution startup fence + protocol v11 + schema v16 + host-owned plugin session import/read/update/delete P0/P1 + selectable shell catalog + icon-free composer prompt row + turn-boundary context checkpoint compaction + session-scoped work panel + edge-specific work-panel/chat resize ownership + models.dev chat model catalog + provider/runtime safety + M5 hardening + settings IA + project archive + sidebar organization + app update delivery + three-platform release + Extensions page density and theme-readable actions + custom global UI font + ChatGPT-style logical project groups)`
+- Baseline Version: `0.4.22`
+- Date: `2026-10-08`
+- Status: `Frozen for implementation details (indefinite local permission approvals + Plan checkpoint artifact + approval/execution startup fence + protocol v11 + schema v16 + host-owned plugin session import/read/update/delete P0/P1 + selectable shell catalog + icon-free composer prompt row + turn-boundary context checkpoint compaction + session-scoped work panel + edge-specific work-panel/chat resize ownership + models.dev chat model catalog + provider/runtime safety + M5 hardening + settings IA + project archive + sidebar organization + app update delivery + three-platform release + Extensions page density and theme-readable actions + custom global UI font + ChatGPT-style logical project groups + categorized plugin providers in Add Service)`
- Language policy: **English-first**
- Backend policy: **Rust host core + pi agent sidecar**
@@ -41,6 +41,11 @@
> and MCP scans live inside their owning settings pages, while session import
> remains available to plugins through the existing plugin API (D645 / ADR
> 0319).
+> `0.4.22` adds plugin-declared providers to Settings → Models → Add Service
+> (D650 / ADR 0322). The chooser shows names under their custom categories and
+> reveals one-sentence introductions on hover or keyboard focus. Provider count
+> is not capped per plugin. Empty model declarations discover models only after
+> the user saves a key; the Host reuses existing rows and secret storage.
> `0.4.10` replaces destructive work-panel clearing on conversation switches
> with runtime session-scoped contexts through D142 / ADR 0028.
> `0.4.11` adopts turn-boundary model-context checkpoint compaction through
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index cfc184b9e..99dd161c8 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -429,6 +429,13 @@ a usage tab.
- provider cards with host, first configured model, secret status,
and test / make-default / delete actions
- Add account and Add provider use the same primary button treatment
+ - Add Service groups unconfigured API-key providers declared by loaded
+ plugins under each contribution's optional custom category. The category
+ defaults to the plugin name and supports English and Simplified Chinese.
+ Tiles show only the provider name; a one-sentence introduction appears on
+ hover or keyboard focus. Search also matches category, plugin, endpoint,
+ and model IDs. A selection opens the Host-owned API-key form; after saving,
+ that provider remains in the service list and leaves the chooser.
- the add/edit dialog configures connection identity (name, endpoint, API
style, and secret). It shrinks to the overlay on a narrow window, and a
focused credential field keeps its 2px accent ring inside the dialog
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index a06ddb979..a902b4da2 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -3956,7 +3956,7 @@ default nor provider configuration. OAuth accounts remain in their separate sect
| Busy row | Test/update/delete actions disabled for that card |
### 19.4 Interactions
-- Add provider opens a modal dialog on a full-window overlay portaled to `#pi-desktop-overlays` on the document element (it can shrink below its 1040px preferred width). Focused credential fields keep their 2px accent ring fully visible: the scrolling body reserves that gutter instead of clipping the ring. Cancel/close resets fields and dismisses the dialog
+- Add provider opens a modal dialog on a full-window overlay portaled to `#pi-desktop-overlays` on the document element (it can shrink below its 1040px preferred width). The chooser groups unconfigured API-key providers declared by loaded plugins under their optional category, searches their category / plugin / provider / endpoint / model labels, and shows the plugin name and endpoint on each tile. Selecting one opens a Host-owned key form for its existing provider row; saving uses the provider secret path and removes that row from the chooser. Category and provider metadata render as text. Focused credential fields keep their 2px accent ring fully visible: the scrolling body reserves that gutter instead of clipping the ring. Cancel/close resets fields and dismisses the dialog
- The model picker searches and toggles multiple models without using a native
multiple select. Its portaled menu closes on outside press, Escape, scroll,
and resize; model selection immediately adds or removes its configuration
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 4f6b83bb3..5f6240bd1 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -9542,18 +9542,18 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
| E / F / Quality — MCP server timeout override | E2E-261 |
| A — App startup | E2E-001, E2E-002, E2E-003, E2E-004, E2E-067, E2E-076, E2E-079, E2E-092, E2E-097, E2E-143, E2E-150, E2E-168, E2E-204 |
| A / C / F / Quality — Tray session navigation | E2E-TRAY-bounded-session-navigation |
-| B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209 |
+| B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209, E2E-PLUGIN-provider-catalog-add-service |
| C — Conversation & stream | E2E-CHAT-long-history-stream-keeps-responsive, E2E-CHAT-running-status-survives-output-pauses, E2E-008, E2E-008d, E2E-008e, E2E-008a, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-031, E2E-040, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-052, E2E-053, E2E-054, E2E-055, E2E-059, E2E-059a, E2E-060c, E2E-060d, E2E-061, E2E-061a, E2E-062, E2E-064, E2E-065, E2E-068, E2E-071, E2E-073, E2E-074, E2E-075, E2E-081, E2E-083, E2E-084, E2E-086, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-COMPOSER-narrow-controls, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-106, E2E-109, E2E-111, E2E-114, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-121, E2E-218, E2E-259, E2E-219, E2E-AGENTS-001, E2E-142, E2E-144, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-161, E2E-162, E2E-166, E2E-172, E2E-173, E2E-174, E2E-177, E2E-178, E2E-179, E2E-180, E2E-182, E2E-183, E2E-187, E2E-198, E2E-199, E2E-202, E2E-203, E2E-207, E2E-208, E2E-CHAT-content-width-handles, E2E-250, E2E-102i, E2E-PLUGIN-session-orchestrator-real-workers, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-SUBAGENT-resume-a-settled-delegation |
| C — Conversation & stream (composer drafts) | E2E-011c, E2E-011c-1 |
| D — Workspace | E2E-012, E2E-013, E2E-022B, E2E-024I, E2E-047, E2E-049, E2E-057, E2E-058, E2E-060, E2E-068, E2E-075, E2E-078, E2E-153, E2E-158, E2E-182, E2E-187, E2E-252 |
| D — Workspace (project ordering) | E2E-253 |
| E — Tools & permissions | E2E-008a, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-024I, E2E-024K, E2E-040, E2E-049, E2E-074, E2E-093, E2E-097, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102d, E2E-102e, E2E-102g, E2E-103, E2E-105, E2E-106, E2E-107, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-119, E2E-121, E2E-122, E2E-142, E2E-145, E2E-147, E2E-155, E2E-158, E2E-166, E2E-181, E2E-PLUGIN-imported-pi-package-skills |
-| F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-038, E2E-SETTINGS-inline-capability-imports, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PLUGIN-session-orchestrator-real-workers |
+| F — Persistence | E2E-020, E2E-021, E2E-021a, E2E-038, E2E-SETTINGS-inline-capability-imports, E2E-040, E2E-042, E2E-047, E2E-048, E2E-051, E2E-054, E2E-056, E2E-061, E2E-062, E2E-064, E2E-066, E2E-068, E2E-071, E2E-072, E2E-073, E2E-082, E2E-084, E2E-096, E2E-098, E2E-102, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-102i, E2E-103, E2E-AGENTS-001, E2E-061a, E2E-073a, E2E-104, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-118, E2E-119, E2E-120, E2E-121, E2E-123, E2E-142, E2E-146, E2E-146a, E2E-148, E2E-151, E2E-158, E2E-160, E2E-168, E2E-171, E2E-177, E2E-178, E2E-183, E2E-186, E2E-005J, E2E-PLUGIN-session-orchestrator-real-workers, E2E-PLUGIN-provider-catalog-add-service |
| F — Persistence (project ordering) | E2E-251 |
-| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024AA, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-imported-pi-package-wrapper, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session |
+| G — Plugins | E2E-022, E2E-022A, E2E-022B, E2E-022C, E2E-023, E2E-024, E2E-024B, E2E-024C, E2E-024D, E2E-024AA, E2E-024E, E2E-024W, E2E-024F, E2E-024G, E2E-024H, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M, E2E-024N, E2E-024O, E2E-024P, E2E-025, E2E-026, E2E-105, E2E-117, E2E-120, E2E-122, E2E-123, E2E-024Q, E2E-148, E2E-152, E2E-153, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-imported-pi-package-wrapper, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-PLUGIN-provider-catalog-add-service |
| H — Diagnostics | E2E-027, E2E-031, E2E-034, E2E-042, E2E-096, E2E-098, E2E-104, E2E-107, E2E-108, E2E-109, E2E-110, E2E-113, E2E-115, E2E-116, E2E-118, E2E-121, E2E-146, E2E-146a, E2E-155, E2E-159, E2E-176, E2E-194, E2E-195 |
-| Security | E2E-SETTINGS-inline-capability-imports, E2E-028, E2E-029, E2E-030, E2E-024J, E2E-024K, E2E-024M, E2E-049, E2E-068, E2E-086, E2E-102c, E2E-102d, E2E-102e, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-113, E2E-115, E2E-116, E2E-117, E2E-119, E2E-121, E2E-122, E2E-123, E2E-142, E2E-148, E2E-151, E2E-153, E2E-158, E2E-187, E2E-196c, E2E-196b, E2E-196, E2E-PLUGIN-fs-root-follows-the-calling-session |
-| Quality | E2E-SETTINGS-inline-capability-imports, E2E-CHAT-long-history-stream-keeps-responsive, E2E-CHAT-running-status-survives-output-pauses, E2E-032, E2E-033, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-053, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-103, E2E-AGENTS-001, E2E-021a, E2E-024N, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-111, E2E-114, E2E-117, E2E-118, E2E-119, E2E-120, E2E-122, E2E-123, E2E-142, E2E-143, E2E-144, E2E-145, E2E-146, E2E-147, E2E-148, E2E-150, E2E-151, E2E-153, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-168, E2E-172, E2E-173, E2E-174, E2E-011g, E2E-176, E2E-177, E2E-178, E2E-179, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-196, E2E-201, E2E-204, E2E-202, E2E-203, E2E-205, E2E-206, E2E-207, E2E-208, E2E-209, E2E-210, E2E-UPDATE-preference-and-once-only-reminder, E2E-218, E2E-259, E2E-219, E2E-250, E2E-252, E2E-102i, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation |
+| Security | E2E-SETTINGS-inline-capability-imports, E2E-028, E2E-029, E2E-030, E2E-024J, E2E-024K, E2E-024M, E2E-049, E2E-068, E2E-086, E2E-102c, E2E-102d, E2E-102e, E2E-105, E2E-106, E2E-107, E2E-108, E2E-109, E2E-110, E2E-112, E2E-113, E2E-115, E2E-116, E2E-117, E2E-119, E2E-121, E2E-122, E2E-123, E2E-142, E2E-148, E2E-151, E2E-153, E2E-158, E2E-187, E2E-196c, E2E-196b, E2E-196, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-PLUGIN-provider-catalog-add-service |
+| Quality | E2E-SETTINGS-inline-capability-imports, E2E-CHAT-long-history-stream-keeps-responsive, E2E-CHAT-running-status-survives-output-pauses, E2E-032, E2E-033, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-053, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-103, E2E-AGENTS-001, E2E-021a, E2E-024N, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-111, E2E-114, E2E-117, E2E-118, E2E-119, E2E-120, E2E-122, E2E-123, E2E-142, E2E-143, E2E-144, E2E-145, E2E-146, E2E-147, E2E-148, E2E-150, E2E-151, E2E-153, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-168, E2E-172, E2E-173, E2E-174, E2E-011g, E2E-176, E2E-177, E2E-178, E2E-179, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-196, E2E-201, E2E-204, E2E-202, E2E-203, E2E-205, E2E-206, E2E-207, E2E-208, E2E-209, E2E-210, E2E-UPDATE-preference-and-once-only-reminder, E2E-218, E2E-259, E2E-219, E2E-250, E2E-252, E2E-102i, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation, E2E-PLUGIN-provider-catalog-add-service |
| Quality (project ordering) | E2E-253 |
| C — Conversation & stream (IME slash alias) | E2E-255 |
| E — Tools & permissions (Skill residency) | E2E-254 |
@@ -9623,7 +9623,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
| Post-baseline local automation | E2E-220 |
| Post-baseline local automation (MCP `pi_session_get` large compaction) | E2E-MCP-session-get-projects-large-compaction |
| Post-MVP remote control | E2E-221, E2E-222, E2E-223, E2E-224, E2E-225, E2E-226, E2E-227, E2E-228, E2E-229, E2E-230, E2E-231, E2E-232 |
-| Trusted extensions (R7 v1) | E2E-DIALOG-long-text-boundaries, E2E-241, E2E-242, E2E-HOOKS-prompt-chain, E2E-HOOKS-cancel-and-dispose, E2E-TRUSTED-EXTENSION-custom-agent-stream-and-binding, E2E-243, E2E-TRUSTED-EXTENSION-temporary-session-cwd-is-scratch, E2E-244, E2E-245, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-declared-provider-appears-in-the-native-provider-list |
+| Trusted extensions (R7 v1) | E2E-DIALOG-long-text-boundaries, E2E-241, E2E-242, E2E-HOOKS-prompt-chain, E2E-HOOKS-cancel-and-dispose, E2E-TRUSTED-EXTENSION-custom-agent-stream-and-binding, E2E-243, E2E-TRUSTED-EXTENSION-temporary-session-cwd-is-scratch, E2E-244, E2E-245, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-declared-provider-appears-in-the-native-provider-list, E2E-PLUGIN-provider-catalog-add-service |
| Trusted extensions (R7 v1 npm recovery) | E2E-PLUGIN-import-extension-recovers-missing-npm |
| Post-MVP regression coverage (plugin tool dispatch) | E2E-PLUGIN-slow-tool-is-not-cut-off-by-host-dispatch |
| M6+ (Project delete) | E2E-PROJECT-delete-removes-project-and-owned-sessions |
@@ -15859,6 +15859,53 @@ plugin-form fixtures in an isolated temporary directory at runtime.
acceptance remains outstanding. Required post-integration suites: `test:e2e`,
`test:e2e:subagents`, `test:e2e:subagent-models`.
+#### E2E-PLUGIN-provider-catalog-add-service: Select a plugin provider from its custom Add Service category
+
+- **Preconditions**: A loaded plugin has `provider.register` and declares two
+ API-key providers with a `baseUrl`, a localized `category`, and a short
+ localized `description`; one provider has static models and the other has an
+ empty model list. Both Host-owned rows have no saved key. Include another row
+ whose key is already configured and a provider contribution from a plugin
+ without `provider.register`.
+- **Steps**: 1) Open Settings → Models → Add provider. 2) Find the declared
+ category and hover or keyboard-focus a provider tile. 3) Select the provider,
+ enter a fixture key, and save. 4) Reopen Add provider and search the remaining
+ entry by category, provider name, introduction, endpoint, and model ID. 5)
+ Change the app language between English and Simplified Chinese and reopen the
+ chooser. 6) Load a manifest with malformed localized category/description
+ fields, an empty category/description, and values over their length limits.
+- **Expected**: Step 1 groups unconfigured API-key contributions under the
+ category for the active locale. Tiles show only provider names; hover/focus
+ shows the one-sentence introduction, and the tile's accessible description
+ remains available to assistive technology. The chooser has no provider-count
+ cap and omits configured providers, OAuth / no-auth rows, and contributions
+ whose plugin lacks the grant. Step 2 opens the existing Host-owned provider
+ key form; the endpoint and plugin remain visible there for a destination
+ check. Step 3 saves through the Host provider secret API; only an empty-model
+ declaration triggers Host model discovery after save. Discovered models are
+ cached for that plugin-owned row. The key is never returned to plugin code or
+ included in catalog metadata. The provider row and key remain in the service
+ list, and that entry disappears from Add Service while the other unconfigured
+ entry remains. Step 4 finds the remaining tile by the listed search fields
+ and never offers the saved row. Step 5 switches the declared localized text
+ correctly. Step 6 rejects malformed metadata without partially loading the
+ plugin. Existing plugin row ids, ownership, reconciliation, and key retention
+ remain unchanged.
+- **Specs linked**: `07-plugins/02-plugin-manifest-schema.md` §5.4,
+ `07-plugins/03-plugin-api.md`, `07-plugins/04-plugin-security.md`,
+ `07-plugins/13-plugin-permissions-matrix.md`, `04-ux/06-settings-ia.md`,
+ `04-ux/08-component-spec.md`, ADR 0322; D650.
+- **Acceptance**: B (model config), E (tools & permissions), F (persistence),
+ G (plugins), Security, Quality
+- **Milestone**: Post-MVP (R7 v1)
+- **Status**: The representative Add Service → category → key save path runs
+ in `apps/desktop/test/plugin-provider-catalog-user-path.test.mjs` under an
+ isolated Electron renderer with a fake Host IPC boundary. Catalog filtering,
+ locale resolution, description tooltip, category validation, filtering, and
+ search have focused tests. The user-path test also confirms that model
+ discovery follows key save and saving one entry hides only that configured
+ row while another entry remains available.
+
#### E2E-PLUGIN-declared-provider-appears-in-the-native-provider-list: Plugin providers use Host-owned rows, permissions, and OAuth sign-in
- **Preconditions**: An installed local plugin declares one API-key provider
diff --git a/docs/spec/07-plugins/02-plugin-manifest-schema.md b/docs/spec/07-plugins/02-plugin-manifest-schema.md
index c0aba5e99..6e82b1275 100644
--- a/docs/spec/07-plugins/02-plugin-manifest-schema.md
+++ b/docs/spec/07-plugins/02-plugin-manifest-schema.md
@@ -323,6 +323,7 @@ type PluginBusContrib = {
type PluginProviderContrib = {
id: string; // ^[a-zA-Z][a-zA-Z0-9_-]{0,63}$, unique within the plugin
name: string; // display name in the native provider list
+ category?: string | { en: string; "zh-CN": string }; // Add Service group; defaults to plugin name
vendorKey?: string; // models.dev vendor key, default `custom`
baseUrl?: string; // absolute http(s) URL
apiStyle?: PluginProviderApiStyle; // wire style, default `chat_completions`
@@ -496,12 +497,18 @@ and `**` matches one or more trailing segments (final segment only).
## 5.4 providers — provider rows the plugin declares
-`contributes.providers` declares at most 8 providers that the Host materializes
-as rows in the native provider list, owned by the plugin ([ADR 0259](../../adr/0259-plugin-declared-providers.md)):
+`contributes.providers` declares provider rows that the Host materializes in
+the native provider list, owned by the plugin ([ADR 0259](../../adr/0259-plugin-declared-providers.md)). There is no per-plugin provider-count cap; the existing 50 MiB plugin package limit remains the outer size bound:
- the declaration `id` matches `[a-zA-Z][a-zA-Z0-9_-]{0,63}` and is unique
within the plugin; the row id is `plugin:<pluginId>:<declaredId>`
- `name` is required and is what Settings shows
+- `category` is optional Add Service group metadata. It accepts a non-empty
+ plain string or both localized labels (`en` and `zh-CN`); each label is at
+ most 128 characters. When omitted, the plugin name is the group label.
+- `description` is an optional short introduction shown in an Add Service
+ tooltip on hover or keyboard focus. It accepts a non-empty string or both
+ localized labels (`en` and `zh-CN`), each at most 280 characters.
- `baseUrl` is optional, but must be an absolute `http(s)` URL
- `apiStyle` is optional and defaults to `chat_completions`; the accepted values
are the provider-config styles except `auto`
@@ -510,7 +517,10 @@ as rows in the native provider list, owned by the plugin ([ADR 0259](../../adr/0
`onProviderOAuth` module export. Optional `oauth.loginLabel` is a
non-empty string of at most 128 characters; `oauth.isSubscription` is a
boolean. The host stores one encrypted credential per provider contribution.
-- `models` requires 1..64 entries with unique ids of 1..256 characters
+- `models` accepts up to 64 entries with unique ids of 1..256 characters. An
+ empty list is valid only for an API-key provider with `baseUrl`; after the
+ user saves a key, the Host discovers and caches that endpoint's models and
+ exposes the cached models for the plugin-owned row.
`thinkingLevels` is optional. The Host trims entries, drops unknown canonical
names, removes duplicates, and preserves the remaining declaration order. An
@@ -525,6 +535,16 @@ fields; disabling the plugin keeps the rows and turns them off, while dropping a
declaration or uninstalling the plugin deletes the row with its stored
credentials.
+An API-key provider with a `baseUrl` appears in the Host's **Add Service**
+chooser while its plugin is loaded with `provider.register` and the provider has
+no saved key. Entries are grouped by `category`, or by plugin name when it is
+omitted. Selecting an entry opens the Host-owned key form and saves through the
+existing provider secret path. Once configured, the provider stays in the
+provider list and is omitted from Add Service so the same row is not offered as
+a second add action. OAuth and no-auth contributions do not appear in this
+chooser. Existing plugin-owned row reconciliation and credential retention are
+unchanged; category is display metadata only and does not grant a capability.
+
OAuth contributions use the host-owned vendor-account UI. `onProviderOAuth`
handles `login` and `refresh`; `pi.providers.oauth.prompt` and `.notify` provide
host-rendered interaction. The callback can read only the credential for its
diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.md
index a393b39c7..96cbe2862 100644
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@ -341,6 +341,30 @@ Only enabled, authenticated provider rows are returned (API key, OAuth, or
so a picker page can populate itself. When the host transport is unavailable,
the call returns an empty list instead of warning (D080).
+### Provider entries in Add Service
+
+The Host exposes unconfigured, manifest-declared API-key providers in Settings
+→ Models → Add Service. This is a data-only projection of
+`contributes.providers`; plugins do not register chooser entries at runtime and
+receive no API key. `category` groups the entries and may be a plain string or
+an `{ en, "zh-CN" }` label. The Host saves the key in its existing encrypted
+provider secret store. A configured row remains in the provider list and is
+hidden from Add Service. The `provider.register` grant is sufficient; there is
+no additional permission or plugin API method.
+
+Tiles show the provider name only. Optional `description` copy appears as a
+single-sentence tooltip on hover or keyboard focus; search also checks the
+description. The selected key form shows the endpoint and plugin name for a
+final destination check before saving.
+
+A provider may declare an empty `models` list only when it is API-key based and
+has a `baseUrl`. After the user saves a key, the Host requests that endpoint's
+model list and caches the answer. The cached models are available to the
+plugin-owned row, whose manifest continues to own its endpoint and other
+provider fields. If discovery returns no models, the key remains saved and the
+user can retry from the provider's model controls. Provider count is not capped
+per plugin; the package's existing size limit bounds the manifest.
+
### provider OAuth (requires `provider.oauth`)
An OAuth provider contribution needs both `provider.register` and
diff --git a/docs/spec/07-plugins/04-plugin-security.md b/docs/spec/07-plugins/04-plugin-security.md
index 5f3b2646f..e334da1d1 100644
--- a/docs/spec/07-plugins/04-plugin-security.md
+++ b/docs/spec/07-plugins/04-plugin-security.md
@@ -193,6 +193,16 @@ trusts. The callback receives an abort signal when login is cancelled, the
plugin unloads, or the host call times out. Sign out clears the credential and
leaves the manifest-owned provider row in place.
+The Add Service provider catalog is also Host-rendered. It reads only the
+manifest metadata of loaded plugins with `provider.register`, includes only
+unconfigured API-key providers with an endpoint, and renders the category and
+provider name as text. An optional description is plain tooltip text on hover
+or keyboard focus. The chooser does not execute plugin code or return
+credentials. Saving a key stores it through the Host's existing provider
+secret path; the Host discovers endpoint models after that explicit save, and
+the provider service receives the key when the user sends a request through
+the provider.
+
## 6. Path safety
`fs.read` / `fs.write` / `fs.delete` say whether a plugin may touch files;
diff --git a/docs/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/spec/07-plugins/13-plugin-permissions-matrix.md
index 6e1e5d23f..260e6201e 100644
--- a/docs/spec/07-plugins/13-plugin-permissions-matrix.md
+++ b/docs/spec/07-plugins/13-plugin-permissions-matrix.md
@@ -25,7 +25,7 @@ Provide a permission–capability–risk–default-policy reference table for re
| `agent.prompt.inject` | high | Inject a system prompt; activates `contributes.skills` | Deny by default / strong confirmation | Easily leads to behavior hijacking |
| `agent.extension` | high | Run `contributes.agentExtensions` modules inside the agent process | Explicit confirmation; local imports and development plugins only in v1.1 | Same access as the agent's own tools; the plugin sandbox does not apply (spec 16) |
| `renderer.extension` | high | `manifest.renderer` is evaluated inside the host renderer to mount UI slots; `rendererActions` and `rendererCallMethods` open the actions and `onRendererCall` methods that module may use | Explicit confirmation; local imports and development plugins only in v1.1, matching `agent.extension` | The module shares the host's own document, so a slot is a contract rather than a sandbox. A component may dispatch only the reviewed vocabulary (`plugin.call`, `composer.insertText`, `composer.readDraft`, `composer.replaceDraft`, `attachments.add` / `list` / `remove`), capped at 16, and `plugin.call` reaches only the calling plugin's own `onRendererCall` methods, capped at 32. Registrations are withdrawn when the plugin unloads; a self-drawn dialog lives in a layer the plugin opened itself |
-| `provider.register` | high | `contributes.providers` become rows in the native provider list, owned by the plugin and refreshed from the manifest on load | Explicit confirmation; local imports and development plugins only in v1.1, matching `agent.extension` | The user path refuses edits to the row (`PROVIDER_OWNED_BY_PLUGIN`); API-key credentials stay in the Host secret store under the usual provider refs |
+| `provider.register` | high | `contributes.providers` become rows in the native provider list, owned by the plugin and refreshed from the manifest on load; unconfigured API-key rows with an endpoint also appear in Add Service, grouped by optional `category` and with optional hover/focus `description` | Explicit confirmation; local imports and development plugins only in v1.1, matching `agent.extension` | The user path refuses edits to the row (`PROVIDER_OWNED_BY_PLUGIN`); Add Service saves the key through the existing Host secret path. Only loaded plugins with this grant contribute entries; the chooser does not expose secrets or run plugin code. An empty API-key model list discovers models after key save. |
| `provider.oauth` | high | `onProviderOAuth`; host-rendered `pi.providers.oauth.prompt` / `notify` for a declared OAuth provider | Explicit confirmation | Required with `provider.register` for `authKind: "oauth"`. The callback can read and refresh only that contribution's encrypted credential. The Host keeps refresh tokens out of the renderer and Agent Runtime. Host-mediated callback egress still needs `net.fetch` and `manifest.net.domains`; plugin entry code itself is not an OS sandbox. One account is stored per provider contribution; sign out clears it |
| `net.fetch` | high | `net.fetch` | Deny by default | Confined to `manifest.net.domains`; an empty or malformed list means no egress (§2A) |
| `net.websocket` | high | `pi.net.websocket.connect` / `send` / `close` (host-owned sockets; at most 4 per plugin, 1 MiB frames) | Deny by default | Confined to `manifest.net.domains` like `net.fetch`; a refused host never reaches the transport, and every socket is closed when the plugin unloads, is disabled, or crashes |
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index f6e6e7813..7cc38c90a 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -1,7 +1,7 @@
# Decisions Log
-> Baseline delta: `0.3.0` → `0.4.20`
-> Date: `2026-10-06`
+> Baseline delta: `0.3.0` → `0.4.22`
+> Date: `2026-10-08`
> Status: Accepted for implementation
This log freezes previously open questions into concrete decisions.
@@ -43,6 +43,7 @@ This log freezes previously open questions into concrete decisions.
| D648 | Skill Market pins an acceptable address for mixed direct DNS answers | **Amend ADR 0272: on a direct route, when DNS includes both rejected and acceptable answers, Skill Market selects and pins one acceptable address instead of letting Chromium choose among them. Third-party content prefers a public answer; the benchmark fake-IP is eligible only under the existing opt-in. ULA-only and other non-public-only answers remain blocked. Proxied and unreadable routes keep the existing policy. See ADR 0321 and E2E-SKILL-MARKET-NET-BOUNDARY.** | Dual-stack and transparent-proxy DNS can include an unused synthetic ULA answer beside an address the request can safely use; pinning prevents the rejected address from being dialed while avoiding the false refusal. |
| D649 | Cloud backup stays closed to users | **Amend D642 / D643: the Settings `sync` destination carries `developmentOnly: true` again, so a packaged build omits its rail row, page, and settings-search hits and falls back to General, while development builds keep it. Developer mode stays irrelevant to the destination and it still carries no Experimental badge. Sync behavior, protocol, host schema, and persisted data are unchanged; dropping the flag reopens it for packaged builds. See `04-ux/06-settings-ia.md` and E2E-CONFIG-SYNC-webdav-portable-configuration.** | The encrypted WebDAV backup is not ready to be offered to packaged-build users yet, so it stays implemented but out of the way until it opens. |
+| D650 | Plugin providers appear in Add Service | **Amend ADR 0259: optional `category` groups manifest-owned provider rows; optional localized `description` supplies one-sentence hover/focus copy. Loaded plugins with `provider.register` contribute unconfigured API-key providers with endpoints. Tiles display provider names only; the Host saves keys through the existing provider secret path. There is no per-plugin provider-count cap. An empty model list is allowed only for an API-key provider with a base URL; after explicit key save, Host discovery populates its cached model choices. Configured rows remain in the provider list and leave the chooser. OAuth / no-auth rows are omitted; no new permission, runtime plugin API, provider row, or credential migration is added. See ADR 0322, `07-plugins/02-plugin-manifest-schema.md`, and E2E-PLUGIN-provider-catalog-add-service.** | Users could not discover manifest-owned community providers in the normal Add Service flow, and each plugin needed to group its own sites without owning credential UI. |
## B. Secondary implementation defaults
@@ -7535,3 +7536,16 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
and `apps/desktop/test/config-sync-settings.test.mjs`; the Cloud sync probe in
`pnpm test:e2e:settings-scroll` runs a development build. See
`04-ux/06-settings-ia.md` and E2E-CONFIG-SYNC-webdav-portable-configuration.
+
+## 2026-10-08 — Plugin providers appear in Add Service (D650)
+
+- ADR 0322 adds provider category and optional short-description metadata to a
+ Host-rendered Add Service projection for unconfigured API-key providers from
+ loaded plugins with `provider.register`.
+- Tiles show the provider name; its introduction is available on hover or
+ keyboard focus. There is no provider-count cap per plugin. Empty model lists
+ discover and cache endpoint models after the user saves a key.
+- The key still uses the Host's existing provider secret path, and a configured
+ row leaves the chooser. OAuth and no-auth declarations do not appear.
+- See E2E-PLUGIN-provider-catalog-add-service and
+ `07-plugins/02-plugin-manifest-schema.md` §5.4.
diff --git a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md
index 3e66624a0..627d974f9 100644
--- a/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md
+++ b/docs/zh-CN/spec/07-plugins/02-plugin-manifest-schema.md
@@ -427,12 +427,17 @@ type PluginNetDomains = string[]; // "api.example.com" 或 "*.example.com"
## 5.4 providers —— 插件声明的 provider 行
-`contributes.providers` 最多声明 8 个 provider,宿主会把每一项落成原生 provider
-列表中的一行,并归该插件所有([ADR 0259](../../../adr/0259-plugin-declared-providers.md)):
+`contributes.providers` 声明的 provider 行由宿主写入原生 provider 列表,并归该插件所有
+([ADR 0259](../../../adr/0259-plugin-declared-providers.md))。每个插件不设 provider 数量上限,
+插件包现有的 50 MiB 限制仍是总量边界:
- 声明的 `id` 匹配 `[a-zA-Z][a-zA-Z0-9_-]{0,63}` 且在插件内唯一;行 id 为
`plugin:<pluginId>:<declaredId>`
- `name` 必填,是设置页显示的名称
+- `category` 可选,用作“添加服务”分组;可填写普通字符串或同时提供 `en` 与 `zh-CN`
+ 的本地化名称,每个名称最多 128 个字符。省略时使用插件名称
+- `description` 可选,是“添加服务”中悬停或键盘聚焦时显示的一句话简介;可填写普通字符串
+ 或同时提供 `en` 与 `zh-CN` 的本地化内容,每条最多 280 个字符
- `baseUrl` 可选,但必须是绝对 `http(s)` URL
- `apiStyle` 可选,默认 `chat_completions`;可取值是 provider 配置中除 `auto`
以外的风格
@@ -440,7 +445,8 @@ type PluginNetDomains = string[]; // "api.example.com" 或 "*.example.com"
- OAuth provider 需要 `provider.register` 和独立高风险权限 `provider.oauth`,还需要
绝对 HTTP(S) `baseUrl` 及插件主模块导出的 `onProviderOAuth`;`oauth` 元数据可设置
`loginLabel` 和 `isSubscription`
-- `models` 要求 1..64 条,id 唯一且长度为 1..256
+- `models` 最多 64 条,id 唯一且长度为 1..256。仅当 provider 使用 API Key 且配置了
+ `baseUrl` 时,才允许为空;用户保存 Key 后,宿主会发现并缓存该端点提供的模型
非空的 `contributes.providers` 需要高风险权限 `provider.register`
([13-plugin-permissions-matrix.md](/zh-CN/spec/07-plugins/13-plugin-permissions-matrix))。
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 5a1a25910..f21f40392 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -3,8 +3,8 @@
> **翻译说明:** 本页是与 [英文源规格](/spec/08-meta/decisions-log) 一一对应的机器辅助翻译。代码、协议字段和标识符保持原文;如翻译与英文源事实有歧义,以英文版本为准。
-> 基线增量:`0.3.0` → `0.4.16`
-> 日期:`2026-10-06`
+> 基线增量:`0.3.0` → `0.4.22`
+> 日期:`2026-10-08`
> 状态:已接受实施
该日志将以前未解决的问题冻结为具体的决策。
@@ -44,6 +44,7 @@
| D644 | 便携指令文件没有体积上限 | **移除 Host 对便携指令文件施加的 32 KiB 单文件上限。全局与项目指令内容只受其他域同样拥有的便携实体负载上限约束,并在上传修订与校验远端修订时检查。UTF-8 校验、symlink 拒绝、作用域选择、映射与审批规则均不变。见 `03-runtime/22-config-sync.md` §2。** | 一个 33 KiB 的项目 `AGENTS.md` 会让整次采集以 `CONFIG_SYNC_LIMIT_EXCEEDED: instruction file is too large` 失败,而设置页只能把它显示为泛化的备份体积错误。 |
| D648 | 混合直接 DNS 结果时固定使用可接受地址 | **修订 ADR 0272:在直连路由上,当 DNS 同时包含被拒绝与可接受的结果时,技能市场会选择并固定到一个可接受地址,而不会让 Chromium 在这些地址中自行选择。第三方内容优先使用公网地址;仅在现有策略允许时使用 `benchmark` 假 IP。仅返回 ULA 或其他非公网地址时仍会拦截。代理与无法读取的路由保持现有策略。见 ADR 0321 与 E2E-SKILL-MARKET-NET-BOUNDARY。** | 双栈与透明代理 DNS 可能在可安全使用的地址旁返回未使用的合成 ULA 地址;固定已通过校验的地址可避免连接到被拒绝结果并消除误拦截。 |
| D649 | 云备份暂不对外开放 | **修订 D642 / D643:设置中的 `sync` 目的地重新带上 `developmentOnly: true`,因此打包构建会省略其导轨行、页面和设置搜索命中并回落到常规,开发构建则保留该目的地。开发者模式与它无关,它仍不带实验性徽章。同步行为、协议、Host schema 与持久化数据均不变;移除该标记即可对打包构建重新开放。见 `04-ux/06-settings-ia.md` 与 E2E-CONFIG-SYNC-webdav-portable-configuration。** | 加密 WebDAV 备份尚未准备好提供给打包构建用户,因此先保持已实现但不出现在界面上,直到正式开放。 |
+| D650 | 插件提供商出现在添加服务中 | **修订 ADR 0259:`contributes.providers[].category` 是可选分类;`description` 可提供一句简介。已加载且拥有现有 `provider.register` 权限的插件,可向 Host 渲染的添加服务选择器贡献带端点、尚未配置的 API Key 提供商。卡片只显示站名,悬停或键盘聚焦显示一句简介;分类可自定义。每个插件不设服务数量上限。空模型列表仅适用于带端点的 API Key 提供商,用户保存密钥后由 Host 发现并缓存模型。密钥仍通过现有提供商密钥路径保存,已配置的行从选择器隐藏。不提供 OAuth / 无认证行;不新增权限、运行时 API、提供商行或凭据迁移。见 ADR 0322、`07-plugins/02-plugin-manifest-schema.md` 与 E2E-PLUGIN-provider-catalog-add-service。** | 用户无法在常规添加服务流程中发现由清单声明的社区提供商;每个插件也需要自己分组站点,却不应拥有密钥界面。 |
| D450 | 签名的 macOS GitHub Release | **修订 D078 / ADR 0022:GitHub tag 发布使用身份 `Developer ID Application: XingYu Liu (DUV63RKYTW)` / 团队 `DUV63RKYTW`,通过 Actions 密钥(`CSC_LINK`、`CSC_KEY_PASSWORD`、`APPLE_ID`、`APPLE_APP_SPECIFIC_PASSWORD`、`APPLE_TEAM_ID`)对 macOS DMG/ZIP 做 Developer ID 签名、`notarytool` 公证、装订和 Gatekeeper 校验;缺少密钥则失败。无证书的本地未签名打包仍可用。`workflow_dispatch` 仅可把 `sign_macos: false` 用于未签名调试产物。打包的 macOS 走应用内 `electron-updater`(ZIP + 合并后的 `latest-mac.yml`);Linux deb/rpm 与 Windows 便携版 ZIP 仍为通知并打开发布页。禁止 afterPack/afterSign adhoc 签名(ADR 0278)。** | 正式 DMG 应无需 Gatekeeper 警告即可打开,已签名 macOS 安装可下载并重启到新 tag。见 ADR 0289、E2E-196c、E2E-067A。 |
## B. 辅助实现默认值
@@ -5299,3 +5300,14 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编
`apps/desktop/test/config-sync-settings.test.mjs` 覆盖,`pnpm test:e2e:settings-scroll`
的云同步探针跑的是开发构建。见 `04-ux/06-settings-ia.md` 与
E2E-CONFIG-SYNC-webdav-portable-configuration。
+
+## 2026-10-08 —— 插件提供商出现在添加服务中(D650)
+
+- ADR 0322 为插件提供商声明增加可选分类和一句简介,并让已加载且拥有
+ `provider.register` 权限的插件把未配置密钥的 API Key 提供商显示在 Host 渲染的
+ 添加服务选择器中。
+- 卡片仅显示站名,悬停或键盘聚焦时显示简介;每个插件不设服务数量上限。空模型列表会在用户
+ 保存密钥后由 Host 发现并缓存模型。密钥仍通过现有提供商密钥路径保存,已配置的行从选择器隐藏。
+ OAuth 和无认证声明不会出现。
+- 见 E2E-PLUGIN-provider-catalog-add-service 与
+ `07-plugins/02-plugin-manifest-schema.md` §5.4。
diff --git a/packages/plugin-sdk/src/index.test.ts b/packages/plugin-sdk/src/index.test.ts
index 9fdf8282a..c45e5ed29 100644
--- a/packages/plugin-sdk/src/index.test.ts
+++ b/packages/plugin-sdk/src/index.test.ts
@@ -782,6 +782,82 @@ describe("contributes.providers", () => {
expect(result.manifest?.contributes?.providers?.[0]?.models).toHaveLength(2);
});
+ it("accepts a custom or localized Add Service category", () => {
+ const permission = { ...base, permissions: ["provider.register"] };
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: { providers: [{ ...provider, category: "Community" }] },
+ }).ok,
+ ).toBe(true);
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: {
+ providers: [{
+ ...provider,
+ category: { en: "Community", "zh-CN": "公益站" },
+ }],
+ },
+ }).ok,
+ ).toBe(true);
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: { providers: [{ ...provider, category: { en: "Community" } as never }] },
+ }).error,
+ ).toMatch(/category\.zh-CN is required/);
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: { providers: [{ ...provider, category: " " }] },
+ }).error,
+ ).toMatch(/category must not be empty/);
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: {
+ providers: [{
+ ...provider,
+ category: { en: "", "zh-CN": "公益站" },
+ }],
+ },
+ }).error,
+ ).toMatch(/category\.en is required/);
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: { providers: [{ ...provider, category: "c".repeat(129) }] },
+ }).error,
+ ).toMatch(/category must be at most 128 characters/);
+ expect(
+ validateManifest({
+ ...permission,
+ contributes: {
+ providers: [{
+ ...provider,
+ category: { en: "Community", "zh-CN": "公".repeat(129) },
+ }],
+ },
+ }).error,
+ ).toMatch(/category\.zh-CN must be at most 128 characters/);
+ });
+
+ it("accepts a short localized introduction and rejects malformed or oversized copy", () => {
+ expect(validateContributions({ providers: [{
+ ...provider,
+ description: { en: "A community API.", "zh-CN": "社区公益 API 服务。" },
+ }] })).toBeUndefined();
+ expect(validateContributions({ providers: [{
+ ...provider,
+ description: { en: "A community API." } as never,
+ }] })).toMatch(/description\.zh-CN is required/);
+ expect(validateContributions({ providers: [{
+ ...provider,
+ description: "x".repeat(281),
+ }] })).toMatch(/description must be at most 280 characters/);
+ });
+
it("rejects a declaration without the provider.register permission", () => {
expect(validateManifest({ ...base, contributes: { providers: [provider] } }).error).toMatch(
/provider\.register permission/,
@@ -805,15 +881,15 @@ describe("contributes.providers", () => {
).toMatch(/unsupported authKind/);
});
- it("rejects a non-http baseUrl, an unbound model list, duplicate ids, and too many entries", () => {
+ it("validates endpoint, model counts, ids, empty dynamic lists and unlimited providers", () => {
expect(
validateContributions({
providers: [{ ...provider, baseUrl: "file:///etc/passwd" }],
}),
).toMatch(/http\(s\) URL/);
- expect(validateContributions({ providers: [{ ...provider, models: [] }] })).toMatch(
- /1 to 64 models/,
- );
+ expect(validateContributions({ providers: [{ ...provider, models: [] }] })).toBeUndefined();
+ expect(validateContributions({ providers: [{ ...provider, authKind: "oauth", models: [] }] }))
+ .toMatch(/may omit models only for an API-key provider/);
expect(
validateContributions({
providers: [{ ...provider, models: [{ id: "m" }, { id: "m" }] }],
@@ -827,9 +903,9 @@ describe("contributes.providers", () => {
);
expect(
validateContributions({
- providers: Array.from({ length: 9 }, (_, index) => ({ ...provider, id: `p${index}` })),
+ providers: Array.from({ length: 24 }, (_, index) => ({ ...provider, id: `p${index}` })),
}),
- ).toMatch(/at most 8 entries/);
+ ).toBeUndefined();
expect(
validateContributions({
providers: [{ ...provider, models: [{ id: "" }] }],
diff --git a/packages/plugin-sdk/src/index.ts b/packages/plugin-sdk/src/index.ts
index 4a577a299..231529bfa 100644
--- a/packages/plugin-sdk/src/index.ts
+++ b/packages/plugin-sdk/src/index.ts
@@ -141,7 +141,10 @@ export type PluginManifest = {
/**
* Providers this plugin adds to Settings' provider list. Requires the
* `provider.register` permission; each row is read-only for the user and
- * refreshed from this manifest on every load.
+ * refreshed from this manifest on every load. API-key providers are also
+ * offered in the Add Service chooser until the user stores a key. An
+ * optional category groups those chooser entries; it is display metadata
+ * and may be localized.
*/
providers?: PluginProviderContrib[];
settings?: PluginSettingContrib[];
@@ -524,9 +527,6 @@ export type PluginProviderOAuthContext = {
signal: AbortSignal;
};
-/** Upper bound on `contributes.providers` entries one plugin may declare. */
-export const MAX_PLUGIN_PROVIDERS_PER_PLUGIN = 8;
-
/** Upper bound on the model list of one contributed provider. */
export const MAX_PLUGIN_PROVIDER_MODELS = 64;
@@ -566,6 +566,10 @@ export type PluginProviderContrib = {
id: string;
/** Display name for the provider row; required and non-empty. */
name: string;
+ /** Optional Add Service chooser group; defaults to the plugin name. */
+ category?: string | PluginLocalizedString;
+ /** Optional short introduction shown on hover/focus in Add Service. */
+ description?: string | PluginLocalizedString;
/** Vendor the row is attributed to; `custom` when omitted. */
vendorKey?: string;
/** Endpoint the runtime reaches; must be an absolute http(s) URL. */
@@ -574,7 +578,7 @@ export type PluginProviderContrib = {
authKind?: PluginProviderAuthKind;
/** OAuth sign-in metadata; valid only when `authKind` is `oauth`. */
oauth?: PluginProviderOAuthContrib;
- /** 1..64 models with unique ids. */
+ /** Up to 64 models with unique ids. An empty list enables endpoint discovery after key setup. */
models: PluginProviderModelContrib[];
};
@@ -1702,9 +1706,6 @@ export function validateContributions(
const declaredProviders = contributes.providers ?? [];
if (!Array.isArray(declaredProviders)) return "contributes.providers must be an array";
- if (declaredProviders.length > MAX_PLUGIN_PROVIDERS_PER_PLUGIN) {
- return `contributes.providers allows at most ${MAX_PLUGIN_PROVIDERS_PER_PLUGIN} entries`;
- }
const providerIds = new Set<string>();
for (const provider of declaredProviders) {
if (!provider || typeof provider !== "object" || Array.isArray(provider)) {
@@ -1720,6 +1721,44 @@ export function validateContributions(
if (typeof provider.name !== "string" || !provider.name.trim()) {
return `provider "${provider.id}" requires a name`;
}
+ const categoryError = localizedStringError(
+ provider.category,
+ `provider "${provider.id}" category`,
+ );
+ if (categoryError) return categoryError;
+ if (typeof provider.category === "string") {
+ if (!provider.category.trim()) {
+ return `provider "${provider.id}" category must not be empty`;
+ }
+ if (provider.category.length > 128) {
+ return `provider "${provider.id}" category must be at most 128 characters`;
+ }
+ } else if (provider.category) {
+ for (const locale of ["en", "zh-CN"] as const) {
+ if (provider.category[locale].length > 128) {
+ return `provider "${provider.id}" category.${locale} must be at most 128 characters`;
+ }
+ }
+ }
+ const descriptionError = localizedStringError(
+ provider.description,
+ `provider "${provider.id}" description`,
+ );
+ if (descriptionError) return descriptionError;
+ if (typeof provider.description === "string") {
+ if (!provider.description.trim()) {
+ return `provider "${provider.id}" description must not be empty`;
+ }
+ if (provider.description.length > 280) {
+ return `provider "${provider.id}" description must be at most 280 characters`;
+ }
+ } else if (provider.description) {
+ for (const locale of ["en", "zh-CN"] as const) {
+ if (provider.description[locale].length > 280) {
+ return `provider "${provider.id}" description.${locale} must be at most 280 characters`;
+ }
+ }
+ }
if (
provider.vendorKey !== undefined &&
(typeof provider.vendorKey !== "string" || !provider.vendorKey.trim())
@@ -1788,8 +1827,14 @@ export function validateContributions(
if (!Array.isArray(provider.models)) {
return `provider "${provider.id}" requires models`;
}
- if (provider.models.length === 0 || provider.models.length > MAX_PLUGIN_PROVIDER_MODELS) {
- return `provider "${provider.id}" declares 1 to ${MAX_PLUGIN_PROVIDER_MODELS} models`;
+ if (provider.models.length > MAX_PLUGIN_PROVIDER_MODELS) {
+ return `provider "${provider.id}" declares at most ${MAX_PLUGIN_PROVIDER_MODELS} models`;
+ }
+ if (
+ provider.models.length === 0 &&
+ ((provider.authKind ?? "api_key") !== "api_key" || !provider.baseUrl)
+ ) {
+ return `provider "${provider.id}" may omit models only for an API-key provider with a baseUrl`;
}
const modelIds = new Set<string>();
for (const model of provider.models) {
diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.ts
index 255bd7761..60fda0e7a 100644
--- a/packages/shared/src/protocol.ts
+++ b/packages/shared/src/protocol.ts
@@ -292,6 +292,7 @@ export const IPC = {
pluginLauncherToggle: "pi-desktop/pluginLauncher/toggle",
pluginLauncherDismiss: "pi-desktop/pluginLauncher/dismiss",
pluginThemes: "pi-desktop/plugin/themes",
+ pluginProviderCatalog: "pi-desktop/plugin/providerCatalog",
pluginScenicThemesDestinations: "pi-desktop/plugin/scenicThemes/destinations",
pluginScenicThemesSetBlur: "pi-desktop/plugin/scenicThemes/setBlur",
pluginServices: "pi-desktop/plugin/services",
diff --git a/packages/shared/src/types/plugins.ts b/packages/shared/src/types/plugins.ts
index f877223d5..d2bef8242 100644
--- a/packages/shared/src/types/plugins.ts
+++ b/packages/shared/src/types/plugins.ts
@@ -138,6 +138,21 @@ export type PluginViewMeta = {
order: number;
};
+/**
+ * An API-key provider a loaded plugin has made available in Add Service.
+ * The host resolves the category for the active locale and returns no runtime
+ * code or credentials; the row itself remains host-owned.
+ */
+export type PluginProviderCatalogMeta = {
+ pluginId: string;
+ /** Host provider row id: `plugin:<pluginId>:<contributionId>`. */
+ providerId: string;
+ pluginName: string;
+ category: string;
+ /** Optional one-sentence introduction, resolved for the active app locale. */
+ description?: string;
+};
+
/** A data-only scenic Settings destination rendered by the host React tree. */
export type PluginScenicThemesDestinationMeta = {
pluginId: string;