UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

27 lines (26 loc) • 1.66 kB
/** One section's share of the leg's system prompt, as the `context_usage` frame reports it. */ export interface ContextUsageSection { /** The pack section id — the same wordlist `prompt.assembled`'s `sections[].id` uses. */ id: string; /** The section's ESTIMATED token weight (see {@link contextUsageSections} for what that promises). */ tokens: number; /** The section's band (`role`, `constitution`, `core-behavior`, …), so a view can group without knowing * every id. Absent only if the manifest entry carried no band. */ kind?: string; } /** * Project the manifest's compiled sections onto the frame's occupancy view. * @contract context_usage.sections — `sections[]` is the leg's PREPARE-TIME system-prompt composition, * one entry per rendered pack section, `tokens` ESTIMATED from rendered characters at the engine's * chars→tokens coefficient. A different measurement from `usedTokens`, the engine's trigger input over the * whole conversation. The two coordinates MUST NOT be mixed: do not subtract `Σ sections[].tokens` from * `usedTokens`, do not compare a section to `compactAtTokens`, and do not read a change across frames as * growth — the value is frozen at prepare and re-reported verbatim at every boundary of the leg. It * answers "what is my system prompt made of, and which part is big". Absent when the leg assembled no * section IR (a provider that replaced the prompt wholesale ships one opaque block). */ export declare function contextUsageSections(sections: ReadonlyArray<{ id: string; band?: string; chars: number; }> | undefined): ContextUsageSection[] | undefined;