openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
28 lines (27 loc) • 1.61 kB
JavaScript
import { r as resolveScheduledPrincipal } from "./execution-context-CSnw8-kc.mjs";
//#region src/cron/bind-parent.ts
/**
* The parent key `automations bind` may record an incarnation for, or why it cannot.
* Only jobs the execution-context builder classifies as `unbound-parent` qualify, so
* binding never changes a job the builder already treats as operator or exact parent.
*/
function resolveCronBindParent(e) {
if (e.pluginCommand) return { refusal: "cron bind does not apply to plugin command automations." };
if (e.sessionTarget === "main") return { refusal: "cron bind does not apply to main-session automations." };
const t = resolveScheduledPrincipal(e, {
trigger: "cron",
agentId: e.agentId ?? ""
});
if ("error" in t) return { refusal: `cron bind cannot classify this automation: ${t.error}.` };
if (t.kind === "parent") return { refusal: "cron bind: this automation is already bound to its parent conversation." };
if (t.kind !== "unbound-parent") return { refusal: "cron bind only applies to automations linked to a parent conversation by session key alone." };
return { parentSessionKey: t.parentSessionKey };
}
/** Store-owner check repeated at commit: bind fills only an absent link for the same parent. */
function assertCronBindApplies(e, t) {
const n = resolveCronBindParent(e);
if ("refusal" in n) throw new TypeError(n.refusal);
if (n.parentSessionKey !== t.sessionKey) throw new TypeError("cron bind must run from this automation's parent conversation; this conversation is not its parent.");
}
//#endregion
export { resolveCronBindParent as n, assertCronBindApplies as t };