@promptbook/remote-server 0.112.0-126 → 0.112.0-128

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 +221 -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 +221 -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
@@ -53,7 +53,7 @@
53
53
  * @generated
54
54
  * @see https://github.com/webgptorg/promptbook
55
55
  */
56
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-126';
56
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-128';
57
57
  /**
58
58
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
59
59
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -9272,7 +9272,8 @@
9272
9272
  * @private internal function of `$registeredLlmToolsMessage`
9273
9273
  */
9274
9274
  function createUsedEnvMessage() {
9275
- return `Unknown \`.env\` file` ;
9275
+ return `Unknown \`.env\` file`
9276
+ ;
9276
9277
  }
9277
9278
  // TODO: [®] DRY Register logic
9278
9279
  // TODO: [🧠][⚛] Maybe pass env as argument
@@ -11263,8 +11264,11 @@
11263
11264
  if (!trimmedContent) {
11264
11265
  return requirements;
11265
11266
  }
11266
- // Add goal as a proper h2 section to the system message
11267
- const goalSection = `## Goal\n\n${trimmedContent}`;
11267
+ const goalSection = _spaceTrim.spaceTrim((block) => `
11268
+ ## Goal
11269
+
11270
+ ${block(trimmedContent)}
11271
+ `);
11268
11272
  const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
11269
11273
  return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
11270
11274
  }
@@ -11786,8 +11790,11 @@
11786
11790
  if (!trimmedContent) {
11787
11791
  return requirements;
11788
11792
  }
11789
- // Add language as a bullet under a ## Language section
11790
- const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
11793
+ const languageSection = _spaceTrim.spaceTrim((block) => `
11794
+ ## Language
11795
+
11796
+ - Your language is ${block(trimmedContent)}
11797
+ `);
11791
11798
  return this.appendToSystemMessage(requirements, languageSection, '\n\n');
11792
11799
  }
11793
11800
  }
@@ -16752,41 +16759,91 @@
16752
16759
  context.fill();
16753
16760
  context.restore();
16754
16761
  }
16762
+ /**
16763
+ * Number of latitude segments used by the single blobby octopus mesh.
16764
+ *
16765
+ * @private helper of `octopus3d2AvatarVisual`
16766
+ */
16767
+ const LATITUDE_PATCH_COUNT$1 = 12;
16768
+ /**
16769
+ * Number of longitude segments used by the single blobby octopus mesh.
16770
+ *
16771
+ * @private helper of `octopus3d2AvatarVisual`
16772
+ */
16773
+ const LONGITUDE_PATCH_COUNT$1 = 24;
16755
16774
  /**
16756
16775
  * Resolves all visible projected patches for the single blobby octopus mesh.
16757
16776
  *
16777
+ * Within a single frame, mesh corner samples and longitude-only lobe-wave values are
16778
+ * quantized to the patch grid and computed once each rather than re-evaluated for every
16779
+ * patch corner — the patch loop alone would call `sampleBlobbyOctopusSurfacePoint`
16780
+ * `latitudePatchCount * longitudePatchCount * 4` times without caching, even though most
16781
+ * corners are shared between neighboring patches.
16782
+ *
16758
16783
  * @private helper of `octopus3d2AvatarVisual`
16759
16784
  */
16760
16785
  function resolveVisibleBlobbyOctopusPatches(options) {
16761
16786
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, animationPhase, timeMs, } = options;
16762
- const latitudePatchCount = 12;
16763
- const longitudePatchCount = 24;
16787
+ const latitudePatchCount = LATITUDE_PATCH_COUNT$1;
16788
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT$1;
16764
16789
  const surfacePatches = [];
16790
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
16791
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
16792
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
16793
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
16794
+ }
16795
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
16796
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
16797
+ }
16798
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
16799
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
16800
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveLowerLobeWave(longitudeBoundaries[boundaryIndex], morphologyProfile, animationPhase, timeMs);
16801
+ }
16802
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
16803
+ const transformedCornerSamples = new Array(cornerCount);
16804
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
16805
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
16806
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
16807
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
16808
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
16809
+ const cornerSample = sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
16810
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
16811
+ }
16812
+ }
16765
16813
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
16766
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
16767
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
16814
+ const startLatitude = latitudeBoundaries[latitudeIndex];
16815
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
16768
16816
  const centerLatitude = (startLatitude + endLatitude) / 2;
