@ai-sdk/otel 1.0.0-beta.59 → 1.0.0-beta.60

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/otel",
3
- "version": "1.0.0-beta.59",
3
+ "version": "1.0.0-beta.60",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -27,15 +27,15 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@opentelemetry/api": "1.9.1",
30
- "@ai-sdk/provider": "4.0.0-beta.13",
31
- "ai": "7.0.0-beta.113"
30
+ "ai": "7.0.0-beta.114",
31
+ "@ai-sdk/provider": "4.0.0-beta.14"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "20.17.24",
35
35
  "tsup": "^8",
36
36
  "typescript": "5.8.3",
37
37
  "zod": "3.25.76",
38
- "@ai-sdk/provider-utils": "5.0.0-beta.28",
38
+ "@ai-sdk/provider-utils": "5.0.0-beta.29",
39
39
  "@vercel/ai-tsconfig": "0.0.0"
40
40
  },
41
41
  "engines": {
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  LanguageModelV4CustomPart,
3
3
  LanguageModelV4FilePart,
4
4
  LanguageModelV4Message,
@@ -184,7 +184,39 @@ function convertMessagePartToSemConv(
184
184
  }
185
185
 
186
186
  case 'file': {
187
- const data = part.data;
187
+ const rawData = part.data as
188
+ | string
189
+ | Uint8Array
190
+ | URL
191
+ | ArrayBuffer
192
+ | { type: 'data'; data: string | Uint8Array | ArrayBuffer }
193
+ | { type: 'url'; url: URL }
194
+ | { type: 'reference'; reference: Record<string, string> }
195
+ | { type: 'text'; text: string };
196
+
197
+ const data: string | Uint8Array | URL | ArrayBuffer = (() => {
198
+ if (
199
+ typeof rawData === 'object' &&
200
+ rawData !== null &&
201
+ !(rawData instanceof URL) &&
202
+ !(rawData instanceof Uint8Array) &&
203
+ !(rawData instanceof ArrayBuffer) &&
204
+ 'type' in rawData
205
+ ) {
206
+ switch (rawData.type) {
207
+ case 'data':
208
+ return rawData.data;
209
+ case 'url':
210
+ return rawData.url;
211
+ case 'text':
212
+ return rawData.text;
213
+ default:
214
+ return '';
215
+ }
216
+ }
217
+ return rawData as string | Uint8Array | URL | ArrayBuffer;
218
+ })();
219
+
188
220
  let content: string;
189
221
  if (data instanceof Uint8Array) {
190
222
  content = convertDataContentToBase64String(data);
@@ -198,6 +230,13 @@ function convertMessagePartToSemConv(
198
230
  };
199
231
  }
200
232
  content = data;
233
+ } else if (data instanceof URL) {
234
+ return {
235
+ type: 'uri',
236
+ modality: getModality(part.mediaType),
237
+ mime_type: part.mediaType ?? null,
238
+ uri: data.toString(),
239
+ };
201
240
  } else {
202
241
  content = String(data);
203
242
  }
@@ -346,7 +385,39 @@ function convertModelMessageToSemConv(
346
385
  };
347
386
  }
348
387
  case 'file': {
349
- const data = part.data;
388
+ const rawData = part.data as
389
+ | string
390
+ | Uint8Array
391
+ | URL
392
+ | ArrayBuffer
393
+ | { type: 'data'; data: string | Uint8Array | ArrayBuffer }
394
+ | { type: 'url'; url: URL }
395
+ | { type: 'reference'; reference: Record<string, string> }
396
+ | { type: 'text'; text: string };
397
+
398
+ const data: string | Uint8Array | URL | ArrayBuffer = (() => {
399
+ if (
400
+ typeof rawData === 'object' &&
401
+ rawData !== null &&
402
+ !(rawData instanceof URL) &&
403
+ !(rawData instanceof Uint8Array) &&
404
+ !(rawData instanceof ArrayBuffer) &&
405
+ 'type' in rawData
406
+ ) {
407
+ switch (rawData.type) {
408
+ case 'data':
409
+ return rawData.data;
410
+ case 'url':
411
+ return rawData.url;
412
+ case 'text':
413
+ return rawData.text;
414
+ default:
415
+ return '';
416
+ }
417
+ }
418
+ return rawData as string | Uint8Array | URL | ArrayBuffer;
419
+ })();
420
+
350
421
  if (data instanceof URL) {
351
422
  return {
352
423
  type: 'uri' as const,
@@ -1,4 +1,4 @@
1
- import { Attributes, AttributeValue } from '@opentelemetry/api';
1
+ import type { Attributes, AttributeValue } from '@opentelemetry/api';
2
2
  import type { LanguageModelCallOptions } from 'ai';
3
3
 
4
4
  export function getBaseTelemetryAttributes({
package/src/get-tracer.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Tracer, trace } from '@opentelemetry/api';
1
+ import { trace, type Tracer } from '@opentelemetry/api';
2
2
  import { noopTracer } from './noop-tracer';
3
3
 
4
4
  export function getTracer({
@@ -1,14 +1,14 @@
1
- import { LanguageModelV4Prompt } from '@ai-sdk/provider';
1
+ import type { LanguageModelV4Prompt } from '@ai-sdk/provider';
2
2
  import type { Context as AISDKContext } from '@ai-sdk/provider-utils';
3
3
  import {
4
- Attributes,
5
- AttributeValue,
6
4
  context,
7
- Context as OpenTelemetryContext,
8
- Span,
9
5
  SpanStatusCode,
10
6
  trace,
11
- Tracer,
7
+ type Attributes,
8
+ type AttributeValue,
9
+ type Context as OpenTelemetryContext,
10
+ type Span,
11
+ type Tracer,
12
12
  } from '@opentelemetry/api';
13
13
  import type {
14
14
  EmbeddingModelCallEndEvent,
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  AttributeValue,
3
3
  Attributes,
4
4
  Context,
@@ -1,4 +1,4 @@
1
- import { Span, SpanContext, Tracer } from '@opentelemetry/api';
1
+ import type { Span, SpanContext, Tracer } from '@opentelemetry/api';
2
2
 
3
3
  /**
4
4
  * Tracer implementation that does nothing (null object).