@promptbook/core 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 +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/README.md CHANGED
@@ -686,7 +686,7 @@ Prompts marked with `[-]` are not ready yet, prompts containing `@@@` are treate
686
686
  - **Multi-runner execution:** `openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`
687
687
  - **Context injection:** `--agent agents/coding/developer.book --context AGENTS.md` or inline extra instructions
688
688
  - **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners
689
- - **Interactive or unattended runs:** default wait mode, or `--no-wait` for batch execution
689
+ - **Unattended or interactive runs:** default auto mode, or `--no-auto` to wait for user confirmation before each prompt
690
690
  - **Git safety:** clean working tree check by default, optional `--ignore-git-changes`
691
691
  - **Opt-in remote pushes:** commits stay local unless you explicitly pass `--auto-push`
692
692
  - **Prompt triage:** `--priority` to process only more important tasks first
@@ -708,7 +708,7 @@ npx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gp
708
708
 
709
709
  npx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --auto-push
710
710
 
711
- npx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --ignore-git-changes --no-wait
711
+ npx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --ignore-git-changes
712
712
 
713
713
  npx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates
714
714
 
@@ -734,7 +734,7 @@ ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh -
734
734
 
735
735
  ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --auto-push
736
736
 
737
- ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --test npm run test --ignore-git-changes --no-wait
737
+ ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --test npm run test --ignore-git-changes
738
738
 
739
739
  ptbk coder find-refactor-candidates
740
740
 
@@ -764,7 +764,7 @@ ptbk coder verify
764
764
  | `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
765
765
  | `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
766
766
  | `--thinking-level <level>` | Sets reasoning effort for supported runners. |
767
- | `--no-wait` | Skips interactive pauses between prompts for unattended execution. |
767
+ | `--no-auto` | Waits for user confirmation before each prompt instead of running automatically through the queue. |
768
768
  | `--ignore-git-changes` | Disables the clean-working-tree guard. |
769
769
  | `--priority <n>` | Runs only prompts at or above the given priority. |
770
770
  | `--dry-run` | Prints which prompts are ready instead of executing them. |
@@ -777,7 +777,7 @@ ptbk coder verify
777
777
  1. Initialize once with `ptbk coder init`.
778
778
  2. Customize `prompts/templates/*.md` if needed, then create or write prompt files in `prompts/`.
779
779
  3. Customize the starter `AGENTS.md` with repository-specific instructions, then pass `--agent agents/coding/developer.book --context AGENTS.md`.
780
- 4. Run one prompt at a time interactively, or use `--no-wait` for unattended batches.
780
+ 4. Run unattended batches by default, or pass `--no-auto` to confirm each prompt interactively.
781
781
  5. Finish with `ptbk coder verify` so resolved prompts are archived and broken ones get explicit repair follow-ups.
782
782
 
783
783
 
package/esm/index.es.js CHANGED
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-126';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-127';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10092,8 +10092,11 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
10092
10092
  if (!trimmedContent) {
10093
10093
  return requirements;
10094
10094
  }
10095
- // Add goal as a proper h2 section to the system message
10096
- const goalSection = `## Goal\n\n${trimmedContent}`;
10095
+ const goalSection = spaceTrim$1((block) => `
10096
+ ## Goal
10097
+
10098
+ ${block(trimmedContent)}
10099
+ `);
10097
10100
  const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
10098
10101
  return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
10099
10102
  }
@@ -10615,8 +10618,11 @@ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
10615
10618
  if (!trimmedContent) {
10616
10619
  return requirements;
10617
10620
  }
10618
- // Add language as a bullet under a ## Language section
10619
- const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
10621
+ const languageSection = spaceTrim$1((block) => `
10622
+ ## Language
10623
+
10624
+ - Your language is ${block(trimmedContent)}
10625
+ `);
10620
10626
  return this.appendToSystemMessage(requirements, languageSection, '\n\n');
10621
10627
  }
10622
10628
  }
@@ -15562,41 +15568,91 @@ function drawBlobbyOctopusShadow(context, size, palette, interaction, timeMs, mo
15562
15568
  context.fill();
15563
15569
  context.restore();
15564
15570
  }
