autotel-devtools 20.1.0 → 21.0.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.
@@ -1,35 +1,4 @@
1
- import { AgentSession } from "autotel-agents";
2
- //#region src/widget/types.d.ts
3
- interface SpanData {
4
- traceId: string;
5
- spanId: string;
6
- parentSpanId?: string;
7
- name: string;
8
- kind: 'INTERNAL' | 'SERVER' | 'CLIENT' | 'PRODUCER' | 'CONSUMER';
9
- startTime: number;
10
- endTime: number;
11
- duration: number;
12
- attributes: Record<string, any>;
13
- status: {
14
- code: 'OK' | 'ERROR' | 'UNSET';
15
- message?: string;
16
- };
17
- events?: Array<{
18
- name: string;
19
- timestamp: number;
20
- attributes?: Record<string, any>;
21
- }>;
22
- links?: Array<{
23
- traceId: string;
24
- spanId: string;
25
- attributes?: Record<string, any>;
26
- }>;
27
- scope?: {
28
- name?: string;
29
- version?: string;
30
- };
31
- }
32
- //#endregion
1
+ import { r as SpanData } from "../types-DHDvZnnn.js";
33
2
  //#region src/widget/genai/detect.d.ts
34
3
  declare function isGenAiSpan(span: SpanData): boolean;
35
4
  //#endregion
@@ -1,3 +1,5 @@
1
+ import { a as asStringArray, i as asString, n as asBoolean, r as asNumber, t as asObject } from "../json-fields-CPjKZ2WH.js";
2
+
1
3
  //#region src/widget/genai/detect.ts
