@sema-agent/core
Version:
Stateless, task-oriented AI agent core
20 lines (19 loc) • 1.14 kB
JavaScript
import { stampConfigInput } from "./config-refusal-input.js";
import { describeRejectedValue } from "./tool-search-setting.js";
export const DEPLOYMENT_SHAPES = Object.freeze(["isolated_sandbox", "own_device", "single_user_host"]);
export function screenDeploymentShape(shape, crossBoundaryPosture) {
if (shape === undefined)
return undefined;
const word = DEPLOYMENT_SHAPES.find((w) => w === shape);
const why = word === undefined
? `RunnerDeps.deploymentShape must be ${DEPLOYMENT_SHAPES.map((w) => `"${w}"`).join(", ")} when present (got ${describeRejectedValue(shape)}) — an unreadable shape is refused, never read as any shape or as none`
: crossBoundaryPosture === "multi_tenant"
? `RunnerDeps.deploymentShape "${word}" contradicts RunnerDeps.crossBoundaryPosture "multi_tenant" — a shape is declared only by a deployment with one owner; drop one of the two`
: undefined;
if (why === undefined)
return word;
const e = new Error(`${why} (refused at new Runner)`);
e.code = "config.deployment_shape";
stampConfigInput(e, "deps");
throw e;
}