ai 6.0.208 → 6.0.210

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/index.mjs CHANGED
@@ -1171,7 +1171,7 @@ import {
1171
1171
  } from "@ai-sdk/provider-utils";
1172
1172
 
1173
1173
  // src/version.ts
1174
- var VERSION = true ? "6.0.208" : "0.0.0-test";
1174
+ var VERSION = true ? "6.0.210" : "0.0.0-test";
1175
1175
 
1176
1176
  // src/util/download/download.ts
1177
1177
  var download = async ({
@@ -2403,6 +2403,30 @@ function recordErrorOnSpan(span, error) {
2403
2403
  }
2404
2404
  }
2405
2405
 
2406
+ // src/telemetry/sanitize-attribute-value.ts
2407
+ function isPrimitiveAttributeValue(value) {
2408
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
2409
+ }
2410
+ function sanitizeAttributeValue(value) {
2411
+ if (!Array.isArray(value)) {
2412
+ return value;
2413
+ }
2414
+ const primitiveTypes = new Set(
2415
+ value.filter(isPrimitiveAttributeValue).map((item) => typeof item)
2416
+ );
2417
+ if (primitiveTypes.size !== 1) {
2418
+ return void 0;
2419
+ }
2420
+ const [primitiveType] = primitiveTypes;
2421
+ if (primitiveType === "string") {
2422
+ return value.filter((item) => typeof item === "string");
2423
+ }
2424
+ if (primitiveType === "number") {
2425
+ return value.filter((item) => typeof item === "number");
2426
+ }
2427
+ return value.filter((item) => typeof item === "boolean");
2428
+ }
2429
+
2406
2430
  // src/telemetry/select-telemetry-attributes.ts
2407
2431
  async function selectTelemetryAttributes({
2408
2432
  telemetry,
@@ -2422,7 +2446,9 @@ async function selectTelemetryAttributes({
2422
2446
  }
2423
2447
  const result = await value.input();
2424
2448
  if (result != null) {
2425
- resultAttributes[key] = result;
2449
+ const sanitized2 = sanitizeAttributeValue(result);
2450
+ if (sanitized2 != null)
2451
+ resultAttributes[key] = sanitized2;
2426
2452
  }
2427
2453
  continue;
2428
2454
  }
@@ -2432,11 +2458,15 @@ async function selectTelemetryAttributes({
2432
2458
  }
2433
2459
  const result = await value.output();
2434
2460
  if (result != null) {
2435
- resultAttributes[key] = result;
2461
+ const sanitized2 = sanitizeAttributeValue(result);
2462
+ if (sanitized2 != null)
2463
+ resultAttributes[key] = sanitized2;
2436
2464
  }
2437
2465
  continue;
2438
2466
  }
2439
- resultAttributes[key] = value;
2467
+ const sanitized = sanitizeAttributeValue(value);
2468
+ if (sanitized != null)
2469
+ resultAttributes[key] = sanitized;
2440
2470
  }
2441
2471
  return resultAttributes;
2442
2472
  }