From 1a2e555ddce9c8c651bd47452fe455d960c949eb Mon Sep 17 00:00:00 2001 From: PlumJam Date: Mon, 8 Jun 2026 20:21:01 +0200 Subject: [PATCH] fix: resolve deprecation warning for apiKey value Signed-off-by: PlumJam --- index.ts | 2 +- src/core.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 1c0bbcb..1295816 100644 --- a/index.ts +++ b/index.ts @@ -83,7 +83,7 @@ export default async function (pi: ExtensionAPI) { pi.registerProvider("commandcode", { name: "Command Code", baseUrl: API_BASE, - apiKey: "COMMANDCODE_API_KEY", + apiKey: "$COMMANDCODE_API_KEY", authHeader: true, api: "commandcode-custom", streamSimple: streamCommandCode, diff --git a/src/core.ts b/src/core.ts index 4b5535b..301ff64 100644 --- a/src/core.ts +++ b/src/core.ts @@ -193,10 +193,17 @@ export function createStreamCommandCode(deps: CoreDependencies) { const stream = deps.createStream() async function run() { - // OMP may pass the env-var name "COMMANDCODE_API_KEY" as the apiKey - // value instead of resolving it. Filter out this specific string. + // OMP may pass the legacy env-var name "COMMANDCODE_API_KEY" (old pi) + // or "$COMMANDCODE_API_KEY" (new pi) as the apiKey value instead of + // resolving it. Filter out these specific strings. + const LEGACY_API_KEY_REF = "$COMMANDCODE_API_KEY" + const OLD_API_KEY_REF = "COMMANDCODE_API_KEY" const hostKey = - options?.apiKey && options.apiKey !== "COMMANDCODE_API_KEY" ? options.apiKey : undefined + options?.apiKey && + options.apiKey !== LEGACY_API_KEY_REF && + options.apiKey !== OLD_API_KEY_REF + ? options.apiKey + : undefined const apiKey = hostKey ??