@runloop/remote-agents-sdk
    Preparing search index...

    Class CodexAxonConnection

    Native Codex app-server connection over an Axon channel.

    Like Claude, Codex requires an initialize handshake before it accepts requests: call connect, then initialize, then send a prompt and consume receiveTurn; the first send creates a server-side thread automatically.

    await connection.connect();
    await connection.initialize();
    await connection.send("Explain this repository");
    for await (const event of connection.receiveTurn()) console.log(event);
    Index

    Constructors

    Properties

    axonId: string
    devboxId: string

    Accessors

    • get currentTurnId(): string | undefined

      The in-flight turn id, set on turn/started and cleared on turn/completed.

      Returns string | undefined

    Methods

    • Compacts the active thread's context server-side (thread/compact/start).

      Returns Promise<void>

    • Opens the SSE transport and starts its read loop. Call initialize next — the app-server rejects requests until the handshake completes.

      Returns Promise<void>

      ConnectionStateError with terminated or already_connected.

    • Gracefully closes the transport and rejects pending requests. Idempotent.

      Returns Promise<void>

    • Runs the Codex app-server initialize handshake: sends the initialize request (client info + capabilities) and the initialized notification. Required once after connect — the app-server rejects all other requests with -32600 "Not initialized" until this completes. If the server was already initialized (e.g. by a previous session against the same process), that response is treated as success.

      Uses a longer timeout (120 s) because the app-server may still be starting.

      Parameters

      Returns Promise<void>

      ConnectionStateError If the connection is not reusable after a fatal broker error (code: "terminated").

      ConnectionStateError If connect has not been called yet (code: "not_connected").

      ConnectionStateError If the handshake has already completed (code: "already_initialized").

    • Interrupts the in-flight turn (turn/interrupt). The app-server requires the thread and turn ids, which the connection tracks from turn/started notifications. A no-op when no turn is in flight.

      Returns Promise<void>

      ConnectionStateError with not_connected if no thread is active.

    • Registers an approval handler. Without one, command/file approvals are accepted, legacy approvals are approved, user-input answers are empty, and requested permissions are granted for the turn. Handler timeouts are declined. Mounting with approval_policy=never avoids approval traffic.

      Parameters

      • method:
            | "item/commandExecution/requestApproval"
            | "item/fileChange/requestApproval"
            | "item/tool/requestUserInput"
            | "item/permissions/requestApproval"
            | "applyPatchApproval"
            | "execCommandApproval"
      • handler: ApprovalHandler

      Returns () => void

    • Parameters

      • params: AxonPublishParams

      Returns Promise<PublishResultView>

    • Resumes a known server-side thread and makes it current.

      Parameters

      • threadId: string

      Returns Promise<void>