import { o as CapabilityAdapter, a7 as LLMClientFactory, X as IdGenerator, ai as Logger, Z as IdentityBindingInput, W as Host, c as AgentManifest, N as Event } from './host-DZMgvbfm.cjs';
import { B as BlueprintContract, A as Agent, h as AgentTrace, c as AgentInput } from './types-D3Ce5bAa.cjs';
import { M as MemoryAgentStorage, c as MemoryStorageSnapshot } from './memory-storage-DE7A70_p.cjs';
import 'zod';
import '@benkei/agent-runtime/storage';

/** In-memory `Host` and `createTestAgent` for testing agents in isolation. */

/** Look up the in-memory storage backing a test agent. */
declare function lookupStorage(did: string): MemoryAgentStorage | undefined;
/** Options for `createTestHost`. */
interface TestHostOptions {
    clock?: () => Date;
    random?: () => Uint8Array;
    ids?: IdGenerator;
    capabilities?: Record<string, CapabilityAdapter>;
    llm?: LLMClientFactory;
    logger?: Logger;
    masterKey?: Uint8Array;
}
/** A test host with access to its in-memory storages. */
interface TestHost extends Host {
    storages: Map<string, MemoryAgentStorage>;
}
/** Build an in-memory `Host` suitable for tests. */
declare function createTestHost(opts?: TestHostOptions): TestHost;
/** Input for `createTestAgent`. */
interface TestAgentInput {
    template: BlueprintContract;
    childSlug?: string;
    name: string;
    parentDid?: string;
    lifecycleState?: string;
    capabilities?: Record<string, CapabilityAdapter>;
    llm?: LLMClientFactory;
    host?: Partial<TestHostOptions>;
    identities?: IdentityBindingInput[];
}
/** Construct a ready-to-use agent backed entirely by in-memory infrastructure. */
declare function createTestAgent(input: TestAgentInput): Promise<Agent>;

/** Mock capability adapters for testing — deterministic, history-recording. */

/** Seed data for `mockMailAdapter`. */
interface SeedMail {
    from: string;
    subject: string;
    body: string;
    to?: string;
    id?: string;
    received_at?: string;
}
/** A mock adapter exposing its call history. */
type MockAdapter<H> = CapabilityAdapter & {
    history: H;
};
/** A mock mail adapter (`mail.read`, `mail.send`, `mail.draft`). */
declare function mockMailAdapter(seed?: SeedMail[]): MockAdapter<{
    outboundMails: Array<{
        to: string;
        subject: string;
        body: string;
    }>;
    reads: Array<{
        since?: string;
        limit?: number;
    }>;
}>;
/** Seed data for `mockAccountingAdapter`. */
interface SeedAccounting {
    invoices?: Array<{
        invoice_id: string;
        total: number;
        status?: string;
        date?: string;
    }>;
    customerName?: string;
}
/** A mock accounting adapter (invoices, payments, customer). */
declare function mockAccountingAdapter(seed?: SeedAccounting): MockAdapter<{
    invoicesCreated: Array<{
        customer_id: string;
    }>;
    paymentsCreated: Array<{
        customer_id: string;
        amount: number;
    }>;
}>;
/** A mock calendar adapter. */
declare function mockCalendarAdapter(): MockAdapter<{
    created: number;
}>;
/** A mock Telegram adapter. */
declare function mockTelegramAdapter(): MockAdapter<{
    sent: string[];
}>;
/** A mock WhatsApp adapter. */
declare function mockWhatsappAdapter(): MockAdapter<{
    sent: string[];
}>;
/** A mock document adapter. */
declare function mockDocumentAdapter(): MockAdapter<{
    classified: number;
}>;
/** A configurable adapter that responds to capabilities with fixed values. */
declare function staticAdapter(opts: {
    provides: string[];
    responses: Record<string, unknown | ((input: unknown) => unknown)>;
}): CapabilityAdapter;

/** Scripted, recorded, chained, and recording LLM client factories. */

/** One entry in an LLM script. */
type LLMScriptEntry = {
    tool: string;
    input: unknown;
} | {
    final: string;
} | {
    error: {
        code: string;
        message: string;
    };
};
/** A full LLM script. */
type LLMScript = LLMScriptEntry[];
/** A deterministic LLM driven by a fixed script (shared across the run). */
declare function scriptedLLM(script: LLMScript): LLMClientFactory;
/** Chain factories: when one runs out of script, the next takes over. */
declare function chainedLLM(...factories: LLMClientFactory[]): LLMClientFactory;
/** Replay LLM completions recorded as JSONL by `recordingLLM`. */
declare function recordedLLM(transcriptPath: string): LLMClientFactory;
/** Wrap a factory, appending each completion result to a JSONL transcript. */
declare function recordingLLM(target: LLMClientFactory, outputPath: string): LLMClientFactory;

/** Assertions over agent traces and agents. */

/** Assert that a capability was called, optionally with specific input. */
declare function assertToolCalled(trace: AgentTrace, name: string, withInput?: unknown): void;
/** Assert that the trace only used capabilities from the allowed list. */
declare function assertNoCapabilityLeak(trace: AgentTrace, allowed: string[]): void;
/** Assert that a knowledge section was written during the turn. */
declare function assertKnowledgeWritten(trace: AgentTrace, namespace: string, key: string): void;
/** Assert that the agent transitioned to a lifecycle state during the turn. */
declare function assertLifecycleTransition(trace: AgentTrace, to: string): void;
/** Assert the agent's event chain verifies. */
declare function assertEventChainValid(agent: Agent): Promise<void>;
/** Assert the agent's state can be rebuilt from its event log unchanged. */
declare function assertReconstructible(agent: Agent): Promise<void>;

