Files
openclaw/src/agents/subagent-registry-steer-runtime.ts
2026-05-02 01:05:29 +01:00

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;
}