mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-14 10:52:59 +00:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import type { SubagentRunRecord } from "./subagent-registry.types.js";
|
|
|
|
type ReplaceSubagentRunAfterSteerParams = {
|
|
previousRunId: string;
|
|
nextRunId: string;
|
|
fallback?: SubagentRunRecord;
|
|
runTimeoutSeconds?: number;
|
|
preserveFrozenResultFallback?: boolean;
|
|
};
|
|
|
|
type ReplaceSubagentRunAfterSteerFn = (params: ReplaceSubagentRunAfterSteerParams) => boolean;
|
|
|
|
type FinalizeInterruptedSubagentRunParams = {
|
|
runId?: string;
|
|
childSessionKey?: string;
|
|
error: string;
|
|
endedAt?: number;
|
|
};
|
|
|
|
type FinalizeInterruptedSubagentRunFn = (
|
|
params: FinalizeInterruptedSubagentRunParams,
|
|
) => Promise<number>;
|
|
|
|
let replaceSubagentRunAfterSteerImpl: ReplaceSubagentRunAfterSteerFn | null = null;
|
|
let finalizeInterruptedSubagentRunImpl: FinalizeInterruptedSubagentRunFn | null = null;
|
|
|
|
export function configureSubagentRegistrySteerRuntime(params: {
|
|
replaceSubagentRunAfterSteer: ReplaceSubagentRunAfterSteerFn;
|
|
finalizeInterruptedSubagentRun?: FinalizeInterruptedSubagentRunFn;
|
|
}) {
|
|
replaceSubagentRunAfterSteerImpl = params.replaceSubagentRunAfterSteer;
|
|
finalizeInterruptedSubagentRunImpl = params.finalizeInterruptedSubagentRun ?? null;
|
|
}
|
|
|
|
export function replaceSubagentRunAfterSteer(params: ReplaceSubagentRunAfterSteerParams) {
|
|
return replaceSubagentRunAfterSteerImpl?.(params) ?? false;
|
|
}
|
|
|
|
export async function finalizeInterruptedSubagentRun(params: FinalizeInterruptedSubagentRunParams) {
|
|
return (await finalizeInterruptedSubagentRunImpl?.(params)) ?? 0;
|
|
}
|