Files
openclaw/src/gateway/session-subagent-reactivation.ts
2026-03-26 23:11:00 +00:00

27 lines
858 B
TypeScript

import { getLatestSubagentRunByChildSessionKey } from "../agents/subagent-registry-read.js";
async function loadSessionSubagentReactivationRuntime() {
return import("./session-subagent-reactivation.runtime.js");
}
export async function reactivateCompletedSubagentSession(params: {
sessionKey: string;
runId?: string;
}): Promise<boolean> {
const runId = params.runId?.trim();
if (!runId) {
return false;
}
const existing = getLatestSubagentRunByChildSessionKey(params.sessionKey);
if (!existing || typeof existing.endedAt !== "number") {
return false;
}
const { replaceSubagentRunAfterSteer } = await loadSessionSubagentReactivationRuntime();
return replaceSubagentRunAfterSteer({
previousRunId: existing.runId,
nextRunId: runId,
fallback: existing,
runTimeoutSeconds: existing.runTimeoutSeconds ?? 0,
});
}