Skip to content

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

TypeScript

fix: close production tsc holes for grok-subscription

Jose Gabriel Ramirez Encinas62c2bf0f8688
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 6674f48de..fca5fe414 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.564",
+ "version": "0.1.565",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.564",
+ "version": "0.1.565",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --git a/control-api/package.json b/control-api/package.json
index cdf588a79..a85620e93 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.564",
+ "version": "0.1.565",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/routes/admin/recipes.ts b/control-api/src/routes/admin/recipes.ts
index e754477b7..9cd7ae80b 100644
--- a/control-api/src/routes/admin/recipes.ts
+++ b/control-api/src/routes/admin/recipes.ts
@@ -1280,10 +1280,21 @@ function recipeHasPluginWorkloadSdk(spec?: Record<string, unknown>): boolean {
return Boolean(sdk && typeof sdk === 'object' && !Array.isArray(sdk))
}
+function recipeAnnotationStrings(
+ annotations: Record<string, unknown> | undefined
+): Record<string, string> | undefined {
+ if (!annotations) return undefined
+ const out: Record<string, string> = {}
+ for (const [key, value] of Object.entries(annotations)) {
+ if (typeof value === 'string') out[key] = value
+ }
+ return out
+}
+
function readRequestedCodexRecipeGrant(body: RecipeBody): string {
const result = readSubscriptionConnectionRef({
provider: 'codex-subscription',
- annotations: body.metadata?.annotations,
+ annotations: recipeAnnotationStrings(body.metadata?.annotations),
})
if (!result.ok) {
throw new RecipeGrantAnnotationDisagreeError(result.message)
@@ -1354,7 +1365,7 @@ function bodyHasCodexGrantAnnotation(body: RecipeBody): boolean {
function readRequestedGrokRecipeGrant(body: RecipeBody): string {
const result = readSubscriptionConnectionRef({
provider: 'grok-subscription',
- annotations: body.metadata?.annotations,
+ annotations: recipeAnnotationStrings(body.metadata?.annotations),
})
if (!result.ok) {
throw new RecipeGrantAnnotationDisagreeError(result.message)
diff --git a/control-api/src/services/grokSubscriptionOAuth.ts b/control-api/src/services/grokSubscriptionOAuth.ts
index 11f697b36..099265ca7 100644
--- a/control-api/src/services/grokSubscriptionOAuth.ts
+++ b/control-api/src/services/grokSubscriptionOAuth.ts
@@ -169,11 +169,13 @@ export type GrokDevicePollResult =
| { status: 'expired' | 'denied' }
| { status: 'connected'; connection: GrokSubscriptionSafeConnection }
-export type GrokCatalogSyncResult = {
- ok: boolean
- catalogStatus: GrokCatalogOutcome | 'never_synced'
- reason?: GrokOAuthErrorCode | 'catalog_sync_failed' | 'stale_revision' | 'no_grant'
-}
+export type GrokCatalogSyncResult =
+ | { ok: true; catalogStatus: 'ready'; connection: GrokSubscriptionSafeConnection }
+ | {
+ ok: false
+ catalogStatus: GrokCatalogOutcome | 'never_synced'
+ reason?: GrokOAuthErrorCode | 'catalog_sync_failed' | 'stale_revision' | 'no_grant'
+ }
export async function getGrokSubscriptionConnection(
deps: GrokOAuthDeps
@@ -399,7 +401,7 @@ export async function runGrokCatalogSync(
if (synced.outcome !== 'ready') {
return { ok: false, catalogStatus: synced.outcome }
}
- return { ok: true, catalogStatus: 'ready' }
+ return { ok: true, catalogStatus: 'ready', connection: synced.connection }
} catch (err) {
log.warn(
{ err, event: 'grok_catalog_auto_sync_failed', connectionKey: key },
diff --git a/control-api/src/services/modelsDevClient.ts b/control-api/src/services/modelsDevClient.ts
index 5cfa54f65..f8c14ebeb 100644
--- a/control-api/src/services/modelsDevClient.ts
+++ b/control-api/src/services/modelsDevClient.ts
@@ -88,7 +88,10 @@ export type RawModelsDevCatalog = Record<string, RawModelsDevProvider>
* only ever review candidates — the operator's hand-added `source='manual'`
* rows (deployment names, `us.anthropic.*` profiles) are never touched (§11.2).
*/
-export type ModelsDevMappedProviderId = Exclude<LlmProviderId, 'codex-subscription'>
+export type ModelsDevMappedProviderId = Exclude<
+ LlmProviderId,
+ 'codex-subscription' | 'grok-subscription'
+>
export const PROVIDER_KEY_MAP: Readonly<Record<ModelsDevMappedProviderId, string>> = {
openai: 'openai',
@@ -399,7 +402,10 @@ export function mapCatalogToProviders(
): Record<LlmProviderId, DiscoveredModel[]> {
const out = Object.create(null) as Record<LlmProviderId, DiscoveredModel[]>
for (const providerId of PROVIDER_IDS) {
- const key = providerId === 'codex-subscription' ? undefined : PROVIDER_KEY_MAP[providerId]
+ const key =
+ providerId === 'codex-subscription' || providerId === 'grok-subscription'
+ ? undefined
+ : PROVIDER_KEY_MAP[providerId]
const entry = key ? catalog[key] : undefined
const models: DiscoveredModel[] = []
out[providerId] = models
diff --git a/control-api/test/services.modelsDevClient.test.ts b/control-api/test/services.modelsDevClient.test.ts
index 2617ff477..1bebe9f4b 100644
--- a/control-api/test/services.modelsDevClient.test.ts
+++ b/control-api/test/services.modelsDevClient.test.ts
@@ -37,14 +37,17 @@ const FIXTURE: RawModelsDevCatalog = {
}
describe('modelsDevClient — PROVIDER_KEY_MAP', () => {
- it('maps every static provider to a models.dev key and excludes the Codex broker', () => {
- const staticIds = PROVIDER_IDS.filter(id => id !== 'codex-subscription')
+ it('maps every static provider to a models.dev key and excludes oauth-broker ids', () => {
+ const staticIds = PROVIDER_IDS.filter(
+ id => id !== 'codex-subscription' && id !== 'grok-subscription'
+ )
for (const id of staticIds) {
expect(typeof PROVIDER_KEY_MAP[id]).toBe('string')
expect(PROVIDER_KEY_MAP[id].length).toBeGreaterThan(0)
}
expect(Object.keys(PROVIDER_KEY_MAP).sort()).toEqual([...staticIds].sort())
expect('codex-subscription' in PROVIDER_KEY_MAP).toBe(false)
+ expect('grok-subscription' in PROVIDER_KEY_MAP).toBe(false)
})
it('pins the non-obvious / ambiguous choices (zai coding-plan, bailian→alibaba)', () => {
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index cb7b4f1de..105b5d6a4 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.338",
+ "version": "0.1.339",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.338",
+ "version": "0.1.339",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index 8589830d5..b217eb623 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.338",
+ "version": "0.1.339",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/config/configStore.test.ts b/mcp-host/src/config/configStore.test.ts
index b5b7babc5..221ccebd0 100644
--- a/mcp-host/src/config/configStore.test.ts
+++ b/mcp-host/src/config/configStore.test.ts
@@ -875,7 +875,6 @@ describe('ConfigStore — allowlist tier (R3)', () => {
catalogRevision: 5,
credentialRevision: 2,
connectionKey: 'team-grok',
- models: ['grok-4.6'],
})
expect(store.allowedModels().get('grok-subscription')).toEqual([{ model: 'grok-4.6' }])
expect(store.codexPolicyBinding()?.catalogRevision).toBe(99)
diff --git a/mcp-host/src/config/configStore.ts b/mcp-host/src/config/configStore.ts
index 1f2a518c9..3d1c8281d 100644
--- a/mcp-host/src/config/configStore.ts
+++ b/mcp-host/src/config/configStore.ts
@@ -38,6 +38,7 @@ import {
toGrokPolicyBinding,
toPolicyBinding,
} from '@clerum/codex-catalog-projection'
+import type { GrokPolicyBinding } from '../llm/grokPolicyBinding'
import { assignedConnectionRef } from '../llm/hostLlmBinding'
import {
ALL_PROVIDERS,
@@ -498,8 +499,16 @@ export class ConfigStore {
* Null when the CM is absent, the Grok map is missing, or the assigned key
* is unassigned. Never reads Codex annotations.
*/
- grokPolicyBinding(): CodexPolicyBinding | null {
- return this.grokBinding
+ grokPolicyBinding(): GrokPolicyBinding | null {
+ const binding = this.grokBinding
+ if (typeof binding?.connectionKey !== 'string' || binding.connectionKey.length === 0) {
+ return null
+ }
+ return {
+ catalogRevision: binding.catalogRevision,
+ credentialRevision: binding.credentialRevision,
+ connectionKey: binding.connectionKey,
+ }
}
// ─── Bootstrap (initial list) ────────────────────────────────────────
diff --git a/mcp-host/src/pluginWorkloadSdk/bootstrapIdentity.oauthBrokerExtract.test.ts b/mcp-host/src/pluginWorkloadSdk/bootstrapIdentity.oauthBrokerExtract.test.ts
index 382cd8150..ec1492d6c 100644
--- a/mcp-host/src/pluginWorkloadSdk/bootstrapIdentity.oauthBrokerExtract.test.ts
+++ b/mcp-host/src/pluginWorkloadSdk/bootstrapIdentity.oauthBrokerExtract.test.ts
@@ -1,4 +1,6 @@
import { describe, expect, it, vi } from 'vitest'
+import type { LlmProvider } from '../llm/registryCore'
+import { configurePluginWorkloadSdkBootstrapIdentity } from './bootstrapIdentity'
vi.mock('@clerum/llm-providers', async () => {
const actual =
@@ -14,23 +16,22 @@ vi.mock('@clerum/llm-providers', async () => {
}
})
-vi.mock('../llm/registryCore.js', async () => {
- const actual =
- await vi.importActual<typeof import('../llm/registryCore.js')>('../llm/registryCore.js')
+vi.mock('../llm/registryCore', async () => {
+ const actual = await vi.importActual<typeof import('../llm/registryCore')>('../llm/registryCore')
return {
...actual,
isLlmProvider: (id: string) => actual.isLlmProvider(id) || id === 'fixture-broker',
}
})
-const { configurePluginWorkloadSdkBootstrapIdentity } = await import('./bootstrapIdentity.js')
+const FIXTURE_BROKER = 'fixture-broker' as LlmProvider
describe('oauth-broker extract bootstrap', () => {
it('uses contractVersion 3 for an injected fixture broker', async () => {
const result = await configurePluginWorkloadSdkBootstrapIdentity(
{
capabilityFamily: 'promptBridge',
- provider: 'fixture-broker',
+ provider: FIXTURE_BROKER,
model: 'fixture-1',
},
{ capabilityFamily: 'promptBridge' }
diff --git a/mcp-host/src/pluginWorkloadSdk/sdkOnlyGrokBinding.ts b/mcp-host/src/pluginWorkloadSdk/sdkOnlyGrokBinding.ts
index f61f29b4f..832abb5b1 100644
--- a/mcp-host/src/pluginWorkloadSdk/sdkOnlyGrokBinding.ts
+++ b/mcp-host/src/pluginWorkloadSdk/sdkOnlyGrokBinding.ts
@@ -1,5 +1,5 @@
-import type { CodexPolicyBinding } from '@clerum/codex-catalog-projection'
import { computeGrokPolicyHash } from '@clerum/grok-provider-attempt-contract'
+import type { GrokPolicyBinding } from '../llm/grokPolicyBinding'
import {
type PluginWorkloadSdkCodexBindingProof,
isPluginWorkloadSdkCodexBindingProof,
@@ -19,13 +19,12 @@ export function readSdkOnlyGrokBinding(): PluginWorkloadSdkCodexBindingProof | n
return current
}
-export function sdkOnlyGrokBindingAsPolicy(): CodexPolicyBinding | null {
+export function sdkOnlyGrokBindingAsPolicy(): GrokPolicyBinding | null {
if (!current) return null
return {
catalogRevision: current.catalogRevision,
credentialRevision: current.credentialRevision,
connectionKey: current.connectionKey,
- models: [current.model],
}
}
diff --git a/mcp-host/src/workflow/workflowService.ts b/mcp-host/src/workflow/workflowService.ts
index 36cdb7a48..5b48bf890 100644
--- a/mcp-host/src/workflow/workflowService.ts
+++ b/mcp-host/src/workflow/workflowService.ts
@@ -106,6 +106,8 @@ function monoCredentialBag(provider: LlmProvider, apiKey: string): ApiKeys {
return { azure: { 'azure-openai-api-key': apiKey } }
case 'codex-subscription':
return {}
+ case 'grok-subscription':
+ return {}
default: {
const _exhaustive: never = provider
void _exhaustive
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 42b6079bd..689805fa3 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.355",
+ "version": "0.1.356",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.355",
+ "version": "0.1.356",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index 70bb0f59b..92d9dce1d 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.355",
+ "version": "0.1.356",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
index a670eaf75..fd8b09e75 100644
--- a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
+++ b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
@@ -1019,6 +1019,7 @@ export class WorkflowRecipeReconciler {
enableCustomCoordinatorImage: this.config.enableCustomCoordinatorImage,
enableSnippetRuntime: this.config.enableSnippetRuntime,
pluginWorkloadSdkEnabled: this.config.pluginWorkloadSdkEnabled,
+ grokSubscriptionEnabled: this.config.grokSubscriptionEnabled,
maxWorkflowSteps: this.config.maxWorkflowSteps,
allowedCoordinatorImagePrefixes: this.config.allowedCoordinatorImagePrefixes,
requireCoordinatorImageDigest: this.config.requireCoordinatorImageDigest,
diff --git a/workflow-recipes/src/workflow/types.ts b/workflow-recipes/src/workflow/types.ts
index 03a8a425c..cf49a9d92 100644
--- a/workflow-recipes/src/workflow/types.ts
+++ b/workflow-recipes/src/workflow/types.ts
@@ -206,6 +206,8 @@ export interface WorkflowConfig {
enableSnippetRuntime?: boolean
/** Plugin Workload SDK master switch (PLUGIN_WORKLOAD_SDK_ENABLED). */
pluginWorkloadSdkEnabled?: boolean
+ /** Grok subscription master switch (WRC_GROK_SUBSCRIPTION_ENABLED). */
+ grokSubscriptionEnabled?: boolean
maxWorkflowSteps: number
allowedCoordinatorImagePrefixes?: string[]
requireCoordinatorImageDigest?: boolean