16769
16817
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
16818
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
16819
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
16770
16820
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
16771
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
16772
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
16821
+ const startLongitude = longitudeBoundaries[longitudeIndex];
16822
+ const endLongitude = longitudeBoundaries[longitudeIndex + 1];
16773
16823
  const centerLongitude = (startLongitude + endLongitude) / 2;
16774
- const localCorners = [
16775
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, startLongitude),
16776
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, endLongitude),
16777
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, endLongitude),
16778
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, startLongitude),
16824
+ const transformedCorners = [
16825
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
16826
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
16827
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
16828
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
16779
16829
  ];
16780
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
16781
16830
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
16782
16831
  if (surfaceNormal.z <= 0.01) {
16783
16832
  continue;
16784
16833
  }
16785
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
16834
+ const projectedCorners = [
16835
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
16836
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
16837
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
16838
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
16839
+ ];
16786
16840
  surfacePatches.push({
16787
16841
  corners: projectedCorners,
16788
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
16789
- transformedCorners.length,
16842
+ averageDepth: (transformedCorners[0].z +
16843
+ transformedCorners[1].z +
16844
+ transformedCorners[2].z +
16845
+ transformedCorners[3].z) /
16846
+ 4,
16790
16847
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
16791
16848
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
16792
16849
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
@@ -16804,12 +16861,21 @@
16804
16861
  * @private helper of `octopus3d2AvatarVisual`
16805
16862
  */
16806
16863
  function sampleBlobbyOctopusSurfacePoint(options, latitude, longitude) {
16864
+ const { morphologyProfile, animationPhase, timeMs } = options;
16865
+ return sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs));
16866
+ }
16867
+ /**
16868
+ * Samples one point on the continuous Octopus 3D 2 surface using a precomputed lower-lobe wave
16869
+ * to skip the per-call trig evaluation for `latitudePatchCount + 1` longitude-shared corners.
16870
+ *
16871
+ * @private helper of `octopus3d2AvatarVisual`
16872
+ */
16873
+ function sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, lowerLobeWave) {
16807
16874
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
16808
16875
  const cosineLatitude = Math.max(0, Math.cos(latitude));
16809
16876
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
16810
16877
  const upperBlend = Math.pow(1 - verticalProgress, 1.2);
16811
16878
  const lowerBlend = Math.pow(verticalProgress, 1.42);
16812
- const lowerLobeWave = resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs);
16813
16879
  const skirtEnvelope = Math.pow(cosineLatitude, 0.5) * lowerBlend;
16814
16880
  const horizontalScale = 1.02 +
16815
16881
  skirtEnvelope * (0.34 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.22 + lowerLobeWave * 0.22) -
@@ -17106,45 +17172,102 @@
17106
17172
  context.fill();
17107
17173
  context.restore();
17108
17174
  }
17175
+ /**
17176
+ * Number of latitude segments used by the continuous Octopus 3D 3 mesh.
17177
+ *
17178
+ * @private helper of `octopus3d3AvatarVisual`
17179
+ */
17180
+ const LATITUDE_PATCH_COUNT = 16;
17181
+ /**
17182
+ * Number of longitude segments used by the continuous Octopus 3D 3 mesh.
17183
+ *
17184
+ * @private helper of `octopus3d3AvatarVisual`
17185
+ */
17186
+ const LONGITUDE_PATCH_COUNT = 40;
17109
17187
  /**
17110
17188
  * Resolves visible projected patches for the continuous octopus mesh.
17111
17189
  *
17190
+ * Within a single frame, mesh corner samples and longitude-only computations (tentacle
17191
+ * influence and lobe wave) are quantized to the patch grid and computed once each rather
17192
+ * than re-evaluated for every patch corner — the patch loop alone calls `sampleContinuousOctopusSurfacePoint`
17193
+ * for `latitudePatchCount * longitudePatchCount * 4` corners without caching, and each call
17194
+ * triggers an inner 8-iteration `Math.exp` loop, which dominates the per-frame cost.
17195
+ *
17112
17196
  * @private helper of `octopus3d3AvatarVisual`
17113
17197
  */
