@promptbook/cli 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.
Files changed (29) hide show
  1. package/esm/index.es.js +787 -8
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
  4. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +5 -0
  5. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +29 -0
  6. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +4 -0
  7. package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +75 -0
  8. package/esm/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
  9. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
  10. package/esm/src/version.d.ts +1 -1
  11. package/package.json +1 -1
  12. package/src/avatars/renderAvatarVisualAsciiArt.ts +138 -0
  13. package/src/other/templates/getTemplatesPipelineCollection.ts +713 -784
  14. package/src/utils/ascii-art/$detectTerminalAnsiColorDepth.ts +45 -0
  15. package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +399 -0
  16. package/src/version.ts +2 -2
  17. package/src/versions.txt +2 -0
  18. package/umd/index.umd.js +787 -8
  19. package/umd/index.umd.js.map +1 -1
  20. package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
  21. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +5 -0
  22. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +29 -0
  23. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +4 -0
  24. package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +75 -0
  25. package/umd/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
  26. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
  27. package/umd/src/version.d.ts +1 -1
  28. package/esm/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
  29. package/umd/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
package/umd/index.umd.js CHANGED
@@ -63,7 +63,7 @@
63
63
  * @generated
64
64
  * @see https://github.com/webgptorg/promptbook
65
65
  */
66
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-3';
66
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-5';
67
67
  /**
68
68
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
69
69
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4547,7 +4547,7 @@
4547
4547
  const visibleOutputLines = buildVisibleOutputLines(options.agentOutputLines);
4548
4548
  const controls = buildControlPills(pausePresentation.pauseControl, options.pendingEnterLabel).join(' ');
4549
4549
  const frame = [
4550
- ...buildCoderRunOctopusVisual({ totalWidth, animationFrame: octopusAnimationFrame }),
4550
+ ...buildFrameHeaderVisual(options, totalWidth, octopusAnimationFrame),
4551
4551
  '',
4552
4552
  ...renderBox('Session', sessionLines, totalWidth, colors__default["default"].yellow.bold),
4553
4553
  ...renderBox(options.currentPromptLabel ? 'Current task' : 'Queue', currentTaskLines, totalWidth, colors__default["default"].magenta.bold),
@@ -4559,6 +4559,18 @@
4559
4559
  frame.push(...renderBox('Controls', [controls], totalWidth, colors__default["default"].white.bold));
4560
4560
  return frame;
4561
4561
  }
4562
+ /**
4563
+ * Builds the header visual above the dashboard boxes.
4564
+ *
4565
+ * Shows the ASCII-art `--agent` avatar visual when one is available and
4566
+ * falls back to the default brand banner otherwise.
4567
+ */
4568
+ function buildFrameHeaderVisual(options, totalWidth, octopusAnimationFrame) {
4569
+ if (options.agentVisualLines !== undefined && options.agentVisualLines.length > 0) {
4570
+ return options.agentVisualLines.map((agentVisualLine) => centerAnsiText(agentVisualLine, totalWidth));
4571
+ }
4572
+ return buildCoderRunOctopusVisual({ totalWidth, animationFrame: octopusAnimationFrame });
4573
+ }
4562
4574
  /**
4563
4575
  * Builds the structured session lines that combine state, runner, queue, and timing metadata.
4564
4576
  */
@@ -4859,6 +4871,13 @@
4859
4871
  this.config = config;
4860
4872
  this.emitChange();
4861
4873
  }
4874
+ /**
4875
+ * Replaces the ASCII-art agent visual shown instead of the default brand banner.
4876
+ */
4877
+ setAgentVisualLines(agentVisualLines) {
4878
+ this.agentVisualLines = agentVisualLines === undefined ? undefined : [...agentVisualLines];
4879
+ this.emitChange();
4880
+ }
4862
4881
  /**
4863
4882
  * Feeds new prompt statistics from the main loop so the progress bar updates.
4864
4883
  */
@@ -5194,6 +5213,7 @@
5194
5213
  pauseState: getPauseState(),
5195
5214
  pauseTargetLabel: getPauseTargetLabel(),
5196
5215
  config: state.config,
5216
+ agentVisualLines: state.agentVisualLines,
5197
5217
  phase: state.phase,
5198
5218
  currentPromptLabel: state.currentPromptLabel,
5199
5219
  currentScriptPaths: state.currentScriptPaths,
@@ -9835,12 +9855,150 @@
9835
9855
  }
9836
9856
 
9837
9857
  /* eslint-disable no-magic-numbers */
9858
+ // Note: [💞] Ignore a discrepancy between file name and entity name
9859
+ /**
9860
+ * Default square size used by avatar renderers.
9861
+ *
9862
+ * @private utility of the avatar rendering system
9863
+ */
9864
+ const DEFAULT_AVATAR_SIZE = 192;
9865
+ /**
9866
+ * Default fallback hash used when no explicit hash is provided.
9867
+ *
9868
+ * @private utility of the avatar rendering system
9869
+ */
9870
+ const DEFAULT_AVATAR_HASH = '0000000000000000000000000000000000000000000000000000000000000000';
9871
+ /**
9872
+ * Default fallback name used when no explicit name is provided.
9873
+ *
9874
+ * @private utility of the avatar rendering system
9875
+ */
9876
+ const DEFAULT_AVATAR_NAME = 'Anonymous Agent';
9838
9877
  /**
9839
9878
  * Corner radius ratio used for the common rounded card frame.
9840
9879
  *
9841
9880
  * @private utility of the avatar rendering system
9842
9881
  */
9843
9882
  const FRAME_RADIUS_RATIO = 0.18;
