import { M as MultiLayerVerifier, V as VerifyOptions, S as Severity } from '../multi-layer-verifier-DUZXrPDA.js';
import { c as RunCritic, a as RunTrace } from '../run-critic-CmMf05uV.js';
import { S as SemanticConceptJudgeOptions, a as SemanticConceptJudgeInput, B as BehavioralMetrics } from '../semantic-concept-judge-DSBB2Cfp.js';
export { C as CreateAnalystAiConfig, D as DEFAULT_TRACE_ANALYST_KINDS, b as DiffPolicy, F as FAILURE_MODE_KIND_SPEC, c as FINDING_SUBJECT_GRAMMAR_PROMPT, d as FINDING_SUBJECT_KINDS, e as FindingSubject, f as FindingSubjectKind, g as FindingSubjectStringSchema, h as FindingsDiff, i as FindingsStore, I as IMPROVEMENT_KIND_SPEC, K as KIND_EXPECTED_SUBJECTS, j as KNOWLEDGE_GAP_KIND_SPEC, k as KNOWLEDGE_POISONING_KIND_SPEC, P as PersistedFinding, l as SKILL_USAGE_ANALYST, m as SkillUsageAnalyst, n as SkillUsageRecord, o as SkillUsageReport, p as SkillUsageScanConfig, q as buildSkillUsageReport, r as createAnalystAi, s as defaultIsMaterial, t as diffFindings, u as emitSkillUsageFindings, v as parseFindingSubject, w as renderFindingSubject } from '../semantic-concept-judge-DSBB2Cfp.js';
import { b as JudgeFn, a as JudgeInput } from '../types-C7DGg5ex.js';
import { A as Analyst, h as AnalystSeverity, c as AnalystFinding } from '../types-B5x54y6n.js';
export { a as AnalystContext, g as AnalystCost, i as AnalystInputKind, j as AnalystRequirements, f as AnalystRunEvent, e as AnalystRunInputs, d as AnalystRunResult, b as AnalystRunSummary, k as ChatCallOpts, C as ChatClient, l as ChatRequest, m as ChatResponse, n as ChatTransport, o as CliBridgeTransportOpts, p as CreateChatClientOpts, D as DirectProviderTransportOpts, E as EvidenceRef, M as MockTransportOpts, R as RouterTransportOpts, S as SandboxSdkTransportOpts, q as computeFindingId, r as createChatClient, s as makeFinding } from '../types-B5x54y6n.js';
import { TCloud } from '@tangle-network/tcloud';
import { T as TraceAnalysisStore } from '../store-C1YxJDEK.js';
export { a as AnalystHooks, A as AnalystRegistry, b as AnalystRegistryOptions, B as BudgetPolicy, D as DefaultAnalystRegistryOptions, R as RegistryRunOpts, c as buildDefaultAnalystRegistry } from '../default-registry-GyE8X5SP.js';
export { A as ANALYST_SEVERITIES, C as CreateTraceAnalystKindOpts, R as RAW_FINDING_SCHEMA_PROMPT, a as RawAnalystFinding, b as RawAnalystFindingSchema, c as TraceAnalystGolden, T as TraceAnalystKindSpec, d as createTraceAnalystKind, p as parseRawFinding, r as renderPriorFindings } from '../kind-factory-X3eDYbKn.js';
import { L as LlmClientOptions } from '../llm-client-Bj7g0rqu.js';
import { AxFunction } from '@ax-llm/ax';
import '../verdict-C9MlYujm.js';
import '../schema-m0gsnbt3.js';
import '../store-BcFXE6LG.js';
import 'zod';
import '../run-record-CP2ObebC.js';
import '@tangle-network/agent-interface';
import '../errors-CzMUYo7b.js';
import '../raw-provider-sink-C46HDghv.js';

/**
 * Adapter factories — lift each existing agent-eval primitive into the
 * Analyst contract without re-implementing it.
 *
 * Five primitives, five factories. Each one:
 *   - Builds an Analyst with a stable id (caller chooses; defaults
 *     given), a sensible default `inputKind`, a version derived from
 *     the wrapped primitive's version + an adapter revision, and an
 *     `analyze()` that calls the primitive and lifts its output to
 *     AnalystFinding[] using `makeFinding()`.
 *   - Maps severities: the existing `Severity` ('critical' | 'major' |
 *     'minor' | 'info') projects onto AnalystSeverity ('critical' |
 *     'high' | 'medium' | 'low' | 'info'); 'major' → 'high', 'minor' →
 *     'medium'. Domain analysts that want finer-grained mapping override.
 *
 * Adapters never own state. Calling the same factory twice with the
 * same primitive instance is safe.
 */

