/** Shared runtime formatting, identity and structured text utilities. */ import type { Entity } from "./types/environment.js"; import type { Memory } from "./types/memory.js"; import type { ModelRegistrationMetadata } from "./types/model.js"; import { ContentType, type JsonValue } from "./types/primitives.js"; import type { IAgentRuntime } from "./types/runtime.js"; import { formatTimestamp } from "./utils/time-format.js"; /** * Adds a header to a body of text. * * This function takes a header string and a body string and returns a new string with the header prepended to the body. * If the body string is empty, the header is returned as is. * * @param {string} header - The header to add to the body. * @param {string} body - The body to which to add the header. * @returns {string} The body with the header prepended. * * @example * // Given a header and a body * const header = "Header"; * const body = "Body"; * * // Adding the header to the body will result in: * // "Header\nBody" * const text = addHeader(header, body); */ export declare const addHeader: (header: string, body: string) => string; /** * Prefix of the RECENT_MESSAGES conversation block heading. The post-turn * evaluator uses it to recognise that the complete room conversation is * already rendered in provider context and must not be embedded a second time. */ export declare const CONVERSATION_MESSAGES_HEADER_PREFIX = "# Conversation Messages ("; /** * Canonical header for a rendered recent-conversation block. * * The parenthetical is load-bearing: it tells the model the visible dialogue * is only the most recent window of a longer stored conversation, so * beyond-window recall questions are not answered from the window alone * (tj-69d82bb89ebb69). Every renderer of this block — the recent-messages * provider and the conversation compactors — must emit the header through * this helper; rebuilding from a bare "# Conversation Messages" constant * silently strips the disclosure. */ export declare const conversationMessagesHeader: (visibleCount: number) => string; export declare const formatPosts: ({ messages, entities, conversationHeader, }: { messages: Memory[]; entities: Entity[]; conversationHeader?: boolean; }) => string; /** * Format messages into a string * @param {Object} params - The formatting parameters * @param {Memory[]} params.messages - List of messages to format * @param {Entity[]} params.entities - List of entities for name resolution * @returns Complete formatted entries, including timestamps and user information. */ export declare const formatMessageSegments: ({ messages, entities, }: { messages: Memory[]; entities: Entity[]; }) => string[]; /** Render the complete formatted transcript in its established display order. */ export declare const formatMessages: (params: { messages: Memory[]; entities: Entity[]; }) => string; export { formatTimestamp }; /** * Parses the simple TOON key-value shape used by generated plugin prompts. * * Supported fields are `key: value` and indexed arrays like * `items[0]: value`. Values stay as strings unless they are JSON literals, * which preserves large IDs such as Discord snowflakes. */ export declare function parseToonKeyValue>(text: string): T | null; /** Parses XML-style structured model responses. */ export declare function parseKeyValueXml>(text: string): T | null; /** * Truncate text to fit within the character limit, ensuring it ends at a complete sentence. */ export declare function truncateToCompleteSentence(text: string, maxLength: number): string; export declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise; /** * Parses a string to determine its boolean equivalent. * * Recognized affirmative values: "YES", "Y", "TRUE", "T", "1", "ON", "ENABLE" * Recognized negative values: "NO", "N", "FALSE", "F", "0", "OFF", "DISABLE" * * @param {string | undefined | null} value - The input text to parse * @returns {boolean} - Returns `true` for affirmative inputs, `false` for negative or unrecognized inputs */ export declare function parseBooleanFromText(value: string | boolean | undefined | null): boolean; export declare const getContentTypeFromMimeType: (mimeType: string) => ContentType | undefined; export interface ProviderUsageLike { promptTokens?: number; completionTokens?: number; inputTokens?: number; outputTokens?: number; totalTokens?: number; cachedPromptTokens?: number; cachedInputTokens?: number; cacheReadInputTokens?: number; cacheCreationInputTokens?: number; reasoningTokens?: number; promptTokensDetails?: { cachedTokens?: number; }; outputTokenDetails?: { reasoningTokens?: number; }; } export interface NormalizedProviderUsage { promptTokens: number; completionTokens: number; totalTokens: number; cacheReadInputTokens?: number; cacheCreationInputTokens?: number; reasoningTokens?: number; } export interface ProviderErrorSummary { name: string; message: string; status?: number; code?: string; } /** Extracts only stable diagnostic fields, never response bodies or credentials. */ export declare function summarizeProviderError(error: unknown): ProviderErrorSummary; export declare function normalizeProviderUsage(usage: ProviderUsageLike): NormalizedProviderUsage; type ProviderModelHandler = (runtime: IAgentRuntime, params: Record) => Promise; export interface ProviderModelRegistration { modelType: string; handler: ProviderModelHandler; priority?: number; metadata?: ModelRegistrationMetadata; } /** Validates a complete set before registering, avoiding partial duplicate setup. */ export declare function registerProviderModels(runtime: Pick, provider: string, registrations: readonly ProviderModelRegistration[]): void;