@promptbook/browser 0.112.0-126 → 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 +219 -50
  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 +219 -50
  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-126';
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
@@ -2799,8 +2799,11 @@
2799
2799
  if (!trimmedContent) {
2800
2800
  return requirements;
2801
2801
  }
2802
- // Add goal as a proper h2 section to the system message
2803
- const goalSection = `## Goal\n\n${trimmedContent}`;
2802
+ const goalSection = spacetrim.spaceTrim((block) => `
2803
+ ## Goal
2804
+
2805
+ ${block(trimmedContent)}
2806
+ `);
2804
2807
  const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
2805
2808
  return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
2806
2809
  }
@@ -3694,8 +3697,11 @@
3694
3697
  if (!trimmedContent) {
3695
3698
  return requirements;
3696
3699
  }
3697
- // Add language as a bullet under a ## Language section
3698
- const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
3700
+ const languageSection = spacetrim.spaceTrim((block) => `
3701
+ ## Language
3702
+
3703
+ - Your language is ${block(trimmedContent)}
3704
+ `);
3699
3705
  return this.appendToSystemMessage(requirements, languageSection, '\n\n');
3700
3706
  }
3701
3707
  }
@@ -8660,41 +8666,91 @@
8660
8666
  context.fill();
8661
8667
  context.restore();
8662
8668
  }
8669
+ /**
8670
+ * Number of latitude segments used by the single blobby octopus mesh.
8671
+ *
8672
+ * @private helper of `octopus3d2AvatarVisual`
8673
+ */
8674
+ const LATITUDE_PATCH_COUNT$1 = 12;
8675
+ /**
8676
+ * Number of longitude segments used by the single blobby octopus mesh.
8677
+ *
8678
+ * @private helper of `octopus3d2AvatarVisual`
8679
+ */
8680
+ const LONGITUDE_PATCH_COUNT$1 = 24;
8663
8681
  /**
8664
8682
  * Resolves all visible projected patches for the single blobby octopus mesh.
8665
8683
  *
8684
+ * Within a single frame, mesh corner samples and longitude-only lobe-wave values are
8685
+ * quantized to the patch grid and computed once each rather than re-evaluated for every
8686
+ * patch corner — the patch loop alone would call `sampleBlobbyOctopusSurfacePoint`
8687
+ * `latitudePatchCount * longitudePatchCount * 4` times without caching, even though most
8688
+ * corners are shared between neighboring patches.
8689
+ *
8666
8690
  * @private helper of `octopus3d2AvatarVisual`
8667
8691
  */
8668
8692
  function resolveVisibleBlobbyOctopusPatches(options) {
8669
8693
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, animationPhase, timeMs, } = options;
8670
- const latitudePatchCount = 12;
8671
- const longitudePatchCount = 24;
8694
+ const latitudePatchCount = LATITUDE_PATCH_COUNT$1;
8695
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT$1;
8672
8696
  const surfacePatches = [];
8697
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
8698
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
8699
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
8700
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
8701
+ }
8702
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
8703
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
8704
+ }
8705
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
8706
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
8707
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveLowerLobeWave(longitudeBoundaries[boundaryIndex], morphologyProfile, animationPhase, timeMs);
8708
+ }
8709
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
8710
+ const transformedCornerSamples = new Array(cornerCount);
8711
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
8712
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
8713
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
8714
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
8715
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
8716
+ const cornerSample = sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
8717
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
8718
+ }
8719
+ }
8673
8720
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
8674
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
8675
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
8721
+ const startLatitude = latitudeBoundaries[latitudeIndex];
8722
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
8676
8723
  const centerLatitude = (startLatitude + endLatitude) / 2;
8677
8724
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
8725
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
8726
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
8678
8727
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
8679
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
8680
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
8728
+ const startLongitude = longitudeBoundaries[longitudeIndex];
8729
+ const endLongitude = longitudeBoundaries[longitudeIndex + 1];
8681
8730
  const centerLongitude = (startLongitude + endLongitude) / 2;
8682
- const localCorners = [
8683
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, startLongitude),
8684
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, endLongitude),
8685
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, endLongitude),
8686
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, startLongitude),
8731
+ const transformedCorners = [
8732
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
8733
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
8734
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
8735
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
8687
8736
  ];
