/** * Agent Instances Validator (Issue #869). * * Validates the `agentInstances` payload accepted by * `PATCH /api/worktrees/[id]`. Mirrors selected-agents-validator: returns a * structured `{ valid, value?, error? }` result instead of throwing, so the API * layer can map failures to 400 responses. * * Rules: * - 1..MAX_AGENT_INSTANCES entries (a worktree always keeps at least one). * - Each entry: valid instance id, valid CLI tool, alias string within length. * - Instance ids must be unique within the payload. * - When an instance id equals a CLI tool id (the primary anchor), its * `cliTool` must match that id, keeping `id === cliTool` consistent. * - `order` is normalized to the array position so drag-and-drop reordering * only needs to send the array in the desired order. */ import { type AgentInstance } from './cli-tools/types'; /** Minimum number of agent instances a worktree must retain (Issue #869). */ export declare const MIN_AGENT_INSTANCES = 1; /** What a refused roster is refused for: `limit` is the size, `entry` one of the rows. */ export type AgentInstancesRefusal = 'shape' | 'limit' | 'entry'; /** * Validate the `agentInstances` input from an API request body. * * @param input - Raw value from the request body (unknown for safety) * @returns Validation result with a normalized AgentInstance[] or an error */ export declare function validateAgentInstancesInput(input: unknown): { valid: boolean; value?: AgentInstance[]; error?: string; /** Issue #4458: set on a refusal, so a caller can tell the size from a bad row. */ refusal?: AgentInstancesRefusal; /** Issue #4458: with `refusal: 'entry'`, the position of the row refused. */ index?: number; }; /** * Whether `candidate` can be added to `base`, judged exactly as the roster write * (`PATCH /api/worktrees/[id]`) will judge the list that results (Issue #4458). The CLI * (`send --register`, `instances add`) asks this before it saves, so the limit, the room * left under it and the id rules have one definition, here, and not a copy in the CLI. * * @param base - The roster as read * @param candidate - The row to append * @returns The validation of `[...base, candidate]` */ export declare function validateAgentInstanceAddition(base: ReadonlyArray, candidate: unknown): ReturnType; /** * Whether `candidate` can be added to `base`, judging the candidate row and the room for * it only (Issue #4458, J1): the limit, the candidate's id (shape, and not already taken), * tool, primary anchor and alias, with the index and the sentence the whole-list check * would give it. The existing rows are not judged, so a bad one cannot hide what is wrong * with the candidate; they are the server's to answer for when the list is saved. On a * roster whose rows are all valid this is the verdict of {@link validateAgentInstanceAddition}. * * @param base - The roster as read * @param candidate - The row to append */ export declare function validateAgentInstanceCandidate(base: ReadonlyArray, candidate: unknown): { valid: boolean; error?: string; refusal?: AgentInstancesRefusal; index?: number; }; //# sourceMappingURL=agent-instances-validator.d.ts.map