@promptbook/components 0.112.0-65 โ†’ 0.112.0-66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('spacetrim'), require('react'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('crypto'), require('moment'), require('mime-types'), require('react-dom'), require('@monaco-editor/react'), require('destroyable'), require('katex'), require('react-dom/client'), require('showdown'), require('rxjs'), require('jspdf'), require('moment/locale/cs'), require('lucide-react'), require('waitasecond'), require('crypto-js/sha256'), require('papaparse'), require('colors'), require('@openai/agents'), require('bottleneck'), require('openai'), require('qrcode')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'spacetrim', 'react', 'crypto-js', 'crypto-js/enc-hex', 'path', 'crypto', 'moment', 'mime-types', 'react-dom', '@monaco-editor/react', 'destroyable', 'katex', 'react-dom/client', 'showdown', 'rxjs', 'jspdf', 'moment/locale/cs', 'lucide-react', 'waitasecond', 'crypto-js/sha256', 'papaparse', 'colors', '@openai/agents', 'bottleneck', 'openai', 'qrcode'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.spacetrim, global.react, global.cryptoJs, global.hexEncoder, global.path, global.crypto$1, global.moment, global.mimeTypes, global.reactDom, global.MonacoEditor, global.destroyable, global.katex, global.client, global.showdown, global.rxjs, global.jspdf, null, global.lucideReact, global.waitasecond, global.sha256, global.papaparse, global.colors, global.agents, global.Bottleneck, global.OpenAI, global.QRCode));
5
- })(this, (function (exports, jsxRuntime, spacetrim, react, cryptoJs, hexEncoder, path, crypto$1, moment, mimeTypes, reactDom, MonacoEditor, destroyable, katex, client, showdown, rxjs, jspdf, cs, lucideReact, waitasecond, sha256, papaparse, colors, agents, Bottleneck, OpenAI, QRCode) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('spacetrim'), require('path'), require('react'), require('crypto-js'), require('crypto-js/enc-hex'), require('crypto'), require('moment'), require('mime-types'), require('react-dom'), require('@monaco-editor/react'), require('destroyable'), require('katex'), require('react-dom/client'), require('showdown'), require('rxjs'), require('jspdf'), require('moment/locale/cs'), require('lucide-react'), require('waitasecond'), require('crypto-js/sha256'), require('papaparse'), require('colors'), require('@openai/agents'), require('bottleneck'), require('openai'), require('qrcode')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'spacetrim', 'path', 'react', 'crypto-js', 'crypto-js/enc-hex', 'crypto', 'moment', 'mime-types', 'react-dom', '@monaco-editor/react', 'destroyable', 'katex', 'react-dom/client', 'showdown', 'rxjs', 'jspdf', 'moment/locale/cs', 'lucide-react', 'waitasecond', 'crypto-js/sha256', 'papaparse', 'colors', '@openai/agents', 'bottleneck', 'openai', 'qrcode'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.spacetrim, global.path, global.react, global.cryptoJs, global.hexEncoder, global.crypto$1, global.moment, global.mimeTypes, global.reactDom, global.MonacoEditor, global.destroyable, global.katex, global.client, global.showdown, global.rxjs, global.jspdf, null, global.lucideReact, global.waitasecond, global.sha256, global.papaparse, global.colors, global.agents, global.Bottleneck, global.OpenAI, global.QRCode));
5
+ })(this, (function (exports, jsxRuntime, spacetrim, path, react, cryptoJs, hexEncoder, crypto$1, moment, mimeTypes, reactDom, MonacoEditor, destroyable, katex, client, showdown, rxjs, jspdf, cs, lucideReact, waitasecond, sha256, papaparse, colors, agents, Bottleneck, OpenAI, QRCode) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -30,7 +30,7 @@
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-65';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-66';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -963,6 +963,29 @@
963
963
  }
964
964
  // TODO: Maybe implement by mix+hsl
965
965
 
966
+ /**
967
+ * Relative directory name without the `./` prefix for Git ignore rules and glob patterns.
968
+ *
969
+ * @private internal utility for Promptbook-owned temp files
970
+ */
971
+ const PROMPTBOOK_TEMP_DIRECTORY_NAME = '.promptbook';
972
+ /**
973
+ * Builds one project-relative path inside the shared Promptbook working directory.
974
+ *
975
+ * @private internal utility for Promptbook-owned temp files
976
+ */
977
+ function getPromptbookTempPath(...pathSegments) {
978
+ return `./${getPromptbookTempPosixPath(...pathSegments)}`;
979
+ }
980
+ /**
981
+ * Builds one POSIX path fragment inside the shared Promptbook working directory for globs and generated text files.
982
+ *
983
+ * @private internal utility for Promptbook-owned temp files
984
+ */
985
+ function getPromptbookTempPosixPath(...pathSegments) {
986
+ return path.posix.join(PROMPTBOOK_TEMP_DIRECTORY_NAME, ...pathSegments);
987
+ }
988
+
966
989
  /**
967
990
  * Returns the same value that is passed as argument.
968
991
  * No side effects.
@@ -1165,7 +1188,6 @@
1165
1188
  */
1166
1189
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
1167
1190
  // <- TODO: [๐Ÿ•] Make also `AGENTS_DIRNAME_ALTERNATIVES`
1168
- // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
1169
1191
  /**
1170
1192
  * Where to store the temporary downloads
1171
1193
  *
@@ -1173,7 +1195,15 @@
1173
1195
  *
1174
1196
  * @public exported from `@promptbook/core`
1175
1197
  */
1176
- const DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
1198
+ const DEFAULT_DOWNLOAD_CACHE_DIRNAME = getPromptbookTempPath('download-cache');
1199
+ /**
1200
+ * Where to store the cache of executions for promptbook CLI
1201
+ *
1202
+ * Note: When the folder does not exist, it is created recursively
1203
+ *
1204
+ * @public exported from `@promptbook/core`
1205
+ */
1206
+ getPromptbookTempPath('execution-cache');
1177
1207
  /**
1178
1208
  * Where to store the scrape cache
1179
1209
  *
@@ -1181,7 +1211,7 @@
1181
1211
  *
1182
1212
  * @public exported from `@promptbook/core`
1183
1213
  */
1184
- const DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
1214
+ const DEFAULT_SCRAPE_CACHE_DIRNAME = getPromptbookTempPath('scrape-cache');
1185
1215
  /**
1186
1216
  * Default remote server URL for the Promptbook
1187
1217
  *
@@ -2815,6 +2845,177 @@
2815
2845
  context.restore();
2816
2846
  }
2817
2847
 
2848
+ /* eslint-disable no-magic-numbers */
2849
+ /**
2850
+ * Builds the seeded six-face texture pack used by the Minecraft-style head cuboid.
2851
+ *
2852
+ * @param random Seeded random generator.
2853
+ * @param palette Derived avatar palette.
2854
+ * @param hasHeadband Whether the generated avatar should include a colored headband.
2855
+ * @returns Head cuboid textures.
2856
+ *
2857
+ * @private helper of the Minecraft avatar visuals
2858
+ */
2859
+ function createMinecraftHeadTextures(random, palette, hasHeadband) {
2860
+ const faceTexture = createMinecraftFaceTexture(random, palette, hasHeadband);
2861
+ const hairColor = random() < 0.5 ? palette.primary : palette.secondary;
2862
+ const skinColor = palette.highlight;
2863
+ const headbandColor = hasHeadband ? palette.accent : hairColor;
2864
+ const sideTexture = createFilledTexture(skinColor);
2865
+ const backTexture = createFilledTexture(skinColor);
2866
+ const topTexture = createFilledTexture(hairColor);
2867
+ const bottomTexture = createFilledTexture(`${palette.shadow}cc`);
2868
+ fillTextureRect(sideTexture, 0, 0, 8, 3, hairColor);
2869
+ fillTextureRect(backTexture, 0, 0, 8, 5, hairColor);
2870
+ fillTextureRect(backTexture, 1, 5, 6, 1, hairColor);
2871
+ if (hasHeadband) {
2872
+ fillTextureRect(sideTexture, 0, 2, 8, 1, headbandColor);
2873
+ fillTextureRect(backTexture, 0, 2, 8, 1, headbandColor);
2874
+ fillTextureRect(topTexture, 0, 4, 8, 1, headbandColor);
2875
+ }
2876
+ sideTexture[4][4] = `${palette.shadow}99`;
2877
+ sideTexture[5][4] = `${palette.shadow}cc`;
2878
+ backTexture[6][2] = `${palette.shadow}99`;
2879
+ backTexture[6][5] = `${palette.shadow}99`;
2880
+ return {
2881
+ front: faceTexture,
2882
+ back: backTexture,
2883
+ left: sideTexture,
2884
+ right: mirrorMinecraftTexture(sideTexture),
2885
+ top: topTexture,
2886
+ bottom: bottomTexture,
2887
+ };
2888
+ }
2889
+ /**
2890
+ * Builds the seeded six-face texture pack used by the Minecraft-style torso cuboid.
2891
+ *
2892
+ * @param random Seeded random generator.
2893
+ * @param palette Derived avatar palette.
2894
+ * @returns Torso cuboid textures.
2895
+ *
2896
+ * @private helper of the Minecraft avatar visuals
2897
+ */
2898
+ function createMinecraftTorsoTextures(random, palette) {
2899
+ const frontTexture = createMinecraftShirtTexture(random, palette);
2900
+ const sideTexture = createFilledTexture(palette.primary);
2901
+ const backTexture = createFilledTexture(palette.primary);
2902
+ const topTexture = createFilledTexture(`${palette.highlight}dd`);
2903
+ const bottomTexture = createFilledTexture(`${palette.shadow}dd`);
2904
+ const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
2905
+ fillTextureRect(sideTexture, 0, 0, 8, 2, palette.shadow);
2906
+ fillTextureRect(backTexture, 0, 0, 8, 2, palette.shadow);
2907
+ fillTextureRect(backTexture, 3, 2, 2, 6, stripeColor);
2908
+ fillTextureRect(sideTexture, 4, 2, 1, 6, stripeColor);
2909
+ fillTextureRect(topTexture, 0, 0, 8, 2, palette.shadow);
2910
+ fillTextureRect(topTexture, 2, 2, 4, 4, stripeColor);
2911
+ return {
2912
+ front: frontTexture,
2913
+ back: backTexture,
2914
+ left: sideTexture,
2915
+ right: mirrorMinecraftTexture(sideTexture),
2916
+ top: topTexture,
2917
+ bottom: bottomTexture,
2918
+ };
2919
+ }
2920
+ /**
2921
+ * Mirrors one Minecraft texture horizontally.
2922
+ *
2923
+ * @param texture Source texture.
2924
+ * @returns Mirrored texture copy.
2925
+ *
2926
+ * @private helper of the Minecraft avatar visuals
2927
+ */
2928
+ function mirrorMinecraftTexture(texture) {
2929
+ return texture.map((row) => [...row].reverse());
2930
+ }
2931
+ /**
2932
+ * Creates the front-face pixel texture for the cube head.
2933
+ *
2934
+ * @param random Seeded random generator.
2935
+ * @param palette Derived avatar palette.
2936
+ * @param hasHeadband Whether the avatar should render a headband row.
2937
+ * @returns 8x8 pixel texture.
2938
+ *
2939
+ * @private helper of the Minecraft avatar visuals
2940
+ */
2941
+ function createMinecraftFaceTexture(random, palette, hasHeadband) {
2942
+ const texture = createFilledTexture(palette.highlight);
2943
+ const hairlineColor = random() < 0.5 ? palette.primary : palette.secondary;
2944
+ const cheekColor = random() < 0.5 ? `${palette.accent}bb` : `${palette.secondary}bb`;
2945
+ fillTextureRect(texture, 0, 0, 8, 2, hairlineColor);
2946
+ texture[2][0] = hairlineColor;
2947
+ texture[2][7] = hairlineColor;
2948
+ texture[3][0] = hairlineColor;
2949
+ texture[3][7] = hairlineColor;
2950
+ if (hasHeadband) {
2951
+ fillTextureRect(texture, 0, 2, 8, 1, palette.accent);
2952
+ }
2953
+ texture[3][2] = palette.ink;
2954
+ texture[3][5] = palette.ink;
2955
+ texture[4][2] = '#ffffff';
2956
+ texture[4][5] = '#ffffff';
2957
+ texture[5][1] = cheekColor;
2958
+ texture[5][6] = cheekColor;
2959
+ texture[5][3] = palette.shadow;
2960
+ texture[5][4] = palette.shadow;
2961
+ texture[6][3] = palette.shadow;
2962
+ texture[6][4] = palette.shadow;
2963
+ return texture;
2964
+ }
2965
+ /**
2966
+ * Creates the front-face pixel texture for the torso.
2967
+ *
2968
+ * @param random Seeded random generator.
2969
+ * @param palette Derived avatar palette.
2970
+ * @returns 8x8 torso texture.
2971
+ *
2972
+ * @private helper of the Minecraft avatar visuals
2973
+ */
2974
+ function createMinecraftShirtTexture(random, palette) {
2975
+ const texture = createFilledTexture(palette.primary);
2976
+ const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
2977
+ fillTextureRect(texture, 0, 0, 8, 2, palette.shadow);
2978
+ for (let rowIndex = 2; rowIndex < 8; rowIndex++) {
2979
+ texture[rowIndex][3] = stripeColor;
2980
+ texture[rowIndex][4] = stripeColor;
2981
+ }
2982
+ texture[4][1] = palette.accent;
2983
+ texture[4][6] = palette.accent;
2984
+ texture[5][2] = palette.highlight;
2985
+ texture[5][5] = palette.highlight;
2986
+ return texture;
2987
+ }
2988
+ /**
2989
+ * Creates one solid-color 8x8 Minecraft texture.
2990
+ *
2991
+ * @param color Fill color.
2992
+ * @returns Filled 8x8 texture.
2993
+ *
2994
+ * @private helper of the Minecraft avatar visuals
2995
+ */
2996
+ function createFilledTexture(color) {
2997
+ return Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => color));
2998
+ }
2999
+ /**
3000
+ * Fills one rectangular area inside a mutable Minecraft texture.
3001
+ *
3002
+ * @param texture Mutable target texture.
3003
+ * @param x Left texture coordinate.
3004
+ * @param y Top texture coordinate.
3005
+ * @param width Rectangle width.
3006
+ * @param height Rectangle height.
3007
+ * @param color Fill color.
3008
+ *
3009
+ * @private helper of the Minecraft avatar visuals
3010
+ */
3011
+ function fillTextureRect(texture, x, y, width, height, color) {
3012
+ for (let rowIndex = y; rowIndex < y + height; rowIndex++) {
3013
+ for (let columnIndex = x; columnIndex < x + width; columnIndex++) {
3014
+ texture[rowIndex][columnIndex] = color;
3015
+ }
3016
+ }
3017
+ }
3018
+
2818
3019
  /* eslint-disable no-magic-numbers */
