@promptbook/cli 0.113.0-4 → 0.113.0-6

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 (54) hide show
  1. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +13 -1
  2. package/apps/agents-server/src/search/createDefaultServerSearchProviders/loadLocalOrganizationSearchDataset.ts +12 -1
  3. package/apps/agents-server/src/utils/agentOrganization/loadAgentOrganizationState.ts +13 -1
  4. package/apps/agents-server/src/utils/createLocalAgentSourceImporter.ts +159 -0
  5. package/apps/agents-server/src/utils/createMissingImportedAgentFallback.ts +60 -0
  6. package/apps/agents-server/src/utils/customDomainRouting.ts +157 -12
  7. package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +1 -1
  8. package/apps/agents-server/src/utils/importAgentWithFallback.ts +1 -58
  9. package/apps/agents-server/src/utils/localAgentRouteReferences.ts +167 -0
  10. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +1 -1
  11. package/apps/agents-server/src/utils/managementApi/managementApiAgents.ts +17 -3
  12. package/apps/agents-server/src/utils/resolveAgentStateFromSource.ts +7 -1
  13. package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +54 -5
  14. package/apps/agents-server/src/utils/resolveServerAgentContext.ts +12 -1
  15. package/apps/agents-server/src/utils/resolveStoredAgentState.ts +2 -1
  16. package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +39 -9
  17. package/apps/agents-server/tests/e2e/support/ChatHistoryNavigationSupport.ts +5 -0
  18. package/esm/index.es.js +803 -39
  19. package/esm/index.es.js.map +1 -1
  20. package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
  21. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +5 -0
  22. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +29 -0
  23. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +4 -0
  24. package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +75 -0
  25. package/esm/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
  26. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
  27. package/esm/src/version.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/src/avatars/avatarAnimationScheduler.ts +2 -1
  30. package/src/avatars/renderAvatarVisualAsciiArt.ts +138 -0
  31. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +6 -2
  32. package/src/avatars/visuals/octopus3d4AvatarVisual.ts +14 -18
  33. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +3 -1
  34. package/src/cli/cli-commands/coder/boilerplateTemplates.ts +14 -21
  35. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +1 -4
  36. package/src/cli/cli-commands/coder/run.ts +2 -9
  37. package/src/commitments/TEAM/TEAM.ts +5 -5
  38. package/src/other/templates/getTemplatesPipelineCollection.ts +781 -943
  39. package/src/utils/ascii-art/$detectTerminalAnsiColorDepth.ts +45 -0
  40. package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +396 -0
  41. package/src/version.ts +2 -2
  42. package/src/versions.txt +2 -0
  43. package/umd/index.umd.js +803 -39
  44. package/umd/index.umd.js.map +1 -1
  45. package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
  46. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +5 -0
  47. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +29 -0
  48. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +4 -0
  49. package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +75 -0
  50. package/umd/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
  51. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
  52. package/umd/src/version.d.ts +1 -1
  53. package/esm/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
  54. 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-4';
66
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-6';
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
  /**
@@ -14418,7 +14668,7 @@
14418
14668
  isAnimated: true,
14419
14669
  supportsPointerTracking: true,
14420
14670
  render({ context, size, palette, createRandom, timeMs, interaction }) {
14421
- const { morphologyProfile, animationPhase, leftEyePhaseOffset, rightEyePhaseOffset, tentacleProfiles, skinSpots } = getOctopus3d4StableState(createRandom);
14671
+ const { morphologyProfile, animationPhase, leftEyePhaseOffset, rightEyePhaseOffset, tentacleProfiles, skinSpots, } = getOctopus3d4StableState(createRandom);
14422
14672
  const sceneCenterX = size * 0.5;
14423
14673
  const sceneCenterY = size * 0.535;
14424
14674
  const bob = Math.sin(timeMs / 980 + animationPhase) * size * 0.013;
@@ -14766,10 +15016,7 @@
14766
15016
  Math.max(0, Math.cos(effectiveLongitude)) * 0.12 +
14767
15017
  lowerBlend * tentacleInfluence.core * (0.12 + tentacleInfluence.depthScale * 0.07) -
14768
15018
  Math.max(0, -Math.cos(effectiveLongitude)) * 0.05;
14769
- const tentacleTubeRadius = lowerBlend *
14770
- tentacleInfluence.core *
14771
- (0.12 + tipBlend * 0.07 + tentacleInfluence.widthScale * 0.028) *
14772
- radiusX;
15019
+ const tentacleTubeRadius = lowerBlend * tentacleInfluence.core * (0.12 + tipBlend * 0.07 + tentacleInfluence.widthScale * 0.028) * radiusX;
14773
15020
  const planarRadiusX = cosineLatitude * radiusX * horizontalScale + tentacleTubeRadius;
14774
15021
  const planarRadiusZ = cosineLatitude * radiusZ * depthScale + tentacleTubeRadius * 0.74;
14775
15022
  const lowerDrop = lowerBlend *
@@ -14781,9 +15028,7 @@
14781
15028
  (morphologyProfile.tentacles.flowLengthScale - 1) * 0.1));
14782
15029
  const combinedTentacleSway = (primaryTentacleWave + secondaryTentacleWave) * radiusX * (0.06 + tipBlend * 0.06);
14783
15030
  return {
14784
- x: Math.sin(effectiveLongitude) * planarRadiusX +
14785
- combinedTentacleSway +
14786
- tentacleCurl * radiusX * 0.18,
15031
+ x: Math.sin(effectiveLongitude) * planarRadiusX + combinedTentacleSway + tentacleCurl * radiusX * 0.18,
14787
15032
  y: Math.sin(latitude) * radiusY * (1 + upperBlend * 0.14) -
14788
15033
  upperBlend * radiusY * 0.12 +
14789
15034
  lowerDrop +
@@ -15890,6 +16135,21 @@
15890
16135
  .toLowerCase()
15891
16136
  .replace(/[^a-z0-9]+/g, '');
15892
16137
  }
16138
+ /**
16139
+ * Returns one avatar visual by its identifier.
16140
+ *
16141
+ * @param visualId Requested visual identifier.
16142
+ * @returns Matching visual definition.
16143
+ *
16144
+ * @private shared registry for the avatar rendering system
16145
+ */
16146
+ function getAvatarVisualById(visualId) {
16147
+ const avatarVisual = AVATAR_VISUALS.find((candidateAvatarVisual) => candidateAvatarVisual.id === visualId);
16148
+ if (!avatarVisual) {
16149
+ throw new Error(`Unknown avatar visual "${visualId}".`);
16150
+ }
16151
+ return avatarVisual;
16152
+ }
15893
16153
  /**
15894
16154
  * Resolves a user-facing avatar visual value to a supported built-in visual id.
15895
16155
  *
@@ -18027,10 +18287,10 @@
18027
18287
  *
18028
18288
  * @private
18029
18289
  */
