@sema-agent/core
Version:
Stateless, task-oriented AI agent core
18 lines (17 loc) • 659 B
JavaScript
import { crossesNetworkInClear } from "@sema-agent/primitives";
const WATCHED = new WeakMap();
export function watchDefaultAdmission(origins, tell) {
if (origins.source === "default" && origins.entries.length > 0)
WATCHED.set(origins, { told: false, tell });
}
export function noteAdmittedSend(origins, endpoint) {
if (typeof origins !== "object" || origins === null)
return;
const watch = WATCHED.get(origins);
if (watch === undefined || watch.told)
return;
if (!crossesNetworkInClear(endpoint) || crossesNetworkInClear(endpoint, origins))
return;
watch.told = true;
watch.tell(endpoint.origin);
}