@tangle-network/traces 0.9.12 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { Analyst, AnalystContext, AnalystFinding, AnalystRegistry, buildDefaultA
5
5
  import { AxAIService } from '@ax-llm/ax';
6
6
  import { ExecutionReport } from '@tangle-network/agent-eval/contract';
7
7
  import { TraceAnalysisStore, RedactionRule, RedactionReport } from '@tangle-network/agent-eval/traces';
8
- export { DEFAULT_REDACTION_RULES, RedactionReport, RedactionRule, redactString, redactValue } from '@tangle-network/agent-eval/traces';
8
+ export { DEFAULT_REDACTION_RULES, ErrorCluster, RedactionReport, RedactionRule, TraceAnalysisStore, redactString, redactValue } from '@tangle-network/agent-eval/traces';
9
9
  import { TraceSpanEvent } from '@tangle-network/agent-eval/hosted';
10
10
  export { HostedClient, createHostedClient, hostedClientFromEnv } from '@tangle-network/agent-eval/hosted';
11
11
 
@@ -109,9 +109,11 @@ interface JsonlCorruptionReceipt {
109
109
  }
110
110
  type JsonlReadOptions = {
111
111
  mode?: 'strict';
112
+ signal?: AbortSignal;
112
113
  } | {
113
114
  mode: 'recover';
114
115
  onCorruption: (receipt: JsonlCorruptionReceipt) => void;
116
+ signal?: AbortSignal;
115
117
  };
116
118
  declare class JsonlParseError extends SyntaxError {
117
119
  readonly sourcePath: string;
@@ -142,7 +144,21 @@ type CorruptionMode = 'recover' | 'strict';
142
144
  interface ParseOptions {
143
145
  /** Recover valid JSONL records by default; strict rejects the first corruption. */
144
146
  corruptionMode?: CorruptionMode;
147
+ /** For resumed session formats, parse all turns, the latest turn, or one exact turn. */
148
+ taskScope?: 'all' | 'latest' | 'turn';
149
+ /** Stable turn identifier required when taskScope is `turn`. */
150
+ taskTurnId?: string;
151
+ /** Stop active session reads and parsing. */
152
+ signal?: AbortSignal;
145
153
  }
154
+ type ParentTaskResolution = {
155
+ readonly kind: 'resolved';
156
+ readonly turnId: string;
157
+ } | {
158
+ readonly kind: 'unavailable';
159
+ readonly reason: 'child-reference-not-found' | 'parent-turn-metadata-missing' | 'ambiguous';
160
+ readonly turnIds?: readonly string[];
161
+ };
146
162
  interface SessionCorruptionReceipt extends JsonlCorruptionReceipt {
147
163
  harness: string;
148
164
  sessionId: string;
@@ -179,8 +195,17 @@ interface HarnessTraceAdapter {
179
195
  readonly aliases?: readonly string[];
180
196
  /** Discover session files for this harness on disk. */
181
197
  locate(opts?: LocateOptions): Promise<SessionRef[]>;
198
+ /** Resolve all files for one stable session ID without cataloging unrelated sessions. */
199
+ locateBySessionId?(sessionId: string, opts?: LocateOptions): Promise<SessionRef[]>;
182
200
  /** Parse one discovered session into normalized OTLP spans. */
183
201
  parse(ref: SessionRef, options?: ParseOptions): Promise<OtlpSpan[]>;
202
+ /** Every file whose bytes can affect parse output. Defaults to ref.path. */
203
+ sourcePaths?(ref: SessionRef, options?: Pick<ParseOptions, 'signal'>): Promise<readonly string[]>;
204
+ /**
205
+ * Resolve the exact parent task that referenced a child by stable session ID.
206
+ * Adapters must not infer this from names or timestamps.
207
+ */
208
+ resolveParentTask?(ref: SessionRef, childSessionId: string, options?: Pick<ParseOptions, 'corruptionMode' | 'signal'>): Promise<ParentTaskResolution>;
184
209
  }
185
210
 
186
211
  /**
@@ -266,8 +291,7 @@ declare function stampSessionIdentity(spans: {
266
291
  attributes: Record<string, unknown>;
267
292
  }[], fallbackSessionId: string): void;
268
293
 
269
- /** Parse an ISO-8601 timestamp or an epoch-millis string to epoch ms.
270
- * Returns 0 for empty/unparseable input (callers treat 0 as "unknown"). */
294
+ /** Parse an ISO-8601 timestamp or an epoch-millis string to epoch ms. */
271
295
  declare function parseIsoToEpochMs(ts: string): number;
272
296
  /** Parse a `--since` window: `30m` / `2h` / `7d` (relative to now) or an ISO
273
297
  * date, → epoch ms. Throws on a malformed value (fail-loud, not silent). */
@@ -316,6 +340,12 @@ interface AdapterSelection {
316
340
  * A named harness that doesn't resolve throws rather than silently dropping. */
317
341
  declare function selectAdapters(opts: AdapterSelection): HarnessTraceAdapter[];
318
342
 
343
+ /**
344
+ * Validate one normalized span batch before any consumer trusts its identity
345
+ * or timing. The returned array contains the original span objects.
346
+ */
347
+ declare function validateOtlpSpans(input: readonly unknown[], source?: string): OtlpSpan[];
348
+
319
349
  /**
320
350
  * Parse one session to spans and stamp per-session repo/git resource attrs
321
351
  * (`tangle.subject.key` etc.) derived from the ref's cwd. Every OTLP-producing
@@ -340,8 +370,6 @@ interface ScanOptions extends AdapterSelection, ParseOptions {
340
370
  sinceMs?: number;
341
371
  /** Cap to the most-recent N sessions per harness. */
342
372
  last?: number;
343
- /** Cancel the scan; iteration stops between sessions. */
344
- signal?: AbortSignal;
345
373
  /** Handle a locate/parse failure and continue. Without this callback, failures propagate. */
346
374
  onError?: (error: unknown, ref?: SessionRef) => void;
347
375
  }
@@ -355,6 +383,115 @@ interface ScannedSession {
355
383
  * propagate unless an explicit `onError` callback handles them. */
356
384
  declare function scanSessions(opts: ScanOptions): AsyncGenerator<ScannedSession>;
357
385
 
386
+ type SessionRole = 'operator' | 'child' | 'unknown';
387
+ interface SessionRelationship {
388
+ readonly sessionId: string;
389
+ readonly role: SessionRole;
390
+ readonly parentSessionId?: string;
391
+ readonly childSessionIds: readonly string[];
392
+ /** Child sessions created in this task. Their full history belongs to the task. */
393
+ readonly spawnedChildSessionIds: readonly string[];
394
+ /** Existing child sessions resumed or steered in this task. */
395
+ readonly resumedChildSessionIds: readonly string[];
396
+ readonly depth?: number;
397
+ readonly agentNickname?: string;
398
+ readonly agentRole?: string;
399
+ readonly agentPath?: string;
400
+ readonly taskScope?: 'all' | 'latest' | 'turn' | 'fork-current';
401
+ readonly turnId?: string;
402
+ }
403
+ type SessionWorkflowErrorCode = 'SESSION_WORKFLOW_EMPTY_SELECTION' | 'SESSION_WORKFLOW_INVALID_LIMIT' | 'SESSION_WORKFLOW_LIMIT_EXCEEDED' | 'SESSION_WORKFLOW_INVALID_RELATION' | 'SESSION_WORKFLOW_DUPLICATE_ID' | 'SESSION_WORKFLOW_TASK_CONFLICT';
404
+ declare class SessionWorkflowError extends Error {
405
+ readonly code: SessionWorkflowErrorCode;
406
+ constructor(code: SessionWorkflowErrorCode, message: string);
407
+ }
408
+ /** Read stable parent/child identity from normalized spans.
409
+ * Worker labels and timestamps are intentionally not used as identity. */
410
+ declare function describeSessionRelationship(ref: SessionRef, spans: readonly OtlpSpan[]): SessionRelationship;
411
+
412
+ type SessionWorkflowIssue = {
413
+ readonly kind: 'missing-session';
414
+ readonly sessionId: string;
415
+ readonly referencedBySessionId: string;
416
+ readonly relation: 'parent' | 'child';
417
+ } | {
418
+ readonly kind: 'ambiguous-session';
419
+ readonly sessionId: string;
420
+ readonly referencedBySessionId: string;
421
+ readonly relation: 'parent' | 'child';
422
+ readonly paths: readonly string[];
423
+ } | {
424
+ readonly kind: 'parent-conflict';
425
+ readonly sessionId: string;
426
+ readonly declaredParentSessionId?: string;
427
+ readonly referencedParentSessionIds: readonly string[];
428
+ } | {
429
+ readonly kind: 'cycle';
430
+ readonly sessionIds: readonly string[];
431
+ } | {
432
+ readonly kind: 'unresolved-parent-task';
433
+ readonly parentSessionId: string;
434
+ readonly childSessionId: string;
435
+ readonly reason: 'unsupported' | 'child-reference-not-found' | 'parent-turn-metadata-missing' | 'ambiguous';
436
+ readonly turnIds?: readonly string[];
437
+ };
438
+ interface SessionWorkflowSession {
439
+ readonly adapter: HarnessTraceAdapter;
440
+ readonly ref: SessionRef;
441
+ readonly spans: readonly OtlpSpan[];
442
+ readonly relationship: SessionRelationship;
443
+ readonly taskScope: 'all' | 'latest' | 'turn';
444
+ readonly taskTurnId?: string;
445
+ }
446
+ interface SessionWorkflowSummary {
447
+ readonly seedSessionIds: readonly string[];
448
+ readonly complete: boolean;
449
+ readonly issues: readonly SessionWorkflowIssue[];
450
+ }
451
+ interface SessionWorkflow extends SessionWorkflowSummary {
452
+ readonly sessions: readonly SessionWorkflowSession[];
453
+ }
454
+ interface CollectSessionWorkflowOptions extends ParseOptions {
455
+ /** Maximum number of source files parsed for one workflow selection. */
456
+ readonly maxSessions?: number;
457
+ }
458
+ /** Expand one or more selected source files into their connected session tree.
459
+ * Missing or ambiguous files are returned as issues; no path is guessed. */
460
+ declare function collectSessionWorkflow(adapter: HarnessTraceAdapter, seeds: readonly SessionRef[], options?: CollectSessionWorkflowOptions): Promise<SessionWorkflow>;
461
+
462
+ interface SessionSeedGroup {
463
+ readonly adapter: HarnessTraceAdapter;
464
+ readonly refs: readonly SessionRef[];
465
+ }
466
+ interface SessionSelectionRow {
467
+ readonly adapter: HarnessTraceAdapter;
468
+ readonly ref: SessionRef;
469
+ readonly spans: readonly OtlpSpan[];
470
+ readonly taskScope: 'all' | 'latest' | 'turn';
471
+ readonly taskTurnId?: string;
472
+ readonly sourceSha256?: string;
473
+ readonly sourceFiles?: readonly SessionSourceFile[];
474
+ }
475
+ interface SessionSourceFile {
476
+ readonly path: string;
477
+ readonly sha256: string;
478
+ }
479
+ interface SessionSelection {
480
+ readonly rows: readonly SessionSelectionRow[];
481
+ readonly workflow?: SessionWorkflowSummary;
482
+ }
483
+ interface CollectSessionSelectionOptions {
484
+ readonly workflow?: boolean;
485
+ readonly maxWorkflowSessions?: number;
486
+ readonly taskScope?: 'all' | 'latest' | 'turn';
487
+ readonly taskTurnId?: string;
488
+ /** Hash and reparse every selected file so emitted evidence binds exact bytes. */
489
+ readonly bindSources?: boolean;
490
+ readonly signal?: AbortSignal;
491
+ }
492
+ /** Parse selected seed groups, optionally expanding and byte-binding their session tree. */
493
+ declare function collectSessionSelection(groups: readonly SessionSeedGroup[], options?: CollectSessionSelectionOptions): Promise<SessionSelection>;
494
+
358
495
  type RepoResolutionSource = 'none' | 'ref-cwd' | 'repaired-cwd' | 'span-path' | 'span-workdir';
359
496
  /** Resource-attribute keys this resolver may stamp. */
360
497
  type RepoAttrs = Partial<Record<typeof ATTR.SUBJECT_KEY | typeof ATTR.GIT_REPOSITORY | typeof ATTR.GIT_BRANCH_NAME | typeof ATTR.GIT_COMMIT | typeof ATTR.CWD, string>> & Partial<Record<typeof ATTR.REPO_RESOLUTION_SOURCE, RepoResolutionSource>>;
@@ -399,8 +536,10 @@ declare function stampSpanWorkdirRepoAttrs(spans: readonly OtlpSpan[]): Promise<
399
536
  * (token trajectory) and `message.content[]` tool_use blocks; tool results
400
537
  * arrive as `tool_result` blocks in the following user message or as a
401
538
  * `tool_result` attachment. Subagent runs live in a sibling
402
- * nested `<session>/subagents/.../agent-*.jsonl` files with a `.meta.json` carrying the
403
- * spawning `toolUseId`, so we parent each subagent under its `Agent` call.
539
+ * nested `<session>/subagents/.../agent-*.jsonl` files. Ordinary subagent
540
+ * metadata carries the spawning `toolUseId`. Workflow subagents instead live
541
+ * under `workflows/<runId>` and bind to the exact run ID and transcript
542
+ * directory returned by the parent `Workflow` call.
404
543
  *
405
544
  * Shared by the claudish / openclaw / nanoclaw forks via aliases — they
406
545
  * write the same transcript shape.
@@ -410,12 +549,18 @@ declare class ClaudeAdapter implements HarnessTraceAdapter {
410
549
  readonly harness = "claude-code";
411
550
  readonly aliases: readonly ["claude", "claudish", "openclaw", "nanoclaw"];
412
551
  private root;
552
+ sourcePaths(ref: SessionRef, options?: Pick<ParseOptions, 'signal'>): Promise<readonly string[]>;
413
553
  locate(opts?: LocateOptions): Promise<SessionRef[]>;
414
554
  parse(ref: SessionRef, options?: ParseOptions): Promise<OtlpSpan[]>;
415
555
  /** Parse nested `subagents/.../agent-*.jsonl`, parenting each under its Agent call. */
416
556
  private foldSubagents;
417
557
  }
418
558
 
559
+ declare class CodexTaskScopeError extends Error {
560
+ readonly code: 'CODEX_CHILD_TASK_AMBIGUOUS' | 'CODEX_CHILD_TASK_NOT_FOUND' | 'CODEX_LATEST_TURN_NOT_FOUND' | 'CODEX_TURN_NOT_FOUND' | 'CODEX_TURN_ID_REQUIRED';
561
+ constructor(code: CodexTaskScopeError['code'], message: string);
562
+ }
563
+
419
564
  /**
420
565
  * OpenAI Codex adapter — `~/.codex/sessions/<Y>/<M>/<D>/rollout-*.jsonl`.
421
566
  *
@@ -436,7 +581,10 @@ declare class CodexAdapter implements HarnessTraceAdapter {
436
581
  readonly harness = "codex";
437
582
  readonly aliases: readonly ["codex-acp"];
438
583
  private root;
584
+ private refFromPath;
439
585
  locate(opts?: LocateOptions): Promise<SessionRef[]>;
586
+ locateBySessionId(sessionId: string, opts?: LocateOptions): Promise<SessionRef[]>;
587
+ resolveParentTask(ref: SessionRef, childSessionId: string, options?: Pick<ParseOptions, 'corruptionMode'>): Promise<ParentTaskResolution>;
440
588
  parse(ref: SessionRef, options?: ParseOptions): Promise<OtlpSpan[]>;
441
589
  }
442
590
 
@@ -661,12 +809,13 @@ declare function capText(raw: string): string;
661
809
  * but only some are a real human typing — the rest are the harness or another
662
810
  * agent feeding the model:
663
811
  * - `human` a person typed it
812
+ * - `agent` a parent agent sent it to a child session
664
813
  * - `subagent-spawn` a parent agent spawned a subagent with this prompt
665
814
  * - `injected` a synthetic harness prompt (benchmark task, memory, …)
666
815
  * - `tool-result` a tool result surfaced as a user turn (rare)
667
816
  * Analysts that measure human reactions must filter to `human` only.
668
817
  */
669
- type Actor = 'human' | 'subagent-spawn' | 'injected' | 'tool-result';
818
+ type Actor = 'human' | 'agent' | 'subagent-spawn' | 'injected' | 'tool-result';
670
819
  /** Span attribute key for {@link Actor}. New (additive) — not part of the
671
820
  * `tangle.sessionId`/`tangle.ingest_source` wire contract. */
672
821
  declare const ACTOR_ATTR = "tangle.actor";
@@ -716,6 +865,7 @@ declare function looksLikeAgentPrompt(s: string): boolean;
716
865
  * adapter already parses, falling back to the text heuristics above.
717
866
  *
718
867
  * isSidechain === true → subagent-spawn
868
+ * isMeta === true → injected
719
869
  * userType present and !== external → injected
720
870
  * synthetic markers in the text → injected
721
871
  * first-turn agent-spawn prompt → subagent-spawn
@@ -724,6 +874,7 @@ declare function looksLikeAgentPrompt(s: string): boolean;
724
874
  declare function claudeActor(args: {
725
875
  text: string;
726
876
  isSidechain?: boolean;
877
+ isMeta?: boolean;
727
878
  userType?: string | null;
728
879
  isFirstUserTurn?: boolean;
729
880
  }): Actor;
@@ -976,6 +1127,7 @@ interface AnalyzeOptions {
976
1127
  /** Where to write the OTLP-JSONL artifact. Defaults to a temp file. */
977
1128
  otlpOutPath?: string;
978
1129
  runId?: string;
1130
+ signal?: AbortSignal;
979
1131
  log?: (msg: string, fields?: Record<string, unknown>) => void;
980
1132
  }
981
1133
  interface AnalyzeResult {
@@ -1014,6 +1166,15 @@ interface PolicyEvidenceRecord {
1014
1166
  readonly path: string;
1015
1167
  readonly cwd: string | null;
1016
1168
  readonly mtimeMs: number;
1169
+ readonly role?: SessionRole;
1170
+ readonly parentSessionId?: string;
1171
+ readonly childSessionIds?: readonly string[];
1172
+ readonly depth?: number;
1173
+ readonly agentNickname?: string;
1174
+ readonly agentRole?: string;
1175
+ readonly agentPath?: string;
1176
+ readonly taskScope?: 'all' | 'latest' | 'turn' | 'fork-current';
1177
+ readonly turnId?: string;
1017
1178
  };
1018
1179
  readonly repo: {
1019
1180
  readonly subjectKey?: string;
@@ -1200,13 +1361,13 @@ declare function serializeInspectionReport(report: TraceInspectionReport): strin
1200
1361
  declare function readSessionIndexFile(path: string): Promise<TraceSessionIndex>;
1201
1362
  declare function writeInspectionReportFile(report: TraceInspectionReport, outPath?: string): Promise<string>;
1202
1363
 
1203
- type JsonObject = Record<string, unknown>;
1204
- type TraceEvidenceInputFormat = 'policy-evidence' | 'sandbox-events' | 'openinference' | 'intelligence-spans';
1364
+ type JsonObject$1 = Record<string, unknown>;
1365
+ type TraceEvidenceInputFormat = 'policy-evidence' | 'sandbox-events' | 'openinference' | 'intelligence-spans' | 'chat-trajectory';
1205
1366
  type TraceEvidenceFormatOption = TraceEvidenceInputFormat | 'auto';
1206
1367
  interface TraceEvidenceExportOptions {
1207
1368
  readonly format?: TraceEvidenceFormatOption;
1208
1369
  readonly sourcePath?: string;
1209
- readonly attributes?: JsonObject;
1370
+ readonly attributes?: JsonObject$1;
1210
1371
  }
1211
1372
  interface TraceEvidenceExportResult {
1212
1373
  readonly format: TraceEvidenceInputFormat;
@@ -1214,13 +1375,41 @@ interface TraceEvidenceExportResult {
1214
1375
  readonly redactionCount: number;
1215
1376
  readonly redactionsByRule: Record<string, number>;
1216
1377
  }
1217
- declare function exportTraceEvidenceRows(rows: readonly unknown[], opts?: TraceEvidenceExportOptions, wrapper?: JsonObject): TraceEvidenceExportResult;
1378
+ declare function exportTraceEvidenceRows(rows: readonly unknown[], opts?: TraceEvidenceExportOptions, wrapper?: JsonObject$1): TraceEvidenceExportResult;
1218
1379
  declare function exportTraceEvidenceText(text: string, opts?: TraceEvidenceExportOptions): TraceEvidenceExportResult;
1219
1380
  declare function exportTraceEvidenceFile(inputPath: string, opts?: TraceEvidenceExportOptions): Promise<TraceEvidenceExportResult>;
1220
1381
  declare function writeTraceEvidenceExportFile(inputPath: string, outPath?: string, opts?: TraceEvidenceExportOptions): Promise<TraceEvidenceExportResult & {
1221
1382
  path: string;
1222
1383
  }>;
1223
1384
 
1385
+ type JsonObject = Record<string, unknown>;
1386
+ interface ChatTrajectoryMessage {
1387
+ role: string;
1388
+ content: string;
1389
+ timestamp?: string | number;
1390
+ name?: string;
1391
+ extra?: JsonObject;
1392
+ }
1393
+ interface ChatTrajectory {
1394
+ messages: readonly ChatTrajectoryMessage[];
1395
+ trajectory_id?: string | number;
1396
+ traj_id?: string;
1397
+ instance_id?: string;
1398
+ trajectory_format?: string;
1399
+ info?: JsonObject;
1400
+ }
1401
+ interface ChatTrajectoryOptions {
1402
+ traceId?: string;
1403
+ service?: string;
1404
+ /** Use every message for datasets whose labels count transcript rows. */
1405
+ stepMode?: 'assistant' | 'message';
1406
+ sourcePath?: string;
1407
+ }
1408
+ declare function isChatTrajectoryMessage(value: unknown): value is ChatTrajectoryMessage;
1409
+ declare function isChatTrajectory(value: unknown): value is ChatTrajectory;
1410
+ /** Convert a generic chat trajectory into stable OpenInference-ready spans. */
1411
+ declare function chatTrajectoryToSpans(input: ChatTrajectory | readonly ChatTrajectoryMessage[], options?: ChatTrajectoryOptions): OtlpSpan[];
1412
+
1224
1413
  /**
1225
1414
  * External-tool adapters: run analysis engines and PII scrubbers that `traces`
1226
1415
  * does NOT bundle. Each is a thin command adapter over a shared subprocess
@@ -1248,21 +1437,51 @@ declare function runCommand(command: string, args?: readonly string[], opts?: {
1248
1437
  }): Promise<RunResult>;
1249
1438
  interface ExternalAnalysisResult {
1250
1439
  analyzer: string;
1440
+ kind: ExternalAnalysisKind;
1251
1441
  ok: boolean;
1252
- /** Raw text the engine produced (markdown/JSON/plain — engine-specific). */
1442
+ /** Raw text the engine produced. */
1253
1443
  output: string;
1254
- /** Structured findings, when the engine emits parseable JSON. */
1255
- findings?: AnalystFinding[];
1444
+ /** Confirmed findings with exact evidence. Only valid when kind is findings. */
1445
+ findings?: readonly AnalystFinding[];
1446
+ /** Distinctive actions that still need review. Only valid when kind is discovery. */
1447
+ candidates?: readonly ExternalDiscoveryCandidate[];
1256
1448
  error?: string;
1257
1449
  }
1450
+ type ExternalAnalysisKind = 'report' | 'findings' | 'discovery';
1451
+ interface ExternalDiscoveryCandidate {
1452
+ engine: string;
1453
+ engineVersion: string;
1454
+ status: 'needs_review';
1455
+ group: string;
1456
+ rank: number;
1457
+ groupSize: number;
1458
+ traceId: string;
1459
+ spanId: string;
1460
+ evidenceUri: string;
1461
+ summary: string;
1462
+ actionText: string;
1463
+ metadata?: Record<string, unknown>;
1464
+ }
1465
+ type ExternalAnalysisPayload = {
1466
+ kind: 'report';
1467
+ } | {
1468
+ kind: 'findings';
1469
+ findings: readonly AnalystFinding[];
1470
+ } | {
1471
+ kind: 'discovery';
1472
+ candidates: readonly ExternalDiscoveryCandidate[];
1473
+ };
1474
+ interface ExternalAnalyzerOptions {
1475
+ prompt?: string;
1476
+ signal?: AbortSignal;
1477
+ /** Supplied by runExternalAnalyzers to avoid rereading the OTLP artifact. */
1478
+ knownSpanUris?: ReadonlySet<string>;
1479
+ }
1258
1480
  /** An analysis engine that runs over the emitted OTLP-JSONL artifact — a peer to
1259
1481
  * the built-in analysts, so you get many analyzers beyond our own. */
1260
1482
  interface ExternalAnalyzer {
1261
1483
  name: string;
1262
- analyze(otlpPath: string, opts?: {
1263
- prompt?: string;
1264
- signal?: AbortSignal;
1265
- }): Promise<ExternalAnalysisResult>;
1484
+ analyze(otlpPath: string, opts?: ExternalAnalyzerOptions): Promise<ExternalAnalysisResult>;
1266
1485
  }
1267
1486
  /** Wrap any CLI that reads the OTLP file and prints analysis to stdout. `args`
1268
1487
  * builds the argv from the artifact path + optional prompt. Non-zero exit →
@@ -1271,8 +1490,8 @@ declare function commandAnalyzer(spec: {
1271
1490
  name: string;
1272
1491
  command: string;
1273
1492
  args: (otlpPath: string, prompt?: string) => string[];
1274
- /** Parse stdout into structured findings; omit to keep raw output only. */
1275
- parse?: (stdout: string) => AnalystFinding[] | undefined;
1493
+ /** Explicitly classify structured output; omit to keep a raw report. */
1494
+ parse?: (stdout: string) => ExternalAnalysisPayload;
1276
1495
  timeoutMs?: number;
1277
1496
  }): ExternalAnalyzer;
1278
1497
  /** HALO (github.com/context-labs/halo) over the OTLP artifact: `halo <file> -p
@@ -1280,17 +1499,26 @@ declare function commandAnalyzer(spec: {
1280
1499
  * OpenInference, so HALO reads the artifact directly — no conversion. Install
1281
1500
  * HALO yourself and configure its LLM provider (it uses the OpenAI client —
1282
1501
  * `OPENAI_BASE_URL` / `OPENAI_API_KEY`); this just drives it. */
1283
- declare function haloAnalyzer(opts?: {
1502
+ type HaloReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
1503
+ interface HaloAnalyzerOptions {
1284
1504
  command?: string;
1285
1505
  defaultPrompt?: string;
1286
1506
  model?: string;
1507
+ maxDepth?: number;
1508
+ maxTurns?: number;
1509
+ maxParallel?: number;
1510
+ instructions?: string;
1511
+ reasoningEffort?: HaloReasoningEffort;
1512
+ telemetry?: boolean;
1287
1513
  timeoutMs?: number;
1288
- }): ExternalAnalyzer;
1514
+ }
1515
+ declare function haloAnalyzer(opts?: HaloAnalyzerOptions): ExternalAnalyzer;
1289
1516
  /** Run external analyzers over one OTLP artifact, concurrently. Never throws —
1290
1517
  * a failing engine returns `ok:false`. */
1291
1518
  declare function runExternalAnalyzers(otlpPath: string, analyzers: readonly ExternalAnalyzer[], opts?: {
1292
1519
  prompt?: string;
1293
1520
  signal?: AbortSignal;
1521
+ spans?: readonly OtlpSpan[];
1294
1522
  }): Promise<ExternalAnalysisResult[]>;
1295
1523
  /** An external PII/secret scrubber for free-form text — catches what regex
1296
1524
  * can't (names, addresses). Use to harden upload beyond the built-in rules. */
@@ -1488,6 +1716,13 @@ interface ReportSource {
1488
1716
  subject: string;
1489
1717
  role: 'operator' | 'child' | 'unknown';
1490
1718
  parentSessionId?: string;
1719
+ childSessionIds?: readonly string[];
1720
+ depth?: number;
1721
+ agentNickname?: string;
1722
+ agentRole?: string;
1723
+ agentPath?: string;
1724
+ taskScope?: 'all' | 'latest' | 'turn' | 'fork-current';
1725
+ turnId?: string;
1491
1726
  integrity?: 'complete' | 'degraded_not_lossless';
1492
1727
  corruptionCount?: number;
1493
1728
  corruptionDigest?: string;
@@ -1504,6 +1739,7 @@ interface TraceInvestigationOptions {
1504
1739
  readonly spans: readonly OtlpSpan[];
1505
1740
  readonly harness: string;
1506
1741
  readonly sources?: readonly ReportSource[];
1742
+ readonly workflow?: SessionWorkflowSummary;
1507
1743
  readonly cwds?: readonly string[];
1508
1744
  readonly minLoopOccurrences?: number;
1509
1745
  readonly ai?: AxAIService;
@@ -1516,6 +1752,7 @@ interface TraceInvestigationOptions {
1516
1752
  readonly analyzerPrompt?: string;
1517
1753
  readonly otlpOutPath?: string;
1518
1754
  readonly generatedAt?: string;
1755
+ readonly signal?: AbortSignal;
1519
1756
  readonly log?: (msg: string, fields?: Record<string, unknown>) => void;
1520
1757
  }
1521
1758
  interface TraceEvidenceRow {
@@ -1544,9 +1781,11 @@ interface TraceInvestigationResult {
1544
1781
  /** Traces without exactly one stable session identity. */
1545
1782
  readonly unassignedTraceCount: number;
1546
1783
  readonly sources?: readonly ReportSource[];
1784
+ readonly workflow?: SessionWorkflowSummary;
1547
1785
  readonly spanCount: number;
1548
1786
  readonly otlpPath: string;
1549
1787
  readonly execution: ExecutionReport;
1788
+ readonly analystResult: AnalystRunResult;
1550
1789
  readonly findings: readonly AnalystFinding[];
1551
1790
  readonly pipelines: PipelineReport;
1552
1791
  readonly reactions: ReactionReport;
@@ -1578,6 +1817,7 @@ interface TraceStoreInvestigationOptions {
1578
1817
  readonly budgetUsd?: number;
1579
1818
  readonly runId?: string;
1580
1819
  readonly generatedAt?: string;
1820
+ readonly signal?: AbortSignal;
1581
1821
  readonly log?: (msg: string, fields?: Record<string, unknown>) => void;
1582
1822
  }
1583
1823
  interface TraceStoreInvestigationResult extends Omit<TraceFindingPacket, 'kind'> {
@@ -1600,6 +1840,61 @@ declare function writeTraceImprovementArtifacts(result: Omit<TraceImprovementRes
1600
1840
  declare function runTraceImprovement(opts: TraceImprovementOptions): Promise<TraceImprovementResult>;
1601
1841
  declare function saveReport(path: string, report: string): Promise<void>;
1602
1842
 
1843
+ type Json = null | boolean | number | string | Json[] | {
1844
+ [key: string]: Json;
1845
+ };
1846
+ interface HodoscopeMessage {
1847
+ role: 'system' | 'user' | 'assistant' | 'tool';
1848
+ content: string;
1849
+ source?: string;
1850
+ tool_calls?: Array<{
1851
+ function: string;
1852
+ arguments: Json;
1853
+ }>;
1854
+ }
1855
+ interface HodoscopeTrajectory {
1856
+ id: string;
1857
+ model?: string;
1858
+ metadata: Record<string, Json>;
1859
+ messages: HodoscopeMessage[];
1860
+ }
1861
+ interface HodoscopeSourceMapEntry {
1862
+ trajectoryId: string;
1863
+ turnId: number;
1864
+ traceId: string;
1865
+ spanId: string;
1866
+ evidenceUri: string;
1867
+ }
1868
+ interface HodoscopeInput {
1869
+ directory: string;
1870
+ trajectoryCount: number;
1871
+ actionCount: number;
1872
+ sourceMap: readonly HodoscopeSourceMapEntry[];
1873
+ }
1874
+ interface HodoscopeAnalyzerOptions {
1875
+ command?: string;
1876
+ commandArgs?: readonly string[];
1877
+ /** Hodoscope 0.2.4 currently resolves on Python 3.11, not Python 3.13. */
1878
+ pythonVersion?: string;
1879
+ /** Parent directory for isolated per-run artifacts. */
1880
+ outputDir?: string;
1881
+ summarizeModel?: string;
1882
+ embeddingModel?: string;
1883
+ embeddingDimensions?: number;
1884
+ maxWorkers?: number;
1885
+ groupByAttribute?: string;
1886
+ samplesPerGroup?: number;
1887
+ projection?: 'pca' | 'tsne' | 'umap' | 'trimap' | 'pacmap';
1888
+ timeoutMs?: number;
1889
+ }
1890
+ /** Convert OpenInference JSONL into Hodoscope's trajectory directory. */
1891
+ declare function writeHodoscopeInput(otlpPath: string, options?: {
1892
+ directory?: string;
1893
+ groupByAttribute?: string;
1894
+ }): Promise<HodoscopeInput>;
1895
+ /** Run Hodoscope as a behavior-discovery engine. Its output requires review. */
1896
+ declare function hodoscopeAnalyzer(options?: HodoscopeAnalyzerOptions): ExternalAnalyzer;
1897
+
1603
1898
  /**
1604
1899
  * Live trace observer — compatibility wrapper behind `traces watch`.
1605
1900
  *
@@ -1805,4 +2100,4 @@ interface ExecuteOptions {
1805
2100
  /** Send the final, new outbound items (or write their dry-run OTLP). */
1806
2101
  declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
1807
2102
 
1808
- export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CODING_REDACTION_RULES, CONTENT_CAP, CORRECTIVE_REACTIONS, ClaudeAdapter, CodexAdapter, CodexExecAdapter, CodexExecStreamError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, CopilotAdapter, type CorruptionMode, DEFAULT_HARNESS, EmptySessionError, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, type ParseOptions, PartialUploadError, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionCorruptionReceipt, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type TraceAgenticRoute, type TraceAgenticRouteReason, type TraceAgenticRouteReasonCode, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceExecutionOptions, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveAction, type TraceLiveActionKind, type TraceLiveAnalysisContext, type TraceLiveAnalyst, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveLoop, type TraceLiveSeverity, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadIdentity, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, alreadyUploaded, analyzeAdoption, analyzeLiveBatch, analyzeReactions, analyzeSpans, applyRedactor, buildPolicyEvidenceRecord, buildSessionIndex, buildSessionIndexFromRows, buildTraceFindingPacket, capText, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessions, commandAnalyzer, commandRedactor, countSkillRunsJsonl, cwdMatchesSelection, defaultTraceLiveAnalysts, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, haloAnalyzer, indexSessionIdsByTrace, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, outboundHash, parseIsoToEpochMs, parseSession, parseSince, planTraceAgenticRoute, planUpload, readJsonFile, readJsonl, readSessionIndexFile, recordSessionCorruption, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovement, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, span, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceAgenticKinds, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
2103
+ export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CODING_REDACTION_RULES, CONTENT_CAP, CORRECTIVE_REACTIONS, type ChatTrajectory, type ChatTrajectoryMessage, type ChatTrajectoryOptions, ClaudeAdapter, CodexAdapter, CodexExecAdapter, CodexExecStreamError, CodexTaskScopeError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, type CollectSessionSelectionOptions, type CollectSessionWorkflowOptions, CopilotAdapter, type CorruptionMode, DEFAULT_HARNESS, EmptySessionError, type ExecuteOptions, type ExternalAnalysisKind, type ExternalAnalysisPayload, type ExternalAnalysisResult, type ExternalAnalyzer, type ExternalAnalyzerOptions, type ExternalDiscoveryCandidate, FactoryAdapter, ForgeAdapter, GeminiAdapter, type HaloAnalyzerOptions, type HaloReasoningEffort, type HarnessTraceAdapter, type HodoscopeAnalyzerOptions, type HodoscopeInput, type HodoscopeMessage, type HodoscopeSourceMapEntry, type HodoscopeTrajectory, INGEST_SOURCE_CLI, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, type ParentTaskResolution, type ParseOptions, PartialUploadError, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionCorruptionReceipt, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionRef, type SessionRelationship, type SessionRole, type SessionSeedGroup, type SessionSelection, type SessionSelectionRow, type SessionSourceFile, type SessionWorkflow, SessionWorkflowError, type SessionWorkflowErrorCode, type SessionWorkflowIssue, type SessionWorkflowSession, type SessionWorkflowSummary, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type TraceAgenticRoute, type TraceAgenticRouteReason, type TraceAgenticRouteReasonCode, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceExecutionOptions, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveAction, type TraceLiveActionKind, type TraceLiveAnalysisContext, type TraceLiveAnalyst, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveLoop, type TraceLiveSeverity, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadIdentity, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, alreadyUploaded, analyzeAdoption, analyzeLiveBatch, analyzeReactions, analyzeSpans, applyRedactor, buildPolicyEvidenceRecord, buildSessionIndex, buildSessionIndexFromRows, buildTraceFindingPacket, capText, chatTrajectoryToSpans, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessionSelection, collectSessionWorkflow, collectSessions, commandAnalyzer, commandRedactor, countSkillRunsJsonl, cwdMatchesSelection, defaultTraceLiveAnalysts, describeSessionRelationship, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, haloAnalyzer, hodoscopeAnalyzer, indexSessionIdsByTrace, inspectSessionIndex, isChatTrajectory, isChatTrajectoryMessage, knownHarnesses, listAdapters, loadState, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, outboundHash, parseIsoToEpochMs, parseSession, parseSince, planTraceAgenticRoute, planUpload, readJsonFile, readJsonl, readSessionIndexFile, recordSessionCorruption, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovement, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, span, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceAgenticKinds, traceStreamEventsFromSpans, uploadKey, userPromptSpan, validateOtlpSpans, watchSessions, writeHodoscopeInput, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };