import { URI } from "../../../../../base/common/uri.js"; import { IAutomationRun } from "./automation.js"; /** Why dispatch ended without starting a session. */ export type AutomationDispatchFailure = /** The automation was deleted between invocation and dispatch. */ "deleted" /** The owning Agent Host cannot currently run this automation. */ | "targetUnavailable" /** The caller's token was cancelled before a session was created. */ | "cancelled" /** The host request or session creation failed; see `run.errorMessage` when available. */ | "error"; /** Outcome of the dispatch phase of {@link IAutomationRunner.runOnce}. */ export type IAutomationRunDispatch = /** Dispatch was acknowledged without a correlated run or session. */ { readonly kind: "accepted"; } /** The request may have been accepted, but its outcome needs reconciliation. */ | { readonly kind: "uncertain"; readonly message: string; } /** The host accepted the request and created a session for it. */ | { readonly kind: "started"; readonly run: IAutomationRun; readonly sessionResource: URI; } /** Another run already held the automation's run slot, so nothing was dispatched. */ | { readonly kind: "alreadyRunning"; readonly activeRun: IAutomationRun; } /** Dispatch ended without a session. `run` is set when a run row was recorded first. */ | { readonly kind: "notStarted"; readonly reason: AutomationDispatchFailure; readonly run?: IAutomationRun; }; /** Separate completion handles for manual dispatch feedback and subsequent host-lifecycle observation. */ export interface IAutomationRunOperation { /** Resolves once the host's dispatch settles. */ readonly whenDispatched: Promise; /** Resolves when lifecycle observation ends, including when observing the host fails. */ readonly whenCompleted: Promise; }