From ea78c09615fde8747a4cb603bf88767a5e9f0941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 17 Apr 2026 02:00:52 -0400 Subject: [PATCH] refactor(connector): adapt buildDefaultConnectorRows to pi-mono shape Pi-mono's ConnectorDefinition no longer carries defaultCommand, configurationDoc, capabilityMatrix, or listModels. Synthesise sane defaults for the legacy ConnectorRecord fields: - command defaults to empty (pi-mono has no CLI entrypoint) - capabilityMatrix collapses to a uniform pi-mono baseline - configurationDoc is generated from the auth descriptor using the existing buildOAuthDoc / buildApiKeyDoc / buildCloudDoc helpers These columns stay in the schema so the UI surfaces that still read them continue to function; the worker and resolver no longer branch on capability flags since pi-mono handles dispatch uniformly. --- src/main/connectors.ts | 58 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/main/connectors.ts b/src/main/connectors.ts index 2af23d73..a90ca9e9 100644 --- a/src/main/connectors.ts +++ b/src/main/connectors.ts @@ -1,5 +1,6 @@ -import type { ConnectorRecord } from "@shared/types"; -import { CONNECTORS } from "./connector-definitions"; +import type { CapabilityMatrix, ConnectorRecord } from "@shared/types"; +import { CONNECTORS, type ConnectorDefinition } from "./connector-definitions"; +import { buildApiKeyDoc, buildCloudDoc, buildOAuthDoc } from "./connector-definitions-docs"; export { CONNECTORS } from "./connector-definitions"; export type { ConnectorDefinition } from "./connector-definitions"; export { findConnectorDefinition, listFeaturedOnboardingConnectors } from "./connector-definitions-lookup"; @@ -16,6 +17,27 @@ const RESERVED_ENV_BINDING_KEYS = new Set([ "PWD", ]); +/** + * Pi-mono drives all provider dispatch through pi-ai, so the adapter-era + * capability matrix now collapses to a uniform baseline. These values are + * still written into the `connectors` table for legacy UI surfaces that read + * them, but the worker and resolver no longer branch on them. + */ +const PI_MONO_CAPABILITIES: CapabilityMatrix = { + sessionResume: true, + gracefulCancel: true, + modelDiscovery: true, + structuredTranscript: true, + costAttribution: true, +}; + +/** + * Legacy `ConnectorRecord.command` column. Pi-mono has no CLI command — the + * worker calls pi-ai directly — so this is an empty string that the UI + * treats as "managed by pi-mono". + */ +const PI_MONO_DEFAULT_COMMAND = ""; + export function getConnectorDefinition(id: string) { const definition = CONNECTORS.find((entry) => entry.id === id); if (!definition) { @@ -44,6 +66,30 @@ export function listInvalidEnvBindingKeys(text: string): string[] { }); } +function renderConfigurationDoc(definition: ConnectorDefinition): string { + switch (definition.auth.type) { + case "oauth": + return buildOAuthDoc(definition.label, definition.auth.oauthId); + case "api_key": + return buildApiKeyDoc(definition.label, definition.auth.envKey); + case "aws": + return buildCloudDoc( + definition.label, + "Credentials are discovered via the standard AWS chain (profile, IAM keys, Bedrock bearer token, ECS roles, or IRSA).", + ); + case "azure": + return buildCloudDoc( + definition.label, + "Provide AZURE_OPENAI_API_KEY plus AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME.", + ); + case "gcp_adc": + return buildCloudDoc( + definition.label, + "Uses Google Cloud Application Default Credentials. Run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS.", + ); + } +} + export function buildDefaultConnectorRows(existing: Array> = []): ConnectorRecord[] { const byId = new Map(existing.map((record) => [record.id, record])); return CONNECTORS.map((definition) => { @@ -53,16 +99,16 @@ export function buildDefaultConnectorRows(existing: Array