8688
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
8689
8737
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
8690
8738
  if (surfaceNormal.z <= 0.01) {
8691
8739
  continue;
8692
8740
  }
8693
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
8741
+ const projectedCorners = [
8742
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
8743
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
8744
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
8745
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
8746
+ ];
8694
8747
  surfacePatches.push({
8695
8748
  corners: projectedCorners,
8696
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
8697
- transformedCorners.length,
8749
+ averageDepth: (transformedCorners[0].z +
8750
+ transformedCorners[1].z +
8751
+ transformedCorners[2].z +
8752
+ transformedCorners[3].z) /
8753
+ 4,
8698
8754
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
8699
8755
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
8700
8756
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
@@ -8712,12 +8768,21 @@
8712
8768
  * @private helper of `octopus3d2AvatarVisual`
8713
8769
  */
8714
8770
  function sampleBlobbyOctopusSurfacePoint(options, latitude, longitude) {
8771
+ const { morphologyProfile, animationPhase, timeMs } = options;
8772
+ return sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs));
8773
+ }
8774
+ /**
8775
+ * Samples one point on the continuous Octopus 3D 2 surface using a precomputed lower-lobe wave
8776
+ * to skip the per-call trig evaluation for `latitudePatchCount + 1` longitude-shared corners.
8777
+ *
8778
+ * @private helper of `octopus3d2AvatarVisual`
8779
+ */
8780
+ function sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, lowerLobeWave) {
8715
8781
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
8716
8782
  const cosineLatitude = Math.max(0, Math.cos(latitude));
8717
8783
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
8718
8784
  const upperBlend = Math.pow(1 - verticalProgress, 1.2);
8719
8785
  const lowerBlend = Math.pow(verticalProgress, 1.42);
8720
- const lowerLobeWave = resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs);
8721
8786
  const skirtEnvelope = Math.pow(cosineLatitude, 0.5) * lowerBlend;
8722
8787
  const horizontalScale = 1.02 +
8723
8788
  skirtEnvelope * (0.34 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.22 + lowerLobeWave * 0.22) -
@@ -9014,45 +9079,102 @@
9014
9079
  context.fill();
9015
9080
  context.restore();
9016
9081
  }
9082
+ /**
9083
+ * Number of latitude segments used by the continuous Octopus 3D 3 mesh.
9084
+ *
9085
+ * @private helper of `octopus3d3AvatarVisual`
9086
+ */
9087
+ const LATITUDE_PATCH_COUNT = 16;
9088
+ /**
9089
+ * Number of longitude segments used by the continuous Octopus 3D 3 mesh.
9090
+ *
9091
+ * @private helper of `octopus3d3AvatarVisual`
9092
+ */
9093
+ const LONGITUDE_PATCH_COUNT = 40;
9017
9094
  /**
9018
9095
  * Resolves visible projected patches for the continuous octopus mesh.
9019
9096
  *
9097
+ * Within a single frame, mesh corner samples and longitude-only computations (tentacle
9098
+ * influence and lobe wave) are quantized to the patch grid and computed once each rather
9099
+ * than re-evaluated for every patch corner — the patch loop alone calls `sampleContinuousOctopusSurfacePoint`
9100
+ * for `latitudePatchCount * longitudePatchCount * 4` corners without caching, and each call
9101
+ * triggers an inner 8-iteration `Math.exp` loop, which dominates the per-frame cost.
9102
+ *
9020
9103
  * @private helper of `octopus3d3AvatarVisual`
9021
9104
  */
