UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

69 lines (68 loc) • 5.66 kB
/** * The LANGUAGE seat (`TaskSpec.language`): the language the person's shell has their reply preference set to, stated to the * model in the reference's own `# Language` attachment (Claude Code 2.1.316 `Pio` / `wSt`, cli316.js:269324-269326) and never * in the system prompt. A leg's seat holds what its first request owes, judged against what the model was told in the * conversation's CURRENT segment (the announced record's `language` arm — the reference compares against the transcript's * last `language` attachment, `s0e` over `Yde`, cli316.js:269326 / :272682): a language declared and a different one (or * none) told ⇒ the full text for the declared one; none declared and a language told ⇒ the cleared sentence; every other * pair owes nothing. A compaction inside the leg restates the declared language right after it lands (the reference's * `vSt`, cli316.js:269326) and records it for the new segment, so the next leg judges against what the model now holds. * * Stated only on the person's own agents: a root leg and a named teammate. An ordinary delegated child reads no language * seat (the reference's `tPr`, cli316.js:272682: main and teammate agents, never a plain subagent). Model lane only — no * `steering_injected` echo (the advisor instructions' and the posture's lane). * * The seat is the reply language, not the engine's text: `TaskSpec.promptLocale` renders the engine's own texts and never * sets a reply language; neither seat is read from the other. */ import { type AnnouncedLanguageState } from "../../internal/harness.js"; import type { SessionTreeEntry } from "../../internal/harness-types.js"; import type { MaybeCompactOptions } from "../auto-compaction.js"; import type { Prepared } from "./contracts.js"; import type { EngineText } from "../../prompt-assembly/engine-text.js"; import { type ToldSeat } from "./conversation-segment.js"; /** The longest language the seat admits — the reference's own bound (its setting's schema is `string().max(256)`: * `S3` (cli316.js:269323), over `OO` (cli316.js:260502)), counted in UTF-16 units as that schema counts. */ export declare const LANGUAGE_MAX = 256; /** The `# Language` attachment's text in `say`'s reading (the run's): the reference's (`XLo`, cli321.js:284845-284847) as * the catalog's `core/event.language` words it. The language is the deployment's declaration (caller-trusted); it is held * to one neutralized line, as the output style's name is, and said as written in every reading. */ export declare function renderLanguageInstructions(language: string, say: EngineText): string; /** The seat's door: the declared language, or `undefined` when the seat is absent. Every bad value is refused by name * (`config.language_invalid`), never ignored — a preference the deployment believes it declared must not run as none: * a value that is not a string, a blank string, a string longer than {@link LANGUAGE_MAX}. */ export declare function screenLanguageSeat(seat: unknown): string | undefined; /** The frame a leg owes, from what the model was told in this segment (`null` = told the preference was cleared, `undefined` * = nothing told) and the declared language, worded by `say`; `value` is what the model has been told once the frame is * delivered. The cleared sentence is the reference's `gDt` given `null` (cli321.js:284845). */ export declare function languageFrame(told: string | null | undefined, declared: string | undefined, say: EngineText): { body: string; value: string | null; } | undefined; /** A leg's language seat: the told seat (the frame its first request owes, the segment that was judged in) and the declared * language (what a compaction restates). */ export interface LanguageSeat extends ToldSeat<string | null> { readonly declared: string | undefined; } /** The leg's seat, or `undefined` when the leg states no language (an ordinary delegated child) or there is nothing to tell * and nothing told. An unreadable branch never withholds: a declared language is stated (a duplicate at worst) and, with none * declared, a recorded one is cleared; such a leg records nothing. */ export declare function prepareLanguageSeat(input: { declared: string | undefined; personAgent: boolean; told: AnnouncedLanguageState | undefined; session: { getBranch(): Promise<ReadonlyArray<SessionTreeEntry>>; }; say: EngineText; }): Promise<LanguageSeat | undefined>; /** The owed frame as one engine-marked reminder — what a fresh leg's first message and a resumed leg's continuation both carry. */ export declare function languageFrameText(prepared: Pick<Prepared, "languageSeat" | "reminderMark">): string | undefined; type RecordSeats = Pick<Prepared, "languageSeat" | "announcedListingsRef" | "frameReceipts">; /** Register the owed frame's receipt on the message that carries it (`text`, its exact first text block): what the model was * told is recorded only once that message is in the transcript. Nothing owed ⇒ nothing registered. */ export declare function registerLanguageReceipt(prepared: RecordSeats, text: string): void; /** The seat's COMPACTION arm, on a leg that declares a language: the told seat's one restate (`restateToldSeat`) of the declared * text — nothing is appended while the leg's own pending frame is that text, and the record moves to the new segment. */ export declare function languageRestateOption(prepared: RecordSeats & Pick<Prepared, "reminderMark" | "session" | "admitRows" | "batchHaltRef" | "postureFrameRef" | "announcedSnapshotRecovered" | "engineText">): Pick<MaybeCompactOptions, "languageRestate">; export {};