openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
21 lines (20 loc) • 578 B
JavaScript
//#region src/infra/mutation-authority.ts
/** Keep the first refusal across retries without changing its thrown value. */
function retainMutationAuthority(e) {
let t;
return (...n) => {
if (t) throw t.error;
try {
const t = e(...n);
if (t !== null && (typeof t === "object" || typeof t === "function") && typeof t.then === "function") {
Promise.resolve(t).catch(() => void 0);
throw new TypeError("mutation authority must be synchronous");
}
} catch (e) {
t = { error: e };
throw e;
}
};
}
//#endregion
export { retainMutationAuthority as t };