agent-inspect 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.
@@ -2906,6 +2906,70 @@ function mapOtlpEvents(value, pathPrefix) {
2906
2906
  unsupportedFields
2907
2907
  };
2908
2908
  }
2909
+ function promoteAgentInspectWorkflowIdentity(attributes, pathPrefix) {
2910
+ const warnings = [];
2911
+ const mapping = [
2912
+ ["agent_inspect.operation_id", "operationId", "string"],
2913
+ ["agent_inspect.attempt_id", "attemptId", "string"],
2914
+ ["agent_inspect.retry_of", "retryOf", "string"],
2915
+ ["agent_inspect.attempt_number", "attemptNumber", "int"]
2916
+ ];
2917
+ const metadata = attributes.metadata && typeof attributes.metadata === "object" && !Array.isArray(attributes.metadata) ? { ...attributes.metadata } : {};
2918
+ for (const [dotted, camel, kind] of mapping) {
2919
+ const raw = attributes[dotted];
2920
+ if (raw === void 0 || raw === null) continue;
2921
+ let promoted;
2922
+ if (kind === "int") {
2923
+ const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
2924
+ if (!Number.isFinite(n) || n < 1) {
2925
+ warnings.push({
2926
+ code: "otlp_identity_invalid",
2927
+ message: `Ignoring invalid ${dotted} identity value.`,
2928
+ severity: "warning",
2929
+ field: `${pathPrefix}.${dotted}`
2930
+ });
2931
+ continue;
2932
+ }
2933
+ promoted = Math.trunc(n);
2934
+ } else if (typeof raw === "string" && raw.trim() !== "") {
2935
+ promoted = raw.trim();
2936
+ } else {
2937
+ warnings.push({
2938
+ code: "otlp_identity_invalid",
2939
+ message: `Ignoring non-string ${dotted} identity value.`,
2940
+ severity: "warning",
2941
+ field: `${pathPrefix}.${dotted}`
2942
+ });
2943
+ continue;
2944
+ }
2945
+ const direct = attributes[camel];
2946
+ const nested = metadata[camel];
2947
+ if (direct !== void 0 && direct !== promoted) {
2948
+ warnings.push({
2949
+ code: "otlp_identity_conflict",
2950
+ message: `Conflicting ${camel}: attributes.${camel} vs ${dotted}; keeping camelCase.`,
2951
+ severity: "warning",
2952
+ field: `${pathPrefix}.${dotted}`
2953
+ });
2954
+ continue;
2955
+ }
2956
+ if (nested !== void 0 && nested !== promoted && direct === void 0) {
2957
+ warnings.push({
2958
+ code: "otlp_identity_conflict",
2959
+ message: `Conflicting ${camel}: attributes.metadata.${camel} vs ${dotted}; keeping nested.`,
2960
+ severity: "warning",
2961
+ field: `${pathPrefix}.${dotted}`
2962
+ });
2963
+ continue;
2964
+ }
2965
+ if (direct === void 0) attributes[camel] = promoted;
2966
+ if (nested === void 0) metadata[camel] = promoted;
2967
+ }
2968
+ if (Object.keys(metadata).length > 0) {
2969
+ attributes.metadata = metadata;
2970
+ }
2971
+ return warnings;
2972
+ }
2909
2973
  function mapOtlpSpan(context) {
2910
2974
  const { span, pathPrefix } = context;
2911
2975
  const warnings = [];
@@ -2937,6 +3001,7 @@ function mapOtlpSpan(context) {
2937
3001
  if (context.scopeVersion !== void 0) {
2938
3002
  attributes["scope.version"] = context.scopeVersion;
2939
3003
  }
3004
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
2940
3005
  for (const [key, value] of Object.entries(span)) {
2941
3006
  if (OTLP_SPAN_KEYS.has(key)) continue;
2942
3007
  unsupportedFields.push(`${pathPrefix}.${key}`);
@@ -2974,6 +3039,7 @@ function mapOtlpSpan(context) {
2974
3039
  if (events.events !== void 0) {
2975
3040
  attributes["otlp.events"] = events.events;
2976
3041
  }
3042
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
2977
3043
  const traceId = readStringField(span, ["traceId"]) ?? "trace-unknown";
2978
3044
  const spanId = readStringField(span, ["spanId"]) ?? "span-unknown";
2979
3045
  const parentSpanId = readStringField(span, ["parentSpanId"]);