@sema-agent/core
Version:
Stateless, task-oriented AI agent core
49 lines (48 loc) • 3.18 kB
TypeScript
/**
* THE LAUNCH CHECK of a run that directs workers and reports to a person (a run that declares a member ledger,
* `TaskSpec.runLedger`): before it spends anything, read whether the leg has what such a run needs, item by item, and say so —
* refuse when it cannot do the job at all, narrow (and say how) when it can do part of it, never start a manager that can only
* repeat its workers' words without saying that it can.
*
* A pure function over facts the leg's prepare reads; each item `ok`, `missing`, or `unknown` (the fact could not be read here —
* never shown as missing, and never a reason to narrow or refuse).
*/
/** The items, in the order they are read. */
export declare const MANAGER_LAUNCH_ITEMS: readonly ["background_delegation", "report_tool", "read_hands", "worker_transcript", "worker_write_approval", "task_list"];
export type ManagerLaunchItem = (typeof MANAGER_LAUNCH_ITEMS)[number];
export type ManagerLaunchState = "ok" | "missing" | "unknown";
/** `task.manager_launch_narrowed`: the run starts without some of what its job needs (the check's sentence). */
export declare function managerLaunchNarrowedNotice(c: ManagerLaunchCheck, ids: Record<string, string | undefined>): {
code: "task.manager_launch_narrowed";
message: string;
detail: Record<string, unknown>;
};
export interface ManagerLaunchCheck {
/** `ready`: nothing missing; `narrowed`: something missing that the run can do without (said in `items`); `refused`. */
readonly verdict: "ready" | "narrowed" | "refused";
readonly items: ReadonlyArray<{
readonly item: ManagerLaunchItem;
readonly state: ManagerLaunchState;
readonly means?: string;
}>;
}
/** The facts the check reads — each `undefined` when the leg cannot read it. */
export type ManagerLaunchFacts = Readonly<Record<ManagerLaunchItem, boolean | undefined>>;
/** The check over its facts — see the module head. */
export declare function managerLaunchCheck(facts: ManagerLaunchFacts): ManagerLaunchCheck;
/** What a prepared leg reads for the check: the names on its roster, whether its delegation lane launches in the background and
* its results come back on a lane, whether a person or a park can take its workers' asks, and whether it is one-shot. */
export interface ManagerLaunchLegReading {
readonly names: ReadonlySet<string>;
readonly backgroundAgents: boolean | undefined;
readonly completionLane: boolean;
readonly approver: boolean;
readonly parkStore: boolean;
readonly oneShot: boolean;
}
/** The check's facts off a prepared leg's reading. A worker's writes have an approval route when the leg has an approver to hand
* down; they have none when there is no approver, no park store and the run is one-shot (nobody can be asked — the measured
* `delegation.ask_unresolvable`); every other case is not read here (`unknown`). */
export declare function managerLaunchFactsOf(r: ManagerLaunchLegReading): ManagerLaunchFacts;
/** The check as one sentence (the notice's message, the refusal's): what is missing and what that means. */
export declare function managerLaunchCheckSentence(c: ManagerLaunchCheck): string;