17114
17198
  function resolveVisibleContinuousOctopusPatches(options) {
17115
17199
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
17116
- const latitudePatchCount = 16;
17117
- const longitudePatchCount = 40;
17200
+ const latitudePatchCount = LATITUDE_PATCH_COUNT;
17201
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT;
17118
17202
  const surfacePatches = [];
17203
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
17204
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
17205
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
17206
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
17207
+ }
17208
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
17209
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
17210
+ }
17211
+ const cachedTentacleInfluencesByCornerLongitude = new Array(longitudePatchCount + 1);
17212
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
17213
+ const cachedTentacleInfluencesByPatchCenterLongitude = new Array(longitudePatchCount);
17214
+ const cachedLobeWavesByPatchCenterLongitude = new Float64Array(longitudePatchCount);
17215
+ const cachedCosByPatchCenterLongitude = new Float64Array(longitudePatchCount);
17216
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
17217
+ const cornerLongitude = longitudeBoundaries[boundaryIndex];
17218
+ cachedTentacleInfluencesByCornerLongitude[boundaryIndex] = resolveContinuousTentacleInfluence(options, cornerLongitude);
17219
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveContinuousLobeWave(options, cornerLongitude);
17220
+ }
17221
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
17222
+ const patchCenterLongitude = (longitudeBoundaries[longitudeIndex] + longitudeBoundaries[longitudeIndex + 1]) / 2;
17223
+ cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex] = resolveContinuousTentacleInfluence(options, patchCenterLongitude);
17224
+ cachedLobeWavesByPatchCenterLongitude[longitudeIndex] = resolveContinuousLobeWave(options, patchCenterLongitude);
17225
+ cachedCosByPatchCenterLongitude[longitudeIndex] = Math.max(0, Math.cos(patchCenterLongitude));
17226
+ }
17227
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
17228
+ const transformedCornerSamples = new Array(cornerCount);
17229
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
17230
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
17231
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
17232
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
17233
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
17234
+ const cornerSample = sampleContinuousOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedTentacleInfluencesByCornerLongitude[longitudeBoundaryIndex], cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
17235
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
17236
+ }
17237
+ }
17119
17238
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
17120
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
17121
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
17239
+ const startLatitude = latitudeBoundaries[latitudeIndex];
17240
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
17122
17241
  const centerLatitude = (startLatitude + endLatitude) / 2;
17123
17242
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
17243
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
17244
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
17124
17245
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
17125
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
17126
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
17127
- const centerLongitude = (startLongitude + endLongitude) / 2;
17128
- const localCorners = [
17129
- sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
17130
- sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
17131
- sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
17132
- sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
17246
+ const transformedCorners = [
17247
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
17248
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
17249
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
17250
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
17133
17251
  ];
17134
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
17135
17252
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
17136
17253
  if (surfaceNormal.z <= 0.008) {
17137
17254
  continue;
17138
17255
  }
17139
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
17140
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
17141
- const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
17256
+ const projectedCorners = [
17257
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
17258
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
17259
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
17260
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
17261
+ ];
17142
17262
  surfacePatches.push({
17143
17263
  corners: projectedCorners,
17144
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
17145
- transformedCorners.length,
17264
+ averageDepth: (transformedCorners[0].z +
17265
+ transformedCorners[1].z +
17266
+ transformedCorners[2].z +
17267
+ transformedCorners[3].z) /
17268
+ 4,
17146
17269
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
17147
- fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
17270
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, cachedCosByPatchCenterLongitude[longitudeIndex], cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex].core, cachedLobeWavesByPatchCenterLongitude[longitudeIndex]),
17148
17271
  outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
17149
17272
  });
17150
17273
  }
@@ -17160,16 +17283,27 @@
17160
17283
  * @private helper of `octopus3d3AvatarVisual`
17161
17284
  */
17162
17285
  function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
