/** * Synchronous decisions, assertions and reports the `send` action makes between its * awaits, split out of `send.ts` (Issue #4128). Nothing here awaits: the waits stay * in the action, and only the judgement after them lives here. */ import type { SendOptions } from '../types'; import type { AutoYesContractPolicy, AutoYesSetResult, ChatMessage, TaskView } from '../types/api-responses'; import { toolPolicyDenialFromResponse } from '../utils/tool-policy-failure'; import type { RoleAssignmentInput } from '../../types/agent-roles'; import type { CommandTarget } from './command-target'; import type { RegisteredRelay, RelayEndpointArg } from './relays'; import type { SessionIdentity } from './whoami'; import type { RelayEndpoints } from './message-dispatch'; /** `--role` and `--no-role` were both given. */ export declare function assertRoleFlagChoice(bothRoleFlags: () => boolean): void; /** * Issue #4458: --register saves this id into the roster, and the roster write * refuses an id outside its rules. Refused here, by the same rule, before anything * is sent: after the send it could only be a warning. */ export declare function assertRegisterTargetId(register: boolean | undefined, instanceId: string | undefined): void; /** The instance id `--register` has to ask the server about before the send, or null. */ export declare function candidateRowTarget(register: boolean | undefined, instanceId: string | undefined): { instanceId: string; } | null; /** The tool `--register` records: `--agent`, else the instance id itself. */ export declare function registerToolOr(agent: string | undefined, instanceId: string): string; export declare function assertNoteAuthor(noteAuthor: SessionIdentity | null): void; export declare function isConditionalSend(options: SendOptions, expectedRole: Record | undefined): boolean; export declare function pinsSendTarget(options: SendOptions, conditional: boolean): boolean; /** * Issue #2771: claude is the exception to the exception. The deferral * exists so Auto-Yes does not answer copilot's `/model` interaction; a * claude model is a launch flag with no interaction to protect, and a * contract send must have Auto-Yes on BEFORE the worker starts working. */ export declare function defersAutoYes(options: SendOptions, agent: string | undefined): boolean; /** * Issue #4226 (P3-2): a --note send that arms Auto-Yes reads its state first, and * the state is read for a named instance. With none (`--agent` alone, nothing * pinned) there is nothing to read, ever: an input error, before any side effect. */ export declare function assertNoteAutoYesTarget(options: SendOptions, deferAutoYes: boolean, agent: string | undefined, instanceId: string | undefined): void; /** * Issue #4116: named before anything with a side effect, so a role that does * not exist leaves no task row and no armed Auto-Yes behind. */ export declare function assertRoleToolForSend(options: SendOptions, agent: string | undefined): void; export declare function relayTargetOf(worktreeId: string, pinsTarget: boolean, commandTarget: CommandTarget, options: SendOptions): { worktreeId: string; instance: string | undefined; agent: string | undefined; }; /** `--register --role` with the instance and role it names, or null when it does not run. */ export declare function roleRegistrationTarget(roleAssignment: RoleAssignmentInput | undefined, options: SendOptions, instanceId: string | undefined): { instanceId: string; role: RoleAssignmentInput; } | null; /** The `--reply-to` to resolve endpoints for first, or null when none has to be. */ export declare function relayEndpointsReplyTo(options: SendOptions, registersWithRole: boolean): string | null; /** What `--contract` left for the message and the grant, from the created task. */ export declare function contractTaskOutcome(task: { task: TaskView; message: string; contractPolicy: AutoYesContractPolicy | null; }, agent: string | undefined, instanceId: string | undefined): { taskId: string; content: string; contractPolicy: AutoYesContractPolicy | null; boundTaskId: string | undefined; }; export declare function shouldRegisterRelayBefore(options: SendOptions, conditional: boolean): boolean; export declare function isArmedNow(options: SendOptions, deferAutoYes: boolean): boolean; export declare function autoYesReadTarget(armsNow: boolean, conditional: boolean, options: SendOptions, agent: string | undefined, instanceId: string | undefined): { cliToolId: string | undefined; instanceId: string | undefined; } | null; export declare function autoYesStateTarget(target: { cliToolId: string | undefined; instanceId: string | undefined; } | null): { cliToolId: string; instanceId: string; } | null; export declare function initialPriorAutoYes(target: { cliToolId: string | undefined; instanceId: string | undefined; } | null, priorState: Partial | null): boolean | null; /** * Off when read, so it can only be armed if it is off still: overwriting a grant armed * since would make it this send's to withdraw. */ export declare function onlyIfOffFor(conditional: boolean, target: { cliToolId: string | undefined; instanceId: string | undefined; } | null, priorAutoYes: boolean | null): boolean; /** * Issue #4226: a --note send undoes its grant when mem refuses the note, which needs * the state before it. Not known, it stops here, before the grant (design §6.2). */ export declare function stopsForUnknownAutoYes(options: SendOptions, armsNow: boolean, priorAutoYes: boolean | null): boolean; export declare function shouldArmAutoYes(armsNow: boolean, priorAutoYes: boolean | null): boolean; /** * Issue #4132: a grant armed since that read. It is theirs: it stays as it * is, and this is now the send that found one on. */ export declare function isAutoYesRace(error: unknown, onlyIfOff: boolean): boolean; /** * Issue #4437 (re-instruction 3): the Auto-Yes route refuses antigravity with * its own 409 TOOL_POLICY_DENIED (#4436), and the relay of --reply-to with * RELAY_TOOL_POLICY_DENIED (#4449). The same refusal as the send's: exit 33, * reason first. */ export declare function autoYesDenialOf(error: unknown, agent: string | undefined, instanceId: string | undefined): ReturnType | null; /** Throw the policy refusal the Auto-Yes route answered with, else the error itself. */ export declare function rethrowAutoYes(error: unknown, denial: ReturnType | null): never; /** Issue #4449: the relay not opened yet is judged with the grant, before it is written. */ export declare function autoYesRelayEndpoint(relay: RegisteredRelay | undefined, relayEndpoints: RelayEndpoints | undefined): RelayEndpointArg | undefined; export declare function appliesAutoYesAfterSend(options: SendOptions, deferAutoYes: boolean, priorAutoYes: boolean | null): boolean; export declare function shouldRegisterRelayAfter(options: SendOptions, conditional: boolean): boolean; /** The `--note` write to make, or null when it does not run. */ export declare function noteToWrite(options: SendOptions, noteAuthor: SessionIdentity | null, relay: RegisteredRelay | undefined): { author: SessionIdentity; relay: RegisteredRelay; note: string; } | null; /** * Issue #4449 (I2): the message of a --contract send naming no target goes to the * target its task was judged and created for — the server reads it from the task, * so a default changed since the task is not resolved again. The body still names * nobody (#4116); a send that names its target already pins it. */ export declare function withBoundTask(sendBody: Record, boundTaskId: string | undefined): Record; export declare function reportSendNotes(sent: ChatMessage, worktreeId: string, agent: string | undefined, instanceId: string | undefined): void; /** Report a failed send the way this command always has. */ export declare function handleSendFailure(error: unknown, options: SendOptions, worktreeId: string): void; //# sourceMappingURL=send-action-support.d.ts.map