@promptbook/wizard 0.112.0-125 → 0.112.0-127

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 (46) hide show
  1. package/README.md +5 -5
  2. package/esm/index.es.js +225 -51
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/_packages/components.index.d.ts +2 -0
  5. package/esm/src/_packages/types.index.d.ts +2 -0
  6. package/esm/src/avatars/avatarAnimationScheduler.d.ts +4 -0
  7. package/esm/src/book-components/Chat/Chat/ChatCitationModal.d.ts +2 -0
  8. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  9. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  10. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  11. package/esm/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +2 -0
  12. package/esm/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +3 -1
  13. package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +2 -0
  14. package/esm/src/book-components/Chat/SourceChip/SourceChip.d.ts +6 -1
  15. package/esm/src/book-components/Chat/hooks/useResolvedCitationLabel.d.ts +12 -0
  16. package/esm/src/book-components/Chat/types/ChatMessage.d.ts +4 -0
  17. package/esm/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  18. package/esm/src/book-components/Chat/types/CitationLabelResolver.d.ts +8 -0
  19. package/esm/src/book-components/Chat/utils/citationHelpers.d.ts +9 -0
  20. package/esm/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.d.ts +14 -0
  21. package/esm/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.test.d.ts +1 -0
  22. package/esm/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +4 -0
  23. package/esm/src/version.d.ts +1 -1
  24. package/package.json +2 -2
  25. package/umd/index.umd.js +225 -51
  26. package/umd/index.umd.js.map +1 -1
  27. package/umd/src/_packages/components.index.d.ts +2 -0
  28. package/umd/src/_packages/types.index.d.ts +2 -0
  29. package/umd/src/avatars/avatarAnimationScheduler.d.ts +4 -0
  30. package/umd/src/book-components/Chat/Chat/ChatCitationModal.d.ts +2 -0
  31. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  32. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  33. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  34. package/umd/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +2 -0
  35. package/umd/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +3 -1
  36. package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +2 -0
  37. package/umd/src/book-components/Chat/SourceChip/SourceChip.d.ts +6 -1
  38. package/umd/src/book-components/Chat/hooks/useResolvedCitationLabel.d.ts +12 -0
  39. package/umd/src/book-components/Chat/types/ChatMessage.d.ts +4 -0
  40. package/umd/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  41. package/umd/src/book-components/Chat/types/CitationLabelResolver.d.ts +8 -0
  42. package/umd/src/book-components/Chat/utils/citationHelpers.d.ts +9 -0
  43. package/umd/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.d.ts +14 -0
  44. package/umd/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.test.d.ts +1 -0
  45. package/umd/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +4 -0
  46. package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js CHANGED
@@ -52,7 +52,7 @@
52
52
  * @generated
53
53
  * @see https://github.com/webgptorg/promptbook
54
54
  */
55
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-125';
55
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-127';
56
56
  /**
57
57
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
58
58
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -19380,8 +19380,11 @@
19380
19380
  if (!trimmedContent) {
19381
19381
  return requirements;
19382
19382
  }
19383
- // Add goal as a proper h2 section to the system message
19384
- const goalSection = `## Goal\n\n${trimmedContent}`;
19383
+ const goalSection = _spaceTrim.spaceTrim((block) => `
19384
+ ## Goal
19385
+
19386
+ ${block(trimmedContent)}
19387
+ `);
19385
19388
  const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
19386
19389
  return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
19387
19390
  }
@@ -19767,8 +19770,11 @@
19767
19770
  if (!trimmedContent) {
19768
19771
  return requirements;
19769
19772
  }
19770
- // Add language as a bullet under a ## Language section
19771
- const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
19773
+ const languageSection = _spaceTrim.spaceTrim((block) => `
19774
+ ## Language
19775
+
19776
+ - Your language is ${block(trimmedContent)}
19777
+ `);
19772
19778
  return this.appendToSystemMessage(requirements, languageSection, '\n\n');
19773
19779
  }
19774
19780
  }
@@ -24610,41 +24616,91 @@
24610
24616
  context.fill();
24611
24617
  context.restore();
24612
24618
  }
24619
+ /**
24620
+ * Number of latitude segments used by the single blobby octopus mesh.
24621
+ *
24622
+ * @private helper of `octopus3d2AvatarVisual`
24623
+ */
24624
+ const LATITUDE_PATCH_COUNT$1 = 12;
24625
+ /**
24626
+ * Number of longitude segments used by the single blobby octopus mesh.
24627
+ *
24628
+ * @private helper of `octopus3d2AvatarVisual`
24629
+ */
24630
+ const LONGITUDE_PATCH_COUNT$1 = 24;
24613
24631
  /**
24614
24632
  * Resolves all visible projected patches for the single blobby octopus mesh.
24615
24633
  *
24634
+ * Within a single frame, mesh corner samples and longitude-only lobe-wave values are
24635
+ * quantized to the patch grid and computed once each rather than re-evaluated for every
24636
+ * patch corner — the patch loop alone would call `sampleBlobbyOctopusSurfacePoint`
24637
+ * `latitudePatchCount * longitudePatchCount * 4` times without caching, even though most
24638
+ * corners are shared between neighboring patches.
24639
+ *
24616
24640
  * @private helper of `octopus3d2AvatarVisual`
24617
24641
  */
