UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

26 lines (25 loc) • 1.16 kB
import { isTextContentHash } from "./canonical-json.js"; export function approvalRequestsPlanExit(pause, recordedMode) { return pause === "plan_review" && recordedMode === "plan"; } export function planReviewFactsOf(row) { const requestedByCallId = planReviewRequesterOf(row.pendingAction); const planContentHash = planReviewContentHashOf(row.pendingAction); return { ...(requestedByCallId !== undefined ? { requestedByCallId } : {}), ...(planContentHash !== undefined ? { planContentHash } : {}), ...(approvalRequestsPlanExit(row.pendingAction.kind, row.state.inheritedGate?.permissionMode) ? { approvalRequestsPlanExit: true } : {}), }; } export function planReviewRequesterOf(pendingAction) { if (pendingAction.kind !== "plan_review") return undefined; const id = pendingAction.requestedByCallId; return typeof id === "string" && id !== "" ? id : undefined; } export function planReviewContentHashOf(pendingAction) { if (pendingAction.kind !== "plan_review") return undefined; const hash = pendingAction.planContentHash; return isTextContentHash(hash) ? hash : undefined; }