@promptbook/cli 0.112.0-44 → 0.112.0-45
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 +675 -491
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/CoderRunTimer.d.ts +31 -0
- package/esm/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +23 -0
- package/esm/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +13 -4
- package/esm/scripts/run-codex-prompts/common/progressFormatting.d.ts +16 -0
- package/esm/scripts/run-codex-prompts/common/runGoScript/$runGoScript.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/$runGoScriptUntilMarkerIdle.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/$runGoScriptWithOutput.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/shouldDeleteTemporaryArtifact.d.ts +7 -0
- package/esm/scripts/run-codex-prompts/common/runGoScript/withPromptRuntimeLog.d.ts +4 -3
- package/esm/scripts/run-codex-prompts/common/runGoScript/withTempScript.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +1 -0
- package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +15 -20
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +28 -0
- package/esm/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +2 -0
- package/esm/src/avatars/Avatar.d.ts +7 -0
- package/esm/src/avatars/avatarRenderingUtils.d.ts +117 -0
- package/esm/src/avatars/index.d.ts +6 -0
- package/esm/src/avatars/renderAvatarVisual.d.ts +9 -0
- package/esm/src/avatars/types/AvatarDefinition.d.ts +20 -0
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +96 -0
- package/esm/src/avatars/visuals/avatarVisualRegistry.d.ts +16 -0
- package/esm/src/avatars/visuals/minecraftAvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/octopusAvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/pixelArtAvatarVisual.d.ts +7 -0
- package/esm/src/commitments/STYLE/STYLE.d.ts +9 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +675 -491
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/CoderRunTimer.d.ts +31 -0
- package/umd/scripts/run-codex-prompts/common/buildCoderRunProgressSnapshot.d.ts +23 -0
- package/umd/scripts/run-codex-prompts/common/cliProgressDisplay.d.ts +13 -4
- package/umd/scripts/run-codex-prompts/common/progressFormatting.d.ts +16 -0
- package/umd/scripts/run-codex-prompts/common/runGoScript/$runGoScript.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/$runGoScriptUntilMarkerIdle.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/$runGoScriptWithOutput.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/shouldDeleteTemporaryArtifact.d.ts +7 -0
- package/umd/scripts/run-codex-prompts/common/runGoScript/withPromptRuntimeLog.d.ts +4 -3
- package/umd/scripts/run-codex-prompts/common/runGoScript/withTempScript.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +1 -0
- package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +15 -20
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +28 -0
- package/umd/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +2 -0
- package/umd/src/avatars/Avatar.d.ts +7 -0
- package/umd/src/avatars/avatarRenderingUtils.d.ts +117 -0
- package/umd/src/avatars/index.d.ts +6 -0
- package/umd/src/avatars/renderAvatarVisual.d.ts +9 -0
- package/umd/src/avatars/types/AvatarDefinition.d.ts +20 -0
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +96 -0
- package/umd/src/avatars/visuals/avatarVisualRegistry.d.ts +16 -0
- package/umd/src/avatars/visuals/minecraftAvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/octopusAvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/pixelArtAvatarVisual.d.ts +7 -0
- package/umd/src/commitments/STYLE/STYLE.d.ts +9 -2
- package/umd/src/version.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/PromptRoundArtifacts.d.ts +0 -35
- package/umd/scripts/run-codex-prompts/common/runGoScript/PromptRoundArtifacts.d.ts +0 -35
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
/**
|
|
3
|
+
* Tracks active coder-run time while excluding pauses and user-confirmation waits.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CoderRunTimer {
|
|
6
|
+
private readonly startTime;
|
|
7
|
+
/**
|
|
8
|
+
* Total milliseconds spent in paused state across the run.
|
|
9
|
+
*/
|
|
10
|
+
private pausedMs;
|
|
11
|
+
/**
|
|
12
|
+
* Timestamp when the timer was last paused, or `undefined` when active.
|
|
13
|
+
*/
|
|
14
|
+
private pausedSince;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a timer anchored at the provided start time.
|
|
17
|
+
*/
|
|
18
|
+
constructor(startTime: moment.Moment, isPausedInitially?: boolean);
|
|
19
|
+
/**
|
|
20
|
+
* Pauses active-time tracking until `resume()` is called.
|
|
21
|
+
*/
|
|
22
|
+
pause(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Resumes active-time tracking after a pause.
|
|
25
|
+
*/
|
|
26
|
+
resume(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the currently accumulated active duration.
|
|
29
|
+
*/
|
|
30
|
+
getElapsedDuration(): moment.Duration;
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import type { PromptStats } from '../prompts/types/PromptStats';
|
|
3
|
+
/**
|
|
4
|
+
* Shared progress metrics used by both coder-run terminal UIs.
|
|
5
|
+
*/
|
|
6
|
+
export type CoderRunProgressSnapshot = {
|
|
7
|
+
readonly totalPrompts: number;
|
|
8
|
+
readonly sessionDone: number;
|
|
9
|
+
readonly sessionRemaining: number;
|
|
10
|
+
readonly sessionTotal: number;
|
|
11
|
+
readonly currentPromptIndex: number;
|
|
12
|
+
readonly skippedPrompts: number;
|
|
13
|
+
readonly toBeWrittenPrompts: number;
|
|
14
|
+
readonly percentage: number;
|
|
15
|
+
readonly elapsedText: string;
|
|
16
|
+
readonly estimatedTotalText: string;
|
|
17
|
+
readonly estimatedLabel: string;
|
|
18
|
+
readonly isEstimatedTotalKnown: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Builds a session-scoped progress snapshot from prompt stats and elapsed active time.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildCoderRunProgressSnapshot(stats: PromptStats, elapsedDuration: moment.Duration, initialDone: number): CoderRunProgressSnapshot;
|
|
@@ -4,7 +4,7 @@ import type { PromptStats } from '../prompts/types/PromptStats';
|
|
|
4
4
|
* Compact CLI progress display that stays pinned at the top of the terminal.
|
|
5
5
|
*/
|
|
6
6
|
export declare class CliProgressDisplay {
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly minimumPriority;
|
|
8
8
|
private stats;
|
|
9
9
|
/**
|
|
10
10
|
* Initial number of completed prompts when the session started.
|
|
@@ -12,16 +12,25 @@ export declare class CliProgressDisplay {
|
|
|
12
12
|
*/
|
|
13
13
|
private initialDone;
|
|
14
14
|
private readonly isInteractive;
|
|
15
|
+
private readonly timer;
|
|
15
16
|
private isHeaderReserved;
|
|
16
17
|
private interval;
|
|
17
18
|
/**
|
|
18
19
|
* Creates a new display that uses the provided start time when computing estimates.
|
|
19
20
|
*/
|
|
20
|
-
constructor(startTime: moment.Moment);
|
|
21
|
+
constructor(startTime: moment.Moment, minimumPriority: number);
|
|
21
22
|
/**
|
|
22
23
|
* Updates the progress statistics shown in the header.
|
|
23
24
|
*/
|
|
24
25
|
update(stats: PromptStats): void;
|
|
26
|
+
/**
|
|
27
|
+
* Pauses the active timer while the runner is waiting for user input.
|
|
28
|
+
*/
|
|
29
|
+
pauseTimer(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Resumes the active timer after a pause.
|
|
32
|
+
*/
|
|
33
|
+
resumeTimer(): void;
|
|
25
34
|
/**
|
|
26
35
|
* Stops the automatic refresh cycle and renders the final header once more.
|
|
27
36
|
*/
|
|
@@ -35,7 +44,7 @@ export declare class CliProgressDisplay {
|
|
|
35
44
|
*/
|
|
36
45
|
private reserveHeaderLine;
|
|
37
46
|
/**
|
|
38
|
-
* Builds the
|
|
47
|
+
* Builds the colored progress text padded to the terminal width.
|
|
39
48
|
*/
|
|
40
|
-
private
|
|
49
|
+
private buildProgressLines;
|
|
41
50
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
/**
|
|
3
|
+
* Calendar formats used when displaying the estimated completion time.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ESTIMATED_DONE_CALENDAR_FORMATS: {
|
|
6
|
+
sameDay: string;
|
|
7
|
+
nextDay: string;
|
|
8
|
+
nextWeek: string;
|
|
9
|
+
lastDay: string;
|
|
10
|
+
lastWeek: string;
|
|
11
|
+
sameElse: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Formats a duration into a compact string such as "3h 12m" or "45s".
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatDurationBrief(duration: moment.Duration): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunGoScriptOptions } from './RunGoScriptOptions';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a temporary script file, runs it, and cleans it up
|
|
3
|
+
* Creates a temporary script file, runs it, and cleans it up unless preservation is requested or the run fails.
|
|
4
4
|
*/
|
|
5
5
|
export declare function $runGoScript(options: RunGoScriptOptions): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RunGoScriptUntilMarkerIdleOptions } from './RunGoScriptUntilMarkerIdleOptions';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a temporary script file, runs it, waits for a completion marker and idle time, and
|
|
3
|
+
* Creates a temporary script file, runs it, waits for a completion marker and idle time, and cleans it up unless preservation is requested or the run fails.
|
|
4
4
|
* Returns the captured output for post-processing.
|
|
5
5
|
*/
|
|
6
6
|
export declare function $runGoScriptUntilMarkerIdle(options: RunGoScriptUntilMarkerIdleOptions): Promise<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunGoScriptOptions } from './RunGoScriptOptions';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a temporary script file, runs it, captures output, and cleans it up
|
|
3
|
+
* Creates a temporary script file, runs it, captures output, and cleans it up unless preservation is requested or the run fails.
|
|
4
4
|
*/
|
|
5
5
|
export declare function $runGoScriptWithOutput(options: RunGoScriptOptions): Promise<string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether one temporary prompt artifact should be deleted after a round finishes.
|
|
3
|
+
*/
|
|
4
|
+
export declare function shouldDeleteTemporaryArtifact({ preserveArtifactsOnSuccess, hasFailed, }: {
|
|
5
|
+
preserveArtifactsOnSuccess?: boolean;
|
|
6
|
+
hasFailed: boolean;
|
|
7
|
+
}): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { PromptRoundArtifacts } from './PromptRoundArtifacts';
|
|
2
1
|
/**
|
|
3
|
-
* Runs one prompt-processing round with a dedicated temporary runtime log file
|
|
2
|
+
* Runs one prompt-processing round with a dedicated temporary runtime log file that is cleaned up only after successful non-preserved runs.
|
|
4
3
|
*/
|
|
5
|
-
export declare function withPromptRuntimeLog<T>(scriptPath: string, handler: (logPath: string) => Promise<T>,
|
|
4
|
+
export declare function withPromptRuntimeLog<T>(scriptPath: string, handler: (logPath: string) => Promise<T>, options?: {
|
|
5
|
+
preserveArtifactsOnSuccess?: boolean;
|
|
6
|
+
}): Promise<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunGoScriptOptions } from './RunGoScriptOptions';
|
|
2
2
|
/**
|
|
3
|
-
* Creates a temporary script file, runs a handler, and
|
|
3
|
+
* Creates a temporary script file, runs a handler, and cleans it up unless preservation is requested or the run fails.
|
|
4
4
|
*/
|
|
5
5
|
export declare function withTempScript<T>(options: RunGoScriptOptions, handler: (scriptPath: string) => Promise<T>): Promise<T>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import moment from 'moment';
|
|
4
|
+
import { type CoderRunProgressSnapshot } from '../common/buildCoderRunProgressSnapshot';
|
|
4
5
|
import type { PromptStats } from '../prompts/types/PromptStats';
|
|
5
6
|
/**
|
|
6
7
|
* Execution phase of the coder run process.
|
|
7
8
|
*
|
|
8
9
|
* @private internal type of coder run UI
|
|
9
10
|
*/
|
|
10
|
-
export type CoderRunPhase = 'initializing' | 'loading' | 'running' | 'verifying' | 'paused' | 'done' | 'error';
|
|
11
|
+
export type CoderRunPhase = 'initializing' | 'loading' | 'running' | 'verifying' | 'waiting' | 'paused' | 'done' | 'error';
|
|
11
12
|
/**
|
|
12
13
|
* Configuration display data for the coder run UI header.
|
|
13
14
|
*
|
|
@@ -22,19 +23,11 @@ export type CoderRunConfig = {
|
|
|
22
23
|
readonly testCommand?: string;
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Re-exported shared progress snapshot type used by the coder run UI.
|
|
26
27
|
*
|
|
27
28
|
* @private internal type of coder run UI
|
|
28
29
|
*/
|
|
29
|
-
export type CoderRunProgressSnapshot
|
|
30
|
-
readonly totalPrompts: number;
|
|
31
|
-
readonly sessionDone: number;
|
|
32
|
-
readonly sessionTotal: number;
|
|
33
|
-
readonly percentage: number;
|
|
34
|
-
readonly elapsedText: string;
|
|
35
|
-
readonly estimatedTotalText: string;
|
|
36
|
-
readonly estimatedLabel: string;
|
|
37
|
-
};
|
|
30
|
+
export type { CoderRunProgressSnapshot };
|
|
38
31
|
/**
|
|
39
32
|
* Reactive state manager for the coder run terminal UI.
|
|
40
33
|
*
|
|
@@ -48,21 +41,15 @@ export declare class CoderRunUiState extends EventEmitter {
|
|
|
48
41
|
currentPromptLabel: string;
|
|
49
42
|
currentAttempt: number;
|
|
50
43
|
maxAttempts: number;
|
|
44
|
+
detailLines: string[];
|
|
45
|
+
pendingEnterLabel: string | undefined;
|
|
51
46
|
agentOutputLines: string[];
|
|
52
47
|
phase: CoderRunPhase;
|
|
53
48
|
statusMessage: string;
|
|
54
49
|
errors: string[];
|
|
55
50
|
private stats;
|
|
56
|
-
private readonly
|
|
51
|
+
private readonly timer;
|
|
57
52
|
private initialDone;
|
|
58
|
-
/**
|
|
59
|
-
* Total milliseconds the timer was paused/waiting (excluded from elapsed display).
|
|
60
|
-
*/
|
|
61
|
-
private pausedMs;
|
|
62
|
-
/**
|
|
63
|
-
* Timestamp when the timer was last paused, or `undefined` when running.
|
|
64
|
-
*/
|
|
65
|
-
private pausedSince;
|
|
66
53
|
constructor(startTime: moment.Moment);
|
|
67
54
|
/**
|
|
68
55
|
* Pauses the elapsed timer (e.g. while waiting for user input or paused state).
|
|
@@ -104,6 +91,14 @@ export declare class CoderRunUiState extends EventEmitter {
|
|
|
104
91
|
* Updates the status message line beneath the current prompt label.
|
|
105
92
|
*/
|
|
106
93
|
setStatusMessage(message: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Replaces the contextual detail lines shown beneath the current prompt status.
|
|
96
|
+
*/
|
|
97
|
+
setDetailLines(detailLines: string[]): void;
|
|
98
|
+
/**
|
|
99
|
+
* Sets or clears the Enter-key action label shown in the controls panel.
|
|
100
|
+
*/
|
|
101
|
+
setPendingEnterLabel(pendingEnterLabel: string | undefined): void;
|
|
107
102
|
/**
|
|
108
103
|
* Appends an error message to the error list shown in the UI.
|
|
109
104
|
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CoderRunConfig, CoderRunPhase, CoderRunProgressSnapshot } from './CoderRunUiState';
|
|
2
|
+
/**
|
|
3
|
+
* Shared pause-state shape between the renderer and the frame builder.
|
|
4
|
+
*/
|
|
5
|
+
export type CoderRunPauseState = 'RUNNING' | 'PAUSING' | 'PAUSED';
|
|
6
|
+
/**
|
|
7
|
+
* Snapshot consumed by the pure coder-run frame builder.
|
|
8
|
+
*/
|
|
9
|
+
export type BuildCoderRunUiFrameOptions = {
|
|
10
|
+
readonly terminalWidth: number;
|
|
11
|
+
readonly spinner: string;
|
|
12
|
+
readonly pauseState: CoderRunPauseState;
|
|
13
|
+
readonly config: CoderRunConfig;
|
|
14
|
+
readonly phase: CoderRunPhase;
|
|
15
|
+
readonly currentPromptLabel: string;
|
|
16
|
+
readonly currentAttempt: number;
|
|
17
|
+
readonly maxAttempts: number;
|
|
18
|
+
readonly statusMessage: string;
|
|
19
|
+
readonly detailLines: readonly string[];
|
|
20
|
+
readonly pendingEnterLabel?: string;
|
|
21
|
+
readonly agentOutputLines: readonly string[];
|
|
22
|
+
readonly errors: readonly string[];
|
|
23
|
+
readonly progress: CoderRunProgressSnapshot;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Builds the complete boxed terminal frame for the rich `ptbk coder run` UI.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildCoderRunUiFrame(options: BuildCoderRunUiFrameOptions): string[];
|
|
@@ -12,6 +12,8 @@ export type CoderRunUiHandle = {
|
|
|
12
12
|
startCapturingAgentOutput(): void;
|
|
13
13
|
/** Disables console interception so normal logging resumes. */
|
|
14
14
|
stopCapturingAgentOutput(): void;
|
|
15
|
+
/** Waits for Enter without leaving the rich terminal UI. */
|
|
16
|
+
waitForEnter(actionLabel: string): Promise<void>;
|
|
15
17
|
/** Tears down the UI and restores original console methods. */
|
|
16
18
|
cleanup(): void;
|
|
17
19
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AvatarProps } from './types/AvatarVisualDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Canvas-based deterministic avatar component.
|
|
4
|
+
*
|
|
5
|
+
* @private shared component for in-repository avatar previews
|
|
6
|
+
*/
|
|
7
|
+
export declare function Avatar(props: AvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { AgentBasicInformation } from '../book-2.0/agent-source/AgentBasicInformation';
|
|
2
|
+
import type { string_color } from '../types/typeAliases';
|
|
3
|
+
import type { AvatarDefinition } from './types/AvatarDefinition';
|
|
4
|
+
import type { AvatarPalette } from './types/AvatarVisualDefinition';
|
|
5
|
+
/**
|
|
6
|
+
* Default square size used by avatar renderers.
|
|
7
|
+
*
|
|
8
|
+
* @private utility of the avatar rendering system
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_AVATAR_SIZE = 192;
|
|
11
|
+
/**
|
|
12
|
+
* Normalizes arbitrary agent colors into a stable non-empty color list.
|
|
13
|
+
*
|
|
14
|
+
* @param colors Raw color list.
|
|
15
|
+
* @returns Stable list of usable colors.
|
|
16
|
+
*
|
|
17
|
+
* @private utility of the avatar rendering system
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeAvatarColors(colors: ReadonlyArray<string_color>): ReadonlyArray<string_color>;
|
|
20
|
+
/**
|
|
21
|
+
* Normalizes the avatar input so visuals can rely on consistent data.
|
|
22
|
+
*
|
|
23
|
+
* @param avatarDefinition Raw avatar input.
|
|
24
|
+
* @returns Normalized avatar definition.
|
|
25
|
+
*
|
|
26
|
+
* @private utility of the avatar rendering system
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeAvatarDefinition(avatarDefinition: AvatarDefinition): AvatarDefinition;
|
|
29
|
+
/**
|
|
30
|
+
* Extracts avatar colors from the flexible `META COLOR` agent field.
|
|
31
|
+
*
|
|
32
|
+
* @param colorValue Raw `META COLOR` value.
|
|
33
|
+
* @returns Parsed avatar colors.
|
|
34
|
+
*
|
|
35
|
+
* @private utility of the avatar rendering system
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseAvatarColors(colorValue: string | undefined): ReadonlyArray<string_color>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a reusable avatar definition from parsed agent information.
|
|
40
|
+
*
|
|
41
|
+
* @param agentBasicInformation Parsed agent information.
|
|
42
|
+
* @returns Avatar definition ready for canvas rendering.
|
|
43
|
+
*
|
|
44
|
+
* @private shared helper for app-level avatar previews
|
|
45
|
+
*/
|
|
46
|
+
export declare function createAvatarDefinitionFromAgentBasicInformation(agentBasicInformation: Pick<AgentBasicInformation, 'agentName' | 'agentHash' | 'meta'>): AvatarDefinition;
|
|
47
|
+
/**
|
|
48
|
+
* Creates the shared derived palette used by every avatar visual.
|
|
49
|
+
*
|
|
50
|
+
* @param avatarDefinition Stable avatar definition.
|
|
51
|
+
* @returns Derived palette.
|
|
52
|
+
*
|
|
53
|
+
* @private utility of the avatar rendering system
|
|
54
|
+
*/
|
|
55
|
+
export declare function createAvatarPalette(avatarDefinition: AvatarDefinition): AvatarPalette;
|
|
56
|
+
/**
|
|
57
|
+
* Draws the common rounded background frame used by most visuals.
|
|
58
|
+
*
|
|
59
|
+
* @param context Canvas 2D context.
|
|
60
|
+
* @param size Canvas size in CSS pixels.
|
|
61
|
+
* @param palette Derived avatar palette.
|
|
62
|
+
*
|
|
63
|
+
* @private utility of the avatar rendering system
|
|
64
|
+
*/
|
|
65
|
+
export declare function drawAvatarFrame(context: CanvasRenderingContext2D, size: number, palette: AvatarPalette): void;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a rounded rectangle path on the current canvas context.
|
|
68
|
+
*
|
|
69
|
+
* @param context Canvas 2D context.
|
|
70
|
+
* @param x Left coordinate.
|
|
71
|
+
* @param y Top coordinate.
|
|
72
|
+
* @param width Rectangle width.
|
|
73
|
+
* @param height Rectangle height.
|
|
74
|
+
* @param radius Corner radius.
|
|
75
|
+
*
|
|
76
|
+
* @private utility of the avatar rendering system
|
|
77
|
+
*/
|
|
78
|
+
export declare function createRoundedRectPath(context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a stable pseudo-random number generator from a string seed.
|
|
81
|
+
*
|
|
82
|
+
* @param seedSource String seed.
|
|
83
|
+
* @returns Generator producing values in `[0, 1)`.
|
|
84
|
+
*
|
|
85
|
+
* @private utility of the avatar rendering system
|
|
86
|
+
*/
|
|
87
|
+
export declare function createSeededRandom(seedSource: string): () => number;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a deterministic random factory scoped to the avatar definition.
|
|
90
|
+
*
|
|
91
|
+
* @param avatarDefinition Stable avatar definition.
|
|
92
|
+
* @returns Random factory that can be re-seeded per visual part.
|
|
93
|
+
*
|
|
94
|
+
* @private utility of the avatar rendering system
|
|
95
|
+
*/
|
|
96
|
+
export declare function createAvatarRandomFactory(avatarDefinition: AvatarDefinition): (salt: string) => () => number;
|
|
97
|
+
/**
|
|
98
|
+
* Clears and scales the canvas for crisp avatar rendering on high DPI displays.
|
|
99
|
+
*
|
|
100
|
+
* @param canvas Canvas element to prepare.
|
|
101
|
+
* @param context Canvas 2D context.
|
|
102
|
+
* @param size Canvas size in CSS pixels.
|
|
103
|
+
* @param devicePixelRatio Device pixel ratio.
|
|
104
|
+
*
|
|
105
|
+
* @private utility of the avatar rendering system
|
|
106
|
+
*/
|
|
107
|
+
export declare function prepareAvatarCanvas(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D, size: number, devicePixelRatio: number): void;
|
|
108
|
+
/**
|
|
109
|
+
* Picks one deterministic element from a non-empty collection.
|
|
110
|
+
*
|
|
111
|
+
* @param items Candidate items.
|
|
112
|
+
* @param random Seeded random generator.
|
|
113
|
+
* @returns Picked item.
|
|
114
|
+
*
|
|
115
|
+
* @private utility of the avatar rendering system
|
|
116
|
+
*/
|
|
117
|
+
export declare function pickRandomItem<T>(items: ReadonlyArray<T>, random: () => number): T;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Avatar } from './Avatar';
|
|
2
|
+
export { renderAvatarVisual } from './renderAvatarVisual';
|
|
3
|
+
export { createAvatarDefinitionFromAgentBasicInformation } from './avatarRenderingUtils';
|
|
4
|
+
export { AVATAR_VISUALS, getAvatarVisualById } from './visuals/avatarVisualRegistry';
|
|
5
|
+
export type { AvatarDefinition } from './types/AvatarDefinition';
|
|
6
|
+
export type { AvatarPalette, AvatarProps, AvatarVisual, AvatarVisualDefinition, AvatarVisualId, AvatarVisualRenderContext, RenderAvatarVisualOptions, } from './types/AvatarVisualDefinition';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RenderAvatarVisualOptions } from './types/AvatarVisualDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Renders one deterministic avatar frame into the provided canvas.
|
|
4
|
+
*
|
|
5
|
+
* @param options Rendering options.
|
|
6
|
+
*
|
|
7
|
+
* @private shared helper for canvas avatar rendering
|
|
8
|
+
*/
|
|
9
|
+
export declare function renderAvatarVisual(options: RenderAvatarVisualOptions): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { string_agent_hash, string_agent_name, string_color } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Normalized identity payload used by all canvas avatar visuals.
|
|
4
|
+
*
|
|
5
|
+
* @private shared contract for the avatar rendering system
|
|
6
|
+
*/
|
|
7
|
+
export type AvatarDefinition = {
|
|
8
|
+
/**
|
|
9
|
+
* Human-readable name of the agent.
|
|
10
|
+
*/
|
|
11
|
+
readonly agentName: string_agent_name;
|
|
12
|
+
/**
|
|
13
|
+
* Stable hash of the agent.
|
|
14
|
+
*/
|
|
15
|
+
readonly agentHash: string_agent_hash;
|
|
16
|
+
/**
|
|
17
|
+
* Ordered list of agent colors used to derive a palette.
|
|
18
|
+
*/
|
|
19
|
+
readonly colors: ReadonlyArray<string_color>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { string_color, string_css_class } from '../../types/typeAliases';
|
|
2
|
+
import type { AvatarDefinition } from './AvatarDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* Supported built-in avatar visual identifiers.
|
|
5
|
+
*
|
|
6
|
+
* @private shared contract for the avatar rendering system
|
|
7
|
+
*/
|
|
8
|
+
export type AvatarVisualId = 'pixel-art' | 'octopus' | 'minecraft';
|
|
9
|
+
/**
|
|
10
|
+
* Derived color palette used by avatar visuals.
|
|
11
|
+
*
|
|
12
|
+
* @private shared contract for the avatar rendering system
|
|
13
|
+
*/
|
|
14
|
+
export type AvatarPalette = {
|
|
15
|
+
readonly background: string_color;
|
|
16
|
+
readonly backgroundSecondary: string_color;
|
|
17
|
+
readonly primary: string_color;
|
|
18
|
+
readonly secondary: string_color;
|
|
19
|
+
readonly accent: string_color;
|
|
20
|
+
readonly highlight: string_color;
|
|
21
|
+
readonly shadow: string_color;
|
|
22
|
+
readonly ink: string_color;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Rendering context forwarded to a single avatar visual.
|
|
26
|
+
*
|
|
27
|
+
* @private shared contract for the avatar rendering system
|
|
28
|
+
*/
|
|
29
|
+
export type AvatarVisualRenderContext = {
|
|
30
|
+
readonly canvas: HTMLCanvasElement;
|
|
31
|
+
readonly context: CanvasRenderingContext2D;
|
|
32
|
+
readonly size: number;
|
|
33
|
+
readonly devicePixelRatio: number;
|
|
34
|
+
readonly timeMs: number;
|
|
35
|
+
readonly avatarDefinition: AvatarDefinition;
|
|
36
|
+
readonly palette: AvatarPalette;
|
|
37
|
+
readonly createRandom: (salt: string) => () => number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Signature of one canvas-based avatar visual renderer.
|
|
41
|
+
*
|
|
42
|
+
* @private shared contract for the avatar rendering system
|
|
43
|
+
*/
|
|
44
|
+
export type AvatarVisual = (context: AvatarVisualRenderContext) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Metadata and renderer for one built-in avatar visual.
|
|
47
|
+
*
|
|
48
|
+
* @private shared contract for the avatar rendering system
|
|
49
|
+
*/
|
|
50
|
+
export type AvatarVisualDefinition = {
|
|
51
|
+
readonly id: AvatarVisualId;
|
|
52
|
+
readonly title: string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
readonly isAnimated: boolean;
|
|
55
|
+
readonly render: AvatarVisual;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Props of the shared `<Avatar/>` component.
|
|
59
|
+
*
|
|
60
|
+
* @private shared contract for the avatar rendering system
|
|
61
|
+
*/
|
|
62
|
+
export type AvatarProps = {
|
|
63
|
+
/**
|
|
64
|
+
* Stable visual identity for the rendered avatar.
|
|
65
|
+
*/
|
|
66
|
+
readonly avatarDefinition: AvatarDefinition;
|
|
67
|
+
/**
|
|
68
|
+
* Selected visual style.
|
|
69
|
+
*/
|
|
70
|
+
readonly visualId: AvatarVisualId;
|
|
71
|
+
/**
|
|
72
|
+
* Output size in CSS pixels.
|
|
73
|
+
*/
|
|
74
|
+
readonly size?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Optional canvas title.
|
|
77
|
+
*/
|
|
78
|
+
readonly title?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Optional CSS class name applied to the canvas.
|
|
81
|
+
*/
|
|
82
|
+
readonly className?: string_css_class;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Low-level rendering options for a single canvas frame.
|
|
86
|
+
*
|
|
87
|
+
* @private shared contract for the avatar rendering system
|
|
88
|
+
*/
|
|
89
|
+
export type RenderAvatarVisualOptions = {
|
|
90
|
+
readonly canvas: HTMLCanvasElement;
|
|
91
|
+
readonly avatarDefinition: AvatarDefinition;
|
|
92
|
+
readonly visualId: AvatarVisualId;
|
|
93
|
+
readonly size: number;
|
|
94
|
+
readonly timeMs: number;
|
|
95
|
+
readonly devicePixelRatio?: number;
|
|
96
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AvatarVisualDefinition, AvatarVisualId } from '../types/AvatarVisualDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in avatar visuals available to the app.
|
|
4
|
+
*
|
|
5
|
+
* @private shared registry for the avatar rendering system
|
|
6
|
+
*/
|
|
7
|
+
export declare const AVATAR_VISUALS: ReadonlyArray<AvatarVisualDefinition>;
|
|
8
|
+
/**
|
|
9
|
+
* Returns one avatar visual by its identifier.
|
|
10
|
+
*
|
|
11
|
+
* @param visualId Requested visual identifier.
|
|
12
|
+
* @returns Matching visual definition.
|
|
13
|
+
*
|
|
14
|
+
* @private shared registry for the avatar rendering system
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAvatarVisualById(visualId: AvatarVisualId): AvatarVisualDefinition;
|
|
@@ -3,8 +3,8 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
|
3
3
|
/**
|
|
4
4
|
* STYLE commitment definition
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Deprecated legacy writing-style commitment kept for backward compatibility.
|
|
7
|
+
* New books should prefer `WRITING RULES` for writing-only constraints.
|
|
8
8
|
*
|
|
9
9
|
* Example usage in agent source:
|
|
10
10
|
*
|
|
@@ -21,6 +21,13 @@ export declare class StyleCommitmentDefinition extends BaseCommitmentDefinition<
|
|
|
21
21
|
* Short one-line description of STYLE.
|
|
22
22
|
*/
|
|
23
23
|
get description(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional UI/docs-only deprecation metadata.
|
|
26
|
+
*/
|
|
27
|
+
get deprecation(): {
|
|
28
|
+
readonly message: "Use `WRITING RULES` for writing-only constraints such as tone, length, formatting, or emoji usage.";
|
|
29
|
+
readonly replacedBy: readonly ["WRITING RULES"];
|
|
30
|
+
};
|
|
24
31
|
/**
|
|
25
32
|
* Icon for this commitment.
|
|
26
33
|
*/
|
package/esm/src/version.d.ts
CHANGED
|
@@ -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.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-44`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|