15571
+ /**
15572
+ * Number of latitude segments used by the single blobby octopus mesh.
15573
+ *
15574
+ * @private helper of `octopus3d2AvatarVisual`
15575
+ */
15576
+ const LATITUDE_PATCH_COUNT$1 = 12;
15577
+ /**
15578
+ * Number of longitude segments used by the single blobby octopus mesh.
15579
+ *
15580
+ * @private helper of `octopus3d2AvatarVisual`
15581
+ */
15582
+ const LONGITUDE_PATCH_COUNT$1 = 24;
15565
15583
  /**
15566
15584
  * Resolves all visible projected patches for the single blobby octopus mesh.
15567
15585
  *
15586
+ * Within a single frame, mesh corner samples and longitude-only lobe-wave values are
15587
+ * quantized to the patch grid and computed once each rather than re-evaluated for every
15588
+ * patch corner — the patch loop alone would call `sampleBlobbyOctopusSurfacePoint`
15589
+ * `latitudePatchCount * longitudePatchCount * 4` times without caching, even though most
15590
+ * corners are shared between neighboring patches.
15591
+ *
15568
15592
  * @private helper of `octopus3d2AvatarVisual`
15569
15593
  */
15570
15594
  function resolveVisibleBlobbyOctopusPatches(options) {
15571
15595
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, animationPhase, timeMs, } = options;
15572
- const latitudePatchCount = 12;
15573
- const longitudePatchCount = 24;
15596
+ const latitudePatchCount = LATITUDE_PATCH_COUNT$1;
15597
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT$1;
15574
15598
  const surfacePatches = [];
15599
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
15600
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
15601
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
15602
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
15603
+ }
15604
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
15605
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
15606
+ }
15607
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
15608
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
15609
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveLowerLobeWave(longitudeBoundaries[boundaryIndex], morphologyProfile, animationPhase, timeMs);
15610
+ }
15611
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
15612
+ const transformedCornerSamples = new Array(cornerCount);
15613
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
15614
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
15615
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
15616
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
15617
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
15618
+ const cornerSample = sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
15619
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
15620
+ }
15621
+ }
15575
15622
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
15576
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
15577
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
15623
+ const startLatitude = latitudeBoundaries[latitudeIndex];
15624
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
15578
15625
  const centerLatitude = (startLatitude + endLatitude) / 2;
15579
15626
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
15627
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
15628
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
15580
15629
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
15581
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
15582
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
15630
+ const startLongitude = longitudeBoundaries[longitudeIndex];
15631
+ const endLongitude = longitudeBoundaries[longitudeIndex + 1];
15583
15632
  const centerLongitude = (startLongitude + endLongitude) / 2;
15584
- const localCorners = [
15585
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, startLongitude),
15586
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, endLongitude),
15587
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, endLongitude),
15588
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, startLongitude),
15633
+ const transformedCorners = [
15634
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
15635
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
15636
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
15637
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
15589
15638
  ];
15590
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
15591
15639
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
15592
15640
  if (surfaceNormal.z <= 0.01) {
15593
15641
  continue;
15594
15642
  }
15595
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
15643
+ const projectedCorners = [
15644
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
15645
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
15646
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
15647
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
15648
+ ];
15596
15649
  surfacePatches.push({
15597
15650
  corners: projectedCorners,
15598
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
15599
- transformedCorners.length,
15651
+ averageDepth: (transformedCorners[0].z +
15652
+ transformedCorners[1].z +
15653
+ transformedCorners[2].z +
15654
+ transformedCorners[3].z) /
15655
+ 4,
15600
15656
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
15601
15657
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
15602
15658
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
@@ -15614,12 +15670,21 @@ function resolveVisibleBlobbyOctopusPatches(options) {
15614
15670
  * @private helper of `octopus3d2AvatarVisual`
15615
15671
  */
15616
15672
  function sampleBlobbyOctopusSurfacePoint(options, latitude, longitude) {
15673
+ const { morphologyProfile, animationPhase, timeMs } = options;
15674
+ return sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs));
15675
+ }
15676
+ /**
15677
+ * Samples one point on the continuous Octopus 3D 2 surface using a precomputed lower-lobe wave
15678
+ * to skip the per-call trig evaluation for `latitudePatchCount + 1` longitude-shared corners.
15679
+ *
15680
+ * @private helper of `octopus3d2AvatarVisual`
15681
+ */
15682
+ function sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, lowerLobeWave) {
15617
15683
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
15618
15684
  const cosineLatitude = Math.max(0, Math.cos(latitude));
15619
15685
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
15620
15686
  const upperBlend = Math.pow(1 - verticalProgress, 1.2);
15621
15687
  const lowerBlend = Math.pow(verticalProgress, 1.42);
15622
- const lowerLobeWave = resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs);
15623
15688
  const skirtEnvelope = Math.pow(cosineLatitude, 0.5) * lowerBlend;
