From 1e0dd1189cb7dbc28cd90fbe346455803a6fa0b1 Mon Sep 17 00:00:00 2001 From: Omar Iqbal Naru Date: Fri, 21 Aug 2026 19:41:54 +0500 Subject: [PATCH] fix(core): register custom api under non-reserved name for omp 17.4.0 omp 17.4.0's host registry rejects registerCustomApi calls under built-in api names ("Cannot register custom API '': built-in API names are reserved"). The provider and its models registered under "openai-completions", so the extension failed to load. Register under "commandcode-custom" instead (matches the published npm build) and restore the real wire api via apiForModelId before dispatching to the native compat stream inside the transport router. The host's model registry also stores provider-supplied compat under model.compatConfig internally, only copying it back to model.compat inside its own dispatch-time patches. Since the transport router calls the native compat stream directly, it must read compatConfig itself or requests crash with 'baseCompat is undefined' before any network call. Verified against a local mock Provider API server with the extension linked into omp 17.4.0: model discovery lists all Command Code models, and a streamed chat completion sends the resolved x-cmd-zdr header and Authorization header end to end. --- index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 72ae558..79349bd 100644 --- a/index.ts +++ b/index.ts @@ -19,6 +19,7 @@ import { getConfiguredApiKey } from "./src/api-key.ts" import { createStreamCommandCode } from "./src/core.ts" import { calculateCommandCodeCost } from "./src/cost.ts" import { + apiForModelId, baseUrlForModel, DEFAULT_MODELS_URL, DEFAULT_PROVIDER_API_BASE, @@ -51,7 +52,7 @@ function createProviderConfig( name: "Command Code", baseUrl: apiBase, apiKey: getConfiguredApiKey() ?? "$COMMANDCODE_API_KEY", - api: "openai-completions", + api: "commandcode-custom", streamSimple: streamCommandCode, headers, oauth: { @@ -63,7 +64,7 @@ function createProviderConfig( models: models.map((model) => ({ id: model.id, name: model.name, - api: model.api, + api: "commandcode-custom", baseUrl: baseUrlForModel(apiBase, model.api), reasoning: model.reasoning, ...(thinkingMetadataForModel(model.id) ?? {}), @@ -108,7 +109,12 @@ export default async function (pi: ExtensionAPI) { }) const transport = createCommandCodeTransportRouter({ createStream: () => new AssistantMessageEventStream(), - streamProvider: streamNativeProvider, + streamProvider: (model, context, options) => + streamNativeProvider( + { ...model, api: apiForModelId(model.id), compat: model.compatConfig ?? model.compat }, + context, + options, + ), streamGenerate, })