@sema-agent/core
Version:
Stateless, task-oriented AI agent core
72 lines (71 loc) • 7.85 kB
TypeScript
/** Who says a leg's parks cannot be resumed — the closed set of {@link approvalParkNotResumableOf}'s two sources. `lane`: the leg was
* started in this run by an engine lane that holds no resume seat for it, so NO park of it (a decision or a resource one) can be
* resumed; `host`: the host declared its decision parks cannot be resumed (`TaskSpec.durableApproval: false`) — its resource parks can. */
export type ApprovalParkNotResumable = "lane" | "host";
/** Did an engine lane of this run start the leg — a delegated child, or an observer sidecar's leg? The one reading, by the internals the
* leg was started with (never a row's seed): the park fact below reads it, and so does the leg's kind (a lane's leg is no root —
* `wiringLegKindOf`, the wiring manifest's `leg` and the reading of who takes the deployment's start word). */
export declare function engineLaneLegOf(internals: Pick<import("./runner/contracts.js").RunInternals, "isDelegatedChild" | "observerLeg"> | undefined): boolean;
/** The holder this leg's durable writes carry — its session writes and its card writes (a park's `put`, the writes on that park after
* it): on a leg the host started, its `RunInternals.holder`, else its `RunInternals.treeHolder`; on a leg {@link engineLaneLegOf} reads
* as an engine lane's, its `treeHolder` only, never a `holder` (a workflow drive hands its member the host's holder for the resume CAS
* of that moment only — the claim reads {@link claimHolderOf}, never this). The one reading of the rule, by the same internals the leg
* was started with. */
export declare function writeHolderOf(internals: Pick<import("./runner/contracts.js").RunInternals, "holder" | "treeHolder" | "isDelegatedChild" | "observerLeg"> | undefined): string | undefined;
/** The holder a resume's claim and its preflight carry (`expect.holder`, and the reading of a lost claim): the leg's `holder`, else its
* `treeHolder` — on every leg, whoever started it. */
export declare function claimHolderOf(internals: Pick<import("./runner/contracts.js").RunInternals, "holder" | "treeHolder"> | undefined): string | undefined;
/**
* THE leg fact "a park of this leg cannot be resumed", derived once per leg (the driver) and read by name: absent ⇔ every park the leg
* can mint has someone to resume it. Two sources, nothing else:
* · `lane` — this run started the leg on an engine lane (a delegated child, or an observer sidecar) and that lane did not say it holds
* the leg's parks (`RunInternals.parkLaneHeld`: a background lane that can park, a workflow whose park lane is armed). A synchronous
* or fork child, a background child whose lane cannot park, an observer, a retained agent's wake cycle: none of them is resumed by
* anyone, so none of their parks is minted. A host resuming a row of such a leg (`Runner.resume`) is not an engine lane: the resume
* is the host's, and only the host's word applies to it;
* · `host` — the host declared it cannot resume this leg's decision parks (`TaskSpec.durableApproval: false`, carried to every child).
*/
export declare function approvalParkNotResumableOf(leg: {
engineLaneLeg: boolean;
parkLaneHeld: boolean;
hostDeclaredNotResumable: boolean;
}): ApprovalParkNotResumable | undefined;
/** The word every refusal on such a leg SAYS — its cause and its way out: the host's whenever the host declared it (its `false` rides
* to every child, so the parent leg and any background child are closed to a decision park too — the lane's way out would name roads
* that are not there), else the leg fact's own source. Park arms read the fact itself (a lane leg parks nothing, whatever the host said). */
export declare function notResumableSaysOf(fact: ApprovalParkNotResumable | undefined, hostDeclared: boolean): ApprovalParkNotResumable | undefined;
/** The way out a refusal on a leg whose parks cannot be resumed names, one clause per source (no capital, no stop: it is the tail of
* a sentence) — every refusal such a leg makes, to the person, says it in these words: the `delegation.ask_unresolvable` notice, the leg's
* `config.durable_gate_unavailable` announcement, and the tool result of a refused ask or question (the deny exit's remedy, the mandated
* ask's refusal) where a person may answer on the leg — where nobody may, the tool result names no person (`NOBODY_CAN_APPROVE`, ask-origin.ts). `mandated`: the `forceDurableGate` entitlement binds the leg — nobody may answer its
* asks live, so the clause names only the roads where an approval can wait. `asks`: what the refused ask wanted of a person — an
* approval, or the answer to a question. */
export declare function notResumableWayOut(source: ApprovalParkNotResumable, mandated: boolean, asks?: "approval" | "answer"): string;
/** The refusal a plan-review request on such a leg answers with — the result of the call that asked (`ctx.requestReview()`). No
* plan_review row is minted there, so the call must not read as "presented": it says nobody will see the plan, then the way out —
* first the one a plan always has (hand it back in the final report: whoever reads this leg's result can present it for approval),
* then the roads where a review can wait (no person reviews a plan live, so the mandated form). */
export declare function reviewRefusalSentence(source: ApprovalParkNotResumable): string;
/** The clause naming why a leg's parks cannot be resumed, per source — the sentence's middle the refusals above share. */
export declare function notResumableClause(source: ApprovalParkNotResumable): string;
/** The facts a gate reads off a leg whose parks cannot be resumed: who says so, and whether the `forceDurableGate` entitlement binds the
* leg (`mandated`: nobody may answer its asks live). Absent ⇔ the leg's parks can be resumed. */
export interface NotResumableLeg {
readonly source: ApprovalParkNotResumable;
readonly mandated: boolean;
}
/** The refusal of a call such a leg could not have run, whatever wanted a person for it (the leg's own mandated ask, an inherited
* mandate): `subject` says what wanted a person; the cause is the leg's (never a facility it lacks); nobody was asked, the call did not
* run, and asking again on this leg is no use. No stop and no way out: the gate's deny exit appends the leg's way out
* ({@link notResumableWayOut}) and {@link NOT_RESUMABLE_CARRY_ON}. The agent's own question is no call: its refusal is the one mint of
* every unanswered question ({@link questionNotShownOnLeg}). */
export declare function notResumableRefusal(subject: string, source: ApprovalParkNotResumable): string;
/** What the model does after such a refusal while the way out is not taken: say what was blocked, and go on with what needs no approval.
* Beside the way out only: where nobody may answer on the leg the one sentence that replaces the way out already says it. */
export declare const NOT_RESUMABLE_CARRY_ON = "Meanwhile, tell the user what was blocked and why you needed it, and continue with the parts of the task that need no approval.";
/** The question tool's refusal on such a leg, read by both sites of the content route's not-shown refusal: the one mint of every
* unanswered question ({@link unansweredAskRefusal}), the leg's account in its parenthesis — the leg's cause, then how it went: past a
* live face only where one was tried (one is wired and no mandate kept the question off it), else without asking anyone, and then
* that trying again on this leg cannot help (nobody can be asked on it; where a face was tried, it is asked again on every call, so a
* later one may be answered). Its only instruction is the mint's (`PROCEED_ON_JUDGMENT`). */
export declare function questionNotShownOnLeg(leg: NotResumableLeg, faceWired: boolean): string;