@promptbook/core 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 +226 -52
  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 +1 -1
  25. package/umd/index.umd.js +226 -52
  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
@@ -29,7 +29,7 @@
29
29
  * @generated
30
30
  * @see https://github.com/webgptorg/promptbook
31
31
  */
32
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-125';
32
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-127';
33
33
  /**
34
34
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
35
35
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10093,8 +10093,11 @@
10093
10093
  if (!trimmedContent) {
10094
10094
  return requirements;
10095
10095
  }
10096
- // Add goal as a proper h2 section to the system message
10097
- const goalSection = `## Goal\n\n${trimmedContent}`;
10096
+ const goalSection = spacetrim.spaceTrim((block) => `
10097
+ ## Goal
10098
+
10099
+ ${block(trimmedContent)}
10100
+ `);
10098
10101
  const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
10099
10102
  return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
10100
10103
  }
@@ -10616,8 +10619,11 @@
10616
10619
  if (!trimmedContent) {
10617
10620
  return requirements;
10618
10621
  }
10619
- // Add language as a bullet under a ## Language section
10620
- const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
10622
+ const languageSection = spacetrim.spaceTrim((block) => `
10623
+ ## Language
10624
+
10625
+ - Your language is ${block(trimmedContent)}
10626
+ `);
10621
10627
  return this.appendToSystemMessage(requirements, languageSection, '\n\n');
10622
10628
  }
10623
10629
  }
@@ -15563,41 +15569,91 @@
15563
15569
  context.fill();
15564
15570
  context.restore();
15565
15571
  }
15572
+ /**
15573
+ * Number of latitude segments used by the single blobby octopus mesh.
15574
+ *
15575
+ * @private helper of `octopus3d2AvatarVisual`
15576
+ */
15577
+ const LATITUDE_PATCH_COUNT$1 = 12;
15578
+ /**
15579
+ * Number of longitude segments used by the single blobby octopus mesh.
15580
+ *
15581
+ * @private helper of `octopus3d2AvatarVisual`
15582
+ */
15583
+ const LONGITUDE_PATCH_COUNT$1 = 24;
15566
15584
  /**
15567
15585
  * Resolves all visible projected patches for the single blobby octopus mesh.
15568
15586
  *
15587
+ * Within a single frame, mesh corner samples and longitude-only lobe-wave values are
15588
+ * quantized to the patch grid and computed once each rather than re-evaluated for every
15589
+ * patch corner — the patch loop alone would call `sampleBlobbyOctopusSurfacePoint`
15590
+ * `latitudePatchCount * longitudePatchCount * 4` times without caching, even though most
15591
+ * corners are shared between neighboring patches.
15592
+ *
15569
15593
  * @private helper of `octopus3d2AvatarVisual`
15570
15594
  */
15571
15595
  function resolveVisibleBlobbyOctopusPatches(options) {
15572
15596
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, animationPhase, timeMs, } = options;
15573
- const latitudePatchCount = 12;
15574
- const longitudePatchCount = 24;
15597
+ const latitudePatchCount = LATITUDE_PATCH_COUNT$1;
15598
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT$1;
15575
15599
  const surfacePatches = [];
15600
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
15601
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
15602
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
15603
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
15604
+ }
15605
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
15606
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
15607
+ }
15608
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
15609
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
15610
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveLowerLobeWave(longitudeBoundaries[boundaryIndex], morphologyProfile, animationPhase, timeMs);
15611
+ }
15612
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
15613
+ const transformedCornerSamples = new Array(cornerCount);
15614
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
15615
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
15616
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
15617
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
15618
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
15619
+ const cornerSample = sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
15620
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
15621
+ }
15622
+ }
15576
15623
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
15577
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
15578
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
15624
+ const startLatitude = latitudeBoundaries[latitudeIndex];
15625
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
15579
15626
  const centerLatitude = (startLatitude + endLatitude) / 2;
15580
15627
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
15628
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
15629
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
15581
15630
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
15582
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
15583
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
15631
+ const startLongitude = longitudeBoundaries[longitudeIndex];
15632
+ const endLongitude = longitudeBoundaries[longitudeIndex + 1];
15584
15633
  const centerLongitude = (startLongitude + endLongitude) / 2;
15585
- const localCorners = [
15586
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, startLongitude),
15587
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, endLongitude),
15588
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, endLongitude),
15589
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, startLongitude),
15634
+ const transformedCorners = [
15635
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
15636
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
15637
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
15638
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
15590
15639
  ];
15591
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
15592
15640
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
15593
15641
  if (surfaceNormal.z <= 0.01) {
15594
15642
  continue;
15595
15643
  }