9883
+ /**
9884
+ * Normalizes arbitrary agent colors into a stable non-empty color list.
9885
+ *
9886
+ * @param colors Raw color list.
9887
+ * @returns Stable list of usable colors.
9888
+ *
9889
+ * @private utility of the avatar rendering system
9890
+ */
9891
+ function normalizeAvatarColors(colors) {
9892
+ const normalizedColors = colors
9893
+ .map((color) => String(color).trim())
9894
+ .filter((color) => color !== '')
9895
+ .map((color) => Color.fromSafe(color).toHex());
9896
+ if (normalizedColors.length > 0) {
9897
+ return normalizedColors;
9898
+ }
9899
+ return [PROMPTBOOK_COLOR.toHex()];
9900
+ }
9901
+ /**
9902
+ * Normalizes the avatar input so visuals can rely on consistent data.
9903
+ *
9904
+ * @param avatarDefinition Raw avatar input.
9905
+ * @returns Normalized avatar definition.
9906
+ *
9907
+ * @private utility of the avatar rendering system
9908
+ */
9909
+ function normalizeAvatarDefinition(avatarDefinition) {
9910
+ return {
9911
+ agentName: (avatarDefinition.agentName || DEFAULT_AVATAR_NAME).trim() || DEFAULT_AVATAR_NAME,
9912
+ agentHash: (avatarDefinition.agentHash || DEFAULT_AVATAR_HASH).trim() || DEFAULT_AVATAR_HASH,
9913
+ colors: normalizeAvatarColors(avatarDefinition.colors),
9914
+ };
9915
+ }
9916
+ /**
9917
+ * Extracts avatar colors from the flexible `META COLOR` agent field.
9918
+ *
9919
+ * @param colorValue Raw `META COLOR` value.
9920
+ * @returns Parsed avatar colors.
9921
+ *
9922
+ * @private utility of the avatar rendering system
9923
+ */
9924
+ function parseAvatarColors(colorValue) {
9925
+ if (!colorValue) {
9926
+ return [];
9927
+ }
9928
+ const colors = [];
9929
+ let currentColor = '';
9930
+ let bracketDepth = 0;
9931
+ for (const character of colorValue) {
9932
+ if (character === '(') {
9933
+ bracketDepth++;
9934
+ currentColor += character;
9935
+ continue;
9936
+ }
9937
+ if (character === ')') {
9938
+ bracketDepth = Math.max(0, bracketDepth - 1);
9939
+ currentColor += character;
9940
+ continue;
9941
+ }
9942
+ if (bracketDepth === 0 && [',', ';', '|', '\n'].includes(character)) {
9943
+ const normalizedColor = currentColor.trim();
9944
+ if (normalizedColor !== '') {
9945
+ colors.push(normalizedColor);
9946
+ }
9947
+ currentColor = '';
9948
+ continue;
9949
+ }
9950
+ currentColor += character;
9951
+ }
9952
+ const lastColor = currentColor.trim();
9953
+ if (lastColor !== '') {
9954
+ colors.push(lastColor);
9955
+ }
9956
+ return colors;
9957
+ }
9958
+ /**
9959
+ * Creates a reusable avatar definition from parsed agent information.
9960
+ *
9961
+ * @param agentBasicInformation Parsed agent information.
9962
+ * @returns Avatar definition ready for canvas rendering.
9963
+ *
9964
+ * @private shared helper for app-level avatar previews
9965
+ */
9966
+ function createAvatarDefinitionFromAgentBasicInformation(agentBasicInformation) {
9967
+ return normalizeAvatarDefinition({
9968
+ agentName: agentBasicInformation.agentName,
9969
+ agentHash: agentBasicInformation.agentHash,
9970
+ colors: parseAvatarColors(agentBasicInformation.meta.color),
9971
+ });
9972
+ }
9973
+ /**
9974
+ * Creates the shared derived palette used by every avatar visual.
9975
+ *
9976
+ * @param avatarDefinition Stable avatar definition.
9977
+ * @param surface Surface style used by the parent UI.
9978
+ * @returns Derived palette.
9979
+ *
9980
+ * @private utility of the avatar rendering system
9981
+ */
9982
+ function createAvatarPalette(avatarDefinition, surface = 'framed') {
9983
+ const normalizedAvatarDefinition = normalizeAvatarDefinition(avatarDefinition);
9984
+ const primaryColor = Color.fromSafe(normalizedAvatarDefinition.colors[0] || PROMPTBOOK_COLOR);
9985
+ const secondaryColor = Color.fromSafe(normalizedAvatarDefinition.colors[1] || primaryColor.then(lighten(0.12)).then(saturate(0.16)));
9986
+ const accentColor = Color.fromSafe(normalizedAvatarDefinition.colors[2] || primaryColor.then(saturate(0.32)).then(lighten(0.22)));
9987
+ const backgroundColor = Color.fromSafe(primaryColor.then(darken(0.34)).then(saturate(-0.1)));
9988
+ const backgroundSecondaryColor = Color.fromSafe(secondaryColor.then(darken(0.42)).then(saturate(-0.16)).then(lighten(0.04)));
9989
+ const highlightColor = Color.fromSafe(accentColor.then(lighten(0.22)).then(saturate(0.08)));
9990
+ const shadowColor = Color.fromSafe(primaryColor.then(darken(0.46)).then(saturate(0.14)));
9991
+ return {
9992
+ background: surface === 'transparent' ? 'transparent' : backgroundColor.toHex(),
9993
+ backgroundSecondary: surface === 'transparent' ? 'transparent' : backgroundSecondaryColor.toHex(),
9994
+ primary: primaryColor.toHex(),
9995
+ secondary: secondaryColor.toHex(),
9996
+ accent: accentColor.toHex(),
9997
+ highlight: highlightColor.toHex(),
9998
+ shadow: shadowColor.toHex(),
9999
+ ink: createInkColor(primaryColor),
10000
+ };
10001
+ }
9844
10002
  /**
9845
10003
  * Draws the common rounded background frame used by most visuals.
9846
10004
  *
@@ -9891,6 +10049,67 @@
9891
10049
  context.arcTo(x, y, x + width, y, normalizedRadius);
9892
10050
  context.closePath();
9893
10051
  }
10052
+ /**
10053
+ * Creates a stable pseudo-random number generator from a string seed.
10054
+ *
10055
+ * @param seedSource String seed.
10056
+ * @returns Generator producing values in `[0, 1)`.
10057
+ *
10058
+ * @private utility of the avatar rendering system
10059
+ */
10060
+ function createSeededRandom(seedSource) {
10061
+ let state = hashStringToUint32(seedSource) || 0x9e3779b9;
10062
+ return () => {
10063
+ state = (state + 0x6d2b79f5) >>> 0;
10064
+ let hash = Math.imul(state ^ (state >>> 15), 1 | state);
10065
+ hash ^= hash + Math.imul(hash ^ (hash >>> 7), 61 | hash);
10066
+ return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
10067
+ };
10068
+ }
10069
+ /**
10070
+ * Creates a deterministic random factory scoped to the avatar definition.
10071
+ *
10072
+ * @param avatarDefinition Stable avatar definition.
10073
+ * @returns Random factory that can be re-seeded per visual part.
10074
+ *
10075
+ * @private utility of the avatar rendering system
10076
+ */
10077
+ function createAvatarRandomFactory(avatarDefinition) {
10078
+ const normalizedAvatarDefinition = normalizeAvatarDefinition(avatarDefinition);
10079
+ const seedBase = `${normalizedAvatarDefinition.agentName}|${normalizedAvatarDefinition.agentHash}|${normalizedAvatarDefinition.colors.join('|')}`;
10080
+ return (salt) => createSeededRandom(`${seedBase}|${salt}`);
10081
+ }
10082
+ /**
10083
+ * Clears and scales the canvas for crisp avatar rendering on high DPI displays.
10084
+ *
10085
+ * @param canvas Canvas element to prepare.
10086
+ * @param context Canvas 2D context.
10087
+ * @param size Canvas size in CSS pixels.
10088
+ * @param devicePixelRatio Device pixel ratio.
10089
+ *
10090
+ * @private utility of the avatar rendering system
10091
+ */
10092
+ function prepareAvatarCanvas(canvas, context, size, devicePixelRatio) {
10093
+ const normalizedDevicePixelRatio = Math.max(1, Math.round(devicePixelRatio * 100) / 100);
10094
+ const nextCanvasWidth = Math.round(size * normalizedDevicePixelRatio);
10095
+ const nextCanvasHeight = Math.round(size * normalizedDevicePixelRatio);
10096
+ const nextCanvasStyleWidth = `${size}px`;
10097
+ const nextCanvasStyleHeight = `${size}px`;
10098
+ if (canvas.width !== nextCanvasWidth) {
10099
+ canvas.width = nextCanvasWidth;
10100
+ }
10101
+ if (canvas.height !== nextCanvasHeight) {
10102
+ canvas.height = nextCanvasHeight;
10103
+ }
10104
+ if (canvas.style.width !== nextCanvasStyleWidth) {
10105
+ canvas.style.width = nextCanvasStyleWidth;
10106
+ }
10107
+ if (canvas.style.height !== nextCanvasStyleHeight) {
10108
+ canvas.style.height = nextCanvasStyleHeight;
10109
+ }
10110
+ context.setTransform(normalizedDevicePixelRatio, 0, 0, normalizedDevicePixelRatio, 0, 0);
10111
+ context.clearRect(0, 0, size, size);
10112
+ }
9894
10113
  /**
9895
10114
  * Picks one deterministic element from a non-empty collection.
9896
10115
  *
@@ -9903,6 +10122,37 @@
9903
10122
  function pickRandomItem(items, random) {
9904
10123
  return items[Math.floor(random() * items.length)];
9905
10124
  }
10125
+ /**
10126
+ * Creates a readable ink color from the given base color.
10127
+ *
10128
+ * @param color Base color.
10129
+ * @returns High-contrast ink color.
10130
+ *
10131
+ * @private utility of the avatar rendering system
10132
+ */
10133
+ function createInkColor(color) {
10134
+ const perceivedBrightness = color.red * 0.299 + color.green * 0.587 + color.blue * 0.114;
10135
+ if (perceivedBrightness > 150) {
10136
+ return '#172033';
10137
+ }
10138
+ return '#f8fbff';
10139
+ }
10140
+ /**
10141
+ * Hashes an arbitrary string into a 32-bit unsigned integer.
10142
+ *
10143
+ * @param value Arbitrary input.
10144
+ * @returns 32-bit unsigned integer hash.
10145
+ *
10146
+ * @private utility of the avatar rendering system
10147
+ */
10148
+ function hashStringToUint32(value) {
10149
+ let hash = 2166136261;
10150
+ for (const character of value) {
10151
+ hash ^= character.charCodeAt(0);
10152
+ hash = Math.imul(hash, 16777619);
10153
+ }
10154
+ return hash >>> 0;
10155
+ }
9906
10156
 
