/** * sim/runner.ts — one simulated-user session, assembled end to end: persona + * scenario in, a JSONL-able event stream + the final SessionFrame out. This is * to `pi-gui sim` what agent/runner.ts is to `pi-gui run`. * * Events (additive namespace, disjoint from the gui-use run contract): * {type:"sim_step", index, thought, actions, cost, record, error?} per step * {type:"sim_speak", text, to?} per speak * {type:"sim_result", status, steps, cost, report, report_card} terminal * * `record` is the full StepRecord and `report_card` the v1 metrics card — * both verbatim engine data, so a host process (e.g. an eval orchestrator) * can persist evidence without importing this package. */ import type { MutableModels, ThinkingLevel } from "@earendil-works/pi-ai"; import { type PiGuiExecutorOptions } from "./executor.ts"; import { type ModelUsage, type Part, type Persona, type Scenario, type SessionFrame, type SimRuntime } from "./models.ts"; export interface SimEvent { type: "sim_step" | "sim_speak" | "sim_result"; [key: string]: unknown; } export interface SimRunOptions { /** Planner model ("provider/model-id"); unset → PI_GUI_SIM_MODEL chain. */ model?: string; thinkingLevel?: ThinkingLevel | null; /** Grounding sub-loop knobs; `driver: "none"` runs pure cognition (no end). */ executor?: PiGuiExecutorOptions & { driver?: string; }; onEvent?: (event: SimEvent) => void; debug?: boolean; /** Test seam shared by planner and judge. */ models?: MutableModels; /** Test seam: a pre-assembled runtime instead of building a PiGuiExecutor. */ runtime?: SimRuntime | null; /** Resume from a prior session's frame (fork semantics: fresh verdict on top * of the carried history; sink.thread is rebuilt from the operate log). */ resumeFrame?: SessionFrame | null; /** Observation parts seeded before the opening (interview questions and * follow-up tasks arrive as world input, never as prompt rewrites). */ seed?: Part[] | null; } export interface SimRunResult { frame: SessionFrame; status: SessionFrame["status"]; steps: number; cost: ModelUsage; } export declare function runSimTask(persona: Persona, scenario: Scenario, opts?: SimRunOptions): Promise;