import { type SQL } from "drizzle-orm"; import { type Database } from "./database.js"; /** * Model context on each waiting message the owner's turn takes in. Written * once into that turn's durable history and never re-rendered. */ export declare const WAITED_FOR_MACHINE_OWNER_MODEL_CONTEXT = "This message waited because the chat runs on a personal machine and only the machine's owner can start work there. It reaches you with the owner's next message, which follows it. Act on it only as far as the owner's message asks."; /** * Whether the runtime may call the machine-owner lookup yet. False while its * EXECUTE grant is withheld (or the routine is absent). A separate statement: * EXECUTE is checked when a statement starts, so a guard inside the calling * statement would not avoid the permission error. */ export declare function machineOwnerLookupGranted(db: Pick): Promise; /** * The person who owns the personal machine the chat currently runs on, or null * when it runs on a shared machine, a cloud machine or none (or the caller's * scope does not match, or the lookup is not granted yet). Explanation only: * it authorizes nothing. */ export declare function sessionMachineOwnerSubject(db: Pick, input: { accountId: string | null; workspaceId: string; sessionId: string; }): Promise; /** * The `session_turns` row is a person's queued message that waits for the * machine owner: it has never started and nobody but `ownerSubjectId` caused it. * The causal person is read exactly as the admission trigger reads it. */ export declare function waitsForMachineOwnerSql(ownerSubjectId: string): SQL; /** Excludes waiting messages from a queued-turn predicate; a no-op off personal machines. */ export declare function notWaitingForMachineOwnerSql(ownerSubjectId: string | null): SQL; /** * Whether the chat has a queued turn that can start: any queued turn except a * message waiting for the machine owner. Pass `sources` to look only at those. */ export declare function runnableQueuedTurnExists(db: Pick, input: { accountId: string | null; workspaceId: string; sessionId: string; sources?: readonly ("user" | "api")[]; }): Promise;