import type { SubagentInputRequestHookPayload } from "#channel/types.js"; import type { InputResolvedStreamEvent } from "#protocol/message.js"; import type { StepCoordinates as PendingInputBatchEvent } from "#harness/session-machine/view.js"; import type { HarnessSessionBase, SessionStateMap } from "#harness/types.js"; import { type InputOption, type InputRequestKind } from "#shared/input.js"; import { type SessionInboxAddress } from "#execution/session-inbox/address.js"; import type { RemoteAgentBinding } from "#eve-channel/support.js"; /** * Marks a request as a workflow tool run's `ctx.ask()` question, rather than a * child session's. Its answer goes to the run's control hook, which carries * every decision the session makes for the run, in order. */ export interface WorkflowAskRoute { readonly control: string; } /** The parts of a request a plain-text reply is resolved against. */ export interface ProxyInputReply { readonly allowFreeform?: boolean; readonly options?: readonly InputOption[]; } /** Routing and control metadata for one descendant-owned input request. */ export interface ProxyInputRequest { readonly remote?: RemoteAgentBinding & { readonly sessionId: string; }; readonly inputSource?: string; readonly workflowAsk?: WorkflowAskRoute; /** * The workflow tool run that relayed the request: its own `ctx.ask()` * question, or a request from a session it opened with `ctx.agent`. Nobody * can answer the request once that run ends. */ readonly runId?: string; /** Batch semantics are optional so sessions written before this field remain routable. */ readonly batch?: ProxyInputRequestBatch; readonly childContinuationToken: string; readonly childSessionInbox?: SessionInboxAddress; /** * Coordinates of the `input.requested` this session emitted for the request; * the `input.resolved` it emits once it routes the answer repeats them. */ readonly event: PendingInputBatchEvent; readonly kind: InputRequestKind; /** Lets the human-facing parent resolve a plain-text reply before proxying it by ID. */ readonly reply?: ProxyInputReply; } export interface ProxyInputRequestBatch { readonly approvalRequestIds: readonly string[]; readonly requestIds: readonly string[]; } /** * Whether the child, not this session, closes a relayed request. A child's tool approval can * refuse the person who answered, so it stays open here until the child's own `input.resolved` * or `approval.settled` arrives. This session closes every other relayed request once it * forwards the answer. */ export declare function resolvedByChild(kind: InputRequestKind): boolean; /** * The part of a child's `input.resolved` its parent relays: the requests the parent leaves for * the child to close. `undefined` when the parent already closed all of them. */ export declare function resolvedForParent(data: InputResolvedStreamEvent["data"]): InputResolvedStreamEvent["data"] | undefined; /** * Returns the proxy-routing map as a fresh `Map`. Never returns a live * reference so accidental mutation cannot corrupt session state. */ export declare function getProxyInputRequests(state: SessionStateMap | undefined): ReadonlyMap; /** * Returns true when the session is currently proxying one or more * HITL requests on behalf of a descendant subagent. */ export declare function hasProxyInputRequests(state: SessionStateMap | undefined): boolean; /** * Replaces prior entries for the destination and input source with the provided * ones. A child raising a fresh batch overwrites its prior batch so the * parent never keeps stale request metadata. Other sources' routes stay * independently answerable. */ export declare function upsertProxyInputRequests(input: { readonly inputSource?: string; readonly entries: readonly (readonly [requestId: string, route: ProxyInputRequest])[]; readonly forChildContinuationToken: string; readonly session: S; }): S; /** State-only variant for control-plane steps that already hold a durable projection. */ export declare function upsertProxyInputRequestState(input: { readonly inputSource?: string; readonly entries: readonly (readonly [requestId: string, route: ProxyInputRequest])[]; readonly forChildContinuationToken: string; readonly state: SessionStateMap | undefined; }): SessionStateMap | undefined; /** Removes every proxy route the predicate selects. */ export declare function clearProxyInputRequestsWhere(session: T, select: (route: ProxyInputRequest, requestId: string) => boolean): T; /** Removes only the request IDs whose responses were successfully forwarded. */ export declare function retireProxyInputRequests(session: T, requestIds: readonly string[]): T; /** * Projects a {@link SubagentInputRequestHookPayload} into the * `(requestId, route)` tuples the session stores. */ export declare function toProxyInputRequestEntries(payload: SubagentInputRequestHookPayload): readonly (readonly [requestId: string, route: ProxyInputRequest])[];