PARACOSM AGENTOS | API Reference v0.9.1202
Home Simulation API Docs GitHub npm
Home Simulation API Docs GitHub npm AgentOS Discord
paracosm - v0.9.1202
    Preparing search index...

    Interface SimulateOptions

    Options-bag for wm.simulate. Replaces the v0.8 positional form simulate(leader, options, keyPersonnel). Extends the full internal RunOptions (provider keys, economics, initial population, etc.) and adds actor + keyPersonnel so visitor-facing call sites need only one argument.

    interface SimulateOptions {
        _forkedFrom?: { atTurn: number; parentRunId: string };
        _resumeFrom?: KernelSnapshot;
        activeDepartments?: string[];
        actor: ActorInput;
        anthropicKey?: string;
        apiKey?: string;
        braveKey?: string;
        captureSnapshots?: boolean;
        cohereKey?: string;
        costPreset?: CostPreset;
        customEvents?: { description: string; title: string; turn: number }[];
        economics?: ResolvedEconomicsProfile;
        execution?: Partial<SimulationExecutionConfig>;
        firecrawlKey?: string;
        initialPopulation?: number;
        intervention?: {
            adherenceProfile?: { expected: number; risks?: string[] };
            category?: string;
            description: string;
            duration?: { unit: string; value: number };
            id: string;
            mechanism?: string;
            name: string;
            scenarioExtensions?: Record<string, unknown>;
            targetBehaviors?: string[];
        };
        keyPersonnel?: KeyPersonnel[];
        liveSearch?: boolean;
        maxTurns?: number;
        models?: Partial<SimulationModelConfig>;
        onEvent?: (event: SimEvent) => void;
        outputDir?: string;
        provider?: LlmProvider;
        scenario?: ScenarioPackage;
        searchEnv?: ProcessEnv;
        seed?: number;
        serperKey?: string;
        signal?: AbortSignal;
        startingEnvironment?: Record<string, string | number | boolean>;
        startingPolitics?: Partial<StartingPolitics>;
        startingResources?: Partial<StartingResources>;
        startingStatuses?: Record<string, string | boolean>;
        startTime?: number;
        stayOnProvider?: boolean;
        subject?: {
            conditions?: string[];
            id: string;
            markers?: {
                category?: string;
                id: string;
                interpretation?: string;
                value?: string;
            }[];
            name: string;
            personality?: Record<string, number>;
            profile?: Record<string, unknown>;
            scenarioExtensions?: Record<string, unknown>;
            signals?: {
                label: string;
                recordedAt?: string;
                unit?: string;
                value: string | number;
            }[];
        };
        tavilyKey?: string;
        timePerTurn?: number;
        writeOutputFile?: boolean;
    }

    Hierarchy (View Summary)

    Index
    _forkedFrom?: { atTurn: number; parentRunId: string }

    Internal-only: WorldModel.fork() sets this to thread the { parentRunId, atTurn } link onto the child run's metadata.forkedFrom. Not part of the public API; callers should use WorldModel.fork() rather than setting this directly.

    _resumeFrom?: KernelSnapshot

    Internal-only: WorldModel.fork() sets this to a KernelSnapshot that the orchestrator restores before running the first turn. Not part of the public API.

    activeDepartments?: string[]
    actor: ActorInput

    The actor whose decisions drive the simulation.

    anthropicKey?: string

    Anthropic API key.

    apiKey?: string

    OpenAI API key. Historical dashboard field name.

    braveKey?: string
    captureSnapshots?: boolean

    When true, the orchestrator captures KernelSnapshots into artifact.scenarioExtensions: kernelSnapshotsPerTurn, one at the end of every turn, which WorldModel.forkFromArtifact() branches from; and, for WorldModel.replay(), kernelSnapshotAtStart, the state the first between-turn step starts from, and kernelSnapshotsAfterProgression, one right after each turn's between-turn step, before the turn's events. Default false so normal runs stay lean: a run with snapshots holds two per turn and one more, each about 100 KB for a 100-agent Mars-shape run.

    cohereKey?: string
    costPreset?: CostPreset

    Cost-vs-quality switch for model routing. Defaults to 'quality' which keeps department agents on the flagship tier (gpt-5.4 / claude-sonnet-4-6) for reliable tool forging — ~$1-3 per 6-turn run on OpenAI. Set to 'economy' to drop every role to mid/cheap (gpt-4o departments, gpt-5.4-nano everything else; haiku on Anthropic) — ~$0.20-0.60 per 6-turn run on OpenAI, ~5-10× cheaper.

    Economy mode drops forge approval rate by roughly 10-20pp because the mid-tier model occasionally violates structured-output schemas the judge rejects. Use it for quick iteration / debugging / CI; use 'quality' (default) for publishable or production runs.

    Explicit models entries always win over the preset, so you can mix and match: { costPreset: 'economy', models: { departments: 'gpt-5.4' } } gives you cheap everything except departments.

    customEvents?: { description: string; title: string; turn: number }[]
    economics?: ResolvedEconomicsProfile
    execution?: Partial<SimulationExecutionConfig>
    firecrawlKey?: string
    initialPopulation?: number
    intervention?: {
        adherenceProfile?: { expected: number; risks?: string[] };
        category?: string;
        description: string;
        duration?: { unit: string; value: number };
        id: string;
        mechanism?: string;
        name: string;
        scenarioExtensions?: Record<string, unknown>;
        targetBehaviors?: string[];
    }

    The change tested on the subject (a treatment, a policy, a product change). The turn loop prints it in the same block as the subject and records it verbatim on RunArtifact.intervention.

    keyPersonnel?: KeyPersonnel[]

    Optional supporting cast for context retrieval. Default [].

    liveSearch?: boolean
    maxTurns?: number
    models?: Partial<SimulationModelConfig>
    onEvent?: (event: SimEvent) => void
    outputDir?: string

    The directory the run's output file (v3-<tag>-<timestamp>.json) is written to. Omitted, the run writes to PARACOSM_OUTPUT_DIR from process.env, else <cwd>/output. The server passes its runs directory, so a server started with its own env writes, reads, sweeps and wipes its runs in one directory.

    provider?: LlmProvider
    scenario?: ScenarioPackage

    The scenario the run plays. Omitted, the run plays Mars Genesis: its events, tables, hooks and research memory, the kernel it builds (landing-day supplies, declared ranges, starting world) and its start time (2035) when startTime is not given. The turn length is the exception: with no scenario and no timePerTurn, turns stay one year apart, not Mars's eight.

    searchEnv?: ProcessEnv

    The environment the run's web search reads a search key from (SERPER_API_KEY, FIRECRAWL_API_KEY, TAVILY_API_KEY, BRAVE_API_KEY, COHERE_API_KEY) when these options name none. Omitted, process.env. {} searches on the keys named here alone; the hosted demo passes it, so a run there never spends the host's search keys.

    seed?: number
    serperKey?: string
    signal?: AbortSignal

    Cancellation signal. When .aborted flips to true, the turn loop short-circuits at the next turn boundary, emits a sim_aborted event, and returns the partial result accumulated so far.

    Server wires this to an AbortController that fires after a grace period of zero connected SSE clients, so a user who closes the tab or navigates away stops billing for new LLM calls while preserving the partial results they already accumulated in the event buffer.

    startingEnvironment?: Record<string, string | number | boolean>
    startingPolitics?: Partial<StartingPolitics>

    Caller overlay on the kernel's starting politics; see startingResources.

    startingResources?: Partial<StartingResources>

    Caller overlay on the kernel's starting metrics: only the values given are applied, over the engine's base values and the scenario's own declarations.

    startingStatuses?: Record<string, string | boolean>
    startTime?: number
    stayOnProvider?: boolean

    Keep every model call on the resolved provider: AgentOS's fallback chain to another provider is off (fallbackProviders: []), and a provider with no key of its own is not swapped for another provider's environment key. The hosted demo sets it on every call it runs. Default false: a call on the environment's keys falls back as AgentOS's default chain does.

    subject?: {
        conditions?: string[];
        id: string;
        markers?: {
            category?: string;
            id: string;
            interpretation?: string;
            value?: string;
        }[];
        name: string;
        personality?: Record<string, number>;
        profile?: Record<string, unknown>;
        scenarioExtensions?: Record<string, unknown>;
        signals?: {
            label: string;
            recordedAt?: string;
            unit?: string;
            value: string | number;
        }[];
    }

    The subject of the run (a person, an organization, a character). The turn loop prints it, with the intervention, in a block that each department's system text, each decision request and each Event Director prompt carry, and records it verbatim on RunArtifact.subject. Alone, without an intervention, it is the subject's baseline. The run's start (the commander's system text, its opening message and the promotions) reads neither. A fork applies only what its own call passes.

    tavilyKey?: string
    timePerTurn?: number
    writeOutputFile?: boolean

    Whether to write the run's output file. Defaults to true. False returns the artifact without writing a file and leaves scenarioExtensions.outputPath unset.