import { TraceAnalystByteBudgets, TraceAnalysisStore } from '@tangle-network/agent-eval';
import { I as Iteration } from './types-ESeMOj94.js';
import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
export { A as AnalystLoopEvent, b as AnalystRegistryLike, c as AnalystRegistryStreamingLike, d as AutoApplyPolicy, F as FindingsStoreLike, I as ImprovementAdapter, e as ImprovementEditBatch, f as ImprovementReport, K as KnowledgeAdapter, g as KnowledgeProposalBatch, h as KnowledgeReport } from './types-BC3bZpH0.js';
import '@tangle-network/sandbox';

/**
 *
 * The read seam that closes the autonomous loop: project a round's `Iteration[]`
 * (each carrying its raw `SandboxEvent[]`) into an in-memory `TraceAnalysisStore`, the
 * read interface the trace analysts query. `runAnalystLoop` has had zero consumers
 * because nothing turned a loop's iterations into a store — this is that bridge.
 *
 * One iteration → one trace. The iteration is the root AGENT span; each `SandboxEvent`
 * becomes a child span (LLM for llm_call events, TOOL for tool events, else SPAN), so an
 * analyst can walk a shot's trace, cluster its errors, and emit findings the driver
 * steers on. Projection is best-effort over the FLAT SandboxEvent shape (no per-event
 * lineage yet — that's the richer-trace gap); it never fabricates — an errored iteration
 * surfaces a real ERROR span carrying the real message.
 *
 * @experimental
 */

/**
 * Build an in-memory `TraceAnalysisStore` over a loop round's iterations. Fail-loud on an
 * empty round — there is nothing for an analyst to read, and a silent empty store would
 * mask a broken capture path.
 */
declare function iterationsToTraceStore<Task, Output>(iterations: ReadonlyArray<Iteration<Task, Output>>, budgets?: TraceAnalystByteBudgets): TraceAnalysisStore;

/**
 * `runAnalystLoop` — the one call agent apps reach for to close the
 * recursive-self-improvement loop.
 *
 *   1. Load baseline findings (last run, or the slice the caller specifies)
 *   2. Run the analyst registry with priorFindings injected
 *   3. Persist the new run's findings to the ledger
 *   4. Diff the new run against the baseline
 *   5. Hand the findings to the knowledge adapter → proposals (and
 *      optionally apply them) → wiki edits
 *   6. Hand the findings to the improvement adapter → prompt / tool /
 *      scaffolding edits (review-only by default)
 *   7. Return a single report the consumer renders / persists / acts on.
 *
 * Adapters are optional: the loop works as a "run + diff + report"
 * primitive when no adapters are wired; it closes end-to-end when
 * both adapters are wired.
 */

declare function runAnalystLoop<TProposal = unknown, TEdit = unknown>(opts: RunAnalystLoopOpts): Promise<RunAnalystLoopResult<TProposal, TEdit>>;

export { RunAnalystLoopOpts, RunAnalystLoopResult, iterationsToTraceStore, runAnalystLoop };