declare function liftSeverity(s: Severity): AnalystSeverity;
interface VerifierAdapterOpts<Env> {
    id?: string;
    area?: string;
    verifier: MultiLayerVerifier<Env>;
    /**
     * The verifier expects an `env` per run. Adapters take it from
     * `AnalystRunInputs.custom[<id>]` via the registry's 'custom' routing.
     */
    options?: Omit<VerifyOptions<Env>, 'env'>;
}
declare function createVerifierAdapter<Env>(opts: VerifierAdapterOpts<Env>): Analyst<Env>;
interface RunCriticAdapterOpts {
    id?: string;
    area?: string;
    critic?: RunCritic;
    /** Optional threshold below which a dimension is reported as a finding. Default 0.5. */
    threshold?: number;
}
declare function createRunCriticAdapter(opts?: RunCriticAdapterOpts): Analyst<RunTrace>;
interface JudgeAdapterOpts {
    id?: string;
    area?: string;
    judge: JudgeFn;
    /** TCloud handle the JudgeFn calls. */
    tcloud: TCloud;
    /** Optional cost classification — most judges call an LLM. */
    cost?: Analyst['cost'];
    /** Optional threshold below which a JudgeScore becomes a finding. Default 6 (on 0-10 scale). */
    threshold?: number;
}
declare function createJudgeAdapter(opts: JudgeAdapterOpts): Analyst<JudgeInput>;
interface SemanticConceptJudgeAdapterOpts {
    id?: string;
    area?: string;
    options?: SemanticConceptJudgeOptions;
}
declare function createSemanticConceptJudgeAdapter(opts?: SemanticConceptJudgeAdapterOpts): Analyst<SemanticConceptJudgeInput>;

/**
 * `behavioralAnalyst` — a DETERMINISTIC analyst (cost.kind = 'deterministic',
 * never calls the LLM). It produces the efficiency/behavioral findings a
 * tolerant agentic analyzer (HALO) re-derives per run inside the model —
 * context bloat, output decay, tool monoculture, missing self-verification —
 * directly from arithmetic over spans (`computeTraceMetrics`).
 *
 * Why it matters: these findings are model-agnostic BY CONSTRUCTION (no model
 * in the loop), so they cannot return 0 on a weak model the way the Ax-RLM
 * does — and they are strictly more reliable than HALO, which spends tokens
 * re-deriving the same numbers and can hallucinate the trend. The agentic
 * RLM kinds remain for SEMANTIC findings that genuinely need a model; this
 * analyst owns the behavioral class.
 */

/**
 * Map computed signals → structured AnalystFindings. Pure: no LLM, no clock
 * dependence beyond `produced_at` (overridable for deterministic tests).
 */
declare function deriveEfficiencyFindings(metrics: BehavioralMetrics, opts?: {
    analystId?: string;
    producedAt?: string;
}): AnalystFinding[];
/** The deterministic behavioral/efficiency analyst (no LLM, any-model). */
declare function behavioralAnalyst(): Analyst<TraceAnalysisStore>;

/**
 * Forgiving pre-parse for analyst findings. Weak models routinely emit
 * schema-correct content in an unusable wrapper — fenced ```json blocks, a
 * single object where an array is expected, trailing commas. Measured: GPT-4o
 * drops to 0% usable output purely from markdown-fence wrapping
 * (arXiv:2605.02363). A five-line de-fence recovers most of it. This module is
 * the de-fence/coerce step that runs BEFORE Zod, so a recoverable finding is
 * repaired, not dropped.
 *
 * Pure + deterministic. No model, no network.
 */
/** Strip a ```lang ... ``` (or bare ``` ... ```) code fence, if the string is one. */
declare function stripCodeFences(text: string): string;
/**
 * Best-effort parse of a string into JSON. De-fences, drops trailing commas,
 * then `JSON.parse`. Returns `undefined` (never throws) when unrecoverable.
 */
declare function coerceJson(text: string): unknown;
/**
 * Coerce arbitrary actor/structurer output into an array of candidate finding
 * rows: a JSON string → parse; a single object → 1-element array; an array →
 * as-is; anything else → []. Callers still run each row through Zod
 * (`parseRawFinding`) — this only fixes the SHAPE, never invents fields.
 */
declare function coerceToFindingRows(raw: unknown): unknown[];

/** DESCRIPTIVE predicate: does the finding cite at least one observable
 *  (span/event/artifact) evidence ref. Useful for ranking evidence quality or
 *  rendering — it is NOT the steer gate. Evidence presence is the WRONG
 *  discriminator for steering: a legitimate trace-analyst observation may cite
 *  nothing (it would be wrongly rejected), and a judge verdict may cite an
 *  artifact (it would be wrongly admitted). Use `assertNoJudgeVerdict` to gate
 *  steering; use this only where "is this grounded in observable evidence" is the
 *  literal question. */
declare function isTraceObservable(finding: AnalystFinding): boolean;
/** True iff the finding is a JUDGE VERDICT (an acceptance score lifted into a
 *  finding), identified by provenance set at the lift site — independent of
 *  whatever evidence it cites. */