15596
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
15644
+ const projectedCorners = [
15645
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
15646
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
15647
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
15648
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
15649
+ ];
15597
15650
  surfacePatches.push({
15598
15651
  corners: projectedCorners,
15599
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
15600
- transformedCorners.length,
15652
+ averageDepth: (transformedCorners[0].z +
15653
+ transformedCorners[1].z +
15654
+ transformedCorners[2].z +
15655
+ transformedCorners[3].z) /
15656
+ 4,
15601
15657
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
15602
15658
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
15603
15659
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
@@ -15615,12 +15671,21 @@
15615
15671
  * @private helper of `octopus3d2AvatarVisual`
15616
15672
  */
15617
15673
  function sampleBlobbyOctopusSurfacePoint(options, latitude, longitude) {
15674
+ const { morphologyProfile, animationPhase, timeMs } = options;
15675
+ return sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs));
15676
+ }
15677
+ /**
15678
+ * Samples one point on the continuous Octopus 3D 2 surface using a precomputed lower-lobe wave
15679
+ * to skip the per-call trig evaluation for `latitudePatchCount + 1` longitude-shared corners.
15680
+ *
15681
+ * @private helper of `octopus3d2AvatarVisual`
15682
+ */
15683
+ function sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, lowerLobeWave) {
15618
15684
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
15619
15685
  const cosineLatitude = Math.max(0, Math.cos(latitude));
15620
15686
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
15621
15687
  const upperBlend = Math.pow(1 - verticalProgress, 1.2);
15622
15688
  const lowerBlend = Math.pow(verticalProgress, 1.42);
15623
- const lowerLobeWave = resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs);
15624
15689
  const skirtEnvelope = Math.pow(cosineLatitude, 0.5) * lowerBlend;
15625
15690
  const horizontalScale = 1.02 +
15626
15691
  skirtEnvelope * (0.34 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.22 + lowerLobeWave * 0.22) -
@@ -15917,45 +15982,102 @@
15917
15982
  context.fill();
15918
15983
  context.restore();
15919
15984
  }
15985
+ /**
15986
+ * Number of latitude segments used by the continuous Octopus 3D 3 mesh.
15987
+ *
15988
+ * @private helper of `octopus3d3AvatarVisual`
15989
+ */
15990
+ const LATITUDE_PATCH_COUNT = 16;
15991
+ /**
15992
+ * Number of longitude segments used by the continuous Octopus 3D 3 mesh.
15993
+ *
15994
+ * @private helper of `octopus3d3AvatarVisual`
15995
+ */
15996
+ const LONGITUDE_PATCH_COUNT = 40;
15920
15997
  /**
15921
15998
  * Resolves visible projected patches for the continuous octopus mesh.
15922
15999
  *
16000
+ * Within a single frame, mesh corner samples and longitude-only computations (tentacle
16001
+ * influence and lobe wave) are quantized to the patch grid and computed once each rather
16002
+ * than re-evaluated for every patch corner — the patch loop alone calls `sampleContinuousOctopusSurfacePoint`
16003
+ * for `latitudePatchCount * longitudePatchCount * 4` corners without caching, and each call
16004
+ * triggers an inner 8-iteration `Math.exp` loop, which dominates the per-frame cost.
16005
+ *
15923
16006
  * @private helper of `octopus3d3AvatarVisual`
15924
16007
  */
15925
16008
  function resolveVisibleContinuousOctopusPatches(options) {
15926
16009
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
15927
- const latitudePatchCount = 16;
15928
- const longitudePatchCount = 40;
16010
+ const latitudePatchCount = LATITUDE_PATCH_COUNT;
16011
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT;
15929
16012
  const surfacePatches = [];
16013
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
16014
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
16015
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
16016
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
16017
+ }
16018
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
16019
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
16020
+ }
16021
+ const cachedTentacleInfluencesByCornerLongitude = new Array(longitudePatchCount + 1);
16022
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
16023
+ const cachedTentacleInfluencesByPatchCenterLongitude = new Array(longitudePatchCount);
16024
+ const cachedLobeWavesByPatchCenterLongitude = new Float64Array(longitudePatchCount);
16025
+ const cachedCosByPatchCenterLongitude = new Float64Array(longitudePatchCount);
16026
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
16027
+ const cornerLongitude = longitudeBoundaries[boundaryIndex];
16028
+ cachedTentacleInfluencesByCornerLongitude[boundaryIndex] = resolveContinuousTentacleInfluence(options, cornerLongitude);
16029
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveContinuousLobeWave(options, cornerLongitude);
16030
+ }
16031
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
16032
+ const patchCenterLongitude = (longitudeBoundaries[longitudeIndex] + longitudeBoundaries[longitudeIndex + 1]) / 2;
16033
+ cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex] = resolveContinuousTentacleInfluence(options, patchCenterLongitude);
16034
+ cachedLobeWavesByPatchCenterLongitude[longitudeIndex] = resolveContinuousLobeWave(options, patchCenterLongitude);
16035
+ cachedCosByPatchCenterLongitude[longitudeIndex] = Math.max(0, Math.cos(patchCenterLongitude));
16036
+ }
16037
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
16038
+ const transformedCornerSamples = new Array(cornerCount);
16039
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
16040
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
16041
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
16042
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
16043
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
16044
+ const cornerSample = sampleContinuousOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedTentacleInfluencesByCornerLongitude[longitudeBoundaryIndex], cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
16045
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
16046
+ }
16047
+ }
15930
16048
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
15931
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
15932
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
16049
+ const startLatitude = latitudeBoundaries[latitudeIndex];
16050
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
15933
16051
  const centerLatitude = (startLatitude + endLatitude) / 2;