2819
3020
  /**
2820
3021
  * Minecraft-style 3D avatar visual.
@@ -2839,8 +3040,8 @@
2839
3040
  const bodyX = size * 0.33;
2840
3041
  const bodyY = headY + headSize * 0.96;
2841
3042
  const hasHeadband = random() < 0.5;
2842
- const faceTexture = createMinecraftFaceTexture(createRandom('minecraft-face'), palette, hasHeadband);
2843
- const shirtTexture = createMinecraftShirtTexture(createRandom('minecraft-shirt'), palette);
3043
+ const headTextures = createMinecraftHeadTextures(createRandom('minecraft-face'), palette, hasHeadband);
3044
+ const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft-shirt'), palette);
2844
3045
  drawAvatarFrame(context, size, palette);
2845
3046
  const spotlight = context.createRadialGradient(size * 0.5, size * 0.18, size * 0.05, size * 0.5, size * 0.18, size * 0.5);
2846
3047
  spotlight.addColorStop(0, `${palette.highlight}66`);
@@ -2860,7 +3061,7 @@
2860
3061
  width: bodyWidth,
2861
3062
  height: bodyHeight,
2862
3063
  depth: bodyDepth,
2863
- frontTexture: shirtTexture,
3064
+ frontTexture: torsoTextures.front,
2864
3065
  topColor: `${palette.highlight}cc`,
2865
3066
  sideColor: `${palette.secondary}dd`,
2866
3067
  outlineColor: `${palette.shadow}aa`,
@@ -2871,7 +3072,7 @@
2871
3072
  width: headSize,
2872
3073
  height: headSize,
2873
3074
  depth,
2874
- frontTexture: faceTexture,
3075
+ frontTexture: headTextures.front,
2875
3076
  topColor: `${palette.highlight}ee`,
2876
3077
  sideColor: `${palette.secondary}ee`,
2877
3078
  outlineColor: `${palette.shadow}cc`,
@@ -2936,72 +3137,505 @@
2936
3137
  context.closePath();
2937
3138
  context.stroke();
2938
3139
  }
3140
+
3141
+ /* eslint-disable no-magic-numbers */
2939
3142
  /**
2940
- * Creates the front-face pixel texture for the cube head.
3143
+ * Fixed scene camera distance used for the proper-3D projection.
2941
3144
  *
2942
- * @param random Seeded random generator.
3145
+ * @private helper of `minecraft2AvatarVisual`
3146
+ */
3147
+ const CAMERA_DISTANCE_RATIO = 1.4;
3148
+ /**
3149
+ * Shared light direction used to shade projected cuboid faces.
3150
+ *
3151
+ * @private helper of `minecraft2AvatarVisual`
3152
+ */
3153
+ const LIGHT_DIRECTION = normalizeVector3({
3154
+ x: 0.4,
3155
+ y: -0.65,
3156
+ z: 0.92,
3157
+ });
3158
+ /**
3159
+ * Minecraft 3D 2 avatar visual.
3160
+ *
3161
+ * @private built-in avatar visual
3162
+ */
3163
+ const minecraft2AvatarVisual = {
3164
+ id: 'minecraft2',
3165
+ title: 'Minecraft 3D 2',
3166
+ description: 'Proper 3D Minecraft-style portrait with textured cuboids and pointer-driven head turns.',
3167
+ isAnimated: true,
3168
+ supportsPointerTracking: true,
3169
+ render({ context, size, palette, createRandom, timeMs, interaction }) {
3170
+ const spotlightY = size * 0.22;
3171
+ const headRandom = createRandom('minecraft2-head');
3172
+ const hasHeadband = headRandom() < 0.5;
3173
+ const headTextures = createMinecraftHeadTextures(createRandom('minecraft2-head-textures'), palette, hasHeadband);
3174
+ const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft2-body-textures'), palette);
3175
+ const bob = Math.sin(timeMs / 880) * size * 0.014;
3176
+ const bodyYaw = -0.24 + Math.sin(timeMs / 2300) * 0.06 + interaction.bodyOffsetX * 0.16;
3177
+ const bodyPitch = -0.12 + Math.cos(timeMs / 2800) * 0.02 - interaction.bodyOffsetY * 0.06;
3178
+ const headYaw = -0.18 + Math.sin(timeMs / 1900 + 0.6) * 0.05 + interaction.gazeX * 0.62;
3179
+ const headPitch = -0.12 + Math.cos(timeMs / 2400 + 1.1) * 0.03 - interaction.gazeY * 0.38;
3180
+ const sceneCenterX = size * 0.5;
3181
+ const sceneCenterY = size * 0.57;
3182
+ const bodyWidth = size * 0.225;
3183
+ const bodyHeight = size * 0.245;
3184
+ const bodyDepth = size * 0.145;
3185
+ const headSize = size * 0.24;
3186
+ const headLift = size * 0.205;
3187
+ const headForwardShift = interaction.intensity * size * 0.018;
3188
+ const sceneCuboids = [
3189
+ {
3190
+ center: {
3191
+ x: interaction.bodyOffsetX * size * 0.026,
3192
+ y: size * 0.05 + interaction.bodyOffsetY * size * 0.018 + bob,
3193
+ z: 0,
3194
+ },
3195
+ width: bodyWidth,
3196
+ height: bodyHeight,
3197
+ depth: bodyDepth,
3198
+ rotationX: bodyPitch,
3199
+ rotationY: bodyYaw,
3200
+ textures: torsoTextures,
3201
+ outlineColor: `${palette.shadow}cc`,
3202
+ },
3203
+ {
3204
+ center: {
3205
+ x: interaction.bodyOffsetX * size * 0.018 + interaction.gazeX * size * 0.016,
3206
+ y: -headLift + bob * 1.15,
3207
+ z: headForwardShift,
3208
+ },
3209
+ width: headSize,
3210
+ height: headSize,
3211
+ depth: headSize,
3212
+ rotationX: headPitch,
3213
+ rotationY: headYaw,
3214
+ textures: headTextures,
3215
+ outlineColor: `${palette.shadow}dd`,
3216
+ },
3217
+ ];
3218
+ const visibleFaces = sceneCuboids
3219
+ .flatMap((cuboid) => resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY))
3220
+ .sort((firstFace, secondFace) => firstFace.averageDepth - secondFace.averageDepth);
3221
+ drawAvatarFrame(context, size, palette);
3222
+ drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs);
3223
+ drawMinecraftShadow(context, size, palette, interaction, timeMs);
3224
+ for (const visibleFace of visibleFaces) {
3225
+ drawTexturedProjectedFace(context, visibleFace);
3226
+ }
3227
+ },
3228
+ };
3229
+ /**
3230
+ * Draws the shared background atmosphere behind the Minecraft 3D 2 portrait.
3231
+ *
3232
+ * @param context Canvas 2D context.
3233
+ * @param size Canvas size in CSS pixels.
2943
3234
  * @param palette Derived avatar palette.
2944
- * @param hasHeadband Whether the avatar should render a headband row.
2945
- * @returns 8x8 pixel texture.
3235
+ * @param sceneCenterX Horizontal scene center.
3236
+ * @param spotlightY Vertical spotlight anchor.
3237
+ * @param interaction Smoothed pointer-aware interaction state.
3238
+ * @param timeMs Current animation time in milliseconds.
2946
3239
  *
2947
- * @private helper of `minecraftAvatarVisual`
3240
+ * @private helper of `minecraft2AvatarVisual`
2948
3241
  */
