UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

31 lines (30 loc) • 1.13 kB
import { readOwnMembers } from "../thrown-value.js"; export function refusedBeforeRelease(occ) { return occ.life === "announced" && occ.startEmitted && occ.gateRounds.at(-1)?.disposition.kind === "denied"; } export function rowDetailsOf(details, notExecuted) { const carries = (() => { try { return details !== null && typeof details === "object" && !Array.isArray(details) && Object.keys(details).includes("notExecuted"); } catch { return false; } })(); if (!notExecuted && !carries) return details; const bag = { ...readOwnMembers(details) }; if (notExecuted) bag["notExecuted"] = true; else delete bag["notExecuted"]; return bag; } export function withRowNotExecuted(row, notExecuted) { return notExecuted ? { ...row, details: rowDetailsOf(undefined, true) } : row; } export function stampRowNotExecuted(result, notExecuted) { if (result === null || typeof result !== "object") return; const next = rowDetailsOf(result.details, notExecuted); if (next !== result.details) Reflect.set(result, "details", next); }