agent-inspect 5.1.0 → 5.3.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/CHANGELOG.md +12 -0
- package/docs/CLI.md +55 -0
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-TSIQUIPF.mjs → chunk-4LKKB4Z5.mjs} +416 -28
- package/packages/cli/dist/chunk-4LKKB4Z5.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +2830 -2072
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +2430 -2103
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-2SZWGKMM.mjs → src-4SGS3Q2D.mjs} +3 -3
- package/packages/cli/dist/{src-2SZWGKMM.mjs.map → src-4SGS3Q2D.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +415 -9
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +54 -4
- package/packages/core/dist/advanced.d.ts +54 -4
- package/packages/core/dist/advanced.mjs +405 -8
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.d.cts +1 -1
- package/packages/core/dist/checks.d.ts +1 -1
- package/packages/core/dist/{context-Cp8NRbBX.d.ts → context-BJ5UQLDi.d.ts} +1 -1
- package/packages/core/dist/{context-BbfkMYjz.d.cts → context-DyKbkmd4.d.cts} +1 -1
- package/packages/core/dist/index.d.cts +2 -2
- package/packages/core/dist/index.d.ts +2 -2
- package/packages/core/dist/{types-CvsKGweN.d.cts → types-J3Xtuf9x.d.cts} +13 -1
- package/packages/core/dist/{types-CvsKGweN.d.ts → types-J3Xtuf9x.d.ts} +13 -1
- package/packages/cli/dist/chunk-TSIQUIPF.mjs.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-
|
|
2
|
-
import { R as RedactionProfile, E as ErrorInfo, b as RunStatus, e as StepStatus,
|
|
1
|
+
export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-DyKbkmd4.cjs';
|
|
2
|
+
import { R as RedactionProfile, h as TraceEvent, E as ErrorInfo, b as RunStatus, e as StepStatus, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-B1X87dUW.cjs';
|
|
3
3
|
export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-B1X87dUW.cjs';
|
|
4
4
|
import { b as InspectRunTree } from './inspect-event-IqwOHbGo.cjs';
|
|
5
5
|
export { A as AttributionConfidence, E as EventSource, a as InspectEvent, I as InspectKind, c as InspectNode } from './inspect-event-IqwOHbGo.cjs';
|
|
6
6
|
import { P as PersistedInspectEvent } from './persisted-inspect-event-Gd-W8vB7.cjs';
|
|
7
7
|
import { Stats } from 'node:fs';
|
|
8
|
+
import { a as ObservedOutcome } from './types-J3Xtuf9x.cjs';
|
|
9
|
+
export { b as ObservedOutcomeStatus } from './types-J3Xtuf9x.cjs';
|
|
8
10
|
import { TraceCheckResult, TraceCheckStatus } from './checks.cjs';
|
|
9
11
|
import './writers.cjs';
|
|
10
|
-
import './types-CvsKGweN.cjs';
|
|
11
12
|
import './log-config-CW8w5YQ9.cjs';
|
|
12
13
|
import './readers.cjs';
|
|
13
14
|
|
|
@@ -20,6 +21,9 @@ interface ResolvedRedactionProfile {
|
|
|
20
21
|
/** Resolves named profile behavior (keys + metadata string caps). */
|
|
21
22
|
declare function resolveRedactionProfile(profile?: RedactionProfile): ResolvedRedactionProfile;
|
|
22
23
|
|
|
24
|
+
declare function extractOutcomesFromTraceEvents(events: readonly TraceEvent[]): ObservedOutcome[];
|
|
25
|
+
declare function extractOutcomesFromPersistedEvents(events: readonly PersistedInspectEvent[]): ObservedOutcome[];
|
|
26
|
+
|
|
23
27
|
/** Two spaces per nesting level in terminal output. */
|
|
24
28
|
declare const TERMINAL_INDENT = " ";
|
|
25
29
|
/** Max display length for names in terminal output. */
|
|
@@ -960,4 +964,50 @@ declare function parseGroupBySpec(groupBy: string | undefined): {
|
|
|
960
964
|
declare function renderCohortSummaryMarkdown(result: CohortAnalysisResult): string;
|
|
961
965
|
declare function renderCohortReport(result: CohortAnalysisResult, options?: RenderCohortReportOptions): string;
|
|
962
966
|
|
|
963
|
-
|
|
967
|
+
type GateExitCode = 0 | 1 | 2 | 3 | 4;
|
|
968
|
+
type GateCheckId = "suite" | "maxErrorRate" | "maxP95Duration" | "forbidTool" | "requireObservation";
|
|
969
|
+
interface GateCheckResult {
|
|
970
|
+
id: GateCheckId;
|
|
971
|
+
name: string;
|
|
972
|
+
ok: boolean;
|
|
973
|
+
message: string;
|
|
974
|
+
expected?: string | number;
|
|
975
|
+
actual?: string | number;
|
|
976
|
+
runId?: string;
|
|
977
|
+
}
|
|
978
|
+
interface GateResult {
|
|
979
|
+
ok: boolean;
|
|
980
|
+
exitCode: GateExitCode;
|
|
981
|
+
traceDir?: string;
|
|
982
|
+
suitePath?: string;
|
|
983
|
+
runCount: number;
|
|
984
|
+
checks: GateCheckResult[];
|
|
985
|
+
diagnostics: string[];
|
|
986
|
+
suiteResult?: SuiteRunResult;
|
|
987
|
+
}
|
|
988
|
+
interface RunGateOptions {
|
|
989
|
+
traceDir?: string;
|
|
990
|
+
suitePath?: string;
|
|
991
|
+
cwd?: string;
|
|
992
|
+
maxErrorRate?: number;
|
|
993
|
+
maxP95DurationMs?: number;
|
|
994
|
+
forbidTools?: string[];
|
|
995
|
+
requireObservations?: string[];
|
|
996
|
+
}
|
|
997
|
+
interface RenderGateReportOptions {
|
|
998
|
+
format?: "markdown" | "json" | "html" | "junit" | "github";
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
declare function parseGateList(value: string | undefined): string[];
|
|
1002
|
+
declare function parseGateNumber(value: string | undefined, label: string): number | undefined;
|
|
1003
|
+
|
|
1004
|
+
declare function gateHasThresholds(options: RunGateOptions): boolean;
|
|
1005
|
+
|
|
1006
|
+
declare function runGate(runs: readonly SessionRunRecord[], options: RunGateOptions): Promise<GateResult>;
|
|
1007
|
+
|
|
1008
|
+
declare function renderGateSummaryMarkdown(result: GateResult): string;
|
|
1009
|
+
declare function renderGateGithubStepSummary(result: GateResult): string;
|
|
1010
|
+
declare function renderGateJUnit(result: GateResult): string;
|
|
1011
|
+
declare function renderGateReport(result: GateResult, options?: RenderGateReportOptions): string;
|
|
1012
|
+
|
|
1013
|
+
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, ObservedOutcome, 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, extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents, 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 };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-
|
|
2
|
-
import { R as RedactionProfile, E as ErrorInfo, b as RunStatus, e as StepStatus,
|
|
1
|
+
export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-BJ5UQLDi.js';
|
|
2
|
+
import { R as RedactionProfile, h as TraceEvent, E as ErrorInfo, b as RunStatus, e as StepStatus, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-BVkjSd0q.js';
|
|
3
3
|
export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-BVkjSd0q.js';
|
|
4
4
|
import { b as InspectRunTree } from './inspect-event-IqwOHbGo.js';
|
|
5
5
|
export { A as AttributionConfidence, E as EventSource, a as InspectEvent, I as InspectKind, c as InspectNode } from './inspect-event-IqwOHbGo.js';
|
|
6
6
|
import { P as PersistedInspectEvent } from './persisted-inspect-event-DruwqARZ.js';
|
|
7
7
|
import { Stats } from 'node:fs';
|
|
8
|
+
import { a as ObservedOutcome } from './types-J3Xtuf9x.js';
|
|
9
|
+
export { b as ObservedOutcomeStatus } from './types-J3Xtuf9x.js';
|
|
8
10
|
import { TraceCheckResult, TraceCheckStatus } from './checks.js';
|
|
9
11
|
import './writers.js';
|
|
10
|
-
import './types-CvsKGweN.js';
|
|
11
12
|
import './log-config-SRA4xTp8.js';
|
|
12
13
|
import './readers.js';
|
|
13
14
|
|
|
@@ -20,6 +21,9 @@ interface ResolvedRedactionProfile {
|
|
|
20
21
|
/** Resolves named profile behavior (keys + metadata string caps). */
|
|
21
22
|
declare function resolveRedactionProfile(profile?: RedactionProfile): ResolvedRedactionProfile;
|
|
22
23
|
|
|
24
|
+
declare function extractOutcomesFromTraceEvents(events: readonly TraceEvent[]): ObservedOutcome[];
|
|
25
|
+
declare function extractOutcomesFromPersistedEvents(events: readonly PersistedInspectEvent[]): ObservedOutcome[];
|
|
26
|
+
|
|
23
27
|
/** Two spaces per nesting level in terminal output. */
|
|
24
28
|
declare const TERMINAL_INDENT = " ";
|
|
25
29
|
/** Max display length for names in terminal output. */
|
|
@@ -960,4 +964,50 @@ declare function parseGroupBySpec(groupBy: string | undefined): {
|
|
|
960
964
|
declare function renderCohortSummaryMarkdown(result: CohortAnalysisResult): string;
|
|
961
965
|
declare function renderCohortReport(result: CohortAnalysisResult, options?: RenderCohortReportOptions): string;
|
|
962
966
|
|
|
963
|
-
|
|
967
|
+
type GateExitCode = 0 | 1 | 2 | 3 | 4;
|
|
968
|
+
type GateCheckId = "suite" | "maxErrorRate" | "maxP95Duration" | "forbidTool" | "requireObservation";
|
|
969
|
+
interface GateCheckResult {
|
|
970
|
+
id: GateCheckId;
|
|
971
|
+
name: string;
|
|
972
|
+
ok: boolean;
|
|
973
|
+
message: string;
|
|
974
|
+
expected?: string | number;
|
|
975
|
+
actual?: string | number;
|
|
976
|
+
runId?: string;
|
|
977
|
+
}
|
|
978
|
+
interface GateResult {
|
|
979
|
+
ok: boolean;
|
|
980
|
+
exitCode: GateExitCode;
|
|
981
|
+
traceDir?: string;
|
|
982
|
+
suitePath?: string;
|
|
983
|
+
runCount: number;
|
|
984
|
+
checks: GateCheckResult[];
|
|
985
|
+
diagnostics: string[];
|
|
986
|
+
suiteResult?: SuiteRunResult;
|
|
987
|
+
}
|
|
988
|
+
interface RunGateOptions {
|
|
989
|
+
traceDir?: string;
|
|
990
|
+
suitePath?: string;
|
|
991
|
+
cwd?: string;
|
|
992
|
+
maxErrorRate?: number;
|
|
993
|
+
maxP95DurationMs?: number;
|
|
994
|
+
forbidTools?: string[];
|
|
995
|
+
requireObservations?: string[];
|
|
996
|
+
}
|
|
997
|
+
interface RenderGateReportOptions {
|
|
998
|
+
format?: "markdown" | "json" | "html" | "junit" | "github";
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
declare function parseGateList(value: string | undefined): string[];
|
|
1002
|
+
declare function parseGateNumber(value: string | undefined, label: string): number | undefined;
|
|
1003
|
+
|
|
1004
|
+
declare function gateHasThresholds(options: RunGateOptions): boolean;
|
|
1005
|
+
|
|
1006
|
+
declare function runGate(runs: readonly SessionRunRecord[], options: RunGateOptions): Promise<GateResult>;
|
|
1007
|
+
|
|
1008
|
+
declare function renderGateSummaryMarkdown(result: GateResult): string;
|
|
1009
|
+
declare function renderGateGithubStepSummary(result: GateResult): string;
|
|
1010
|
+
declare function renderGateJUnit(result: GateResult): string;
|
|
1011
|
+
declare function renderGateReport(result: GateResult, options?: RenderGateReportOptions): string;
|
|
1012
|
+
|
|
1013
|
+
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, ObservedOutcome, 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, extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents, 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 };
|
|
@@ -3,6 +3,7 @@ export { MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, TERMINAL_INDENT, TraceDir
|
|
|
3
3
|
import { buildRunSummary, extractMetadata } from './chunk-3USJVBLA.mjs';
|
|
4
4
|
export { buildRunSummary, buildRunTimeline, buildRunWhatSummary, extractMetadata, renderRunWhat, renderTimeline } from './chunk-3USJVBLA.mjs';
|
|
5
5
|
import { parseObservationFilter, extractOutcomesFromTraceEvents, extractOutcomesFromPersistedEvents } from './chunk-VFO76UH3.mjs';
|
|
6
|
+
export { extractOutcomesFromPersistedEvents, extractOutcomesFromTraceEvents } from './chunk-VFO76UH3.mjs';
|
|
6
7
|
import './chunk-BT7CATSD.mjs';
|
|
7
8
|
import { escapeHtml } from './chunk-CAWPF22J.mjs';
|
|
8
9
|
import { resolveRedactionProfile, readTraceEventsFromFile } from './chunk-ULCGIRTC.mjs';
|
|
@@ -440,9 +441,9 @@ async function searchTraces(metas, options) {
|
|
|
440
441
|
}
|
|
441
442
|
const limit = options.limit ?? 50;
|
|
442
443
|
const sessionId = options.session?.trim();
|
|
443
|
-
const
|
|
444
|
+
const observationStatus2 = parseObservationFilter(options.observation);
|
|
444
445
|
const hasContentFilter = Boolean(
|
|
445
|
-
options.status || stepTypeFilter || nameQuery || toolQuery || durationFilter ||
|
|
446
|
+
options.status || stepTypeFilter || nameQuery || toolQuery || durationFilter || observationStatus2
|
|
446
447
|
);
|
|
447
448
|
const results = [];
|
|
448
449
|
const sessionLabel = sessionId && sessionId !== "" ? sessionId : void 0;
|
|
@@ -487,9 +488,9 @@ async function searchTraces(metas, options) {
|
|
|
487
488
|
statusFilter: options.status
|
|
488
489
|
});
|
|
489
490
|
results.push(...stepMatches);
|
|
490
|
-
if (
|
|
491
|
+
if (observationStatus2) {
|
|
491
492
|
const outcomes = extractOutcomesFromTraceEvents(events);
|
|
492
|
-
const matched = outcomes.filter((outcome) => outcome.status ===
|
|
493
|
+
const matched = outcomes.filter((outcome) => outcome.status === observationStatus2);
|
|
493
494
|
for (const outcome of matched) {
|
|
494
495
|
results.push({
|
|
495
496
|
runId: m.runId,
|
|
@@ -1325,12 +1326,12 @@ function buildCriticalPath(runs, handoffs) {
|
|
|
1325
1326
|
handoffs.filter((edge) => edge.confidence === "explicit").map((edge) => edge.from)
|
|
1326
1327
|
);
|
|
1327
1328
|
const ordered = [...runs].sort(compareRuns);
|
|
1328
|
-
const
|
|
1329
|
+
const path7 = [];
|
|
1329
1330
|
const visited = /* @__PURE__ */ new Set();
|
|
1330
1331
|
const pushRun = (run, confidence, source) => {
|
|
1331
1332
|
if (visited.has(run.runId)) return;
|
|
1332
1333
|
visited.add(run.runId);
|
|
1333
|
-
|
|
1334
|
+
path7.push({
|
|
1334
1335
|
runId: run.runId,
|
|
1335
1336
|
name: run.name,
|
|
1336
1337
|
startedAt: run.startedAt,
|
|
@@ -1355,7 +1356,7 @@ function buildCriticalPath(runs, handoffs) {
|
|
|
1355
1356
|
const confidence = explicitTargets.has(run.runId) || explicitSources.has(run.runId) ? "explicit" : "correlated";
|
|
1356
1357
|
pushRun(run, confidence, confidence === "explicit" ? "manual" : "inferred");
|
|
1357
1358
|
}
|
|
1358
|
-
return
|
|
1359
|
+
return path7;
|
|
1359
1360
|
}
|
|
1360
1361
|
function metaRunIdMatches(run, token, runById) {
|
|
1361
1362
|
const meta = extractSessionWorkflowMetadata(run.metadata);
|
|
@@ -2735,6 +2736,402 @@ function renderCohortReport(result, options = {}) {
|
|
|
2735
2736
|
return renderCohortSummaryMarkdown(result);
|
|
2736
2737
|
}
|
|
2737
2738
|
|
|
2738
|
-
|
|
2739
|
+
// packages/core/src/gate/parse.ts
|
|
2740
|
+
function parseGateList(value) {
|
|
2741
|
+
if (value === void 0 || value.trim() === "") return [];
|
|
2742
|
+
return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
2743
|
+
}
|
|
2744
|
+
function parseGateNumber(value, label) {
|
|
2745
|
+
if (value === void 0 || value.trim() === "") return void 0;
|
|
2746
|
+
const parsed = Number(value);
|
|
2747
|
+
if (!Number.isFinite(parsed)) {
|
|
2748
|
+
throw new Error(`Invalid ${label}: ${value}`);
|
|
2749
|
+
}
|
|
2750
|
+
return parsed;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
// packages/core/src/gate/evaluate.ts
|
|
2754
|
+
function percentile3(values, p) {
|
|
2755
|
+
if (values.length === 0) return void 0;
|
|
2756
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
2757
|
+
const idx = Math.min(
|
|
2758
|
+
sorted.length - 1,
|
|
2759
|
+
Math.max(0, Math.ceil(p / 100 * sorted.length) - 1)
|
|
2760
|
+
);
|
|
2761
|
+
return sorted[idx];
|
|
2762
|
+
}
|
|
2763
|
+
function hasThresholds(options) {
|
|
2764
|
+
return options.maxErrorRate !== void 0 || options.maxP95DurationMs !== void 0 || (options.forbidTools?.length ?? 0) > 0 || (options.requireObservations?.length ?? 0) > 0;
|
|
2765
|
+
}
|
|
2766
|
+
function gateHasThresholds(options) {
|
|
2767
|
+
return hasThresholds(options);
|
|
2768
|
+
}
|
|
2769
|
+
async function loadRunMetrics(runs) {
|
|
2770
|
+
const metrics = [];
|
|
2771
|
+
for (const run of runs) {
|
|
2772
|
+
if (run.filePath === void 0) continue;
|
|
2773
|
+
metrics.push(
|
|
2774
|
+
await computeCohortRunMetrics({
|
|
2775
|
+
runId: run.runId,
|
|
2776
|
+
filePath: run.filePath,
|
|
2777
|
+
metadata: run.metadata,
|
|
2778
|
+
status: run.status,
|
|
2779
|
+
durationMs: run.durationMs,
|
|
2780
|
+
groupKey: "all"
|
|
2781
|
+
})
|
|
2782
|
+
);
|
|
2783
|
+
}
|
|
2784
|
+
return metrics;
|
|
2785
|
+
}
|
|
2786
|
+
async function observationStatus(filePath, name) {
|
|
2787
|
+
const events = await readTraceEventsFromFile(filePath);
|
|
2788
|
+
const outcomes = extractOutcomesFromTraceEvents(events);
|
|
2789
|
+
const match = outcomes.find((item) => item.name === name);
|
|
2790
|
+
if (!match) return "missing";
|
|
2791
|
+
return match.status === "passed" ? "passed" : "failed";
|
|
2792
|
+
}
|
|
2793
|
+
async function evaluateGateThresholds(runs, options) {
|
|
2794
|
+
const checks = [];
|
|
2795
|
+
const readErrors = [];
|
|
2796
|
+
if (!hasThresholds(options)) {
|
|
2797
|
+
return { checks, readErrors };
|
|
2798
|
+
}
|
|
2799
|
+
if (runs.length === 0) {
|
|
2800
|
+
readErrors.push("No trace runs found in the gate directory.");
|
|
2801
|
+
return { checks, readErrors };
|
|
2802
|
+
}
|
|
2803
|
+
let runMetrics;
|
|
2804
|
+
try {
|
|
2805
|
+
runMetrics = await loadRunMetrics(runs);
|
|
2806
|
+
} catch (error) {
|
|
2807
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2808
|
+
readErrors.push(message);
|
|
2809
|
+
return { checks, readErrors };
|
|
2810
|
+
}
|
|
2811
|
+
if (options.maxErrorRate !== void 0) {
|
|
2812
|
+
const errors = runMetrics.filter((run) => run.error).length;
|
|
2813
|
+
const actual = runMetrics.length > 0 ? errors / runMetrics.length * 100 : 0;
|
|
2814
|
+
const ok = actual <= options.maxErrorRate;
|
|
2815
|
+
checks.push({
|
|
2816
|
+
id: "maxErrorRate",
|
|
2817
|
+
name: "Max error rate",
|
|
2818
|
+
ok,
|
|
2819
|
+
expected: options.maxErrorRate,
|
|
2820
|
+
actual: Math.round(actual * 10) / 10,
|
|
2821
|
+
message: ok ? `Error rate ${actual.toFixed(1)}% within limit ${options.maxErrorRate}%` : `Error rate ${actual.toFixed(1)}% exceeds limit ${options.maxErrorRate}%`
|
|
2822
|
+
});
|
|
2823
|
+
}
|
|
2824
|
+
if (options.maxP95DurationMs !== void 0) {
|
|
2825
|
+
const durations = runMetrics.map((run) => run.durationMs).filter((value) => typeof value === "number");
|
|
2826
|
+
const actual = percentile3(durations, 95);
|
|
2827
|
+
const ok = actual !== void 0 && actual <= options.maxP95DurationMs;
|
|
2828
|
+
checks.push({
|
|
2829
|
+
id: "maxP95Duration",
|
|
2830
|
+
name: "Max p95 duration (ms)",
|
|
2831
|
+
ok,
|
|
2832
|
+
expected: options.maxP95DurationMs,
|
|
2833
|
+
actual: actual ?? "n/a",
|
|
2834
|
+
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`
|
|
2835
|
+
});
|
|
2836
|
+
}
|
|
2837
|
+
for (const tool of options.forbidTools ?? []) {
|
|
2838
|
+
let violated = false;
|
|
2839
|
+
for (const run of runMetrics) {
|
|
2840
|
+
const used = run.toolChoices.includes(tool) || run.toolOrdering.includes(tool);
|
|
2841
|
+
if (used) {
|
|
2842
|
+
violated = true;
|
|
2843
|
+
checks.push({
|
|
2844
|
+
id: "forbidTool",
|
|
2845
|
+
name: `Forbid tool: ${tool}`,
|
|
2846
|
+
ok: false,
|
|
2847
|
+
expected: `not used`,
|
|
2848
|
+
actual: "used",
|
|
2849
|
+
runId: run.runId,
|
|
2850
|
+
message: `Forbidden tool "${tool}" used in run ${run.runId}`
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
if (!violated) {
|
|
2855
|
+
checks.push({
|
|
2856
|
+
id: "forbidTool",
|
|
2857
|
+
name: `Forbid tool: ${tool}`,
|
|
2858
|
+
ok: true,
|
|
2859
|
+
message: `Forbidden tool "${tool}" not used`
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
for (const observation of options.requireObservations ?? []) {
|
|
2864
|
+
for (const run of runs) {
|
|
2865
|
+
if (run.filePath === void 0) continue;
|
|
2866
|
+
try {
|
|
2867
|
+
const status = await observationStatus(run.filePath, observation);
|
|
2868
|
+
const ok = status === "passed";
|
|
2869
|
+
checks.push({
|
|
2870
|
+
id: "requireObservation",
|
|
2871
|
+
name: `Require observation: ${observation}`,
|
|
2872
|
+
ok,
|
|
2873
|
+
expected: "passed",
|
|
2874
|
+
actual: status,
|
|
2875
|
+
runId: run.runId,
|
|
2876
|
+
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}`
|
|
2877
|
+
});
|
|
2878
|
+
} catch (error) {
|
|
2879
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2880
|
+
readErrors.push(`Run ${run.runId}: ${message}`);
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
return { checks, readErrors };
|
|
2885
|
+
}
|
|
2886
|
+
function checksFromSuiteResult(suiteResult) {
|
|
2887
|
+
const checks = [
|
|
2888
|
+
{
|
|
2889
|
+
id: "suite",
|
|
2890
|
+
name: `Suite: ${suiteResult.suiteName}`,
|
|
2891
|
+
ok: suiteResult.ok,
|
|
2892
|
+
message: suiteResult.ok ? `Suite passed (${suiteResult.summary.passed} cases)` : `Suite failed (${suiteResult.summary.failed} failed, ${suiteResult.summary.errors} errors)`
|
|
2893
|
+
}
|
|
2894
|
+
];
|
|
2895
|
+
for (const suiteCase of suiteResult.cases) {
|
|
2896
|
+
if (suiteCase.status === "pass") continue;
|
|
2897
|
+
checks.push({
|
|
2898
|
+
id: "suite",
|
|
2899
|
+
name: `Case: ${suiteCase.id}`,
|
|
2900
|
+
ok: false,
|
|
2901
|
+
message: suiteCase.message ?? `Case status: ${suiteCase.status}`
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
return checks;
|
|
2905
|
+
}
|
|
2906
|
+
function resolveExitCode(input) {
|
|
2907
|
+
if (input.configError) return 2;
|
|
2908
|
+
if (input.readError) return 3;
|
|
2909
|
+
if (!input.ok) return 1;
|
|
2910
|
+
return 0;
|
|
2911
|
+
}
|
|
2912
|
+
function validateOptions(options) {
|
|
2913
|
+
const errors = [];
|
|
2914
|
+
const hasSuite = options.suitePath !== void 0 && options.suitePath.trim() !== "";
|
|
2915
|
+
const hasThresholds2 = gateHasThresholds(options);
|
|
2916
|
+
if (!hasSuite && !hasThresholds2) {
|
|
2917
|
+
errors.push(
|
|
2918
|
+
"No gate rules specified. Pass --suite or at least one threshold flag."
|
|
2919
|
+
);
|
|
2920
|
+
}
|
|
2921
|
+
if (hasThresholds2 && (options.traceDir === void 0 || options.traceDir.trim() === "")) {
|
|
2922
|
+
if (!hasSuite) {
|
|
2923
|
+
errors.push("Threshold flags require --dir <trace-directory>.");
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
if (options.maxErrorRate !== void 0 && options.maxErrorRate < 0) {
|
|
2927
|
+
errors.push("--max-error-rate must be a non-negative percentage.");
|
|
2928
|
+
}
|
|
2929
|
+
if (options.maxP95DurationMs !== void 0 && options.maxP95DurationMs < 0) {
|
|
2930
|
+
errors.push("--max-p95-duration must be a non-negative millisecond value.");
|
|
2931
|
+
}
|
|
2932
|
+
return errors;
|
|
2933
|
+
}
|
|
2934
|
+
function isConfigLoadError(error) {
|
|
2935
|
+
if (!(error instanceof Error)) return false;
|
|
2936
|
+
const ext = path3.extname(error.message);
|
|
2937
|
+
if (error.message.includes("Unsupported suite config extension")) return true;
|
|
2938
|
+
if (error.message.includes("TypeScript suite configs require")) return true;
|
|
2939
|
+
if (error.message.includes("No suite config found")) return true;
|
|
2940
|
+
if (error.message.includes("AI_SUITE_CONFIG")) return true;
|
|
2941
|
+
if (ext === ".ts" || ext === ".mts" || ext === ".cts") return true;
|
|
2942
|
+
return "diagnostics" in error;
|
|
2943
|
+
}
|
|
2944
|
+
async function runGate(runs, options) {
|
|
2945
|
+
const diagnostics = [];
|
|
2946
|
+
const checks = [];
|
|
2947
|
+
const validationErrors = validateOptions(options);
|
|
2948
|
+
if (validationErrors.length > 0) {
|
|
2949
|
+
return {
|
|
2950
|
+
ok: false,
|
|
2951
|
+
exitCode: 2,
|
|
2952
|
+
runCount: 0,
|
|
2953
|
+
checks,
|
|
2954
|
+
diagnostics: validationErrors
|
|
2955
|
+
};
|
|
2956
|
+
}
|
|
2957
|
+
let traceDir = options.traceDir?.trim();
|
|
2958
|
+
let suiteResult;
|
|
2959
|
+
if (options.suitePath !== void 0 && options.suitePath.trim() !== "") {
|
|
2960
|
+
try {
|
|
2961
|
+
suiteResult = await runSuite({
|
|
2962
|
+
configPath: options.suitePath,
|
|
2963
|
+
cwd: options.cwd
|
|
2964
|
+
});
|
|
2965
|
+
traceDir = traceDir ?? suiteResult.tracesDir;
|
|
2966
|
+
checks.push(...checksFromSuiteResult(suiteResult));
|
|
2967
|
+
} catch (error) {
|
|
2968
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2969
|
+
diagnostics.push(message);
|
|
2970
|
+
return {
|
|
2971
|
+
ok: false,
|
|
2972
|
+
exitCode: isConfigLoadError(error) ? 2 : 3,
|
|
2973
|
+
traceDir,
|
|
2974
|
+
suitePath: options.suitePath,
|
|
2975
|
+
runCount: 0,
|
|
2976
|
+
checks,
|
|
2977
|
+
diagnostics
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
if (gateHasThresholds(options)) {
|
|
2982
|
+
const thresholdDir = traceDir;
|
|
2983
|
+
if (thresholdDir === void 0 || thresholdDir.trim() === "") {
|
|
2984
|
+
return {
|
|
2985
|
+
ok: false,
|
|
2986
|
+
exitCode: 2,
|
|
2987
|
+
traceDir,
|
|
2988
|
+
suitePath: options.suitePath,
|
|
2989
|
+
runCount: runs.length,
|
|
2990
|
+
checks,
|
|
2991
|
+
diagnostics: ["Threshold evaluation requires a trace directory."],
|
|
2992
|
+
...suiteResult !== void 0 ? { suiteResult } : {}
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
const thresholdRuns = runs.length > 0 ? runs : [];
|
|
2996
|
+
const { checks: thresholdChecks, readErrors } = await evaluateGateThresholds(
|
|
2997
|
+
thresholdRuns,
|
|
2998
|
+
options
|
|
2999
|
+
);
|
|
3000
|
+
checks.push(...thresholdChecks);
|
|
3001
|
+
diagnostics.push(...readErrors);
|
|
3002
|
+
if (readErrors.length > 0) {
|
|
3003
|
+
const ok2 = checks.length > 0 && checks.every((item) => item.ok);
|
|
3004
|
+
return {
|
|
3005
|
+
ok: ok2,
|
|
3006
|
+
exitCode: resolveExitCode({
|
|
3007
|
+
ok: ok2,
|
|
3008
|
+
configError: false,
|
|
3009
|
+
readError: true
|
|
3010
|
+
}),
|
|
3011
|
+
traceDir: thresholdDir,
|
|
3012
|
+
suitePath: options.suitePath,
|
|
3013
|
+
runCount: thresholdRuns.length,
|
|
3014
|
+
checks,
|
|
3015
|
+
diagnostics,
|
|
3016
|
+
...suiteResult !== void 0 ? { suiteResult } : {}
|
|
3017
|
+
};
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
const ok = checks.length > 0 && checks.every((item) => item.ok);
|
|
3021
|
+
return {
|
|
3022
|
+
ok,
|
|
3023
|
+
exitCode: resolveExitCode({ ok, configError: false, readError: false }),
|
|
3024
|
+
traceDir,
|
|
3025
|
+
suitePath: options.suitePath,
|
|
3026
|
+
runCount: runs.length,
|
|
3027
|
+
checks,
|
|
3028
|
+
diagnostics,
|
|
3029
|
+
...suiteResult !== void 0 ? { suiteResult } : {}
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
// packages/core/src/gate/render.ts
|
|
3034
|
+
function escapeXml(value) {
|
|
3035
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
3036
|
+
}
|
|
3037
|
+
function renderGateSummaryMarkdown(result) {
|
|
3038
|
+
const lines = [];
|
|
3039
|
+
lines.push("# AgentInspect gate");
|
|
3040
|
+
lines.push("");
|
|
3041
|
+
lines.push(`Status: **${result.ok ? "PASS" : "FAIL"}** (exit ${result.exitCode})`);
|
|
3042
|
+
if (result.traceDir !== void 0) {
|
|
3043
|
+
lines.push(`Trace directory: \`${result.traceDir}\``);
|
|
3044
|
+
}
|
|
3045
|
+
if (result.suitePath !== void 0) {
|
|
3046
|
+
lines.push(`Suite config: \`${result.suitePath}\``);
|
|
3047
|
+
}
|
|
3048
|
+
lines.push(`Runs evaluated: ${result.runCount}`);
|
|
3049
|
+
lines.push("");
|
|
3050
|
+
if (result.diagnostics.length > 0) {
|
|
3051
|
+
lines.push("## Diagnostics");
|
|
3052
|
+
for (const item of result.diagnostics) lines.push(`- ${item}`);
|
|
3053
|
+
lines.push("");
|
|
3054
|
+
}
|
|
3055
|
+
lines.push("## Checks");
|
|
3056
|
+
for (const check of result.checks) {
|
|
3057
|
+
const flag = check.ok ? "PASS" : "FAIL";
|
|
3058
|
+
lines.push(`- [${flag}] ${check.name}: ${check.message}`);
|
|
3059
|
+
}
|
|
3060
|
+
lines.push("");
|
|
3061
|
+
return lines.join("\n").trimEnd();
|
|
3062
|
+
}
|
|
3063
|
+
function renderGateGithubStepSummary(result) {
|
|
3064
|
+
const lines = [];
|
|
3065
|
+
lines.push(`## AgentInspect gate: ${result.ok ? "PASS" : "FAIL"}`);
|
|
3066
|
+
lines.push("");
|
|
3067
|
+
lines.push("| Check | Status | Details |");
|
|
3068
|
+
lines.push("| --- | --- | --- |");
|
|
3069
|
+
for (const check of result.checks) {
|
|
3070
|
+
lines.push(
|
|
3071
|
+
`| ${check.name} | ${check.ok ? "pass" : "fail"} | ${check.message.replace(/\|/g, "/")} |`
|
|
3072
|
+
);
|
|
3073
|
+
}
|
|
3074
|
+
if (result.diagnostics.length > 0) {
|
|
3075
|
+
lines.push("");
|
|
3076
|
+
lines.push("**Diagnostics**");
|
|
3077
|
+
for (const item of result.diagnostics) lines.push(`- ${item}`);
|
|
3078
|
+
}
|
|
3079
|
+
return lines.join("\n").trimEnd();
|
|
3080
|
+
}
|
|
3081
|
+
function renderGateReportHtml(result) {
|
|
3082
|
+
const rows = result.checks.map(
|
|
3083
|
+
(check) => `<tr><td>${escapeHtml(check.name)}</td><td>${check.ok ? "PASS" : "FAIL"}</td><td>${escapeHtml(check.message)}</td></tr>`
|
|
3084
|
+
).join("");
|
|
3085
|
+
return `<!DOCTYPE html>
|
|
3086
|
+
<html lang="en">
|
|
3087
|
+
<head>
|
|
3088
|
+
<meta charset="utf-8" />
|
|
3089
|
+
<title>Gate report</title>
|
|
3090
|
+
<style>
|
|
3091
|
+
body { font-family: system-ui, sans-serif; margin: 2rem; }
|
|
3092
|
+
table { border-collapse: collapse; width: 100%; }
|
|
3093
|
+
th, td { border: 1px solid #ddd; padding: 0.5rem; text-align: left; }
|
|
3094
|
+
th { background: #f6f6f6; }
|
|
3095
|
+
</style>
|
|
3096
|
+
</head>
|
|
3097
|
+
<body>
|
|
3098
|
+
<h1>AgentInspect gate</h1>
|
|
3099
|
+
<p>Status: <strong>${result.ok ? "PASS" : "FAIL"}</strong> (exit ${result.exitCode})</p>
|
|
3100
|
+
<h2>Checks</h2>
|
|
3101
|
+
<table>
|
|
3102
|
+
<thead><tr><th>Check</th><th>Status</th><th>Details</th></tr></thead>
|
|
3103
|
+
<tbody>${rows}</tbody>
|
|
3104
|
+
</table>
|
|
3105
|
+
</body>
|
|
3106
|
+
</html>`;
|
|
3107
|
+
}
|
|
3108
|
+
function renderGateJUnit(result) {
|
|
3109
|
+
const failures = result.checks.filter((check) => !check.ok).length;
|
|
3110
|
+
const tests = result.checks.length;
|
|
3111
|
+
const cases = result.checks.map((check) => {
|
|
3112
|
+
if (check.ok) {
|
|
3113
|
+
return ` <testcase name="${escapeXml(check.name)}" classname="gate" />`;
|
|
3114
|
+
}
|
|
3115
|
+
return ` <testcase name="${escapeXml(check.name)}" classname="gate">
|
|
3116
|
+
<failure message="${escapeXml(check.message)}">${escapeXml(check.message)}</failure>
|
|
3117
|
+
</testcase>`;
|
|
3118
|
+
}).join("\n");
|
|
3119
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
3120
|
+
<testsuites tests="${tests}" failures="${failures}" errors="0" time="0">
|
|
3121
|
+
<testsuite name="agent-inspect-gate" tests="${tests}" failures="${failures}" errors="0" time="0">
|
|
3122
|
+
${cases}
|
|
3123
|
+
</testsuite>
|
|
3124
|
+
</testsuites>`;
|
|
3125
|
+
}
|
|
3126
|
+
function renderGateReport(result, options = {}) {
|
|
3127
|
+
const format = options.format ?? "markdown";
|
|
3128
|
+
if (format === "json") return JSON.stringify(result, null, 2);
|
|
3129
|
+
if (format === "html") return renderGateReportHtml(result);
|
|
3130
|
+
if (format === "junit") return renderGateJUnit(result);
|
|
3131
|
+
if (format === "github") return renderGateGithubStepSummary(result);
|
|
3132
|
+
return renderGateSummaryMarkdown(result);
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
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
3136
|
//# sourceMappingURL=advanced.mjs.map
|
|
2740
3137
|
//# sourceMappingURL=advanced.mjs.map
|