UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

22 lines (21 loc) • 1.22 kB
import { receiptRefusal } from "./own-property-receipt.js"; export function peerTaskFramesDeclared(deps) { return deps.a2a?.peerTaskFrames === true; } export function readsTaskFrame(deps, frame) { return frame.task_type !== "peer_task" || peerTaskFramesDeclared(deps); } export function peerTaskFrameRefused(taskId) { return new Error(`peer_task notification ${taskId} refused: this deployment has not declared that its readers read peer_task frames (RunnerDeps.a2a.peerTaskFrames)`); } export function receiveA2aDeploymentSwitches(value, field) { if (value === undefined) return undefined; if (typeof value !== "object" || value === null || Array.isArray(value)) throw receiptRefusal(`${field} must be an object of switches when given — refused at new Runner rather than read as none`); const frames = Reflect.get(value, "peerTaskFrames"); if (frames !== undefined && typeof frames !== "boolean") { throw receiptRefusal(`${field}.peerTaskFrames must be a boolean when given (true: every reader of this deployment's task notifications reads peer_task frames) — refused at new Runner rather than read as false`); } return Object.freeze({ ...value }); }