@promptbook/utils 0.113.0-3 → 0.113.0-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -17,7 +17,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
17
17
  * @generated
18
18
  * @see https://github.com/webgptorg/promptbook
19
19
  */
20
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-3';
20
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-5';
21
21
  /**
22
22
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
23
23
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -0,0 +1,75 @@
1
+ import type { AsciiArtColorDepth } from '../utils/ascii-art/convertImageDataToAsciiArt';
2
+ import type { AvatarDefinition } from './types/AvatarDefinition';
3
+ import type { AvatarVisualId } from './types/AvatarVisualDefinition';
4
+ /**
5
+ * Default output width of the ASCII avatar in terminal character cells.
6
+ *
7
+ * @private within the repository
8
+ */
9
+ export declare const DEFAULT_AVATAR_ASCII_ART_COLUMNS = 32;
10
+ /**
11
+ * Factory creating a drawable canvas of the requested pixel size.
12
+ *
13
+ * In browsers this is typically `document.createElement('canvas')` (with width/height set),
14
+ * in Node.js an adapter around `createCanvas` of `@napi-rs/canvas` or a compatible library.
15
+ *
16
+ * @private within the repository
17
+ */
18
+ export type CreateCanvasForAsciiArt = (width: number, height: number) => HTMLCanvasElement;
19
+ /**
20
+ * Options for `renderAvatarVisualAsciiArt`.
21
+ *
22
+ * @private within the repository
23
+ */
24
+ export type RenderAvatarVisualAsciiArtOptions = {
25
+ /**
26
+ * Stable visual identity of the rendered agent avatar.
27
+ */
28
+ readonly avatarDefinition: AvatarDefinition;
29
+ /**
30
+ * Built-in avatar visual to render, the same one used on the website.
31
+ */
32
+ readonly visualId: AvatarVisualId;
33
+ /**
34
+ * Output width in terminal character cells.
35
+ *
36
+ * @default `DEFAULT_AVATAR_ASCII_ART_COLUMNS`
37
+ */
38
+ readonly columns?: number;
39
+ /**
40
+ * Output height in terminal character cells.
41
+ *
42
+ * @default `columns / 2` so the square avatar stays visually square in a common terminal font
43
+ */
44
+ readonly rows?: number;
45
+ /**
46
+ * Color depth of the emitted ANSI escape codes.
47
+ *
48
+ * @default 'TRUE_COLOR'
49
+ */
50
+ readonly colorDepth?: AsciiArtColorDepth;
51
+ /**
52
+ * Animation timestamp for animated visuals.
53
+ *
54
+ * @default `STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS`
55
+ */
56
+ readonly timeMs?: number;
57
+ /**
58
+ * Platform-specific canvas factory used to rasterize the visual.
59
+ */
60
+ readonly createCanvas: CreateCanvasForAsciiArt;
61
+ };
62
+ /**
63
+ * Renders one built-in avatar visual into ANSI-colored ASCII art for terminal display.
64
+ *
65
+ * This is the universal bridge between the canvas avatar visuals shown on the website and
66
+ * text-based terminal UIs: the visual is rasterized through the exact same `renderAvatarVisual`
67
+ * pipeline the web uses, then the resulting pixels are converted into colored half-block
68
+ * characters by `convertImageDataToAsciiArt`.
69
+ *
70
+ * @param options Avatar identity, visual selection, output grid size, and the platform canvas factory.
71
+ * @returns One ANSI-colored string per output row.
72
+ *
73
+ * @private within the repository
74
+ */
75
+ export declare function renderAvatarVisualAsciiArt(options: RenderAvatarVisualAsciiArtOptions): ReadonlyArray<string>;
@@ -0,0 +1,15 @@
1
+ import type { AsciiArtColorDepth } from './convertImageDataToAsciiArt';
2
+ /**
3
+ * Detects the ANSI color depth supported by the current terminal.
4
+ *
5
+ * Prefers 24-bit true color when the environment advertises it (modern terminals such as
6
+ * Windows Terminal, ConEmu, VS Code, mintty, iTerm2, and WezTerm) and falls back to the
7
+ * portable 256-color palette otherwise.
8
+ *
9
+ * Note: `$` is used to indicate that this function is not a pure function - it reads the process environment
10
+ *
11
+ * @returns Color depth usable by `convertImageDataToAsciiArt`
12
+ *
13
+ * @private within the repository
14
+ */
15
+ export declare function $detectTerminalAnsiColorDepth(): AsciiArtColorDepth;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Color depth of the ANSI escape codes emitted by the ASCII-art conversion.
3
+ *
4
+ * - `TRUE_COLOR` emits 24-bit `38;2;r;g;b` / `48;2;r;g;b` sequences
5
+ * - `ANSI_256` approximates colors on the 256-color ANSI cube for older terminals
6
+ *
7
+ * @private within the repository
8
+ */
9
+ export type AsciiArtColorDepth = 'TRUE_COLOR' | 'ANSI_256';
10
+ /**
11
+ * Minimal structural subset of the DOM `ImageData` accepted by the ASCII-art conversion.
12
+ *
13
+ * Works with browser canvas `ImageData`, `@napi-rs/canvas` image data, or any raw RGBA buffer.
14
+ *
15
+ * @private within the repository
16
+ */
17
+ export type AsciiArtImageData = {
18
+ /**
19
+ * Source image width in pixels.
20
+ */
21
+ readonly width: number;
22
+ /**
23
+ * Source image height in pixels.
24
+ */
25
+ readonly height: number;
26
+ /**
27
+ * Flat RGBA pixel buffer with 4 bytes per pixel.
28
+ */
29
+ readonly data: ArrayLike<number>;
30
+ };
31
+ /**
32
+ * Options for `convertImageDataToAsciiArt`.
33
+ *
34
+ * @private within the repository
35
+ */
36
+ export type ConvertImageDataToAsciiArtOptions = {
37
+ /**
38
+ * Source pixels to convert.
39
+ */
40
+ readonly imageData: AsciiArtImageData;
41
+ /**
42
+ * Output width in terminal character cells.
43
+ */
44
+ readonly columns: number;
45
+ /**
46
+ * Output height in terminal character cells.
47
+ *
48
+ * Each character cell renders two vertically stacked pixels, so `rows = columns / 2`
49
+ * keeps a square image visually square in a common terminal font.
50
+ */
51
+ readonly rows: number;
52
+ /**
53
+ * Color depth of the emitted ANSI escape codes.
54
+ *
55
+ * @default 'TRUE_COLOR'
56
+ */
57
+ readonly colorDepth?: AsciiArtColorDepth;
58
+ /**
59
+ * Alpha channel value (0-255) below which an averaged half-cell is treated as fully transparent.
60
+ *
61
+ * @default 32
62
+ */
63
+ readonly alphaThreshold?: number;
64
+ };
65
+ /**
66
+ * Converts raw RGBA image pixels into colored ASCII art for ANSI terminals.
67
+ *
68
+ * This is the universal image-to-terminal technique used across the repository:
69
+ * every output character cell covers a rectangular region of source pixels which is
70
+ * split into a top and bottom half; each half is area-averaged and rendered with
71
+ * half-block characters (`▀` / `▄`) so one character shows two "pixels" vertically.
72
+ * Transparent halves keep the terminal background so non-rectangular images
73
+ * (for example rounded avatar cards) compose naturally into any terminal UI.
74
+ *
75
+ * @param options Source pixels, output grid size, and ANSI color depth.
76
+ * @returns One ANSI-colored string per output row, each ending with a color reset.
77
+ *
78
+ * @private within the repository
79
+ */
80
+ export declare function convertImageDataToAsciiArt(options: ConvertImageDataToAsciiArtOptions): ReadonlyArray<string>;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.113.0-1`).
18
+ * It follows semantic versioning (e.g., `0.113.0-4`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/utils",
3
- "version": "0.113.0-3",
3
+ "version": "0.113.0-5",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-3';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-5';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -0,0 +1,75 @@
1
+ import type { AsciiArtColorDepth } from '../utils/ascii-art/convertImageDataToAsciiArt';
2
+ import type { AvatarDefinition } from './types/AvatarDefinition';
3
+ import type { AvatarVisualId } from './types/AvatarVisualDefinition';
4
+ /**
5
+ * Default output width of the ASCII avatar in terminal character cells.
6
+ *
7
+ * @private within the repository
8
+ */
9
+ export declare const DEFAULT_AVATAR_ASCII_ART_COLUMNS = 32;
10
+ /**
11
+ * Factory creating a drawable canvas of the requested pixel size.
12
+ *
13
+ * In browsers this is typically `document.createElement('canvas')` (with width/height set),
14
+ * in Node.js an adapter around `createCanvas` of `@napi-rs/canvas` or a compatible library.
15
+ *
16
+ * @private within the repository
17
+ */
18
+ export type CreateCanvasForAsciiArt = (width: number, height: number) => HTMLCanvasElement;
19
+ /**
20
+ * Options for `renderAvatarVisualAsciiArt`.
21
+ *
22
+ * @private within the repository
23
+ */
24
+ export type RenderAvatarVisualAsciiArtOptions = {
25
+ /**
26
+ * Stable visual identity of the rendered agent avatar.
27
+ */
28
+ readonly avatarDefinition: AvatarDefinition;
29
+ /**
30
+ * Built-in avatar visual to render, the same one used on the website.
31
+ */
32
+ readonly visualId: AvatarVisualId;
33
+ /**
34
+ * Output width in terminal character cells.
35
+ *
36
+ * @default `DEFAULT_AVATAR_ASCII_ART_COLUMNS`
37
+ */
38
+ readonly columns?: number;
39
+ /**
40
+ * Output height in terminal character cells.
41
+ *
42
+ * @default `columns / 2` so the square avatar stays visually square in a common terminal font
43
+ */
44
+ readonly rows?: number;
45
+ /**
46
+ * Color depth of the emitted ANSI escape codes.
47
+ *
48
+ * @default 'TRUE_COLOR'
49
+ */
50
+ readonly colorDepth?: AsciiArtColorDepth;
51
+ /**
52
+ * Animation timestamp for animated visuals.
53
+ *
54
+ * @default `STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS`
55
+ */
56
+ readonly timeMs?: number;
57
+ /**
58
+ * Platform-specific canvas factory used to rasterize the visual.
59
+ */
60
+ readonly createCanvas: CreateCanvasForAsciiArt;
61
+ };
62
+ /**
63
+ * Renders one built-in avatar visual into ANSI-colored ASCII art for terminal display.
64
+ *
65
+ * This is the universal bridge between the canvas avatar visuals shown on the website and
66
+ * text-based terminal UIs: the visual is rasterized through the exact same `renderAvatarVisual`
67
+ * pipeline the web uses, then the resulting pixels are converted into colored half-block
68
+ * characters by `convertImageDataToAsciiArt`.
69
+ *
70
+ * @param options Avatar identity, visual selection, output grid size, and the platform canvas factory.
71
+ * @returns One ANSI-colored string per output row.
72
+ *
73
+ * @private within the repository
74
+ */
75
+ export declare function renderAvatarVisualAsciiArt(options: RenderAvatarVisualAsciiArtOptions): ReadonlyArray<string>;
@@ -0,0 +1,15 @@
1
+ import type { AsciiArtColorDepth } from './convertImageDataToAsciiArt';
2
+ /**
3
+ * Detects the ANSI color depth supported by the current terminal.
4
+ *
5
+ * Prefers 24-bit true color when the environment advertises it (modern terminals such as
6
+ * Windows Terminal, ConEmu, VS Code, mintty, iTerm2, and WezTerm) and falls back to the
7
+ * portable 256-color palette otherwise.
8
+ *
9
+ * Note: `$` is used to indicate that this function is not a pure function - it reads the process environment
10
+ *
11
+ * @returns Color depth usable by `convertImageDataToAsciiArt`
12
+ *
13
+ * @private within the repository
14
+ */
15
+ export declare function $detectTerminalAnsiColorDepth(): AsciiArtColorDepth;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Color depth of the ANSI escape codes emitted by the ASCII-art conversion.
3
+ *
4
+ * - `TRUE_COLOR` emits 24-bit `38;2;r;g;b` / `48;2;r;g;b` sequences
5
+ * - `ANSI_256` approximates colors on the 256-color ANSI cube for older terminals
6
+ *
7
+ * @private within the repository
8
+ */
9
+ export type AsciiArtColorDepth = 'TRUE_COLOR' | 'ANSI_256';
10
+ /**
11
+ * Minimal structural subset of the DOM `ImageData` accepted by the ASCII-art conversion.
12
+ *
13
+ * Works with browser canvas `ImageData`, `@napi-rs/canvas` image data, or any raw RGBA buffer.
14
+ *
15
+ * @private within the repository
16
+ */
17
+ export type AsciiArtImageData = {
18
+ /**
19
+ * Source image width in pixels.
20
+ */
21
+ readonly width: number;
22
+ /**
23
+ * Source image height in pixels.
24
+ */
25
+ readonly height: number;
26
+ /**
27
+ * Flat RGBA pixel buffer with 4 bytes per pixel.
28
+ */
29
+ readonly data: ArrayLike<number>;
30
+ };
31
+ /**
32
+ * Options for `convertImageDataToAsciiArt`.
33
+ *
34
+ * @private within the repository
35
+ */
36
+ export type ConvertImageDataToAsciiArtOptions = {
37
+ /**
38
+ * Source pixels to convert.
39
+ */
40
+ readonly imageData: AsciiArtImageData;
41
+ /**
42
+ * Output width in terminal character cells.
43
+ */
44
+ readonly columns: number;
45
+ /**
46
+ * Output height in terminal character cells.
47
+ *
48
+ * Each character cell renders two vertically stacked pixels, so `rows = columns / 2`
49
+ * keeps a square image visually square in a common terminal font.
50
+ */
51
+ readonly rows: number;
52
+ /**
53
+ * Color depth of the emitted ANSI escape codes.
54
+ *
55
+ * @default 'TRUE_COLOR'
56
+ */
57
+ readonly colorDepth?: AsciiArtColorDepth;
58
+ /**
59
+ * Alpha channel value (0-255) below which an averaged half-cell is treated as fully transparent.
60
+ *
61
+ * @default 32
62
+ */
63
+ readonly alphaThreshold?: number;
64
+ };
65
+ /**
66
+ * Converts raw RGBA image pixels into colored ASCII art for ANSI terminals.
67
+ *
68
+ * This is the universal image-to-terminal technique used across the repository:
69
+ * every output character cell covers a rectangular region of source pixels which is
70
+ * split into a top and bottom half; each half is area-averaged and rendered with
71
+ * half-block characters (`▀` / `▄`) so one character shows two "pixels" vertically.
72
+ * Transparent halves keep the terminal background so non-rectangular images
73
+ * (for example rounded avatar cards) compose naturally into any terminal UI.
74
+ *
75
+ * @param options Source pixels, output grid size, and ANSI color depth.
76
+ * @returns One ANSI-colored string per output row, each ending with a color reset.
77
+ *
78
+ * @private within the repository
79
+ */
80
+ export declare function convertImageDataToAsciiArt(options: ConvertImageDataToAsciiArtOptions): ReadonlyArray<string>;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.113.0-1`).
18
+ * It follows semantic versioning (e.g., `0.113.0-4`).
19
19
  *
20
20
  * @generated
21
21
  */