import type { MachineView, Session, SessionMachineAccess } from "@opengeni/sdk"; import type { OpenGeniText } from "./messages/runtime.js"; /** Whether a Connected Machine can take work right now. Offline, reconnecting * and enrolling machines cannot; a machine without screen-control consent can * still run compute. */ export declare function isMachineComputeSelectable(state: string): boolean; /** A machine-list response is useful only while it names the session's current pointer. */ export declare function currentSessionMachineAccess(access: SessionMachineAccess | null | undefined, activeSandboxId: string | null | undefined): SessionMachineAccess | null; export type SessionAdmissionReason = { /** The public reason; unknown future reasons arrive as their own string. */ reason: string; /** The refusal was a permission check (SQLSTATE 42501). */ permissionDenied: boolean; }; /** * The admission block a person should see, or null. Older servers omit the * projection, and a stale block on a session that is no longer waiting is * ignored. Never exposes raw database diagnostics. */ export declare function sessionAdmissionReason(session: Pick & { admissionBlock?: unknown; }): SessionAdmissionReason | null; /** * The block, if any, is the personal-machine refusal that waiting updates from * other people's work explain; another block keeps its own notice. */ export declare function sessionWaitingWorkExplainsBlock(reason: SessionAdmissionReason | null): boolean; /** The saved message was refused because only the machine's owner may start work on it. */ export declare function sessionAdmissionNeedsDifferentMachine(reason: SessionAdmissionReason | null, access: SessionMachineAccess | null | undefined): boolean; /** * Machines that can take the saved message. Accepted messages keep the * personal-resource permissions they were sent with, so a personal machine * chosen now could not run them: offer the session's own cloud machine and * workspace or organization machines that are reachable. */ export declare function savedMessageMachineChoices(machines: readonly MachineView[]): MachineView[]; /** * The saved message is the machine owner's own and was approved for other * machines, not the one the chat runs on now (for example, the chat moved * after it was sent). No recheck can start it here: it runs once the chat is * back on a machine it was approved for, or after it is removed and sent again. */ export declare function sessionAdmissionApprovedElsewhere(reason: SessionAdmissionReason | null, access: SessionMachineAccess | null | undefined): boolean; export type ApprovedMachineChoice = { sandboxId: string; /** The machine's name as the server reported it for the saved message. */ name: string; /** The same machine in the person's machine list, when it is there. */ machine: MachineView | null; /** The chat can move there now. */ available: boolean; }; /** * The machines the saved message was approved for, matched to the person's * machine list, the ones the chat can move to now first. Only the message's * sender gets names from the server; everyone else gets an empty list. */ export declare function savedMessageApprovedMachines(access: SessionMachineAccess | null | undefined, machines: readonly MachineView[]): ApprovedMachineChoice[]; export type ApprovedElsewhereCopy = { title: string; body: string; next: string; /** "Run it on …" for the machine the chat can move to now; null when there is none. */ action: string | null; }; /** * Words for a saved message that was approved for another machine. The * sender learns which machine and gets the one action that starts it there; * everyone else learns who can. Never offers a recheck: one can't pass here. */ export declare function sessionAdmissionApprovedElsewhereCopy(t: OpenGeniText, access: Pick, target: ApprovedMachineChoice | null): ApprovedElsewhereCopy; /** * Start the saved message on a machine it was approved for: move the chat * there, then one fenced recheck. The control fence does not depend on the * machine, so the move cannot make the recheck run anything twice. Resolves * to an error to show, or null once it moved and was rechecked; a failed * recheck throws (see `recheckSessionAdmission`). */ export declare function runSavedMessageOnMachine({ sandboxId, attach, recheck, failedMove, }: { sandboxId: string; attach: (sandboxId: string) => Promise; recheck: () => Promise; failedMove: string; }): Promise; export type SessionAdmissionCopy = { title: string; body: string; next: string; /** The recheck button label. */ action: string; }; /** Words for an admission block that is not (or not known to be) a machine-owner refusal. */ export declare function sessionAdmissionCopy(t: OpenGeniText, { reason, permissionDenied }: SessionAdmissionReason): SessionAdmissionCopy; /** After a refusal, the session moved to another machine: the saved message can be rechecked there. */ export declare function sessionAdmissionMachineChangedCopy(t: OpenGeniText): SessionAdmissionCopy; export type PersonalMachineCopy = { /** Whose machine this chat runs on, and who may start work there. */ explanation: string; /** What happens to the person's words, and the ways forward. */ next: string; /** A message the person can send the owner themselves; null for the owner. */ ownerRequest: string | null; /** "Copy request to …" button label; null for the owner. */ copyRequest: string | null; /** Before sending, for others: their agents' updates wait here too. */ workNote: string | null; }; /** * Explain a chat that runs on a personal machine. `queued` is a saved message * the runtime refused; otherwise it is a draft the person has not sent yet. */ export declare function personalMachineCopy(t: OpenGeniText, access: Pick, { queued }: { queued: boolean; }): PersonalMachineCopy; export type WaitingWorkCopy = { title: string; /** Whose machine this is, and why the updates wait. */ explanation: string; /** Who can do what about it. */ next: string; /** The owner's "continue" button label; null for everyone else. */ continueAction: string | null; }; /** * Explain updates from other people's work (their agents' messages and their * workers' results) that wait because the chat runs on somebody's personal * machine, or null when nothing waits. The owner gets the way to continue; * everyone else learns who can and why. */ export declare function waitingWorkCopy(t: OpenGeniText, access: Pick): WaitingWorkCopy | null; export type WaitingMessagesCopy = { title: string; /** Whose machine this is, and why the messages wait. */ explanation: string; /** What happens to them, and who can do what. */ next: string; }; /** * Explain messages other people sent that wait because the chat runs on * somebody's personal machine, or null when none wait. They never run there * on their own: the owner's next message brings them to the agent, and moving * the chat to a machine the sender may use runs them. */ export declare function waitingMessagesCopy(t: OpenGeniText, access: Pick): WaitingMessagesCopy | null; /** Stream, detail, and mutation receipts can arrive in different orders. */ export declare function admissionRecheckControl(sessionControl: Session["effectiveControl"], ...observed: (Session["effectiveControl"] | null | undefined)[]): Session["effectiveControl"]; export declare function admissionControlNeedsRefresh(control: Session["effectiveControl"], ...observed: (Session["effectiveControl"] | null | undefined)[]): boolean; /** * Recheck a blocked session: one fenced Resume (the server refuses it if the * session's control changed since `control` was read), then every read. A * rejected Resume refreshes the reads and is never replayed, so the saved * message cannot be sent twice. */ export declare function recheckSessionAdmission({ control, refreshOnly, resume, refresh, }: { control: Session["effectiveControl"]; refreshOnly: boolean; resume: (control: Session["effectiveControl"]) => Promise; refresh: (() => Promise)[]; }): Promise;