@sema-agent/core
Version:
Stateless, task-oriented AI agent core
28 lines (27 loc) • 1.47 kB
JavaScript
import { governanceBaselineProblem } from "./governance-baseline-validity.js";
export function isSelfOrchestrationActive(spec, deps) {
return spec.selfOrchestration === true && workflowsCapability(deps);
}
export function workflowsCapability(deps) {
return deps.workflowScriptRunner?.safeForUntrustedScripts === true && hasUsableGovernanceBaseline(deps);
}
function hasUsableGovernanceBaseline(deps) {
return governanceBaselineProblem(deps.workflowGovernanceBaseline) === null;
}
export function selfOrchestrationFailClosedReason(spec, deps) {
if (spec.selfOrchestration !== true)
return null;
if (isSelfOrchestrationActive(spec, deps))
return null;
const missing = [];
if (deps.workflowScriptRunner?.safeForUntrustedScripts !== true) {
missing.push("a hard WorkflowScriptRunner (RunnerDeps.workflowScriptRunner.safeForUntrustedScripts === true)");
}
const problem = governanceBaselineProblem(deps.workflowGovernanceBaseline);
if (problem !== null) {
missing.push(`a usable governance baseline (RunnerDeps.workflowGovernanceBaseline.${problem.where === "workflowGovernanceBaseline" ? "" : `${problem.where} `}` +
`is ${problem.found})`);
}
return (`self-orchestration (TaskSpec.selfOrchestration) requires ${missing.join(" and ")}; it is DISABLED for ` +
`this task (fail-closed — the run_workflow tool is not mounted and the orchestration prompt is not injected).`);
}