import { z } from 'zod'; import { type StdioOutput, type TurnInfo, type TurnEventNotification, type UserInput } from '@cogitator-ai/app-server'; import type { CogitatorConfig } from '@cogitator-ai/types'; export declare const OUTPUT_FORMATS: readonly ["text", "json", "stream-json"]; export declare const INPUT_FORMATS: readonly ["text", "stream-json"]; export type OutputFormat = (typeof OUTPUT_FORMATS)[number]; export type InputFormat = (typeof INPUT_FORMATS)[number]; /** Exit codes of `cogitator run -p`: those of every command, and 3 for a turn left paused */ export declare const HEADLESS_EXIT: { readonly paused: 3; readonly ok: 0; readonly failed: 1; readonly usage: 2; }; /** The flags of `cogitator run` that belong to the headless mode */ export interface HeadlessFlags { print?: boolean; interactive?: boolean; outputFormat?: string; inputFormat?: string; resume?: string; fork?: boolean; sessionId?: string; jsonSchema?: string; sessionPersistence?: boolean; } /** What the headless mode runs with, its flags checked */ export interface HeadlessPlan { outputFormat: OutputFormat; inputFormat: InputFormat; resume?: string; fork: boolean; sessionId?: string; outputSchema?: Record; persistSessions: boolean; } /** * The headless plan of the flags, undefined without `-p`. Throws a {@link UsageError} for flags * that do not go together: headless flags without `-p`, `--fork` without `--resume`, stream-json * input without stream-json output, `-p` with `-i`, a schema that cannot be read */ export declare function headlessPlan(flags: HeadlessFlags, cwd?: string): HeadlessPlan | undefined; /** * The JSON Schema `--json-schema` names: inline JSON, or the path of a file holding it. It must * be an object the runtime reads as a response format */ export declare function readJsonSchema(value: string, cwd?: string): Record; /** Where sessions are kept without `memory.adapter`: `COGITATOR_SESSIONS_DB`, else in the home */ export declare function sessionsDbPath(env?: NodeJS.ProcessEnv): string; /** * The config with a session store: memory of the process alone when sessions are not kept, * even over a configured `memory.adapter`, else the config as it is with `memory.adapter`, else * SQLite at {@link sessionsDbPath} */ export declare function withSessionStore(config: CogitatorConfig, persist: boolean, env?: NodeJS.ProcessEnv): CogitatorConfig; declare const ResumeLineSchema: z.ZodObject<{ type: z.ZodLiteral<"resume">; decisions: z.ZodOptional; updatedArguments: z.ZodOptional>; remember: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ approved: z.ZodLiteral; reason: z.ZodOptional; remember: z.ZodOptional; }, z.core.$strip>]>>>; responses: z.ZodOptional>; defaultDecision: z.ZodOptional; updatedArguments: z.ZodOptional>; remember: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ approved: z.ZodLiteral; reason: z.ZodOptional; remember: z.ZodOptional; }, z.core.$strip>]>>; }, z.core.$strip>; /** A line of `--input-format stream-json`, read */ export type InputLine = { type: 'user'; input: UserInput[]; delivery?: 'steer' | 'followUp' | 'inject'; } | z.output | { type: 'interrupt'; }; /** * A line of stream-json input: `user` with a message (text, or parts with images, as Claude * Code's stream-json has them) and how to deliver it to a turn going on, `resume` with the * answers to a paused turn, or `interrupt` */ export declare function parseInputLine(value: unknown): { line: InputLine; } | { error: string; }; /** The exit code a turn ends the process with */ export declare function exitCodeOfTurn(turn: Pick, structuredMissing?: boolean): number; /** A line of `--output-format stream-json` for an event of a turn */ export declare function streamJsonEvent(notification: TurnEventNotification): Record; /** The `result` line a turn ends with, also the whole answer of `--output-format json` */ export declare function resultLine(turn: TurnInfo, options?: { structuredWanted?: boolean; }): Record; /** Stdout held for protocol output: console output goes to stderr until {@link restore} */ export interface ClaimedStdout { /** Writes `text` to stdout, in order, waiting for the stream to drain */ write(text: string): Promise; /** Resolves once everything written reached the stream */ drained(): Promise; /** Gives the console its stdout back */ restore(): void; } /** * Holds stdout for protocol output: `console.log`, `console.info` and `console.debug` (the CLI's * own messages and the runtime's logger) go to `stderr` instead, so a reader of stdout gets * protocol lines only */ export declare function claimStdout(stdout?: StdioOutput, stderr?: { write(text: string): unknown; }): ClaimedStdout; export {}; //# sourceMappingURL=headless.d.ts.map