declare function isJudgeVerdict(finding: AnalystFinding): boolean;
/**
 * THE steer firewall. Fail-loud guard for any path that admits analyst findings
 * as STEERING input (the `f(trace)` role): rejects — naming the offenders — any
 * finding whose provenance is a judge verdict, rather than let `J` leak into the
 * loop. Returns the findings unchanged for chaining.
 *
 * Call this at the chokepoint where a detector that ALSO scores/gates has its
 * findings turned into a steer (the judge-and-steer dual-role case). It keys on
 * provenance, so it correctly admits evidence-less trace-analyst observations and
 * correctly rejects an artifact-citing judge verdict — the cases an evidence
 * check gets backwards.
 *
 * It is necessary, not sufficient: it stops PROVENANCE-tagged verdicts. A judge
 * whose output is laundered through a hand-built finding with no provenance flag
 * is out of its reach — provenance must be honestly set at every judge→finding
 * lift (today: createJudgeAdapter). That is why the integrity rule lives at the
 * lift site, and why ProposeContext.judgeScores?: never is the complementary
 * compile-time tripwire on the obvious direct channel.
 */
declare function assertNoJudgeVerdict(findings: ReadonlyArray<AnalystFinding>, context?: string): ReadonlyArray<AnalystFinding>;

/**
 * `structureFindings` — the deferred structuring pass (DSPy TwoStepAdapter /
 * HALO `synthesize_traces` analog). The agentic actor reasons FREE-FORM and
 * emits a prose `report` (which any model does reliably); this separate, cheap
 * call's ONLY job is to turn that report into `AnalystFinding[]`. Decoupling
 * reasoning from structuring is what makes the SEMANTIC findings model-agnostic
 * — the reasoning model never has to satisfy a strict typed-array contract
 * while it diagnoses.
 *
 * Forgiving: the response runs through `coerceToFindingRows` (de-fence, lift
 * single→array) before Zod, and on a zero-finding extraction from a substantive
 * report it reasks ONCE with the schema restated. Returns a typed outcome so a
 * legitimate "nothing to report" is distinguishable from a failed extraction
 * (no silent empty).
 */

interface StructureFindingsOptions {
    /** The actor's free-form diagnosis prose. */
    report: string;
    analystId: string;
    /** Coarse classification stamped on every extracted finding. */
    area: string;
    model: string;
    baseUrl: string;
    apiKey?: string;
    /** Max reask attempts after a zero/invalid extraction. Default 1. */
    maxReasks?: number;
    /** Test seam: inject a fetch (no network in unit tests). */
    fetchImpl?: LlmClientOptions['fetch'];
}
interface StructureFindingsResult {
    findings: AnalystFinding[];
    outcome: 'ok' | 'extraction_failed';
}
declare function structureFindings(opts: StructureFindingsOptions): Promise<StructureFindingsResult>;

/**
 * Pre-curated tool subsets for analyst kinds.
 *
 * The full trace-analyst tool set is seven functions. Most kinds only
 * need three or four. Picking from named groups instead of importing
 * the whole bundle keeps every kind's actor-context budget tight and
 * makes "what can this analyst see?" obvious at registration time.
 *
 * Each function in the group keeps its full `name`/`description` from
 * `buildTraceAnalystTools` — we filter, we don't re-implement.
 */

/** Named tool sets. Kinds pass `tools: TRACE_TOOL_GROUPS.failureForensics` etc. */
type TraceToolGroupName = 
/** All seven tools. Use for open-ended discovery kinds. */
'all'
/** Overview + paginated query + count. No deep reads. Cheap. */
 | 'discovery'
/** Discovery + viewTrace + viewSpans. Deep-read but no regex search. */
 | 'discoveryAndRead'
/** Discovery + search tools. For pattern-matching across many traces. */
 | 'discoveryAndSearch'
/** Discovery + viewSpans + searchSpan. Targeted-span work after another kind narrows down. */
 | 'targeted';
/**
 * Build the tool set for a named group bound to a specific trace store.
 *
 * `all` returns every tool. Other groups filter `buildTraceAnalystTools`
 * by name to the documented subset. An unrecognised group name throws —
 * silently returning all tools would defeat the cost-control point.
 */
declare function buildTraceToolsForGroup(group: TraceToolGroupName, store: TraceAnalysisStore): AxFunction[];

export { Analyst, AnalystFinding, AnalystSeverity, type JudgeAdapterOpts, type RunCriticAdapterOpts, type SemanticConceptJudgeAdapterOpts, type StructureFindingsOptions, type StructureFindingsResult, type TraceToolGroupName, type VerifierAdapterOpts, assertNoJudgeVerdict, behavioralAnalyst, buildTraceToolsForGroup, coerceJson, coerceToFindingRows, createJudgeAdapter, createRunCriticAdapter, createSemanticConceptJudgeAdapter, createVerifierAdapter, deriveEfficiencyFindings, isJudgeVerdict, isTraceObservable, liftSeverity, stripCodeFences, structureFindings };
