import type { Database } from "./database.js"; /** Who can use a Connected Machine: everyone in its workspace, or one person. */ export type MachineAudience = "workspace" | "only_me"; /** * What the change does to one thing on the machine. move_off: the chat leaves * the machine (its files stay). keep: the owner's chat stays and keeps its * audience. pause: another person's schedule that runs on the machine; the new * owner's own schedules keep running with no change and are not listed. * make_only_me is no longer produced. remove_first: the same computer is * connected a second time; that copy has to be removed before the switch. */ export type MachineAudienceAction = "move_off" | "keep" | "make_only_me" | "pause" | "remove_first"; export type MachineAudienceItem = { kind: "chat" | "schedule" | "duplicate_connection"; action: MachineAudienceAction; sessionId?: string; scheduledTaskId?: string; enrollmentId?: string; workspaceId?: string; relation?: "other_member" | "owner_shared" | "owner_private" | "other_workspace"; visibility?: "user_private" | "workspace_shared"; title?: string | null; name?: string | null; ownerSubjectId?: string | null; /** A running turn in this chat stops for good. */ stopsTurn?: boolean; /** Commands the agent still runs there that stop. */ stopsCommands?: number; }; export type MachineAudienceSummary = { /** The owner's chats that keep working with no change. */ keptChats: number; /** The owner's shared chats that stay on the machine and stay shared. */ keptSharedChats: number; movedOffChats: number; /** No longer produced: always 0. */ schedulesMadeOnlyMe: number; schedulesPaused: number; stoppedTurns: number; stoppedCommands: number; /** People who get an inbox notice. */ notifiedPeople: number; }; export type MachineAudiencePreviewRecord = { enrollmentId: string; sandboxId: string; machineName: string; currentAudience: MachineAudience; targetAudience: MachineAudience; generation: number; ownerSubjectId: string; summary: MachineAudienceSummary; retiredRecordCount: number; items: MachineAudienceItem[]; /** False only when the same computer is connected a second time. */ ready: boolean; }; export type MachineAudienceRefusal = "machine_not_found" | "organization_machine" | "invalid_target" | "already_target" | "owner_not_member" | "owner_lacks_workspace_access" | "not_machine_owner"; export type MachineAudienceChangeRecord = { outcome: "changed"; enrollmentId: string; sandboxId: string; previousAudience: MachineAudience; audience: MachineAudience; ownerSubjectId: string | null; previousGeneration: number; generation: number; summary: MachineAudienceSummary; detachedSessionIds: string[]; keptSessionIds: string[]; stoppedAttemptIds: string[]; pausedScheduleIds: string[]; onlyMeScheduleIds: string[]; reauthorizedAttemptIds: string[]; retiredEnrollmentIds: string[]; } | { outcome: "blocked"; preview: MachineAudiencePreviewRecord; } | { outcome: "stale"; generation: number; } | { outcome: "refused"; refusal: MachineAudienceRefusal; }; type AudienceRequest = { accountId: string; /** The machine's home workspace (the route workspace). */ workspaceId: string; /** The authenticated caller. */ subjectId: string; enrollmentId: string; target: MachineAudience; /** Who will own the machine when the target is Only me. */ ownerSubjectId: string | null; }; /** * The plan for changing who can use one Connected Machine: everything the one * confirmation will do. Reads only; the change recomputes the same plan under * the machine lock and applies it. */ export declare function previewMachineAudienceChange(db: Database, input: AudienceRequest): Promise; /** * Change who can use one Connected Machine in place, in one transaction: move * other people's chats off, stop their running turns, pause or narrow the * schedules on it, notify the people affected and move the machine's * authority. The enrollment, sandbox, credentials and live connection are * kept, so the connected agent and the owner's running work carry on. */ export declare function changeMachineAudience(db: Database, input: AudienceRequest & { expectedGeneration: number; }): Promise; export {};