mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-26 09:41:10 +00:00
23 lines
817 B
TypeScript
23 lines
817 B
TypeScript
// Shared control seam for task-ledger and process-tool cancellation.
|
|
import { getProcessSupervisor } from "../process/supervisor/index.js";
|
|
import { getSession } from "./bash-process-registry.js";
|
|
|
|
export function isBackgroundExecSessionActive(sessionId: string): boolean {
|
|
const session = getSession(sessionId);
|
|
return Boolean(session?.backgrounded && !session.exited);
|
|
}
|
|
|
|
export function cancelBackgroundExecSession(sessionId: string): boolean {
|
|
const session = getSession(sessionId);
|
|
if (!session?.backgrounded || session.exited || session.finalizing) {
|
|
return false;
|
|
}
|
|
const supervisor = getProcessSupervisor();
|
|
const record = supervisor.getRecord(sessionId);
|
|
if (!record || record.state === "exited") {
|
|
return false;
|
|
}
|
|
supervisor.cancel(sessionId, "manual-cancel");
|
|
return true;
|
|
}
|