@sema-agent/core
Version:
Stateless, task-oriented AI agent core
39 lines (38 loc) • 2.72 kB
TypeScript
/**
* The derived-leg route pre-flight shared by prepareTask's two derived seats: the compaction-summary model (the
* driver's own seat, resolved before the offload prelude) and the auto-mode classifier model (the caps-and-workflow
* phase's arming). Moved whole out of the orchestrator so the phase reaches DOWN for it instead of the two callers
* spelling it twice. The judgment law and both announcements live in the brain's route adjudicator; this is the one
* guarded seat around them.
*/
import type { Model } from "../../internal/llm.js";
import type { RunnerDeps, TaskSpec } from "../types.js";
/**
* The derived-leg pairing pre-flight as ONE guarded seat: judge the derived model where its route
* differs from the primary's, announce what a broken pairing means for THIS seat (`onBrokenPairing` —
* one judgment, and the POSTURE is the deployment's), and ABSTAIN (keep the derived model) on ANY throw. The pre-flight is advisory — the brain's request gate re-runs the
* same law — so neither a throwing judge face nor a garbage catalog value (the route-identity
* normalization throws a TypeError on a non-string baseUrl) may widen into "task preparation
* failed": at the compaction seat the session is already acquired and the throw-cleanup contract
* is not yet armed, so a throw here would leak the acquired session view, and the garbage value
* still earns its loud refusal at the request gate the moment the derived leg is actually used.
* Returns whether the seat should fall back to the primary model.
*/
export declare function derivedRouteFallsBack(args: {
seat: string;
derived: Model;
primary: Model;
brain: RunnerDeps["brain"];
getApiKeyAndHeaders: TaskSpec["getApiKeyAndHeaders"];
onNotice: RunnerDeps["onNotice"];
/** The run this seat resolution belongs to; carried onto the notice as its routing key
* (the audience stays operator: correlation, not entitlement). Absent ⇒ nothing is fabricated. */
sessionId?: string;
/** The INVOCATION this seat resolution belongs to. The session cannot stand in for it: two
* runs of one session that both fall back on the same seat mint otherwise byte-identical lines. */
runId?: string;
/** What this seat's DEPLOYMENT asked for on a broken pairing. Absent / `"fall_back"`: swap and announce `route.fallback_to_primary`
* (the only posture a seat with no knob of its own has). `"refuse"`: keep the seat and announce `route.classifier_unroutable` — never
* quietly granting a fallback the deployment declined (`autoMode.classifierFallback: "none"`); announcing is why no swap is not no word. */
onBrokenPairing?: "fall_back" | "refuse";
}): Promise<boolean>;