15624
15689
  const horizontalScale = 1.02 +
15625
15690
  skirtEnvelope * (0.34 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.22 + lowerLobeWave * 0.22) -
@@ -15916,45 +15981,102 @@ function drawContinuousOctopusShadow(context, size, palette, interaction, timeMs
15916
15981
  context.fill();
15917
15982
  context.restore();
15918
15983
  }
15984
+ /**
15985
+ * Number of latitude segments used by the continuous Octopus 3D 3 mesh.
15986
+ *
15987
+ * @private helper of `octopus3d3AvatarVisual`
15988
+ */
15989
+ const LATITUDE_PATCH_COUNT = 16;
15990
+ /**
15991
+ * Number of longitude segments used by the continuous Octopus 3D 3 mesh.
15992
+ *
15993
+ * @private helper of `octopus3d3AvatarVisual`
15994
+ */
15995
+ const LONGITUDE_PATCH_COUNT = 40;
15919
15996
  /**
15920
15997
  * Resolves visible projected patches for the continuous octopus mesh.
15921
15998
  *
15999
+ * Within a single frame, mesh corner samples and longitude-only computations (tentacle
16000
+ * influence and lobe wave) are quantized to the patch grid and computed once each rather
16001
+ * than re-evaluated for every patch corner — the patch loop alone calls `sampleContinuousOctopusSurfacePoint`
16002
+ * for `latitudePatchCount * longitudePatchCount * 4` corners without caching, and each call
16003
+ * triggers an inner 8-iteration `Math.exp` loop, which dominates the per-frame cost.
16004
+ *
15922
16005
  * @private helper of `octopus3d3AvatarVisual`
15923
16006
  */
15924
16007
  function resolveVisibleContinuousOctopusPatches(options) {
15925
16008
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
15926
- const latitudePatchCount = 16;
15927
- const longitudePatchCount = 40;
16009
+ const latitudePatchCount = LATITUDE_PATCH_COUNT;
16010
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT;
15928
16011
  const surfacePatches = [];
16012
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
16013
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
16014
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
16015
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
16016
+ }
16017
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
16018
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
16019
+ }
16020
+ const cachedTentacleInfluencesByCornerLongitude = new Array(longitudePatchCount + 1);
16021
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
16022
+ const cachedTentacleInfluencesByPatchCenterLongitude = new Array(longitudePatchCount);
16023
+ const cachedLobeWavesByPatchCenterLongitude = new Float64Array(longitudePatchCount);
16024
+ const cachedCosByPatchCenterLongitude = new Float64Array(longitudePatchCount);
16025
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
16026
+ const cornerLongitude = longitudeBoundaries[boundaryIndex];
16027
+ cachedTentacleInfluencesByCornerLongitude[boundaryIndex] = resolveContinuousTentacleInfluence(options, cornerLongitude);
16028
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveContinuousLobeWave(options, cornerLongitude);
16029
+ }
16030
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
16031
+ const patchCenterLongitude = (longitudeBoundaries[longitudeIndex] + longitudeBoundaries[longitudeIndex + 1]) / 2;
16032
+ cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex] = resolveContinuousTentacleInfluence(options, patchCenterLongitude);
16033
+ cachedLobeWavesByPatchCenterLongitude[longitudeIndex] = resolveContinuousLobeWave(options, patchCenterLongitude);
16034
+ cachedCosByPatchCenterLongitude[longitudeIndex] = Math.max(0, Math.cos(patchCenterLongitude));
16035
+ }
16036
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
16037
+ const transformedCornerSamples = new Array(cornerCount);
16038
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
16039
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
16040
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
16041
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
16042
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
16043
+ const cornerSample = sampleContinuousOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedTentacleInfluencesByCornerLongitude[longitudeBoundaryIndex], cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
16044
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
16045
+ }
16046
+ }
15929
16047
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
15930
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
15931
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
16048
+ const startLatitude = latitudeBoundaries[latitudeIndex];
16049
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
15932
16050
  const centerLatitude = (startLatitude + endLatitude) / 2;