24618
24642
  function resolveVisibleBlobbyOctopusPatches(options) {
24619
24643
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, animationPhase, timeMs, } = options;
24620
- const latitudePatchCount = 12;
24621
- const longitudePatchCount = 24;
24644
+ const latitudePatchCount = LATITUDE_PATCH_COUNT$1;
24645
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT$1;
24622
24646
  const surfacePatches = [];
24647
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
24648
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
24649
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
24650
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
24651
+ }
24652
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
24653
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
24654
+ }
24655
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
24656
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
24657
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveLowerLobeWave(longitudeBoundaries[boundaryIndex], morphologyProfile, animationPhase, timeMs);
24658
+ }
24659
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
24660
+ const transformedCornerSamples = new Array(cornerCount);
24661
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
24662
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
24663
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
24664
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
24665
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
24666
+ const cornerSample = sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
24667
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
24668
+ }
24669
+ }
24623
24670
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
24624
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
24625
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
24671
+ const startLatitude = latitudeBoundaries[latitudeIndex];
24672
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
24626
24673
  const centerLatitude = (startLatitude + endLatitude) / 2;
24627
24674
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
24675
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
24676
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
24628
24677
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
24629
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
24630
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
24678
+ const startLongitude = longitudeBoundaries[longitudeIndex];
24679
+ const endLongitude = longitudeBoundaries[longitudeIndex + 1];
24631
24680
  const centerLongitude = (startLongitude + endLongitude) / 2;
24632
- const localCorners = [
24633
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, startLongitude),
24634
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, endLongitude),
24635
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, endLongitude),
24636
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, startLongitude),
24681
+ const transformedCorners = [
24682
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
24683
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
24684
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
24685
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
24637
24686
  ];
24638
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
24639
24687
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
24640
24688
  if (surfaceNormal.z <= 0.01) {
24641
24689
  continue;
24642
24690
  }
24643
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
24691
+ const projectedCorners = [
24692
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
24693
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
24694
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
24695
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
24696
+ ];
24644
24697
  surfacePatches.push({
24645
24698
  corners: projectedCorners,
24646
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
24647
- transformedCorners.length,
24699
+ averageDepth: (transformedCorners[0].z +
24700
+ transformedCorners[1].z +
24701
+ transformedCorners[2].z +
24702
+ transformedCorners[3].z) /
24703
+ 4,
24648
24704
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
24649
24705
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
24650
24706
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
@@ -24662,12 +24718,21 @@
24662
24718
  * @private helper of `octopus3d2AvatarVisual`
24663
24719
  */
24664
24720
  function sampleBlobbyOctopusSurfacePoint(options, latitude, longitude) {
24721
+ const { morphologyProfile, animationPhase, timeMs } = options;
24722
+ return sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs));
24723
+ }
24724
+ /**
24725
+ * Samples one point on the continuous Octopus 3D 2 surface using a precomputed lower-lobe wave
24726
+ * to skip the per-call trig evaluation for `latitudePatchCount + 1` longitude-shared corners.
24727
+ *
24728
+ * @private helper of `octopus3d2AvatarVisual`
24729
+ */
24730
+ function sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, lowerLobeWave) {
24665
24731
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
24666
24732
  const cosineLatitude = Math.max(0, Math.cos(latitude));
24667
24733
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
24668
24734
  const upperBlend = Math.pow(1 - verticalProgress, 1.2);
24669
24735
  const lowerBlend = Math.pow(verticalProgress, 1.42);
24670
- const lowerLobeWave = resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs);
24671
24736
  const skirtEnvelope = Math.pow(cosineLatitude, 0.5) * lowerBlend;
24672
24737
  const horizontalScale = 1.02 +
24673
24738
  skirtEnvelope * (0.34 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.22 + lowerLobeWave * 0.22) -
@@ -24964,45 +25029,102 @@
24964
25029
  context.fill();
24965
25030
  context.restore();
24966
25031
  }
25032
+ /**
25033
+ * Number of latitude segments used by the continuous Octopus 3D 3 mesh.
25034
+ *
25035
+ * @private helper of `octopus3d3AvatarVisual`
25036
+ */
25037
+ const LATITUDE_PATCH_COUNT = 16;
25038
+ /**
25039
+ * Number of longitude segments used by the continuous Octopus 3D 3 mesh.
25040
+ *
25041
+ * @private helper of `octopus3d3AvatarVisual`
25042
+ */
25043
+ const LONGITUDE_PATCH_COUNT = 40;
24967
25044
  /**
24968
25045
  * Resolves visible projected patches for the continuous octopus mesh.
24969
25046
  *
25047
+ * Within a single frame, mesh corner samples and longitude-only computations (tentacle
25048
+ * influence and lobe wave) are quantized to the patch grid and computed once each rather
25049
+ * than re-evaluated for every patch corner — the patch loop alone calls `sampleContinuousOctopusSurfacePoint`
25050
+ * for `latitudePatchCount * longitudePatchCount * 4` corners without caching, and each call
25051
+ * triggers an inner 8-iteration `Math.exp` loop, which dominates the per-frame cost.
25052
+ *
24970
25053
  * @private helper of `octopus3d3AvatarVisual`
24971
25054
  */
24972
25055
  function resolveVisibleContinuousOctopusPatches(options) {
24973
25056
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
24974
- const latitudePatchCount = 16;
24975
- const longitudePatchCount = 40;
25057
+ const latitudePatchCount = LATITUDE_PATCH_COUNT;
25058
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT;
24976
25059
  const surfacePatches = [];
25060
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
25061
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
25062
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
25063
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
25064
+ }
25065
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
25066
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
25067
+ }
25068
+ const cachedTentacleInfluencesByCornerLongitude = new Array(longitudePatchCount + 1);
25069
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
25070
+ const cachedTentacleInfluencesByPatchCenterLongitude = new Array(longitudePatchCount);
25071
+ const cachedLobeWavesByPatchCenterLongitude = new Float64Array(longitudePatchCount);
25072
+ const cachedCosByPatchCenterLongitude = new Float64Array(longitudePatchCount);
25073
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
25074
+ const cornerLongitude = longitudeBoundaries[boundaryIndex];
25075
+ cachedTentacleInfluencesByCornerLongitude[boundaryIndex] = resolveContinuousTentacleInfluence(options, cornerLongitude);
25076
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveContinuousLobeWave(options, cornerLongitude);
25077
+ }
25078
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
25079
+ const patchCenterLongitude = (longitudeBoundaries[longitudeIndex] + longitudeBoundaries[longitudeIndex + 1]) / 2;
25080
+ cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex] = resolveContinuousTentacleInfluence(options, patchCenterLongitude);
25081
+ cachedLobeWavesByPatchCenterLongitude[longitudeIndex] = resolveContinuousLobeWave(options, patchCenterLongitude);
25082
+ cachedCosByPatchCenterLongitude[longitudeIndex] = Math.max(0, Math.cos(patchCenterLongitude));
25083
+ }
25084
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
25085
+ const transformedCornerSamples = new Array(cornerCount);
25086
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
25087
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
25088
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
25089
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
25090
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
25091
+ const cornerSample = sampleContinuousOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedTentacleInfluencesByCornerLongitude[longitudeBoundaryIndex], cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
25092
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
25093
+ }
25094
+ }
24977
25095
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
24978
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
24979
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
25096
+ const startLatitude = latitudeBoundaries[latitudeIndex];
25097
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
24980
25098
  const centerLatitude = (startLatitude + endLatitude) / 2;
