agent-inspect 5.1.0 → 5.2.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.
@@ -960,4 +960,50 @@ declare function parseGroupBySpec(groupBy: string | undefined): {
960
960
  declare function renderCohortSummaryMarkdown(result: CohortAnalysisResult): string;
961
961
  declare function renderCohortReport(result: CohortAnalysisResult, options?: RenderCohortReportOptions): string;
962
962
 
963
- export { type ActivityEntry, type ActivitySummary, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, compareCohortAggregates, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveTraceDir, runSuite, searchTraces, serializeEvent, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateSuiteConfig, warn, writeTraceEvent };
963
+ type GateExitCode = 0 | 1 | 2 | 3 | 4;
964
+ type GateCheckId = "suite" | "maxErrorRate" | "maxP95Duration" | "forbidTool" | "requireObservation";
965
+ interface GateCheckResult {
966
+ id: GateCheckId;
967
+ name: string;
968
+ ok: boolean;
969
+ message: string;
970
+ expected?: string | number;
971
+ actual?: string | number;
972
+ runId?: string;
973
+ }
974
+ interface GateResult {
975
+ ok: boolean;
976
+ exitCode: GateExitCode;
977
+ traceDir?: string;
978
+ suitePath?: string;
979
+ runCount: number;
980
+ checks: GateCheckResult[];
981
+ diagnostics: string[];
982
+ suiteResult?: SuiteRunResult;
983
+ }
984
+ interface RunGateOptions {
985
+ traceDir?: string;
986
+ suitePath?: string;
987
+ cwd?: string;
988
+ maxErrorRate?: number;
989
+ maxP95DurationMs?: number;
990
+ forbidTools?: string[];
991
+ requireObservations?: string[];
992
+ }
993
+ interface RenderGateReportOptions {
994
+ format?: "markdown" | "json" | "html" | "junit" | "github";
995
+ }
996
+
997
+ declare function parseGateList(value: string | undefined): string[];
998
+ declare function parseGateNumber(value: string | undefined, label: string): number | undefined;
999
+
1000
+ declare function gateHasThresholds(options: RunGateOptions): boolean;
1001
+
1002
+ declare function runGate(runs: readonly SessionRunRecord[], options: RunGateOptions): Promise<GateResult>;
1003
+
1004
+ declare function renderGateSummaryMarkdown(result: GateResult): string;
1005
+ declare function renderGateGithubStepSummary(result: GateResult): string;
1006
+ declare function renderGateJUnit(result: GateResult): string;
1007
+ declare function renderGateReport(result: GateResult, options?: RenderGateReportOptions): string;
1008
+
1009
+ export { type ActivityEntry, type ActivitySummary, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GateCheckId, type GateCheckResult, type GateExitCode, type GateResult, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderGateReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, type RunGateOptions, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, compareCohortAggregates, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, gateHasThresholds, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseGateList, parseGateNumber, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveTraceDir, runGate, runSuite, searchTraces, serializeEvent, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateSuiteConfig, warn, writeTraceEvent };
@@ -960,4 +960,50 @@ declare function parseGroupBySpec(groupBy: string | undefined): {
960
960
  declare function renderCohortSummaryMarkdown(result: CohortAnalysisResult): string;
961
961
  declare function renderCohortReport(result: CohortAnalysisResult, options?: RenderCohortReportOptions): string;
962
962
 
963
- export { type ActivityEntry, type ActivitySummary, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, compareCohortAggregates, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveTraceDir, runSuite, searchTraces, serializeEvent, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateSuiteConfig, warn, writeTraceEvent };
963
+ type GateExitCode = 0 | 1 | 2 | 3 | 4;
964
+ type GateCheckId = "suite" | "maxErrorRate" | "maxP95Duration" | "forbidTool" | "requireObservation";
965
+ interface GateCheckResult {
966
+ id: GateCheckId;
967
+ name: string;
968
+ ok: boolean;
969
+ message: string;
970
+ expected?: string | number;
971
+ actual?: string | number;
972
+ runId?: string;
973
+ }
974
+ interface GateResult {
975
+ ok: boolean;
976
+ exitCode: GateExitCode;
977
+ traceDir?: string;
978
+ suitePath?: string;
979
+ runCount: number;
980
+ checks: GateCheckResult[];
981
+ diagnostics: string[];
982
+ suiteResult?: SuiteRunResult;
983
+ }
984
+ interface RunGateOptions {
985
+ traceDir?: string;
986
+ suitePath?: string;
987
+ cwd?: string;
988
+ maxErrorRate?: number;
989
+ maxP95DurationMs?: number;
990
+ forbidTools?: string[];
991
+ requireObservations?: string[];
992
+ }
993
+ interface RenderGateReportOptions {
994
+ format?: "markdown" | "json" | "html" | "junit" | "github";
995
+ }
996
+
997
+ declare function parseGateList(value: string | undefined): string[];
998
+ declare function parseGateNumber(value: string | undefined, label: string): number | undefined;
999
+
1000
+ declare function gateHasThresholds(options: RunGateOptions): boolean;
1001
+
1002
+ declare function runGate(runs: readonly SessionRunRecord[], options: RunGateOptions): Promise<GateResult>;
1003
+
1004
+ declare function renderGateSummaryMarkdown(result: GateResult): string;
1005
+ declare function renderGateGithubStepSummary(result: GateResult): string;
1006
+ declare function renderGateJUnit(result: GateResult): string;
1007
+ declare function renderGateReport(result: GateResult, options?: RenderGateReportOptions): string;
1008
+
1009
+ export { type ActivityEntry, type ActivitySummary, type AnalyzeCohortOptions, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, COHORT_METRIC_IDS, type CohortAggregateMetrics, type CohortAnalysisResult, type CohortMetricComparison, type CohortMetricId, type CohortRunMetrics, type CriticalPathStep, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GateCheckId, type GateCheckResult, type GateExitCode, type GateResult, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, type LoadSuiteConfigOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderCohortReportOptions, type RenderGateReportOptions, type RenderSuiteReportOptions, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type ResolvedSuiteCase, type RetryLink, type RunGateOptions, RunStatus, type RunSuiteOptions, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, type SuiteArtifactsConfig, type SuiteCaseConfig, type SuiteCaseResult, type SuiteCaseStatus, type SuiteChecksConfig, type SuiteConfig, type SuiteDiagnostic, type SuiteDiagnosticCode, type SuiteEvalConfig, type SuiteRunResult, type SuiteRunSummary, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, type ValidateSuiteConfigResult, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, compareCohortAggregates, createRunId, createStepId, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, gateHasThresholds, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDuration, parseDurationFilter, parseGateList, parseGateNumber, parseGroupBySpec, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderErrorLine, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderRunSummary, renderRunWhat, renderStepLine, renderSuiteReport, renderSuiteReportMarkdown, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteCaseTrace, resolveSuiteConfigPath, resolveTraceDir, runGate, runSuite, searchTraces, serializeEvent, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, validateSuiteConfig, warn, writeTraceEvent };
@@ -440,9 +440,9 @@ async function searchTraces(metas, options) {
440
440
  }
441
441
  const limit = options.limit ?? 50;
442
442
  const sessionId = options.session?.trim();
443
- const observationStatus = parseObservationFilter(options.observation);
443
+ const observationStatus2 = parseObservationFilter(options.observation);
444
444
  const hasContentFilter = Boolean(
445
- options.status || stepTypeFilter || nameQuery || toolQuery || durationFilter || observationStatus
445
+ options.status || stepTypeFilter || nameQuery || toolQuery || durationFilter || observationStatus2
446
446
  );
447
447
  const results = [];
448
448
  const sessionLabel = sessionId && sessionId !== "" ? sessionId : void 0;
@@ -487,9 +487,9 @@ async function searchTraces(metas, options) {
487
487
  statusFilter: options.status
488
488
  });
489
489
  results.push(...stepMatches);
490
- if (observationStatus) {
490
+ if (observationStatus2) {
491
491
  const outcomes = extractOutcomesFromTraceEvents(events);
492
- const matched = outcomes.filter((outcome) => outcome.status === observationStatus);
492
+ const matched = outcomes.filter((outcome) => outcome.status === observationStatus2);
493
493
  for (const outcome of matched) {
494
494
  results.push({
495
495
  runId: m.runId,
@@ -1325,12 +1325,12 @@ function buildCriticalPath(runs, handoffs) {
1325
1325
  handoffs.filter((edge) => edge.confidence === "explicit").map((edge) => edge.from)
1326
1326
  );
1327
1327
  const ordered = [...runs].sort(compareRuns);
1328
- const path6 = [];
1328
+ const path7 = [];
1329
1329
  const visited = /* @__PURE__ */ new Set();
1330
1330
  const pushRun = (run, confidence, source) => {
1331
1331
  if (visited.has(run.runId)) return;
1332
1332
  visited.add(run.runId);
1333
- path6.push({
1333
+ path7.push({
1334
1334
  runId: run.runId,
1335
1335
  name: run.name,
1336
1336
  startedAt: run.startedAt,
@@ -1355,7 +1355,7 @@ function buildCriticalPath(runs, handoffs) {
1355
1355
  const confidence = explicitTargets.has(run.runId) || explicitSources.has(run.runId) ? "explicit" : "correlated";
1356
1356
  pushRun(run, confidence, confidence === "explicit" ? "manual" : "inferred");
1357
1357
  }
1358
- return path6;
1358
+ return path7;
1359
1359
  }
1360
1360
  function metaRunIdMatches(run, token, runById) {
1361
1361
  const meta = extractSessionWorkflowMetadata(run.metadata);
@@ -2735,6 +2735,402 @@ function renderCohortReport(result, options = {}) {
2735
2735
  return renderCohortSummaryMarkdown(result);
2736
2736
  }
2737
2737
 
2738
- export { COHORT_METRIC_IDS, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, SESSION_WORKFLOW_KEYS, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, compareCohortAggregates, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, groupSessionCohorts, isAgentInspectTrace, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDurationFilter, parseGroupBySpec, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderSuiteReport, renderSuiteReportMarkdown, renderTraceStats, resolveBundleRunIds, resolveSuiteCaseTrace, resolveSuiteConfigPath, runSuite, searchTraces, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, validateSuiteConfig };
2738
+ // packages/core/src/gate/parse.ts
2739
+ function parseGateList(value) {
2740
+ if (value === void 0 || value.trim() === "") return [];
2741
+ return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
2742
+ }
2743
+ function parseGateNumber(value, label) {
2744
+ if (value === void 0 || value.trim() === "") return void 0;
2745
+ const parsed = Number(value);
2746
+ if (!Number.isFinite(parsed)) {
2747
+ throw new Error(`Invalid ${label}: ${value}`);
2748
+ }
2749
+ return parsed;
2750
+ }
2751
+
2752
+ // packages/core/src/gate/evaluate.ts
2753
+ function percentile3(values, p) {
2754
+ if (values.length === 0) return void 0;
2755
+ const sorted = [...values].sort((a, b) => a - b);
2756
+ const idx = Math.min(
2757
+ sorted.length - 1,
2758
+ Math.max(0, Math.ceil(p / 100 * sorted.length) - 1)
2759
+ );
2760
+ return sorted[idx];
2761
+ }
2762
+ function hasThresholds(options) {
2763
+ return options.maxErrorRate !== void 0 || options.maxP95DurationMs !== void 0 || (options.forbidTools?.length ?? 0) > 0 || (options.requireObservations?.length ?? 0) > 0;
2764
+ }
2765
+ function gateHasThresholds(options) {
2766
+ return hasThresholds(options);
2767
+ }
2768
+ async function loadRunMetrics(runs) {
2769
+ const metrics = [];
2770
+ for (const run of runs) {
2771
+ if (run.filePath === void 0) continue;
2772
+ metrics.push(
2773
+ await computeCohortRunMetrics({
2774
+ runId: run.runId,
2775
+ filePath: run.filePath,
2776
+ metadata: run.metadata,
2777
+ status: run.status,
2778
+ durationMs: run.durationMs,
2779
+ groupKey: "all"
2780
+ })
2781
+ );
2782
+ }
2783
+ return metrics;
2784
+ }
2785
+ async function observationStatus(filePath, name) {
2786
+ const events = await readTraceEventsFromFile(filePath);
2787
+ const outcomes = extractOutcomesFromTraceEvents(events);
2788
+ const match = outcomes.find((item) => item.name === name);
2789
+ if (!match) return "missing";
2790
+ return match.status === "passed" ? "passed" : "failed";
2791
+ }
2792
+ async function evaluateGateThresholds(runs, options) {
2793
+ const checks = [];
2794
+ const readErrors = [];
2795
+ if (!hasThresholds(options)) {
2796
+ return { checks, readErrors };
2797
+ }
2798
+ if (runs.length === 0) {
2799
+ readErrors.push("No trace runs found in the gate directory.");
2800
+ return { checks, readErrors };
2801
+ }
2802
+ let runMetrics;
2803
+ try {
2804
+ runMetrics = await loadRunMetrics(runs);
2805
+ } catch (error) {
2806
+ const message = error instanceof Error ? error.message : String(error);
2807
+ readErrors.push(message);
2808
+ return { checks, readErrors };
2809
+ }
2810
+ if (options.maxErrorRate !== void 0) {
2811
+ const errors = runMetrics.filter((run) => run.error).length;
2812
+ const actual = runMetrics.length > 0 ? errors / runMetrics.length * 100 : 0;
2813
+ const ok = actual <= options.maxErrorRate;
2814
+ checks.push({
2815
+ id: "maxErrorRate",
2816
+ name: "Max error rate",
2817
+ ok,
2818
+ expected: options.maxErrorRate,
2819
+ actual: Math.round(actual * 10) / 10,
2820
+ message: ok ? `Error rate ${actual.toFixed(1)}% within limit ${options.maxErrorRate}%` : `Error rate ${actual.toFixed(1)}% exceeds limit ${options.maxErrorRate}%`
2821
+ });
2822
+ }
2823
+ if (options.maxP95DurationMs !== void 0) {
2824
+ const durations = runMetrics.map((run) => run.durationMs).filter((value) => typeof value === "number");
2825
+ const actual = percentile3(durations, 95);
2826
+ const ok = actual !== void 0 && actual <= options.maxP95DurationMs;
2827
+ checks.push({
2828
+ id: "maxP95Duration",
2829
+ name: "Max p95 duration (ms)",
2830
+ ok,
2831
+ expected: options.maxP95DurationMs,
2832
+ actual: actual ?? "n/a",
2833
+ message: actual === void 0 ? "No duration samples available for p95 check." : ok ? `P95 duration ${Math.round(actual)} ms within limit ${options.maxP95DurationMs} ms` : `P95 duration ${Math.round(actual)} ms exceeds limit ${options.maxP95DurationMs} ms`
2834
+ });
2835
+ }
2836
+ for (const tool of options.forbidTools ?? []) {
2837
+ let violated = false;
2838
+ for (const run of runMetrics) {
2839
+ const used = run.toolChoices.includes(tool) || run.toolOrdering.includes(tool);
2840
+ if (used) {
2841
+ violated = true;
2842
+ checks.push({
2843
+ id: "forbidTool",
2844
+ name: `Forbid tool: ${tool}`,
2845
+ ok: false,
2846
+ expected: `not used`,
2847
+ actual: "used",
2848
+ runId: run.runId,
2849
+ message: `Forbidden tool "${tool}" used in run ${run.runId}`
2850
+ });
2851
+ }
2852
+ }
2853
+ if (!violated) {
2854
+ checks.push({
2855
+ id: "forbidTool",
2856
+ name: `Forbid tool: ${tool}`,
2857
+ ok: true,
2858
+ message: `Forbidden tool "${tool}" not used`
2859
+ });
2860
+ }
2861
+ }
2862
+ for (const observation of options.requireObservations ?? []) {
2863
+ for (const run of runs) {
2864
+ if (run.filePath === void 0) continue;
2865
+ try {
2866
+ const status = await observationStatus(run.filePath, observation);
2867
+ const ok = status === "passed";
2868
+ checks.push({
2869
+ id: "requireObservation",
2870
+ name: `Require observation: ${observation}`,
2871
+ ok,
2872
+ expected: "passed",
2873
+ actual: status,
2874
+ runId: run.runId,
2875
+ message: ok ? `Observation "${observation}" passed in run ${run.runId}` : status === "missing" ? `Observation "${observation}" missing in run ${run.runId}` : `Observation "${observation}" failed in run ${run.runId}`
2876
+ });
2877
+ } catch (error) {
2878
+ const message = error instanceof Error ? error.message : String(error);
2879
+ readErrors.push(`Run ${run.runId}: ${message}`);
2880
+ }
2881
+ }
2882
+ }
2883
+ return { checks, readErrors };
2884
+ }
2885
+ function checksFromSuiteResult(suiteResult) {
2886
+ const checks = [
2887
+ {
2888
+ id: "suite",
2889
+ name: `Suite: ${suiteResult.suiteName}`,
2890
+ ok: suiteResult.ok,
2891
+ message: suiteResult.ok ? `Suite passed (${suiteResult.summary.passed} cases)` : `Suite failed (${suiteResult.summary.failed} failed, ${suiteResult.summary.errors} errors)`
2892
+ }
2893
+ ];
2894
+ for (const suiteCase of suiteResult.cases) {
2895
+ if (suiteCase.status === "pass") continue;
2896
+ checks.push({
2897
+ id: "suite",
2898
+ name: `Case: ${suiteCase.id}`,
2899
+ ok: false,
2900
+ message: suiteCase.message ?? `Case status: ${suiteCase.status}`
2901
+ });
2902
+ }
2903
+ return checks;
2904
+ }
2905
+ function resolveExitCode(input) {
2906
+ if (input.configError) return 2;
2907
+ if (input.readError) return 3;
2908
+ if (!input.ok) return 1;
2909
+ return 0;
2910
+ }
2911
+ function validateOptions(options) {
2912
+ const errors = [];
2913
+ const hasSuite = options.suitePath !== void 0 && options.suitePath.trim() !== "";
2914
+ const hasThresholds2 = gateHasThresholds(options);
2915
+ if (!hasSuite && !hasThresholds2) {
2916
+ errors.push(
2917
+ "No gate rules specified. Pass --suite or at least one threshold flag."
2918
+ );
2919
+ }
2920
+ if (hasThresholds2 && (options.traceDir === void 0 || options.traceDir.trim() === "")) {
2921
+ if (!hasSuite) {
2922
+ errors.push("Threshold flags require --dir <trace-directory>.");
2923
+ }
2924
+ }
2925
+ if (options.maxErrorRate !== void 0 && options.maxErrorRate < 0) {
2926
+ errors.push("--max-error-rate must be a non-negative percentage.");
2927
+ }
2928
+ if (options.maxP95DurationMs !== void 0 && options.maxP95DurationMs < 0) {
2929
+ errors.push("--max-p95-duration must be a non-negative millisecond value.");
2930
+ }
2931
+ return errors;
2932
+ }
2933
+ function isConfigLoadError(error) {
2934
+ if (!(error instanceof Error)) return false;
2935
+ const ext = path3.extname(error.message);
2936
+ if (error.message.includes("Unsupported suite config extension")) return true;
2937
+ if (error.message.includes("TypeScript suite configs require")) return true;
2938
+ if (error.message.includes("No suite config found")) return true;
2939
+ if (error.message.includes("AI_SUITE_CONFIG")) return true;
2940
+ if (ext === ".ts" || ext === ".mts" || ext === ".cts") return true;
2941
+ return "diagnostics" in error;
2942
+ }
2943
+ async function runGate(runs, options) {
2944
+ const diagnostics = [];
2945
+ const checks = [];
2946
+ const validationErrors = validateOptions(options);
2947
+ if (validationErrors.length > 0) {
2948
+ return {
2949
+ ok: false,
2950
+ exitCode: 2,
2951
+ runCount: 0,
2952
+ checks,
2953
+ diagnostics: validationErrors
2954
+ };
2955
+ }
2956
+ let traceDir = options.traceDir?.trim();
2957
+ let suiteResult;
2958
+ if (options.suitePath !== void 0 && options.suitePath.trim() !== "") {
2959
+ try {
2960
+ suiteResult = await runSuite({
2961
+ configPath: options.suitePath,
2962
+ cwd: options.cwd
2963
+ });
2964
+ traceDir = traceDir ?? suiteResult.tracesDir;
2965
+ checks.push(...checksFromSuiteResult(suiteResult));
2966
+ } catch (error) {
2967
+ const message = error instanceof Error ? error.message : String(error);
2968
+ diagnostics.push(message);
2969
+ return {
2970
+ ok: false,
2971
+ exitCode: isConfigLoadError(error) ? 2 : 3,
2972
+ traceDir,
2973
+ suitePath: options.suitePath,
2974
+ runCount: 0,
2975
+ checks,
2976
+ diagnostics
2977
+ };
2978
+ }
2979
+ }
2980
+ if (gateHasThresholds(options)) {
2981
+ const thresholdDir = traceDir;
2982
+ if (thresholdDir === void 0 || thresholdDir.trim() === "") {
2983
+ return {
2984
+ ok: false,
2985
+ exitCode: 2,
2986
+ traceDir,
2987
+ suitePath: options.suitePath,
2988
+ runCount: runs.length,
2989
+ checks,
2990
+ diagnostics: ["Threshold evaluation requires a trace directory."],
2991
+ ...suiteResult !== void 0 ? { suiteResult } : {}
2992
+ };
2993
+ }
2994
+ const thresholdRuns = runs.length > 0 ? runs : [];
2995
+ const { checks: thresholdChecks, readErrors } = await evaluateGateThresholds(
2996
+ thresholdRuns,
2997
+ options
2998
+ );
2999
+ checks.push(...thresholdChecks);
3000
+ diagnostics.push(...readErrors);
3001
+ if (readErrors.length > 0) {
3002
+ const ok2 = checks.length > 0 && checks.every((item) => item.ok);
3003
+ return {
3004
+ ok: ok2,
3005
+ exitCode: resolveExitCode({
3006
+ ok: ok2,
3007
+ configError: false,
3008
+ readError: true
3009
+ }),
3010
+ traceDir: thresholdDir,
3011
+ suitePath: options.suitePath,
3012
+ runCount: thresholdRuns.length,
3013
+ checks,
3014
+ diagnostics,
3015
+ ...suiteResult !== void 0 ? { suiteResult } : {}
3016
+ };
3017
+ }
3018
+ }
3019
+ const ok = checks.length > 0 && checks.every((item) => item.ok);
3020
+ return {
3021
+ ok,
3022
+ exitCode: resolveExitCode({ ok, configError: false, readError: false }),
3023
+ traceDir,
3024
+ suitePath: options.suitePath,
3025
+ runCount: runs.length,
3026
+ checks,
3027
+ diagnostics,
3028
+ ...suiteResult !== void 0 ? { suiteResult } : {}
3029
+ };
3030
+ }
3031
+
3032
+ // packages/core/src/gate/render.ts
3033
+ function escapeXml(value) {
3034
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
3035
+ }
3036
+ function renderGateSummaryMarkdown(result) {
3037
+ const lines = [];
3038
+ lines.push("# AgentInspect gate");
3039
+ lines.push("");
3040
+ lines.push(`Status: **${result.ok ? "PASS" : "FAIL"}** (exit ${result.exitCode})`);
3041
+ if (result.traceDir !== void 0) {
3042
+ lines.push(`Trace directory: \`${result.traceDir}\``);
3043
+ }
3044
+ if (result.suitePath !== void 0) {
3045
+ lines.push(`Suite config: \`${result.suitePath}\``);
3046
+ }
3047
+ lines.push(`Runs evaluated: ${result.runCount}`);
3048
+ lines.push("");
3049
+ if (result.diagnostics.length > 0) {
3050
+ lines.push("## Diagnostics");
3051
+ for (const item of result.diagnostics) lines.push(`- ${item}`);
3052
+ lines.push("");
3053
+ }
3054
+ lines.push("## Checks");
3055
+ for (const check of result.checks) {
3056
+ const flag = check.ok ? "PASS" : "FAIL";
3057
+ lines.push(`- [${flag}] ${check.name}: ${check.message}`);
3058
+ }
3059
+ lines.push("");
3060
+ return lines.join("\n").trimEnd();
3061
+ }
3062
+ function renderGateGithubStepSummary(result) {
3063
+ const lines = [];
3064
+ lines.push(`## AgentInspect gate: ${result.ok ? "PASS" : "FAIL"}`);
3065
+ lines.push("");
3066
+ lines.push("| Check | Status | Details |");
3067
+ lines.push("| --- | --- | --- |");
3068
+ for (const check of result.checks) {
3069
+ lines.push(
3070
+ `| ${check.name} | ${check.ok ? "pass" : "fail"} | ${check.message.replace(/\|/g, "/")} |`
3071
+ );
3072
+ }
3073
+ if (result.diagnostics.length > 0) {
3074
+ lines.push("");
3075
+ lines.push("**Diagnostics**");
3076
+ for (const item of result.diagnostics) lines.push(`- ${item}`);
3077
+ }
3078
+ return lines.join("\n").trimEnd();
3079
+ }
3080
+ function renderGateReportHtml(result) {
3081
+ const rows = result.checks.map(
3082
+ (check) => `<tr><td>${escapeHtml(check.name)}</td><td>${check.ok ? "PASS" : "FAIL"}</td><td>${escapeHtml(check.message)}</td></tr>`
3083
+ ).join("");
3084
+ return `<!DOCTYPE html>
3085
+ <html lang="en">
3086
+ <head>
3087
+ <meta charset="utf-8" />
3088
+ <title>Gate report</title>
3089
+ <style>
3090
+ body { font-family: system-ui, sans-serif; margin: 2rem; }
3091
+ table { border-collapse: collapse; width: 100%; }
3092
+ th, td { border: 1px solid #ddd; padding: 0.5rem; text-align: left; }
3093
+ th { background: #f6f6f6; }
3094
+ </style>
3095
+ </head>
3096
+ <body>
3097
+ <h1>AgentInspect gate</h1>
3098
+ <p>Status: <strong>${result.ok ? "PASS" : "FAIL"}</strong> (exit ${result.exitCode})</p>
3099
+ <h2>Checks</h2>
3100
+ <table>
3101
+ <thead><tr><th>Check</th><th>Status</th><th>Details</th></tr></thead>
3102
+ <tbody>${rows}</tbody>
3103
+ </table>
3104
+ </body>
3105
+ </html>`;
3106
+ }
3107
+ function renderGateJUnit(result) {
3108
+ const failures = result.checks.filter((check) => !check.ok).length;
3109
+ const tests = result.checks.length;
3110
+ const cases = result.checks.map((check) => {
3111
+ if (check.ok) {
3112
+ return ` <testcase name="${escapeXml(check.name)}" classname="gate" />`;
3113
+ }
3114
+ return ` <testcase name="${escapeXml(check.name)}" classname="gate">
3115
+ <failure message="${escapeXml(check.message)}">${escapeXml(check.message)}</failure>
3116
+ </testcase>`;
3117
+ }).join("\n");
3118
+ return `<?xml version="1.0" encoding="UTF-8"?>
3119
+ <testsuites tests="${tests}" failures="${failures}" errors="0" time="0">
3120
+ <testsuite name="agent-inspect-gate" tests="${tests}" failures="${failures}" errors="0" time="0">
3121
+ ${cases}
3122
+ </testsuite>
3123
+ </testsuites>`;
3124
+ }
3125
+ function renderGateReport(result, options = {}) {
3126
+ const format = options.format ?? "markdown";
3127
+ if (format === "json") return JSON.stringify(result, null, 2);
3128
+ if (format === "html") return renderGateReportHtml(result);
3129
+ if (format === "junit") return renderGateJUnit(result);
3130
+ if (format === "github") return renderGateGithubStepSummary(result);
3131
+ return renderGateSummaryMarkdown(result);
3132
+ }
3133
+
3134
+ export { COHORT_METRIC_IDS, DEFAULT_SUITE_ARTIFACTS_DIR, DEFAULT_SUITE_CONFIG_NAMES, SESSION_WORKFLOW_KEYS, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, compareCohortAggregates, defaultBundleOutputPath, defaultSuiteConfigTemplate, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, gateHasThresholds, groupSessionCohorts, isAgentInspectTrace, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, normalizeBundleOutputPath, normalizeSuiteConfig, parseCohortMetricList, parseDurationFilter, parseGateList, parseGateNumber, parseGroupBySpec, renderActivitySummaryHuman, renderCohortReport, renderCohortSummaryMarkdown, renderGateGithubStepSummary, renderGateJUnit, renderGateReport, renderGateSummaryMarkdown, renderSuiteReport, renderSuiteReportMarkdown, renderTraceStats, resolveBundleRunIds, resolveSuiteCaseTrace, resolveSuiteConfigPath, runGate, runSuite, searchTraces, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, validateSuiteConfig };
2739
3135
  //# sourceMappingURL=advanced.mjs.map
2740
3136
  //# sourceMappingURL=advanced.mjs.map