15933
16051
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
16052
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
16053
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
15934
16054
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
15935
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
15936
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
15937
- const centerLongitude = (startLongitude + endLongitude) / 2;
15938
- const localCorners = [
15939
- sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
15940
- sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
15941
- sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
15942
- sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
16055
+ const transformedCorners = [
16056
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
16057
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
16058
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
16059
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
15943
16060
  ];
15944
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
15945
16061
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
15946
16062
  if (surfaceNormal.z <= 0.008) {
15947
16063
  continue;
15948
16064
  }
15949
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
15950
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
15951
- const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
16065
+ const projectedCorners = [
16066
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
16067
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
16068
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
16069
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
16070
+ ];
15952
16071
  surfacePatches.push({
15953
16072
  corners: projectedCorners,
15954
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
15955
- transformedCorners.length,
16073
+ averageDepth: (transformedCorners[0].z +
16074
+ transformedCorners[1].z +
16075
+ transformedCorners[2].z +
16076
+ transformedCorners[3].z) /
16077
+ 4,
15956
16078
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
15957
- fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
16079
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, cachedCosByPatchCenterLongitude[longitudeIndex], cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex].core, cachedLobeWavesByPatchCenterLongitude[longitudeIndex]),
15958
16080
  outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
15959
16081
  });
15960
16082
  }
