@tangle-network/agent-eval 0.30.0 → 0.31.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.
- package/dist/{baseline-BwdCXUS8.d.ts → baseline-4R5deP0N.d.ts} +1 -1
- package/dist/benchmarks/index.d.ts +3 -3
- package/dist/builder-eval/index.d.ts +3 -3
- package/dist/builder-eval/index.js +2 -2
- package/dist/{chunk-R5UQJNKC.js → chunk-4L3WJXQJ.js} +2 -2
- package/dist/{chunk-RUI6SIHY.js → chunk-75ZREHD7.js} +4 -4
- package/dist/{chunk-5AKPEK5L.js → chunk-CXJOVDJR.js} +2 -2
- package/dist/{chunk-K33INZHH.js → chunk-GVQT44CS.js} +2 -2
- package/dist/{chunk-UW4NOOZI.js → chunk-HIO4UIS5.js} +308 -2
- package/dist/chunk-HIO4UIS5.js.map +1 -0
- package/dist/{chunk-4S4BM3QQ.js → chunk-M6RZ5LJN.js} +2 -2
- package/dist/{chunk-NG236HPC.js → chunk-QYJT52YW.js} +1 -1
- package/dist/chunk-QYJT52YW.js.map +1 -0
- package/dist/{chunk-XFZCM5Z3.js → chunk-SMSGXM74.js} +2 -2
- package/dist/{chunk-KTGTIOFD.js → chunk-UBPIXOC4.js} +2 -2
- package/dist/{chunk-DBIGN5MJ.js → chunk-WGXZAQLR.js} +3 -3
- package/dist/{chunk-NLMNWKVM.js → chunk-WSI4K3WB.js} +2 -2
- package/dist/{chunk-PALJO75S.js → chunk-XEL6UP7C.js} +2 -2
- package/dist/{chunk-SZSBQUIJ.js → chunk-Y2CPBYKH.js} +3 -3
- package/dist/{chunk-QHF6EQKK.js → chunk-YTMXBHFM.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/{control-rJhEDdpy.d.ts → control-BFpqHFV2.d.ts} +5 -5
- package/dist/{control-runtime-BRdQ0wrx.d.ts → control-runtime-BZ_lVLYW.d.ts} +2 -2
- package/dist/control.d.ts +8 -8
- package/dist/control.js +3 -3
- package/dist/{dataset-CiK_3LDr.d.ts → dataset-ueRVTUoY.d.ts} +1 -1
- package/dist/{emitter-BqjeOvJh.d.ts → emitter-DP_cSSiw.d.ts} +1 -1
- package/dist/{errors-BZ9sTdz7.d.ts → errors-mje_cKOs.d.ts} +1 -1
- package/dist/{failure-cluster-D1NZKqYu.d.ts → failure-cluster-Cw65_5FY.d.ts} +1 -1
- package/dist/{feedback-trajectory-j0nJFgC6.d.ts → feedback-trajectory-iATEAHmc.d.ts} +2 -2
- package/dist/governance/index.d.ts +4 -4
- package/dist/{index-Cgt3DKXr.d.ts → index-DPILdKbP.d.ts} +2 -2
- package/dist/{index--fVrWDiR.d.ts → index-TVjRYWRm.d.ts} +1 -1
- package/dist/index.d.ts +108 -38
- package/dist/index.js +159 -14
- package/dist/index.js.map +1 -1
- package/dist/{integrity-BAxLGJ9I.d.ts → integrity-DYR5gWlb.d.ts} +2 -2
- package/dist/knowledge/index.d.ts +3 -3
- package/dist/meta-eval/index.d.ts +4 -4
- package/dist/openapi.json +1 -1
- package/dist/optimization.d.ts +11 -11
- package/dist/optimization.js +8 -8
- package/dist/pipelines/index.d.ts +6 -6
- package/dist/pipelines/index.js +3 -3
- package/dist/prm/index.d.ts +4 -4
- package/dist/{query-BFDT0kX_.d.ts → query-DODUYdPg.d.ts} +1 -1
- package/dist/{release-report-PWhGlpfO.d.ts → release-report-C8r4Vben.d.ts} +3 -3
- package/dist/reporting.d.ts +8 -8
- package/dist/reporting.js +4 -4
- package/dist/{researcher-ClDX3KZx.d.ts → researcher-BmgJ_901.d.ts} +6 -6
- package/dist/rl.d.ts +10 -10
- package/dist/rl.js +6 -6
- package/dist/{rubric-DgSqjqqj.d.ts → rubric-D5tjHNJQ.d.ts} +2 -2
- package/dist/{rubric-predictive-validity-C0uDYwG6.d.ts → rubric-predictive-validity-Bm-CbN46.d.ts} +1 -1
- package/dist/{run-record-CqzahIbx.d.ts → run-record-nYf9x2hU.d.ts} +1 -1
- package/dist/{store-BP5be6s7.d.ts → store-Db2Bv8Cf.d.ts} +1 -1
- package/dist/{summary-report-jrSGb2xZ.d.ts → summary-report-dir7A-eQ.d.ts} +2 -2
- package/dist/{test-graded-scenario-BJ54PDan.d.ts → test-graded-scenario-B2kWEdh9.d.ts} +2 -2
- package/dist/traces.d.ts +533 -10
- package/dist/traces.js +14 -300
- package/dist/traces.js.map +1 -1
- package/dist/{trajectory-BFmveYZt.d.ts → trajectory-CnoBo-JY.d.ts} +1 -1
- package/dist/wire/index.d.ts +6 -6
- package/dist/wire/index.js +3 -3
- package/package.json +12 -21
- package/dist/chunk-NG236HPC.js.map +0 -1
- package/dist/chunk-UW4NOOZI.js.map +0 -1
- package/dist/replay-BX5Fm8en.d.ts +0 -529
- /package/dist/{chunk-R5UQJNKC.js.map → chunk-4L3WJXQJ.js.map} +0 -0
- /package/dist/{chunk-RUI6SIHY.js.map → chunk-75ZREHD7.js.map} +0 -0
- /package/dist/{chunk-5AKPEK5L.js.map → chunk-CXJOVDJR.js.map} +0 -0
- /package/dist/{chunk-K33INZHH.js.map → chunk-GVQT44CS.js.map} +0 -0
- /package/dist/{chunk-4S4BM3QQ.js.map → chunk-M6RZ5LJN.js.map} +0 -0
- /package/dist/{chunk-XFZCM5Z3.js.map → chunk-SMSGXM74.js.map} +0 -0
- /package/dist/{chunk-KTGTIOFD.js.map → chunk-UBPIXOC4.js.map} +0 -0
- /package/dist/{chunk-DBIGN5MJ.js.map → chunk-WGXZAQLR.js.map} +0 -0
- /package/dist/{chunk-NLMNWKVM.js.map → chunk-WSI4K3WB.js.map} +0 -0
- /package/dist/{chunk-PALJO75S.js.map → chunk-XEL6UP7C.js.map} +0 -0
- /package/dist/{chunk-SZSBQUIJ.js.map → chunk-Y2CPBYKH.js.map} +0 -0
- /package/dist/{chunk-QHF6EQKK.js.map → chunk-YTMXBHFM.js.map} +0 -0
package/dist/traces.d.ts
CHANGED
|
@@ -1,12 +1,416 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
export { A as Artifact, B as BudgetLedgerEntry, g as BudgetSpec,
|
|
8
|
-
|
|
9
|
-
import { AxFunction } from '@ax-llm/ax';
|
|
1
|
+
import { N as NotFoundError, R as ReplayError } from './errors-mje_cKOs.js';
|
|
2
|
+
import { R as RawProviderSink, f as RawProviderEvent } from './integrity-DYR5gWlb.js';
|
|
3
|
+
export { F as FileSystemRawProviderSink, c as FileSystemRawProviderSinkOptions, I as InMemoryRawProviderSink, d as InMemoryRawProviderSinkOptions, N as NoopRawProviderSink, P as ProviderRedactor, e as RawProviderDirection, g as RawProviderSinkFilter, h as RunIntegrityError, a as RunIntegrityExpectations, i as RunIntegrityIssue, j as RunIntegrityIssueCode, b as RunIntegrityReport, k as assertRunCaptured, l as defaultProviderRedactor, p as providerFromBaseUrl, t as throwIfRunIncomplete } from './integrity-DYR5gWlb.js';
|
|
4
|
+
import { a as RunCompleteHookContext, R as RunCompleteHook } from './emitter-DP_cSSiw.js';
|
|
5
|
+
export { S as SpanHandle, T as TraceEmitter, b as TraceEmitterOptions, l as llmSpanFromProvider } from './emitter-DP_cSSiw.js';
|
|
6
|
+
import { T as TraceStore } from './store-Db2Bv8Cf.js';
|
|
7
|
+
export { A as Artifact, B as BudgetLedgerEntry, g as BudgetSpec, i as EventFilter, E as EventKind, j as FAILURE_CLASSES, F as FailureClass, k as FileSystemTraceStore, l as FileSystemTraceStoreOptions, G as GenericSpan, I as InMemoryTraceStore, J as JudgeSpan, L as LlmSpan, M as Message, e as RetrievalSpan, R as Run, h as RunFilter, m as RunLayer, c as RunOutcome, n as RunStatus, f as SandboxSpan, S as Span, o as SpanBase, p as SpanFilter, d as SpanKind, q as SpanStatus, r as TRACE_SCHEMA_VERSION, a as ToolSpan, b as TraceEvent, s as isJudgeSpan, t as isLlmSpan, u as isRetrievalSpan, v as isSandboxSpan, w as isToolSpan } from './store-Db2Bv8Cf.js';
|
|
8
|
+
export { a as aggregateLlm, b as argHash, g as groupBy, j as judgeSpans, l as llmSpans, r as runFailureClass, c as runsForScenario, t as toolSpans } from './query-DODUYdPg.js';
|
|
9
|
+
import { AxAIService, AxFunction } from '@ax-llm/ax';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* OpenTelemetry JSON export — maps TraceSchema v1 to OTLP/JSON so
|
|
13
|
+
* traces render natively in Jaeger / Honeycomb / Langfuse / Grafana.
|
|
14
|
+
*
|
|
15
|
+
* Wire format only. We do NOT depend on the @opentelemetry SDK — that
|
|
16
|
+
* would drag in polyfills incompatible with Workers/Edge. Consumers
|
|
17
|
+
* push the JSON to their collector of choice via HTTP.
|
|
18
|
+
*
|
|
19
|
+
* Reference: OTLP 1.3.2 (ResourceSpans / ScopeSpans / Span).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare const OTEL_AGENT_EVAL_SCOPE: {
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
};
|
|
26
|
+
interface OtlpSpan {
|
|
27
|
+
traceId: string;
|
|
28
|
+
spanId: string;
|
|
29
|
+
parentSpanId?: string;
|
|
30
|
+
name: string;
|
|
31
|
+
kind: number;
|
|
32
|
+
startTimeUnixNano: string;
|
|
33
|
+
endTimeUnixNano: string;
|
|
34
|
+
attributes: Array<{
|
|
35
|
+
key: string;
|
|
36
|
+
value: {
|
|
37
|
+
stringValue?: string;
|
|
38
|
+
intValue?: string;
|
|
39
|
+
doubleValue?: number;
|
|
40
|
+
boolValue?: boolean;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
events?: Array<{
|
|
44
|
+
timeUnixNano: string;
|
|
45
|
+
name: string;
|
|
46
|
+
attributes?: OtlpSpan['attributes'];
|
|
47
|
+
}>;
|
|
48
|
+
status?: {
|
|
49
|
+
code: number;
|
|
50
|
+
message?: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
interface OtlpResourceSpans {
|
|
54
|
+
resource: {
|
|
55
|
+
attributes: OtlpSpan['attributes'];
|
|
56
|
+
};
|
|
57
|
+
scopeSpans: Array<{
|
|
58
|
+
scope: typeof OTEL_AGENT_EVAL_SCOPE;
|
|
59
|
+
spans: OtlpSpan[];
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
interface OtlpExport {
|
|
63
|
+
resourceSpans: OtlpResourceSpans[];
|
|
64
|
+
}
|
|
65
|
+
/** Export a single run's spans + events in OTLP/JSON. */
|
|
66
|
+
declare function exportRunAsOtlp(store: TraceStore, runId: string, resourceAttrs?: Record<string, string | number | boolean>): Promise<OtlpExport>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Redaction — remove PII / secrets from trace payloads before persist.
|
|
70
|
+
*
|
|
71
|
+
* Pre-persistence rules mean raw traces in storage are already scrubbed.
|
|
72
|
+
* Unredacted variants (for debugging / post-mortems) live in a separate
|
|
73
|
+
* storage layer with stricter access controls; this module only covers
|
|
74
|
+
* the default scrub-then-persist path.
|
|
75
|
+
*
|
|
76
|
+
* Rules compose: pass an array of `RedactionRule`, each is applied in
|
|
77
|
+
* order. Strings that match get replaced with a tagged sentinel so the
|
|
78
|
+
* eval framework can count how many redactions happened per run
|
|
79
|
+
* (surfaced via `redaction_applied` events).
|
|
80
|
+
*/
|
|
81
|
+
interface RedactionRule {
|
|
82
|
+
id: string;
|
|
83
|
+
pattern: RegExp;
|
|
84
|
+
/** Replacement — e.g. '[PII:email]'. Defaults to `[redacted:{id}]`. */
|
|
85
|
+
replacement?: string;
|
|
86
|
+
}
|
|
87
|
+
interface RedactionReport {
|
|
88
|
+
redactionCount: number;
|
|
89
|
+
byRule: Record<string, number>;
|
|
90
|
+
}
|
|
91
|
+
/** OWASP / common-sense defaults — extend per-domain. */
|
|
92
|
+
declare const DEFAULT_REDACTION_RULES: RedactionRule[];
|
|
93
|
+
declare const REDACTION_VERSION = "1.0.0";
|
|
94
|
+
/**
|
|
95
|
+
* Redact a single string. Returns the new string and a per-rule count of
|
|
96
|
+
* how many substitutions fired.
|
|
97
|
+
*/
|
|
98
|
+
declare function redactString(input: string, rules?: RedactionRule[]): {
|
|
99
|
+
output: string;
|
|
100
|
+
report: RedactionReport;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Walk a JSON-ish value applying `redactString` to every string leaf.
|
|
104
|
+
* Arrays and plain objects are recursed; other types pass through
|
|
105
|
+
* untouched. Circular references throw — traces should be tree-shaped.
|
|
106
|
+
*/
|
|
107
|
+
declare function redactValue(value: unknown, rules?: RedactionRule[], report?: RedactionReport): {
|
|
108
|
+
value: unknown;
|
|
109
|
+
report: RedactionReport;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Shared types for the trace-analyst module.
|
|
114
|
+
*
|
|
115
|
+
* Wire format. The store interface speaks `OtlpSpanLike` rows — one JSONL
|
|
116
|
+
* line per span, OTLP-shaped. We do NOT depend on a specific tracing
|
|
117
|
+
* vendor at the type level. Adapter
|
|
118
|
+
* layers map upstream shapes onto this interface.
|
|
119
|
+
*
|
|
120
|
+
* Design constraint. Every read operation that can return arbitrary
|
|
121
|
+
* payload must carry a byte budget so the agent's tool result stays
|
|
122
|
+
* bounded regardless of input trace size. Oversized responses
|
|
123
|
+
* substitute a deterministic summary instead of bytes — see
|
|
124
|
+
* `ViewTraceOversized`.
|
|
125
|
+
*/
|
|
126
|
+
/** OTLP span kind (subset we actually use). */
|
|
127
|
+
type TraceAnalystSpanKind = 'AGENT' | 'LLM' | 'TOOL' | 'CHAIN' | 'GUARDRAIL' | 'SPAN' | 'UNKNOWN';
|
|
128
|
+
type TraceAnalystSpanStatus = 'OK' | 'ERROR' | 'UNSET';
|
|
129
|
+
/** Subset of OTLP span fields the analyst exposes to the agent. The
|
|
130
|
+
* store's job is to project upstream's full span shape down to this
|
|
131
|
+
* view — the analyst never sees vendor extensions directly. */
|
|
132
|
+
interface TraceAnalystSpan {
|
|
133
|
+
trace_id: string;
|
|
134
|
+
span_id: string;
|
|
135
|
+
parent_span_id: string | null;
|
|
136
|
+
name: string;
|
|
137
|
+
kind: TraceAnalystSpanKind;
|
|
138
|
+
start_time: string;
|
|
139
|
+
end_time: string;
|
|
140
|
+
duration_ms: number;
|
|
141
|
+
status: TraceAnalystSpanStatus;
|
|
142
|
+
status_message?: string;
|
|
143
|
+
service_name: string | null;
|
|
144
|
+
agent_name: string | null;
|
|
145
|
+
model_name: string | null;
|
|
146
|
+
tool_name: string | null;
|
|
147
|
+
/** Raw JSON-serialisable attribute map. May contain large strings;
|
|
148
|
+
* callers must respect the per-attribute byte cap. */
|
|
149
|
+
attributes: Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
interface TraceAnalystTraceSummary {
|
|
152
|
+
trace_id: string;
|
|
153
|
+
service_name: string | null;
|
|
154
|
+
agent_name: string | null;
|
|
155
|
+
span_count: number;
|
|
156
|
+
has_errors: boolean;
|
|
157
|
+
start_time: string;
|
|
158
|
+
end_time: string;
|
|
159
|
+
duration_ms: number;
|
|
160
|
+
raw_jsonl_bytes: number;
|
|
161
|
+
models: string[];
|
|
162
|
+
tools: string[];
|
|
163
|
+
}
|
|
164
|
+
interface TraceAnalystFilters {
|
|
165
|
+
/** Restrict to traces that contain at least one error span. */
|
|
166
|
+
has_errors?: boolean;
|
|
167
|
+
/** Match if any span's `service.name` is in this list. */
|
|
168
|
+
service_names?: string[];
|
|
169
|
+
/** Match if any span's `agent.name` is in this list. */
|
|
170
|
+
agent_names?: string[];
|
|
171
|
+
/** Match if any LLM span's `llm.model_name` is in this list. */
|
|
172
|
+
model_names?: string[];
|
|
173
|
+
/** Match if any tool span's `tool.name` is in this list. */
|
|
174
|
+
tool_names?: string[];
|
|
175
|
+
/** ISO-8601 lower bound on the trace's earliest start time. */
|
|
176
|
+
start_time_after?: string;
|
|
177
|
+
/** ISO-8601 upper bound on the trace's earliest start time. */
|
|
178
|
+
start_time_before?: string;
|
|
179
|
+
/** Single regex applied to raw JSONL bytes for the trace. Opt-in;
|
|
180
|
+
* expensive on large datasets. Use the indexed filters above first. */
|
|
181
|
+
regex_pattern?: string;
|
|
182
|
+
}
|
|
183
|
+
interface DatasetOverview {
|
|
184
|
+
total_traces: number;
|
|
185
|
+
raw_jsonl_bytes: number;
|
|
186
|
+
services: string[];
|
|
187
|
+
agents: string[];
|
|
188
|
+
models: string[];
|
|
189
|
+
tool_names: string[];
|
|
190
|
+
/** Up to 20 real trace ids the agent may pass to view/search tools. */
|
|
191
|
+
sample_trace_ids: string[];
|
|
192
|
+
errors: {
|
|
193
|
+
trace_count: number;
|
|
194
|
+
span_count: number;
|
|
195
|
+
};
|
|
196
|
+
time_range: {
|
|
197
|
+
earliest: string;
|
|
198
|
+
latest: string;
|
|
199
|
+
} | null;
|
|
200
|
+
}
|
|
201
|
+
interface QueryTracesPage {
|
|
202
|
+
traces: TraceAnalystTraceSummary[];
|
|
203
|
+
total: number;
|
|
204
|
+
has_more: boolean;
|
|
205
|
+
}
|
|
206
|
+
/** Full-trace view. When the response would exceed the per-call byte
|
|
207
|
+
* budget, `oversized` is populated INSTEAD of `spans` so the agent
|
|
208
|
+
* knows to switch to `searchTrace` / `viewSpans`. */
|
|
209
|
+
interface ViewTraceResult {
|
|
210
|
+
trace_id: string;
|
|
211
|
+
spans?: TraceAnalystSpan[];
|
|
212
|
+
oversized?: ViewTraceOversized;
|
|
213
|
+
}
|
|
214
|
+
interface ViewTraceOversized {
|
|
215
|
+
span_count: number;
|
|
216
|
+
/** Names with their counts, sorted desc. Capped at 20 entries. */
|
|
217
|
+
top_span_names: Array<[string, number]>;
|
|
218
|
+
/** Largest single span body (bytes after attribute-cap projection). */
|
|
219
|
+
span_response_bytes_max: number;
|
|
220
|
+
error_span_count: number;
|
|
221
|
+
}
|
|
222
|
+
interface ViewSpansResult {
|
|
223
|
+
trace_id: string;
|
|
224
|
+
spans: TraceAnalystSpan[];
|
|
225
|
+
/** Number of requested span ids that were not found in the trace. */
|
|
226
|
+
missing_span_ids: string[];
|
|
227
|
+
/** Number of attribute fields truncated to fit the per-attribute cap. */
|
|
228
|
+
truncated_attribute_count: number;
|
|
229
|
+
}
|
|
230
|
+
interface SpanMatchRecord {
|
|
231
|
+
trace_id: string;
|
|
232
|
+
span_id: string;
|
|
233
|
+
span_name: string;
|
|
234
|
+
span_kind: TraceAnalystSpanKind;
|
|
235
|
+
/** JSON pointer-style path to the matched value, e.g.
|
|
236
|
+
* `attributes."llm.input_messages"[2].content`. */
|
|
237
|
+
attribute_path: string;
|
|
238
|
+
matched_text: string;
|
|
239
|
+
context_before: string;
|
|
240
|
+
context_after: string;
|
|
241
|
+
match_offset: number;
|
|
242
|
+
}
|
|
243
|
+
interface SearchTraceResult {
|
|
244
|
+
trace_id: string;
|
|
245
|
+
hits: SpanMatchRecord[];
|
|
246
|
+
total_matches: number;
|
|
247
|
+
has_more: boolean;
|
|
248
|
+
}
|
|
249
|
+
interface SearchSpanResult {
|
|
250
|
+
trace_id: string;
|
|
251
|
+
span_id: string;
|
|
252
|
+
hits: SpanMatchRecord[];
|
|
253
|
+
total_matches: number;
|
|
254
|
+
has_more: boolean;
|
|
255
|
+
}
|
|
256
|
+
/** Tunable byte budgets for bounded RLM tool output. */
|
|
257
|
+
interface TraceAnalystByteBudgets {
|
|
258
|
+
/** Max bytes any single tool response may emit. Hard ceiling enforced
|
|
259
|
+
* by the store; oversized → summary. Default 150_000. */
|
|
260
|
+
perCallByteCeiling: number;
|
|
261
|
+
/** Per-attribute string truncation cap on `viewTrace` (discovery scan).
|
|
262
|
+
* Default 4096. */
|
|
263
|
+
perAttributeViewBudget: number;
|
|
264
|
+
/** Per-attribute string truncation cap on `viewSpans` (surgical reads).
|
|
265
|
+
* Default 16384. */
|
|
266
|
+
perAttributeSpanBudget: number;
|
|
267
|
+
/** Per-attribute cap on a single match record's `matched_text` and
|
|
268
|
+
* context window. Default 1024. */
|
|
269
|
+
perMatchTextBudget: number;
|
|
270
|
+
}
|
|
271
|
+
declare const DEFAULT_TRACE_ANALYST_BUDGETS: TraceAnalystByteBudgets;
|
|
272
|
+
/** Marker substituted in place of truncated string payloads. Callers
|
|
273
|
+
* parsing tool output can detect it deterministically. */
|
|
274
|
+
declare const TRACE_ANALYST_TRUNCATION_MARKER_PREFIX = "[trace-analyst truncated:";
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* `TraceAnalysisStore` — read-side interface the trace-analyst calls
|
|
278
|
+
* through. Six operations, all bounded:
|
|
279
|
+
*
|
|
280
|
+
* - `getOverview(filters?)` — dataset rollup + sample trace ids.
|
|
281
|
+
* - `queryTraces(filters?, limit, offset)` — paginated summaries.
|
|
282
|
+
* - `countTraces(filters?)` — cheap count without materialisation.
|
|
283
|
+
* - `viewTrace(trace_id, perAttrCap)` — full span list, oversized → summary.
|
|
284
|
+
* - `viewSpans(trace_id, span_ids, perAttrCap)` — surgical span fetch.
|
|
285
|
+
* - `searchTrace(trace_id, regex, max_matches)` — bounded regex hits.
|
|
286
|
+
* - `searchSpan(trace_id, span_id, regex, max_matches)` — single-span search.
|
|
287
|
+
*
|
|
288
|
+
* Multiple implementations ship in the core (`OtlpFileTraceStore`).
|
|
289
|
+
* Downstream callers can supply their own — e.g. a DuckDB-backed
|
|
290
|
+
* adapter or an in-memory adapter for tests — by implementing this
|
|
291
|
+
* interface.
|
|
292
|
+
*
|
|
293
|
+
* Filters compose with AND semantics. Empty/undefined fields impose
|
|
294
|
+
* no constraint. `regex_pattern` is the only opt-in raw-bytes scan —
|
|
295
|
+
* implementations may skip it via `count`/`overview` when not set.
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
interface TraceAnalysisStore {
|
|
299
|
+
getOverview(filters?: TraceAnalystFilters): Promise<DatasetOverview>;
|
|
300
|
+
queryTraces(opts: {
|
|
301
|
+
filters?: TraceAnalystFilters;
|
|
302
|
+
limit: number;
|
|
303
|
+
offset?: number;
|
|
304
|
+
}): Promise<QueryTracesPage>;
|
|
305
|
+
countTraces(filters?: TraceAnalystFilters): Promise<number>;
|
|
306
|
+
viewTrace(opts: {
|
|
307
|
+
trace_id: string;
|
|
308
|
+
/** Override per-attribute byte cap. Defaults to discovery budget. */
|
|
309
|
+
per_attribute_byte_cap?: number;
|
|
310
|
+
}): Promise<ViewTraceResult>;
|
|
311
|
+
viewSpans(opts: {
|
|
312
|
+
trace_id: string;
|
|
313
|
+
span_ids: readonly string[];
|
|
314
|
+
/** Override per-attribute byte cap. Defaults to surgical budget. */
|
|
315
|
+
per_attribute_byte_cap?: number;
|
|
316
|
+
}): Promise<ViewSpansResult>;
|
|
317
|
+
searchTrace(opts: {
|
|
318
|
+
trace_id: string;
|
|
319
|
+
regex_pattern: string;
|
|
320
|
+
/** Hard cap on matches returned. Default 50. */
|
|
321
|
+
max_matches?: number;
|
|
322
|
+
}): Promise<SearchTraceResult>;
|
|
323
|
+
searchSpan(opts: {
|
|
324
|
+
trace_id: string;
|
|
325
|
+
span_id: string;
|
|
326
|
+
regex_pattern: string;
|
|
327
|
+
max_matches?: number;
|
|
328
|
+
}): Promise<SearchSpanResult>;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
interface AnalyzeTracesInput {
|
|
332
|
+
/** The user-facing question. Domain framing belongs here, not in the
|
|
333
|
+
* actor description. */
|
|
334
|
+
question: string;
|
|
335
|
+
}
|
|
336
|
+
interface AnalyzeTracesResult {
|
|
337
|
+
/** The responder's prose answer. */
|
|
338
|
+
answer: string;
|
|
339
|
+
/** Bulleted findings extracted from the responder's structured output. */
|
|
340
|
+
findings: string[];
|
|
341
|
+
/** Per-actor-turn snapshots captured via `actorTurnCallback`. */
|
|
342
|
+
turns: AnalyzeTracesTurnSnapshot[];
|
|
343
|
+
/** Total turns the actor took. */
|
|
344
|
+
turnCount: number;
|
|
345
|
+
/** Token usage by role. */
|
|
346
|
+
usage: TraceAnalystUsage;
|
|
347
|
+
/** Full system + assistant + tool message log by role. */
|
|
348
|
+
chatLog: TraceAnalystChatLog;
|
|
349
|
+
/** Prompt version that produced this run. */
|
|
350
|
+
actorPromptVersion: string;
|
|
351
|
+
}
|
|
352
|
+
interface TraceAnalystUsage {
|
|
353
|
+
actor: TraceAnalystUsageEntry[];
|
|
354
|
+
responder: TraceAnalystUsageEntry[];
|
|
355
|
+
}
|
|
356
|
+
interface TraceAnalystUsageEntry {
|
|
357
|
+
[key: string]: unknown;
|
|
358
|
+
}
|
|
359
|
+
interface TraceAnalystChatLog {
|
|
360
|
+
actor: TraceAnalystChatMessage[];
|
|
361
|
+
responder: TraceAnalystChatMessage[];
|
|
362
|
+
}
|
|
363
|
+
interface TraceAnalystChatMessage {
|
|
364
|
+
[key: string]: unknown;
|
|
365
|
+
}
|
|
366
|
+
interface AnalyzeTracesTurnSnapshot {
|
|
367
|
+
turn: number;
|
|
368
|
+
isError: boolean;
|
|
369
|
+
/** The JS code the actor produced for this turn. */
|
|
370
|
+
code: string;
|
|
371
|
+
/** The formatted action-log entry the actor sees on the next turn. */
|
|
372
|
+
output: string;
|
|
373
|
+
/** Provider thought (when `actorOptions.showThoughts` is true and the
|
|
374
|
+
* provider returns it). */
|
|
375
|
+
thought?: string;
|
|
376
|
+
}
|
|
377
|
+
interface AnalyzeTracesOptions {
|
|
378
|
+
/** Trace data source. Pass either an OTLP-JSONL path or a custom store. */
|
|
379
|
+
source: string | TraceAnalysisStore;
|
|
380
|
+
/** Caller-provided AxAIService. */
|
|
381
|
+
ai: AxAIService;
|
|
382
|
+
/** Model id forwarded to actor + responder. */
|
|
383
|
+
model?: string;
|
|
384
|
+
/** Recursion depth. 0 = no sub-agent dispatch. Default 1. */
|
|
385
|
+
maxDepth?: number;
|
|
386
|
+
/** Maximum actor turns. Default 12. */
|
|
387
|
+
maxTurns?: number;
|
|
388
|
+
/** Maximum parallel sub-agent calls in batched llmQuery. Default 2. */
|
|
389
|
+
maxParallelSubagents?: number;
|
|
390
|
+
/** Override the actor description. */
|
|
391
|
+
actorDescription?: string;
|
|
392
|
+
/** Override the subagent description. */
|
|
393
|
+
subagentDescription?: string;
|
|
394
|
+
/** Per-turn observability hook. */
|
|
395
|
+
onTurn?: (turn: AnalyzeTracesTurnSnapshot) => void | Promise<void>;
|
|
396
|
+
/** Override max runtime characters per turn. Default 6000. */
|
|
397
|
+
maxRuntimeChars?: number;
|
|
398
|
+
/** When set, every turn's snapshot is appended to this JSONL file
|
|
399
|
+
* immediately. If the analyst crashes mid-loop (provider 503,
|
|
400
|
+
* network error, validator reject) the partial reasoning is still
|
|
401
|
+
* on disk. Replay the file with the responder afterward to recover
|
|
402
|
+
* evidence. */
|
|
403
|
+
progressLogPath?: string;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Run the trace analyst.
|
|
407
|
+
*
|
|
408
|
+
* Throws:
|
|
409
|
+
* - `TraceFileMissingError` if `source` is a path and doesn't exist.
|
|
410
|
+
* - `AxAgentClarificationError` if the analyst asks for clarification.
|
|
411
|
+
* - Provider errors (auth, rate limits) propagate from the AI service.
|
|
412
|
+
*/
|
|
413
|
+
declare function analyzeTraces(input: AnalyzeTracesInput, options: AnalyzeTracesOptions): Promise<AnalyzeTracesResult>;
|
|
10
414
|
|
|
11
415
|
/**
|
|
12
416
|
* Trace-analyst auto-execution hook.
|
|
@@ -284,4 +688,123 @@ declare function traceAnalystFunctionGroup(opts: BuildTraceAnalystToolsOpts): {
|
|
|
284
688
|
functions: AxFunction[];
|
|
285
689
|
};
|
|
286
690
|
|
|
287
|
-
|
|
691
|
+
/**
|
|
692
|
+
* Replay-from-raw-events — turn every captured campaign run into a
|
|
693
|
+
* re-runnable artifact.
|
|
694
|
+
*
|
|
695
|
+
* `RawProviderSink` captures every provider HTTP envelope; `runEvalCampaign`
|
|
696
|
+
* makes that capture the default. Together they make every past run a
|
|
697
|
+
* complete fingerprint of what happened on the wire — enough to replay
|
|
698
|
+
* the run without burning new LLM cost.
|
|
699
|
+
*
|
|
700
|
+
* Three use cases this primitive enables:
|
|
701
|
+
*
|
|
702
|
+
* 1. **Post-hoc judging** — apply a new judge / rubric / scoring callback
|
|
703
|
+
* to last week's runs without re-calling any LLM. The cost of trying
|
|
704
|
+
* a new rubric drops from "another full sweep" to a CPU-bound replay.
|
|
705
|
+
* 2. **Determinism audits** — replay the same campaign and verify the
|
|
706
|
+
* raw responses match byte-for-byte. Any drift is a non-determinism
|
|
707
|
+
* bug (in the harness, the prompt builder, the sandbox, …).
|
|
708
|
+
* 3. **Free judge calibration** — run two judges on identical responses
|
|
709
|
+
* and measure inter-judge agreement without doubling LLM spend.
|
|
710
|
+
*
|
|
711
|
+
* The interface is deliberately fetch-shaped. Inject `createReplayFetch`
|
|
712
|
+
* into `LlmClientOptions.fetch` and every `callLlm` transparently reads
|
|
713
|
+
* from the cache instead of calling the network. No new code path through
|
|
714
|
+
* the LLM client is needed; the cache hit is invisible to the runner.
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
declare class ReplayCacheMissError extends ReplayError {
|
|
718
|
+
readonly url: string;
|
|
719
|
+
readonly requestKey: string;
|
|
720
|
+
constructor(url: string, requestKey: string, message?: string);
|
|
721
|
+
}
|
|
722
|
+
interface ReplayCacheEntry {
|
|
723
|
+
request: RawProviderEvent;
|
|
724
|
+
response: RawProviderEvent;
|
|
725
|
+
}
|
|
726
|
+
interface ReplayCacheStats {
|
|
727
|
+
total: number;
|
|
728
|
+
byProvider: Record<string, number>;
|
|
729
|
+
byModel: Record<string, number>;
|
|
730
|
+
/** Spans for which we have a request but no response (run aborted mid-call). */
|
|
731
|
+
orphanRequests: number;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* In-memory deterministic cache of (request → response) keyed on a stable
|
|
735
|
+
* hash of the request body. Built from a `RawProviderSink` containing
|
|
736
|
+
* paired `request` and `response` events from a previous run.
|
|
737
|
+
*
|
|
738
|
+
* The cache is the source of truth for replay; `createReplayFetch` is a
|
|
739
|
+
* thin wrapper that reads from it.
|
|
740
|
+
*/
|
|
741
|
+
declare class ReplayCache {
|
|
742
|
+
private byKey;
|
|
743
|
+
private orphans;
|
|
744
|
+
private byProvider;
|
|
745
|
+
private byModel;
|
|
746
|
+
/**
|
|
747
|
+
* Build a cache from a sink's events. The sink must implement `list()`.
|
|
748
|
+
* Filter by `runId` / `spanId` to scope to a specific replay.
|
|
749
|
+
*/
|
|
750
|
+
static fromSink(sink: RawProviderSink, filter?: {
|
|
751
|
+
runId?: string;
|
|
752
|
+
spanId?: string;
|
|
753
|
+
}): Promise<ReplayCache>;
|
|
754
|
+
/** Build a cache from an in-memory event list. */
|
|
755
|
+
static fromEvents(events: RawProviderEvent[]): Promise<ReplayCache>;
|
|
756
|
+
/** Number of cacheable (request, response) pairs in the cache. */
|
|
757
|
+
size(): number;
|
|
758
|
+
stats(): ReplayCacheStats;
|
|
759
|
+
/** Iterate every cached `(request, response)` pair in insertion order. */
|
|
760
|
+
entries(): IterableIterator<ReplayCacheEntry>;
|
|
761
|
+
/**
|
|
762
|
+
* Look up a cached response by hashing the (model, messages, temperature,
|
|
763
|
+
* maxTokens, response_format) shape. Returns `undefined` on miss; the
|
|
764
|
+
* caller decides whether to throw, fall back to the network, or skip.
|
|
765
|
+
*/
|
|
766
|
+
lookup(requestBody: unknown): Promise<ReplayCacheEntry | undefined>;
|
|
767
|
+
}
|
|
768
|
+
interface ReplayFetchOptions {
|
|
769
|
+
/**
|
|
770
|
+
* Behaviour on cache miss. Default `'throw'`. `'fallback'` calls the
|
|
771
|
+
* `fallbackFetch` (typically `globalThis.fetch`) so a partial replay can
|
|
772
|
+
* still complete; `'fail-closed'` returns a synthetic 599 response so the
|
|
773
|
+
* call site sees a non-retriable failure.
|
|
774
|
+
*/
|
|
775
|
+
onMiss?: 'throw' | 'fallback' | 'fail-closed';
|
|
776
|
+
fallbackFetch?: typeof fetch;
|
|
777
|
+
/** Optional callback fired once per replayed call (for telemetry / counters). */
|
|
778
|
+
onHit?: (info: {
|
|
779
|
+
url: string;
|
|
780
|
+
provider: string;
|
|
781
|
+
model: string;
|
|
782
|
+
}) => void;
|
|
783
|
+
/** Optional callback fired on cache miss before the `onMiss` policy applies. */
|
|
784
|
+
onMissNotify?: (info: {
|
|
785
|
+
url: string;
|
|
786
|
+
requestBody: unknown;
|
|
787
|
+
}) => void;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Build a `fetch`-shaped function that serves cached responses out of a
|
|
791
|
+
* `ReplayCache` for any URL ending in `/chat/completions`. Pass through
|
|
792
|
+
* `LlmClientOptions.fetch` and `callLlm` becomes free.
|
|
793
|
+
*
|
|
794
|
+
* Non-`/chat/completions` URLs are passed straight to the fallback fetch
|
|
795
|
+
* (default: `globalThis.fetch`). This matters because non-LLM HTTP work
|
|
796
|
+
* (judge HTTP servers, sandbox callbacks) sometimes flows through the same
|
|
797
|
+
* `fetch` and shouldn't be intercepted.
|
|
798
|
+
*/
|
|
799
|
+
declare function createReplayFetch(cache: ReplayCache, opts?: ReplayFetchOptions): typeof fetch;
|
|
800
|
+
/**
|
|
801
|
+
* Convenience iterator over `(request, response)` pairs in a sink — for
|
|
802
|
+
* post-hoc scoring that doesn't need a `fetch` shim. The judge or scorer
|
|
803
|
+
* runs purely in-process over cached LLM outputs.
|
|
804
|
+
*/
|
|
805
|
+
declare function iterateRawCalls(sink: RawProviderSink, filter?: {
|
|
806
|
+
runId?: string;
|
|
807
|
+
spanId?: string;
|
|
808
|
+
}): AsyncGenerator<ReplayCacheEntry>;
|
|
809
|
+
|
|
810
|
+
export { type AnalyzeTracesInput, type AnalyzeTracesOptions, type AnalyzeTracesResult, type AnalyzeTracesTurnSnapshot, DEFAULT_REDACTION_RULES, DEFAULT_TRACE_ANALYST_BUDGETS, type DatasetOverview, OTEL_AGENT_EVAL_SCOPE, type OtlpExport, OtlpFileTraceStore, type OtlpFileTraceStoreOptions, type OtlpResourceSpans, type OtlpSpan, type QueryTracesPage, REDACTION_VERSION, RawProviderEvent, RawProviderSink, type RedactionReport, type RedactionRule, ReplayCache, type ReplayCacheEntry, ReplayCacheMissError, type ReplayCacheStats, type ReplayFetchOptions, RunCompleteHook, RunCompleteHookContext, type SearchSpanResult, type SearchTraceResult, type SpanMatchRecord, SpanNotFoundError, TRACE_ANALYST_ACTOR_DESCRIPTION, TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION, TRACE_ANALYST_SUBAGENT_DESCRIPTION, TRACE_ANALYST_TRUNCATION_MARKER_PREFIX, type TraceAnalysisStore, type TraceAnalystByteBudgets, type TraceAnalystFilters, type TraceAnalystHookOptions, type TraceAnalystSpan, type TraceAnalystSpanKind, type TraceAnalystSpanStatus, type TraceAnalystTraceSummary, TraceFileMissingError, type TraceInsightContext, type TraceInsightFinding, type TraceInsightPanelRole, type TraceInsightPromptInput, type TraceInsightQualityGate, type TraceInsightQuestion, type TraceInsightReadiness, type TraceInsightSuite, type TraceInsightTask, TraceNotFoundError, TraceStore, type ViewSpansResult, type ViewTraceOversized, type ViewTraceResult, analyzeTraces, buildTraceAnalystTools, buildTraceInsightContext, buildTraceInsightPrompt, createReplayFetch, defaultTraceInsightPanel, describeTraceInsightScope, domainEvidencePattern, exportRunAsOtlp, inferDomainKeywords, iterateRawCalls, planTraceInsightQuestions, redactString, redactValue, scoreTraceInsightReadiness, tokenizeDomainWords, traceAnalystFunctionGroup, traceAnalystOnRunComplete };
|