24981
25099
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
25100
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
25101
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
24982
25102
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
24983
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
24984
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
24985
- const centerLongitude = (startLongitude + endLongitude) / 2;
24986
- const localCorners = [
24987
- sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
24988
- sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
24989
- sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
24990
- sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
25103
+ const transformedCorners = [
25104
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
25105
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
25106
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
25107
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
24991
25108
  ];
24992
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
24993
25109
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
24994
25110
  if (surfaceNormal.z <= 0.008) {
24995
25111
  continue;
24996
25112
  }
24997
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
24998
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
24999
- const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
25113
+ const projectedCorners = [
25114
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
25115
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
25116
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
25117
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
25118
+ ];
25000
25119
  surfacePatches.push({
25001
25120
  corners: projectedCorners,
25002
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
25003
- transformedCorners.length,
25121
+ averageDepth: (transformedCorners[0].z +
25122
+ transformedCorners[1].z +
25123
+ transformedCorners[2].z +
25124
+ transformedCorners[3].z) /
25125
+ 4,
25004
25126
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
25005
- fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
25127
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, cachedCosByPatchCenterLongitude[longitudeIndex], cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex].core, cachedLobeWavesByPatchCenterLongitude[longitudeIndex]),
25006
25128
  outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
25007
25129
  });
25008
25130
  }
@@ -25018,16 +25140,27 @@
25018
25140
  * @private helper of `octopus3d3AvatarVisual`
25019
25141
  */
25020
25142
  function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
