@sema-agent/core
Version:
Stateless, task-oriented AI agent core
43 lines (42 loc) • 2.47 kB
TypeScript
/** The field path the sentences open with. */
export declare const RETAIN_SEAT_FIELD = "TaskSpec.retainSubagentSessions";
/** The option as the engine reads it once it is on: `true` (the defaults) or a frozen record of the members the caller gave. */
export type RetainSeat = true | {
readonly ttlMs?: number;
readonly max?: number;
};
/** The screen's answer: the seat (absent ⇔ the option is off), or the refusal — its code, the field path it is about, and the sentence
* (opening with that path, saying the kind of the value and never the value). Never thrown. */
export type RetainSeatScreen = {
readonly ok: true;
readonly seat?: RetainSeat;
} | {
readonly ok: false;
readonly code: "config.invalid_argument";
readonly field: string;
readonly message: string;
};
type RetainSeatRefusal = Extract<RetainSeatScreen, {
ok: false;
}>;
/**
* Judge the retain option. `undefined` and `false` are off (no seat); `true` is on with the defaults; a plain record is on, and its
* members are the only keys `ttlMs` and `max` — each present member (not `undefined`) a whole number of at least 1 — and the seat is a
* frozen copy holding exactly the members given. Refused, each `config.invalid_argument` with its field path: `null`, a string, a number
* or an array as the option; a key the option does not take; a record that is not plain (a class instance, a Proxy); a member whose
* read throws (the sentence says it could not be read, never what it threw); and a member that is `null`, not a number, not finite, a
* fraction or below 1. Each member is read once, off the record's captured descriptors, and the answer is a copy of what was read, so the
* caller's record is never read again. `at` is the field path of the option for the sentences.
*/
export declare function screenRetainSeat(value: unknown, at?: string): RetainSeatScreen;
/** The refusal as the error a door throws: the code, and `detail.field` naming the field. */
export declare function retainSeatError(refusal: RetainSeatRefusal): Error & {
code: "config.invalid_argument";
detail: {
field: string;
};
};
/** The screen as a ledger's constructor takes it: the seat to build from (`true` or the frozen record), or the refusal thrown. A value that
* asks for no retention (`false`, absent) is refused too — a ledger is made only for an opt-in. */
export declare function retainSeatToBuild(value: unknown): RetainSeat;
export {};