import type { SessionAuthContext } from "#channel/types.js"; import type { ModelMessage } from "ai"; import type { getApprovalAuditState } from "#harness/hitl/candidates.js"; import { type AuthorizationChallenge } from "#harness/authorization.js"; import { type ResolvedInputBatch } from "#harness/input-request-resolution.js"; import type { StepInput } from "#harness/types.js"; import type { RuntimeWorkflowTaskRequest } from "#shared/action-types.js"; import type { InputRequest } from "#shared/input.js"; import type { Transition } from "#harness/session-machine/commit.js"; import { type ResolvedStepInput } from "./delivery.js"; import type { StepCoordinates, SuspendedStep } from "#harness/session-machine/view.js"; import { type SessionView } from "#harness/session-machine/view.js"; /** * A model response made calls that need a person's approval. The response waits in a suspended * step, beside any runtime calls it made, and the turn holds until the answers arrive. */ export declare function parkOnApprovals(view: SessionView, input: { readonly event: StepCoordinates; readonly messages: readonly ModelMessage[]; readonly requests: readonly InputRequest[]; readonly tasks: readonly RuntimeWorkflowTaskRequest[]; readonly responseAuthRequiredRequestIds?: readonly string[]; readonly requester?: SuspendedStep["requester"]; }): Transition; /** Approved workflow and agent calls join the runs their steps wait on, as their approvers. */ export declare function dispatch(view: SessionView, input: { readonly approvers: Readonly>; readonly tasks: readonly RuntimeWorkflowTaskRequest[]; }): Transition; /** * Approved calls run before the delivery's own input, as the AI SDK ran them: the model reads * their results first. The input waits in the queue, unreceived, for the step after. */ export declare function deferInput(view: SessionView, input: StepInput): Transition; /** What the approval-response policies did with a delivery, before `answer` reads it. */ export interface ResponsePolicyPass { readonly kind: "continue" | "continue-coordination" | "authorization-required" | "responses-completed" | "park"; readonly challenges: readonly AuthorizationChallenge[]; readonly feedback: readonly string[]; /** The delivery minus the answers the policies took, plus the settlements they reached. */ readonly stepInput?: StepInput; readonly audit: ReturnType; /** Responder sign-ins pending when the pass began. */ readonly challengesAtStart: readonly AuthorizationChallenge[]; } /** What `answer` concluded, beyond the events and state it changed. */ export interface Answered extends Transition { /** * `continue`: the step goes on. `park`: nothing can run until more input arrives. * `repeat`: a policy pass committed, so the next pass runs in a fresh step. `sign-in`: a * responder must sign in first. `defer-message`: a message arrived while the session-limit * prompt is open; it waits in its turn for the prompt. */ readonly next: "continue" | "park" | "repeat" | "sign-in" | "defer-message"; /** The turn's input, without the answers `answer` consumed. */ readonly input?: StepInput; /** Whether a plain-text answer consumed the message. */ readonly consumedMessage?: boolean; /** The batches the delivery resolved, in order. */ readonly resolved: readonly ResolvedInputBatch[]; /** A decision on the session-limit prompt. */ readonly limit?: { readonly granted: boolean; }; } /** * A delivery answers what the session asked. An approval batch resolves once every request in it * has a decision: approved calls become ready to run, denied ones get their denial as a result, * and `once()` approvals grant their key. A message steers the held turn instead: the first * pending batch resolves with the answers it has, and the rest are ignored. A session-limit * answer grants or declines a fresh budget. A partial answer waits, queued, for the rest. */ export declare function answer(view: SessionView, input: { readonly delivery: ResolvedStepInput | undefined; readonly policy: ResponsePolicyPass; /** The delivery merged the queue in, so the queue empties. */ readonly takeQueued: boolean; readonly approvalKey: (request: InputRequest) => string | undefined; /** * Whether the request's restored step has `eve__search`, which a call whose * tool is gone can use to find another. */ readonly searchable: (request: InputRequest) => boolean; }): Answered; /** Queued input that can run now, rather than wait for more answers. */ export declare function hasRunnableQueue(view: SessionView): boolean; /** Keys `once()` approvals granted, except those a pending approval still asks about. */ export declare function grantedApprovalKeys(view: SessionView, approvalKey: (request: InputRequest) => string | undefined): ReadonlySet; /** * The steps a delivery approves calls of, whose tools the calls run with: those it answers in * full, approving at least one call. */ export declare function approvingSteps(view: SessionView, stepInput: StepInput | undefined): readonly SuspendedStep[]; /** The suspended step that holds `requestId`. */ export declare function stepForRequest(view: SessionView, requestId: string): SuspendedStep | undefined; /** * The held turn moves on, steered or cancelled: the sign-ins it waits on end, declined, including * a responder's for one of its approvals. */ export declare function withdrawSignIns(view: SessionView, reason: string): Transition; /** * The session spent its budget: it asks whether to continue instead of calling the model, and * the turn ends. The prompt is the projection's open request; `answer` grants a * fresh budget or declines it. */ export declare function requestLimit(view: SessionView, input: { readonly request: InputRequest; }): Transition; /** * Work needs a sign-in. The calls that need it stop, settling `cancelled` until it completes; * an attempt it replaces fails; and each sign-in is asked for and recorded. The turn holds until * every sign-in calls back. Input that waited on a responder's sign-in stays queued for it. An * approved call that needs the sign-in leaves its step, so the model calls it again once the * sign-in completes. */ export declare function requireSignIn(view: SessionView, input: { readonly challenges: readonly AuthorizationChallenge[]; readonly callIdsByName?: ReadonlyMap; readonly queued?: StepInput; }): Transition;