2949
- function createMinecraftFaceTexture(random, palette, hasHeadband) {
2950
- const texture = Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => palette.highlight));
2951
- const hairlineColor = random() < 0.5 ? palette.primary : palette.secondary;
2952
- const cheekColor = random() < 0.5 ? `${palette.accent}bb` : `${palette.secondary}bb`;
2953
- for (let rowIndex = 0; rowIndex < 2; rowIndex++) {
2954
- for (let columnIndex = 0; columnIndex < 8; columnIndex++) {
2955
- texture[rowIndex][columnIndex] = hairlineColor;
3242
+ function drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs) {
3243
+ const spotlightGradient = context.createRadialGradient(sceneCenterX + interaction.gazeX * size * 0.08, spotlightY + interaction.gazeY * size * 0.05, size * 0.03, sceneCenterX, spotlightY, size * 0.52);
3244
+ spotlightGradient.addColorStop(0, `${palette.highlight}66`);
3245
+ spotlightGradient.addColorStop(0.42, `${palette.accent}1d`);
3246
+ spotlightGradient.addColorStop(1, `${palette.highlight}00`);
3247
+ context.fillStyle = spotlightGradient;
3248
+ context.fillRect(0, 0, size, size);
3249
+ const rimGradient = context.createLinearGradient(0, size * 0.14, 0, size * 0.92);
3250
+ rimGradient.addColorStop(0, `${palette.highlight}12`);
3251
+ rimGradient.addColorStop(0.55, `${palette.secondary}0a`);
3252
+ rimGradient.addColorStop(1, `${palette.shadow}00`);
3253
+ context.fillStyle = rimGradient;
3254
+ context.fillRect(0, 0, size, size);
3255
+ context.save();
3256
+ context.globalAlpha = 0.08 + interaction.intensity * 0.04;
3257
+ context.fillStyle = palette.highlight;
3258
+ context.beginPath();
3259
+ context.arc(size * 0.72 + Math.sin(timeMs / 1600) * size * 0.03, size * 0.2 + Math.cos(timeMs / 1400) * size * 0.018, size * 0.025, 0, Math.PI * 2);
3260
+ context.fill();
3261
+ context.restore();
3262
+ }
3263
+ /**
3264
+ * Draws the soft floor shadow used to anchor the cuboids in the frame.
3265
+ *
3266
+ * @param context Canvas 2D context.
3267
+ * @param size Canvas size in CSS pixels.
3268
+ * @param palette Derived avatar palette.
3269
+ * @param interaction Smoothed pointer-aware interaction state.
3270
+ * @param timeMs Current animation time in milliseconds.
3271
+ *
3272
+ * @private helper of `minecraft2AvatarVisual`
3273
+ */
3274
+ function drawMinecraftShadow(context, size, palette, interaction, timeMs) {
3275
+ context.save();
3276
+ context.fillStyle = `${palette.shadow}66`;
3277
+ context.filter = `blur(${size * 0.02}px)`;
3278
+ context.beginPath();
3279
+ context.ellipse(size * 0.5 + interaction.gazeX * size * 0.03, size * 0.85 + Math.sin(timeMs / 880) * size * 0.01, size * (0.16 + interaction.intensity * 0.015), size * 0.055, 0, 0, Math.PI * 2);
3280
+ context.fill();
3281
+ context.restore();
3282
+ }
3283
+ /**
3284
+ * Resolves all visible projected faces for one scene cuboid.
3285
+ *
3286
+ * @param cuboid Scene cuboid definition.
3287
+ * @param size Canvas size in CSS pixels.
3288
+ * @param sceneCenterX Horizontal scene center.
3289
+ * @param sceneCenterY Vertical scene center.
3290
+ * @returns Visible faces sorted later by depth.
3291
+ *
3292
+ * @private helper of `minecraft2AvatarVisual`
3293
+ */
3294
+ function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
3295
+ const halfWidth = cuboid.width / 2;
3296
+ const halfHeight = cuboid.height / 2;
3297
+ const halfDepth = cuboid.depth / 2;
3298
+ const faceDefinitions = [
3299
+ {
3300
+ texture: cuboid.textures.front,
3301
+ corners: [
3302
+ { x: -halfWidth, y: -halfHeight, z: halfDepth },
3303
+ { x: halfWidth, y: -halfHeight, z: halfDepth },
3304
+ { x: halfWidth, y: halfHeight, z: halfDepth },
3305
+ { x: -halfWidth, y: halfHeight, z: halfDepth },
3306
+ ],
3307
+ },
3308
+ {
3309
+ texture: cuboid.textures.back,
3310
+ corners: [
3311
+ { x: halfWidth, y: -halfHeight, z: -halfDepth },
3312
+ { x: -halfWidth, y: -halfHeight, z: -halfDepth },
3313
+ { x: -halfWidth, y: halfHeight, z: -halfDepth },
3314
+ { x: halfWidth, y: halfHeight, z: -halfDepth },
3315
+ ],
3316
+ },
3317
+ {
3318
+ texture: cuboid.textures.right,
3319
+ corners: [
3320
+ { x: halfWidth, y: -halfHeight, z: halfDepth },
3321
+ { x: halfWidth, y: -halfHeight, z: -halfDepth },
3322
+ { x: halfWidth, y: halfHeight, z: -halfDepth },
3323
+ { x: halfWidth, y: halfHeight, z: halfDepth },
3324
+ ],
3325
+ },
3326
+ {
3327
+ texture: cuboid.textures.left,
3328
+ corners: [
3329
+ { x: -halfWidth, y: -halfHeight, z: -halfDepth },
3330
+ { x: -halfWidth, y: -halfHeight, z: halfDepth },
3331
+ { x: -halfWidth, y: halfHeight, z: halfDepth },
3332
+ { x: -halfWidth, y: halfHeight, z: -halfDepth },
3333
+ ],
3334
+ },
3335
+ {
3336
+ texture: cuboid.textures.top,
3337
+ corners: [
3338
+ { x: -halfWidth, y: -halfHeight, z: -halfDepth },
3339
+ { x: halfWidth, y: -halfHeight, z: -halfDepth },
3340
+ { x: halfWidth, y: -halfHeight, z: halfDepth },
3341
+ { x: -halfWidth, y: -halfHeight, z: halfDepth },
3342
+ ],
3343
+ },
3344
+ {
3345
+ texture: cuboid.textures.bottom,
3346
+ corners: [
3347
+ { x: -halfWidth, y: halfHeight, z: halfDepth },
3348
+ { x: halfWidth, y: halfHeight, z: halfDepth },
3349
+ { x: halfWidth, y: halfHeight, z: -halfDepth },
3350
+ { x: -halfWidth, y: halfHeight, z: -halfDepth },
3351
+ ],
3352
+ },
3353
+ ];
3354
+ const visibleFaces = faceDefinitions
3355
+ .map((faceDefinition) => {
3356
+ const transformedCorners = faceDefinition.corners.map((corner) => transformScenePoint(corner, cuboid.center, cuboid.rotationX, cuboid.rotationY));
3357
+ const faceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
3358
+ if (faceNormal.z <= 0.02) {
3359
+ return null;
2956
3360
  }
3361
+ const projectedCorners = transformedCorners.map((corner) => projectScenePoint(corner, size, sceneCenterX, sceneCenterY));
3362
+ return {
3363
+ corners: projectedCorners,
3364
+ texture: faceDefinition.texture,
3365
+ averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
3366
+ lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION), -1, 1),
3367
+ outlineColor: cuboid.outlineColor,
3368
+ };
3369
+ });
3370
+ return visibleFaces.filter((visibleFace) => visibleFace !== null);
3371
+ }
3372
+ /**
3373
+ * Draws one projected textured face by tessellating its texture cells into quads.
3374
+ *
3375
+ * @param context Canvas 2D context.
3376
+ * @param face Visible projected face.
3377
+ *
3378
+ * @private helper of `minecraft2AvatarVisual`
3379
+ */
3380
+ function drawTexturedProjectedFace(context, face) {
3381
+ var _a;
3382
+ const rows = face.texture.length;
3383
+ const columns = ((_a = face.texture[0]) === null || _a === void 0 ? void 0 : _a.length) || 0;
3384
+ if (rows === 0 || columns === 0) {
3385
+ return;
2957
3386
  }
2958
- texture[2][0] = hairlineColor;
2959
- texture[2][7] = hairlineColor;
2960
- texture[3][0] = hairlineColor;
2961
- texture[3][7] = hairlineColor;
2962
- if (hasHeadband) {
2963
- for (let columnIndex = 0; columnIndex < 8; columnIndex++) {
2964
- texture[2][columnIndex] = palette.accent;
3387
+ for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
3388
+ for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
3389
+ const startX = columnIndex / columns;
3390
+ const endX = (columnIndex + 1) / columns;
3391
+ const startY = rowIndex / rows;
3392
+ const endY = (rowIndex + 1) / rows;
3393
+ drawProjectedQuad(context, [
3394
+ interpolateProjectedQuad(face.corners, startX, startY),
3395
+ interpolateProjectedQuad(face.corners, endX, startY),
3396
+ interpolateProjectedQuad(face.corners, endX, endY),
3397
+ interpolateProjectedQuad(face.corners, startX, endY),
3398
+ ], face.texture[rowIndex][columnIndex]);
2965
3399
  }
2966
3400
  }
2967
- texture[3][2] = palette.ink;
2968
- texture[3][5] = palette.ink;
2969
- texture[4][2] = '#ffffff';
2970
- texture[4][5] = '#ffffff';
2971
- texture[5][1] = cheekColor;
2972
- texture[5][6] = cheekColor;
2973
- texture[5][3] = palette.shadow;
2974
- texture[5][4] = palette.shadow;
2975
- texture[6][3] = palette.shadow;
2976
- texture[6][4] = palette.shadow;
2977
- return texture;
3401
+ if (face.lightIntensity > 0) {
3402
+ drawProjectedQuad(context, face.corners, `rgba(255, 255, 255, ${0.15 * face.lightIntensity})`);
3403
+ }
3404
+ else if (face.lightIntensity < 0) {
3405
+ drawProjectedQuad(context, face.corners, `rgba(0, 0, 0, ${0.22 * Math.abs(face.lightIntensity)})`);
3406
+ }
3407
+ context.save();
3408
+ context.beginPath();
3409
+ context.moveTo(face.corners[0].x, face.corners[0].y);
3410
+ for (let cornerIndex = 1; cornerIndex < face.corners.length; cornerIndex++) {
3411
+ context.lineTo(face.corners[cornerIndex].x, face.corners[cornerIndex].y);
3412
+ }
3413
+ context.closePath();
3414
+ context.strokeStyle = face.outlineColor;
3415
+ context.lineWidth = Math.max(1.1, getProjectedQuadPerimeter(face.corners) * 0.0045);
3416
+ context.lineJoin = 'round';
3417
+ context.stroke();
3418
+ context.restore();
2978
3419
  }
