import type { CommandResponse, SharedManagementSurface } from "pilotswarm-sdk"; type CommandResponseLike = CommandResponse & { version?: number; emittedAt?: number; }; export declare class CommandRejectedError extends Error { readonly cmd: string; readonly cmdId: string; readonly response: CommandResponseLike; constructor(response: CommandResponseLike); } export declare class CommandTimeoutError extends Error { readonly cmd: string; readonly cmdId: string; readonly timeoutMs: number; constructor(cmd: string, cmdId: string, timeoutMs: number); } /** * Send a command to a session's orchestration and wait for the orchestration's * response. * * The bare `mgmt.sendCommand(...)` call is fire-and-forget — it returns once the * command is enqueued, regardless of whether the orchestration ultimately * accepts it. Unknown commands (e.g. anything other than the orchestration's * recognized set: `set_model` / `list_models` / `get_info` / `done` / * `cancel` / `delete`) are queued, processed, and rejected with * `error: "Unknown command: ..."` written to KV — but the caller never sees * that error if it doesn't poll. * * This helper closes the loop: enqueue with a fresh `cmdId`, poll the * orchestration's KV-backed response channel until the response shows up, * then return the response or throw `CommandRejectedError` / * `CommandTimeoutError`. * * @param mgmt - management surface (either mode; direct-only in practice — web throws WEB_MODE_UNSUPPORTED on sendCommand) * @param sessionId - target session id * @param cmd - command name (e.g. "set_model") * @param args - command-specific arguments * @param opts.timeoutMs - max time to wait for the orchestration's response * (default 15s) * @param opts.pollIntervalMs - KV poll interval (default 200ms) * @param opts.signal - optional abort signal * @throws CommandRejectedError if the orchestration writes an `error` response * @throws CommandTimeoutError if no response shows up within `timeoutMs` */ export declare function sendCommandAndWait(mgmt: SharedManagementSurface, sessionId: string, cmd: string, args?: Record, opts?: { timeoutMs?: number; pollIntervalMs?: number; signal?: AbortSignal; }): Promise; export {}; //# sourceMappingURL=command.d.ts.map