@sema-agent/core
Version:
Stateless, task-oriented AI agent core
19 lines (18 loc) • 1.1 kB
JavaScript
export const UNAVAILABLE_LANDINGS = Object.freeze(["park", "close"]);
export function isUnavailableLanding(value) {
return UNAVAILABLE_LANDINGS.some((word) => word === value);
}
export function questionMayPark(question, durableQuestionFace) {
return !question || durableQuestionFace !== false;
}
export function unavailableLandingOf(facts) {
return facts.parkRoute && facts.suspendTargetGap === undefined && !facts.attemptFailed && questionMayPark(facts.question, facts.durableQuestionFace) ? "park" : "close";
}
export function readSuspendTargetGap(value) {
if (value === undefined)
return undefined;
if (typeof value === "string" && value.trim().length > 0)
return value;
const got = typeof value === "string" ? "a string with no visible character" : value === null ? "null" : `a value of type ${typeof value}`;
throw Object.assign(new Error(`runToolGate: ToolGateInput.suspendTargetGap is the leg's own sentence saying why it cannot hold a park — a string with a visible character, or absent (got ${got})`), { code: "config.invalid_argument" });
}