@f5-sales-demo/pi-ai 21.21.2 → 21.23.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.21.2",
4
+ "version": "21.23.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.115",
47
47
  "@aws-sdk/client-bedrock-runtime": "^3",
48
48
  "@bufbuild/protobuf": "^2.11",
49
- "@f5-sales-demo/pi-utils": "21.21.2",
49
+ "@f5-sales-demo/pi-utils": "21.23.0",
50
50
  "@google/genai": "^2.15",
51
51
  "@sinclair/typebox": "^0.34",
52
52
  "@smithy/node-http-handler": "^4.4",
@@ -1490,6 +1490,7 @@ export function githubCopilotModelManagerOptions(config?: GithubCopilotModelMana
1490
1490
  provider: "github-copilot",
1491
1491
  baseUrl,
1492
1492
  apiKey,
1493
+ throwOnUnauthorized: true,
1493
1494
  headers: OPENCODE_HEADERS,
1494
1495
  mapModel: (
1495
1496
  entry: OpenAICompatibleModelRecord,
@@ -82,6 +82,8 @@ export interface FetchOpenAICompatibleModelsOptions<TApi extends Api> {
82
82
  signal?: AbortSignal;
83
83
  /** Optional fetch implementation override for testing/custom runtimes. */
84
84
  fetch?: typeof globalThis.fetch;
85
+ /** Surface HTTP 401 so callers can distinguish revoked credentials from connectivity failures. */
86
+ throwOnUnauthorized?: boolean;
85
87
  /**
86
88
  * Optional post-normalization filter.
87
89
  * Return false to skip a model.
@@ -101,7 +103,8 @@ export interface FetchOpenAICompatibleModelsOptions<TApi extends Api> {
101
103
  /**
102
104
  * Fetches and normalizes an OpenAI-compatible `/models` catalog.
103
105
  *
104
- * Returns `null` on transport/protocol failures.
106
+ * Returns `null` on transport/protocol failures unless the caller opts into
107
+ * surfacing an HTTP 401 for provider-specific credential classification.
105
108
  * Returns `[]` only when the endpoint responds successfully with no usable models.
106
109
  */
107
110
  export async function fetchOpenAICompatibleModels<TApi extends Api>(
@@ -133,6 +136,9 @@ export async function fetchOpenAICompatibleModels<TApi extends Api>(
133
136
  }
134
137
 
135
138
  if (!response.ok) {
139
+ if (response.status === 401 && options.throwOnUnauthorized) {
140
+ throw new Error(`${options.provider} model discovery failed (HTTP 401)`);
141
+ }
136
142
  return null;
137
143
  }
138
144