@promptbook/node
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
99 lines (98 loc) • 3.47 kB
TypeScript
import type { AsciiArtColorDepth } from '../utils/ascii-art/convertImageDataToAsciiArt';
import type { ResolvedAvatarRenderDefinition } from './renderAvatarVisual';
import type { AvatarDefinition } from './types/AvatarDefinition';
import type { AvatarSurfaceStyle, AvatarVisualId } from './types/AvatarVisualDefinition';
/**
* Default output width of the ASCII avatar in terminal character cells.
*
* @private within the repository
*/
export declare const DEFAULT_AVATAR_ASCII_ART_COLUMNS = 32;
/**
* Factory creating a drawable canvas of the requested pixel size.
*
* In browsers this is typically `document.createElement('canvas')` (with width/height set),
* in Node.js an adapter around `createCanvas` of `@napi-rs/canvas` or a compatible library.
*
* @private within the repository
*/
export type CreateCanvasForAsciiArt = (width: number, height: number) => HTMLCanvasElement;
/**
* Options for `renderAvatarVisualAsciiArt`.
*
* @private within the repository
*/
export type RenderAvatarVisualAsciiArtOptions = {
/**
* Stable visual identity of the rendered agent avatar.
*/
readonly avatarDefinition: AvatarDefinition;
/**
* Built-in avatar visual to render, the same one used on the website.
*/
readonly visualId: AvatarVisualId;
/**
* Surface used to composite the avatar before ASCII conversion.
*
* @default 'framed'
*/
readonly surface?: AvatarSurfaceStyle;
/**
* Output width in terminal character cells.
*
* @default `DEFAULT_AVATAR_ASCII_ART_COLUMNS`
*/
readonly columns?: number;
/**
* Output height in terminal character cells.
*
* @default `columns / 2` so the square avatar stays visually square in a common terminal font
*/
readonly rows?: number;
/**
* Color depth of the emitted ANSI escape codes.
*
* @default 'TRUE_COLOR'
*/
readonly colorDepth?: AsciiArtColorDepth;
/**
* Animation timestamp for animated visuals.
*
* @default `STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS`
*/
readonly timeMs?: number;
/**
* Source canvas width in CSS pixels before ASCII conversion.
*
* @default `DEFAULT_AVATAR_SIZE`
*/
readonly canvasWidth?: number;
/**
* Source canvas height in CSS pixels before ASCII conversion.
*
* @default `DEFAULT_AVATAR_SIZE`
*/
readonly canvasHeight?: number;
/**
* Optional stable render data reused across frames.
*/
readonly resolvedAvatarRenderDefinition?: ResolvedAvatarRenderDefinition;
/**
* Platform-specific canvas factory used to rasterize the visual.
*/
readonly createCanvas: CreateCanvasForAsciiArt;
};
/**
* Renders one built-in avatar visual into ANSI-colored ASCII art for terminal display.
*
* This is the universal bridge between the canvas avatar visuals shown on the website and
* text-based terminal UIs: the visual is rasterized through the exact same `renderAvatarVisual`
* pipeline the web uses, then the resulting pixels are converted into colored half-block
* characters by `convertImageDataToAsciiArt`.
*
* @param options Avatar identity, visual selection, output grid size, and the platform canvas factory.
* @returns One ANSI-colored string per output row.
*
* @private within the repository
*/
export declare function renderAvatarVisualAsciiArt(options: RenderAvatarVisualAsciiArtOptions): ReadonlyArray<string>;