@sema-agent/core
Version:
Stateless, task-oriented AI agent core
48 lines (47 loc) • 3.53 kB
TypeScript
/**
* The one reading of a Claude model id — parsing it into its parts and telling whether two ids name the same model. Its
* readers: the reference preset table's lookup (`referenceModelIdOf`, `reference-model-traits.ts`), and fast mode's rule, which
* reads the model an endpoint's `speed` refusal names (`fastModeFallbackOf`, `fast-mode.ts`). A module of its own so a reader
* of the id does not reach the preset table (the prompt-assembly path never does: pinned by
* test/backlog4297-s1-reference-presets.test.ts).
*/
/** The boundary-aware LAST path segment of a model id, case-folded (BYOM ids may carry provider prefixes —
* "openrouter/anthropic/claude-fable-5"): the tail every model-id comparison reads — this module's parse, and the tool
* model gate's exact-id rows. Prompt text never reads a model id; it selects on the model's declared traits. */
export declare function modelIdTail(id: string): string;
/** A Claude model id read into its parts: `claude-<family>-<major>[-<minor>]`, or the older `claude-<major>[-<minor>]-<family>`. */
export interface ParsedClaudeModelId {
readonly family: string;
readonly major: number;
/** Absent when the id names no minor version (`claude-opus-5`). */
readonly minor?: number;
/** The older spelling, version before family (`claude-3-5-sonnet`). */
readonly versionFirst: boolean;
/** The id up to and including the version, without any accepted suffix. */
readonly base: string;
}
/**
* Read a model id as a Claude model id, the reference's way (`r_` cli321.js B[12233485,12233661) folds case and a
* dotted version, then `Cd` cli321.js B[8743093,8743705) parses): trim and fold case; a blank id or one with inner
* whitespace is not one; a `[1m]` / `[2m]` window suffix is dropped; `4.8` reads as `4-8`; only the last `/` segment
* counts (`modelIdTail`); an `anthropic.` or `<region>.anthropic.` prefix is dropped (a region outside the closed set ⇒
* not one); then `claude-<family>-<major>[-<minor>]` or `claude-<major>[-<minor>]-<family>`
* (`c` cli321.js B[8744833,8745300)), followed by nothing or an accepted suffix. Any other suffix ⇒ `undefined`: an id
* this reading does not know is never guessed at by substring (the reference's `D$` cli321.js B[12233661,12235471)
* does; we do not — the id set is open).
*/
export declare function parseClaudeModelId(id: string): ParsedClaudeModelId | undefined;
/**
* Two parsed ids name the same model: family, spelling and version, a missing minor reading as 0 — so `claude-opus-5-0`,
* `claude-opus-5@20260101` and `us.anthropic.claude-opus-5-v1:0` all name `claude-opus-5` (the reference's
* `N$` cli321.js B[12235517,12235642) and `yWt` cli321.js B[8744286,8744390) compare the same way).
*/
export declare function sameParsedClaudeModel(p: ParsedClaudeModelId, q: ParsedClaudeModelId): boolean;
/**
* Whether two model ids name the same model — the reference's comparison of two names, `Lp` of each side (`Lp`
* cli321.js:277334 "function Lp(e){return Ht(it(e,{identity:!0}))}"), read with this module's one reading: two ids that
* both read as Claude ids ({@link parseClaudeModelId}) compare by their parts; when neither does, they compare with case
* folded, a window suffix and a dated `-YYYYMMDD` snapshot dropped (what the reference's reading does to an id it knows no
* family of, `wA` cli321.js:277334); one that reads and one that does not are two models.
*/
export declare function sameModelNamed(a: string, b: string): boolean;