UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

48 lines • 2.83 kB
import type { SeededJsonAgentSessionEvent, SeededJsonMessageUpdateEvent } from "../json-event.ts"; import type { ActiveBlock } from "./compact-active-block.ts"; import type { CompactComponentRoots } from "./compact-component-roots.ts"; import type { CompactContentIndex } from "./compact-content-index.ts"; import type { CompactContentStore } from "./compact-content-store.ts"; import { type SeededBlock } from "./compact-seeded-block.ts"; import { CompactSeededDraft, type SeededFields } from "./compact-seeded-draft.ts"; import type { SettledRow } from "./compact-state-view.ts"; import type { FrozenBlock } from "./compact-text-view.ts"; type Nested = Extract<SeededJsonMessageUpdateEvent["assistantMessageEvent"], { type: "start" | "done" | "error"; }>; export type SeededMessage = Extract<SeededJsonAgentSessionEvent, { type: "message_start"; }>["message"]; /** The message-level records: outer start and end, and the nested start and terminals of an assistant stream. */ export type SeededMessageRecord = Extract<SeededJsonAgentSessionEvent, { type: "message_start" | "message_end"; }> | (Omit<SeededJsonMessageUpdateEvent, "assistantMessageEvent"> & { readonly assistantMessageEvent: Nested; }); interface TerminalCut { readonly invalidatedBlocks?: readonly number[]; readonly rewrittenFrom?: number; } export declare function recordMessage(record: SeededMessageRecord): { message: SeededMessage; terminal: boolean; }; /** * The whole public message wins: a terminal rebuilds every block from its content, so no index it no longer names * survives. Raw tool spelling is kept only from an ENDED block below the producer's cutoff and not invalidated, so an * abandoned stream's partial raw text and preview never outlive the terminal. */ export declare function seedMessage(draft: CompactSeededDraft, message: SeededMessage, terminal: boolean, previous?: ReadonlyMap<number, ActiveBlock>, cut?: TerminalCut): { fields: SeededFields; blocks: Map<number, SeededBlock>; }; /** An indexed record's usage and changed metadata fold into the message's own fields in the same step. */ export declare function updateFields(draft: CompactSeededDraft, fields: SeededFields | undefined, update: Partial<Pick<SeededJsonMessageUpdateEvent, "usage" | "messageMetadata">>): SeededFields | undefined; /** The cold edit/install step: a settled row replaced whole from an authoritative message, never a partial patch. */ export declare function installSettledMessage(owner: { readonly store: CompactContentStore; readonly blockRoots: CompactComponentRoots<FrozenBlock>; readonly settled: CompactContentIndex<SettledRow>; }, messageId: string, message: SeededMessage, keep: Pick<SettledRow, "persistence" | "correlation">): void; export {}; //# sourceMappingURL=compact-seeded-messages.d.ts.map