@tangle-network/agent-eval 0.138.0 → 0.139.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.
Files changed (164) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +2 -1
  3. package/dist/analyst/index.d.ts +41 -94
  4. package/dist/analyst/index.d.ts.map +1 -1
  5. package/dist/analyst/index.js +9 -24
  6. package/dist/analyst/index.js.map +1 -1
  7. package/dist/{benchmark-D8dkki-J.js → benchmark-CYtcIF2V.js} +2 -2
  8. package/dist/{benchmark-D8dkki-J.js.map → benchmark-CYtcIF2V.js.map} +1 -1
  9. package/dist/{benchmark-DlQgU_XI.d.ts → benchmark-DDVdWcwA.d.ts} +3 -3
  10. package/dist/{benchmark-DlQgU_XI.d.ts.map → benchmark-DDVdWcwA.d.ts.map} +1 -1
  11. package/dist/{benchmark-command-CMqVqReF.js → benchmark-command-BKfjOBJ5.js} +243 -38
  12. package/dist/benchmark-command-BKfjOBJ5.js.map +1 -0
  13. package/dist/benchmarks/index.d.ts +1 -1
  14. package/dist/benchmarks/index.js +1 -1
  15. package/dist/{benchmarks-BJ_xK5rQ.js → benchmarks-zxhy1QV3.js} +4 -4
  16. package/dist/{benchmarks-BJ_xK5rQ.js.map → benchmarks-zxhy1QV3.js.map} +1 -1
  17. package/dist/campaign/index.d.ts +5 -5
  18. package/dist/campaign/index.js +4 -3
  19. package/dist/{campaign-BIBS-NHV.js → campaign-DrS6_hLd.js} +10 -9
  20. package/dist/campaign-DrS6_hLd.js.map +1 -0
  21. package/dist/canonical-D011XM8r.js +86 -0
  22. package/dist/canonical-D011XM8r.js.map +1 -0
  23. package/dist/cli.js +3 -3
  24. package/dist/{client-BwPKohkJ.d.ts → client-BohnDFBq.d.ts} +4 -4
  25. package/dist/{client-BwPKohkJ.d.ts.map → client-BohnDFBq.d.ts.map} +1 -1
  26. package/dist/{completion-verifier-B4-IMYcS.d.ts → completion-verifier-IPoP4fQO.d.ts} +178 -4
  27. package/dist/completion-verifier-IPoP4fQO.d.ts.map +1 -0
  28. package/dist/contract/index.d.ts +10 -10
  29. package/dist/contract/index.js +8 -7
  30. package/dist/contract/index.js.map +1 -1
  31. package/dist/control.d.ts +2 -2
  32. package/dist/{cost-ledger-CHDLA0Ss.js → cost-ledger-CZ9diLxY.js} +7 -7
  33. package/dist/cost-ledger-CZ9diLxY.js.map +1 -0
  34. package/dist/{cost-ledger-B1D3COAc.d.ts → cost-ledger-DKgyIWRj.d.ts} +5 -2
  35. package/dist/cost-ledger-DKgyIWRj.d.ts.map +1 -0
  36. package/dist/default-registry-B8vf7Rmf.d.ts +118 -0
  37. package/dist/default-registry-B8vf7Rmf.d.ts.map +1 -0
  38. package/dist/{default-registry-lp5R0lve.js → default-registry-BgJJItGr.js} +57 -1532
  39. package/dist/default-registry-BgJJItGr.js.map +1 -0
  40. package/dist/dspy-rlm-engine-DTkVyDX-.js +344 -0
  41. package/dist/dspy-rlm-engine-DTkVyDX-.js.map +1 -0
  42. package/dist/{eval-campaign-9MozgKL7.js → eval-campaign-BmptJj50.js} +2 -2
  43. package/dist/{eval-campaign-9MozgKL7.js.map → eval-campaign-BmptJj50.js.map} +1 -1
  44. package/dist/{exact-types-Dpw2LeHA.d.ts → exact-types-MaaFcllV.d.ts} +2 -2
  45. package/dist/{exact-types-Dpw2LeHA.d.ts.map → exact-types-MaaFcllV.d.ts.map} +1 -1
  46. package/dist/external-optimizer-contracts-BrxY2Sli.d.ts +32 -0
  47. package/dist/external-optimizer-contracts-BrxY2Sli.d.ts.map +1 -0
  48. package/dist/{extract-usage-CS391dOE.js → extract-usage-DZs601Va.js} +2 -2
  49. package/dist/{extract-usage-CS391dOE.js.map → extract-usage-DZs601Va.js.map} +1 -1
  50. package/dist/{feedback-trajectory-CoNep7rl.d.ts → feedback-trajectory-BJUWOkJM.d.ts} +3 -3
  51. package/dist/{feedback-trajectory-CoNep7rl.d.ts.map → feedback-trajectory-BJUWOkJM.d.ts.map} +1 -1
  52. package/dist/fuzz.d.ts +1 -1
  53. package/dist/fuzz.js +1 -1
  54. package/dist/{hf-dataset-DBJXXoY1.js → hf-dataset-XggBupCr.js} +2 -2
  55. package/dist/{hf-dataset-DBJXXoY1.js.map → hf-dataset-XggBupCr.js.map} +1 -1
  56. package/dist/hosted/index.d.ts +3 -3
  57. package/dist/{index-D0cxAdaV.d.ts → index-BTm_P9aC.d.ts} +11 -11
  58. package/dist/{index-D0cxAdaV.d.ts.map → index-BTm_P9aC.d.ts.map} +1 -1
  59. package/dist/{index-B2-IxCMB.d.ts → index-CWOPCJiw.d.ts} +2 -2
  60. package/dist/{index-B2-IxCMB.d.ts.map → index-CWOPCJiw.d.ts.map} +1 -1
  61. package/dist/{index-sMN_hI4E.d.ts → index-CtR1xh4V.d.ts} +3 -3
  62. package/dist/{index-sMN_hI4E.d.ts.map → index-CtR1xh4V.d.ts.map} +1 -1
  63. package/dist/{index-CjVYlVBK.d.ts → index-_66rVpwN.d.ts} +5 -5
  64. package/dist/{index-CjVYlVBK.d.ts.map → index-_66rVpwN.d.ts.map} +1 -1
  65. package/dist/index.d.ts +35 -56
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +51 -176
  68. package/dist/index.js.map +1 -1
  69. package/dist/{insight-report-CXd8VBDR.d.ts → insight-report-Bu5Wi9tG.d.ts} +4 -4
  70. package/dist/{insight-report-CXd8VBDR.d.ts.map → insight-report-Bu5Wi9tG.d.ts.map} +1 -1
  71. package/dist/{integrity-B-MLFz0I.d.ts → integrity-COTh3DTH.d.ts} +2 -2
  72. package/dist/{integrity-B-MLFz0I.d.ts.map → integrity-COTh3DTH.d.ts.map} +1 -1
  73. package/dist/kind-factory-CFxA0JQX.js +2133 -0
  74. package/dist/kind-factory-CFxA0JQX.js.map +1 -0
  75. package/dist/ledger-core/index.js +2 -1
  76. package/dist/{ledger-core-C0Yx1I14.js → ledger-core-Dxz0Rkwa.js} +3 -85
  77. package/dist/ledger-core-Dxz0Rkwa.js.map +1 -0
  78. package/dist/{llm-client-Cj3c7PEm.js → llm-client-bkztEfIx.js} +2 -2
  79. package/dist/{llm-client-Cj3c7PEm.js.map → llm-client-bkztEfIx.js.map} +1 -1
  80. package/dist/meta-eval/index.d.ts +2 -2
  81. package/dist/multishot/index.d.ts +2 -2
  82. package/dist/openapi.json +1 -1
  83. package/dist/{release-report-CoyvyLBs.d.ts → release-report-fZarvIm-.d.ts} +3 -3
  84. package/dist/{release-report-CoyvyLBs.d.ts.map → release-report-fZarvIm-.d.ts.map} +1 -1
  85. package/dist/{replay-DbIYwso6.d.ts → replay-DjG4IG60.d.ts} +34 -143
  86. package/dist/replay-DjG4IG60.d.ts.map +1 -0
  87. package/dist/{replay-Cb-4Vf0k.js → replay-SA4OB7O7.js} +48 -137
  88. package/dist/replay-SA4OB7O7.js.map +1 -0
  89. package/dist/reporting.d.ts +4 -4
  90. package/dist/{researcher-BCeOEjtR.d.ts → researcher-BxhtGfKa.d.ts} +5 -5
  91. package/dist/{researcher-BCeOEjtR.d.ts.map → researcher-BxhtGfKa.d.ts.map} +1 -1
  92. package/dist/{reward-hacking-sE2l_NV6.d.ts → reward-hacking-CqSLiV51.d.ts} +2 -2
  93. package/dist/{reward-hacking-sE2l_NV6.d.ts.map → reward-hacking-CqSLiV51.d.ts.map} +1 -1
  94. package/dist/rl.d.ts +5 -5
  95. package/dist/rl.js +1 -1
  96. package/dist/rollout/index.d.ts +1 -1
  97. package/dist/rollout/index.js +2 -2
  98. package/dist/{rollout-DQFl0UXA.js → rollout-8nj3mYvx.js} +2 -2
  99. package/dist/{rollout-DQFl0UXA.js.map → rollout-8nj3mYvx.js.map} +1 -1
  100. package/dist/{rubric-predictive-validity-w2klGv1u.d.ts → rubric-predictive-validity-DQBQj6uV.d.ts} +2 -2
  101. package/dist/{rubric-predictive-validity-w2klGv1u.d.ts.map → rubric-predictive-validity-DQBQj6uV.d.ts.map} +1 -1
  102. package/dist/{run-evidence-CbE0A8Xg.d.ts → run-evidence-C4RcRQT5.d.ts} +3 -3
  103. package/dist/{run-evidence-CbE0A8Xg.d.ts.map → run-evidence-C4RcRQT5.d.ts.map} +1 -1
  104. package/dist/{run-record-DwHMk1Ai.d.ts → run-record-CztDMXVF.d.ts} +2 -2
  105. package/dist/{run-record-DwHMk1Ai.d.ts.map → run-record-CztDMXVF.d.ts.map} +1 -1
  106. package/dist/{semantic-concept-judge-DYXDPZW0.js → semantic-concept-judge-BuIJ9IfB.js} +43 -6
  107. package/dist/semantic-concept-judge-BuIJ9IfB.js.map +1 -0
  108. package/dist/{server-DLEvyW2z.js → server-DaCpLfi0.js} +3 -3
  109. package/dist/{server-DLEvyW2z.js.map → server-DaCpLfi0.js.map} +1 -1
  110. package/dist/single-run-lock-BTTtPZ9N.js +989 -0
  111. package/dist/single-run-lock-BTTtPZ9N.js.map +1 -0
  112. package/dist/{skill-usage-Bv3G4VkA.d.ts → skill-usage-B-BFS8M2.d.ts} +54 -39
  113. package/dist/skill-usage-B-BFS8M2.d.ts.map +1 -0
  114. package/dist/{skillopt-optimization-method-CjKMZy0d.js → skillopt-optimization-method-BbGnCC53.js} +18 -802
  115. package/dist/skillopt-optimization-method-BbGnCC53.js.map +1 -0
  116. package/dist/{skillopt-optimization-method-CzfnA8O-.d.ts → skillopt-optimization-method-_s0Tub7Y.d.ts} +11 -39
  117. package/dist/skillopt-optimization-method-_s0Tub7Y.d.ts.map +1 -0
  118. package/dist/{statistics-mf70aXKp.d.ts → statistics-B5d0Zd-z.d.ts} +2 -2
  119. package/dist/{statistics-mf70aXKp.d.ts.map → statistics-B5d0Zd-z.d.ts.map} +1 -1
  120. package/dist/store-otlp-DX4fGIcf.js +757 -0
  121. package/dist/store-otlp-DX4fGIcf.js.map +1 -0
  122. package/dist/{summary-report-BKinV4yD.d.ts → summary-report-Cg7BifAM.d.ts} +3 -3
  123. package/dist/{summary-report-BKinV4yD.d.ts.map → summary-report-Cg7BifAM.d.ts.map} +1 -1
  124. package/dist/tool-groups-CdYq22lX.d.ts +258 -0
  125. package/dist/tool-groups-CdYq22lX.d.ts.map +1 -0
  126. package/dist/traces.d.ts +7 -6
  127. package/dist/traces.js +5 -5
  128. package/dist/{types-zFYez3PK.d.ts → types-BBFNHxSK.d.ts} +5 -5
  129. package/dist/{types-zFYez3PK.d.ts.map → types-BBFNHxSK.d.ts.map} +1 -1
  130. package/dist/{types-BtJhn8v6.d.ts → types-DoEYskCd.d.ts} +5 -5
  131. package/dist/{types-BtJhn8v6.d.ts.map → types-DoEYskCd.d.ts.map} +1 -1
  132. package/dist/{types-5q2T25iW.d.ts → types-uPrS6mD-.d.ts} +2 -2
  133. package/dist/{types-5q2T25iW.d.ts.map → types-uPrS6mD-.d.ts.map} +1 -1
  134. package/dist/usage-receipt-CgxMEBZq.js +134 -0
  135. package/dist/usage-receipt-CgxMEBZq.js.map +1 -0
  136. package/dist/wire/index.d.ts +3 -3
  137. package/dist/wire/index.js +1 -1
  138. package/docs/trace-analysis.md +170 -484
  139. package/package.json +1 -2
  140. package/dist/analyze-runs-CPYxfPWT.d.ts +0 -72
  141. package/dist/analyze-runs-CPYxfPWT.d.ts.map +0 -1
  142. package/dist/benchmark-command-CMqVqReF.js.map +0 -1
  143. package/dist/campaign-BIBS-NHV.js.map +0 -1
  144. package/dist/completion-verifier-B4-IMYcS.d.ts.map +0 -1
  145. package/dist/cost-ledger-B1D3COAc.d.ts.map +0 -1
  146. package/dist/cost-ledger-CHDLA0Ss.js.map +0 -1
  147. package/dist/default-registry-PUhIVRWz.d.ts +0 -215
  148. package/dist/default-registry-PUhIVRWz.d.ts.map +0 -1
  149. package/dist/default-registry-lp5R0lve.js.map +0 -1
  150. package/dist/ledger-core-C0Yx1I14.js.map +0 -1
  151. package/dist/registry-C4yJTza7.d.ts +0 -178
  152. package/dist/registry-C4yJTza7.d.ts.map +0 -1
  153. package/dist/replay-Cb-4Vf0k.js.map +0 -1
  154. package/dist/replay-DbIYwso6.d.ts.map +0 -1
  155. package/dist/semantic-concept-judge-DYXDPZW0.js.map +0 -1
  156. package/dist/single-run-lock-D_bS5xhj.js +0 -318
  157. package/dist/single-run-lock-D_bS5xhj.js.map +0 -1
  158. package/dist/skill-usage-Bv3G4VkA.d.ts.map +0 -1
  159. package/dist/skillopt-optimization-method-CjKMZy0d.js.map +0 -1
  160. package/dist/skillopt-optimization-method-CzfnA8O-.d.ts.map +0 -1
  161. package/dist/store-otlp-BenKynPE.js +0 -1688
  162. package/dist/store-otlp-BenKynPE.js.map +0 -1
  163. package/dist/tools-DZGdROtG.js +0 -255
  164. package/dist/tools-DZGdROtG.js.map +0 -1