9907
10157
  /* eslint-disable no-magic-numbers */
9908
10158
  /**
@@ -15890,6 +16140,21 @@
15890
16140
  .toLowerCase()
15891
16141
  .replace(/[^a-z0-9]+/g, '');
15892
16142
  }
16143
+ /**
16144
+ * Returns one avatar visual by its identifier.
16145
+ *
16146
+ * @param visualId Requested visual identifier.
16147
+ * @returns Matching visual definition.
16148
+ *
16149
+ * @private shared registry for the avatar rendering system
16150
+ */
16151
+ function getAvatarVisualById(visualId) {
16152
+ const avatarVisual = AVATAR_VISUALS.find((candidateAvatarVisual) => candidateAvatarVisual.id === visualId);
16153
+ if (!avatarVisual) {
16154
+ throw new Error(`Unknown avatar visual "${visualId}".`);
16155
+ }
16156
+ return avatarVisual;
16157
+ }
15893
16158
  /**
15894
16159
  * Resolves a user-facing avatar visual value to a supported built-in visual id.
15895
16160
  *
@@ -28467,9 +28732,10 @@
28467
28732
  * Builds the shell script that runs Claude Code with the prompt and coding context.
28468
28733
  */
28469
28734
  function buildClaudeScript(options) {
28735
+ const MODEL_ARGUMENT = options.model ? ` --model ${options.model}` : '';
28470
28736
  const THINKING_LEVEL_ARGUMENT = options.thinkingLevel ? ` --effort ${options.thinkingLevel}` : '';
28471
28737
  return spaceTrim((block) => `
28472
- claude --allowedTools "Bash,Read,Edit,Write"${THINKING_LEVEL_ARGUMENT} --output-format json --print <<'${CLAUDE_PROMPT_DELIMITER}'
28738
+ claude --allowedTools "Bash,Read,Edit,Write"${MODEL_ARGUMENT}${THINKING_LEVEL_ARGUMENT} --output-format stream-json --verbose --include-partial-messages --print <<'${CLAUDE_PROMPT_DELIMITER}'
28473
28739
 
28474
28740
  ${block(options.prompt)}
28475
28741
 
@@ -28619,6 +28885,7 @@
28619
28885
  async runPrompt(options) {
28620
28886
  const scriptContent = buildClaudeScript({
28621
28887
  prompt: options.prompt,
28888
+ model: this.options.model,
28622
28889
  thinkingLevel: this.options.thinkingLevel,
28623
28890
  });
28624
28891
  const output = await $runGoScriptWithOutput({
@@ -29802,8 +30069,9 @@
29802
30069
  }
29803
30070
  if (agentName === 'claude-code') {
29804
30071
  return createRunnerResolution(options, new ClaudeCodeRunner({
30072
+ model: options.model,
29805
30073
  thinkingLevel: options.thinkingLevel,
29806
- }));
30074
+ }), options.model);
29807
30075
  }
29808
30076
  if (agentName === 'opencode') {
29809
30077
  return createRunnerResolution(options, new OpencodeRunner({
@@ -29877,7 +30145,7 @@
29877
30145
  if (options.agentName === 'cline') {
29878
30146
  return { runnerName, modelName: CLINE_MODEL };
29879
30147
  }
29880
- if (options.agentName === 'opencode') {
30148
+ if (options.agentName === 'opencode' || options.agentName === 'claude-code') {
29881
30149
  return { runnerName, modelName: options.model };
29882
30150
  }
29883
30151
  return { runnerName };
@@ -71223,7 +71491,7 @@
71223
71491
  *
71224
71492
  * Returns `undefined` when no agent path is provided.
71225
71493
  */
71226
- async function resolveAgentSystemMessage(agentPath, currentWorkingDirectory) {
71494
+ async function resolveCoderAgent(agentPath, currentWorkingDirectory) {
71227
71495
  if (!agentPath) {
71228
71496
  return undefined;
71229
71497
  }
@@ -71238,7 +71506,10 @@
71238
71506
  }
71239
71507
  throw error;
71240
71508
  });
71241
- return createAgentRunnerSystemMessage(agentSource);
71509
+ return {
71510
+ agentSource: agentSource,
71511
+ systemMessage: await createAgentRunnerSystemMessage(agentSource),
71512
+ };
71242
71513
  }
71243
71514
 
71244
71515
  /**
@@ -71436,6 +71707,498 @@
71436
71707
  await waitForEnter(colors__default["default"].bgWhite(`Press Enter to start the ${label}...`));
71437
71708
  }
71438
71709
 
71710
+ /**
71711
+ * Default alpha channel value below which a half-cell is rendered as terminal background.
71712
+ *
71713
+ * @private within the repository
71714
+ */
71715
+ const DEFAULT_ALPHA_THRESHOLD = 32;
71716
+ /**
71717
+ * Number of channels per pixel in an RGBA buffer.
71718
+ *
71719
+ * @private within the repository
71720
+ */
71721
+ const RGBA_CHANNEL_COUNT = 4;
71722
+ /**
71723
+ * Upper half block character - foreground paints the top pixel, background paints the bottom pixel.
71724
+ *
71725
+ * @private within the repository
71726
+ */
71727
+ const UPPER_HALF_BLOCK = '▀'; // <- ▀
71728
+ /**
71729
+ * Lower half block character - foreground paints the bottom pixel while the top pixel stays transparent.
71730
+ *
71731
+ * @private within the repository
71732
+ */
71733
+ const LOWER_HALF_BLOCK = '▄'; // <- ▄
71734
+ /**
71735
+ * ANSI escape sequence that resets all colors and attributes.
71736
+ *
71737
+ * @private within the repository
71738
+ */
71739
+ const ANSI_RESET = '\u001b[0m';
71740
+ /**
71741
+ * Maximum spread between RGB channels for a color to be treated as (nearly) achromatic gray.
71742
+ *
71743
+ * @private within the repository
71744
+ */
71745
+ const ANSI_256_ACHROMATIC_CHANNEL_SPREAD = 12;
71746
+ /**
71747
+ * Gray level above which an achromatic color maps to the pure white color-cube entry.
71748
+ *
71749
+ * @private within the repository
71750
+ */
71751
+ const ANSI_256_NEAR_WHITE_GRAY_LEVEL = 246;
71752
+ /**
71753
+ * Index of pure white inside the 6×6×6 ANSI color cube.
71754
+ *
71755
+ * @private within the repository
71756
+ */
71757
+ const ANSI_256_WHITE_INDEX = 231;
71758
+ /**
71759
+ * Brightness of the lightest entry of the ANSI 256 grayscale ramp.
71760
+ *
71761
+ * @private within the repository
71762
+ */
71763
+ const ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL = 238;
71764
+ /**
71765
+ * Number of grayscale ramp steps above its first entry (ANSI indexes 232-255).
71766
+ *
71767
+ * @private within the repository
71768
+ */
71769
+ const ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN = 23;
71770
+ /**
71771
+ * Converts raw RGBA image pixels into colored ASCII art for ANSI terminals.
71772
+ *
71773
+ * This is the universal image-to-terminal technique used across the repository:
71774
+ * every output character cell covers a rectangular region of source pixels which is
71775
+ * split into a top and bottom half; each half is area-averaged and rendered with
71776
+ * half-block characters (`▀` / `▄`) so one character shows two "pixels" vertically.
71777
+ * Transparent halves keep the terminal background so non-rectangular images
71778
+ * (for example rounded avatar cards) compose naturally into any terminal UI.
71779
+ *
71780
+ * @param options Source pixels, output grid size, and ANSI color depth.
71781
+ * @returns One ANSI-colored string per output row, each ending with a color reset.
71782
+ *
71783
+ * @private within the repository
71784
+ */
71785
+ function convertImageDataToAsciiArt(options) {
71786
+ const { imageData, columns, rows, colorDepth = 'TRUE_COLOR', alphaThreshold = DEFAULT_ALPHA_THRESHOLD } = options;
71787
+ if (!Number.isInteger(columns) || columns <= 0 || !Number.isInteger(rows) || rows <= 0) {
71788
+ throw new UnexpectedError(_spaceTrim.spaceTrim(`
71789
+ ASCII-art grid size is invalid.
71790
+
71791
+ Both \`columns\` and \`rows\` must be positive integers but \`${columns}\` × \`${rows}\` was requested.
71792
+ `));
71793
+ }
71794
+ if (imageData.width <= 0 ||
71795
+ imageData.height <= 0 ||
71796
+ imageData.data.length < imageData.width * imageData.height * RGBA_CHANNEL_COUNT) {
71797
+ throw new UnexpectedError(_spaceTrim.spaceTrim(`
71798
+ ASCII-art source image data is invalid.
71799
+
71800
+ Expected a RGBA buffer of at least \`${imageData.width} × ${imageData.height} × ${RGBA_CHANNEL_COUNT}\` bytes
71801
+ but got \`${imageData.data.length}\` bytes.
71802
+ `));
71803
+ }
71804
+ const halfCellRowCount = rows * 2;
71805
+ const asciiArtLines = [];
71806
+ for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
71807
+ let line = '';
71808
+ let currentForegroundCode = undefined;
71809
+ let currentBackgroundCode = undefined;
71810
+ for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
71811
+ const topHalfColor = computeHalfCellColor(imageData, columnIndex, rowIndex * 2, columns, halfCellRowCount, alphaThreshold);
71812
+ const bottomHalfColor = computeHalfCellColor(imageData, columnIndex, rowIndex * 2 + 1, columns, halfCellRowCount, alphaThreshold);
71813
+ let character;
71814
+ let nextForegroundCode;
71815
+ let nextBackgroundCode;
71816
+ if (topHalfColor.isOpaque && bottomHalfColor.isOpaque) {
71817
+ character = UPPER_HALF_BLOCK;
71818
+ nextForegroundCode = createForegroundColorCode(topHalfColor, colorDepth);
71819
+ nextBackgroundCode = createBackgroundColorCode(bottomHalfColor, colorDepth);
71820
+ }
71821
+ else if (topHalfColor.isOpaque) {
71822
+ character = UPPER_HALF_BLOCK;
71823
+ nextForegroundCode = createForegroundColorCode(topHalfColor, colorDepth);
71824
+ nextBackgroundCode = undefined;
71825
+ }
71826
+ else if (bottomHalfColor.isOpaque) {
71827
+ character = LOWER_HALF_BLOCK;
71828
+ nextForegroundCode = createForegroundColorCode(bottomHalfColor, colorDepth);
71829
+ nextBackgroundCode = undefined;
71830
+ }
71831
+ else {
71832
+ character = ' ';
71833
+ nextForegroundCode = undefined;
71834
+ nextBackgroundCode = undefined;
71835
+ }
71836
+ if (nextForegroundCode !== currentForegroundCode || nextBackgroundCode !== currentBackgroundCode) {
71837
+ // Note: A reset is required whenever a previously set color must be cleared,
71838
+ // otherwise stale background color would bleed into transparent cells.
71839
+ const isResetNeeded = (currentForegroundCode !== undefined && nextForegroundCode === undefined) ||
71840
+ (currentBackgroundCode !== undefined && nextBackgroundCode === undefined);
71841
+ if (isResetNeeded) {
71842
+ line += ANSI_RESET;
71843
+ currentForegroundCode = undefined;
71844
+ currentBackgroundCode = undefined;
71845
+ }
71846
+ if (nextForegroundCode !== undefined && nextForegroundCode !== currentForegroundCode) {
71847
+ line += nextForegroundCode;
71848
+ }
71849
+ if (nextBackgroundCode !== undefined && nextBackgroundCode !== currentBackgroundCode) {
71850
+ line += nextBackgroundCode;
71851
+ }
71852
+ currentForegroundCode = nextForegroundCode;
71853
+ currentBackgroundCode = nextBackgroundCode;
71854
+ }
71855
+ line += character;
71856
+ }
71857
+ if (currentForegroundCode !== undefined || currentBackgroundCode !== undefined) {
71858
+ line += ANSI_RESET;
71859
+ }
71860
+ asciiArtLines.push(line);
71861
+ }
71862
+ return asciiArtLines;
71863
+ }
71864
+ /**
71865
+ * Computes the area-averaged color of one half-cell of the output grid.
71866
+ *
71867
+ * Color channels are alpha-weighted so semi-transparent edge pixels do not darken towards black.
71868
+ *
71869
+ * @private helper of `convertImageDataToAsciiArt`
71870
+ */
71871
+ function computeHalfCellColor(imageData, columnIndex, halfCellRowIndex, columns, halfCellRowCount, alphaThreshold) {
71872
+ const startX = Math.floor((columnIndex * imageData.width) / columns);
71873
+ const endX = Math.max(startX + 1, Math.floor(((columnIndex + 1) * imageData.width) / columns));
71874
+ const startY = Math.floor((halfCellRowIndex * imageData.height) / halfCellRowCount);
71875
+ const endY = Math.max(startY + 1, Math.floor(((halfCellRowIndex + 1) * imageData.height) / halfCellRowCount));
71876
+ let redSum = 0;
71877
+ let greenSum = 0;
71878
+ let blueSum = 0;
71879
+ let alphaSum = 0;
71880
+ let sampledPixelCount = 0;
71881
+ for (let y = startY; y < endY && y < imageData.height; y++) {
71882
+ for (let x = startX; x < endX && x < imageData.width; x++) {
71883
+ const pixelOffset = (y * imageData.width + x) * RGBA_CHANNEL_COUNT;
71884
+ const alpha = imageData.data[pixelOffset + 3];
71885
+ redSum += imageData.data[pixelOffset] * alpha;
71886
+ greenSum += imageData.data[pixelOffset + 1] * alpha;
71887
+ blueSum += imageData.data[pixelOffset + 2] * alpha;
71888
+ alphaSum += alpha;
71889
+ sampledPixelCount++;
71890
+ }
71891
+ }
71892
+ const averageAlpha = sampledPixelCount === 0 ? 0 : alphaSum / sampledPixelCount;
71893
+ if (averageAlpha < alphaThreshold || alphaSum === 0) {
71894
+ return { red: 0, green: 0, blue: 0, isOpaque: false };
71895
+ }
71896
+ return {
71897
+ red: Math.round(redSum / alphaSum),
71898
+ green: Math.round(greenSum / alphaSum),
71899
+ blue: Math.round(blueSum / alphaSum),
71900
+ isOpaque: true,
71901
+ };
71902
+ }
71903
+ /**
71904
+ * Creates the ANSI escape code that sets the foreground color of following characters.
71905
+ *
71906
+ * @private helper of `convertImageDataToAsciiArt`
71907
+ */
71908
+ function createForegroundColorCode(color, colorDepth) {
71909
+ if (colorDepth === 'TRUE_COLOR') {
71910
+ return `\u001b[38;2;${color.red};${color.green};${color.blue}m`;
71911
+ }
71912
+ return `\u001b[38;5;${mapColorToAnsi256(color)}m`;
71913
+ }
71914
+ /**
71915
+ * Creates the ANSI escape code that sets the background color of following characters.
71916
+ *
71917
+ * @private helper of `convertImageDataToAsciiArt`
71918
+ */
71919
+ function createBackgroundColorCode(color, colorDepth) {
71920
+ if (colorDepth === 'TRUE_COLOR') {
71921
+ return `\u001b[48;2;${color.red};${color.green};${color.blue}m`;
71922
+ }
71923
+ return `\u001b[48;5;${mapColorToAnsi256(color)}m`;
71924
+ }
71925
+ /**
71926
+ * Maps a 24-bit color onto the closest entry of the 256-color ANSI palette.
71927
+ *
71928
+ * Uses the 6×6×6 color cube (entries 16-231) and the grayscale ramp (entries 232-255).
71929
+ *
71930
+ * @private helper of `convertImageDataToAsciiArt`
71931
+ */
71932
+ function mapColorToAnsi256(color) {
71933
+ const { red, green, blue } = color;
71934
+ // Note: Prefer the finer grayscale ramp when the color is (nearly) achromatic
71935
+ const maxChannel = Math.max(red, green, blue);
71936
+ const minChannel = Math.min(red, green, blue);
71937
+ if (maxChannel - minChannel < ANSI_256_ACHROMATIC_CHANNEL_SPREAD) {
71938
+ const gray = Math.round((red + green + blue) / 3);
71939
+ if (gray < 4) {
71940
+ return 16; // <- Note: Pure black lives in the color cube
71941
+ }
71942
+ if (gray > ANSI_256_NEAR_WHITE_GRAY_LEVEL) {
71943
+ return ANSI_256_WHITE_INDEX; // <- Note: Pure white lives in the color cube
71944
+ }
71945
+ return (232 +
71946
+ Math.round(((gray - 8) / ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL) * ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN));
71947
+ }
71948
+ const redIndex = Math.round((red / 255) * 5);
71949
+ const greenIndex = Math.round((green / 255) * 5);
71950
+ const blueIndex = Math.round((blue / 255) * 5);
71951
+ return 16 + 36 * redIndex + 6 * greenIndex + blueIndex;
71952
+ }
71953
+
71954
+ /**
71955
+ * Stable zeroed interaction state used by non-interactive render paths.
71956
+ *
71957
+ * @private utility of the avatar rendering system
71958
+ */
71959
+ const IDLE_AVATAR_INTERACTION_STATE = {
71960
+ gazeX: 0,
71961
+ gazeY: 0,
71962
+ bodyOffsetX: 0,
71963
+ bodyOffsetY: 0,
71964
+ intensity: 0,
71965
+ isPointerActive: false,
71966
+ pointerType: 'idle',
71967
+ };
71968
+ /**
71969
+ * Returns the neutral interaction state used by static/server-side renders.
71970
+ *
71971
+ * @returns Zeroed interaction state.
71972
+ *
71973
+ * @private utility of the avatar rendering system
71974
+ */
71975
+ function createIdleAvatarInteractionState() {
71976
+ return IDLE_AVATAR_INTERACTION_STATE;
71977
+ }
71978
+
71979
+ /**
71980
+ * Resolves the stable avatar render inputs reused across multiple frames.
71981
+ *
71982
+ * @param options Avatar identity and visual selection.
71983
+ * @returns Stable render data ready to be used by `renderAvatarVisual`.
71984
+ *
71985
+ * @private shared helper for canvas avatar rendering
71986
+ */
71987
+ function resolveAvatarRenderDefinition(options) {
71988
+ const avatarDefinition = normalizeAvatarDefinition(options.avatarDefinition);
71989
+ const surface = options.surface || 'framed';
71990
+ return {
71991
+ avatarDefinition,
71992
+ avatarVisual: getAvatarVisualById(options.visualId),
71993
+ surface,
71994
+ palette: createAvatarPalette(avatarDefinition, surface),
71995
+ createRandom: createAvatarRandomFactory(avatarDefinition),
71996
+ };
71997
+ }
71998
+ /**
71999
+ * Renders one deterministic avatar frame into the provided canvas.
72000
+ *
72001
+ * @param options Rendering options.
72002
+ * @param resolvedAvatarRenderDefinition Optional stable render data reused between frames.
72003
+ *
72004
+ * @private shared helper for canvas avatar rendering
72005
+ */
72006
+ function renderAvatarVisual(options, resolvedAvatarRenderDefinition) {
72007
+ const resolvedRenderDefinition = resolvedAvatarRenderDefinition ||
72008
+ resolveAvatarRenderDefinition({
72009
+ avatarDefinition: options.avatarDefinition,
72010
+ visualId: options.visualId,
72011
+ surface: options.surface,
72012
+ });
72013
+ const context = options.canvas.getContext('2d');
72014
+ if (!context) {
72015
+ throw new Error('2D canvas rendering context is unavailable.');
72016
+ }
72017
+ prepareAvatarCanvas(options.canvas, context, options.size, options.devicePixelRatio || 1);
72018
+ resolvedRenderDefinition.avatarVisual.render({
72019
+ canvas: options.canvas,
72020
+ context,
72021
+ size: options.size,
72022
+ devicePixelRatio: options.devicePixelRatio || 1,
72023
+ timeMs: options.timeMs,
72024
+ avatarDefinition: resolvedRenderDefinition.avatarDefinition,
72025
+ palette: resolvedRenderDefinition.palette,
72026
+ createRandom: resolvedRenderDefinition.createRandom,
72027
+ surface: resolvedRenderDefinition.surface,
72028
+ interaction: options.interaction || createIdleAvatarInteractionState(),
72029
+ });
72030
+ }
72031
+
72032
+ /**
72033
+ * Default output width of the ASCII avatar in terminal character cells.
72034
+ *
72035
+ * @private within the repository
72036
+ */
72037
+ const DEFAULT_AVATAR_ASCII_ART_COLUMNS = 32;
72038
+ /**
72039
+ * Stable animation timestamp used when rasterizing animated avatar visuals into a static ASCII frame.
72040
+ *
72041
+ * @private within the repository
72042
+ */
72043
+ const STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS = 840;
72044
+ /**
72045
+ * Renders one built-in avatar visual into ANSI-colored ASCII art for terminal display.
72046
+ *
72047
+ * This is the universal bridge between the canvas avatar visuals shown on the website and
72048
+ * text-based terminal UIs: the visual is rasterized through the exact same `renderAvatarVisual`
72049
+ * pipeline the web uses, then the resulting pixels are converted into colored half-block
72050
+ * characters by `convertImageDataToAsciiArt`.
72051
+ *
72052
+ * @param options Avatar identity, visual selection, output grid size, and the platform canvas factory.
72053
+ * @returns One ANSI-colored string per output row.
72054
+ *
72055
+ * @private within the repository
72056
+ */
72057
+ function renderAvatarVisualAsciiArt(options) {
72058
+ var _a, _b, _c;
72059
+ const columns = (_a = options.columns) !== null && _a !== void 0 ? _a : DEFAULT_AVATAR_ASCII_ART_COLUMNS;
72060
+ const rows = (_b = options.rows) !== null && _b !== void 0 ? _b : Math.round(columns / 2);
72061
+ const canvas = options.createCanvas(DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_SIZE);
72062
+ if (!canvas.style) {
72063
+ // Note: `renderAvatarVisual` expects a browser canvas shape; Node.js canvases only need this tiny compatibility shim.
72064
+ canvas.style = {};
72065
+ }
72066
+ renderAvatarVisual({
72067
+ canvas,
72068
+ avatarDefinition: options.avatarDefinition,
72069
+ visualId: options.visualId,
72070
+ size: DEFAULT_AVATAR_SIZE,
72071
+ timeMs: (_c = options.timeMs) !== null && _c !== void 0 ? _c : STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS,
72072
+ devicePixelRatio: 1,
72073
+ });
72074
+ const context = canvas.getContext('2d');
72075
+ if (!context) {
72076
+ throw new EnvironmentMismatchError(_spaceTrim.spaceTrim(`
72077
+ 2D canvas rendering context is unavailable while converting the avatar visual to ASCII art.
72078
+
72079
+ Provide a \`createCanvas\` factory whose canvases support \`getContext('2d')\`,
72080
+ for example \`createCanvas\` of \`@napi-rs/canvas\` in Node.js.
72081
+ `));
72082
+ }
72083
+ const imageData = context.getImageData(0, 0, DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_SIZE);
72084
+ return convertImageDataToAsciiArt({
72085
+ imageData,
72086
+ columns,
72087
+ rows,
72088
+ colorDepth: options.colorDepth,
72089
+ });
72090
+ }
72091
+
72092
+ /**
72093
+ * Default built-in avatar visual used when an agent does not define `META IMAGE`.
72094
+ *
72095
+ * @private shared avatar contract
72096
+ */
72097
+ const DEFAULT_AGENT_AVATAR_VISUAL_ID = 'octopus3d4';
72098
+ /**
72099
+ * Resolves the avatar visual preferred by an agent, then falls back to a federated server default
72100
+ * and finally to the caller/server default.
72101
+ *
72102
+ * @param agent Agent metadata and optional remote-profile visual id.
72103
+ * @param defaultAvatarVisualId Optional metadata-resolved server default.
72104
+ * @returns Supported avatar visual id.
72105
+ *
72106
+ * @private shared avatar contract
72107
+ */
72108
+ function resolveAgentAvatarVisualId(agent, defaultAvatarVisualId = DEFAULT_AGENT_AVATAR_VISUAL_ID) {
72109
+ var _a;
72110
+ return (resolveAvatarVisualId((_a = agent.meta) === null || _a === void 0 ? void 0 : _a.avatar) ||
72111
+ agent.avatarVisualId ||
72112
+ agent.defaultAgentAvatarVisualId ||
72113
+ defaultAvatarVisualId);
72114
+ }
72115
+
72116
+ /**
72117
+ * Detects the ANSI color depth supported by the current terminal.
72118
+ *
72119
+ * Prefers 24-bit true color when the environment advertises it (modern terminals such as
72120
+ * Windows Terminal, ConEmu, VS Code, mintty, iTerm2, and WezTerm) and falls back to the
72121
+ * portable 256-color palette otherwise.
72122
+ *
72123
+ * Note: `$` is used to indicate that this function is not a pure function - it reads the process environment
72124
+ *
72125
+ * @returns Color depth usable by `convertImageDataToAsciiArt`
72126
+ *
72127
+ * @private within the repository
72128
+ */
72129
+ function $detectTerminalAnsiColorDepth() {
72130
+ if (typeof process === 'undefined' || !process.env) {
72131
+ return 'ANSI_256';
72132
+ }
72133
+ const colorTerm = (process.env.COLORTERM || '').toLowerCase();
72134
+ if (colorTerm.includes('truecolor') || colorTerm.includes('24bit')) {
72135
+ return 'TRUE_COLOR';
72136
+ }
72137
+ if (process.env.WT_SESSION !== undefined) {
72138
+ return 'TRUE_COLOR'; // <- Note: Windows Terminal always supports true color but does not set COLORTERM
72139
+ }
72140
+ if (process.env.ConEmuANSI === 'ON') {
72141
+ return 'TRUE_COLOR';
72142
+ }
72143
+ const termProgram = process.env.TERM_PROGRAM || '';
72144
+ if (['vscode', 'iTerm.app', 'WezTerm', 'ghostty', 'Hyper'].includes(termProgram)) {
72145
+ return 'TRUE_COLOR';
72146
+ }
72147
+ const term = (process.env.TERM || '').toLowerCase();
72148
+ if (term.includes('truecolor') || term.includes('24bit') || term.includes('direct')) {
72149
+ return 'TRUE_COLOR';
72150
+ }
72151
+ return 'ANSI_256';
72152
+ }
72153
+
72154
+ /**
72155
+ * Output width of the coder-run agent visual in terminal character cells.
72156
+ *
72157
+ * @private internal constant of coder run UI
72158
+ */
72159
+ const CODER_RUN_AGENT_VISUAL_COLUMNS = 24;
72160
+ /**
72161
+ * Output height of the coder-run agent visual in terminal character cells.
72162
+ *
72163
+ * Half of the columns keeps the square avatar visually square in a common terminal font.
72164
+ *
72165
+ * @private internal constant of coder run UI
72166
+ */
72167
+ const CODER_RUN_AGENT_VISUAL_ROWS = 12;
72168
+ /**
72169
+ * Builds the ANSI ASCII-art visual of the `--agent` book shown above the coder-run dashboard.
72170
+ *
72171
+ * The agent's avatar visual is resolved the same way as on the website - the `META AVATAR`
72172
+ * commitment wins, then the `META VISUAL` commitment, then the shared default visual - and is
72173
+ * rendered dynamically through the shared canvas avatar pipeline into terminal ASCII art.
72174
+ *
72175
+ * The visual is decorative, so any failure (for example when the optional `@napi-rs/canvas`
72176
+ * module is not installed) returns `null` and the caller keeps the default brand banner.
72177
+ *
72178
+ * @param agentSource Source of the `--agent` book file.
72179
+ * @returns ANSI-colored ASCII-art lines or `null` when the visual cannot be rendered.
72180
+ */
72181
+ async function buildCoderRunAgentVisual(agentSource) {
72182
+ try {
72183
+ // Note: `@napi-rs/canvas` is an optional native module, so it is imported dynamically and lazily
72184
+ const { createCanvas } = await import('@napi-rs/canvas');
72185
+ const agentBasicInformation = parseAgentSource(agentSource);
72186
+ const avatarDefinition = createAvatarDefinitionFromAgentBasicInformation(agentBasicInformation);
72187
+ const avatarVisualId = resolveAgentAvatarVisualId(agentBasicInformation, resolveAvatarVisualId(agentBasicInformation.meta.visual) || DEFAULT_AGENT_AVATAR_VISUAL_ID);
72188
+ return renderAvatarVisualAsciiArt({
72189
+ avatarDefinition,
72190
+ visualId: avatarVisualId,
72191
+ columns: CODER_RUN_AGENT_VISUAL_COLUMNS,
72192
+ rows: CODER_RUN_AGENT_VISUAL_ROWS,
72193
+ colorDepth: $detectTerminalAnsiColorDepth(),
72194
+ createCanvas: (width, height) => createCanvas(width, height),
72195
+ });
72196
+ }
72197
+ catch (error) {
72198
+ return null;
72199
+ }
72200
+ }
72201
+
71439
72202
  /**
71440
72203
  * Formats commit message lines for console display.
71441
72204
  */