@@ -15970,16 +16092,27 @@ function resolveVisibleContinuousOctopusPatches(options) {
15970
16092
  * @private helper of `octopus3d3AvatarVisual`
15971
16093
  */
15972
16094
  function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
16095
+ return sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveContinuousTentacleInfluence(options, longitude), resolveContinuousLobeWave(options, longitude));
16096
+ }
16097
+ /**
16098
+ * Samples one point on the continuous Octopus 3D 3 surface using precomputed longitude-only
16099
+ * values to skip the per-call `Math.exp` tentacle-influence loop and the lobe-wave trig call.
16100
+ *
16101
+ * The patch loop quantizes the mesh into a fixed `(latitudePatchCount + 1) * (longitudePatchCount + 1)`
16102
+ * corner grid, so the same longitude is reused across every latitude row and each
16103
+ * tentacle/lobe value can be computed once per frame instead of `latitudePatchCount * 4` times.
16104
+ *
16105
+ * @private helper of `octopus3d3AvatarVisual`
16106
+ */
16107
+ function sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, tentacleInfluence, lowerLobeWave) {
15973
16108
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
15974
16109
  const cosineLatitude = Math.max(0, Math.cos(latitude));
15975
16110
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
15976
16111
  const upperBlend = Math.pow(1 - verticalProgress, 1.28);
15977
16112
  const lowerBlend = smoothStep(0.38, 1, verticalProgress);
15978
16113
  const tipBlend = smoothStep(0.68, 1, verticalProgress);
15979
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
15980
16114
  const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
15981
16115
  const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
15982
- const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
15983
16116
  const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
15984
16117
  animationPhase * 0.6 +
15985
16118
  timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
@@ -19310,7 +19443,15 @@ function buildTeammateMetadata(entry) {
19310
19443
  * Builds the teammate request text, optionally including context.
19311
19444
  */
19312
19445
  function buildTeammateRequest(message, context) {
19313
- return context ? `${message}\n\nContext:\n${context}` : message;
19446
+ if (!context) {
19447
+ return message;
19448
+ }
19449
+ return spaceTrim$1((block) => `
19450
+ ${block(message)}
19451
+
19452
+ Context:
19453
+ ${block(context)}
19454
+ `);
19314
19455
  }
19315
19456
  /**
19316
19457
  * Builds a minimal chat prompt for teammate calls.
@@ -23136,7 +23277,11 @@ function createUseProjectToolFunctions() {
23136
23277
  const lineRangedContent = applyOptionalLineRange(decodedContent, args.startLine, args.endLine);
23137
23278
  const wasCharacterTruncated = lineRangedContent.length > MAX_PROJECT_FILE_CONTENT_CHARACTERS;
23138
23279
  const contentToReturn = wasCharacterTruncated
23139
- ? `${lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS)}\n\n[...truncated...]`
23280
+ ? spaceTrim$1((block) => `
23281
+ ${block(lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS))}
23282
+
23283
+ [...truncated...]
23284
+ `)
23140
23285
  : lineRangedContent;
23141
23286
  const wasTruncated = decoded.isTruncated || wasCharacterTruncated;
23142
23287
  if (wasCharacterTruncated) {
@@ -26672,11 +26817,19 @@ const JsonFileImportPlugin = {
26672
26817
  try {
26673
26818
  const json = JSON.parse(content);
26674
26819
  const formattedJson = JSON.stringify(json, null, 4);
26675
- return `\`\`\`json\n${formattedJson}\n\`\`\``;
26820
+ return spaceTrim$1((block) => `
26821
+ \`\`\`json
26822
+ ${block(formattedJson)}
26823
+ \`\`\`
26824
+ `);
26676
26825
  }
26677
26826
  catch (error) {
26678
26827
  // If JSON is invalid, still import it but maybe not as pretty JSON
26679
- return `\`\`\`json\n${content}\n\`\`\``;
26828
+ return spaceTrim$1((block) => `
26829
+ \`\`\`json
26830
+ ${block(content)}
26831
+ \`\`\`
26832
+ `);
26680
26833
  }
26681
26834
  },
26682
26835
  };
@@ -26700,7 +26853,11 @@ const TextFileImportPlugin = {
26700
26853
  import(content, mimeType) {
26701
26854
  const extension = mimeTypeToExtension(mimeType);
26702
26855
  const codeBlockType = extension || 'txt';
26703
- return `\`\`\`${codeBlockType}\n${content}\n\`\`\``;
26856
+ return spaceTrim$1((block) => `
26857
+ \`\`\`${codeBlockType}
26858
+ ${block(content)}
26859
+ \`\`\`
26860
+ `);
26704
26861
  },
26705
26862
  };
26706
26863
 
@@ -26947,11 +27104,19 @@ function collectExampleInteractionLines(parseResult, samples) {
26947
27104
  const examples = [];
26948
27105
  const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
26949
27106
  if (initialMessage) {
26950
- examples.push(`**Agent:**\n${initialMessage}`);
27107
+ examples.push(spaceTrim$1((block) => `
27108
+ **Agent:**
27109
+ ${block(initialMessage)}
27110
+ `));
26951
27111
  }
26952
27112
  if (samples && samples.length > 0) {
26953
27113
  for (const sample of samples) {
26954
- examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
27114
+ examples.push(spaceTrim$1((block) => `
27115
+ **User:** ${block(String(sample.question))}
27116
+
27117
+ **Agent:**
27118
+ ${block(sample.answer)}
27119
+ `));
26955
27120
  }
26956
27121
  }
26957
27122
  return examples;
@@ -28666,7 +28831,11 @@ function removeLeadingTopLevelHeading(markdown) {
28666
28831
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
28667
28832
  */
28668
28833
  function renderDocumentationSection(title, documentation) {
28669
- return `#### ${title}\n\n${removeLeadingTopLevelHeading(documentation)}`;
28834
+ return spaceTrim$1((block) => `
28835
+ #### ${title}
28836
+
28837
+ ${block(removeLeadingTopLevelHeading(documentation))}
28838
+ `);
28670
28839
  }
28671
28840
  /**
28672
28841
  * Renders the documentation body for one grouped commitment entry.
@@ -35135,7 +35304,8 @@ function colorizeAvailableProviderMessage(providerMessage, { isInstalled, isFull
35135
35304
  * @private internal function of `$registeredLlmToolsMessage`
35136
35305
  */
35137
35306
  function createUsedEnvMessage() {
35138
- return `Unknown \`.env\` file` ;
35307
+ return `Unknown \`.env\` file`
35308
+ ;
35139
35309
  }
35140
35310
  // TODO: [®] DRY Register logic
35141
35311
  // TODO: [🧠][⚛] Maybe pass env as argument
@@ -41823,7 +41993,11 @@ function truncateAttachmentInlineText(content, maxCharacters) {
41823
41993
  };
41824
41994
  }
41825
41995
  return {
41826
- content: `${content.slice(0, Math.max(0, maxCharacters))}\n\n[...truncated...]`,
41996
+ content: spaceTrim$1((block) => `
41997
+ ${block(content.slice(0, Math.max(0, maxCharacters)))}
41998
+
41999
+ [...truncated...]
42000
+ `),
41827
42001
  isTruncated: true,
41828
42002
  };
41829
42003
  }