UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

28 lines (27 loc) • 1.45 kB
export function unjudgedAllowRefused(req, by) { return { action: "deny", message: by === "blanket" ? `approval required for "${req.toolName}" but the wired approver is a blanket "allow" (no ` + `judgment was applied) — this decision requires an actual auto-mode classifier verdict or a ` + `real approval callback, neither of which a blanket bypass can provide: ${req.message}` : `approval required for "${req.toolName}" but the wired approver answered by policy (no person judged) — ` + `this decision requires a person's approval or an actual auto-mode classifier verdict, neither of which ` + `a policy's answer is: ${req.message}`, decisionReason: "mode", settlement: { kind: "blanket_allow_refused", who: { party: "none" }, when: Date.now() }, }; } export function rowDemandsAPerson(cp) { return cp.gate.kind === "irreversible_ask" && cp.gate.realApproval !== undefined; } function demandsAPerson(question) { if ("gate" in question) return rowDemandsAPerson(question); if ("action" in question) return question.action === "ask" && question.requiresRealApproval === true; return question.status === "available" && question.verdict?.behavior === "ask"; } export function policyCannotAnswer(question, decidedBy) { return decidedBy === "policy" && demandsAPerson(question); }