Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

chore: merge origin/dev into feat/ux-improvements-32

M3f9bb304ef94
diff --cc control-ui/app/mcp-servers/[name]/edit/page.tsx
index ded5ec8d1,a212ed035..ff65e59db
--- a/control-ui/app/mcp-servers/[name]/edit/page.tsx
+++ b/control-ui/app/mcp-servers/[name]/edit/page.tsx
@@@ -44,7 -47,30 +45,8 @@@ import
sortAccessPrincipals,
} from '@lib/connectorAccess'
import type { EgressEditorStatus } from '@lib/egressModel'
+ import { extractOAuthImmutables, oauthClientSecretRefName } from '@lib/oauthInstall'
-/**
- * Narrows `server.spec.envSecret` (typed as `unknown` on the generic
- * `AnyRecord` spec) into the shape UpdateConnectorCredentials needs. A
- * malformed or partial envSecret (missing name, keys not an array, or no
- * usable key mappings) is treated the same as "no envSecret" — there is
- * nothing safely rotatable through this form either way.
- */
-function resolveEnvSecret(spec: Record<string, unknown> | undefined): EnvSecret | undefined {
- const raw = spec?.envSecret
- if (!raw || typeof raw !== 'object') return undefined
- const candidate = raw as { name?: unknown; keys?: unknown }
- if (typeof candidate.name !== 'string' || !Array.isArray(candidate.keys)) return undefined
- const keys = candidate.keys.filter(
- (k): k is EnvSecretKeyMapping =>
- Boolean(k) &&
- typeof (k as EnvSecretKeyMapping).secretKey === 'string' &&
- typeof (k as EnvSecretKeyMapping).envVar === 'string'
- )
- if (keys.length === 0) return undefined
- return { name: candidate.name, keys }
-}
-
function parseConnectorEditTab(value: string | string[] | undefined): ConnectorEditTab {
const candidate = Array.isArray(value) ? value[0] : value
return CONNECTOR_EDIT_TABS.find(tab => tab === candidate) ?? CONNECTOR_EDIT_DEFAULT_TAB
@@@ -262,9 -302,9 +264,12 @@@ export default function EditMcpServerPa
const envSecret = server?.spec
? resolveEnvSecret(server.spec as Record<string, unknown>)
: undefined
+ const nonCanonicalSecretName = server?.spec
+ ? nonCanonicalEnvSecretName(server.spec as Record<string, unknown>)
+ : undefined
+ const oauthImmutables = server?.spec
+ ? extractOAuthImmutables(server.spec as Record<string, unknown>)
+ : null
const registryCredentialSource = useMemo(
() => resolveRegistryCredentialSource(server?.metadata),
[server?.metadata]
@@@ -330,12 -370,17 +335,20 @@@
) : server ? (
activeTab === 'credentials' ? (
<div className="cu-connector-edit-form">
- {oauthImmutables ? (
- // An OAuth connector's credential lives in its clientSecretRef
- // Secret, not spec.envSecret — so UpdateConnectorCredentials would
- // fall to its "nothing to rotate here" branch and mislead. Show the
- // accurate OAuth panel instead (D-B7; rotation is a follow-up).
+ {nonCanonicalSecretName !== undefined ? (
+ <div className="cu-banner cu-banner--error" role="alert">
+ This connector stores a non-canonical Secret name:{' '}
+ <code>{JSON.stringify(nonCanonicalSecretName)}</code>. Correct the connector
+ reference before editing credentials.
+ </div>
++ ) : oauthImmutables ? (
++ // OAuth credentials live in clientSecretRef, not envSecret.
+ <OAuthImmutableFields
+ oauth={oauthImmutables}
+ credentialSecretName={oauthClientSecretRefName(
+ server.spec as Record<string, unknown>
+ )}
+ />
) : (
<UpdateConnectorCredentials
serverName={name}
diff --cc control-ui/test/fixtures/directCrdMcpServer.ts
index 000000000,000000000..7d0128872
new file mode 100644
--- /dev/null
+++ b/control-ui/test/fixtures/directCrdMcpServer.ts
@@@ -1,0 -1,0 +1,45 @@@
++import { secretFound } from '../../components/__tests__/fixtures/secretResolvedConditions'
++import type { EnvSecret, McpServerResource } from '../../lib/api'
++
++const HCC_RECONCILED_AT = '2026-01-01T00:00:00.000Z'
++
++/** Direct CRD API input, deliberately separate from registry install output.
++ * It covers shared Secret references, noncanonical names, and distinct key-to-
++ * environment mappings that the registry install producer does not emit. */
++export function buildDirectCrdMcpServerReference(options: {
++ name: string
++ secretName: string
++ secretKey?: string
++ envVar?: string
++ annotations?: Record<string, string>
++ labels?: Record<string, string>
++}): McpServerResource {
++ const envSecret: EnvSecret = {
++ name: options.secretName,
++ keys: [
++ {
++ secretKey: options.secretKey ?? 'api-key',
++ envVar: options.envVar ?? 'LINEAR_API_KEY',
++ },
++ ],
++ }
++ return {
++ metadata: {
++ name: options.name,
++ namespace: 'mcp-server',
++ ...(options.annotations ? { annotations: options.annotations } : {}),
++ ...(options.labels ? { labels: options.labels } : {}),
++ },
++ spec: {
++ image: 'ghcr.io/acme/linear-mcp:1.4.0',
++ contextRef: 'default',
++ enabled: true,
++ managed: true,
++ transport: { type: 'streamableHttp', port: 3000 },
++ envSecret,
++ },
++ ...(envSecret.name.trim() === envSecret.name
++ ? { status: { conditions: [secretFound({ at: HCC_RECONCILED_AT })] } }
++ : {}),
++ }
++}
diff --cc control-ui/test/fixtures/mcpServer.ts
index f8045ec18,000000000..46b27b868
mode 100644,000000..100644
--- a/control-ui/test/fixtures/mcpServer.ts
+++ b/control-ui/test/fixtures/mcpServer.ts
@@@ -1,83 -1,0 +1,43 @@@
+import { secretFound } from '../../components/__tests__/fixtures/secretResolvedConditions'
- import type { EnvSecret, McpServerResource } from '../../lib/api'
++import type { McpServerResource } from '../../lib/api'
+import {
+ registryEnvSecret,
+ registryMcpServerMetadata,
+ registrySecretName,
+} from './registryMcpServerProducer'
+
+const HCC_RECONCILED_AT = '2026-01-01T00:00:00.000Z'
+
+/** Registry install -> API list -> HCC reconcile. Callers supply registry
+ * inputs only; the producer owns the Secret reference, metadata, and status. */
+export function buildRegistryMcpServerReference(options: {
+ name: string
+ catalogId: string
+ catalogVersion: string
+ credentialKeyNames?: string[]
+}): McpServerResource {
+ const secretName = registrySecretName(options.name)
+ const spec = {
+ image: 'ghcr.io/acme/linear-mcp:1.4.0',
+ contextRef: 'default',
+ enabled: true,
+ managed: true,
+ transport: { type: 'streamableHttp', port: 3000 },
+ envSecret: registryEnvSecret(secretName, options.credentialKeyNames ?? ['api-key']),
+ }
+ return {
+ metadata: registryMcpServerMetadata({
+ serverName: options.name,
+ catalogId: options.catalogId,
+ catalogVersion: options.catalogVersion,
+ namespace: 'mcp-server',
+ spec,
+ }),
+ spec,
+ status: { conditions: [secretFound({ at: HCC_RECONCILED_AT })] },
+ }
+}
+
- /** Direct CRD API input, deliberately separate from registry install output.
- * It covers shared Secret references, noncanonical names, and distinct key-to-
- * environment mappings that the registry install producer does not emit. */
- export function buildDirectCrdMcpServerReference(options: {
- name: string
- secretName: string
- secretKey?: string
- envVar?: string
- annotations?: Record<string, string>
- labels?: Record<string, string>
- }): McpServerResource {
- const envSecret: EnvSecret = {
- name: options.secretName,
- keys: [
- {
- secretKey: options.secretKey ?? 'api-key',
- envVar: options.envVar ?? 'LINEAR_API_KEY',
- },
- ],
- }
- return {
- metadata: {
- name: options.name,
- namespace: 'mcp-server',
- ...(options.annotations ? { annotations: options.annotations } : {}),
- ...(options.labels ? { labels: options.labels } : {}),
- },
- spec: {
- image: 'ghcr.io/acme/linear-mcp:1.4.0',
- contextRef: 'default',
- enabled: true,
- managed: true,
- transport: { type: 'streamableHttp', port: 3000 },
- envSecret,
- },
- ...(envSecret.name.trim() === envSecret.name
- ? { status: { conditions: [secretFound({ at: HCC_RECONCILED_AT })] } }
- : {}),
- }
- }
-
- /** Existing edit-page test harness models direct CRD inputs. */
- export const buildMcpServerReference = buildDirectCrdMcpServerReference
++export { buildDirectCrdMcpServerReference } from './directCrdMcpServer'
++/** Compatibility name for the existing direct-CRD edit-page tests. */
++export { buildDirectCrdMcpServerReference as buildMcpServerReference } from './directCrdMcpServer'
diff --cc control-ui/test/fixtures/registryMcpServerProducer.ts
index 8e0a0db7f,000000000..e1c91b761
mode 100644,000000..100644
--- a/control-ui/test/fixtures/registryMcpServerProducer.ts
+++ b/control-ui/test/fixtures/registryMcpServerProducer.ts
@@@ -1,180 -1,0 +1,237 @@@
+import { readFileSync } from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import ts from 'typescript'
+import {
+ REGISTRY_OPERATION_ID_ANNOTATION,
+ REGISTRY_SPEC_DIGEST_ANNOTATION,
+ registrySpecDigest,
+} from '../../../control-api/src/services/registryMutation'
+import type { EnvSecret, McpServerResource } from '../../lib/api'
+
+const REGISTRY_PATH = path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../control-api/src/routes/admin/registry.ts'
+)
++const GATEWAY_PATH = path.resolve(
++ path.dirname(fileURLToPath(import.meta.url)),
++ '../../../control-api/test/mockGateway.ts'
++)
+
+/** Execute the registry install producer's Secret-name and envSecret expressions. */
+function registrySecretFactory(): {
+ name: (serverName: string) => string
+ envSecret: (secretName: string, keyNames: string[]) => EnvSecret
+ metadata: (input: RegistryMetadataInput) => NonNullable<McpServerResource['metadata']>
+} {
+ const source = ts.createSourceFile(
+ REGISTRY_PATH,
+ readFileSync(REGISTRY_PATH, 'utf8'),
+ ts.ScriptTarget.Latest,
+ true
+ )
+ const assignments: ts.Expression[] = []
+ const secretNames: ts.Expression[] = []
+ const registryLabels: ts.Expression[] = []
+ const registryAnnotations: ts.Expression[] = []
+ const registryResourceMetadata: ts.Expression[] = []
+ let catalogAnnotations: ts.FunctionDeclaration | undefined
+
+ function visit(node: ts.Node): void {
+ if (
+ ts.isVariableDeclaration(node) &&
+ node.name.getText(source) === 'secretName' &&
+ node.initializer?.getText(source).includes('${serverName}')
+ ) {
+ secretNames.push(node.initializer)
+ }
+ if (ts.isFunctionDeclaration(node) && node.name?.text === 'catalogAnnotations') {
+ catalogAnnotations = node
+ }
+ if (ts.isVariableDeclaration(node) && node.initializer) {
+ const variableName = node.name.getText(source)
+ if (variableName === 'registryLabels' && node.pos > 0) {
+ registryLabels.push(node.initializer)
+ }
+ if (
+ variableName === 'registryAnnotations' &&
+ node.initializer.getText(source).includes('registrySpecDigest(mcpServerSpec)')
+ ) {
+ registryAnnotations.push(node.initializer)
+ }
+ }
+ if (
+ ts.isBinaryExpression(node) &&
+ node.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
+ node.left.getText(source) === 'mcpServerSpec.envSecret'
+ ) {
+ let parent: ts.Node | undefined = node.parent
+ while (parent && !ts.isIfStatement(parent)) parent = parent.parent
+ if (
+ parent &&
+ ts.isIfStatement(parent) &&
+ parent.expression.getText(source) === 'credRequired'
+ ) {
+ assignments.push(node.right)
+ }
+ }
+ if (
+ ts.isCallExpression(node) &&
+ node.expression.getText(source) === 'gateway.createResource' &&
+ node.arguments[0]?.getText(source) === "'mcpservers'" &&
+ ts.isObjectLiteralExpression(node.arguments[1])
+ ) {
+ const resource = node.arguments[1]
+ const metadata = resource.properties.find(
+ property =>
+ ts.isPropertyAssignment(property) && property.name.getText(source) === 'metadata'
+ )
+ if (
+ metadata &&
+ ts.isPropertyAssignment(metadata) &&
+ metadata.initializer.getText(source).includes('registryAnnotations')
+ ) {
+ registryResourceMetadata.push(metadata.initializer)
+ }
+ }
+ ts.forEachChild(node, visit)
+ }
+ visit(source)
+ if (
+ assignments.length !== 1 ||
+ !ts.isObjectLiteralExpression(assignments[0]) ||
+ secretNames.length !== 1 ||
+ registryAnnotations.length !== 1 ||
+ registryResourceMetadata.length !== 1 ||
+ !catalogAnnotations
+ ) {
+ throw new Error('Registry Secret producer changed; rederive the frontend fixture')
+ }
+
+ const expression = assignments[0].getText(source)
+ const nameExpression = secretNames[0].getText(source)
+ const labels = registryLabels
+ .filter(candidate => candidate.pos < registryAnnotations[0].pos)
+ .at(-1)
+ if (!labels) throw new Error('Registry labels producer changed; rederive the frontend fixture')
++ const gatewaySource = ts.createSourceFile(
++ GATEWAY_PATH,
++ readFileSync(GATEWAY_PATH, 'utf8'),
++ ts.ScriptTarget.Latest,
++ true
++ )
++ const gatewayMetadata: ts.Expression[] = []
++ function visitGateway(node: ts.Node): void {
++ if (
++ ts.isVariableDeclaration(node) &&
++ node.name.getText(gatewaySource) === 'row' &&
++ node.initializer &&
++ ts.isObjectLiteralExpression(node.initializer)
++ ) {
++ const metadata = node.initializer.properties.find(
++ property =>
++ ts.isPropertyAssignment(property) && property.name.getText(gatewaySource) === 'metadata'
++ )
++ if (
++ metadata &&
++ ts.isPropertyAssignment(metadata) &&
++ metadata.initializer.getText(gatewaySource).includes('this.allocateUid(plural, ns')
++ ) {
++ gatewayMetadata.push(metadata.initializer)
++ }
++ }
++ ts.forEachChild(node, visitGateway)
++ }
++ visitGateway(gatewaySource)
++ if (gatewayMetadata.length !== 1) {
++ throw new Error('API response metadata producer changed; rederive the frontend fixture')
++ }
+ const compiled = ts.transpileModule(
+ `const produce = (secretName, credSchema) => (${expression});
+ const produceName = (serverName) => (${nameExpression});
+ ${catalogAnnotations.getText(source).replace(/^export /, '')}
+ const produceMetadata = (body, serverName, targetNs, isLocal, mcpServerSpec, resourceOperationId) => {
+ const registryLabels = ${labels.getText(source)};
+ const registryAnnotations = ${registryAnnotations[0].getText(source)};
- return { ...(${registryResourceMetadata[0].getText(source)}), namespace: targetNs };
++ return (${registryResourceMetadata[0].getText(source)});
+ };`,
+ { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.None } }
+ ).outputText
+ const producers = new Function(
+ 'REGISTRY_OPERATION_ID_ANNOTATION',
+ 'REGISTRY_SPEC_DIGEST_ANNOTATION',
+ 'registrySpecDigest',
+ `${compiled}\nreturn { produce, produceName, produceMetadata };`
+ )(REGISTRY_OPERATION_ID_ANNOTATION, REGISTRY_SPEC_DIGEST_ANNOTATION, registrySpecDigest) as {
+ produce: (secretName: string, credSchema: { keys: { name: string }[] }) => EnvSecret
+ produceName: (serverName: string) => string
+ produceMetadata: (
+ body: { registryEntryName: string; registryEntryVersion: string },
+ serverName: string,
+ targetNs: string,
+ isLocal: boolean,
+ mcpServerSpec: Record<string, unknown>,
+ resourceOperationId: string
+ ) => NonNullable<McpServerResource['metadata']>
+ }
++ const gatewayCompiled = ts.transpileModule(
++ `function produceResponseMetadata(body, ns, plural) {
++ return (${gatewayMetadata[0].getText(gatewaySource)});
++ }`,
++ { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.None } }
++ ).outputText
++ const produceResponseMetadata = new Function(
++ `${gatewayCompiled}\nreturn produceResponseMetadata;`
++ )() as (
++ this: { allocateUid: (plural: string, namespace: string, name: string) => string },
++ body: { metadata: NonNullable<McpServerResource['metadata']> },
++ namespace: string,
++ plural: string
++ ) => NonNullable<McpServerResource['metadata']>
+
+ return {
+ name: producers.produceName,
+ envSecret: (secretName, keyNames) =>
+ producers.produce(secretName, { keys: keyNames.map(name => ({ name })) }),
- metadata: input =>
- producers.produceMetadata(
++ metadata: input => {
++ const metadata = producers.produceMetadata(
+ { registryEntryName: input.catalogId, registryEntryVersion: input.catalogVersion },
+ input.serverName,
+ input.namespace,
+ true,
+ input.spec,
+ '00000000-0000-4000-8000-000000000001'
- ),
++ )
++ return produceResponseMetadata.call(
++ { allocateUid: (plural, namespace, name) => `uid-${plural}-${namespace}-${name}-1` },
++ { metadata },
++ input.namespace,
++ 'mcpservers'
++ )
++ },
+ }
+}
+
+const registrySecret = registrySecretFactory()
+
+type RegistryMetadataInput = {
+ serverName: string
+ catalogId: string
+ catalogVersion: string
+ namespace: string
+ spec: Record<string, unknown>
+}
+
+export function registryEnvSecret(secretName: string, keyNames: string[]): EnvSecret {
+ return registrySecret.envSecret(secretName, keyNames)
+}
+
+export function registrySecretName(serverName: string): string {
+ return registrySecret.name(serverName)
+}
+
+export function registryMcpServerMetadata(
+ input: RegistryMetadataInput
+): NonNullable<McpServerResource['metadata']> {
+ return registrySecret.metadata(input)
+}