@@ -1,1688 +0,0 @@
1
- import { a as LimitExceededError, c as ValidationError, n as CaptureIntegrityError, o as NotFoundError, t as AgentEvalError } from "./errors-D-LKuDhb.js";
2
- import { INPUT_VALUE, LLM_MODEL_ATTR_KEYS, OUTPUT_VALUE, SPAN_KIND_ATTR_KEYS, TOOL_ARGS_CAPTURED, TOOL_LATENCY_MS, TOOL_NAME, TOOL_NAME_ATTR_KEYS } from "./trace-attributes.js";
3
- import { z } from "zod";
4
- import { readFile, stat } from "node:fs/promises";
5
- import { RE2JS } from "re2js";
6
- //#region src/trace/otlp-attributes.ts
7
- /** Canonical OpenInference-over-OTLP attribute vocabulary used at the trace boundary. */
8
- const TOOL_SPAN_ATTRIBUTE_KEYS = [
9
- TOOL_NAME,
10
- TOOL_ARGS_CAPTURED,
11
- TOOL_LATENCY_MS,
12
- INPUT_VALUE,
13
- OUTPUT_VALUE
14
- ];
15
- const EXPLICIT_SPAN_ROLES = /* @__PURE__ */ new Set([
16
- "AGENT",
17
- "CHAIN",
18
- "EVALUATOR",
19
- "GUARDRAIL",
20
- "LLM",
21
- "SPAN",
22
- "TOOL"
23
- ]);
24
- /**
25
- * Classify a span once for both measurement and error accounting.
26
- * An explicit OpenInference kind wins; untyped spans use the same tool and
27
- * model signals in online and offline intake.
28
- */
29
- function classifyOtlpSpanRole(input) {
30
- const explicitKind = input.kind ?? firstStringAttribute(input.attributes, SPAN_KIND_ATTR_KEYS);
31
- if (explicitKind) {
32
- const normalized = explicitKind.toUpperCase();
33
- if (EXPLICIT_SPAN_ROLES.has(normalized)) return normalized;
34
- }
35
- if (firstStringAttribute(input.attributes, TOOL_NAME_ATTR_KEYS) !== void 0 || /^(?:function|tool)[.:/]/i.test(input.name)) return "TOOL";
36
- const spanType = input.attributes["span.type"];
37
- if (typeof spanType === "string" && spanType.toLowerCase() === "llm_request" || /(?:^|[.:/_-])(?:chat[._-]?completions?|llm)(?:$|[.:/_-])/i.test(input.name) || firstStringAttribute(input.attributes, LLM_MODEL_ATTR_KEYS) !== void 0 || typeof input.attributes["gen_ai.operation.name"] === "string") return "LLM";
38
- return "UNKNOWN";
39
- }
40
- function isOtlpModelCall(input) {
41
- return classifyOtlpSpanRole(input) === "LLM";
42
- }
43
- function toolSpanOtlpAttributes(span) {
44
- const argsCaptured = span.argsCaptured !== false;
45
- const attributes = {
46
- [TOOL_NAME]: span.toolName,
47
- [TOOL_ARGS_CAPTURED]: argsCaptured
48
- };
49
- if (span.latencyMs !== void 0) attributes[TOOL_LATENCY_MS] = span.latencyMs;
50
- if (argsCaptured) attributes[INPUT_VALUE] = stringifyTraceValue(span.args);
51
- if (span.result !== void 0) attributes[OUTPUT_VALUE] = stringifyTraceValue(span.result);
52
- return attributes;
53
- }
54
- function applyToolSpanOtlpAttributes(attributes, span) {
55
- for (const key of TOOL_SPAN_ATTRIBUTE_KEYS) delete attributes[key];
56
- Object.assign(attributes, toolSpanOtlpAttributes(span));
57
- }
58
- function traceSpanKindToOpenInferenceKind(kind) {
59
- switch (kind) {
60
- case "llm": return "LLM";
61
- case "tool": return "TOOL";
62
- case "retrieval": return "CHAIN";
63
- case "judge": return "EVALUATOR";
64
- case "sandbox": return "CHAIN";
65
- case "agent": return "AGENT";
66
- default: return "SPAN";
67
- }
68
- }
69
- function firstStringAttribute(attributes, keys) {
70
- for (const key of keys) {
71
- const value = attributes[key];
72
- if (typeof value === "string" && value.length > 0) return value;
73
- }
74
- }
75
- function stringifyTraceValue(value) {
76
- if (value === void 0) return "null";
77
- if (typeof value === "string") return value;
78
- try {
79
- return JSON.stringify(value) ?? String(value);
80
- } catch {
81
- return String(value);
82
- }
83
- }
84
- //#endregion
85
- //#region src/trace-analyst/otlp-span.ts
86
- /**
87
- * Canonical OTLP-flat-line readers shared by every consumer of the
88
- * OTLP-JSONL wire shape (one OTLP span per line; the form
89
- * `flattenOtlpExportToNdjson` produces and the form AppWorld / HALO
90
- * emit via their OpenInference OTLP exporter).
91
- *
92
- * `OtlpFileTraceStore` indexes spans with these; `otlpToRunRecords`
93
- * aggregates spans into `RunRecord`s with the same readers. One parser,
94
- * one vocabulary — a divergence between the analyst's view of a trace and
95
- * the RunRecord projected from it is a class of bug this consolidation
96
- * removes by construction.
97
- *
98
- * Vocabulary. The readers understand BOTH dialects that appear in the
99
- * wild:
100
- * - the substrate's own `llm.*` / `tool.*` / `span.kind` attributes
101
- * (`flattenSpanAttributes` in `trace/otel.ts`), and
102
- * - the OpenInference / inference-export attributes AppWorld / HALO
103
- * emit (`openinference.span.kind`, `inference.observation_kind`,
104
- * `inference.llm.input_tokens`, `llm.token_count.prompt`, …).
105
- *
106
- * Pure, no I/O.
107
- */
108
- /**
109
- * Project one parsed OTLP-JSONL object to `ProjectedOtlpSpan`, or `null`
110
- * when the line is missing the mandatory `trace_id` + `span_id`.
111
- */
112
- function projectOtlpFlatLine(raw) {
113
- const trace_id = stringField(raw, "trace_id") ?? stringField(raw, "traceId");
114
- const span_id = stringField(raw, "span_id") ?? stringField(raw, "spanId");
115
- if (!trace_id || !span_id) return null;
116
- const parent_id = normalizeParentSpanId(trace_id, span_id, stringField(raw, "parent_span_id") ?? stringField(raw, "parentSpanId") ?? null);
117
- const name = stringField(raw, "name") ?? "unknown";
118
- const start_time = stringField(raw, "start_time") ?? stringField(raw, "startTime") ?? "";
119
- const end_time = stringField(raw, "end_time") ?? stringField(raw, "endTime") ?? start_time;
120
- const status = readOtlpStatus(raw);
121
- const attributes = extractOtlpAttributes(raw);
122
- const service_name = asString(attributes["service.name"]) ?? asString(attributes["resource.attributes.service.name"]) ?? null;
123
- const agent_name = asString(attributes["agent.name"]) ?? asString(attributes["inference.agent.name"]) ?? asString(attributes["inference.agent_name"]) ?? null;
124
- const model_name = firstStringAttr(attributes, LLM_MODEL_ATTR_KEYS);
125
- const tool_name = firstStringAttr(attributes, TOOL_NAME_ATTR_KEYS);
126
- const kind = inferOtlpKind(attributes);
127
- let duration_ms = 0;
128
- if (start_time && end_time) {
129
- const a = spanEpochMillis(start_time);
130
- const b = spanEpochMillis(end_time);
131
- if (a !== null && b !== null) duration_ms = Math.max(0, b - a);
132
- }
133
- return {
134
- trace_id,
135
- span_id,
136
- parent_span_id: parent_id && parent_id.length > 0 ? parent_id : null,
137
- name,
138
- kind,
139
- start_time,
140
- end_time,
141
- duration_ms,
142
- status: status.code,
143
- status_message: status.message,
144
- service_name,
145
- agent_name,
146
- model_name,
147
- tool_name,
148
- attributes
149
- };
150
- }
151
- function normalizeParentSpanId(traceId, spanId, parentId) {
152
- if (!parentId) return null;
153
- const prefix = `${traceId}:`;
154
- return spanId.startsWith(prefix) && !parentId.startsWith(prefix) ? `${prefix}${parentId}` : parentId;
155
- }
156
- function readOtlpStatus(raw) {
157
- const status = raw.status;
158
- if (status && typeof status === "object" && !Array.isArray(status)) {
159
- const codeRaw = status.code;
160
- const code = codeRaw === "STATUS_CODE_OK" || codeRaw === "OK" ? "OK" : codeRaw === "STATUS_CODE_ERROR" || codeRaw === "ERROR" ? "ERROR" : "UNSET";
161
- const messageRaw = status.message;
162
- return {
163
- code,
164
- message: typeof messageRaw === "string" && messageRaw.length > 0 ? messageRaw : void 0
165
- };
166
- }
167
- return {
168
- code: "UNSET",
169
- message: void 0
170
- };
171
- }
172
- function inferOtlpKind(attrs) {
173
- const opik = firstStringAttr(attrs, SPAN_KIND_ATTR_KEYS);
174
- if (opik) {
175
- const upper = opik.toUpperCase();
176
- if (upper === "AGENT" || upper === "LLM" || upper === "TOOL" || upper === "CHAIN" || upper === "EVALUATOR" || upper === "GUARDRAIL" || upper === "SPAN") return upper;
177
- }
178
- return "UNKNOWN";
179
- }
180
- /**
181
- * Flatten OTLP `attributes` + `resource.attributes` into a single
182
- * dotted-key map. Span attributes override resource attributes when keys
183
- * overlap. Nested objects/arrays are preserved as-is.
184
- */
185
- function extractOtlpAttributes(raw) {
186
- const out = {};
187
- const resource = raw.resource;
188
- if (resource && typeof resource === "object" && !Array.isArray(resource)) {
189
- const ra = resource.attributes;
190
- if (ra && typeof ra === "object" && !Array.isArray(ra)) for (const [k, v] of Object.entries(ra)) out[k] = v;
191
- }
192
- const spanAttrs = raw.attributes;
193
- if (spanAttrs && typeof spanAttrs === "object" && !Array.isArray(spanAttrs)) for (const [k, v] of Object.entries(spanAttrs)) out[k] = v;
194
- return out;
195
- }
196
- function stringField(raw, key) {
197
- const v = raw[key];
198
- return typeof v === "string" ? v : void 0;
199
- }
200
- function asString(v) {
201
- return typeof v === "string" && v.length > 0 ? v : null;
202
- }
203
- /** First non-empty string value across a list of candidate attribute keys. */
204
- function firstStringAttr(attrs, keys) {
205
- for (const k of keys) {
206
- const s = asString(attrs[k]);
207
- if (s !== null) return s;
208
- }
209
- return null;
210
- }
211
- /**
212
- * Parse a span timestamp to epoch millis, or null when empty/unparseable. The
213
- * OTLP readers accept BOTH ISO-8601 and epoch-millis-string dialects, so raw
214
- * string comparison (`<`, `localeCompare`) mis-orders across dialects and
215
- * `Date.parse` returns NaN for a bare epoch-millis string.
216
- */
217
- function spanEpochMillis(ts) {
218
- if (!ts) return null;
219
- if (/^\d+$/.test(ts)) return Number(ts);
220
- const n = Date.parse(ts);
221
- return Number.isNaN(n) ? null : n;
222
- }
223
- /**
224
- * Order comparator for span timestamps across mixed ISO/epoch dialects.
225
- * Unparseable timestamps sort as epoch 0 (earliest), never NaN (which would
226
- * make the sort non-deterministic).
227
- */
228
- function compareSpanTime(a, b) {
229
- return (spanEpochMillis(a) ?? 0) - (spanEpochMillis(b) ?? 0);
230
- }
231
- //#endregion
232
- //#region src/trace-analyst/errors.ts
233
- /** Invalid trace-tool arguments, including malformed filters and regexes. */
234
- var TraceAnalysisValidationError = class extends ValidationError {};
235
- /** A trace read cannot fit within a documented count or byte limit. */
236
- var TraceAnalysisLimitError = class extends LimitExceededError {
237
- operation;
238
- actual;
239
- limit;
240
- constructor(operation, actual, limit, message) {
241
- super(message ?? `${operation} produced ${actual}, over the limit of ${limit}`);
242
- this.operation = operation;
243
- this.actual = actual;
244
- this.limit = limit;
245
- }
246
- };
247
- /** A supplied store returned a shape that violates the trace read contract. */
248
- var TraceAnalysisStoreContractError = class extends AgentEvalError {
249
- operation;
250
- constructor(operation, message, options) {
251
- super("backend_integrity", `${operation}: ${message}`, options);
252
- this.operation = operation;
253
- }
254
- };
255
- var TraceFileMissingError = class extends NotFoundError {
256
- path;
257
- constructor(path) {
258
- super(`trace file not found: ${path}`);
259
- this.path = path;
260
- }
261
- };
262
- var TraceFileTooLargeError = class extends TraceAnalysisLimitError {
263
- path;
264
- size_bytes;
265
- max_bytes;
266
- constructor(path, size_bytes, max_bytes) {
267
- super("OtlpFileTraceStore.readBuffer", size_bytes, max_bytes, `trace file ${path} is ${size_bytes} bytes, over the ${max_bytes}-byte limit; raise OtlpFileTraceStoreOptions.maxFileBytes or pre-split the file`);
268
- this.path = path;
269
- this.size_bytes = size_bytes;
270
- this.max_bytes = max_bytes;
271
- }
272
- };
273
- var TraceFileMalformedError = class extends CaptureIntegrityError {
274
- path;
275
- line_number;
276
- byte_offset;
277
- constructor(path, line_number, byte_offset, cause) {
278
- super(`malformed trace row in ${path} at line ${line_number}, byte ${byte_offset}`, { cause });
279
- this.path = path;
280
- this.line_number = line_number;
281
- this.byte_offset = byte_offset;
282
- }
283
- };
284
- var TraceNotFoundError = class extends NotFoundError {
285
- trace_id;
286
- constructor(trace_id) {
287
- super(`trace not found: ${trace_id}`);
288
- this.trace_id = trace_id;
289
- }
290
- };
291
- var SpanNotFoundError = class extends NotFoundError {
292
- trace_id;
293
- span_id;
294
- constructor(trace_id, span_id) {
295
- super(`span ${span_id} not found in trace ${trace_id}`);
296
- this.trace_id = trace_id;
297
- this.span_id = span_id;
298
- }
299
- };
300
- //#endregion
301
- //#region src/trace-analyst/shared-abortable-task.ts
302
- function createSharedAbortableTask(factory) {
303
- const controller = new AbortController();
304
- const task = {
305
- controller,
306
- promise: factory(controller.signal),
307
- consumers: 0,
308
- settled: false
309
- };
310
- task.promise.then(() => {
311
- task.settled = true;
312
- }, () => {
313
- task.settled = true;
314
- });
315
- return task;
316
- }
317
- function waitForSharedTask(task, signal) {
318
- signal?.throwIfAborted();
319
- task.consumers += 1;
320
- return new Promise((resolve, reject) => {
321
- let finished = false;
322
- const finish = (callback) => {
323
- if (finished) return;
324
- finished = true;
325
- signal?.removeEventListener("abort", onAbort);
326
- task.consumers -= 1;
327
- callback();
328
- };
329
- const onAbort = () => {
330
- finish(() => {
331
- reject(signal?.reason);
332
- if (!task.settled && task.consumers === 0) task.controller.abort(signal?.reason);
333
- });
334
- };
335
- signal?.addEventListener("abort", onAbort, { once: true });
336
- task.promise.then((value) => finish(() => resolve(value)), (error) => finish(() => reject(error)));
337
- if (signal?.aborted) onAbort();
338
- });
339
- }
340
- //#endregion
341
- //#region src/trace-analyst/store-contract.ts
342
- const TRACE_ANALYSIS_LIMITS = {
343
- sampleTraceIds: 20,
344
- queryTraces: 200,
345
- viewSpans: 100,
346
- searchMatches: 500,
347
- filterValues: 100,
348
- identifierCharacters: 256,
349
- regexCharacters: 4096,
350
- minimumTextBudget: 64
351
- };
352
- //#endregion
353
- //#region src/trace-analyst/types.ts
354
- const DEFAULT_TRACE_ANALYST_BUDGETS = {
355
- perCallByteCeiling: 15e4,
356
- perAttributeViewBudget: 4096,
357
- perAttributeSpanBudget: 16384,
358
- perMatchTextBudget: 1024
359
- };
360
- /** Marker substituted in place of truncated string payloads. Callers
361
- * parsing tool output can detect it deterministically. */
362
- const TRACE_ANALYST_TRUNCATION_MARKER_PREFIX = "[trace-analyst truncated:";
363
- //#endregion
364
- //#region src/trace-analyst/store-bounds.ts
365
- function resolveTraceBudgets(overrides) {
366
- const budgets = {
367
- ...DEFAULT_TRACE_ANALYST_BUDGETS,
368
- ...overrides
369
- };
370
- validateInteger(budgets.perCallByteCeiling, "perCallByteCeiling", 1);
371
- for (const name of [
372
- "perAttributeViewBudget",
373
- "perAttributeSpanBudget",
374
- "perMatchTextBudget"
375
- ]) validateInteger(budgets[name], name, TRACE_ANALYSIS_LIMITS.minimumTextBudget);
376
- return budgets;
377
- }
378
- function boundOverview(result, byteCeiling) {
379
- if (result.sample_trace_ids.length > result.total_traces) throw contractError("getOverview", "sample_trace_ids contains more entries than total_traces");
380
- if (result.errors.trace_count > result.total_traces) throw contractError("getOverview", "errors.trace_count exceeds total_traces");
381
- return withinByteCeiling("getOverview", result, byteCeiling);
382
- }
383
- function boundTracePage(result, input, byteCeiling) {
384
- if (result.traces.length > input.limit) throw contractError("queryTraces", `store returned ${result.traces.length} traces for limit ${input.limit}`);
385
- if (result.total < input.offset + result.traces.length) throw contractError("queryTraces", `total ${result.total} is smaller than the returned page ending at ${input.offset + result.traces.length}`);
386
- if (result.has_more !== input.offset + result.traces.length < result.total) throw contractError("queryTraces", "has_more does not match the returned page position and total");
387
- if (result.has_more && result.traces.length === 0) throw contractError("queryTraces", "store reported more traces without returning any progress");
388
- const traces = [];
389
- for (const trace of result.traces) {
390
- if (encodedBytes("queryTraces", {
391
- traces: [...traces, trace],
392
- total: result.total,
393
- has_more: true
394
- }) > byteCeiling) break;
395
- traces.push(trace);
396
- }
397
- if (result.traces.length > 0 && traces.length === 0) throw responseItemTooLarge("queryTraces", {
398
- traces: [result.traces[0]],
399
- total: result.total,
400
- has_more: true
401
- }, byteCeiling);
402
- return withinByteCeiling("queryTraces", {
403
- traces,
404
- total: result.total,
405
- has_more: result.has_more || traces.length < result.traces.length
406
- }, byteCeiling);
407
- }
408
- function boundTraceView(result, expectedTraceId, perAttributeCap, byteCeiling) {
409
- requireEqual("viewTrace", "trace_id", result.trace_id, expectedTraceId);
410
- if (result.oversized) return withinByteCeiling("viewTrace", result, byteCeiling);
411
- const spans = result.spans.map((span) => {
412
- requireEqual("viewTrace", "span.trace_id", span.trace_id, expectedTraceId);
413
- return truncateSpanAttributes("viewTrace", span, perAttributeCap).span;
414
- });
415
- const full = {
416
- trace_id: expectedTraceId,
417
- spans
418
- };
419
- if (encodedBytes("viewTrace", full) <= byteCeiling) return full;
420
- return withinByteCeiling("viewTrace", {
421
- trace_id: expectedTraceId,
422
- oversized: oversizedFromSpans(spans)
423
- }, byteCeiling);
424
- }
425
- function boundSpansView(result, expectedTraceId, requested, existingSpanIds, perAttributeCap, byteCeiling) {
426
- requireEqual("viewSpans", "trace_id", result.trace_id, expectedTraceId);
427
- const requestedSet = new Set(requested);
428
- const missing = checkedAccountingIds("missing_span_ids", result.missing_span_ids, requestedSet);
429
- const omitted = checkedAccountingIds("omitted_span_ids", result.omitted_span_ids, requestedSet);
430
- const missingSet = new Set(missing);
431
- const omittedSet = new Set(omitted);
432
- const expectedMissing = requested.filter((id) => !existingSpanIds.has(id));
433
- if (expectedMissing.length !== missing.length || expectedMissing.some((id) => !missingSet.has(id))) throw contractError("viewSpans", "missing_span_ids does not match the store existence checks");
434
- if (result.has_more !== omitted.length > 0) throw contractError("viewSpans", "has_more must be true exactly when omitted_span_ids is non-empty");
435
- if (result.spans.length === 0 && requested.some((id) => existingSpanIds.has(id) && omittedSet.has(id))) throw contractError("viewSpans", "store omitted every existing requested span instead of returning progress or throwing a size error");
436
- const projected = /* @__PURE__ */ new Map();
437
- for (const span of result.spans) {
438
- requireEqual("viewSpans", "span.trace_id", span.trace_id, expectedTraceId);
439
- if (!requestedSet.has(span.span_id)) throw contractError("viewSpans", `store returned unrequested span ${JSON.stringify(span.span_id)}`);
440
- if (missingSet.has(span.span_id) || omittedSet.has(span.span_id)) throw contractError("viewSpans", `span ${JSON.stringify(span.span_id)} is both returned and unavailable`);
441
- if (projected.has(span.span_id)) throw contractError("viewSpans", `store returned duplicate span ${JSON.stringify(span.span_id)}`);
442
- projected.set(span.span_id, truncateSpanAttributes("viewSpans", span, perAttributeCap));
443
- }
444
- for (const id of requested) if (!missingSet.has(id) && !omittedSet.has(id) && !projected.has(id)) throw contractError("viewSpans", `store did not account for requested span ${JSON.stringify(id)}`);
445
- const spans = [];
446
- let addedTruncations = 0;
447
- const build = () => ({
448
- trace_id: expectedTraceId,
449
- spans,
450
- missing_span_ids: requested.filter((id) => missingSet.has(id)),
451
- omitted_span_ids: requested.filter((id) => omittedSet.has(id)),
452
- has_more: omittedSet.size > 0,
453
- truncated_attribute_count: result.truncated_attribute_count + addedTruncations
454
- });
455
- withinByteCeiling("viewSpans", build(), byteCeiling);
456
- for (const id of requested) {
457
- const item = projected.get(id);
458
- if (!item) continue;
459
- spans.push(item.span);
460
- omittedSet.delete(id);
461
- addedTruncations += item.truncations;
462
- if (encodedBytes("viewSpans", build()) <= byteCeiling) continue;
463
- spans.pop();
464
- omittedSet.add(id);
465
- addedTruncations -= item.truncations;
466
- }
467
- if (projected.size > 0 && spans.length === 0) {
468
- const first = projected.values().next().value;
469
- if (first) throw responseItemTooLarge("viewSpans", {
470
- trace_id: expectedTraceId,
471
- spans: [first.span],
472
- missing_span_ids: [],
473
- omitted_span_ids: [],
474
- has_more: false,
475
- truncated_attribute_count: result.truncated_attribute_count + first.truncations
476
- }, byteCeiling);
477
- }
478
- return withinByteCeiling("viewSpans", build(), byteCeiling);
479
- }
480
- function boundTraceSearch(result, expectedTraceId, maxMatches, budgets) {
481
- requireEqual("searchTrace", "trace_id", result.trace_id, expectedTraceId);
482
- return {
483
- trace_id: expectedTraceId,
484
- ...boundSearchHits("searchTrace", result, maxMatches, budgets, (hit) => {
485
- requireEqual("searchTrace", "hit.trace_id", hit.trace_id, expectedTraceId);
486
- })
487
- };
488
- }
489
- function boundSpanSearch(result, expectedTraceId, expectedSpanId, maxMatches, budgets) {
490
- requireEqual("searchSpan", "trace_id", result.trace_id, expectedTraceId);
491
- requireEqual("searchSpan", "span_id", result.span_id, expectedSpanId);
492
- return {
493
- trace_id: expectedTraceId,
494
- span_id: expectedSpanId,
495
- ...boundSearchHits("searchSpan", result, maxMatches, budgets, (hit) => {
496
- requireEqual("searchSpan", "hit.trace_id", hit.trace_id, expectedTraceId);
497
- requireEqual("searchSpan", "hit.span_id", hit.span_id, expectedSpanId);
498
- })
499
- };
500
- }
501
- function boundSearchHits(operation, result, maxMatches, budgets, validateHit) {
502
- if (result.hits.length > maxMatches) throw contractError(operation, `store returned ${result.hits.length} hits for max_matches ${maxMatches}`);
503
- if (result.has_more && result.hits.length === 0) throw contractError(operation, "store reported more matches without returning any progress");
504
- const hits = [];
505
- for (const raw of result.hits) {
506
- validateHit(raw);
507
- const hit = truncateMatchRecord(raw, budgets.perMatchTextBudget);
508
- if (encodedBytes(operation, {
509
- hits: [...hits, hit],
510
- has_more: true
511
- }) > budgets.perCallByteCeiling) break;
512
- hits.push(hit);
513
- }
514
- if (result.hits.length > 0 && hits.length === 0) throw responseItemTooLarge(operation, {
515
- hits: [truncateMatchRecord(result.hits[0], budgets.perMatchTextBudget)],
516
- has_more: true
517
- }, budgets.perCallByteCeiling);
518
- return withinByteCeiling(operation, {
519
- hits,
520
- has_more: result.has_more || hits.length < result.hits.length
521
- }, budgets.perCallByteCeiling);
522
- }
523
- function checkedAccountingIds(label, ids, requested) {
524
- const seen = /* @__PURE__ */ new Set();
525
- for (const id of ids) {
526
- if (!requested.has(id)) throw contractError("viewSpans", `${label} contains unrequested id ${JSON.stringify(id)}`);
527
- if (seen.has(id)) throw contractError("viewSpans", `${label} contains duplicate id ${JSON.stringify(id)}`);
528
- seen.add(id);
529
- }
530
- return [...ids];
531
- }
532
- function truncateMatchRecord(record, cap) {
533
- return {
534
- ...record,
535
- span_name: truncateForBudget(record.span_name, cap),
536
- attribute_path: truncateForBudget(record.attribute_path, cap),
537
- matched_text: truncateForBudget(record.matched_text, cap),
538
- context_before: truncateForBudget(record.context_before, cap),
539
- context_after: truncateForBudget(record.context_after, cap)
540
- };
541
- }
542
- function truncateSpanAttributes(operation, span, cap) {
543
- const attributes = {};
544
- let truncations = 0;
545
- for (const [key, value] of Object.entries(span.attributes)) {
546
- if (typeof value === "string") {
547
- const truncated = truncateForBudget(value, cap);
548
- if (truncated !== value) truncations += 1;
549
- attributes[key] = truncated;
550
- continue;
551
- }
552
- if (value !== null && typeof value === "object") {
553
- let json;
554
- try {
555
- json = JSON.stringify(value);
556
- } catch (cause) {
557
- throw new TraceAnalysisStoreContractError(operation, `span attribute ${JSON.stringify(key)} is not JSON-serializable`, { cause });
558
- }
559
- const truncated = truncateForBudget(json, cap);
560
- if (truncated !== json) {
561
- truncations += 1;
562
- attributes[key] = truncated;
563
- } else attributes[key] = value;
564
- continue;
565
- }
566
- attributes[key] = value;
567
- }
568
- return {
569
- span: {
570
- ...span,
571
- attributes
572
- },
573
- truncations
574
- };
575
- }
576
- function oversizedFromSpans(spans) {
577
- const names = /* @__PURE__ */ new Map();
578
- let maxBytes = 0;
579
- let errors = 0;
580
- for (const span of spans) {
581
- names.set(span.name, (names.get(span.name) ?? 0) + 1);
582
- maxBytes = Math.max(maxBytes, encodedBytes("viewTrace", span));
583
- if (span.status === "ERROR") errors += 1;
584
- }
585
- return {
586
- span_count: spans.length,
587
- top_span_names: [...names.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 20),
588
- span_response_bytes_max: maxBytes,
589
- error_span_count: errors
590
- };
591
- }
592
- function compileSearchRegex(pattern) {
593
- if (typeof pattern !== "string" || pattern.length === 0) throw new TraceAnalysisValidationError("regex_pattern must be a non-empty string");
594
- let source = pattern;
595
- let flags = RE2JS.MULTILINE;
596
- if (source.startsWith("(?i)")) {
597
- source = source.slice(4);
598
- flags |= RE2JS.CASE_INSENSITIVE;
599
- }
600
- try {
601
- return RE2JS.compile(source, flags);
602
- } catch (cause) {
603
- throw new TraceAnalysisValidationError(`regex_pattern is invalid: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
604
- }
605
- }
606
- function truncateForBudget(value, byteCap) {
607
- validateInteger(byteCap, "byteCap", TRACE_ANALYSIS_LIMITS.minimumTextBudget);
608
- const original = Buffer.byteLength(value, "utf8");
609
- if (original <= byteCap) return value;
610
- const marker = `\n[trace-analyst truncated: original ${original} bytes]`;
611
- const contentCap = byteCap - Buffer.byteLength(marker, "utf8");
612
- let cut = Math.max(0, Math.floor(value.length * contentCap / original));
613
- while (cut > 0 && Buffer.byteLength(value.slice(0, cut), "utf8") > contentCap) cut -= 1;
614
- return `${value.slice(0, cut)}${marker}`;
615
- }
616
- function validateInteger(value, label, minimum, maximum = Number.MAX_SAFE_INTEGER) {
617
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum || value > maximum) throw new TraceAnalysisValidationError(`${label} must be an integer ${minimum}..${maximum}, got ${String(value)}`);
618
- return value;
619
- }
620
- function requireEqual(operation, label, actual, expected) {
621
- if (actual !== expected) throw contractError(operation, `${label} ${JSON.stringify(actual)} does not match ${JSON.stringify(expected)}`);
622
- }
623
- function encodedBytes(operation, value) {
624
- try {
625
- const encoded = JSON.stringify(value);
626
- if (encoded === void 0) throw new TypeError("JSON.stringify returned undefined");
627
- return Buffer.byteLength(encoded, "utf8");
628
- } catch (cause) {
629
- if (cause instanceof TraceAnalysisStoreContractError) throw cause;
630
- throw new TraceAnalysisStoreContractError(operation, "store result is not JSON-serializable", { cause });
631
- }
632
- }
633
- function withinByteCeiling(operation, value, ceiling) {
634
- const actual = encodedBytes(operation, value);
635
- if (actual > ceiling) throw new TraceAnalysisLimitError(operation, actual, ceiling, `${operation} metadata requires ${actual} bytes, over the ${ceiling}-byte response limit`);
636
- return value;
637
- }
638
- function responseItemTooLarge(operation, value, ceiling) {
639
- return new TraceAnalysisLimitError(operation, encodedBytes(operation, value), ceiling, `${operation} cannot fit one result item in the ${ceiling}-byte response limit`);
640
- }
641
- function contractError(operation, message) {
642
- return new TraceAnalysisStoreContractError(operation, message);
643
- }
644
- //#endregion
645
- //#region src/trace-analyst/store-schemas.ts
646
- const identifier = z.string().min(1).max(TRACE_ANALYSIS_LIMITS.identifierCharacters);
647
- const timestamp = z.iso.datetime({ offset: true });
648
- const nonNegativeInteger = z.number().int().nonnegative();
649
- const nonNegativeNumber = z.number().nonnegative();
650
- const nullableString = z.string().nullable();
651
- const nullableIdentifier = identifier.nullable();
652
- const stringArray = z.array(z.string());
653
- const filterValues = z.array(identifier).max(TRACE_ANALYSIS_LIMITS.filterValues);
654
- const traceFiltersSchema = z.object({
655
- has_errors: z.boolean().optional(),
656
- service_names: filterValues.optional(),
657
- agent_names: filterValues.optional(),
658
- model_names: filterValues.optional(),
659
- tool_names: filterValues.optional(),
660
- start_time_after: timestamp.optional(),
661
- start_time_before: timestamp.optional(),
662
- regex_pattern: z.string().min(1).max(TRACE_ANALYSIS_LIMITS.regexCharacters).optional()
663
- }).strict();
664
- const byteCap = z.number().int().min(TRACE_ANALYSIS_LIMITS.minimumTextBudget);
665
- const searchPattern = z.string().min(1).max(TRACE_ANALYSIS_LIMITS.regexCharacters);
666
- const traceStoreInputSchemas = {
667
- hasTrace: z.object({ trace_id: identifier }).strict(),
668
- hasSpans: z.object({
669
- trace_id: identifier,
670
- span_ids: z.array(identifier).min(1).max(TRACE_ANALYSIS_LIMITS.viewSpans)
671
- }).strict(),
672
- getOverview: z.object({ filters: traceFiltersSchema.optional() }).strict(),
673
- queryTraces: z.object({
674
- filters: traceFiltersSchema.optional(),
675
- limit: z.number().int().min(1).max(TRACE_ANALYSIS_LIMITS.queryTraces),
676
- offset: z.number().int().nonnegative().optional()
677
- }).strict(),
678
- countTraces: z.object({ filters: traceFiltersSchema.optional() }).strict(),
679
- viewTrace: z.object({
680
- trace_id: identifier,
681
- per_attribute_byte_cap: byteCap.optional()
682
- }).strict(),
683
- viewSpans: z.object({
684
- trace_id: identifier,
685
- span_ids: z.array(identifier).min(1).max(TRACE_ANALYSIS_LIMITS.viewSpans),
686
- per_attribute_byte_cap: byteCap.optional()
687
- }).strict(),
688
- searchTrace: z.object({
689
- trace_id: identifier,
690
- regex_pattern: searchPattern,
691
- max_matches: z.number().int().min(1).max(TRACE_ANALYSIS_LIMITS.searchMatches).default(50)
692
- }).strict(),
693
- searchSpan: z.object({
694
- trace_id: identifier,
695
- span_id: identifier,
696
- regex_pattern: searchPattern,
697
- max_matches: z.number().int().min(1).max(TRACE_ANALYSIS_LIMITS.searchMatches).default(50)
698
- }).strict()
699
- };
700
- const spanKind = z.enum([
701
- "AGENT",
702
- "LLM",
703
- "TOOL",
704
- "CHAIN",
705
- "EVALUATOR",
706
- "GUARDRAIL",
707
- "SPAN",
708
- "UNKNOWN"
709
- ]);
710
- const spanStatus = z.enum([
711
- "OK",
712
- "ERROR",
713
- "UNSET"
714
- ]);
715
- const traceSpan = z.object({
716
- trace_id: identifier,
717
- span_id: identifier,
718
- parent_span_id: nullableIdentifier,
719
- name: z.string(),
720
- kind: spanKind,
721
- start_time: timestamp,
722
- end_time: timestamp,
723
- duration_ms: nonNegativeNumber,
724
- status: spanStatus,
725
- status_message: z.string().optional(),
726
- service_name: nullableString,
727
- agent_name: nullableString,
728
- model_name: nullableString,
729
- tool_name: nullableString,
730
- attributes: z.record(z.string(), z.json())
731
- }).strict();
732
- const traceSummary = z.object({
733
- trace_id: identifier,
734
- service_name: nullableString,
735
- agent_name: nullableString,
736
- span_count: nonNegativeInteger,
737
- has_errors: z.boolean(),
738
- start_time: timestamp,
739
- end_time: timestamp,
740
- duration_ms: nonNegativeNumber,
741
- raw_jsonl_bytes: nonNegativeInteger,
742
- models: stringArray,
743
- tools: stringArray
744
- }).strict();
745
- const errorCluster = z.object({
746
- signature: z.string(),
747
- status_message_sample: z.string(),
748
- span_name: nullableString,
749
- tool_name: nullableString,
750
- trace_count: nonNegativeInteger,
751
- span_count: nonNegativeInteger,
752
- prevalence: z.number().min(0).max(1),
753
- exemplar_trace_ids: z.array(identifier),
754
- exemplar_span_ids: z.array(identifier)
755
- }).strict();
756
- const overview = z.object({
757
- total_traces: nonNegativeInteger,
758
- raw_jsonl_bytes: nonNegativeInteger,
759
- services: stringArray,
760
- agents: stringArray,
761
- models: stringArray,
762
- tool_names: stringArray,
763
- sample_trace_ids: z.array(identifier).max(TRACE_ANALYSIS_LIMITS.sampleTraceIds),
764
- errors: z.object({
765
- trace_count: nonNegativeInteger,
766
- span_count: nonNegativeInteger
767
- }).strict(),
768
- error_clusters: z.array(errorCluster),
769
- time_range: z.object({
770
- earliest: timestamp,
771
- latest: timestamp
772
- }).strict().nullable()
773
- }).strict();
774
- const tracePage = z.object({
775
- traces: z.array(traceSummary),
776
- total: nonNegativeInteger,
777
- has_more: z.boolean()
778
- }).strict();
779
- const oversizedTrace = z.object({
780
- span_count: nonNegativeInteger,
781
- top_span_names: z.array(z.tuple([z.string(), nonNegativeInteger])).max(20),
782
- span_response_bytes_max: nonNegativeInteger,
783
- error_span_count: nonNegativeInteger
784
- }).strict();
785
- const traceView = z.object({
786
- trace_id: identifier,
787
- spans: z.array(traceSpan).optional(),
788
- oversized: oversizedTrace.optional()
789
- }).strict().refine((value) => value.spans === void 0 !== (value.oversized === void 0), { message: "exactly one of spans or oversized is required" });
790
- const spansView = z.object({
791
- trace_id: identifier,
792
- spans: z.array(traceSpan),
793
- missing_span_ids: z.array(identifier),
794
- omitted_span_ids: z.array(identifier),
795
- has_more: z.boolean(),
796
- truncated_attribute_count: nonNegativeInteger
797
- }).strict();
798
- const matchRecord = z.object({
799
- trace_id: identifier,
800
- span_id: identifier,
801
- span_name: z.string(),
802
- span_kind: spanKind,
803
- attribute_path: z.string(),
804
- matched_text: z.string(),
805
- context_before: z.string(),
806
- context_after: z.string(),
807
- match_offset: nonNegativeInteger
808
- }).strict();
809
- const traceSearch = z.object({
810
- trace_id: identifier,
811
- hits: z.array(matchRecord),
812
- has_more: z.boolean()
813
- }).strict();
814
- const spanSearch = traceSearch.extend({ span_id: identifier }).strict();
815
- const traceStoreOutputSchemas = {
816
- hasTrace: z.boolean(),
817
- hasSpans: z.array(identifier).max(TRACE_ANALYSIS_LIMITS.viewSpans),
818
- getOverview: overview,
819
- queryTraces: tracePage,
820
- countTraces: nonNegativeInteger,
821
- viewTrace: traceView,
822
- viewSpans: spansView,
823
- searchTrace: traceSearch,
824
- searchSpan: spanSearch
825
- };
826
- function parseTraceInput(operation, schema, value) {
827
- try {
828
- return schema.parse(value);
829
- } catch (cause) {
830
- throw new TraceAnalysisValidationError(`${operation}: invalid arguments: ${cause instanceof z.ZodError ? z.prettifyError(cause) : String(cause)}`, { cause });
831
- }
832
- }
833
- function parseStoreOutput(operation, schema, value) {
834
- try {
835
- return schema.parse(value);
836
- } catch (cause) {
837
- throw new TraceAnalysisStoreContractError(operation, `invalid store result: ${cause instanceof z.ZodError ? z.prettifyError(cause) : String(cause)}`, { cause });
838
- }
839
- }
840
- function toTraceJsonSchema(schema) {
841
- return z.toJSONSchema(schema, { target: "draft-7" });
842
- }
843
- //#endregion
844
- //#region src/trace-analyst/store-boundary.ts
845
- /** Apply the public validation, cancellation, not-found, and size rules to any adapter. */
846
- function createBoundedTraceAnalysisStore(source, options = {}) {
847
- const budgets = resolveTraceBudgets(options.budgets);
848
- return {
849
- async hasTrace(traceId, context) {
850
- throwIfAborted(context);
851
- const { trace_id } = parseTraceInput("hasTrace", traceStoreInputSchemas.hasTrace, { trace_id: traceId });
852
- const result = await source.hasTrace(trace_id, context);
853
- throwIfAborted(context);
854
- return parseStoreOutput("hasTrace", traceStoreOutputSchemas.hasTrace, result);
855
- },
856
- async hasSpans(input, context) {
857
- throwIfAborted(context);
858
- const parsed = parseTraceInput("hasSpans", traceStoreInputSchemas.hasSpans, input);
859
- assertUniqueIds(parsed.span_ids, "hasSpans.span_ids");
860
- const result = await source.hasSpans(parsed, context);
861
- throwIfAborted(context);
862
- return validateExistingSpanIds(parseStoreOutput("hasSpans", traceStoreOutputSchemas.hasSpans, result), parsed.span_ids);
863
- },
864
- async getOverview(filters, context) {
865
- throwIfAborted(context);
866
- const input = parseTraceInput("getOverview", traceStoreInputSchemas.getOverview, { filters });
867
- const result = await source.getOverview(input.filters, context);
868
- throwIfAborted(context);
869
- return boundOverview(parseStoreOutput("getOverview", traceStoreOutputSchemas.getOverview, result), budgets.perCallByteCeiling);
870
- },
871
- async queryTraces(input, context) {
872
- throwIfAborted(context);
873
- const parsed = parseTraceInput("queryTraces", traceStoreInputSchemas.queryTraces, input);
874
- const offset = parsed.offset ?? 0;
875
- const result = await source.queryTraces({
876
- ...parsed,
877
- offset
878
- }, context);
879
- throwIfAborted(context);
880
- return boundTracePage(parseStoreOutput("queryTraces", traceStoreOutputSchemas.queryTraces, result), {
881
- limit: parsed.limit,
882
- offset
883
- }, budgets.perCallByteCeiling);
884
- },
885
- async countTraces(filters, context) {
886
- throwIfAborted(context);
887
- const input = parseTraceInput("countTraces", traceStoreInputSchemas.countTraces, { filters });
888
- const result = await source.countTraces(input.filters, context);
889
- throwIfAborted(context);
890
- return parseStoreOutput("countTraces", traceStoreOutputSchemas.countTraces, result);
891
- },
892
- async viewTrace(input, context) {
893
- throwIfAborted(context);
894
- const parsed = parseTraceInput("viewTrace", traceStoreInputSchemas.viewTrace, input);
895
- await requireTrace(source, parsed.trace_id, context);
896
- const perAttributeCap = parsed.per_attribute_byte_cap ?? budgets.perAttributeViewBudget;
897
- const result = await source.viewTrace({
898
- ...parsed,
899
- per_attribute_byte_cap: perAttributeCap
900
- }, context);
901
- throwIfAborted(context);
902
- return boundTraceView(parseStoreOutput("viewTrace", traceStoreOutputSchemas.viewTrace, result), parsed.trace_id, perAttributeCap, budgets.perCallByteCeiling);
903
- },
904
- async viewSpans(input, context) {
905
- throwIfAborted(context);
906
- const parsed = parseTraceInput("viewSpans", traceStoreInputSchemas.viewSpans, input);
907
- assertUniqueIds(parsed.span_ids, "viewSpans.span_ids");
908
- await requireTrace(source, parsed.trace_id, context);
909
- const existingSpanIds = new Set(validateExistingSpanIds(parseStoreOutput("hasSpans", traceStoreOutputSchemas.hasSpans, await source.hasSpans({
910
- trace_id: parsed.trace_id,
911
- span_ids: parsed.span_ids
912
- }, context)), parsed.span_ids));
913
- throwIfAborted(context);
914
- const perAttributeCap = parsed.per_attribute_byte_cap ?? budgets.perAttributeSpanBudget;
915
- const result = await source.viewSpans({
916
- ...parsed,
917
- per_attribute_byte_cap: perAttributeCap
918
- }, context);
919
- throwIfAborted(context);
920
- return boundSpansView(parseStoreOutput("viewSpans", traceStoreOutputSchemas.viewSpans, result), parsed.trace_id, parsed.span_ids, existingSpanIds, perAttributeCap, budgets.perCallByteCeiling);
921
- },
922
- async searchTrace(input, context) {
923
- throwIfAborted(context);
924
- const parsed = parseTraceInput("searchTrace", traceStoreInputSchemas.searchTrace, input);
925
- compileSearchRegex(parsed.regex_pattern);
926
- await requireTrace(source, parsed.trace_id, context);
927
- const result = await source.searchTrace(parsed, context);
928
- throwIfAborted(context);
929
- return boundTraceSearch(parseStoreOutput("searchTrace", traceStoreOutputSchemas.searchTrace, result), parsed.trace_id, parsed.max_matches, budgets);
930
- },
931
- async searchSpan(input, context) {
932
- throwIfAborted(context);
933
- const parsed = parseTraceInput("searchSpan", traceStoreInputSchemas.searchSpan, input);
934
- compileSearchRegex(parsed.regex_pattern);
935
- await requireTrace(source, parsed.trace_id, context);
936
- await requireSpan(source, parsed.trace_id, parsed.span_id, context);
937
- const result = await source.searchSpan(parsed, context);
938
- throwIfAborted(context);
939
- return boundSpanSearch(parseStoreOutput("searchSpan", traceStoreOutputSchemas.searchSpan, result), parsed.trace_id, parsed.span_id, parsed.max_matches, budgets);
940
- }
941
- };
942
- }
943
- async function requireTrace(source, traceId, context) {
944
- throwIfAborted(context);
945
- const exists = await source.hasTrace(traceId, context);
946
- throwIfAborted(context);
947
- if (!parseStoreOutput("hasTrace", traceStoreOutputSchemas.hasTrace, exists)) throw new TraceNotFoundError(traceId);
948
- }
949
- async function requireSpan(source, traceId, spanId, context) {
950
- throwIfAborted(context);
951
- const existing = await source.hasSpans({
952
- trace_id: traceId,
953
- span_ids: [spanId]
954
- }, context);
955
- throwIfAborted(context);
956
- if (validateExistingSpanIds(parseStoreOutput("hasSpans", traceStoreOutputSchemas.hasSpans, existing), [spanId]).length === 0) throw new SpanNotFoundError(traceId, spanId);
957
- }
958
- function validateExistingSpanIds(found, requested) {
959
- const requestedSet = new Set(requested);
960
- const seen = /* @__PURE__ */ new Set();
961
- for (const id of found) {
962
- if (!requestedSet.has(id)) throw new TraceAnalysisStoreContractError("hasSpans", `hasSpans returned unrequested span id ${JSON.stringify(id)}`);
963
- if (seen.has(id)) throw new TraceAnalysisStoreContractError("hasSpans", `hasSpans returned duplicate span id ${JSON.stringify(id)}`);
964
- seen.add(id);
965
- }
966
- return [...found];
967
- }
968
- function assertUniqueIds(ids, label) {
969
- if (new Set(ids).size !== ids.length) throw new TraceAnalysisValidationError(`${label} must not contain duplicates`);
970
- }
971
- function throwIfAborted(context) {
972
- context?.signal?.throwIfAborted();
973
- }
974
- //#endregion
975
- //#region src/trace-analyst/store-otlp.ts
976
- /**
977
- * `OtlpFileTraceStore` — read-only OTLP-JSONL trace store for the
978
- * trace-analyst.
979
- *
980
- * Wire shape. Each line of the input file is one OTLP-shaped span. The
981
- * store understands flattened OTLP JSONL plus the OpenInference vocab.
982
- * We project upstream's full
983
- * span shape down to `TraceAnalystSpan` lazily — full materialisation
984
- * only happens for the spans the agent actually requests.
985
- *
986
- * Indexing. On first read the store builds an in-memory index keyed
987
- * by `trace_id` carrying:
988
- * - byte offsets + lengths for each span line (for surgical reads
989
- * without re-parsing the whole file)
990
- * - a `TraceAnalystTraceSummary` rollup
991
- * - sets of services / agents / models / tools / has_errors
992
- * - byte size of the trace's JSONL slab
993
- *
994
- * Memory bound. The index keeps span metadata only — names, kinds,
995
- * offsets, status. Attribute payloads stay on disk until requested.
996
- * For a 50MB JSONL with 50k spans, the index is ~5MB.
997
- *
998
- * Concurrency. The store builds the index once on first read and
999
- * caches it. Subsequent reads reuse the index. The file is opened on
1000
- * each read; we never hold a long-lived FD.
1001
- */
1002
- /** Lines indexed between event-loop yields. Bounded synchronous work per
1003
- * tick keeps the index build from starving other tasks on large files
1004
- * while staying coarse enough that the yields are cheap. */
1005
- const INDEX_YIELD_LINES = 5e3;
1006
- const SCAN_YIELD_ITEMS = 500;
1007
- /** Hand control back to the event loop without busy-waiting. */
1008
- function yieldToEventLoop() {
1009
- return new Promise((resolve) => setImmediate(resolve));
1010
- }
1011
- async function scanCheckpoint(signal, item) {
1012
- signal?.throwIfAborted();
1013
- if (item > 0 && item % SCAN_YIELD_ITEMS === 0) {
1014
- await yieldToEventLoop();
1015
- signal?.throwIfAborted();
1016
- }
1017
- }
1018
- /** Default ceiling for {@link OtlpFileTraceStoreOptions.maxFileBytes}. */
1019
- const DEFAULT_MAX_TRACE_FILE_BYTES = 256 * 1024 * 1024;
1020
- var BufferedOtlpTraceStore = class {
1021
- perAttributeViewBudget;
1022
- perAttributeSpanBudget;
1023
- perCallByteCeiling;
1024
- perMatchTextBudget;
1025
- indexValue;
1026
- indexTask;
1027
- bufferValue;
1028
- bufferTask;
1029
- constructor(opts) {
1030
- this.perAttributeViewBudget = validateInteger(opts.perAttributeViewBudget ?? DEFAULT_TRACE_ANALYST_BUDGETS.perAttributeViewBudget, "perAttributeViewBudget", TRACE_ANALYSIS_LIMITS.minimumTextBudget);
1031
- this.perAttributeSpanBudget = validateInteger(opts.perAttributeSpanBudget ?? DEFAULT_TRACE_ANALYST_BUDGETS.perAttributeSpanBudget, "perAttributeSpanBudget", TRACE_ANALYSIS_LIMITS.minimumTextBudget);
1032
- this.perCallByteCeiling = validateInteger(opts.perCallByteCeiling ?? DEFAULT_TRACE_ANALYST_BUDGETS.perCallByteCeiling, "perCallByteCeiling", 1);
1033
- this.perMatchTextBudget = validateInteger(opts.perMatchTextBudget ?? DEFAULT_TRACE_ANALYST_BUDGETS.perMatchTextBudget, "perMatchTextBudget", TRACE_ANALYSIS_LIMITS.minimumTextBudget);
1034
- }
1035
- async hasTrace(trace_id, context) {
1036
- context?.signal?.throwIfAborted();
1037
- const idx = await this.index(context);
1038
- context?.signal?.throwIfAborted();
1039
- return idx.byTrace.has(trace_id);
1040
- }
1041
- async hasSpans(opts, context) {
1042
- context?.signal?.throwIfAborted();
1043
- const trace = (await this.index(context)).byTrace.get(opts.trace_id);
1044
- if (!trace) return [];
1045
- const requested = new Set(opts.span_ids);
1046
- const found = [];
1047
- for (let index = 0; index < trace.spans.length; index += 1) {
1048
- await scanCheckpoint(context?.signal, index);
1049
- const spanId = trace.spans[index].span_id;
1050
- if (requested.has(spanId)) found.push(spanId);
1051
- }
1052
- return found;
1053
- }
1054
- async getOverview(filters, context) {
1055
- const idx = await this.index(context);
1056
- const matched = await this.matchedTraces(idx, filters, context);
1057
- const services = /* @__PURE__ */ new Set();
1058
- const agents = /* @__PURE__ */ new Set();
1059
- const models = /* @__PURE__ */ new Set();
1060
- const tools = /* @__PURE__ */ new Set();
1061
- let rawBytes = 0;
1062
- let earliest = null;
1063
- let latest = null;
1064
- let errorTraceCount = 0;
1065
- let errorSpanCount = 0;
1066
- const clusters = /* @__PURE__ */ new Map();
1067
- let traceIndex = 0;
1068
- for (const t of matched) {
1069
- await scanCheckpoint(context?.signal, traceIndex++);
1070
- if (t.service_name) services.add(t.service_name);
1071
- if (t.agent_name) agents.add(t.agent_name);
1072
- for (const m of t.models) models.add(m);
1073
- for (const tn of t.tools) tools.add(tn);
1074
- rawBytes += t.raw_jsonl_bytes;
1075
- if (!earliest || compareSpanTime(t.start_time, earliest) < 0) earliest = t.start_time;
1076
- if (!latest || compareSpanTime(t.end_time, latest) > 0) latest = t.end_time;
1077
- if (t.has_errors) {
1078
- errorTraceCount += 1;
1079
- let spanIndex = 0;
1080
- for (const s of t.spans) {
1081
- await scanCheckpoint(context?.signal, spanIndex++);
1082
- if (s.status !== "ERROR") continue;
1083
- errorSpanCount += 1;
1084
- accumulateErrorCluster(clusters, t.trace_id, s);
1085
- }
1086
- }
1087
- }
1088
- const sample_trace_ids = matched.slice(0, 20).map((t) => t.trace_id);
1089
- return {
1090
- total_traces: matched.length,
1091
- raw_jsonl_bytes: rawBytes,
1092
- services: [...services].sort(),
1093
- agents: [...agents].sort(),
1094
- models: [...models].sort(),
1095
- tool_names: [...tools].sort(),
1096
- sample_trace_ids,
1097
- errors: {
1098
- trace_count: errorTraceCount,
1099
- span_count: errorSpanCount
1100
- },
1101
- error_clusters: finalizeErrorClusters(clusters, errorTraceCount),
1102
- time_range: earliest && latest ? {
1103
- earliest,
1104
- latest
1105
- } : null
1106
- };
1107
- }
1108
- async queryTraces(opts, context) {
1109
- const limit = validateInteger(opts.limit, "queryTraces.limit", 1, TRACE_ANALYSIS_LIMITS.queryTraces);
1110
- const offset = validateInteger(opts.offset ?? 0, "queryTraces.offset", 0);
1111
- const idx = await this.index(context);
1112
- const matched = await this.matchedTraces(idx, opts.filters, context);
1113
- const slice = matched.slice(offset, offset + limit);
1114
- return {
1115
- traces: slice.map((t) => this.toSummary(t)),
1116
- total: matched.length,
1117
- has_more: offset + slice.length < matched.length
1118
- };
1119
- }
1120
- async countTraces(filters, context) {
1121
- const idx = await this.index(context);
1122
- return (await this.matchedTraces(idx, filters, context)).length;
1123
- }
1124
- async viewTrace(opts, context) {
1125
- context?.signal?.throwIfAborted();
1126
- const trace = (await this.index(context)).byTrace.get(opts.trace_id);
1127
- if (!trace) throw new TraceNotFoundError(opts.trace_id);
1128
- const cap = validateInteger(opts.per_attribute_byte_cap ?? this.perAttributeViewBudget, "viewTrace.per_attribute_byte_cap", 1);
1129
- const buf = await this.buffer(context);
1130
- const spans = [];
1131
- let runningBytes = 0;
1132
- let span_response_bytes_max = 0;
1133
- const counter = { value: 0 };
1134
- let spanIndex = 0;
1135
- for (const s of trace.spans) {
1136
- await scanCheckpoint(context?.signal, spanIndex++);
1137
- const projected = this.projectSpan(buf, trace.trace_id, s, cap, counter);
1138
- const bytes = Buffer.byteLength(JSON.stringify(projected), "utf8");
1139
- span_response_bytes_max = Math.max(span_response_bytes_max, bytes);
1140
- runningBytes += bytes;
1141
- if (runningBytes > this.perCallByteCeiling) return {
1142
- trace_id: trace.trace_id,
1143
- oversized: this.buildOversizedSummary(trace, span_response_bytes_max)
1144
- };
1145
- spans.push(projected);
1146
- }
1147
- return {
1148
- trace_id: trace.trace_id,
1149
- spans
1150
- };
1151
- }
1152
- async viewSpans(opts, context) {
1153
- context?.signal?.throwIfAborted();
1154
- const trace = (await this.index(context)).byTrace.get(opts.trace_id);
1155
- if (!trace) throw new TraceNotFoundError(opts.trace_id);
1156
- if (opts.span_ids.length < 1 || opts.span_ids.length > TRACE_ANALYSIS_LIMITS.viewSpans) throw new TraceAnalysisValidationError(`viewSpans.span_ids must contain 1..${TRACE_ANALYSIS_LIMITS.viewSpans} ids, got ${opts.span_ids.length}`);
1157
- const cap = validateInteger(opts.per_attribute_byte_cap ?? this.perAttributeSpanBudget, "viewSpans.per_attribute_byte_cap", 1);
1158
- const requested = [...new Set(opts.span_ids)];
1159
- const wantSet = new Set(requested);
1160
- const foundById = /* @__PURE__ */ new Map();
1161
- for (let index = 0; index < trace.spans.length; index += 1) {
1162
- await scanCheckpoint(context?.signal, index);
1163
- const span = trace.spans[index];
1164
- if (wantSet.has(span.span_id)) foundById.set(span.span_id, span);
1165
- }
1166
- const missing = requested.filter((id) => !foundById.has(id));
1167
- const buf = await this.buffer(context);
1168
- const spans = [];
1169
- let truncatedAttributeCount = 0;
1170
- const omitted = new Set(requested.filter((id) => foundById.has(id)));
1171
- const buildResult = () => ({
1172
- trace_id: trace.trace_id,
1173
- spans,
1174
- missing_span_ids: missing,
1175
- omitted_span_ids: requested.filter((id) => omitted.has(id)),
1176
- has_more: omitted.size > 0,
1177
- truncated_attribute_count: truncatedAttributeCount
1178
- });
1179
- const metadataBytes = Buffer.byteLength(JSON.stringify(buildResult()), "utf8");
1180
- if (metadataBytes > this.perCallByteCeiling) throw new TraceAnalysisLimitError("viewSpans", metadataBytes, this.perCallByteCeiling, `viewSpans accounting requires ${metadataBytes} bytes, over the ${this.perCallByteCeiling}-byte response limit`);
1181
- let spanIndex = 0;
1182
- let smallestRejectedBytes = Number.POSITIVE_INFINITY;
1183
- for (const id of requested) {
1184
- await scanCheckpoint(context?.signal, spanIndex++);
1185
- const s = foundById.get(id);
1186
- if (!s) continue;
1187
- const counter = { value: 0 };
1188
- const projected = this.projectSpan(buf, trace.trace_id, s, cap, counter);
1189
- spans.push(projected);
1190
- omitted.delete(id);
1191
- truncatedAttributeCount += counter.value;
1192
- const responseBytes = Buffer.byteLength(JSON.stringify(buildResult()), "utf8");
1193
- if (responseBytes <= this.perCallByteCeiling) continue;
1194
- smallestRejectedBytes = Math.min(smallestRejectedBytes, responseBytes);
1195
- if (requested.length === 1) throw new TraceAnalysisLimitError("viewSpans", responseBytes, this.perCallByteCeiling, `viewSpans cannot fit span ${JSON.stringify(id)} in the ${this.perCallByteCeiling}-byte response limit`);
1196
- spans.pop();
1197
- omitted.add(id);
1198
- truncatedAttributeCount -= counter.value;
1199
- }
1200
- if (foundById.size > 0 && spans.length === 0) throw new TraceAnalysisLimitError("viewSpans", smallestRejectedBytes, this.perCallByteCeiling, `viewSpans cannot fit one requested span in the ${this.perCallByteCeiling}-byte response limit`);
1201
- return buildResult();
1202
- }
1203
- async searchTrace(opts, context) {
1204
- const max_matches = validateInteger(opts.max_matches ?? 50, "searchTrace.max_matches", 1, TRACE_ANALYSIS_LIMITS.searchMatches);
1205
- const trace = (await this.index(context)).byTrace.get(opts.trace_id);
1206
- if (!trace) throw new TraceNotFoundError(opts.trace_id);
1207
- const re = compileSearchRegex(opts.regex_pattern);
1208
- const buf = await this.buffer(context);
1209
- const hits = [];
1210
- let hasMore = false;
1211
- let spanIndex = 0;
1212
- for (const s of trace.spans) {
1213
- await scanCheckpoint(context?.signal, spanIndex++);
1214
- const remaining = max_matches - hits.length;
1215
- const localHits = await this.scanSpanForMatches(buf, trace.trace_id, s, re, this.perMatchTextBudget, remaining, context);
1216
- for (const h of localHits.records) {
1217
- if (hits.length >= max_matches) break;
1218
- hits.push(h);
1219
- }
1220
- if (localHits.hasMore) {
1221
- hasMore = true;
1222
- break;
1223
- }
1224
- }
1225
- return {
1226
- trace_id: trace.trace_id,
1227
- hits,
1228
- has_more: hasMore
1229
- };
1230
- }
1231
- async searchSpan(opts, context) {
1232
- const max_matches = validateInteger(opts.max_matches ?? 50, "searchSpan.max_matches", 1, TRACE_ANALYSIS_LIMITS.searchMatches);
1233
- const trace = (await this.index(context)).byTrace.get(opts.trace_id);
1234
- if (!trace) throw new TraceNotFoundError(opts.trace_id);
1235
- let span;
1236
- for (let index = 0; index < trace.spans.length; index += 1) {
1237
- await scanCheckpoint(context?.signal, index);
1238
- const candidate = trace.spans[index];
1239
- if (candidate.span_id === opts.span_id) {
1240
- span = candidate;
1241
- break;
1242
- }
1243
- }
1244
- if (!span) throw new SpanNotFoundError(opts.trace_id, opts.span_id);
1245
- const re = compileSearchRegex(opts.regex_pattern);
1246
- const buf = await this.buffer(context);
1247
- const localHits = await this.scanSpanForMatches(buf, trace.trace_id, span, re, this.perMatchTextBudget, max_matches, context);
1248
- return {
1249
- trace_id: trace.trace_id,
1250
- span_id: span.span_id,
1251
- hits: localHits.records,
1252
- has_more: localHits.hasMore
1253
- };
1254
- }
1255
- /** Force the index to materialise. Useful to amortise startup cost
1256
- * before the first agent call. */
1257
- async ensureIndexed(context) {
1258
- await this.index(context);
1259
- }
1260
- async buffer(context) {
1261
- context?.signal?.throwIfAborted();
1262
- if (this.bufferValue) return this.bufferValue;
1263
- if (!this.bufferTask) {
1264
- const task = createSharedAbortableTask((signal) => this.readBuffer(signal));
1265
- this.bufferTask = task;
1266
- task.promise.then((value) => {
1267
- this.bufferValue = value;
1268
- if (this.bufferTask === task) this.bufferTask = void 0;
1269
- }, () => {
1270
- if (this.bufferTask === task) this.bufferTask = void 0;
1271
- });
1272
- }
1273
- return waitForSharedTask(this.bufferTask, context?.signal);
1274
- }
1275
- async index(context) {
1276
- context?.signal?.throwIfAborted();
1277
- if (this.indexValue) return this.indexValue;
1278
- if (!this.indexTask) {
1279
- const task = createSharedAbortableTask((signal) => this.buildIndex(signal));
1280
- this.indexTask = task;
1281
- task.promise.then((value) => {
1282
- this.indexValue = value;
1283
- if (this.indexTask === task) this.indexTask = void 0;
1284
- }, () => {
1285
- if (this.indexTask === task) this.indexTask = void 0;
1286
- });
1287
- }
1288
- return waitForSharedTask(this.indexTask, context?.signal);
1289
- }
1290
- async buildIndex(signal) {
1291
- const buf = await this.buffer({ signal });
1292
- signal?.throwIfAborted();
1293
- const byTrace = /* @__PURE__ */ new Map();
1294
- let cursor = 0;
1295
- let lineNumber = 0;
1296
- let sinceYield = 0;
1297
- while (cursor < buf.length) {
1298
- lineNumber += 1;
1299
- if (++sinceYield >= INDEX_YIELD_LINES) {
1300
- sinceYield = 0;
1301
- await yieldToEventLoop();
1302
- signal?.throwIfAborted();
1303
- }
1304
- const newlineIndex = buf.indexOf(10, cursor);
1305
- const lineEnd = newlineIndex === -1 ? buf.length : newlineIndex;
1306
- const lineLength = lineEnd - cursor;
1307
- if (lineLength === 0) {
1308
- cursor = lineEnd + 1;
1309
- continue;
1310
- }
1311
- const lineSlice = buf.subarray(cursor, lineEnd).toString("utf8");
1312
- const lineOffset = cursor;
1313
- cursor = lineEnd + 1;
1314
- let parsed;
1315
- try {
1316
- parsed = JSON.parse(lineSlice);
1317
- } catch (cause) {
1318
- throw new TraceFileMalformedError(this.sourcePath(), lineNumber, lineOffset, cause);
1319
- }
1320
- if (!parsed || typeof parsed !== "object") throw new TraceFileMalformedError(this.sourcePath(), lineNumber, lineOffset);
1321
- const span = projectOtlpFlatLine(parsed);
1322
- if (!span) throw new TraceFileMalformedError(this.sourcePath(), lineNumber, lineOffset);
1323
- let entry = byTrace.get(span.trace_id);
1324
- if (!entry) {
1325
- entry = {
1326
- trace_id: span.trace_id,
1327
- service_name: span.service_name,
1328
- agent_name: span.agent_name,
1329
- span_count: 0,
1330
- has_errors: false,
1331
- start_time: span.start_time,
1332
- end_time: span.end_time,
1333
- duration_ms: 0,
1334
- raw_jsonl_bytes: 0,
1335
- models: /* @__PURE__ */ new Set(),
1336
- tools: /* @__PURE__ */ new Set(),
1337
- spans: []
1338
- };
1339
- byTrace.set(span.trace_id, entry);
1340
- } else {
1341
- if (!entry.service_name && span.service_name) entry.service_name = span.service_name;
1342
- if (!entry.agent_name && span.agent_name) entry.agent_name = span.agent_name;
1343
- }
1344
- const indexEntry = {
1345
- span_id: span.span_id,
1346
- parent_span_id: span.parent_span_id,
1347
- name: span.name,
1348
- kind: span.kind,
1349
- start_time: span.start_time,
1350
- end_time: span.end_time,
1351
- duration_ms: span.duration_ms,
1352
- status: span.status,
1353
- status_message: span.status_message,
1354
- service_name: span.service_name,
1355
- agent_name: span.agent_name,
1356
- model_name: span.model_name,
1357
- tool_name: span.tool_name,
1358
- line_byte_offset: lineOffset,
1359
- line_byte_length: lineLength
1360
- };
1361
- entry.spans.push(indexEntry);
1362
- entry.span_count += 1;
1363
- entry.raw_jsonl_bytes += lineLength + 1;
1364
- if (span.status === "ERROR") entry.has_errors = true;
1365
- if (compareSpanTime(span.start_time, entry.start_time) < 0) entry.start_time = span.start_time;
1366
- if (compareSpanTime(span.end_time, entry.end_time) > 0) entry.end_time = span.end_time;
1367
- if (span.model_name) entry.models.add(span.model_name);
1368
- if (span.tool_name) entry.tools.add(span.tool_name);
1369
- }
1370
- let totalRawBytes = 0;
1371
- for (const t of byTrace.values()) {
1372
- signal?.throwIfAborted();
1373
- totalRawBytes += t.raw_jsonl_bytes;
1374
- t.spans.sort((a, b) => compareSpanTime(a.start_time, b.start_time) || a.line_byte_offset - b.line_byte_offset);
1375
- const startMs = spanEpochMillis(t.start_time);
1376
- const endMs = spanEpochMillis(t.end_time);
1377
- t.duration_ms = startMs === null || endMs === null ? 0 : Math.max(0, endMs - startMs);
1378
- }
1379
- const sortedTraceIds = [...byTrace.keys()].sort();
1380
- signal?.throwIfAborted();
1381
- return {
1382
- byTrace,
1383
- totalRawBytes,
1384
- sortedTraceIds
1385
- };
1386
- }
1387
- async matchedTraces(idx, filters, context) {
1388
- context?.signal?.throwIfAborted();
1389
- const traces = [];
1390
- for (let index = 0; index < idx.sortedTraceIds.length; index += 1) {
1391
- await scanCheckpoint(context?.signal, index);
1392
- const trace = idx.byTrace.get(idx.sortedTraceIds[index]);
1393
- if (trace) traces.push(trace);
1394
- }
1395
- if (!filters) return traces;
1396
- const indexedFiltered = [];
1397
- for (let index = 0; index < traces.length; index += 1) {
1398
- await scanCheckpoint(context?.signal, index);
1399
- const t = traces[index];
1400
- if (filters.has_errors !== void 0 && t.has_errors !== filters.has_errors) continue;
1401
- if (filters.service_names && filters.service_names.length > 0) {
1402
- if (!t.service_name || !filters.service_names.includes(t.service_name)) continue;
1403
- }
1404
- if (filters.agent_names && filters.agent_names.length > 0) {
1405
- if (!t.agent_name || !filters.agent_names.includes(t.agent_name)) continue;
1406
- }
1407
- if (filters.model_names && filters.model_names.length > 0) {
1408
- if (![...t.models].some((m) => filters.model_names.includes(m))) continue;
1409
- }
1410
- if (filters.tool_names && filters.tool_names.length > 0) {
1411
- if (![...t.tools].some((tn) => filters.tool_names.includes(tn))) continue;
1412
- }
1413
- if (filters.start_time_after && t.start_time < filters.start_time_after) continue;
1414
- if (filters.start_time_before && t.start_time > filters.start_time_before) continue;
1415
- indexedFiltered.push(t);
1416
- }
1417
- if (!filters.regex_pattern) return indexedFiltered;
1418
- const re = compileSearchRegex(filters.regex_pattern);
1419
- const buf = await this.buffer(context);
1420
- const out = [];
1421
- let traceIndex = 0;
1422
- for (const t of indexedFiltered) {
1423
- await scanCheckpoint(context?.signal, traceIndex++);
1424
- let matched = false;
1425
- let spanIndex = 0;
1426
- for (const s of t.spans) {
1427
- await scanCheckpoint(context?.signal, spanIndex++);
1428
- const slice = buf.subarray(s.line_byte_offset, s.line_byte_offset + s.line_byte_length);
1429
- if (re.test(slice.toString("utf8"))) {
1430
- matched = true;
1431
- break;
1432
- }
1433
- }
1434
- if (matched) out.push(t);
1435
- }
1436
- return out;
1437
- }
1438
- toSummary(t) {
1439
- return {
1440
- trace_id: t.trace_id,
1441
- service_name: t.service_name,
1442
- agent_name: t.agent_name,
1443
- span_count: t.span_count,
1444
- has_errors: t.has_errors,
1445
- start_time: t.start_time,
1446
- end_time: t.end_time,
1447
- duration_ms: t.duration_ms,
1448
- raw_jsonl_bytes: t.raw_jsonl_bytes,
1449
- models: [...t.models].sort(),
1450
- tools: [...t.tools].sort()
1451
- };
1452
- }
1453
- projectSpan(buf, trace_id, s, perAttrCap, counter) {
1454
- const slice = buf.subarray(s.line_byte_offset, s.line_byte_offset + s.line_byte_length).toString("utf8");
1455
- let raw = {};
1456
- try {
1457
- const parsed = JSON.parse(slice);
1458
- if (parsed && typeof parsed === "object") raw = parsed;
1459
- } catch {}
1460
- const attrs = extractOtlpAttributes(raw);
1461
- const projected = {};
1462
- for (const [k, v] of Object.entries(attrs)) if (typeof v === "string") {
1463
- const trunc = truncateForBudget(v, perAttrCap);
1464
- if (trunc !== v) counter.value += 1;
1465
- projected[k] = trunc;
1466
- } else if (Array.isArray(v) || v && typeof v === "object") {
1467
- const json = JSON.stringify(v);
1468
- const trunc = truncateForBudget(json, perAttrCap);
1469
- if (trunc !== json) {
1470
- counter.value += 1;
1471
- projected[k] = trunc;
1472
- } else projected[k] = v;
1473
- } else projected[k] = v;
1474
- return {
1475
- trace_id,
1476
- span_id: s.span_id,
1477
- parent_span_id: s.parent_span_id,
1478
- name: s.name,
1479
- kind: s.kind,
1480
- start_time: s.start_time,
1481
- end_time: s.end_time,
1482
- duration_ms: s.duration_ms,
1483
- status: s.status,
1484
- status_message: s.status_message,
1485
- service_name: s.service_name,
1486
- agent_name: s.agent_name,
1487
- model_name: s.model_name,
1488
- tool_name: s.tool_name,
1489
- attributes: projected
1490
- };
1491
- }
1492
- buildOversizedSummary(t, span_response_bytes_max) {
1493
- const counts = /* @__PURE__ */ new Map();
1494
- let errorCount = 0;
1495
- for (const s of t.spans) {
1496
- counts.set(s.name, (counts.get(s.name) ?? 0) + 1);
1497
- if (s.status === "ERROR") errorCount += 1;
1498
- }
1499
- const top = [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, 20);
1500
- return {
1501
- span_count: t.span_count,
1502
- top_span_names: top,
1503
- span_response_bytes_max,
1504
- error_span_count: errorCount
1505
- };
1506
- }
1507
- async scanSpanForMatches(buf, trace_id, s, re, textBudget, recordCap, context) {
1508
- const slice = buf.subarray(s.line_byte_offset, s.line_byte_offset + s.line_byte_length).toString("utf8");
1509
- const records = [];
1510
- let hasMore = false;
1511
- let matchIndex = 0;
1512
- for (const match of re.matchAll(slice)) {
1513
- await scanCheckpoint(context?.signal, matchIndex++);
1514
- if (records.length >= recordCap) {
1515
- hasMore = true;
1516
- break;
1517
- }
1518
- const offset = match.index ?? 0;
1519
- const before = slice.slice(Math.max(0, offset - textBudget / 2), offset);
1520
- const after = slice.slice(offset + match[0].length, offset + match[0].length + Math.floor(textBudget / 2));
1521
- records.push({
1522
- trace_id,
1523
- span_id: s.span_id,
1524
- span_name: s.name,
1525
- span_kind: s.kind,
1526
- attribute_path: bestAttributePathForOffset(slice, offset) ?? "span.raw",
1527
- matched_text: truncateForBudget(match[0], textBudget),
1528
- context_before: truncateForBudget(before, textBudget),
1529
- context_after: truncateForBudget(after, textBudget),
1530
- match_offset: offset
1531
- });
1532
- }
1533
- return {
1534
- records,
1535
- hasMore
1536
- };
1537
- }
1538
- };
1539
- var OtlpFileTraceStore = class extends BufferedOtlpTraceStore {
1540
- path;
1541
- maxFileBytes;
1542
- constructor(opts) {
1543
- super(opts);
1544
- this.path = opts.path;
1545
- this.maxFileBytes = validateInteger(opts.maxFileBytes ?? 268435456, "maxFileBytes", 1);
1546
- }
1547
- /** Stat-then-read so an oversized file fails loud before allocating the
1548
- * source buffer. Missing files remain distinct from malformed traces. */
1549
- async readBuffer(signal) {
1550
- signal?.throwIfAborted();
1551
- let stats;
1552
- try {
1553
- stats = await stat(this.path);
1554
- } catch (err) {
1555
- if (err?.code === "ENOENT") throw new TraceFileMissingError(this.path);
1556
- throw err;
1557
- }
1558
- if (stats.size > this.maxFileBytes) throw new TraceFileTooLargeError(this.path, stats.size, this.maxFileBytes);
1559
- signal?.throwIfAborted();
1560
- return readFile(this.path, { signal });
1561
- }
1562
- sourcePath() {
1563
- return this.path;
1564
- }
1565
- };
1566
- var OtlpBufferTraceStore = class extends BufferedOtlpTraceStore {
1567
- source;
1568
- constructor(source, opts) {
1569
- super(opts);
1570
- this.source = source;
1571
- }
1572
- async readBuffer(signal) {
1573
- signal?.throwIfAborted();
1574
- return this.source;
1575
- }
1576
- sourcePath() {
1577
- return "<memory>";
1578
- }
1579
- };
1580
- /** Build the bounded trace store directly from OpenInference JSONL text. */
1581
- function otlpTextToTraceAnalysisStore(text, opts = {}) {
1582
- if (!text.trim()) throw new CaptureIntegrityError("OTLP trace text must not be empty");
1583
- return new OtlpBufferTraceStore(Buffer.from(text, "utf8"), opts);
1584
- }
1585
- function createOtlpBufferTraceStore(source, options = {}) {
1586
- return new OtlpBufferTraceStore(source, options);
1587
- }
1588
- /** A `"` at `idx` is a real JSON delimiter only when the run of `\`
1589
- * immediately preceding it is even-length; an odd run means the quote
1590
- * is escaped (`\"`) and is part of a string value, not a boundary. */
1591
- function isUnescapedQuote(slice, idx) {
1592
- if (slice[idx] !== "\"") return false;
1593
- let backslashes = 0;
1594
- let b = idx - 1;
1595
- while (b >= 0 && slice[b] === "\\") {
1596
- backslashes += 1;
1597
- b -= 1;
1598
- }
1599
- return backslashes % 2 === 0;
1600
- }
1601
- /** Scan backwards from `from` (inclusive) for the nearest UNescaped `"`.
1602
- * Returns its index, or -1 when none is found. */
1603
- function prevUnescapedQuote(slice, from) {
1604
- for (let i = from; i >= 0; i -= 1) if (slice[i] === "\"" && isUnescapedQuote(slice, i)) return i;
1605
- return -1;
1606
- }
1607
- /**
1608
- * Best-effort: locate the JSON path for the substring at `offset` in
1609
- * a single span's JSONL slice. The slice is '...,"key":"value..."' — we
1610
- * walk back from `offset` to the value-opening quote, past the `:`, to
1611
- * the key's closing then opening quote, skipping `\"`-escaped quotes that
1612
- * live inside string values. Returns `null` when the offset doesn't fall
1613
- * inside a recognisable string field.
1614
- */
1615
- function bestAttributePathForOffset(slice, offset) {
1616
- const valueQuote = prevUnescapedQuote(slice, Math.min(offset, slice.length - 1));
1617
- if (valueQuote < 1) return null;
1618
- let j = valueQuote - 1;
1619
- while (j >= 0 && slice[j] !== ":") j -= 1;
1620
- if (j < 1) return null;
1621
- const keyClose = prevUnescapedQuote(slice, j - 1);
1622
- if (keyClose < 1) return null;
1623
- const keyOpen = prevUnescapedQuote(slice, keyClose - 1);
1624
- if (keyOpen < 0) return null;
1625
- return slice.slice(keyOpen + 1, keyClose);
1626
- }
1627
- const ERROR_CLUSTER_EXEMPLARS = 5;
1628
- /** Collapse volatile tokens so semantically identical failures share a key:
1629
- * hex/uuid ids → <id>, numbers → #, quoted/abs paths → <path>, durations →
1630
- * <dur>, whitespace collapsed. Empty/absent messages fall back to the span
1631
- * name so a no-message error still forms a real cluster. */
1632
- function normalizeErrorSignature(message, spanName) {
1633
- const raw = (message ?? "").trim();
1634
- return (raw.length > 0 ? raw : `(${spanName || "error"} — no message)`).replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, "<id>").replace(/\b[0-9a-f]{12,}\b/gi, "<id>").replace(/(?:\/[\w.\-@]+){2,}/g, "<path>").replace(/\b\d+(?:\.\d+)?(ms|s|m|h|kb|mb|gb)?\b/gi, (_m, u) => u ? `#${u}` : "#").replace(/\s+/g, " ").trim();
1635
- }
1636
- function bump(map, key) {
1637
- if (!key) return;
1638
- map.set(key, (map.get(key) ?? 0) + 1);
1639
- }
1640
- function topKey(map) {
1641
- let best = null;
1642
- let bestN = 0;
1643
- for (const [k, n] of map) if (n > bestN) {
1644
- best = k;
1645
- bestN = n;
1646
- }
1647
- return best;
1648
- }
1649
- function accumulateErrorCluster(clusters, traceId, span) {
1650
- const signature = normalizeErrorSignature(span.status_message, span.name);
1651
- let acc = clusters.get(signature);
1652
- if (!acc) {
1653
- acc = {
1654
- signature,
1655
- sample: span.status_message ?? span.name ?? "",
1656
- traceIds: /* @__PURE__ */ new Set(),
1657
- spanIds: [],
1658
- spanCount: 0,
1659
- spanNames: /* @__PURE__ */ new Map(),
1660
- toolNames: /* @__PURE__ */ new Map()
1661
- };
1662
- clusters.set(signature, acc);
1663
- }
1664
- acc.traceIds.add(traceId);
1665
- acc.spanCount += 1;
1666
- if (acc.spanIds.length < ERROR_CLUSTER_EXEMPLARS && !acc.spanIds.includes(span.span_id)) acc.spanIds.push(span.span_id);
1667
- bump(acc.spanNames, span.name);
1668
- bump(acc.toolNames, span.tool_name);
1669
- }
1670
- function finalizeErrorClusters(clusters, errorTraceCount) {
1671
- const out = [...clusters.values()].map((acc) => ({
1672
- signature: acc.signature,
1673
- status_message_sample: acc.sample,
1674
- span_name: topKey(acc.spanNames),
1675
- tool_name: topKey(acc.toolNames),
1676
- trace_count: acc.traceIds.size,
1677
- span_count: acc.spanCount,
1678
- prevalence: errorTraceCount > 0 ? acc.traceIds.size / errorTraceCount : 0,
1679
- exemplar_trace_ids: [...acc.traceIds].slice(0, ERROR_CLUSTER_EXEMPLARS),
1680
- exemplar_span_ids: acc.spanIds.slice(0, ERROR_CLUSTER_EXEMPLARS)
1681
- }));
1682
- out.sort((a, b) => b.trace_count - a.trace_count || b.span_count - a.span_count);
1683
- return out;
1684
- }
1685
- //#endregion
1686
- export { classifyOtlpSpanRole as A, firstStringAttr as C, spanEpochMillis as D, readOtlpStatus as E, traceSpanKindToOpenInferenceKind as M, stringField as O, extractOtlpAttributes as S, projectOtlpFlatLine as T, TraceFileMissingError as _, createBoundedTraceAnalysisStore as a, asString as b, traceStoreInputSchemas as c, TRACE_ANALYSIS_LIMITS as d, SpanNotFoundError as f, TraceFileMalformedError as g, TraceAnalysisValidationError as h, otlpTextToTraceAnalysisStore as i, isOtlpModelCall as j, applyToolSpanOtlpAttributes as k, DEFAULT_TRACE_ANALYST_BUDGETS as l, TraceAnalysisStoreContractError as m, OtlpFileTraceStore as n, parseTraceInput as o, TraceAnalysisLimitError as p, createOtlpBufferTraceStore as r, toTraceJsonSchema as s, DEFAULT_MAX_TRACE_FILE_BYTES as t, TRACE_ANALYST_TRUNCATION_MARKER_PREFIX as u, TraceFileTooLargeError as v, inferOtlpKind as w, compareSpanTime as x, TraceNotFoundError as y };
1687
-
1688
- //# sourceMappingURL=store-otlp-BenKynPE.js.map