@vedmalex/ai-connect 0.6.0 → 0.7.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/dist/bun/index.js CHANGED
@@ -1984,6 +1984,8 @@ function fillConfiguredContextLength(route, models) {
1984
1984
  return {
1985
1985
  ...entry,
1986
1986
  contextLength: configured,
1987
+ // FT-002: typed provenance (canonical) + metadata alias (back-compat).
1988
+ contextWindowSource: "configured",
1987
1989
  metadata: { ...entry.metadata ?? {}, contextWindowSource: "configured" }
1988
1990
  };
1989
1991
  });
@@ -3316,7 +3318,8 @@ function createClient(configOrInput, options = {}) {
3316
3318
  ...catalog.canonicalModelId ? { canonicalModelId: catalog.canonicalModelId } : {},
3317
3319
  ...catalog.resolvedModelId ? { resolvedModelId: catalog.resolvedModelId } : {},
3318
3320
  ...catalog.currentModelId ? { currentModelId: catalog.currentModelId } : {},
3319
- availableModels: catalog.availableModels
3321
+ availableModels: catalog.availableModels,
3322
+ ...catalog.warnings?.length ? { warnings: catalog.warnings } : {}
3320
3323
  });
3321
3324
  wideAttempts.push({
3322
3325
  index: wideAttempts.length + 1,
@@ -5019,7 +5022,7 @@ function parseOpenAiModelCatalog(route, payload) {
5019
5022
  modelId: entry.id,
5020
5023
  name: typeof entry.display_name === "string" ? entry.display_name : typeof entry.name === "string" ? entry.name : entry.id,
5021
5024
  ...typeof entry.description === "string" ? { description: entry.description } : {},
5022
- ...contextLength !== void 0 ? { contextLength } : {},
5025
+ ...contextLength !== void 0 ? { contextLength, contextWindowSource: "discovered" } : {},
5023
5026
  ...pricing ? { pricing } : {},
5024
5027
  ...free ? { free } : {},
5025
5028
  ...metadata ? {
@@ -9015,16 +9018,20 @@ function buildCliDiscoveryInvocation(route, command, options) {
9015
9018
  parameterKeys
9016
9019
  };
9017
9020
  }
9018
- function buildStaticCliCatalog(route) {
9021
+ function buildStaticCliCatalog(route, warning) {
9019
9022
  const models = route.advertisedModels.map((id) => ({
9020
9023
  modelId: id,
9021
9024
  name: id
9022
9025
  }));
9023
- return buildModelCatalog(
9026
+ const catalog = buildModelCatalog(
9024
9027
  route,
9025
9028
  models,
9026
9029
  currentModelIdForRoute(route, route.advertisedModels)
9027
9030
  );
9031
+ if (warning) {
9032
+ catalog.warnings = [...catalog.warnings ?? [], warning];
9033
+ }
9034
+ return catalog;
9028
9035
  }
9029
9036
  function statsToUsage(stats) {
9030
9037
  if (!stats || typeof stats !== "object") {
@@ -9167,7 +9174,9 @@ function modelInfoFromRecord(record, selector) {
9167
9174
  modelId,
9168
9175
  name,
9169
9176
  ...description ? { description } : {},
9170
- ...contextLength !== void 0 ? { contextLength } : {}
9177
+ // FT-002: a contextLength read from the list-command output is a discovered
9178
+ // value (consistent with the API parsers), so tag its provenance.
9179
+ ...contextLength !== void 0 ? { contextLength, contextWindowSource: "discovered" } : {}
9171
9180
  };
9172
9181
  }
9173
9182
  function parseCliModelList(stdout, parser, selector) {
@@ -9438,13 +9447,20 @@ function createCliTransportManager(options) {
9438
9447
  throw error;
9439
9448
  }
9440
9449
  if (source.fallback === "static") {
9441
- return buildStaticCliCatalog(context.route);
9450
+ const detail = error instanceof Error ? error.message : String(error);
9451
+ return buildStaticCliCatalog(
9452
+ context.route,
9453
+ `CLI discovery command for "${context.route.transport.id}" failed (${detail}); fell back to the static models[] catalog.`
9454
+ );
9442
9455
  }
9443
9456
  throw error;
9444
9457
  }
9445
9458
  if (models.length === 0) {
9446
9459
  if (source.fallback === "static") {
9447
- return buildStaticCliCatalog(context.route);
9460
+ return buildStaticCliCatalog(
9461
+ context.route,
9462
+ `CLI discovery command for "${context.route.transport.id}" returned no models; fell back to the static models[] catalog.`
9463
+ );
9448
9464
  }
9449
9465
  throw new AiConnectError(
9450
9466
  "temporary_unavailable",