import type { MachineView, Session, SessionMachineAccess } from "@opengeni/sdk"; import { type ApprovedMachineChoice, type SessionAdmissionReason } from "../session-admission-model.js"; import { type EmbeddedSessionClientOverride } from "../session-context.js"; import { type MachinesClientLike } from "./use-machines.js"; export type UseSessionStartOptions = EmbeddedSessionClientOverride & { session: Session; /** Re-read the session (and its queue) after a machine change or a recheck. */ onSessionChanged: () => Promise; /** * Reads the session's machines and moves the chat (`listMachines`, * `swapActiveSandbox`). Defaults to the session client when it has them; a * host proxy without them still gets the explanation, without choices. */ machinesClient?: MachinesClientLike | undefined; /** * Whether this viewer may read the workspace machines (`GET /machines`, * permission `enrollments:read`). Defaults to true. Pass false for a viewer * without it: nothing is requested and the notice offers no machine choice. */ machinesEnabled?: boolean | undefined; }; export type UseSessionStartResult = { /** The refused message's admission block, or null when nothing is blocked. */ reason: SessionAdmissionReason | null; /** The session's personal-machine projection for its current machine. */ machineAccess: SessionMachineAccess | null; /** The saved message was refused because only the machine's owner may start work there. */ needsDifferentMachine: boolean; /** * The person's own saved message was approved for another machine, not the * one the chat runs on now; a recheck can't start it here. */ approvedElsewhere: boolean; /** The machines it was approved for, the ones the chat can move to now first. */ approvedMachines: ApprovedMachineChoice[]; /** * Move the chat to a machine the saved message was approved for, then * recheck once. Resolves to an error to show, or null; throws when the * recheck could not be confirmed. Absent when moving isn't possible here. */ runOnApprovedMachine: ((sandboxId: string) => Promise) | undefined; /** The person's machines, as last read. */ machines: readonly MachineView[]; /** Move the chat without sending anything. Absent when moving isn't possible here. */ moveToMachine: ((sandboxId: string) => Promise) | undefined; /** The chat runs on somebody else's personal machine, so a new message could not start. */ warnBeforeSending: boolean; /** Machines the person may move the chat to (never another personal machine). */ machineChoices: MachineView[]; /** Moving is possible from this client. */ canChooseMachine: boolean; /** Move the chat. Resolves to an error to show, or null once it moved. Never resends. */ chooseMachine: (machine: MachineView) => Promise; /** A specific reason for the last refused move (for example, the machine went offline). */ machineChoiceError: string | null; /** One fenced Resume, then fresh reads. Throws when it could not be confirmed. */ recheck: () => Promise; /** * As the machine's owner, let the agent continue with other people's * waiting updates, then recheck a blocked chat (or just re-read). Absent * when the session client cannot. Throws when it could not be confirmed. */ continueWaitingWork: (() => Promise) | undefined; }; /** * Renderer-neutral state for explaining why a message can't start and the * allowed ways forward. Reads machines only while the chat is on a machine, * polls only while a refused message waits, and rechecks with one Resume * fenced on the session's control ETag, so the saved message is never sent * twice. Access control stays on the server. */ export declare function useSessionStart({ session, onSessionChanged, machinesClient, machinesEnabled, ...override }: UseSessionStartOptions): UseSessionStartResult;