import type { SessionAuthContext } from "#channel/types.js"; import type { TokenUsage } from "#shared/token-usage.js"; import type { ModelMessage } from "ai"; import type { AuthorizationChallenge } from "#harness/authorization.js"; import { type TaskToolCall } from "#execution/tasks/calls.js"; import type { SessionStateMap, StepInput } from "#harness/types.js"; import type { RuntimeWorkflowTaskRequest } from "#shared/action-types.js"; import { type SessionProjection } from "#protocol/session-projection.js"; import { type StepCoordinates, type SuspendedStep, type TurnState } from "./state.js"; export type { StepCoordinates, SuspendedStep, TurnState } from "./state.js"; export declare const SESSION_PROJECTION_STATE_KEY = "eve.harness.sessionProjection"; /** What a transition sees. */ export interface SessionView { readonly turn: TurnState; readonly projection: SessionProjection; /** Requests this session relays for a child session or a workflow run, by `requestId`. */ readonly relayedRequestIds: ReadonlySet; /** The sign-in attempts the session waits on, with what completing them needs. */ readonly signIns: readonly AuthorizationChallenge[]; /** The session's token usage so far, which its waiting and terminal events report. */ readonly usage: TokenUsage; } /** Reads the authoritative lifecycle facts saved alongside execution state. */ export declare function storedProjection(state: SessionStateMap | undefined): SessionProjection; /** Coordinates the next lifecycle event carries, and whether a turn is open. */ export interface TurnPosition { readonly sessionStarted: boolean; readonly sequence: number; readonly stepIndex: number; /** The open turn's id, or `""` between turns. */ readonly turnId: string; /** The open turn streamed assistant output, so steering can no longer restart it. */ readonly assistantOutputStarted?: boolean; } export declare function turnPosition(projection: SessionProjection): TurnPosition; /** The open turn's id, or the id the next turn takes. */ export declare function activeTurnId(position: Pick): string; export declare function isBetweenTurns(projection: SessionProjection): boolean; /** The index the open turn's next `step.started` takes. */ export declare function nextStepIndex(projection: SessionProjection): number; /** Input the session holds until it can run. */ export declare function queuedInput(state: SessionStateMap | undefined): StepInput | undefined; export declare function suspendedSteps(state: SessionStateMap | undefined): readonly SuspendedStep[]; /** The ids of calls that already have a result in `messages`. */ export declare function answeredCallIds(messages: readonly ModelMessage[]): ReadonlySet; /** Workflow and agent calls of `step` the runtime still runs. */ export declare function runningTasks(step: SuspendedStep): readonly RuntimeWorkflowTaskRequest[]; /** What the turn waits on the runtime for: dispatched runs and the task tool calls. */ export interface RuntimeWait { readonly event: StepCoordinates; readonly callIds: readonly string[]; readonly tasks: readonly RuntimeWorkflowTaskRequest[]; readonly taskToolCalls: readonly TaskToolCall[]; /** Who approved each task an approval started, by call id. */ readonly approvers: Readonly>; } /** The calls suspended steps wait on the runtime for, or `undefined` when none do. */ export declare function runtimeWait(state: SessionStateMap | undefined): RuntimeWait | undefined;