15934
16052
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
16053
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
16054
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
15935
16055
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
15936
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
15937
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
15938
- const centerLongitude = (startLongitude + endLongitude) / 2;
15939
- const localCorners = [
15940
- sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
15941
- sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
15942
- sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
15943
- sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
16056
+ const transformedCorners = [
16057
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
16058
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
16059
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
16060
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
15944
16061
  ];
15945
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
15946
16062
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
15947
16063
  if (surfaceNormal.z <= 0.008) {
15948
16064
  continue;
15949
16065
  }
15950
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
15951
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
15952
- const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
16066
+ const projectedCorners = [
16067
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
16068
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
16069
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
16070
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
16071
+ ];
15953
16072
  surfacePatches.push({
15954
16073
  corners: projectedCorners,
15955
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
15956
- transformedCorners.length,
16074
+ averageDepth: (transformedCorners[0].z +
16075
+ transformedCorners[1].z +
16076
+ transformedCorners[2].z +
16077
+ transformedCorners[3].z) /
16078
+ 4,
15957
16079
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
15958
- fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
16080
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, cachedCosByPatchCenterLongitude[longitudeIndex], cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex].core, cachedLobeWavesByPatchCenterLongitude[longitudeIndex]),
15959
16081
  outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
15960
16082
  });
15961
16083
  }
@@ -15971,16 +16093,27 @@
15971
16093
  * @private helper of `octopus3d3AvatarVisual`
15972
16094
  */
15973
16095
  function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
