@sema-agent/core
Version:
Stateless, task-oriented AI agent core
22 lines (21 loc) • 992 B
JavaScript
import { observeThenableRejection } from "./safe-notify.js";
let malformedDelegationSeatAnnounced = false;
export function __resetMalformedDelegationSeatAnnouncement() {
malformedDelegationSeatAnnounced = false;
}
export function deliverDelegationLifecycle(seat, event, notifier, site) {
if (typeof seat === "function") {
const frame = Object.freeze(Object.assign(Object.create(null), event));
notifier.notify(() => observeThenableRejection(seat(frame), notifier, site), site);
return;
}
if (seat !== undefined && !malformedDelegationSeatAnnounced) {
malformedDelegationSeatAnnounced = true;
try {
console.warn(`The delegation-lifecycle sink (RunnerDeps.onDelegationLifecycle) holds ${seat === null ? "null" : typeof seat} — not a ` +
`function. Delegation spawn/terminal frames are NOT delivered until the wiring is fixed (omit the key, or wire a function).`);
}
catch {
}
}
}