UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

73 lines (72 loc) • 6.6 kB
/** * The `unavailable` answer of the engine's two human faces — an approver (`onAsk`, `AskOutcome` `"unavailable"`) and a question face * (`onQuestion`, `QuestionUnavailable`) — stated ONCE for both: when a face may give it, and what the engine does with it. * * WHEN a face may answer `unavailable` (one permission, both faces): * · this delivery took no answer and no decision, AND the face closed it before its wait window elapsed — from that moment a late * answer or decision for this delivery is refused. A card a person already saw qualifies (a replica draining, a session the host * ends): the close is what keeps the question single-winner, whatever the engine then does with it. * · a card never presented on a live face (delivered to a ledger or an inbox only) may also answer it when its window elapses. * · NOT covered: a card presented on a live face whose window elapsed with nobody answering — that face THROWS. * "Presented on a live face" means the host holds the fact that a person-facing live face accepted and displayed the card. That the card * could be answered somewhere else does not make it presented; a ledger card a following shell happens to show is not presented; a * disconnect the caller declared not to be an end does not close the delivery. * A THROW is the other arm: the delivery was attempted and failed. It never parks. * * WHAT the engine does with it is minted on the request, per delivery: {@link UnavailableLanding}. */ /** The closed set of what an `unavailable` answer to ONE delivery leads to. Read a word outside it as unknown — never as either word. */ export declare const UNAVAILABLE_LANDINGS: readonly ["park", "close"]; /** * What the engine does if THIS delivery ends with the face's `unavailable` answer — minted by the engine per delivery, never read from * the caller (a value the caller put on the request is dropped where the request is minted): * · `"park"` — it will TRY to file the ask as a durable row on the issuing leg and pause the run, so a person can answer later. An * attempt, not a promise: the park path can still refuse it at the attempt (the row cannot be committed, an argument cannot * be parked, the remote environment's pause fails, offloaded results held only in memory, a capacity bound), and another * check can still refuse the call — then the model reads that refusal. What the engine knows when it wires the leg is not an * attempt: a leg whose per-task environment has no suspend target refuses every park, so its deliveries say `close`. One * known over-statement: a delivery to an ancestor's approver from a delegated leg's fold, on the pass that re-judges a * person's approved edit after this call's park already failed, says `park` (KNOWN-LIMITS KL-4306-a). * · `"close"` — it ends the ask now: the model reads that nobody answered (for a question the tool asked itself, a continuation, or a * coded failure under an interactive posture or on the call an approval was redeemed for; a refusal for a routed * question; the fail-closed deny for an approval) and the run goes on; nothing waits. * A throw is not covered: a throw never parks. Absent ⇔ the engine did not mint this request (an engine older than this member, a * request a host built itself, or a delivery whose landing the engine cannot state) — read it as unknown, never as either word. * The word is per delivery: read it off each request, never cache it per leg or per call — one leg can say `park` on an approval and * `close` on a question, and one call says `close` once its park has failed. */ export type UnavailableLanding = (typeof UNAVAILABLE_LANDINGS)[number]; /** * The call as the gate hands it to a seat that puts a question to a person (`ToolGateInput.resolveAsk` / `resolveContentAsk`): the call, * plus the landing the gate minted for THIS delivery. The gate is the member's only writer; a seat carries it onto the request it builds * for a face, and never derives it again. A fresh frozen copy minted at the delivery — not the object `adjudicate` or the first park * attempt saw (the word can depend on that attempt's outcome); a re-route parks this same object. Relate a call across seats by its * `toolCallId`, never by object identity. */ export type GateDeliveredCall = import("./tool-policy.js").ToolCallRequest & { readonly ifUnavailable: UnavailableLanding; }; /** Is `value` one of the two {@link UNAVAILABLE_LANDINGS} words (for a consumer reading the member off a wire)? */ export declare function isUnavailableLanding(value: unknown): value is UnavailableLanding; /** May the engine's question park on this leg? Only where the leg's question face is durable (a store and a durable opt-in the leg can be * resumed under); `durableQuestionFace` absent = the leg did not state it (a host driving the gate itself), and its park closure judges. Every * park site of the gate and the landing below read this one rule. */ export declare function questionMayPark(question: boolean, durableQuestionFace: boolean | undefined): boolean; /** * THE one judge of "if this delivery ends `unavailable`, does the engine try to park it?" — the gate mints its value onto every delivery it * makes and reads the same value back where it re-routes; the inherited stations of a delegated leg read it for theirs. Four conjuncts: * the call has a park route (the leg's park closure exists for this call), the leg has a suspend target (`suspendTargetGap` absent: the * one fact the park closure refuses every attempt on, named when the leg is wired — `suspendTargetGapOf`), no park attempt has failed for * this call, and a question may park here ({@link questionMayPark}). */ export declare function unavailableLandingOf(facts: { readonly parkRoute: boolean; readonly suspendTargetGap: string | undefined; readonly attemptFailed: boolean; readonly question: boolean; readonly durableQuestionFace: boolean | undefined; }): UnavailableLanding; /** The gate's one read of `ToolGateInput.suspendTargetGap`, the leg's own sentence saying why it cannot hold a park: absent ⇒ `undefined` * (a target, or not stated); a string with a visible character ⇒ that sentence; anything else is refused loudly (`config.invalid_argument`, * naming the input and the kind it got, never the value) — a bad value is never read as a gap. */ export declare function readSuspendTargetGap(value: unknown): string | undefined;