2
4
  const GENAI_MARKERS = [
3
5
  "gen_ai.system",
@@ -148,25 +150,6 @@ function priceCall(inputs) {
148
150
 
149
151
  //#endregion
150
152
  //#region src/widget/genai/normalize.ts
151
- function str(v) {
152
- return typeof v === "string" ? v : void 0;
153
- }
154
- function num(v) {
155
- if (typeof v === "number") return v;
156
- if (typeof v === "string" && v !== "") {
157
- const n = Number(v);
158
- return Number.isFinite(n) ? n : void 0;
159
- }
160
- }
161
- function strArray(v) {
162
- if (Array.isArray(v) && v.every((x) => typeof x === "string")) return v;
163
- if (typeof v === "string") return [v];
164
- }
165
- function bool(v) {
166
- if (typeof v === "boolean") return v;
167
- if (v === "true") return true;
168
- if (v === "false") return false;
169
- }
170
153
  function parseJson(v) {
171
154
  if (v == null) return void 0;
172
155
  if (typeof v === "object") return v;
@@ -219,9 +202,10 @@ function normalizeMessageParts(raw) {
219
202
  value: p
220
203
  };
221
204
  });
222
- if (typeof raw.content === "string") return [{
205
+ const legacyText = asString(raw.content);
206
+ if (legacyText !== void 0) return [{
223
207
  kind: "text",
224
- text: raw.content
208
+ text: legacyText
225
209
  }];
226
210
  if (raw.content != null) return [{
227
211
  kind: "json",
@@ -230,7 +214,8 @@ function normalizeMessageParts(raw) {
230
214
  return [];
231
215
  }
232
216
  function unwrapToolResult(payload) {
233
- return payload && typeof payload === "object" && "value" in payload ? payload.value : payload;
217
+ const wrapper = asObject(payload);
218
+ return wrapper && "value" in wrapper ? wrapper.value : payload;
234
219
  }
235
220
  function classifyAiSdkPart(part) {
236
221
  if (part.type === "tool-call") return {
@@ -344,8 +329,9 @@ function messagesFromEvents(events) {
344
329
  for (const ev of events) {
345
330
  const attrs = ev.attributes ?? {};
346
331
  if (ev.name === "gen_ai.choice") {
347
- const message = parseJson(attrs.message) ?? attrs.message;
348
- const finishReason = str(attrs.finish_reason);
332
+ const unparsedMessage = attrs.message;
333
+ const message = parseJson(attrs.message) ?? unparsedMessage;
334
+ const finishReason = asString(attrs.finish_reason);
349
335
  if (message) {
350
336
  const normalized = normalizeMessage(message);
351
337
  if (finishReason) normalized.finishReason = finishReason;
@@ -357,12 +343,13 @@ function messagesFromEvents(events) {
357
343
  if (!m) continue;
358
344
  const role = m[1];
359
345
  const content = attrs.content;
360
- const parsed = typeof content === "string" ? parseJson(content) ?? content : content;
346
+ const contentText = asString(content);
347
+ const parsed = contentText === void 0 ? content : parseJson(contentText) ?? contentText;
361
348
  out.push(normalizeMessage({
362
349
  role,
363
350
  content: parsed,
364
351
  tool_calls: parseJson(attrs.tool_calls),
365
- tool_call_id: str(attrs.id) ?? str(attrs.tool_call_id)
352
+ tool_call_id: asString(attrs.id) ?? asString(attrs.tool_call_id)
366
353
  }));
367
354
  }
368
355
  return out;
@@ -370,7 +357,7 @@ function messagesFromEvents(events) {
370
357
  function readToolDefinitions(attrs) {
371
358
  const raw = parseJson(attrs["gen_ai.tool.definitions"] ?? attrs["gen_ai.orchestrator.agent.definitions"]);
372
359
  if (!Array.isArray(raw)) return void 0;
373
- return raw.filter((d) => typeof d.name === "string").map((d) => ({
360
+ return raw.filter((d) => asString(d.name) !== void 0).map((d) => ({
374
361
  name: d.name,
375
362
  description: d.description,
376
363
  type: d.type,
@@ -379,18 +366,18 @@ function readToolDefinitions(attrs) {
379
366
  }
380
367
  function readUsage(attrs) {
381
368
  return {
382
- inputTokens: num(attrs["gen_ai.usage.input_tokens"]) ?? num(attrs["gen_ai.usage.prompt_tokens"]) ?? num(attrs["llm.usage.prompt_tokens"]) ?? num(attrs["ai.usage.inputTokens"]),
383
- outputTokens: num(attrs["gen_ai.usage.output_tokens"]) ?? num(attrs["gen_ai.usage.completion_tokens"]) ?? num(attrs["llm.usage.completion_tokens"]) ?? num(attrs["ai.usage.outputTokens"]),
384
- reasoningOutputTokens: num(attrs["gen_ai.usage.reasoning.output_tokens"]),
385
- cacheReadInputTokens: num(attrs["gen_ai.usage.cache_read.input_tokens"]),
386
- cacheCreationInputTokens: num(attrs["gen_ai.usage.cache_creation.input_tokens"])
369
+ inputTokens: asNumber(attrs["gen_ai.usage.input_tokens"]) ?? asNumber(attrs["gen_ai.usage.prompt_tokens"]) ?? asNumber(attrs["llm.usage.prompt_tokens"]) ?? asNumber(attrs["ai.usage.inputTokens"]),
370
+ outputTokens: asNumber(attrs["gen_ai.usage.output_tokens"]) ?? asNumber(attrs["gen_ai.usage.completion_tokens"]) ?? asNumber(attrs["llm.usage.completion_tokens"]) ?? asNumber(attrs["ai.usage.outputTokens"]),
371
+ reasoningOutputTokens: asNumber(attrs["gen_ai.usage.reasoning.output_tokens"]),
372
+ cacheReadInputTokens: asNumber(attrs["gen_ai.usage.cache_read.input_tokens"]),
373
+ cacheCreationInputTokens: asNumber(attrs["gen_ai.usage.cache_creation.input_tokens"])
387
374
  };
388
375
  }
389
376
  function readStreaming(attrs) {
390
- const timeToFirstChunkS = num(attrs["gen_ai.response.time_to_first_chunk"]);
391
- const timeToFinishS = num(attrs["gen_ai.response.time_to_finish"]);
392
- const outputTokensPerSecond = num(attrs["gen_ai.response.output_tokens_per_second"]);
393
- const timePerOutputChunkS = num(attrs["gen_ai.response.time_per_output_chunk"]);
377
+ const timeToFirstChunkS = asNumber(attrs["gen_ai.response.time_to_first_chunk"]);
378
+ const timeToFinishS = asNumber(attrs["gen_ai.response.time_to_finish"]);
379
+ const outputTokensPerSecond = asNumber(attrs["gen_ai.response.output_tokens_per_second"]);
380
+ const timePerOutputChunkS = asNumber(attrs["gen_ai.response.time_per_output_chunk"]);
394
381
  if (timeToFirstChunkS === void 0 && timeToFinishS === void 0 && outputTokensPerSecond === void 0 && timePerOutputChunkS === void 0) return;
395
382
  return {
396
383
  timeToFirstChunkS,
@@ -400,12 +387,12 @@ function readStreaming(attrs) {
400
387
  };
401
388
  }
402
389
  function readSession(attrs) {
403
- const costUsd = num(attrs["gen_ai.session.cost.usd"]);
404
- const inputTokens = num(attrs["gen_ai.session.input_tokens"]);
405
- const outputTokens = num(attrs["gen_ai.session.output_tokens"]);
406
- const stepCount = num(attrs["gen_ai.session.step.count"]);
407
- const toolCallCount = num(attrs["gen_ai.session.tool_call.count"]);
408
- const errorCount = num(attrs["gen_ai.session.error.count"]);
390
+ const costUsd = asNumber(attrs["gen_ai.session.cost.usd"]);
391
+ const inputTokens = asNumber(attrs["gen_ai.session.input_tokens"]);
392
+ const outputTokens = asNumber(attrs["gen_ai.session.output_tokens"]);
393
+ const stepCount = asNumber(attrs["gen_ai.session.step.count"]);
394
+ const toolCallCount = asNumber(attrs["gen_ai.session.tool_call.count"]);
395
+ const errorCount = asNumber(attrs["gen_ai.session.error.count"]);
409
396
  if (costUsd === void 0 && inputTokens === void 0 && outputTokens === void 0 && stepCount === void 0 && toolCallCount === void 0 && errorCount === void 0) return;
410
397
  return {
411
398
  costUsd,
@@ -417,18 +404,18 @@ function readSession(attrs) {
417
404
  };
418
405
  }
419
406
  function readGuardDetails(a, defaultAction) {
420
- const rule = str(a["gen_ai.guard.rule"]);
407
+ const rule = asString(a["gen_ai.guard.rule"]);
421
408
  if (!rule) return void 0;
422
409
  return {
423
410
  rule,
424
- action: str(a["gen_ai.guard.action"]) ?? defaultAction,
425
- message: str(a["gen_ai.guard.message"]),
426
- observed: num(a["gen_ai.guard.observed"]),
427
- limit: num(a["gen_ai.guard.limit"])
411
+ action: asString(a["gen_ai.guard.action"]) ?? defaultAction,
412
+ message: asString(a["gen_ai.guard.message"]),
413
+ observed: asNumber(a["gen_ai.guard.observed"]),
414
+ limit: asNumber(a["gen_ai.guard.limit"])
428
415
  };
429
416
  }
430
417
  function readGuardAndWarnings(attrs, events) {
431
- const stopped = bool(attrs["gen_ai.guard.stopped"]);
418
+ const stopped = asBoolean(attrs["gen_ai.guard.stopped"]);
432
419
  const warnings = [];
433
420
  let guard = readGuardDetails(attrs);
434
421
  const apply = (next) => {
@@ -537,17 +524,17 @@ const KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
537
524
  ]);
538
525
  function toGenAiSpan(span) {
539
526
  const attrs = span.attributes ?? {};
540
- const provider = normalizeProviderName(str(attrs["gen_ai.provider.name"]) ?? str(attrs["gen_ai.system"]) ?? str(attrs["ai.model.provider"]) ?? "unknown");
541
- const operation = str(attrs["gen_ai.operation.name"]) ?? "chat";
542
- const requestModel = str(attrs["gen_ai.request.model"]) ?? str(attrs["llm.request.model"]) ?? str(attrs["model_name"]) ?? str(attrs["ai.model.id"]) ?? "unknown";
543
- const responseModel = str(attrs["gen_ai.response.model"]) ?? str(attrs["llm.response.model"]) ?? str(attrs["ai.response.model"]);
527
+ const provider = normalizeProviderName(asString(attrs["gen_ai.provider.name"]) ?? asString(attrs["gen_ai.system"]) ?? asString(attrs["ai.model.provider"]) ?? "unknown");
528
+ const operation = asString(attrs["gen_ai.operation.name"]) ?? "chat";
529
+ const requestModel = asString(attrs["gen_ai.request.model"]) ?? asString(attrs["llm.request.model"]) ?? asString(attrs["model_name"]) ?? asString(attrs["ai.model.id"]) ?? "unknown";
530
+ const responseModel = asString(attrs["gen_ai.response.model"]) ?? asString(attrs["llm.response.model"]) ?? asString(attrs["ai.response.model"]);
544
531
  const inputMessages = readMessagesAttribute(attrs, "gen_ai.input.messages") ?? [];
545
532
  const outputMessages = readMessagesAttribute(attrs, "gen_ai.output.messages") ?? [];
546
533
  let systemInstructions = [];
547
534
  const rawSystem = parseJson(attrs["gen_ai.system_instructions"]);
548
535
  if (Array.isArray(rawSystem) && rawSystem.length > 0) {
549
- const first = rawSystem[0];
550
- if (first && typeof first === "object" && "role" in first) systemInstructions = rawSystem.map((m) => normalizeMessage(m));
536
+ const first = asObject(rawSystem[0]);
537
+ if (first && "role" in first) systemInstructions = rawSystem.map((m) => normalizeMessage(m));
551
538
  else systemInstructions = [{
552
539
  role: "system",
553
540
  parts: rawSystem.map((p) => p.type === "text" || p.content !== void 0 ? {
@@ -564,8 +551,8 @@ function toGenAiSpan(span) {
564
551
  ...inputMessages,
565
552
  ...outputMessages
566
553
  ] : messagesFromEvents(span.events);
567
- const inputRef = str(attrs["gen_ai.input.messages.ref"]);
568
- const outputRef = str(attrs["gen_ai.output.messages.ref"]);
554
+ const inputRef = asString(attrs["gen_ai.input.messages.ref"]);
555
+ const outputRef = asString(attrs["gen_ai.output.messages.ref"]);
569
556
  const hasInputContent = messages.some((m) => m.role === "system" || m.role === "user");
570
557
  const hasOutputContent = messages.some((m) => m.role === "assistant");
571
558
  if (inputRef && !hasInputContent) messages.push({
@@ -608,14 +595,14 @@ function toGenAiSpan(span) {
608
595
  }
609
596
  }
610
597
  const aiResponseToolCalls = parseJson(attrs["ai.response.toolCalls"]);
611
- const assistantToolCalls = Array.isArray(aiResponseToolCalls) ? aiResponseToolCalls.filter((c) => typeof c.toolName === "string").map((c) => ({
598
+ const assistantToolCalls = Array.isArray(aiResponseToolCalls) ? aiResponseToolCalls.filter((c) => asString(c.toolName) !== void 0).map((c) => ({
612
599
  id: c.toolCallId,
613
600
  name: c.toolName,
614
601
  arguments: parseJson(c.input ?? c.args) ?? c.input ?? c.args ?? {}
615
602
  })) : void 0;
616
- const aiResponseText = str(attrs["ai.response.text"]);
603
+ const aiResponseText = asString(attrs["ai.response.text"]);
617
604
  if (aiResponseText || assistantToolCalls && assistantToolCalls.length > 0) {
618
- const finishReason = strArray(attrs["gen_ai.response.finish_reasons"])?.[0] ?? str(attrs["ai.response.finishReason"]);
605
+ const finishReason = asStringArray(attrs["gen_ai.response.finish_reasons"])?.[0] ?? asString(attrs["ai.response.finishReason"]);
619
606
  const msg = normalizeMessage({
620
607
  role: "assistant",
621
608
  content: aiResponseText ?? ""
@@ -632,7 +619,7 @@ function toGenAiSpan(span) {
632
619
  if (messages.length === 0) {
633
620
  const legacy = [];
634
621
  for (let i = 0; i < 32; i++) {
635
- const role = str(attrs[`gen_ai.prompt.${i}.role`]) ?? str(attrs[`llm.prompts.${i}.role`]);
622
+ const role = asString(attrs[`gen_ai.prompt.${i}.role`]) ?? asString(attrs[`llm.prompts.${i}.role`]);
636
623
  const content = attrs[`gen_ai.prompt.${i}.content`] ?? attrs[`llm.prompts.${i}.content`];
637
624
  if (!role) break;
638
625
  legacy.push(normalizeMessage({
@@ -641,9 +628,9 @@ function toGenAiSpan(span) {
641
628
  }));
642
629
  }
643
630
  for (let i = 0; i < 32; i++) {
644
- const role = str(attrs[`gen_ai.completion.${i}.role`]) ?? str(attrs[`llm.completions.${i}.role`]);
631
+ const role = asString(attrs[`gen_ai.completion.${i}.role`]) ?? asString(attrs[`llm.completions.${i}.role`]);
645
632
  const content = attrs[`gen_ai.completion.${i}.content`] ?? attrs[`llm.completions.${i}.content`];
646
- const finishReason = str(attrs[`gen_ai.completion.${i}.finish_reason`]);
633
+ const finishReason = asString(attrs[`gen_ai.completion.${i}.finish_reason`]);
647
634
  if (!role) break;
648
635
  const msg = normalizeMessage({
649
636
  role,
@@ -690,7 +677,7 @@ function toGenAiSpan(span) {
690
677
  cacheReadInputTokens: usage.cacheReadInputTokens,
691
678
  cacheCreationInputTokens: usage.cacheCreationInputTokens
692
679
  });
693
- const reportedCost = num(attrs["gen_ai.usage.cost.usd"]);
680
+ const reportedCost = asNumber(attrs["gen_ai.usage.cost.usd"]);
694
681
  const cost = reportedCost !== void 0 ? {
695
682
  currency: "USD",
696
683
  input: tableCost?.input ?? 0,
@@ -703,34 +690,34 @@ function toGenAiSpan(span) {
703
690
  const streaming = readStreaming(attrs);
704
691
  const session = readSession(attrs);
705
692
  const { guard, warnings } = readGuardAndWarnings(attrs, span.events);
706
- const finishReasons = strArray(attrs["gen_ai.response.finish_reasons"]);
707
- const agentName = str(attrs["gen_ai.agent.name"]);
708
- const agentId = str(attrs["gen_ai.agent.id"]);
709
- const agentDescription = str(attrs["gen_ai.agent.description"]);
710
- const toolName = str(attrs["gen_ai.tool.name"]);
711
- const toolCallId = str(attrs["gen_ai.tool.call.id"]);
712
- const handoffFrom = str(attrs["gen_ai.handoff.from_agent"]);
713
- const handoffTo = str(attrs["gen_ai.handoff.to_agent"]);
714
- const guardrailName = str(attrs["gen_ai.guardrail.name"]);
715
- const guardrailTriggered = bool(attrs["gen_ai.guardrail.triggered"]);
716
- const evalName = str(attrs["gen_ai.evaluation.name"]);
717
- const evalScoreValue = num(attrs["gen_ai.evaluation.score.value"]);
718
- const evalScoreLabel = str(attrs["gen_ai.evaluation.score.label"]);
719
- const evalExplanation = str(attrs["gen_ai.evaluation.explanation"]);
720
- const audioIn = str(attrs["gen_ai.audio.input.format"]);
721
- const audioOut = str(attrs["gen_ai.audio.output.format"]);
722
- const speechVoice = str(attrs["gen_ai.speech.voice"]);
723
- const speechInputText = str(attrs["gen_ai.speech.input_text"]);
724
- const transcriptionText = str(attrs["gen_ai.transcription.text"]);
725
- const embeddingDims = num(attrs["gen_ai.embeddings.dimension.count"]);
726
- const consentOutcome = str(attrs["agent.consent.outcome"]);
727
- const policyDecision = str(attrs["policy.decision"]);
728
- const injectionVerdict = str(attrs["mcp.security.injection.verdict"]);
729
- const actionRiskClass = str(attrs["agent.action.risk_class"]);
730
- const inputProvenance = str(attrs["agent.input.provenance"]);
731
- const planStepIndex = num(attrs["agent.plan.step_index"]);
732
- const securityEvent = str(attrs["security.event"]);
733
- const guardStoppedAttr = bool(attrs["gen_ai.guard.stopped"]);
693
+ const finishReasons = asStringArray(attrs["gen_ai.response.finish_reasons"]);
694
+ const agentName = asString(attrs["gen_ai.agent.name"]);
695
+ const agentId = asString(attrs["gen_ai.agent.id"]);
696
+ const agentDescription = asString(attrs["gen_ai.agent.description"]);
697
+ const toolName = asString(attrs["gen_ai.tool.name"]);
698
+ const toolCallId = asString(attrs["gen_ai.tool.call.id"]);
699
+ const handoffFrom = asString(attrs["gen_ai.handoff.from_agent"]);
700
+ const handoffTo = asString(attrs["gen_ai.handoff.to_agent"]);
701
+ const guardrailName = asString(attrs["gen_ai.guardrail.name"]);
702
+ const guardrailTriggered = asBoolean(attrs["gen_ai.guardrail.triggered"]);
703
+ const evalName = asString(attrs["gen_ai.evaluation.name"]);
704
+ const evalScoreValue = asNumber(attrs["gen_ai.evaluation.score.value"]);
705
+ const evalScoreLabel = asString(attrs["gen_ai.evaluation.score.label"]);
706
+ const evalExplanation = asString(attrs["gen_ai.evaluation.explanation"]);
707
+ const audioIn = asString(attrs["gen_ai.audio.input.format"]);
708
+ const audioOut = asString(attrs["gen_ai.audio.output.format"]);
709
+ const speechVoice = asString(attrs["gen_ai.speech.voice"]);
710
+ const speechInputText = asString(attrs["gen_ai.speech.input_text"]);
711
+ const transcriptionText = asString(attrs["gen_ai.transcription.text"]);
712
+ const embeddingDims = asNumber(attrs["gen_ai.embeddings.dimension.count"]);
713
+ const consentOutcome = asString(attrs["agent.consent.outcome"]);
714
+ const policyDecision = asString(attrs["policy.decision"]);
715
+ const injectionVerdict = asString(attrs["mcp.security.injection.verdict"]);
716
+ const actionRiskClass = asString(attrs["agent.action.risk_class"]);
717
+ const inputProvenance = asString(attrs["agent.input.provenance"]);
718
+ const planStepIndex = asNumber(attrs["agent.plan.step_index"]);
719
+ const securityEvent = asString(attrs["security.event"]);
720
+ const guardStoppedAttr = asBoolean(attrs["gen_ai.guard.stopped"]);
734
721
  const agentSecurity = consentOutcome || policyDecision || injectionVerdict || actionRiskClass || inputProvenance || planStepIndex !== void 0 || securityEvent || guardStoppedAttr !== void 0 || guard?.stopped ? {
735
722
  ...consentOutcome && { consentOutcome },
736
723
  ...policyDecision && { policyDecision },
@@ -762,15 +749,15 @@ function toGenAiSpan(span) {
762
749
  requestModel,
763
750
  responseModel,
764
751
  params: {
765
- temperature: num(attrs["gen_ai.request.temperature"]),
766
- topP: num(attrs["gen_ai.request.top_p"]),
767
- topK: num(attrs["gen_ai.request.top_k"]),
768
- maxTokens: num(attrs["gen_ai.request.max_tokens"]),
769
- stopSequences: strArray(attrs["gen_ai.request.stop_sequences"]),
770
- seed: num(attrs["gen_ai.request.seed"]),
771
- frequencyPenalty: num(attrs["gen_ai.request.frequency_penalty"]),
772
- presencePenalty: num(attrs["gen_ai.request.presence_penalty"]),
773
- choiceCount: num(attrs["gen_ai.request.choice.count"])
752
+ temperature: asNumber(attrs["gen_ai.request.temperature"]),
753
+ topP: asNumber(attrs["gen_ai.request.top_p"]),
754
+ topK: asNumber(attrs["gen_ai.request.top_k"]),
755
+ maxTokens: asNumber(attrs["gen_ai.request.max_tokens"]),
756
+ stopSequences: asStringArray(attrs["gen_ai.request.stop_sequences"]),
757
+ seed: asNumber(attrs["gen_ai.request.seed"]),
758
+ frequencyPenalty: asNumber(attrs["gen_ai.request.frequency_penalty"]),
759
+ presencePenalty: asNumber(attrs["gen_ai.request.presence_penalty"]),
760
+ choiceCount: asNumber(attrs["gen_ai.request.choice.count"])
774
761
  },
775
762
  messages,
776
763
  toolDefinitions: readToolDefinitions(attrs),
@@ -782,7 +769,7 @@ function toGenAiSpan(span) {
782
769
  session,
783
770
  warnings,
784
771
  finishReasons,
785
- responseId: str(attrs["gen_ai.response.id"]),
772
+ responseId: asString(attrs["gen_ai.response.id"]),
786
773
  agent: agentId || agentName || agentDescription ? {
787
774
  id: agentId,
788
775
  name: agentName,
@@ -800,7 +787,7 @@ function toGenAiSpan(span) {
800
787
  name: guardrailName,
801
788
  triggered: guardrailTriggered
802
789
  } : void 0,
803
- conversationId: str(attrs["gen_ai.conversation.id"]),
790
+ conversationId: asString(attrs["gen_ai.conversation.id"]),
804
791
  agentSecurity,
805
792
  evaluation: evalName || evalScoreValue !== void 0 || evalScoreLabel || evalExplanation ? {
806
793
  name: evalName,
@@ -817,12 +804,12 @@ function toGenAiSpan(span) {
817
804
  embeddingDimensions: embeddingDims
818
805
  } : void 0,
819
806
  extras: {
820
- openaiServiceTier: str(attrs["gen_ai.openai.request.service_tier"]) || str(attrs["gen_ai.openai.response.service_tier"]) || str(attrs["openai.request.service_tier"]) || str(attrs["openai.response.service_tier"]) ? {
821
- request: str(attrs["gen_ai.openai.request.service_tier"]) ?? str(attrs["openai.request.service_tier"]),
822
- response: str(attrs["gen_ai.openai.response.service_tier"]) ?? str(attrs["openai.response.service_tier"])
807
+ openaiServiceTier: asString(attrs["gen_ai.openai.request.service_tier"]) || asString(attrs["gen_ai.openai.response.service_tier"]) || asString(attrs["openai.request.service_tier"]) || asString(attrs["openai.response.service_tier"]) ? {
808
+ request: asString(attrs["gen_ai.openai.request.service_tier"]) ?? asString(attrs["openai.request.service_tier"]),
809
+ response: asString(attrs["gen_ai.openai.response.service_tier"]) ?? asString(attrs["openai.response.service_tier"])
823
810
  } : void 0,
824
- openaiSystemFingerprint: str(attrs["gen_ai.openai.response.system_fingerprint"]) ?? str(attrs["openai.response.system_fingerprint"]),
825
- openaiResponseFormat: str(attrs["gen_ai.openai.request.response_format"]) ?? str(attrs["openai.request.response_format"]),
811
+ openaiSystemFingerprint: asString(attrs["gen_ai.openai.response.system_fingerprint"]) ?? asString(attrs["openai.response.system_fingerprint"]),
812
+ openaiResponseFormat: asString(attrs["gen_ai.openai.request.response_format"]) ?? asString(attrs["openai.request.response_format"]),
826
813
  raw
827
814
  }
828
815
  };