9022
9105
  function resolveVisibleContinuousOctopusPatches(options) {
9023
9106
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
9024
- const latitudePatchCount = 16;
9025
- const longitudePatchCount = 40;
9107
+ const latitudePatchCount = LATITUDE_PATCH_COUNT;
9108
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT;
9026
9109
  const surfacePatches = [];
9110
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
9111
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
9112
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
9113
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
9114
+ }
9115
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
9116
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
9117
+ }
9118
+ const cachedTentacleInfluencesByCornerLongitude = new Array(longitudePatchCount + 1);
9119
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
9120
+ const cachedTentacleInfluencesByPatchCenterLongitude = new Array(longitudePatchCount);
9121
+ const cachedLobeWavesByPatchCenterLongitude = new Float64Array(longitudePatchCount);
9122
+ const cachedCosByPatchCenterLongitude = new Float64Array(longitudePatchCount);
9123
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
9124
+ const cornerLongitude = longitudeBoundaries[boundaryIndex];
9125
+ cachedTentacleInfluencesByCornerLongitude[boundaryIndex] = resolveContinuousTentacleInfluence(options, cornerLongitude);
9126
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveContinuousLobeWave(options, cornerLongitude);
9127
+ }
9128
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
9129
+ const patchCenterLongitude = (longitudeBoundaries[longitudeIndex] + longitudeBoundaries[longitudeIndex + 1]) / 2;
9130
+ cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex] = resolveContinuousTentacleInfluence(options, patchCenterLongitude);
9131
+ cachedLobeWavesByPatchCenterLongitude[longitudeIndex] = resolveContinuousLobeWave(options, patchCenterLongitude);
9132
+ cachedCosByPatchCenterLongitude[longitudeIndex] = Math.max(0, Math.cos(patchCenterLongitude));
9133
+ }
9134
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
9135
+ const transformedCornerSamples = new Array(cornerCount);
9136
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
9137
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
9138
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
9139
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
9140
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
9141
+ const cornerSample = sampleContinuousOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedTentacleInfluencesByCornerLongitude[longitudeBoundaryIndex], cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
9142
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
9143
+ }
9144
+ }
9027
9145
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
9028
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
9029
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
9146
+ const startLatitude = latitudeBoundaries[latitudeIndex];
9147
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
9030
9148
  const centerLatitude = (startLatitude + endLatitude) / 2;
9031
9149
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
9150
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
9151
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
9032
9152
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
9033
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
9034
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
9035
- const centerLongitude = (startLongitude + endLongitude) / 2;
9036
- const localCorners = [
9037
- sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
9038
- sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
9039
- sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
9040
- sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
9153
+ const transformedCorners = [
9154
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
9155
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
9156
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
9157
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
9041
9158
  ];
9042
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
9043
9159
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
9044
9160
  if (surfaceNormal.z <= 0.008) {
9045
9161
  continue;
9046
9162
  }
9047
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
9048
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
9049
- const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
9163
+ const projectedCorners = [
9164
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
9165
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
9166
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
9167
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
9168
+ ];
9050
9169
  surfacePatches.push({
9051
9170
  corners: projectedCorners,
9052
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
9053
- transformedCorners.length,
9171
+ averageDepth: (transformedCorners[0].z +
9172
+ transformedCorners[1].z +
9173
+ transformedCorners[2].z +
9174
+ transformedCorners[3].z) /
9175
+ 4,
9054
9176
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
9055
- fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
9177
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, cachedCosByPatchCenterLongitude[longitudeIndex], cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex].core, cachedLobeWavesByPatchCenterLongitude[longitudeIndex]),
9056
9178
  outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
9057
9179
  });
9058
9180
  }
@@ -9068,16 +9190,27 @@
9068
9190
  * @private helper of `octopus3d3AvatarVisual`
9069
9191
  */
9070
9192
  function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