16096
+ return sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveContinuousTentacleInfluence(options, longitude), resolveContinuousLobeWave(options, longitude));
16097
+ }
16098
+ /**
16099
+ * Samples one point on the continuous Octopus 3D 3 surface using precomputed longitude-only
16100
+ * values to skip the per-call `Math.exp` tentacle-influence loop and the lobe-wave trig call.
16101
+ *
16102
+ * The patch loop quantizes the mesh into a fixed `(latitudePatchCount + 1) * (longitudePatchCount + 1)`
16103
+ * corner grid, so the same longitude is reused across every latitude row and each
16104
+ * tentacle/lobe value can be computed once per frame instead of `latitudePatchCount * 4` times.
16105
+ *
16106
+ * @private helper of `octopus3d3AvatarVisual`
16107
+ */
16108
+ function sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, tentacleInfluence, lowerLobeWave) {
15974
16109
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
15975
16110
  const cosineLatitude = Math.max(0, Math.cos(latitude));
15976
16111
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
15977
16112
  const upperBlend = Math.pow(1 - verticalProgress, 1.28);
15978
16113
  const lowerBlend = smoothStep(0.38, 1, verticalProgress);
15979
16114
  const tipBlend = smoothStep(0.68, 1, verticalProgress);
15980
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
15981
16115
  const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
15982
16116
  const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
15983
- const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
15984
16117
  const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
15985
16118
  animationPhase * 0.6 +
15986
16119
  timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
@@ -19311,7 +19444,15 @@
19311
19444
  * Builds the teammate request text, optionally including context.
19312
19445
  */
19313
19446
  function buildTeammateRequest(message, context) {
19314
- return context ? `${message}\n\nContext:\n${context}` : message;
19447
+ if (!context) {
19448
+ return message;
19449
+ }
19450
+ return spacetrim.spaceTrim((block) => `
19451
+ ${block(message)}
19452
+
19453
+ Context:
19454
+ ${block(context)}
19455
+ `);
19315
19456
  }
19316
19457
  /**
19317
19458
  * Builds a minimal chat prompt for teammate calls.
@@ -23137,7 +23278,11 @@
23137
23278
  const lineRangedContent = applyOptionalLineRange(decodedContent, args.startLine, args.endLine);
23138
23279
  const wasCharacterTruncated = lineRangedContent.length > MAX_PROJECT_FILE_CONTENT_CHARACTERS;
23139
23280
  const contentToReturn = wasCharacterTruncated
23140
- ? `${lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS)}\n\n[...truncated...]`
23281
+ ? spacetrim.spaceTrim((block) => `
23282
+ ${block(lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS))}
23283
+
23284
+ [...truncated...]
23285
+ `)
23141
23286
  : lineRangedContent;
23142
23287
  const wasTruncated = decoded.isTruncated || wasCharacterTruncated;
23143
23288
  if (wasCharacterTruncated) {
@@ -26673,11 +26818,19 @@
26673
26818
  try {
26674
26819
  const json = JSON.parse(content);
26675
26820
  const formattedJson = JSON.stringify(json, null, 4);
26676
- return `\`\`\`json\n${formattedJson}\n\`\`\``;
26821
+ return spacetrim.spaceTrim((block) => `
26822
+ \`\`\`json
26823
+ ${block(formattedJson)}
26824
+ \`\`\`
26825
+ `);
26677
26826
  }
26678
26827
  catch (error) {
26679
26828
  // If JSON is invalid, still import it but maybe not as pretty JSON
26680
- return `\`\`\`json\n${content}\n\`\`\``;
26829
+ return spacetrim.spaceTrim((block) => `
26830
+ \`\`\`json
26831
+ ${block(content)}
26832
+ \`\`\`
26833
+ `);
26681
26834
  }
26682
26835
  },
26683
26836
  };
@@ -26701,7 +26854,11 @@
26701
26854
  import(content, mimeType) {
26702
26855
  const extension = mimeTypeToExtension(mimeType);
26703
26856
  const codeBlockType = extension || 'txt';
26704
- return `\`\`\`${codeBlockType}\n${content}\n\`\`\``;
26857
+ return spacetrim.spaceTrim((block) => `
26858
+ \`\`\`${codeBlockType}
26859
+ ${block(content)}
26860
+ \`\`\`
26861
+ `);
26705
26862
  },
26706
26863
  };
26707
26864
 
@@ -26948,11 +27105,19 @@
26948
27105
  const examples = [];
26949
27106
  const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
26950
27107
  if (initialMessage) {
26951
- examples.push(`**Agent:**\n${initialMessage}`);
27108
+ examples.push(spacetrim.spaceTrim((block) => `
27109
+ **Agent:**
27110
+ ${block(initialMessage)}
27111
+ `));
26952
27112
  }
26953
27113
  if (samples && samples.length > 0) {
26954
27114
  for (const sample of samples) {
26955
- examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
27115
+ examples.push(spacetrim.spaceTrim((block) => `
27116
+ **User:** ${block(String(sample.question))}
27117
+
27118
+ **Agent:**
27119
+ ${block(sample.answer)}
27120
+ `));
26956
27121
  }
26957
27122
  }
26958
27123
  return examples;
@@ -28667,7 +28832,11 @@
28667
28832
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
28668
28833
  */
28669
28834
  function renderDocumentationSection(title, documentation) {
28670
- return `#### ${title}\n\n${removeLeadingTopLevelHeading(documentation)}`;
28835
+ return spacetrim.spaceTrim((block) => `
28836
+ #### ${title}
28837
+
28838
+ ${block(removeLeadingTopLevelHeading(documentation))}
28839
+ `);
28671
28840
  }
28672
28841
  /**
28673
28842
  * Renders the documentation body for one grouped commitment entry.
@@ -35136,7 +35305,8 @@
35136
35305
  * @private internal function of `$registeredLlmToolsMessage`
35137
35306
  */
35138
35307
  function createUsedEnvMessage() {
35139
- return `Unknown \`.env\` file` ;
35308
+ return `Unknown \`.env\` file`
35309
+ ;
35140
35310
  }
35141
35311
  // TODO: [®] DRY Register logic
35142
35312
  // TODO: [🧠][⚛] Maybe pass env as argument
@@ -41824,7 +41994,11 @@
41824
41994
  };
41825
41995
  }
41826
41996
  return {
41827
- content: `${content.slice(0, Math.max(0, maxCharacters))}\n\n[...truncated...]`,
41997
+ content: spacetrim.spaceTrim((block) => `
41998
+ ${block(content.slice(0, Math.max(0, maxCharacters)))}
41999
+
42000
+ [...truncated...]
42001
+ `),
41828
42002
  isTruncated: true,
41829
42003
  };
41830
42004
  }