UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

22 lines (21 loc) • 1.43 kB
const NOUNS = { tool_approval: { waiting: "the approval request", again: "resume it again", started: "the approved action", grant: "approval" }, question: { waiting: "the question", again: "resume it again", started: "the answered question", grant: "answer" }, plan_review: { waiting: "the plan review", again: "resume it again", started: "the approved plan", grant: "plan approval" }, resource_limit: { waiting: "the paused run", again: "resume it again", started: "the continued run", grant: "continuation" }, review: { waiting: "the review", again: "resume it again", started: "the reviewed step", grant: "review" }, task_done: { waiting: "the finished task", again: "wake it again", started: "the wake", grant: "wake" }, }; const UNKNOWN_KIND = { waiting: "the paused run", again: "resume it again", started: "the resumed step", grant: "decision" }; export function parkNounOf(row) { const pending = row?.pendingAction; if (pending === undefined) return UNKNOWN_KIND; if (pending.kind === "tool_approval" && pending.origin === "content_question") return NOUNS.question; return Object.hasOwn(NOUNS, pending.kind) ? NOUNS[pending.kind] : UNKNOWN_KIND; } export function resumeCancelledSentence(when, row) { const noun = parkNounOf(row); return `the resume was cancelled ${when}: nothing ran, and ${noun.waiting} is still waiting — ${noun.again} to carry on`; }