mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
refactor(deadcode): privatize runtime test seams (#108338)
* refactor(sessions): privatize runtime test seams * refactor(commitments): privatize extraction test seams * refactor(flows): privatize doctor health seams * refactor(tasks): privatize registry test seams * build(commitments): bundle Docker test support * chore(deadcode): shrink runtime export baseline
This commit is contained in:
committed by
GitHub
parent
8d5592548b
commit
3d76a4af92
@@ -0,0 +1,47 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import "./runtime.js";
|
||||
import type { CommitmentExtractionBatchResult, CommitmentExtractionItem } from "./types.js";
|
||||
|
||||
type TimerHandle = ReturnType<typeof setTimeout>;
|
||||
|
||||
type CommitmentExtractionRuntime = {
|
||||
extractBatch?: (params: {
|
||||
cfg?: OpenClawConfig;
|
||||
items: CommitmentExtractionItem[];
|
||||
}) => Promise<CommitmentExtractionBatchResult>;
|
||||
resolveDefaultModel?: (params: { cfg: OpenClawConfig; agentId?: string }) => {
|
||||
provider: string;
|
||||
model: string;
|
||||
};
|
||||
setTimer?: (callback: () => void, delayMs: number) => TimerHandle;
|
||||
clearTimer?: (timer: TimerHandle) => void;
|
||||
forceInTests?: boolean;
|
||||
};
|
||||
|
||||
type CommitmentRuntimeTestApi = {
|
||||
configureCommitmentExtractionRuntime(next: CommitmentExtractionRuntime): void;
|
||||
drainCommitmentExtractionQueue(): Promise<number>;
|
||||
resetCommitmentExtractionRuntimeForTests(): void;
|
||||
};
|
||||
|
||||
function getTestApi(): CommitmentRuntimeTestApi {
|
||||
const api = (globalThis as Record<PropertyKey, unknown>)[
|
||||
Symbol.for("openclaw.commitmentRuntimeTestApi")
|
||||
];
|
||||
if (!api) {
|
||||
throw new Error("commitment runtime test API is unavailable");
|
||||
}
|
||||
return api as CommitmentRuntimeTestApi;
|
||||
}
|
||||
|
||||
export function configureCommitmentExtractionRuntime(next: CommitmentExtractionRuntime): void {
|
||||
getTestApi().configureCommitmentExtractionRuntime(next);
|
||||
}
|
||||
|
||||
export async function drainCommitmentExtractionQueue(): Promise<number> {
|
||||
return await getTestApi().drainCommitmentExtractionQueue();
|
||||
}
|
||||
|
||||
export function resetCommitmentExtractionRuntimeForTests(): void {
|
||||
getTestApi().resetCommitmentExtractionRuntimeForTests();
|
||||
}
|
||||
Reference in New Issue
Block a user