2979
3420
  /**
2980
- * Creates the front-face pixel texture for the torso.
3421
+ * Draws one filled projected quad.
2981
3422
  *
2982
- * @param random Seeded random generator.
2983
- * @param palette Derived avatar palette.
2984
- * @returns 8x8 torso texture.
3423
+ * @param context Canvas 2D context.
3424
+ * @param corners Quad corners in clockwise order.
3425
+ * @param fillStyle CSS fill style.
2985
3426
  *
2986
- * @private helper of `minecraftAvatarVisual`
3427
+ * @private helper of `minecraft2AvatarVisual`
2987
3428
  */
2988
- function createMinecraftShirtTexture(random, palette) {
2989
- const texture = Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => palette.primary));
2990
- const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
2991
- for (let rowIndex = 0; rowIndex < 2; rowIndex++) {
2992
- for (let columnIndex = 0; columnIndex < 8; columnIndex++) {
2993
- texture[rowIndex][columnIndex] = palette.shadow;
2994
- }
3429
+ function drawProjectedQuad(context, corners, fillStyle) {
3430
+ context.beginPath();
3431
+ context.moveTo(corners[0].x, corners[0].y);
3432
+ context.lineTo(corners[1].x, corners[1].y);
3433
+ context.lineTo(corners[2].x, corners[2].y);
3434
+ context.lineTo(corners[3].x, corners[3].y);
3435
+ context.closePath();
3436
+ context.fillStyle = fillStyle;
3437
+ context.fill();
3438
+ }
3439
+ /**
3440
+ * Interpolates one point inside a projected quad across both quad axes.
3441
+ *
3442
+ * @param corners Quad corners in clockwise order.
3443
+ * @param horizontalRatio Horizontal ratio in the range `[0, 1]`.
3444
+ * @param verticalRatio Vertical ratio in the range `[0, 1]`.
3445
+ * @returns Interpolated projected point.
3446
+ *
3447
+ * @private helper of `minecraft2AvatarVisual`
3448
+ */
3449
+ function interpolateProjectedQuad(corners, horizontalRatio, verticalRatio) {
3450
+ const topPoint = interpolateProjectedPoint(corners[0], corners[1], horizontalRatio);
3451
+ const bottomPoint = interpolateProjectedPoint(corners[3], corners[2], horizontalRatio);
3452
+ return interpolateProjectedPoint(topPoint, bottomPoint, verticalRatio);
3453
+ }
3454
+ /**
3455
+ * Interpolates between two projected points.
3456
+ *
3457
+ * @param startPoint Start point.
3458
+ * @param endPoint End point.
3459
+ * @param ratio Interpolation ratio in the range `[0, 1]`.
3460
+ * @returns Interpolated projected point.
3461
+ *
3462
+ * @private helper of `minecraft2AvatarVisual`
3463
+ */
3464
+ function interpolateProjectedPoint(startPoint, endPoint, ratio) {
3465
+ return {
3466
+ x: startPoint.x + (endPoint.x - startPoint.x) * ratio,
3467
+ y: startPoint.y + (endPoint.y - startPoint.y) * ratio,
3468
+ z: startPoint.z + (endPoint.z - startPoint.z) * ratio,
3469
+ };
3470
+ }
3471
+ /**
3472
+ * Projects one rotated scene point into canvas coordinates.
3473
+ *
3474
+ * @param point Scene point.
3475
+ * @param size Canvas size in CSS pixels.
3476
+ * @param sceneCenterX Horizontal scene center.
3477
+ * @param sceneCenterY Vertical scene center.
3478
+ * @returns Projected point.
3479
+ *
3480
+ * @private helper of `minecraft2AvatarVisual`
3481
+ */
3482
+ function projectScenePoint(point, size, sceneCenterX, sceneCenterY) {
3483
+ const cameraDistance = size * CAMERA_DISTANCE_RATIO;
3484
+ const perspectiveScale = cameraDistance / Math.max(cameraDistance - point.z, cameraDistance * 0.35);
3485
+ return {
3486
+ x: sceneCenterX + point.x * perspectiveScale,
3487
+ y: sceneCenterY + point.y * perspectiveScale,
3488
+ z: point.z,
3489
+ };
3490
+ }
3491
+ /**
3492
+ * Applies the local cuboid rotations and translation to one scene point.
3493
+ *
3494
+ * @param localPoint Point in cuboid-local space.
3495
+ * @param center Cuboid center in scene space.
3496
+ * @param rotationX Cuboid pitch in radians.
3497
+ * @param rotationY Cuboid yaw in radians.
3498
+ * @returns Transformed scene-space point.
3499
+ *
3500
+ * @private helper of `minecraft2AvatarVisual`
3501
+ */
3502
+ function transformScenePoint(localPoint, center, rotationX, rotationY) {
3503
+ const yawedPoint = rotatePointAroundY(localPoint, rotationY);
3504
+ const pitchedPoint = rotatePointAroundX(yawedPoint, rotationX);
3505
+ return {
3506
+ x: center.x + pitchedPoint.x,
3507
+ y: center.y + pitchedPoint.y,
3508
+ z: center.z + pitchedPoint.z,
3509
+ };
3510
+ }
3511
+ /**
3512
+ * Rotates one point around the local Y axis.
3513
+ *
3514
+ * @param point Source point.
3515
+ * @param angle Rotation angle in radians.
3516
+ * @returns Rotated point.
3517
+ *
3518
+ * @private helper of `minecraft2AvatarVisual`
3519
+ */
3520
+ function rotatePointAroundY(point, angle) {
3521
+ const cosine = Math.cos(angle);
3522
+ const sine = Math.sin(angle);
3523
+ return {
3524
+ x: point.x * cosine + point.z * sine,
3525
+ y: point.y,
3526
+ z: -point.x * sine + point.z * cosine,
3527
+ };
3528
+ }
3529
+ /**
3530
+ * Rotates one point around the local X axis.
3531
+ *
3532
+ * @param point Source point.
3533
+ * @param angle Rotation angle in radians.
3534
+ * @returns Rotated point.
3535
+ *
3536
+ * @private helper of `minecraft2AvatarVisual`
3537
+ */
3538
+ function rotatePointAroundX(point, angle) {
3539
+ const cosine = Math.cos(angle);
3540
+ const sine = Math.sin(angle);
3541
+ return {
3542
+ x: point.x,
3543
+ y: point.y * cosine - point.z * sine,
3544
+ z: point.y * sine + point.z * cosine,
3545
+ };
3546
+ }
3547
+ /**
3548
+ * Subtracts one 3D point from another.
3549
+ *
3550
+ * @param leftPoint Left point.
3551
+ * @param rightPoint Right point.
3552
+ * @returns Difference vector.
3553
+ *
3554
+ * @private helper of `minecraft2AvatarVisual`
3555
+ */
3556
+ function subtractPoint3D(leftPoint, rightPoint) {
3557
+ return {
3558
+ x: leftPoint.x - rightPoint.x,
3559
+ y: leftPoint.y - rightPoint.y,
3560
+ z: leftPoint.z - rightPoint.z,
3561
+ };
3562
+ }
3563
+ /**
3564
+ * Computes the 3D cross product of two vectors.
3565
+ *
3566
+ * @param leftVector Left vector.
3567
+ * @param rightVector Right vector.
3568
+ * @returns Cross product.
3569
+ *
3570
+ * @private helper of `minecraft2AvatarVisual`
3571
+ */
3572
+ function crossProduct3D(leftVector, rightVector) {
3573
+ return {
3574
+ x: leftVector.y * rightVector.z - leftVector.z * rightVector.y,
3575
+ y: leftVector.z * rightVector.x - leftVector.x * rightVector.z,
3576
+ z: leftVector.x * rightVector.y - leftVector.y * rightVector.x,
3577
+ };
3578
+ }
3579
+ /**
3580
+ * Computes the 3D dot product of two vectors.
3581
+ *
3582
+ * @param leftVector Left vector.
3583
+ * @param rightVector Right vector.
3584
+ * @returns Dot product.
3585
+ *
3586
+ * @private helper of `minecraft2AvatarVisual`
3587
+ */
3588
+ function dotProduct3D(leftVector, rightVector) {
3589
+ return leftVector.x * rightVector.x + leftVector.y * rightVector.y + leftVector.z * rightVector.z;
3590
+ }
3591
+ /**
3592
+ * Normalizes one 3D vector while keeping zero vectors stable.
3593
+ *
3594
+ * @param vector Source vector.
3595
+ * @returns Normalized vector.
3596
+ *
3597
+ * @private helper of `minecraft2AvatarVisual`
3598
+ */
3599
+ function normalizeVector3(vector) {
3600
+ const length = Math.hypot(vector.x, vector.y, vector.z);
3601
+ if (length === 0) {
3602
+ return vector;
2995
3603
  }
2996
- for (let rowIndex = 2; rowIndex < 8; rowIndex++) {
2997
- texture[rowIndex][3] = stripeColor;
2998
- texture[rowIndex][4] = stripeColor;
3604
+ return {
3605
+ x: vector.x / length,
3606
+ y: vector.y / length,
3607
+ z: vector.z / length,
3608
+ };
3609
+ }
3610
+ /**
3611
+ * Clamps one number into the provided range.
3612
+ *
3613
+ * @param value Input value.
3614
+ * @param minimumValue Inclusive lower bound.
3615
+ * @param maximumValue Inclusive upper bound.
3616
+ * @returns Clamped value.
3617
+ *
3618
+ * @private helper of `minecraft2AvatarVisual`
3619
+ */
3620
+ function clampNumber$1(value, minimumValue, maximumValue) {
3621
+ return Math.min(maximumValue, Math.max(minimumValue, value));
3622
+ }
3623
+ /**
3624
+ * Measures the perimeter of one projected quad.
3625
+ *
3626
+ * @param corners Quad corners.
3627
+ * @returns Perimeter length.
3628
+ *
3629
+ * @private helper of `minecraft2AvatarVisual`
3630
+ */
3631
+ function getProjectedQuadPerimeter(corners) {
3632
+ let perimeter = 0;
3633
+ for (let cornerIndex = 0; cornerIndex < corners.length; cornerIndex++) {
3634
+ const currentCorner = corners[cornerIndex];
3635
+ const nextCorner = corners[(cornerIndex + 1) % corners.length];
3636
+ perimeter += Math.hypot(nextCorner.x - currentCorner.x, nextCorner.y - currentCorner.y);
2999
3637
  }
3000
- texture[4][1] = palette.accent;
3001
- texture[4][6] = palette.accent;
3002
- texture[5][2] = palette.highlight;
3003
- texture[5][5] = palette.highlight;
3004
- return texture;
3638
+ return perimeter;
3005
3639
  }
3006
3640
 
3007
3641
  /* eslint-disable no-magic-numbers */
@@ -4606,6 +5240,7 @@
4606
5240
  octopus3AvatarVisual,
4607
5241
  asciiOctopusAvatarVisual,
4608
5242
  minecraftAvatarVisual,
5243
+ minecraft2AvatarVisual,
4609
5244
  fractalAvatarVisual,
4610
5245
  orbAvatarVisual,
4611
5246
  ];
@@ -14518,7 +15153,10 @@
14518
15153
  */
14519
15154
  function buildTeamToolDescription(entry) {
14520
15155
  const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
14521
- return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
15156
+ return spacetrim.spaceTrim((block) => `
15157
+ Consult teammate ${entry.teammate.label}
15158
+ ${block(detailLines.join('\n'))}
15159
+ `);
14522
15160
  }
14523
15161
  /**
14524
15162
  * Collects structured teammate details that should stay visible to the model.
@@ -20034,7 +20672,10 @@
20034
20672
  if (hiddenCount > 0) {
20035
20673
  summaryRows.push(`...and ${hiddenCount} more.`);
20036
20674
  }
20037
- return [`Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:`, ...summaryRows].join('\n');
20675
+ return spacetrim.spaceTrim((block) => `
20676
+ Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:
20677
+ ${block(summaryRows.join('\n'))}
20678
+ `);
20038
20679
  }
20039
20680
  /**
20040
20681
  * Formats one timeout row for assistant-visible timeout listings.