18030
- const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
18031
- '- If a teammate is relevant to the request, consult that teammate using the matching tool.',
18032
- '- Do not ask the user for information that a listed teammate can provide directly.',
18033
- ];
18290
+ const TEAM_SYSTEM_MESSAGE_GUIDANCE = _spaceTrim.spaceTrim(`
18291
+ - If a teammate is relevant to the request, consult that teammate using the matching tool.
18292
+ - Do not ask the user for information that a listed teammate can provide directly.
18293
+ `);
18034
18294
  /**
18035
18295
  * Constant for remote agents by Url.
18036
18296
  */
@@ -18212,7 +18472,7 @@
18212
18472
  `);
18213
18473
  });
18214
18474
  return _spaceTrim.spaceTrim((block) => `
18215
- ${block(TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES.join('\n'))}
18475
+ ${block(TEAM_SYSTEM_MESSAGE_GUIDANCE)}
18216
18476
 
18217
18477
  ${block(teammateSections.join('\n\n'))}
18218
18478
  `);
@@ -28470,7 +28730,7 @@
28470
28730
  const MODEL_ARGUMENT = options.model ? ` --model ${options.model}` : '';
28471
28731
  const THINKING_LEVEL_ARGUMENT = options.thinkingLevel ? ` --effort ${options.thinkingLevel}` : '';
28472
28732
  return spaceTrim((block) => `
28473
- claude --allowedTools "Bash,Read,Edit,Write"${MODEL_ARGUMENT}${THINKING_LEVEL_ARGUMENT} --output-format json --print <<'${CLAUDE_PROMPT_DELIMITER}'
28733
+ claude --allowedTools "Bash,Read,Edit,Write"${MODEL_ARGUMENT}${THINKING_LEVEL_ARGUMENT} --output-format stream-json --verbose --include-partial-messages --print <<'${CLAUDE_PROMPT_DELIMITER}'
28474
28734
 
28475
28735
  ${block(options.prompt)}
28476
28736
 
@@ -40139,26 +40399,26 @@
40139
40399
  id: 'common',
40140
40400
  relativeFilePath: path.join(PROMPTS_TEMPLATES_DIRECTORY_PATH, 'common.md'),
40141
40401
  slugPrefix: null,
40142
- content: buildCoderPromptTemplateContent([
40143
- '- @@@',
40144
- "- Keep in mind the DRY _(don't repeat yourself)_ principle.",
40145
- '- Do a proper analysis of the current functionality before you start implementing.',
40146
- '- Add the changes into the [changelog](changelog/_current-preversion.md)',
40147
- ]),
40402
+ content: _spaceTrim.spaceTrim(`
40403
+ - @@@
40404
+ - Keep in mind the DRY _(don't repeat yourself)_ principle.
40405
+ - Do a proper analysis of the current functionality before you start implementing.
40406
+ - Add the changes into the [changelog](changelog/_current-preversion.md)
40407
+ `),
40148
40408
  isDefaultProjectTemplate: true,
40149
40409
  },
