import type { PlatformAdapter } from '../../../platform/index.js'; import type { CommandResult } from './command-context.js'; import type { CommandActionRouter } from '../../interactions/command-action-router.js'; /** Seams for {@link cancelBgHolds} — injected in tests, defaulted to the real registry/adapter. */ export interface BgHoldCancelDeps { heldSessions?: (channel: string) => string[]; killPooled?: (channel: string) => boolean; abortHold?: (sessionId: string) => boolean; } /** Stop the web background-task hold(s) on a channel; returns the number stopped. * * Why this exists: a bg-held session is logically running (the UI shows Stop) but its execution * has ALREADY been torn down — `holdWebForBg` is installed after `teardownExecution` removed the * entry from `runningExecutions`. So the channel-keyed cancel below found zero executions and * returned 0, and Stop was a silent no-op: the click resolved ok, nothing changed, and the session * stayed "Background" until the grace / max-wait cap fired. * * Two things must happen, in this order: kill the pooled backend process that still owns the * background task (otherwise the work runs on and streams a continuation into a session the user * just stopped), then fire the hold's abort to seal running:false. The kill alone is not enough — * the adapter only delivers its interrupted-notification when work is still pending, so a hold * installed for finished-but-unnotified work would never be sealed by it. */ export declare function cancelBgHolds(channel: string, deps?: BgHoldCancelDeps): number; /** Cancel every live execution running on a channel; returns the number cancelled. Shared by the * no-arg / `--all` `!cancel` branches and the Web UI Stop path (ui-service `sessions.cancel`, wired * via the `cancelSessionRun` dep in entry/app.ts). Also ends a web background-task hold on the * channel — a held session has no live execution, so without this Stop did nothing (see * {@link cancelBgHolds}). Clears the conduit queue when anything ran. */ export declare function cancelChannelRuns(channel: string): Promise; export declare function createCancelHandler(cancelDispatchedTask: ((opts: { taskId: string; channel: string; }) => Promise<{ ok: boolean; message: string; }>) | null, router?: CommandActionRouter): (channel: string, adapter: PlatformAdapter, trimmedMessage: string) => Promise;