@f5-sales-demo/pi-ai 21.25.0 → 21.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/pi-ai",
4
- "version": "21.25.0",
4
+ "version": "21.27.0",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -46,7 +46,7 @@
46
46
  "@anthropic-ai/sdk": "0.123.0",
47
47
  "@aws-sdk/client-bedrock-runtime": "3.1126.0",
48
48
  "@bufbuild/protobuf": "2.14.1",
49
- "@f5-sales-demo/pi-utils": "21.25.0",
49
+ "@f5-sales-demo/pi-utils": "21.27.0",
50
50
  "@google/genai": "2.21.0",
51
51
  "@sinclair/typebox": "0.34.52",
52
52
  "@smithy/node-http-handler": "4.12.1",
@@ -2268,6 +2268,27 @@ export class AuthStorage {
2268
2268
  return this.#fallbackResolver?.(provider) ?? undefined;
2269
2269
  }
2270
2270
 
2271
+ /**
2272
+ * Resolve an API key without consulting or refreshing stored OAuth credentials.
2273
+ * Use this for protocols that explicitly require key authentication even when
2274
+ * the owning model uses OAuth. Environment resolution remains provider-specific.
2275
+ */
2276
+ async getApiKeyFromNonOAuthSources(provider: string, sessionId?: string): Promise<string | undefined> {
2277
+ provider = canonicalizeOAuthProviderId(provider);
2278
+ const runtimeKey = this.#runtimeOverrides.get(provider);
2279
+ if (runtimeKey) return runtimeKey;
2280
+
2281
+ const apiKeySelection = this.#selectCredentialByType(provider, "api_key", sessionId);
2282
+ if (apiKeySelection) {
2283
+ this.#recordSessionCredential(provider, sessionId, "api_key", apiKeySelection.index);
2284
+ return this.#configValueResolver(apiKeySelection.credential.key);
2285
+ }
2286
+
2287
+ const envKey = getEnvApiKey(provider);
2288
+ if (envKey) return envKey;
2289
+ return this.#fallbackResolver?.(provider) ?? undefined;
2290
+ }
2291
+
2271
2292
  /**
2272
2293
  * Get API key for a provider.
2273
2294
  * Priority:
@@ -233,9 +233,18 @@ export function refreshModelThinking<TApi extends Api>(model: ApiModel<TApi>): A
233
233
  * Each model is first normalized through `refreshModelThinking()` so generated
234
234
  * catalogs keep canonical thinking metadata and policy fixes in one pass.
235
235
  */
236
- export function applyGeneratedModelPolicies(models: ApiModel<Api>[]): void {
236
+ export function applyGeneratedModelPolicies(
237
+ models: ApiModel<Api>[],
238
+ options: { preserveDiscoveredThinking?: boolean } = {},
239
+ ): void {
237
240
  for (let index = 0; index < models.length; index++) {
238
- const model = refreshModelThinking(models[index]!);
241
+ const source = models[index]!;
242
+ // Subscription discovery is authoritative for the effort enum. Re-inferring
243
+ // it from a model family can add values rejected by the backing model.
244
+ const model =
245
+ options.preserveDiscoveredThinking && source.api === "openai-codex-responses"
246
+ ? enrichModelThinking(source)
247
+ : refreshModelThinking(source);
239
248
  applyGeneratedModelPolicy(model);
240
249
  models[index] = model;
241
250
  }