40150
40410
  {
40151
40411
  id: 'agents-server',
40152
40412
  relativeFilePath: path.join(PROMPTS_TEMPLATES_DIRECTORY_PATH, 'agents-server.md'),
40153
40413
  slugPrefix: 'agents-server',
40154
- content: buildCoderPromptTemplateContent([
40155
- '- @@@',
40156
- "- Keep in mind the DRY _(don't repeat yourself)_ principle.",
40157
- '- Do a proper analysis of the current functionality before you start implementing.',
40158
- '- You are working with the [Agents Server](apps/agents-server)',
40159
- '- If you need to do the database migration, do it',
40160
- '- Add the changes into the [changelog](changelog/_current-preversion.md)',
40161
- ]),
40414
+ content: _spaceTrim.spaceTrim(`
40415
+ - @@@
40416
+ - Keep in mind the DRY _(don't repeat yourself)_ principle.
40417
+ - Do a proper analysis of the current functionality before you start implementing.
40418
+ - You are working with the [Agents Server](apps/agents-server)
40419
+ - If you need to do the database migration, do it
40420
+ - Add the changes into the [changelog](changelog/_current-preversion.md)
40421
+ `),
40162
40422
  isDefaultProjectTemplate: false,
40163
40423
  },
40164
40424
  ];
@@ -40278,12 +40538,6 @@
40278
40538
  function getDefaultCoderPromptTemplateDefinitionOrUndefined(template) {
40279
40539
  return DEFAULT_CODER_PROMPT_TEMPLATE_DEFINITIONS.find((definition) => definition.id === template);
40280
40540
  }
40281
- /**
40282
- * Builds stable markdown content for one coder prompt template without indentation drift.
40283
- */
40284
- function buildCoderPromptTemplateContent(lines) {
40285
- return lines.join('\n');
40286
- }
40287
40541
  /**
40288
40542
  * Creates a fully resolved template payload from one built-in definition.
40289
40543
  */
@@ -71226,7 +71480,7 @@
71226
71480
  *
71227
71481
  * Returns `undefined` when no agent path is provided.
71228
71482
  */
71229
- async function resolveAgentSystemMessage(agentPath, currentWorkingDirectory) {
71483
+ async function resolveCoderAgent(agentPath, currentWorkingDirectory) {
71230
71484
  if (!agentPath) {
71231
71485
  return undefined;
71232
71486
  }
@@ -71241,7 +71495,10 @@
71241
71495
  }
71242
71496
  throw error;
71243
71497
  });
71244
- return createAgentRunnerSystemMessage(agentSource);
71498
+ return {
71499
+ agentSource: agentSource,
71500
+ systemMessage: await createAgentRunnerSystemMessage(agentSource),
71501
+ };
71245
71502
  }
71246
71503
 
