/** * agentish/index.ts — Agentish v2 (AG2), the wire format sessions use to * talk to each other. * * A session working a long shift reports to whoever is managing it many * times a night, and every one of those reports is budget spent before any * work gets done. Prose restates the task to prove it was understood, hedges * where a fact would do, and buries the one field a reader actually needs — * did the gate pass — in a paragraph. AG2 is the alternative: a kind line * plus `k=v` lines with one-letter keys, so a report costs as few tokens as * the facts it carries and can be checked by a machine instead of read by * one. `check` refuses a report that is missing a required field, uses a key * its kind does not have, carries a field of the wrong shape, or claims * success (`r=+`) without the proof that success requires; `measure` prints * a message's token count beside a prose twin so the saving is a number, not * a claim. * * This module is deliberately dependency-free — no daemon code, no Node API * beyond what plain JS already gives it — so a team that wants the validator * without AIBroker's daemon can take this one file (or `npm install` it, * once it is split into its own package) and get CI checking for free. See * `docs/agentish.md`, section "Use in CI". * * This is a port, not an original design — a sibling project's validator * (`tools/agentish.py`) worked out the shape of these checks first. AG2_SPEC * is the sibling's wire format, unchanged. `why` (the `y` key) is this * project's own addition: it is not in AG2_SPEC, it is documented separately * as AG2_EXTENSIONS, and it is accepted only where a report needs room to * explain a result that is not a plain pass — R, Q, X. The sibling has not * adopted it; until it does, "why" is something this validator alone checks. */ /** The wire format itself, unmodified, as it is told to every session that * must speak it. This is the sibling project's spec — extensions live in * AG2_EXTENSIONS instead of being folded in here. */ export declare const AG2_SPEC = "AG2. msg=kind line+k=v lines. kinds T R S Q A X. keys i id g goal o own n forbid d steps p proof u out l limits r res c changes t tests G gate I inst m images # nums w worst x next z note(<200ch). sep |. outcomes + - ~ ? !. @n=path declared once then reused; @n:12=file:line. tests as Name+ Name-. no prose, no articles, never restate, unknown=?. r=+ only if all t +."; /** What this validator accepts beyond AG2_SPEC. Not yet proposed back to the * sibling project — see the module comment. */ export declare const AG2_EXTENSIONS = "y why(\u2264600ch)"; /** This validator's own identity when it is carried over a channel that * needs one — e.g. an A2A extension declaration. Not part of AG2_SPEC. */ export declare const AGENTISH_URI = "urn:aibroker:a2a:ext:agentish:2"; export type AgentishKind = "T" | "R" | "S" | "Q" | "A" | "X"; /** * A stable identifier for one failure, so a CI script can branch on `code` * instead of grepping `message`. This table is a public contract once * published — see docs/agentish.md's "Use in CI" section, which says so. */ export type AgentishErrorCode = "E_EMPTY" | "E_KIND" | "E_TOO_LONG" | "E_PARSE" | "E_DUP" | "E_REQUIRED" | "E_KEY" | "E_SHAPE" | "E_REF_UNDECLARED" | "E_R_UNPROVEN" | "E_Z_LEN" | "E_Y_LEN" | "E_T_OMITTED" | "E_T_UNREQUESTED"; export interface AgentishError { code: AgentishErrorCode; message: string; /** 1-based position among this message's own non-blank lines, where known. */ line?: number; } export interface AgentishCheckResult { kind: AgentishKind | null; fields: Record; symbols: Record; /** Human-readable messages, in order — the format every existing caller * and test in this codebase reads. Same content as `details[].message`. */ errors: string[]; /** The same failures, with a stable code and a line where one applies. */ details: AgentishError[]; } /** * Validate one Agentish message. `earlier` is the thread's prior messages — * read for their `@n=path` declarations, so a reply can reuse a symbol * without repeating the line that introduced it, and for a `T` sharing this * message's `id`, so an `R` can be held to the tests that `T` asked for. */ export declare function check(msg: string, earlier?: string[]): AgentishCheckResult; export interface AgentishExpandResult { /** `msg` with every declared `@n=path` line removed and every reference to * a declared symbol inlined to its path (suffix, if any, kept attached). */ expanded: string; symbols: Record; /** Human-readable messages for any reference whose symbol was never * declared (in `msg` or in `earlier`) — those are left verbatim in * `expanded` rather than dropped. */ errors: string[]; details: AgentishError[]; } /** * Decompress an AG2 message: resolve every `@n` reference back to the path * its `@n=path` declaration named, and drop the declaration lines themselves * (they're inlined, so repeating them would just restate what `expanded` * already says). `earlier` supplies symbols declared in prior thread * messages, exactly as `check` does. * * A reference to a symbol nothing declared — in this message or in * `earlier` — is left as-is in `expanded` and reported via `errors`/ * `details` (code `E_REF_UNDECLARED`), so a dangling ref surfaces instead of * silently vanishing or corrupting output. */ export declare function expand(msg: string, earlier?: string[]): AgentishExpandResult; export interface AgentishMeasureResult { agentish: number; prose: number; ratio: number; valid: boolean; } /** A message's token cost beside its prose twin, so a saving is a number. */ export declare function measure(msg: string, proseTwin: string): AgentishMeasureResult; //# sourceMappingURL=index.d.ts.map