import { Command } from "commander"; /** Loose view of a /turn-state response — `phase` is `string` so an unknown * (future) phase is handled, not a type error. */ export interface AwaitTurnState { conversationId?: string; phase: string; report?: string; humanInput?: unknown; } /** What `await-turn` should do with one observed state. `null` means the turn * hasn't settled — keep polling. Terminal outcomes carry the exit code the * caller switches on. Exported so the mapping is unit-tested directly. */ export type AwaitTurnOutcome = { kind: "report"; exitCode: number; report: string; } | { kind: "json"; exitCode: number; json: unknown; } | { kind: "fail"; exitCode: number; json?: unknown; message: string; }; export declare function classifyTurnState(state: AwaitTurnState): AwaitTurnOutcome | null; export declare function editCredentialFields(opts: { vaultUserId?: string; vaultDomain?: string; }): { permissionedUserId?: string; authUrl?: string; }; /** Max length of a version note (mirrors the DB CHECK on * workflow_versions.version_note). */ export declare const MAX_VERSION_NOTE = 2048; /** Build the optional save body from --message. A trimmed, non-empty note * becomes { versionNote }; anything empty returns undefined so the backend * applies its "Saved from API" default. Over-length rejects client-side. */ export declare function buildSaveBody(opts: { message?: string; }): { versionNote: string; } | undefined; /** * --limit for `conversations get`. Two departures from parseLimit, both because * this limit never reaches the backend — it windows an array already in memory: * * 0 is meaningful (read the conversation row, skip the transcript), where * `builder messages` forwards its limit and a 0 there falls through to "no * limit" — the opposite. And there is no upper bound: parseLimit's ceiling * exists to keep a request sane, but nothing is requested here, and a limit * past the end of the transcript just means "all of it". */ export declare function parseTranscriptLimit(limit: string | undefined): number | undefined; export type BuilderResponseValue = string | number | boolean | null | Record; /** Parse typed stdin responses while preserving unquoted text as a string. */ export declare function parseBuilderResponseValue(rawValue: string): BuilderResponseValue; /** Reconcile the two ways `conversations get` can name a conversation. The * positional id and --conversation mean the same thing, so agreeing is fine and * disagreeing is a mistake worth failing on rather than silently picking one. */ export declare function pickConversationSelector(id: string | undefined, flag: string | undefined): string | undefined; /** * The pointer a whole-chain-dead 404 owes the caller. `builder messages` reads * the live turn log, which is gone once a conversation ends (or is cleared with * no live successor) — but the bucket transcript normally outlives it, so exit 4 * on its own hides a still-readable answer. Returns undefined for every error * but a gone-conversation 404. */ export declare function archiveFallbackHint(err: unknown, conversationId: string): string | undefined; export interface ChatTail { chat: unknown[]; total: number; limit: number | null; hasMore: boolean; } /** * Take the last `limit` messages, or all of them when no limit is given. * * Deliberately not a paginator. The archive route accepts no query params, so * every call re-signs the S3 URL and re-downloads the whole transcript * server-side — walking one in pages would cost a full fetch per page. `--output` * plus a local slice is the tool for anything deeper than "show me the end". */ export declare function tailChat(chat: unknown[], limit?: number): ChatTail; /** The archive route's response. Every artifact is optional: the row always * exists, the bucket objects may not. */ export interface ConversationArchive { conversation?: unknown; chat?: unknown; chat_error?: string | null; workflow_snapshot?: unknown; workflow_snapshot_error?: string | null; } /** * Shape the archive response for a machine reader: the metadata a caller needs * to decide what to fetch next comes first, the (potentially enormous) message * array last. The snapshot is dropped unless asked for — it duplicates * `workflows get` and dwarfs everything else in the payload. Sharing flags * (workflow_accessible, can_manage_sharing, can_reshare) are UI concerns and * are dropped; --output keeps the unfiltered response. * * `total` counts the messages after filtering, so it agrees with what `chat` * is a tail of. Dropped system messages are reported as `systemMessagesOmitted` * rather than silently vanishing. */ export declare function buildArchiveOutput(conversationId: string, raw: ConversationArchive, opts?: { limit?: number; snapshot?: boolean; includeSystem?: boolean; /** Path --output wrote the unfiltered response to, reported alongside the * other metadata rather than trailing the message array. */ file?: string; }): Record; export declare function registerBuilderCommands(program: Command): void;