/** Agent snapshot / restore and trace comparison. */

/** A captured agent snapshot. */
interface AgentSnapshot {
    manifest: AgentManifest;
    events: Event[];
    state: MemoryStorageSnapshot;
}
/** Capture a full snapshot of a testkit-backed agent. */
declare function snapshotAgent(agent: Agent): Promise<AgentSnapshot>;
/** Restore an agent from a snapshot into a fresh in-memory host. */
declare function restoreAgent(snapshot: AgentSnapshot, host?: Partial<TestHostOptions>): Promise<Agent>;
/** A structural diff between two agent traces. */
interface TraceDiff {
    toolCalls: {
        matched: number;
        aOnly: AgentTrace['toolCalls'];
        bOnly: AgentTrace['toolCalls'];
    };
    knowledgeWrites: {
        matched: number;
        aOnly: AgentTrace['knowledgeWrites'];
        bOnly: AgentTrace['knowledgeWrites'];
    };
    lifecycleTransitions: {
        matched: number;
        aOnly: AgentTrace['lifecycleTransitions'];
        bOnly: AgentTrace['lifecycleTransitions'];
    };
    finalText: {
        equal: boolean;
        diff?: string;
    };
    tokens: {
        aDelta: number;
        bDelta: number;
    };
    duration_ms: {
        a: number;
        b: number;
    };
}
/** Compute a structural diff between two agent traces. */
declare function compareTraces(a: AgentTrace, b: AgentTrace): TraceDiff;

/** The eval runner: runs assertion suites against a template. */

/** An assertion evaluated against an agent trace. */
type EvalAssertion = {
    kind: 'tool_called';
    name: string;
    with?: unknown;
} | {
    kind: 'lifecycle_transitioned';
    to: string;
} | {
    kind: 'knowledge_written';
    namespace: string;
    key: string;
} | {
    kind: 'document_added';
    slug?: string;
} | {
    kind: 'final_text_contains';
    substring: string;
} | {
    kind: 'no_capability_leak';
    allowed: string[];
};
/** Per-case setup. */
interface EvalCaseSetup {
    childSlug?: string;
    lifecycleState?: string;
    capabilities?: string[];
}
/** A knowledge section seeded into the agent's corpus before a case runs. */
interface SeedKnowledge {
    namespace: string;
    key: string;
    title?: string;
    body: string;
}
/** Fixtures supplied to a case. */
interface EvalFixtures {
    mail?: SeedMail[];
    knowledge?: SeedKnowledge[];
}
/** One eval case. */
interface EvalCase {
    name: string;
    setup: EvalCaseSetup;
    input: AgentInput;
    fixtures?: EvalFixtures;
    script?: LLMScript;
    assertions: EvalAssertion[];
}
/** A collection of eval cases. */
interface EvalSuite {
    suite: string;
    description?: string;
    cases: EvalCase[];
}
/** A single assertion failure. */
interface AssertionFailure {
    assertion: EvalAssertion;
    message: string;
}
/** The outcome of running an eval suite. */
interface EvalReport {
    suite: string;
    passed: number;
    failed: number;
    total: number;
    cases: Array<{
        name: string;
        passed: boolean;
        failures?: AssertionFailure[];
        trace?: AgentTrace;
    }>;
}
/** Options for the `EvalRunner`. */
interface EvalRunnerOptions {
    template: BlueprintContract;
    /**
     * How the LLM is driven per case:
     * - `scripted` — the case's `script` (deterministic, offline).
     * - `recorded` — replay a transcript from `recordingDir` (deterministic).
     * - `live` — call `liveClient`; if `recordingDir` is set, the run is also
     *   recorded so a later `recorded` run can replay it.
     */
    llmStrategy: 'scripted' | 'recorded' | 'live';
    recordingDir?: string;
    liveClient?: LLMClientFactory;
}
/** Runs eval suites against a template, asserting on observable trace facts. */
declare class EvalRunner {
    #private;
    constructor(options: EvalRunnerOptions);
    /** Run a suite (or load it from a YAML path) and produce a report. */
    run(suite: EvalSuite | string): Promise<EvalReport>;
}
/** Load and parse an eval suite from a YAML file. */
declare function loadEvalSuite(yamlPath: string): Promise<EvalSuite>;

export { type AgentSnapshot, type AssertionFailure, type EvalAssertion, type EvalCase, type EvalCaseSetup, type EvalFixtures, type EvalReport, EvalRunner, type EvalRunnerOptions, type EvalSuite, type LLMScript, type LLMScriptEntry, type MockAdapter, type SeedAccounting, type SeedKnowledge, type SeedMail, type TestAgentInput, type TestHost, type TestHostOptions, type TraceDiff, assertEventChainValid, assertKnowledgeWritten, assertLifecycleTransition, assertNoCapabilityLeak, assertReconstructible, assertToolCalled, chainedLLM, compareTraces, createTestAgent, createTestHost, loadEvalSuite, lookupStorage, mockAccountingAdapter, mockCalendarAdapter, mockDocumentAdapter, mockMailAdapter, mockTelegramAdapter, mockWhatsappAdapter, recordedLLM, recordingLLM, restoreAgent, scriptedLLM, snapshotAgent, staticAdapter };
