@sema-agent/core
Version:
Stateless, task-oriented AI agent core
39 lines (38 loc) • 3.5 kB
TypeScript
/**
* How much of an execution environment's failure message reaches a sentence the engine writes — the contract's one number, a root
* export so a host reads it instead of copying it. The message is read whole by the egress pass, folded to one line, then cut to at
* most this many Unicode code points; a message that was cut ends in one `…` (a sentence holds at most this many code points plus
* the mark), and one with nothing visible reads `the execution environment reported no reason`. What follows the bound is not shown,
* so an adapter that has a way out to give puts it FIRST.
*/
export declare const ENV_ERROR_DETAIL_MAX = 512;
/**
* The ONE reading of an execution target's failure message on its way into a sentence the engine writes — a leaf, so that
* `safety.ts` (which `fs-shared.ts` imports) and the attachment cards of `core/user-attachment.ts` read the same function the file
* tools and the Bash tool read, without a cycle: this module imports only the one-line form of foreign words (`core/protocol-http-auth.ts`),
* whose import closure holds neither `safety.ts` nor `fs-shared.ts` (the other import, `core/principal-name.ts`, has none at all).
*
* A host-supplied failure `message` is untrusted as a CARRIER OF FACTS: an execution env whose adapter
* hands back an empty (or whitespace-only) string turns any text built as `Error (X): ${message}` into a
* bare `Error (X):` — a card with a red badge and nothing to act on, which is exactly what a model (and
* a person) reads as "the engine broke and won't say how". It is also untrusted as TEXT: an adapter's sentence spliced raw onto a
* line the engine wrote can carry a newline, an escape sequence or a forged `Error (…):` line of its own. So this is the ONE reading of
* an adapter's failure message on its way into a model-visible sentence — whether the message is the whole fact or only decorates the
* sentence around it: the `same-principal` egress pass over the WHOLE message first, as written and as folded (a cut must never leave part
* of a credential the pass would have recognised whole), then one line by `inlineUntrusted`, bounded to {@link ENV_ERROR_DETAIL_MAX}
* code points (both are {@link foreignLine}, the one composition of the two), and never blank: "blank" is the engine's one reading of it
* ({@link hasVisibleContent} — nothing is left once white space and every format character, the zero-width marks and joiners among them,
* are taken away), so a message of nothing but invisible characters says it reported no reason as an empty one does.
*/
export declare function envErrorDetail(message: string | undefined): string;
/**
* Which text of a refused start this READER is shown: the whole message the first time (a tool instance is one leg's Bash, so one model's
* conversation), and the failure's own bounded restatement (`briefMessage`, the same reason and way out) every time after — not the same
* paragraph again. A failure with no restatement, or no record to keep (`shown` absent), is always shown whole. The record is the MODEL's: a
* caller whose answer never reaches the model's transcript (an extension's own `$.tool.call`) is handed none, so it neither reads nor writes
* what the model was shown. The text is the environment's: the caller still bounds it with {@link envErrorDetail}.
*/
export declare function failureMessageOnce(failure: {
message: string;
briefMessage?: string;
}, shown: Set<string> | undefined): string;