UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

28 lines (27 loc) • 1.61 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) { const gate = Reflect.get(question, "gate"); const verdict = Reflect.get(question, "verdict"); const row = typeof gate === "object" && gate !== null && rowDemandsAPerson(question); const org = Reflect.get(question, "status") === "available" && typeof verdict === "object" && verdict !== null && Reflect.get(verdict, "behavior") === "ask"; return row || Reflect.get(question, "requiresRealApproval") === true || org; } export function policyCannotAnswer(question, decidedBy) { return decidedBy === "policy" && demandsAPerson(question); }