25143
+ return sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveContinuousTentacleInfluence(options, longitude), resolveContinuousLobeWave(options, longitude));
25144
+ }
25145
+ /**
25146
+ * Samples one point on the continuous Octopus 3D 3 surface using precomputed longitude-only
25147
+ * values to skip the per-call `Math.exp` tentacle-influence loop and the lobe-wave trig call.
25148
+ *
25149
+ * The patch loop quantizes the mesh into a fixed `(latitudePatchCount + 1) * (longitudePatchCount + 1)`
25150
+ * corner grid, so the same longitude is reused across every latitude row and each
25151
+ * tentacle/lobe value can be computed once per frame instead of `latitudePatchCount * 4` times.
25152
+ *
25153
+ * @private helper of `octopus3d3AvatarVisual`
25154
+ */
25155
+ function sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, tentacleInfluence, lowerLobeWave) {
25021
25156
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
25022
25157
  const cosineLatitude = Math.max(0, Math.cos(latitude));
25023
25158
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
25024
25159
  const upperBlend = Math.pow(1 - verticalProgress, 1.28);
25025
25160
  const lowerBlend = smoothStep(0.38, 1, verticalProgress);
25026
25161
  const tipBlend = smoothStep(0.68, 1, verticalProgress);
25027
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
25028
25162
  const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
25029
25163
  const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
25030
- const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
25031
25164
  const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
25032
25165
  animationPhase * 0.6 +
25033
25166
  timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
@@ -28358,7 +28491,15 @@
28358
28491
  * Builds the teammate request text, optionally including context.
28359
28492
  */
28360
28493
  function buildTeammateRequest(message, context) {
28361
- return context ? `${message}\n\nContext:\n${context}` : message;
28494
+ if (!context) {
28495
+ return message;
28496
+ }
28497
+ return _spaceTrim.spaceTrim((block) => `
28498
+ ${block(message)}
28499
+
28500
+ Context:
28501
+ ${block(context)}
28502
+ `);
28362
28503
  }
28363
28504
  /**
28364
28505
  * Builds a minimal chat prompt for teammate calls.
@@ -32184,7 +32325,11 @@
32184
32325
  const lineRangedContent = applyOptionalLineRange(decodedContent, args.startLine, args.endLine);
32185
32326
  const wasCharacterTruncated = lineRangedContent.length > MAX_PROJECT_FILE_CONTENT_CHARACTERS;
32186
32327
  const contentToReturn = wasCharacterTruncated
32187
- ? `${lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS)}\n\n[...truncated...]`
32328
+ ? _spaceTrim.spaceTrim((block) => `
32329
+ ${block(lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS))}
32330
+
32331
+ [...truncated...]
32332
+ `)
32188
32333
  : lineRangedContent;
32189
32334
  const wasTruncated = decoded.isTruncated || wasCharacterTruncated;
32190
32335
  if (wasCharacterTruncated) {
@@ -35673,11 +35818,19 @@
35673
35818
  try {
35674
35819
  const json = JSON.parse(content);
35675
35820
  const formattedJson = JSON.stringify(json, null, 4);
35676
- return `\`\`\`json\n${formattedJson}\n\`\`\``;
35821
+ return _spaceTrim.spaceTrim((block) => `
35822
+ \`\`\`json
35823
+ ${block(formattedJson)}
35824
+ \`\`\`
35825
+ `);
35677
35826
  }
35678
35827
  catch (error) {
35679
35828
  // If JSON is invalid, still import it but maybe not as pretty JSON
35680
- return `\`\`\`json\n${content}\n\`\`\``;
35829
+ return _spaceTrim.spaceTrim((block) => `
35830
+ \`\`\`json
35831
+ ${block(content)}
35832
+ \`\`\`
35833
+ `);
35681
35834
  }
35682
35835
  },
35683
35836
  };
@@ -35701,7 +35854,11 @@
35701
35854
  import(content, mimeType) {
35702
35855
  const extension = mimeTypeToExtension(mimeType);
35703
35856
  const codeBlockType = extension || 'txt';
35704
- return `\`\`\`${codeBlockType}\n${content}\n\`\`\``;
35857
+ return _spaceTrim.spaceTrim((block) => `
35858
+ \`\`\`${codeBlockType}
35859
+ ${block(content)}
35860
+ \`\`\`
35861
+ `);
35705
35862
  },
35706
35863
  };
35707
35864
 
@@ -35948,11 +36105,19 @@
35948
36105
  const examples = [];
35949
36106
  const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
35950
36107
  if (initialMessage) {
35951
- examples.push(`**Agent:**\n${initialMessage}`);
36108
+ examples.push(_spaceTrim.spaceTrim((block) => `
36109
+ **Agent:**
36110
+ ${block(initialMessage)}
36111
+ `));
35952
36112
  }
35953
36113
  if (samples && samples.length > 0) {
35954
36114
  for (const sample of samples) {
35955
- examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
36115
+ examples.push(_spaceTrim.spaceTrim((block) => `
36116
+ **User:** ${block(String(sample.question))}
36117
+
36118
+ **Agent:**
36119
+ ${block(sample.answer)}
36120
+ `));
35956
36121
  }
35957
36122
  }
35958
36123
  return examples;
@@ -40477,7 +40642,12 @@
40477
40642
  * @private internal function of `$registeredLlmToolsMessage`
40478
40643
  */
40479
40644
  function createUsedEnvMessage() {
40480
- return $usedEnvFilename === null ? `Unknown \`.env\` file` : `Used \`.env\` file:\n${$usedEnvFilename}`;
40645
+ return $usedEnvFilename === null
40646
+ ? `Unknown \`.env\` file`
40647
+ : _spaceTrim.spaceTrim(`
40648
+ Used \`.env\` file:
40649
+ ${$usedEnvFilename}
40650
+ `);
40481
40651
  }
40482
40652
  // TODO: [®] DRY Register logic
40483
40653
  // TODO: [🧠][⚛] Maybe pass env as argument
@@ -50465,7 +50635,11 @@
50465
50635
  };
50466
50636
  }
50467
50637
  return {
50468
- content: `${content.slice(0, Math.max(0, maxCharacters))}\n\n[...truncated...]`,
50638
+ content: _spaceTrim.spaceTrim((block) => `
50639
+ ${block(content.slice(0, Math.max(0, maxCharacters)))}
50640
+
50641
+ [...truncated...]
50642
+ `),
50469
50643
  isTruncated: true,
50470
50644
  };
50471
50645
  }