import { CONTEXT_INTRO_CUSTOM_TYPE } from '../core/runtime/bearings.js'; /** The `customType` stamped on the injected session message. Used both to write * the entry and to detect it on resume (the idempotency guard). Defined beside * the block builder in `core/runtime/bearings.ts` because the warm-pool claim's * live delivery needs it too; re-exported here as this module's own surface. */ export { CONTEXT_INTRO_CUSTOM_TYPE }; interface SessionEntryLike { type: string; customType?: string; /** custom_message entries carry their injected content (string or blocks). */ content?: string | Array<{ type: string; text?: string; }>; /** Extension metadata we stamp on the block (NOT sent to the LLM). The * authoritative idempotency discriminator: `nodeId` is the node the block * belongs to, so a fork (whose copied source block carries the SOURCE's id) * is told apart from a genuine resume by an EXACT id match. */ details?: { nodeId?: string; }; } interface SessionStartCtxLike { sessionManager: { getEntries: () => SessionEntryLike[]; getBranch?: (fromId?: string) => SessionEntryLike[]; }; } interface CustomMessageLike { customType: string; content: string; display?: boolean; /** Extension-only metadata (not sent to the LLM); used as the exact * idempotency discriminator on resume — see SessionEntryLike.details. */ details?: { nodeId: string; }; } /** The message handed to a message renderer. `content` is normally the string we * sent, but pi types it as string-or-blocks, so we handle both. */ interface RenderedMessageLike { customType: string; content: string | Array<{ type: string; text?: string; }>; } /** Minimal structural match for pi-tui's `Component` (render + invalidate). A * plain object of this shape is a valid child for pi's Container. */ interface ComponentLike { render: (width: number) => string[]; invalidate: () => void; } /** Subset of pi's `Theme` we touch — `fg(color, text)` wraps text in ANSI. Used * defensively (falls back to plain text if absent). */ interface ThemeLike { fg?: (color: string, text: string) => string; } interface PiLike { on: (event: 'session_start', handler: (event: unknown, ctx: SessionStartCtxLike) => void | Promise) => void; sendMessage: (message: CustomMessageLike, options?: { deliverAs?: string; triggerTurn?: boolean; }) => void; registerMessageRenderer: (customType: string, renderer: (message: RenderedMessageLike, options: { expanded?: boolean; }, theme: ThemeLike) => ComponentLike | undefined) => void; } /** Build the bearings block for `nodeId`. Thin wrapper over the * shared builder in core/runtime/bearings.ts (the single source of truth, also * used by the promotion guidance dump). Exported for testing. */ export declare function buildContextIntro(nodeId: string): string; /** * Renderer for `crtr-context` messages. Collapsed (default) shows a one-line * stub; expanded (Ctrl+O) shows the label + full body. Returns a plain object * matching pi's structural `Component` interface — no pi-tui import. Exported for * testing. */ export declare function renderContextMessage(message: RenderedMessageLike, options: { expanded?: boolean; }, theme: ThemeLike): ComponentLike; /** * Register the context-intro preamble on `pi`. * * Returns immediately (inert) when CRTR_NODE_ID is absent. On `session_start` * it injects the block as the first message of a brand-new chat * — but only when the session does not already carry it, so a `--session ` * relaunch (which restores the conversation) never duplicates the block. */ export declare function registerCanvasContextIntro(pi: PiLike): void; export default registerCanvasContextIntro;