import type { SessionInboxAddress } from "#execution/session-inbox/address.js"; import type { DeliverPayload } from "#channel/types.js"; import type { StepCoordinates as PendingInputBatchEvent } from "#harness/session-machine/view.js"; import type { WorkflowAskRoute, ProxyInputRequest } from "#harness/proxy-input-requests.js"; import type { SessionStateMap } from "#harness/types.js"; import type { InputResolution } from "#protocol/message.js"; import type { InputResponse } from "#shared/input.js"; /** One proxied-child bucket of a routed deliver payload. */ export interface RoutedChildDelivery { readonly workflowAsk?: WorkflowAskRoute; readonly remote?: ProxyInputRequest["remote"]; readonly inputSource?: string; readonly childContinuationToken: string; readonly childSessionInbox?: SessionInboxAddress; /** The person's message whose text answered this bucket's question. */ readonly message?: DeliverPayload["message"]; readonly payload: { readonly inputResponses: readonly InputResponse[]; }; /** What forwarding this bucket resolves on the routing session. */ readonly resolved: ProxiedInputResolutions; } /** * The parent-visible requests one forwarded bucket resolves: those it answers, * plus the rest of a batch those answers complete. Each retires from the proxy * map, and the session announces them with one `input.resolved` at `event`, * the coordinates of the child batch's `input.requested`. */ export interface ProxiedInputResolutions { readonly event: PendingInputBatchEvent; readonly resolutions: readonly InputResolution[]; } /** * Outcome of splitting one deliver payload by the session's proxy map. * `forSelf` is the parent-local remainder (or `undefined` when fully * routed); `forChildren` carries one entry per descendant token. */ export interface RoutedDeliverPayload { readonly forChildren: readonly RoutedChildDelivery[]; readonly forSelf: DeliverPayload | undefined; readonly parentAction: { readonly kind: "cancel-turn"; } | undefined; } /** * Splits a deliver payload into parent-local and proxied-child buckets. * * With `resolveMessage`, a plain-text message is also resolved against the * first open request when a child asked it, whether a `ctx.ask()` question, a * tool approval, or a session-limit prompt: a matching option or permitted free * text answers that one request, and the message is consumed along with its * `context`. Otherwise the message stays with the parent. */ export declare function routeDeliverPayload(input: { readonly allowRoute?: (requestId: string, route: ProxyInputRequest) => boolean; readonly payload: DeliverPayload; readonly resolveMessage?: boolean; readonly state: SessionStateMap | undefined; }): RoutedDeliverPayload;