UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

27 lines (26 loc) • 894 B
import { steerPriorityOf } from "../task-notification.js"; const humanInputOrdinals = new WeakMap(); export function nextHumanInputSeq(key) { let box = humanInputOrdinals.get(key); if (box === undefined) { box = { n: 0 }; humanInputOrdinals.set(key, box); } return ++box.n; } const acceptanceSeats = new WeakMap(); export function armAcceptance(record, publish) { let published; acceptanceSeats.set(record, () => (published ??= publish())); } export function announceAcceptance(record) { return acceptanceSeats.get(record)?.(); } export function sameAcceptedSteerInput(a, b) { return (a.payload === b.payload && a.trusted === b.trusted && steerPriorityOf(a) === steerPriorityOf(b) && a.actor?.id === b.actor?.id && a.actor?.hostAsserted === b.actor?.hostAsserted && a.actor?.issuer === b.actor?.issuer); }