import { AgencyConfig } from "../config/config.js"; import { stageConfiguredAgent } from "./stageConfiguredAgent.js"; import { compile } from "../compiler/defaultSession.js"; import { spawn as realSpawn } from "child_process"; export type ResolvedAgentLaunch = { configOverrides: Partial; agentHome: string | null; /** A forwarded `--workdir `: the child's working directory, absolute. * It must be the SPAWN cwd — the agent's static initializers resolve * paths and discover agency.json against cwd before main() runs. */ workdir: string | null; budgetInput: { maxCost?: string; maxTime?: string; }; /** A forwarded `--config `; wins over the root-level `-c`. */ configPath?: string; /** Why the flags cannot be used together, or null. Only `--incognito` * with `--log` or `--trace` today. */ conflict: string | null; }; /** Launch behavior callers may set; test seams live in the separate * dependencies parameter, never here. */ export type AgentLaunchOptions = { /** An explicit root `-c ` — set only when the user wrote the flag * (cwd config discovery never sets it), which is the provenance the * staged configured compile needs. */ explicitConfigPath?: string; }; /** The launcher's environment seams, injectable for orchestration tests. * Every field is used by exactly the branch it controls. */ export type RunBundledAgentDependencies = { resolveAgentDir: (agentName: string) => string; fileExists: (file: string) => boolean; stageConfiguredAgent: typeof stageConfiguredAgent; compile: typeof compile; spawn: typeof realSpawn; exit: (code: number) => void; }; /** * The semantic result of the launcher pre-scan: trace/log projected into a * config override (the flag→config meaning lives in `applyCliFlags`; a bare * `--trace` maps to a per-run trace file in cwd, `--log stdout` to the stdout * sink), agent-home resolved to an absolute path (the child would otherwise * resolve a relative one against its own cwd) or null, and the raw budget * inputs for `resolveBudget` validation. Callers never interpret scanner * state, and the input array is never modified — the child always receives * the original argv. */ export declare function resolveAgentLaunchArgs(args: readonly string[]): ResolvedAgentLaunch; export declare function runBundledAgent(config: AgencyConfig, agentName: string, args?: string[], options?: AgentLaunchOptions, deps?: Partial): void;