@agent-inspect/viewer 6.31.18 → 6.31.20

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.cjs CHANGED
@@ -1571,7 +1571,7 @@ function extractSessionWorkflowMetadata(record) {
1571
1571
  assignString("conversationId", record.conversationId);
1572
1572
  assignString("groupId", record.groupId);
1573
1573
  assignString("parentGroupId", record.parentGroupId);
1574
- assignString("retryOf", record.retryOf);
1574
+ assignString("retryOf", record.retryOf ?? record["agent_inspect.retry_of"]);
1575
1575
  assignString("retryReason", record.retryReason);
1576
1576
  assignString("handoffFrom", record.handoffFrom);
1577
1577
  assignString("handoffTo", record.handoffTo);
@@ -1584,8 +1584,8 @@ function extractSessionWorkflowMetadata(record) {
1584
1584
  assignString("toolCallId", record.toolCallId);
1585
1585
  assignString("mcpToolCallId", record.mcpToolCallId);
1586
1586
  assignString("linkedStepId", record.linkedStepId);
1587
- assignString("operationId", record.operationId);
1588
- assignString("attemptId", record.attemptId);
1587
+ assignString("operationId", record.operationId ?? record["agent_inspect.operation_id"]);
1588
+ assignString("attemptId", record.attemptId ?? record["agent_inspect.attempt_id"]);
1589
1589
  assignString("fallbackOf", record.fallbackOf);
1590
1590
  assignString("idempotencyKey", record.idempotencyKey);
1591
1591
  assignString("correlationId", record.correlationId);
@@ -1596,7 +1596,9 @@ function extractSessionWorkflowMetadata(record) {
1596
1596
  out.attempt = attempt;
1597
1597
  found = true;
1598
1598
  }
1599
- const attemptNumber = finitePositiveInt(record.attemptNumber);
1599
+ const attemptNumber = finitePositiveInt(
1600
+ record.attemptNumber ?? record["agent_inspect.attempt_number"]
1601
+ );
1600
1602
  if (attemptNumber !== void 0) {
1601
1603
  out.attemptNumber = attemptNumber;
1602
1604
  found = true;
@@ -5391,6 +5393,70 @@ function mapOtlpEvents(value, pathPrefix) {
5391
5393
  unsupportedFields
5392
5394
  };
5393
5395
  }
5396
+ function promoteAgentInspectWorkflowIdentity(attributes, pathPrefix) {
5397
+ const warnings = [];
5398
+ const mapping = [
5399
+ ["agent_inspect.operation_id", "operationId", "string"],
5400
+ ["agent_inspect.attempt_id", "attemptId", "string"],
5401
+ ["agent_inspect.retry_of", "retryOf", "string"],
5402
+ ["agent_inspect.attempt_number", "attemptNumber", "int"]
5403
+ ];
5404
+ const metadata = attributes.metadata && typeof attributes.metadata === "object" && !Array.isArray(attributes.metadata) ? { ...attributes.metadata } : {};
5405
+ for (const [dotted, camel, kind] of mapping) {
5406
+ const raw = attributes[dotted];
5407
+ if (raw === void 0 || raw === null) continue;
5408
+ let promoted;
5409
+ if (kind === "int") {
5410
+ const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
5411
+ if (!Number.isFinite(n) || n < 1) {
5412
+ warnings.push({
5413
+ code: "otlp_identity_invalid",
5414
+ message: `Ignoring invalid ${dotted} identity value.`,
5415
+ severity: "warning",
5416
+ field: `${pathPrefix}.${dotted}`
5417
+ });
5418
+ continue;
5419
+ }
5420
+ promoted = Math.trunc(n);
5421
+ } else if (typeof raw === "string" && raw.trim() !== "") {
5422
+ promoted = raw.trim();
5423
+ } else {
5424
+ warnings.push({
5425
+ code: "otlp_identity_invalid",
5426
+ message: `Ignoring non-string ${dotted} identity value.`,
5427
+ severity: "warning",
5428
+ field: `${pathPrefix}.${dotted}`
5429
+ });
5430
+ continue;
5431
+ }
5432
+ const direct = attributes[camel];
5433
+ const nested = metadata[camel];
5434
+ if (direct !== void 0 && direct !== promoted) {
5435
+ warnings.push({
5436
+ code: "otlp_identity_conflict",
5437
+ message: `Conflicting ${camel}: attributes.${camel} vs ${dotted}; keeping camelCase.`,
5438
+ severity: "warning",
5439
+ field: `${pathPrefix}.${dotted}`
5440
+ });
5441
+ continue;
5442
+ }
5443
+ if (nested !== void 0 && nested !== promoted && direct === void 0) {
5444
+ warnings.push({
5445
+ code: "otlp_identity_conflict",
5446
+ message: `Conflicting ${camel}: attributes.metadata.${camel} vs ${dotted}; keeping nested.`,
5447
+ severity: "warning",
5448
+ field: `${pathPrefix}.${dotted}`
5449
+ });
5450
+ continue;
5451
+ }
5452
+ if (direct === void 0) attributes[camel] = promoted;
5453
+ if (nested === void 0) metadata[camel] = promoted;
5454
+ }
5455
+ if (Object.keys(metadata).length > 0) {
5456
+ attributes.metadata = metadata;
5457
+ }
5458
+ return warnings;
5459
+ }
5394
5460
  function mapOtlpSpan(context) {
5395
5461
  const { span, pathPrefix } = context;
5396
5462
  const warnings = [];
@@ -5422,6 +5488,7 @@ function mapOtlpSpan(context) {
5422
5488
  if (context.scopeVersion !== void 0) {
5423
5489
  attributes["scope.version"] = context.scopeVersion;
5424
5490
  }
5491
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
5425
5492
  for (const [key, value] of Object.entries(span)) {
5426
5493
  if (OTLP_SPAN_KEYS.has(key)) continue;
5427
5494
  unsupportedFields.push(`${pathPrefix}.${key}`);
@@ -5459,6 +5526,7 @@ function mapOtlpSpan(context) {
5459
5526
  if (events.events !== void 0) {
5460
5527
  attributes["otlp.events"] = events.events;
5461
5528
  }
5529
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
5462
5530
  const traceId = readStringField(span, ["traceId"]) ?? "trace-unknown";
5463
5531
  const spanId = readStringField(span, ["spanId"]) ?? "span-unknown";
5464
5532
  const parentSpanId = readStringField(span, ["parentSpanId"]);