71247
71504
  /**
@@ -71439,6 +71696,497 @@
71439
71696
  await waitForEnter(colors__default["default"].bgWhite(`Press Enter to start the ${label}...`));
71440
71697
  }
71441
71698
 
71699
+ /**
71700
+ * Default alpha channel value below which a half-cell is rendered as terminal background.
71701
+ *
71702
+ * @private within the repository
71703
+ */
71704
+ const DEFAULT_ALPHA_THRESHOLD = 32;
71705
+ /**
71706
+ * Number of channels per pixel in an RGBA buffer.
71707
+ *
71708
+ * @private within the repository
71709
+ */
71710
+ const RGBA_CHANNEL_COUNT = 4;
71711
+ /**
71712
+ * Upper half block character - foreground paints the top pixel, background paints the bottom pixel.
71713
+ *
71714
+ * @private within the repository
71715
+ */
71716
+ const UPPER_HALF_BLOCK = '▀'; // <- ▀
71717
+ /**
71718
+ * Lower half block character - foreground paints the bottom pixel while the top pixel stays transparent.
71719
+ *
71720
+ * @private within the repository
71721
+ */
71722
+ const LOWER_HALF_BLOCK = '▄'; // <- ▄
71723
+ /**
71724
+ * ANSI escape sequence that resets all colors and attributes.
71725
+ *
71726
+ * @private within the repository
71727
+ */
71728
+ const ANSI_RESET = '\u001b[0m';
71729
+ /**
71730
+ * Maximum spread between RGB channels for a color to be treated as (nearly) achromatic gray.
71731
+ *
71732
+ * @private within the repository
71733
+ */
71734
+ const ANSI_256_ACHROMATIC_CHANNEL_SPREAD = 12;
71735
+ /**
71736
+ * Gray level above which an achromatic color maps to the pure white color-cube entry.
71737
+ *
71738
+ * @private within the repository
71739
+ */
71740
+ const ANSI_256_NEAR_WHITE_GRAY_LEVEL = 246;
71741
+ /**
71742
+ * Index of pure white inside the 6×6×6 ANSI color cube.
71743
+ *
71744
+ * @private within the repository
71745
+ */
71746
+ const ANSI_256_WHITE_INDEX = 231;
71747
+ /**
71748
+ * Brightness of the lightest entry of the ANSI 256 grayscale ramp.
71749
+ *
71750
+ * @private within the repository
71751
+ */
71752
+ const ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL = 238;
71753
+ /**
71754
+ * Number of grayscale ramp steps above its first entry (ANSI indexes 232-255).
71755
+ *
71756
+ * @private within the repository
71757
+ */
71758
+ const ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN = 23;
71759
+ /**
71760
+ * Converts raw RGBA image pixels into colored ASCII art for ANSI terminals.
71761
+ *
71762
+ * This is the universal image-to-terminal technique used across the repository:
71763
+ * every output character cell covers a rectangular region of source pixels which is
71764
+ * split into a top and bottom half; each half is area-averaged and rendered with
71765
+ * half-block characters (`▀` / `▄`) so one character shows two "pixels" vertically.
71766
+ * Transparent halves keep the terminal background so non-rectangular images
71767
+ * (for example rounded avatar cards) compose naturally into any terminal UI.
71768
+ *
71769
+ * @param options Source pixels, output grid size, and ANSI color depth.
71770
+ * @returns One ANSI-colored string per output row, each ending with a color reset.
71771
+ *
71772
+ * @private within the repository
71773
+ */
71774
+ function convertImageDataToAsciiArt(options) {
71775
+ const { imageData, columns, rows, colorDepth = 'TRUE_COLOR', alphaThreshold = DEFAULT_ALPHA_THRESHOLD } = options;
71776
+ if (!Number.isInteger(columns) || columns <= 0 || !Number.isInteger(rows) || rows <= 0) {
71777
+ throw new UnexpectedError(_spaceTrim.spaceTrim(`
71778
+ ASCII-art grid size is invalid.
71779
+
71780
+ Both \`columns\` and \`rows\` must be positive integers but \`${columns}\` × \`${rows}\` was requested.
71781
+ `));
71782
+ }
71783
+ if (imageData.width <= 0 ||
71784
+ imageData.height <= 0 ||
71785
+ imageData.data.length < imageData.width * imageData.height * RGBA_CHANNEL_COUNT) {
71786
+ throw new UnexpectedError(_spaceTrim.spaceTrim(`
71787
+ ASCII-art source image data is invalid.
71788
+
71789
+ Expected a RGBA buffer of at least \`${imageData.width} × ${imageData.height} × ${RGBA_CHANNEL_COUNT}\` bytes
71790
+ but got \`${imageData.data.length}\` bytes.
71791
+ `));
71792
+ }
71793
+ const halfCellRowCount = rows * 2;
71794
+ const asciiArtLines = [];
71795
+ for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
71796
+ let line = '';
71797
+ let currentForegroundCode = undefined;
71798
+ let currentBackgroundCode = undefined;
71799
+ for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
71800
+ const topHalfColor = computeHalfCellColor(imageData, columnIndex, rowIndex * 2, columns, halfCellRowCount, alphaThreshold);
71801
+ const bottomHalfColor = computeHalfCellColor(imageData, columnIndex, rowIndex * 2 + 1, columns, halfCellRowCount, alphaThreshold);
71802
+ let character;
71803
+ let nextForegroundCode;
71804
+ let nextBackgroundCode;
71805
+ if (topHalfColor.isOpaque && bottomHalfColor.isOpaque) {
71806
+ character = UPPER_HALF_BLOCK;
71807
+ nextForegroundCode = createForegroundColorCode(topHalfColor, colorDepth);
71808
+ nextBackgroundCode = createBackgroundColorCode(bottomHalfColor, colorDepth);
71809
+ }
71810
+ else if (topHalfColor.isOpaque) {
71811
+ character = UPPER_HALF_BLOCK;
71812
+ nextForegroundCode = createForegroundColorCode(topHalfColor, colorDepth);
71813
+ nextBackgroundCode = undefined;
71814
+ }
71815
+ else if (bottomHalfColor.isOpaque) {
71816
+ character = LOWER_HALF_BLOCK;
71817
+ nextForegroundCode = createForegroundColorCode(bottomHalfColor, colorDepth);
71818
+ nextBackgroundCode = undefined;
71819
+ }
71820
+ else {
71821
+ character = ' ';
71822
+ nextForegroundCode = undefined;
71823
+ nextBackgroundCode = undefined;
71824
+ }
71825
+ if (nextForegroundCode !== currentForegroundCode || nextBackgroundCode !== currentBackgroundCode) {
71826
+ // Note: A reset is required whenever a previously set color must be cleared,
71827
+ // otherwise stale background color would bleed into transparent cells.
71828
+ const isResetNeeded = (currentForegroundCode !== undefined && nextForegroundCode === undefined) ||
71829
+ (currentBackgroundCode !== undefined && nextBackgroundCode === undefined);
71830
+ if (isResetNeeded) {
71831
+ line += ANSI_RESET;
71832
+ currentForegroundCode = undefined;
71833
+ currentBackgroundCode = undefined;
71834
+ }
71835
+ if (nextForegroundCode !== undefined && nextForegroundCode !== currentForegroundCode) {
71836
+ line += nextForegroundCode;
71837
+ }
71838
+ if (nextBackgroundCode !== undefined && nextBackgroundCode !== currentBackgroundCode) {
71839
+ line += nextBackgroundCode;
71840
+ }
71841
+ currentForegroundCode = nextForegroundCode;
71842
+ currentBackgroundCode = nextBackgroundCode;
71843
+ }
71844
+ line += character;
71845
+ }
71846
+ if (currentForegroundCode !== undefined || currentBackgroundCode !== undefined) {
71847
+ line += ANSI_RESET;
71848
+ }
71849
+ asciiArtLines.push(line);
71850
+ }
71851
+ return asciiArtLines;
71852
+ }
71853
+ /**
71854
+ * Computes the area-averaged color of one half-cell of the output grid.
71855
+ *
71856
+ * Color channels are alpha-weighted so semi-transparent edge pixels do not darken towards black.
71857
+ *
71858
+ * @private helper of `convertImageDataToAsciiArt`
71859
+ */
71860
+ function computeHalfCellColor(imageData, columnIndex, halfCellRowIndex, columns, halfCellRowCount, alphaThreshold) {
71861
+ const startX = Math.floor((columnIndex * imageData.width) / columns);
71862
+ const endX = Math.max(startX + 1, Math.floor(((columnIndex + 1) * imageData.width) / columns));
71863
+ const startY = Math.floor((halfCellRowIndex * imageData.height) / halfCellRowCount);
71864
+ const endY = Math.max(startY + 1, Math.floor(((halfCellRowIndex + 1) * imageData.height) / halfCellRowCount));
71865
+ let redSum = 0;
71866
+ let greenSum = 0;
71867
+ let blueSum = 0;
71868
+ let alphaSum = 0;
71869
+ let sampledPixelCount = 0;
71870
+ for (let y = startY; y < endY && y < imageData.height; y++) {
71871
+ for (let x = startX; x < endX && x < imageData.width; x++) {
71872
+ const pixelOffset = (y * imageData.width + x) * RGBA_CHANNEL_COUNT;
71873
+ const alpha = imageData.data[pixelOffset + 3];
71874
+ redSum += imageData.data[pixelOffset] * alpha;
71875
+ greenSum += imageData.data[pixelOffset + 1] * alpha;
71876
+ blueSum += imageData.data[pixelOffset + 2] * alpha;
71877
+ alphaSum += alpha;
71878
+ sampledPixelCount++;
71879
+ }
71880
+ }
71881
+ const averageAlpha = sampledPixelCount === 0 ? 0 : alphaSum / sampledPixelCount;
71882
+ if (averageAlpha < alphaThreshold || alphaSum === 0) {
71883
+ return { red: 0, green: 0, blue: 0, isOpaque: false };
71884
+ }
71885
+ return {
71886
+ red: Math.round(redSum / alphaSum),
71887
+ green: Math.round(greenSum / alphaSum),
71888
+ blue: Math.round(blueSum / alphaSum),
71889
+ isOpaque: true,
71890
+ };
71891
+ }
71892
+ /**
71893
+ * Creates the ANSI escape code that sets the foreground color of following characters.
71894
+ *
71895
+ * @private helper of `convertImageDataToAsciiArt`
71896
+ */
71897
+ function createForegroundColorCode(color, colorDepth) {
71898
+ if (colorDepth === 'TRUE_COLOR') {
71899
+ return `\u001b[38;2;${color.red};${color.green};${color.blue}m`;
71900
+ }
71901
+ return `\u001b[38;5;${mapColorToAnsi256(color)}m`;
71902
+ }
71903
+ /**
71904
+ * Creates the ANSI escape code that sets the background color of following characters.
71905
+ *
71906
+ * @private helper of `convertImageDataToAsciiArt`
71907
+ */
71908
+ function createBackgroundColorCode(color, colorDepth) {
71909
+ if (colorDepth === 'TRUE_COLOR') {
71910
+ return `\u001b[48;2;${color.red};${color.green};${color.blue}m`;
71911
+ }
71912
+ return `\u001b[48;5;${mapColorToAnsi256(color)}m`;
71913
+ }
71914
+ /**
71915
+ * Maps a 24-bit color onto the closest entry of the 256-color ANSI palette.
71916
+ *
71917
+ * Uses the 6×6×6 color cube (entries 16-231) and the grayscale ramp (entries 232-255).
71918
+ *
71919
+ * @private helper of `convertImageDataToAsciiArt`
71920
+ */
71921
+ function mapColorToAnsi256(color) {
71922
+ const { red, green, blue } = color;
71923
+ // Note: Prefer the finer grayscale ramp when the color is (nearly) achromatic
71924
+ const maxChannel = Math.max(red, green, blue);
71925
+ const minChannel = Math.min(red, green, blue);
71926
+ if (maxChannel - minChannel < ANSI_256_ACHROMATIC_CHANNEL_SPREAD) {
71927
+ const gray = Math.round((red + green + blue) / 3);
71928
+ if (gray < 4) {
71929
+ return 16; // <- Note: Pure black lives in the color cube
71930
+ }
71931
+ if (gray > ANSI_256_NEAR_WHITE_GRAY_LEVEL) {
71932
+ return ANSI_256_WHITE_INDEX; // <- Note: Pure white lives in the color cube
71933
+ }
71934
+ return 232 + Math.round(((gray - 8) / ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL) * ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN);
71935
+ }
71936
+ const redIndex = Math.round((red / 255) * 5);
71937
+ const greenIndex = Math.round((green / 255) * 5);
71938
+ const blueIndex = Math.round((blue / 255) * 5);
71939
+ return 16 + 36 * redIndex + 6 * greenIndex + blueIndex;
71940
+ }
71941
+
71942
+ /**
71943
+ * Stable zeroed interaction state used by non-interactive render paths.
71944
+ *
71945
+ * @private utility of the avatar rendering system
71946
+ */
71947
+ const IDLE_AVATAR_INTERACTION_STATE = {
71948
+ gazeX: 0,
71949
+ gazeY: 0,
71950
+ bodyOffsetX: 0,
71951
+ bodyOffsetY: 0,
71952
+ intensity: 0,
71953
+ isPointerActive: false,
71954
+ pointerType: 'idle',
71955
+ };
71956
+ /**
71957
+ * Returns the neutral interaction state used by static/server-side renders.
71958
+ *
71959
+ * @returns Zeroed interaction state.
71960
+ *
71961
+ * @private utility of the avatar rendering system
71962
+ */
71963
+ function createIdleAvatarInteractionState() {
71964
+ return IDLE_AVATAR_INTERACTION_STATE;
71965
+ }
71966
+
71967
+ /**
71968
+ * Resolves the stable avatar render inputs reused across multiple frames.
71969
+ *
71970
+ * @param options Avatar identity and visual selection.
71971
+ * @returns Stable render data ready to be used by `renderAvatarVisual`.
71972
+ *
71973
+ * @private shared helper for canvas avatar rendering
71974
+ */
71975
+ function resolveAvatarRenderDefinition(options) {
71976
+ const avatarDefinition = normalizeAvatarDefinition(options.avatarDefinition);
71977
+ const surface = options.surface || 'framed';
71978
+ return {
71979
+ avatarDefinition,
71980
+ avatarVisual: getAvatarVisualById(options.visualId),
71981
+ surface,
71982
+ palette: createAvatarPalette(avatarDefinition, surface),
71983
+ createRandom: createAvatarRandomFactory(avatarDefinition),
71984
+ };
71985
+ }
71986
+ /**
71987
+ * Renders one deterministic avatar frame into the provided canvas.
71988
+ *
71989
+ * @param options Rendering options.
71990
+ * @param resolvedAvatarRenderDefinition Optional stable render data reused between frames.
71991
+ *
71992
+ * @private shared helper for canvas avatar rendering
71993
+ */
71994
+ function renderAvatarVisual(options, resolvedAvatarRenderDefinition) {
71995
+ const resolvedRenderDefinition = resolvedAvatarRenderDefinition ||
71996
+ resolveAvatarRenderDefinition({
71997
+ avatarDefinition: options.avatarDefinition,
71998
+ visualId: options.visualId,
71999
+ surface: options.surface,
72000
+ });
72001
+ const context = options.canvas.getContext('2d');
72002
+ if (!context) {
72003
+ throw new Error('2D canvas rendering context is unavailable.');
72004
+ }
72005
+ prepareAvatarCanvas(options.canvas, context, options.size, options.devicePixelRatio || 1);
72006
+ resolvedRenderDefinition.avatarVisual.render({
72007
+ canvas: options.canvas,
72008
+ context,
72009
+ size: options.size,
72010
+ devicePixelRatio: options.devicePixelRatio || 1,
72011
+ timeMs: options.timeMs,
72012
+ avatarDefinition: resolvedRenderDefinition.avatarDefinition,
72013
+ palette: resolvedRenderDefinition.palette,
72014
+ createRandom: resolvedRenderDefinition.createRandom,
72015
+ surface: resolvedRenderDefinition.surface,
72016
+ interaction: options.interaction || createIdleAvatarInteractionState(),
72017
+ });
72018
+ }
72019
+
72020
+ /**
72021
+ * Default output width of the ASCII avatar in terminal character cells.
72022
+ *
72023
+ * @private within the repository
72024
+ */
72025
+ const DEFAULT_AVATAR_ASCII_ART_COLUMNS = 32;
72026
+ /**
72027
+ * Stable animation timestamp used when rasterizing animated avatar visuals into a static ASCII frame.
72028
+ *
72029
+ * @private within the repository
72030
+ */
72031
+ const STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS = 840;
72032
+ /**
72033
+ * Renders one built-in avatar visual into ANSI-colored ASCII art for terminal display.
72034
+ *
72035
+ * This is the universal bridge between the canvas avatar visuals shown on the website and
72036
+ * text-based terminal UIs: the visual is rasterized through the exact same `renderAvatarVisual`
72037
+ * pipeline the web uses, then the resulting pixels are converted into colored half-block
72038
+ * characters by `convertImageDataToAsciiArt`.
72039
+ *
72040
+ * @param options Avatar identity, visual selection, output grid size, and the platform canvas factory.
72041
+ * @returns One ANSI-colored string per output row.
72042
+ *
72043
+ * @private within the repository
72044
+ */
72045
+ function renderAvatarVisualAsciiArt(options) {
72046
+ var _a, _b, _c;
72047
+ const columns = (_a = options.columns) !== null && _a !== void 0 ? _a : DEFAULT_AVATAR_ASCII_ART_COLUMNS;
72048
+ const rows = (_b = options.rows) !== null && _b !== void 0 ? _b : Math.round(columns / 2);
72049
+ const canvas = options.createCanvas(DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_SIZE);
72050
+ if (!canvas.style) {
72051
+ // Note: `renderAvatarVisual` expects a browser canvas shape; Node.js canvases only need this tiny compatibility shim.
72052
+ canvas.style = {};
72053
+ }
72054
+ renderAvatarVisual({
72055
+ canvas,
72056
+ avatarDefinition: options.avatarDefinition,
72057
+ visualId: options.visualId,
72058
+ size: DEFAULT_AVATAR_SIZE,
72059
+ timeMs: (_c = options.timeMs) !== null && _c !== void 0 ? _c : STATIC_AVATAR_ASCII_ART_FRAME_TIME_MS,
72060
+ devicePixelRatio: 1,
72061
+ });
72062
+ const context = canvas.getContext('2d');
72063
+ if (!context) {
72064
+ throw new EnvironmentMismatchError(_spaceTrim.spaceTrim(`
72065
+ 2D canvas rendering context is unavailable while converting the avatar visual to ASCII art.
72066
+
72067
+ Provide a \`createCanvas\` factory whose canvases support \`getContext('2d')\`,
72068
+ for example \`createCanvas\` of \`@napi-rs/canvas\` in Node.js.
72069
+ `));
72070
+ }
72071
+ const imageData = context.getImageData(0, 0, DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_SIZE);
72072
+ return convertImageDataToAsciiArt({
72073
+ imageData,
72074
+ columns,
72075
+ rows,
72076
+ colorDepth: options.colorDepth,
72077
+ });
72078
+ }
72079
+
72080
+ /**
72081
+ * Default built-in avatar visual used when an agent does not define `META IMAGE`.
72082
+ *
72083
+ * @private shared avatar contract
72084
+ */
72085
+ const DEFAULT_AGENT_AVATAR_VISUAL_ID = 'octopus3d4';
72086
+ /**
72087
+ * Resolves the avatar visual preferred by an agent, then falls back to a federated server default
72088
+ * and finally to the caller/server default.
72089
+ *
72090
+ * @param agent Agent metadata and optional remote-profile visual id.
72091
+ * @param defaultAvatarVisualId Optional metadata-resolved server default.
72092
+ * @returns Supported avatar visual id.
72093
+ *
72094
+ * @private shared avatar contract
72095
+ */
72096
+ function resolveAgentAvatarVisualId(agent, defaultAvatarVisualId = DEFAULT_AGENT_AVATAR_VISUAL_ID) {
72097
+ var _a;
72098
+ return (resolveAvatarVisualId((_a = agent.meta) === null || _a === void 0 ? void 0 : _a.avatar) ||
72099
+ agent.avatarVisualId ||
72100
+ agent.defaultAgentAvatarVisualId ||
72101
+ defaultAvatarVisualId);
72102
+ }
72103
+
72104
+ /**
72105
+ * Detects the ANSI color depth supported by the current terminal.
72106
+ *
72107
+ * Prefers 24-bit true color when the environment advertises it (modern terminals such as
72108
+ * Windows Terminal, ConEmu, VS Code, mintty, iTerm2, and WezTerm) and falls back to the
72109
+ * portable 256-color palette otherwise.
72110
+ *
72111
+ * Note: `$` is used to indicate that this function is not a pure function - it reads the process environment
72112
+ *
72113
+ * @returns Color depth usable by `convertImageDataToAsciiArt`
72114
+ *
72115
+ * @private within the repository
72116
+ */
72117
+ function $detectTerminalAnsiColorDepth() {
72118
+ if (typeof process === 'undefined' || !process.env) {
72119
+ return 'ANSI_256';
72120
+ }
72121
+ const colorTerm = (process.env.COLORTERM || '').toLowerCase();
72122
+ if (colorTerm.includes('truecolor') || colorTerm.includes('24bit')) {
72123
+ return 'TRUE_COLOR';
72124
+ }
72125
+ if (process.env.WT_SESSION !== undefined) {
72126
+ return 'TRUE_COLOR'; // <- Note: Windows Terminal always supports true color but does not set COLORTERM
72127
+ }
72128
+ if (process.env.ConEmuANSI === 'ON') {
72129
+ return 'TRUE_COLOR';
72130
+ }
72131
+ const termProgram = process.env.TERM_PROGRAM || '';
72132
+ if (['vscode', 'iTerm.app', 'WezTerm', 'ghostty', 'Hyper'].includes(termProgram)) {
72133
+ return 'TRUE_COLOR';
72134
+ }
72135
+ const term = (process.env.TERM || '').toLowerCase();
72136
+ if (term.includes('truecolor') || term.includes('24bit') || term.includes('direct')) {
72137
+ return 'TRUE_COLOR';
72138
+ }
72139
+ return 'ANSI_256';
72140
+ }
72141
+
72142
+ /**
72143
+ * Output width of the coder-run agent visual in terminal character cells.
72144
+ *
72145
+ * @private internal constant of coder run UI
72146
+ */
72147
+ const CODER_RUN_AGENT_VISUAL_COLUMNS = 24;
72148
+ /**
72149
+ * Output height of the coder-run agent visual in terminal character cells.
72150
+ *
72151
+ * Half of the columns keeps the square avatar visually square in a common terminal font.
72152
+ *
72153
+ * @private internal constant of coder run UI
72154
+ */
72155
+ const CODER_RUN_AGENT_VISUAL_ROWS = 12;
72156
+ /**
72157
+ * Builds the ANSI ASCII-art visual of the `--agent` book shown above the coder-run dashboard.
72158
+ *
72159
+ * The agent's avatar visual is resolved the same way as on the website - the `META AVATAR`
72160
+ * commitment wins, then the `META VISUAL` commitment, then the shared default visual - and is
72161
+ * rendered dynamically through the shared canvas avatar pipeline into terminal ASCII art.
72162
+ *
72163
+ * The visual is decorative, so any failure (for example when the optional `@napi-rs/canvas`
72164
+ * module is not installed) returns `null` and the caller keeps the default brand banner.
72165
+ *
72166
+ * @param agentSource Source of the `--agent` book file.
72167
+ * @returns ANSI-colored ASCII-art lines or `null` when the visual cannot be rendered.
72168
+ */
72169
+ async function buildCoderRunAgentVisual(agentSource) {
72170
+ try {
72171
+ // Note: `@napi-rs/canvas` is an optional native module, so it is imported dynamically and lazily
72172
+ const { createCanvas } = await import('@napi-rs/canvas');
72173
+ const agentBasicInformation = parseAgentSource(agentSource);
72174
+ const avatarDefinition = createAvatarDefinitionFromAgentBasicInformation(agentBasicInformation);
72175
+ const avatarVisualId = resolveAgentAvatarVisualId(agentBasicInformation, resolveAvatarVisualId(agentBasicInformation.meta.visual) || DEFAULT_AGENT_AVATAR_VISUAL_ID);
72176
+ return renderAvatarVisualAsciiArt({
72177
+ avatarDefinition,
72178
+ visualId: avatarVisualId,
72179
+ columns: CODER_RUN_AGENT_VISUAL_COLUMNS,
72180
+ rows: CODER_RUN_AGENT_VISUAL_ROWS,
72181
+ colorDepth: $detectTerminalAnsiColorDepth(),
72182
+ createCanvas: (width, height) => createCanvas(width, height),
72183
+ });
72184
+ }
72185
+ catch (error) {
72186
+ return null;
72187
+ }
72188
+ }
72189
+
71442
72190
  /**
71443
72191
  * Formats commit message lines for console display.
71444
72192
  */