17286
+ return sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveContinuousTentacleInfluence(options, longitude), resolveContinuousLobeWave(options, longitude));
17287
+ }
17288
+ /**
17289
+ * Samples one point on the continuous Octopus 3D 3 surface using precomputed longitude-only
17290
+ * values to skip the per-call `Math.exp` tentacle-influence loop and the lobe-wave trig call.
17291
+ *
17292
+ * The patch loop quantizes the mesh into a fixed `(latitudePatchCount + 1) * (longitudePatchCount + 1)`
17293
+ * corner grid, so the same longitude is reused across every latitude row and each
17294
+ * tentacle/lobe value can be computed once per frame instead of `latitudePatchCount * 4` times.
17295
+ *
17296
+ * @private helper of `octopus3d3AvatarVisual`
17297
+ */
17298
+ function sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, tentacleInfluence, lowerLobeWave) {
17163
17299
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
17164
17300
  const cosineLatitude = Math.max(0, Math.cos(latitude));
17165
17301
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
17166
17302
  const upperBlend = Math.pow(1 - verticalProgress, 1.28);
17167
17303
  const lowerBlend = smoothStep(0.38, 1, verticalProgress);
17168
17304
  const tipBlend = smoothStep(0.68, 1, verticalProgress);
17169
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
17170
17305
  const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
17171
17306
  const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
17172
- const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
17173
17307
  const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
17174
17308
  animationPhase * 0.6 +
17175
17309
  timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
@@ -20500,7 +20634,15 @@
20500
20634
  * Builds the teammate request text, optionally including context.
20501
20635
  */
20502
20636
  function buildTeammateRequest(message, context) {
20503
- return context ? `${message}\n\nContext:\n${context}` : message;
20637
+ if (!context) {
20638
+ return message;
20639
+ }
20640
+ return _spaceTrim.spaceTrim((block) => `
20641
+ ${block(message)}
20642
+
20643
+ Context:
20644
+ ${block(context)}
20645
+ `);
20504
20646
  }
20505
20647
  /**
20506
20648
  * Builds a minimal chat prompt for teammate calls.
@@ -24489,7 +24631,11 @@
24489
24631
  const lineRangedContent = applyOptionalLineRange(decodedContent, args.startLine, args.endLine);
24490
24632
  const wasCharacterTruncated = lineRangedContent.length > MAX_PROJECT_FILE_CONTENT_CHARACTERS;
24491
24633
  const contentToReturn = wasCharacterTruncated
24492
- ? `${lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS)}\n\n[...truncated...]`
24634
+ ? _spaceTrim.spaceTrim((block) => `
24635
+ ${block(lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS))}
24636
+
24637
+ [...truncated...]
24638
+ `)
24493
24639
  : lineRangedContent;
24494
24640
  const wasTruncated = decoded.isTruncated || wasCharacterTruncated;
24495
24641
  if (wasCharacterTruncated) {
@@ -33424,11 +33570,19 @@
33424
33570
  try {
33425
33571
  const json = JSON.parse(content);
33426
33572
  const formattedJson = JSON.stringify(json, null, 4);
33427
- return `\`\`\`json\n${formattedJson}\n\`\`\``;
33573
+ return _spaceTrim.spaceTrim((block) => `
33574
+ \`\`\`json
33575
+ ${block(formattedJson)}
33576
+ \`\`\`
33577
+ `);
33428
33578
  }
33429
33579
  catch (error) {
33430
33580
  // If JSON is invalid, still import it but maybe not as pretty JSON
33431
- return `\`\`\`json\n${content}\n\`\`\``;
33581
+ return _spaceTrim.spaceTrim((block) => `
33582
+ \`\`\`json
33583
+ ${block(content)}
33584
+ \`\`\`
33585
+ `);
33432
33586
  }
33433
33587
  },
33434
33588
  };
@@ -33452,7 +33606,11 @@
33452
33606
  import(content, mimeType) {
33453
33607
  const extension = mimeTypeToExtension(mimeType);
33454
33608
  const codeBlockType = extension || 'txt';
33455
- return `\`\`\`${codeBlockType}\n${content}\n\`\`\``;
33609
+ return _spaceTrim.spaceTrim((block) => `
33610
+ \`\`\`${codeBlockType}
33611
+ ${block(content)}
33612
+ \`\`\`
33613
+ `);
33456
33614
  },
33457
33615
  };
33458
33616
 
@@ -33699,11 +33857,19 @@
33699
33857
  const examples = [];
33700
33858
  const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
33701
33859
  if (initialMessage) {
33702
- examples.push(`**Agent:**\n${initialMessage}`);
33860
+ examples.push(_spaceTrim.spaceTrim((block) => `
33861
+ **Agent:**
33862
+ ${block(initialMessage)}
33863
+ `));
33703
33864
  }
33704
33865
  if (samples && samples.length > 0) {
33705
33866
  for (const sample of samples) {
33706
- examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
33867
+ examples.push(_spaceTrim.spaceTrim((block) => `
33868
+ **User:** ${block(String(sample.question))}
33869
+
33870
+ **Agent:**
33871
+ ${block(sample.answer)}
33872
+ `));
33707
33873
  }
33708
33874
  }
33709
33875
  return examples;
@@ -40331,7 +40497,11 @@
40331
40497
  };
40332
40498
  }
40333
40499
  return {
40334
- content: `${content.slice(0, Math.max(0, maxCharacters))}\n\n[...truncated...]`,
40500
+ content: _spaceTrim.spaceTrim((block) => `
40501
+ ${block(content.slice(0, Math.max(0, maxCharacters)))}
40502
+
40503
+ [...truncated...]
40504
+ `),
40335
40505
  isTruncated: true,
40336
40506
  };
40337
40507
  }