9193
+ return sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveContinuousTentacleInfluence(options, longitude), resolveContinuousLobeWave(options, longitude));
9194
+ }
9195
+ /**
9196
+ * Samples one point on the continuous Octopus 3D 3 surface using precomputed longitude-only
9197
+ * values to skip the per-call `Math.exp` tentacle-influence loop and the lobe-wave trig call.
9198
+ *
9199
+ * The patch loop quantizes the mesh into a fixed `(latitudePatchCount + 1) * (longitudePatchCount + 1)`
9200
+ * corner grid, so the same longitude is reused across every latitude row and each
9201
+ * tentacle/lobe value can be computed once per frame instead of `latitudePatchCount * 4` times.
9202
+ *
9203
+ * @private helper of `octopus3d3AvatarVisual`
9204
+ */
9205
+ function sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, tentacleInfluence, lowerLobeWave) {
9071
9206
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
9072
9207
  const cosineLatitude = Math.max(0, Math.cos(latitude));
9073
9208
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
9074
9209
  const upperBlend = Math.pow(1 - verticalProgress, 1.28);
9075
9210
  const lowerBlend = smoothStep(0.38, 1, verticalProgress);
9076
9211
  const tipBlend = smoothStep(0.68, 1, verticalProgress);
9077
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
9078
9212
  const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
9079
9213
  const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
9080
- const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
9081
9214
  const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
9082
9215
  animationPhase * 0.6 +
9083
9216
  timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
@@ -12482,7 +12615,15 @@
12482
12615
  * Builds the teammate request text, optionally including context.
12483
12616
  */
12484
12617
  function buildTeammateRequest(message, context) {
12485
- return context ? `${message}\n\nContext:\n${context}` : message;
12618
+ if (!context) {
12619
+ return message;
12620
+ }
12621
+ return spacetrim.spaceTrim((block) => `
12622
+ ${block(message)}
12623
+
12624
+ Context:
12625
+ ${block(context)}
12626
+ `);
12486
12627
  }
12487
12628
  /**
12488
12629
  * Builds a minimal chat prompt for teammate calls.
@@ -16505,7 +16646,11 @@
16505
16646
  const lineRangedContent = applyOptionalLineRange(decodedContent, args.startLine, args.endLine);
16506
16647
  const wasCharacterTruncated = lineRangedContent.length > MAX_PROJECT_FILE_CONTENT_CHARACTERS;
16507
16648
  const contentToReturn = wasCharacterTruncated
16508
- ? `${lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS)}\n\n[...truncated...]`
16649
+ ? spacetrim.spaceTrim((block) => `
16650
+ ${block(lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS))}
16651
+
16652
+ [...truncated...]
16653
+ `)
16509
16654
  : lineRangedContent;
16510
16655
  const wasTruncated = decoded.isTruncated || wasCharacterTruncated;
16511
16656
  if (wasCharacterTruncated) {
@@ -28754,11 +28899,19 @@
28754
28899
  try {
28755
28900
  const json = JSON.parse(content);
28756
28901
  const formattedJson = JSON.stringify(json, null, 4);
28757
- return `\`\`\`json\n${formattedJson}\n\`\`\``;
28902
+ return spacetrim.spaceTrim((block) => `
28903
+ \`\`\`json
28904
+ ${block(formattedJson)}
28905
+ \`\`\`
28906
+ `);
28758
28907
  }
28759
28908
  catch (error) {
28760
28909
  // If JSON is invalid, still import it but maybe not as pretty JSON
28761
- return `\`\`\`json\n${content}\n\`\`\``;
28910
+ return spacetrim.spaceTrim((block) => `
28911
+ \`\`\`json
28912
+ ${block(content)}
28913
+ \`\`\`
28914
+ `);
28762
28915
  }
28763
28916
  },
28764
28917
  };
@@ -28782,7 +28935,11 @@
28782
28935
  import(content, mimeType) {
28783
28936
  const extension = mimeTypeToExtension(mimeType);
28784
28937
  const codeBlockType = extension || 'txt';
28785
- return `\`\`\`${codeBlockType}\n${content}\n\`\`\``;
28938
+ return spacetrim.spaceTrim((block) => `
28939
+ \`\`\`${codeBlockType}
28940
+ ${block(content)}
28941
+ \`\`\`
28942
+ `);
28786
28943
  },
28787
28944
  };
28788
28945
 
@@ -29029,11 +29186,19 @@
29029
29186
  const examples = [];
29030
29187
  const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
29031
29188
  if (initialMessage) {
29032
- examples.push(`**Agent:**\n${initialMessage}`);
29189
+ examples.push(spacetrim.spaceTrim((block) => `
29190
+ **Agent:**
29191
+ ${block(initialMessage)}
29192
+ `));
29033
29193
  }
29034
29194
  if (samples && samples.length > 0) {
29035
29195
  for (const sample of samples) {
29036
- examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
29196
+ examples.push(spacetrim.spaceTrim((block) => `
29197
+ **User:** ${block(String(sample.question))}
29198
+
29199
+ **Agent:**
29200
+ ${block(sample.answer)}
29201
+ `));
29037
29202
  }
29038
29203
  }
29039
29204
  return examples;
@@ -35728,7 +35893,11 @@
35728
35893
  };
35729
35894
  }
35730
35895
  return {
35731
- content: `${content.slice(0, Math.max(0, maxCharacters))}\n\n[...truncated...]`,
35896
+ content: spacetrim.spaceTrim((block) => `
35897
+ ${block(content.slice(0, Math.max(0, maxCharacters)))}
35898
+
35899
+ [...truncated...]
35900
+ `),
35732
35901
  isTruncated: true,
35733
35902
  };
35734
35903
  }