import { AgentBase, type SpawnPlan } from '../../../core/agent-base.js';
import type { AgentSendOpts } from '../../../core/types.js';
/** v1.2.143 — invalidate the binary cache so the next call re-probes
 *  from scratch. Used when a previously cached path turns up missing
 *  (ENOENT on spawn) — e.g. operator upgraded codex while agim was
 *  running and the old vendor dir got deleted. Exported for tests and
 *  for the ENOENT-recovery path inside `isAvailable`. */
export declare function resetCodexBinaryCache(): void;
export declare class CodexAdapter extends AgentBase {
    readonly name = "codex";
    readonly aliases: string[];
    readonly kind: "cli";
    /**
     * Override to bypass the codex wrapper's broken stdio handling — see
     * resolveCodexBinary() above. Falls back to "codex" (PATH lookup) if
     * native binary resolution fails.
     *
     * commandName drives `isAvailable()` (--version probe) AND the spawn binary,
     * so resolving here gets us both at once.
     */
    protected get commandName(): string;
    /**
     * v1.2.143 — override the default `--version` probe so that a stale
     * cached path (e.g. operator upgraded codex while agim was running
     * and the old vendor dir got deleted) self-heals: ENOENT triggers a
     * cache reset + one re-probe before reporting unavailable.
     *
     * Why: AgentBase's default isAvailable spawns commandName which goes
     * through `resolveCodexBinary` → cachedBinary. If cachedBinary points
     * at a deleted file, spawn errors with ENOENT every call until
     * restart. The settings/agents UI shows "未就绪" indefinitely even
     * though the operator's actual codex install is fine.
     */
    isAvailable(): Promise<boolean>;
    /**
     * Build the codex argv WITHOUT MCP -c flags. prepareCommand prepends MCP
     * args separately so the order is: `<-c global flags...> exec [resume <id>]
     * <exec flags...> <prompt>`. Codex's clap requires global flags ahead of
     * the subcommand, and the prompt has to be the trailing positional.
     */
    protected buildArgs(prompt: string, opts: AgentSendOpts): string[];
    /**
     * codex reads its project-level AGENTS.md from spawn cwd, so for IM calls we
     * pin to ~/.agim-workspaces/codex/. Non-IM calls (web/scheduler) keep
     * cwd undefined and inherit agim's cwd. See agent-cwd.ts for rationale.
     *
     * MCP sidecar injection: when we have an IM thread + the bus is up, prepend
     * `-c mcp_servers.imhub.{command,args,env}=...` to register the imhub MCP
     * sidecar for this invocation only. The runId env entry is registered on
     * the bus first so reminder.* RPCs from the sidecar route back to the
     * correct RunContext. Cleanup unregisters the runId after the spawn exits.
     *
     * Fallback path (no IM context, bus down, or IMHUB_APPROVAL_DISABLED=1):
     * just buildArgs(prompt, opts) — codex still works, just without imhub
     * MCP tools. Matches the existing claude-code/opencode fallback shape.
     */
    protected prepareCommand(prompt: string, opts: AgentSendOpts): Promise<SpawnPlan>;
    protected extractText(event: unknown): string;
    /**
     * Side-channel hook: capture session id (`thread.started`) and usage
     * (`turn.completed.usage`) without disrupting the text stream.
     */
    protected inspectEvent(event: unknown, opts: AgentSendOpts): void;
    protected handleError(_code: number, _stderr: string, errorMessage: string): string | null;
}
export declare const codexAdapter: CodexAdapter;
export declare const _testInternals: {
    buildArgs(adapter: CodexAdapter, prompt: string, opts?: AgentSendOpts): string[];
    prepareCommand(adapter: CodexAdapter, prompt: string, opts: AgentSendOpts): Promise<SpawnPlan>;
    extractText(adapter: CodexAdapter, event: unknown): string;
    inspectEvent(adapter: CodexAdapter, event: unknown, opts: AgentSendOpts): void;
};
//# sourceMappingURL=index.d.ts.map