@@ -73352,13 +74115,15 @@
73352
74115
  startPauseListenerIfNeeded(isRichUiEnabled);
73353
74116
  try {
73354
74117
  const resolvedCoderContext = await resolveCoderContext(options.context, process.cwd());
73355
- const resolvedAgentSystemMessage = await resolveAgentSystemMessage(options.agent, process.cwd());
74118
+ const resolvedCoderAgent = await resolveCoderAgent(options.agent, process.cwd());
74119
+ const resolvedAgentSystemMessage = resolvedCoderAgent === null || resolvedCoderAgent === void 0 ? void 0 : resolvedCoderAgent.systemMessage;
73356
74120
  if (await runDryRunIfRequested(options)) {
73357
74121
  return;
73358
74122
  }
73359
74123
  const { runner, actualRunnerModel, runnerMetadata } = resolvePromptRunner(options);
73360
74124
  console.info(colors__default["default"].green(`Running prompts with ${runner.name}`));
73361
74125
  initializeRunUi(uiHandle, runner.name, actualRunnerModel, options);
74126
+ await initializeRunUiAgentVisual(uiHandle, resolvedCoderAgent === null || resolvedCoderAgent === void 0 ? void 0 : resolvedCoderAgent.agentSource);
73362
74127
  await seedCachedAveragePromptDuration({
73363
74128
  options,
73364
74129
  actualRunnerModel,
@@ -73596,6 +74361,20 @@
73596
74361
  uiHandle === null || uiHandle === void 0 ? void 0 : uiHandle.state.setPhase('loading');
73597
74362
  uiHandle === null || uiHandle === void 0 ? void 0 : uiHandle.state.setStatusMessage(`Running prompts with ${runnerName}`);
73598
74363
  }
74364
+ /**
74365
+ * Renders the `--agent` book avatar as ASCII art and shows it instead of the default brand banner.
74366
+ *
74367
+ * Keeps the default banner when no agent is selected, the UI is disabled, or the visual cannot be rendered.
74368
+ */
74369
+ async function initializeRunUiAgentVisual(uiHandle, agentSource) {
74370
+ if (!uiHandle || !agentSource) {
74371
+ return;
74372
+ }
74373
+ const agentVisualLines = await buildCoderRunAgentVisual(agentSource);
74374
+ if (agentVisualLines) {
74375
+ uiHandle.state.setAgentVisualLines(agentVisualLines);
74376
+ }
74377
+ }
73599
74378
  /**
73600
74379
  * Loads prompt files, updates progress displays, and selects the next runnable prompt.
73601
74380
  */