@@ -73355,13 +74103,15 @@
73355
74103
  startPauseListenerIfNeeded(isRichUiEnabled);
73356
74104
  try {
73357
74105
  const resolvedCoderContext = await resolveCoderContext(options.context, process.cwd());
73358
- const resolvedAgentSystemMessage = await resolveAgentSystemMessage(options.agent, process.cwd());
74106
+ const resolvedCoderAgent = await resolveCoderAgent(options.agent, process.cwd());
74107
+ const resolvedAgentSystemMessage = resolvedCoderAgent === null || resolvedCoderAgent === void 0 ? void 0 : resolvedCoderAgent.systemMessage;
73359
74108
  if (await runDryRunIfRequested(options)) {
73360
74109
  return;
73361
74110
  }
73362
74111
  const { runner, actualRunnerModel, runnerMetadata } = resolvePromptRunner(options);
73363
74112
  console.info(colors__default["default"].green(`Running prompts with ${runner.name}`));
73364
74113
  initializeRunUi(uiHandle, runner.name, actualRunnerModel, options);
74114
+ await initializeRunUiAgentVisual(uiHandle, resolvedCoderAgent === null || resolvedCoderAgent === void 0 ? void 0 : resolvedCoderAgent.agentSource);
73365
74115
  await seedCachedAveragePromptDuration({
73366
74116
  options,
73367
74117
  actualRunnerModel,
@@ -73599,6 +74349,20 @@
73599
74349
  uiHandle === null || uiHandle === void 0 ? void 0 : uiHandle.state.setPhase('loading');
73600
74350
  uiHandle === null || uiHandle === void 0 ? void 0 : uiHandle.state.setStatusMessage(`Running prompts with ${runnerName}`);
73601
74351
  }
74352
+ /**
74353
+ * Renders the `--agent` book avatar as ASCII art and shows it instead of the default brand banner.
74354
+ *
74355
+ * Keeps the default banner when no agent is selected, the UI is disabled, or the visual cannot be rendered.
74356
+ */
74357
+ async function initializeRunUiAgentVisual(uiHandle, agentSource) {
74358
+ if (!uiHandle || !agentSource) {
74359
+ return;
74360
+ }
74361
+ const agentVisualLines = await buildCoderRunAgentVisual(agentSource);
74362
+ if (agentVisualLines) {
74363
+ uiHandle.state.setAgentVisualLines(agentVisualLines);
74364
+ }
74365
+ }
73602
74366
  /**
73603
74367
  * Loads prompt files, updates progress displays, and selects the next runnable prompt.
73604
74368
  */