UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

44 lines (43 loc) • 2.97 kB
/** * A run's trimmed stretch, as the context lane keeps it between request builds: where the latest handed-on trimmed request started * (the next trim starts no earlier, so the cut never moves back inside the stretch — a scale that reads a little lower after a cut * would otherwise bring it back and forth, each move a new prefix), the view's first row then (a different one is a rebuilt * transcript — a compaction landed — which ends the stretch, as a view judged under the line does), and the person's account of * each view handed on (`context.messages_omitted`, {@link createMessagesOmittedSeat}). */ import type { AgentMessage } from "../../internal/harness.js"; import { type RequestSize, type RequestSizing } from "../context-guard.js"; import type { InTurnCompactionVerdict } from "./contracts.js"; import type { NoticeSeatInput } from "./notice-seat-input.js"; /** One view the lane hands on, as the stretch reads it. */ export interface HandedOnView { /** How many messages the trim left out (zero: the view fits). */ readonly omitted: number; /** How the trim sized the request — present when the view reached the trim over the line. */ readonly sizing?: RequestSizing; /** The trim's choice after the git frame's own guard, before the frames every request carries ride in, and what each row of the * request as handed on costs (present with `sizing`). */ readonly framed: readonly AgentMessage[]; readonly sentSize?: RequestSize; /** The view the trim cut (indexes are this view's) and what it kept. */ readonly working: readonly AgentMessage[]; readonly kept: readonly AgentMessage[]; /** The rows the trim never drops. */ readonly held: ReadonlySet<AgentMessage>; readonly lineTokens: number; /** The model's window (`physicalWindowOf`): a short room with nothing left out is said only when the request, at the run's scale, * is past it — the provider refuses that one; under it the request is the one 7.69.0 sent and the provider takes it. */ readonly windowTokens: number; /** What compaction did for this request over its guard — the account's why and way out (absent: arm B not reached or its seat unwired). */ readonly compaction?: InTurnCompactionVerdict; } export interface TrimStretch { /** A new build over `view`: a different first row than the last build saw ends the stretch. */ begin(view: readonly AgentMessage[]): void; /** Where the next trim may start — an index into the view — once a trimmed request of the stretch was handed on. */ notBefore(): number | undefined; /** The account of a view handed on, to run when it is: the room a short request names (the in-band notice aside, which the trim * does not weigh), the person's own messages it leaves out, and where it started. */ handedOn(v: HandedOnView): () => void; } export declare function createTrimStretch(ids: NoticeSeatInput): TrimStretch;