@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/README.md CHANGED
@@ -464,7 +464,7 @@ Prompts marked with `[-]` are not ready yet, prompts containing `@@@` are treate
464
464
  - **Multi-runner execution:** `openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`
465
465
  - **Context injection:** `--agent agents/coding/developer.book --context AGENTS.md` or inline extra instructions
466
466
  - **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners
467
- - **Interactive or unattended runs:** default wait mode, or `--no-wait` for batch execution
467
+ - **Unattended or interactive runs:** default auto mode, or `--no-auto` to wait for user confirmation before each prompt
468
468
  - **Git safety:** clean working tree check by default, optional `--ignore-git-changes`
469
469
  - **Opt-in remote pushes:** commits stay local unless you explicitly pass `--auto-push`
470
470
  - **Prompt triage:** `--priority` to process only more important tasks first
@@ -486,7 +486,7 @@ npx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gp
486
486
 
487
487
  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
488
488
 
489
- 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
489
+ 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
490
490
 
491
491
  npx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates
492
492
 
@@ -512,7 +512,7 @@ ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh -
512
512
 
513
513
  ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --context AGENTS.md --auto-push
514
514
 
515
- 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
515
+ 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
516
516
 
517
517
  ptbk coder find-refactor-candidates
518
518
 
@@ -542,7 +542,7 @@ ptbk coder verify
542
542
  | `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
543
543
  | `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
544
544
  | `--thinking-level <level>` | Sets reasoning effort for supported runners. |
545
- | `--no-wait` | Skips interactive pauses between prompts for unattended execution. |
545
+ | `--no-auto` | Waits for user confirmation before each prompt instead of running automatically through the queue. |
546
546
  | `--ignore-git-changes` | Disables the clean-working-tree guard. |
547
547
  | `--priority <n>` | Runs only prompts at or above the given priority. |
548
548
  | `--dry-run` | Prints which prompts are ready instead of executing them. |
@@ -555,7 +555,7 @@ ptbk coder verify
555
555
  1. Initialize once with `ptbk coder init`.
556
556
  2. Customize `prompts/templates/*.md` if needed, then create or write prompt files in `prompts/`.
557
557
  3. Customize the starter `AGENTS.md` with repository-specific instructions, then pass `--agent agents/coding/developer.book --context AGENTS.md`.
558
- 4. Run one prompt at a time interactively, or use `--no-wait` for unattended batches.
558
+ 4. Run unattended batches by default, or pass `--no-auto` to confirm each prompt interactively.
559
559
  5. Finish with `ptbk coder verify` so resolved prompts are archived and broken ones get explicit repair follow-ups.
560
560
 
561
561
 
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
@@ -2798,8 +2798,11 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
2798
2798
  if (!trimmedContent) {
2799
2799
  return requirements;
2800
2800
  }
2801
- // Add goal as a proper h2 section to the system message
2802
- const goalSection = `## Goal\n\n${trimmedContent}`;
2801
+ const goalSection = spaceTrim$1((block) => `
2802
+ ## Goal
2803
+
2804
+ ${block(trimmedContent)}
2805
+ `);
2803
2806
  const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
2804
2807
  return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
2805
2808
  }
@@ -3693,8 +3696,11 @@ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
3693
3696
  if (!trimmedContent) {
3694
3697
  return requirements;
3695
3698
  }
3696
- // Add language as a bullet under a ## Language section
3697
- const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
3699
+ const languageSection = spaceTrim$1((block) => `
3700
+ ## Language
3701
+
3702
+ - Your language is ${block(trimmedContent)}
3703
+ `);
3698
3704
  return this.appendToSystemMessage(requirements, languageSection, '\n\n');
3699
3705
  }
3700
3706
  }
@@ -8659,41 +8665,91 @@ function drawBlobbyOctopusShadow(context, size, palette, interaction, timeMs, mo
8659
8665
  context.fill();
8660
8666
  context.restore();
8661
8667
  }
8668
+ /**
8669
+ * Number of latitude segments used by the single blobby octopus mesh.
8670
+ *
8671
+ * @private helper of `octopus3d2AvatarVisual`
8672
+ */
8673
+ const LATITUDE_PATCH_COUNT$1 = 12;
8674
+ /**
8675
+ * Number of longitude segments used by the single blobby octopus mesh.
8676
+ *
8677
+ * @private helper of `octopus3d2AvatarVisual`
8678
+ */
8679
+ const LONGITUDE_PATCH_COUNT$1 = 24;
8662
8680
  /**
8663
8681
  * Resolves all visible projected patches for the single blobby octopus mesh.
8664
8682
  *
8683
+ * Within a single frame, mesh corner samples and longitude-only lobe-wave values are
8684
+ * quantized to the patch grid and computed once each rather than re-evaluated for every
8685
+ * patch corner — the patch loop alone would call `sampleBlobbyOctopusSurfacePoint`
8686
+ * `latitudePatchCount * longitudePatchCount * 4` times without caching, even though most
8687
+ * corners are shared between neighboring patches.
8688
+ *
8665
8689
  * @private helper of `octopus3d2AvatarVisual`
8666
8690
  */
8667
8691
  function resolveVisibleBlobbyOctopusPatches(options) {
8668
8692
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette, morphologyProfile, animationPhase, timeMs, } = options;
8669
- const latitudePatchCount = 12;
8670
- const longitudePatchCount = 24;
8693
+ const latitudePatchCount = LATITUDE_PATCH_COUNT$1;
8694
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT$1;
8671
8695
  const surfacePatches = [];
8696
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
8697
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
8698
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
8699
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
8700
+ }
8701
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
8702
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
8703
+ }
8704
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
8705
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
8706
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveLowerLobeWave(longitudeBoundaries[boundaryIndex], morphologyProfile, animationPhase, timeMs);
8707
+ }
8708
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
8709
+ const transformedCornerSamples = new Array(cornerCount);
8710
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
8711
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
8712
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
8713
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
8714
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
8715
+ const cornerSample = sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
8716
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
8717
+ }
8718
+ }
8672
8719
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
8673
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
8674
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
8720
+ const startLatitude = latitudeBoundaries[latitudeIndex];
8721
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
8675
8722
  const centerLatitude = (startLatitude + endLatitude) / 2;
8676
8723
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
8724
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
8725
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
8677
8726
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
8678
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
8679
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
8727
+ const startLongitude = longitudeBoundaries[longitudeIndex];
8728
+ const endLongitude = longitudeBoundaries[longitudeIndex + 1];
8680
8729
  const centerLongitude = (startLongitude + endLongitude) / 2;
8681
- const localCorners = [
8682
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, startLongitude),
8683
- sampleBlobbyOctopusSurfacePoint(options, startLatitude, endLongitude),
8684
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, endLongitude),
8685
- sampleBlobbyOctopusSurfacePoint(options, endLatitude, startLongitude),
8730
+ const transformedCorners = [
8731
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
8732
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
8733
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
8734
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
8686
8735
  ];
8687
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
8688
8736
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
8689
8737
  if (surfaceNormal.z <= 0.01) {
8690
8738
  continue;
8691
8739
  }
8692
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
8740
+ const projectedCorners = [
8741
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
8742
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
8743
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
8744
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
8745
+ ];
8693
8746
  surfacePatches.push({
8694
8747
  corners: projectedCorners,
8695
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
8696
- transformedCorners.length,
8748
+ averageDepth: (transformedCorners[0].z +
8749
+ transformedCorners[1].z +
8750
+ transformedCorners[2].z +
8751
+ transformedCorners[3].z) /
8752
+ 4,
8697
8753
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION$1), -1, 1),
8698
8754
  fillStyle: resolveBlobbySurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), resolveLowerLobeWave(centerLongitude, morphologyProfile, animationPhase, timeMs)),
8699
8755
  outlineColor: verticalProgress < 0.58 ? `${palette.highlight}73` : `${palette.shadow}8a`,
@@ -8711,12 +8767,21 @@ function resolveVisibleBlobbyOctopusPatches(options) {
8711
8767
  * @private helper of `octopus3d2AvatarVisual`
8712
8768
  */
8713
8769
  function sampleBlobbyOctopusSurfacePoint(options, latitude, longitude) {
8770
+ const { morphologyProfile, animationPhase, timeMs } = options;
8771
+ return sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs));
8772
+ }
8773
+ /**
8774
+ * Samples one point on the continuous Octopus 3D 2 surface using a precomputed lower-lobe wave
8775
+ * to skip the per-call trig evaluation for `latitudePatchCount + 1` longitude-shared corners.
8776
+ *
8777
+ * @private helper of `octopus3d2AvatarVisual`
8778
+ */
8779
+ function sampleBlobbyOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, lowerLobeWave) {
8714
8780
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
8715
8781
  const cosineLatitude = Math.max(0, Math.cos(latitude));
8716
8782
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
8717
8783
  const upperBlend = Math.pow(1 - verticalProgress, 1.2);
8718
8784
  const lowerBlend = Math.pow(verticalProgress, 1.42);
8719
- const lowerLobeWave = resolveLowerLobeWave(longitude, morphologyProfile, animationPhase, timeMs);
8720
8785
  const skirtEnvelope = Math.pow(cosineLatitude, 0.5) * lowerBlend;
8721
8786
  const horizontalScale = 1.02 +
8722
8787
  skirtEnvelope * (0.34 + (morphologyProfile.tentacles.rootSpreadScale - 1) * 0.22 + lowerLobeWave * 0.22) -
@@ -9013,45 +9078,102 @@ function drawContinuousOctopusShadow(context, size, palette, interaction, timeMs
9013
9078
  context.fill();
9014
9079
  context.restore();
9015
9080
  }
9081
+ /**
9082
+ * Number of latitude segments used by the continuous Octopus 3D 3 mesh.
9083
+ *
9084
+ * @private helper of `octopus3d3AvatarVisual`
9085
+ */
9086
+ const LATITUDE_PATCH_COUNT = 16;
9087
+ /**
9088
+ * Number of longitude segments used by the continuous Octopus 3D 3 mesh.
9089
+ *
9090
+ * @private helper of `octopus3d3AvatarVisual`
9091
+ */
9092
+ const LONGITUDE_PATCH_COUNT = 40;
9016
9093
  /**
9017
9094
  * Resolves visible projected patches for the continuous octopus mesh.
9018
9095
  *
9096
+ * Within a single frame, mesh corner samples and longitude-only computations (tentacle
9097
+ * influence and lobe wave) are quantized to the patch grid and computed once each rather
9098
+ * than re-evaluated for every patch corner — the patch loop alone calls `sampleContinuousOctopusSurfacePoint`
9099
+ * for `latitudePatchCount * longitudePatchCount * 4` corners without caching, and each call
9100
+ * triggers an inner 8-iteration `Math.exp` loop, which dominates the per-frame cost.
9101
+ *
9019
9102
  * @private helper of `octopus3d3AvatarVisual`
9020
9103
  */
9021
9104
  function resolveVisibleContinuousOctopusPatches(options) {
9022
9105
  const { center, rotationX, rotationY, sceneCenterX, sceneCenterY, size, palette } = options;
9023
- const latitudePatchCount = 16;
9024
- const longitudePatchCount = 40;
9106
+ const latitudePatchCount = LATITUDE_PATCH_COUNT;
9107
+ const longitudePatchCount = LONGITUDE_PATCH_COUNT;
9025
9108
  const surfacePatches = [];
9109
+ const latitudeBoundaries = new Float64Array(latitudePatchCount + 1);
9110
+ const longitudeBoundaries = new Float64Array(longitudePatchCount + 1);
9111
+ for (let boundaryIndex = 0; boundaryIndex <= latitudePatchCount; boundaryIndex++) {
9112
+ latitudeBoundaries[boundaryIndex] = -Math.PI / 2 + (boundaryIndex / latitudePatchCount) * Math.PI;
9113
+ }
9114
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
9115
+ longitudeBoundaries[boundaryIndex] = -Math.PI + (boundaryIndex / longitudePatchCount) * Math.PI * 2;
9116
+ }
9117
+ const cachedTentacleInfluencesByCornerLongitude = new Array(longitudePatchCount + 1);
9118
+ const cachedLobeWavesByCornerLongitude = new Float64Array(longitudePatchCount + 1);
9119
+ const cachedTentacleInfluencesByPatchCenterLongitude = new Array(longitudePatchCount);
9120
+ const cachedLobeWavesByPatchCenterLongitude = new Float64Array(longitudePatchCount);
9121
+ const cachedCosByPatchCenterLongitude = new Float64Array(longitudePatchCount);
9122
+ for (let boundaryIndex = 0; boundaryIndex <= longitudePatchCount; boundaryIndex++) {
9123
+ const cornerLongitude = longitudeBoundaries[boundaryIndex];
9124
+ cachedTentacleInfluencesByCornerLongitude[boundaryIndex] = resolveContinuousTentacleInfluence(options, cornerLongitude);
9125
+ cachedLobeWavesByCornerLongitude[boundaryIndex] = resolveContinuousLobeWave(options, cornerLongitude);
9126
+ }
9127
+ for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
9128
+ const patchCenterLongitude = (longitudeBoundaries[longitudeIndex] + longitudeBoundaries[longitudeIndex + 1]) / 2;
9129
+ cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex] = resolveContinuousTentacleInfluence(options, patchCenterLongitude);
9130
+ cachedLobeWavesByPatchCenterLongitude[longitudeIndex] = resolveContinuousLobeWave(options, patchCenterLongitude);
9131
+ cachedCosByPatchCenterLongitude[longitudeIndex] = Math.max(0, Math.cos(patchCenterLongitude));
9132
+ }
9133
+ const cornerCount = (latitudePatchCount + 1) * (longitudePatchCount + 1);
9134
+ const transformedCornerSamples = new Array(cornerCount);
9135
+ for (let latitudeBoundaryIndex = 0; latitudeBoundaryIndex <= latitudePatchCount; latitudeBoundaryIndex++) {
9136
+ const cornerLatitude = latitudeBoundaries[latitudeBoundaryIndex];
9137
+ for (let longitudeBoundaryIndex = 0; longitudeBoundaryIndex <= longitudePatchCount; longitudeBoundaryIndex++) {
9138
+ const cornerLongitude = longitudeBoundaries[longitudeBoundaryIndex];
9139
+ const cornerIndex = latitudeBoundaryIndex * (longitudePatchCount + 1) + longitudeBoundaryIndex;
9140
+ const cornerSample = sampleContinuousOctopusSurfacePointWithLongitudeCache(options, cornerLatitude, cornerLongitude, cachedTentacleInfluencesByCornerLongitude[longitudeBoundaryIndex], cachedLobeWavesByCornerLongitude[longitudeBoundaryIndex]);
9141
+ transformedCornerSamples[cornerIndex] = transformScenePoint(cornerSample, center, rotationX, rotationY);
9142
+ }
9143
+ }
9026
9144
  for (let latitudeIndex = 0; latitudeIndex < latitudePatchCount; latitudeIndex++) {
9027
- const startLatitude = -Math.PI / 2 + (latitudeIndex / latitudePatchCount) * Math.PI;
9028
- const endLatitude = -Math.PI / 2 + ((latitudeIndex + 1) / latitudePatchCount) * Math.PI;
9145
+ const startLatitude = latitudeBoundaries[latitudeIndex];
9146
+ const endLatitude = latitudeBoundaries[latitudeIndex + 1];
9029
9147
  const centerLatitude = (startLatitude + endLatitude) / 2;
9030
9148
  const verticalProgress = (Math.sin(centerLatitude) + 1) / 2;
9149
+ const startCornerRowOffset = latitudeIndex * (longitudePatchCount + 1);
9150
+ const endCornerRowOffset = (latitudeIndex + 1) * (longitudePatchCount + 1);
9031
9151
  for (let longitudeIndex = 0; longitudeIndex < longitudePatchCount; longitudeIndex++) {
9032
- const startLongitude = -Math.PI + (longitudeIndex / longitudePatchCount) * Math.PI * 2;
9033
- const endLongitude = -Math.PI + ((longitudeIndex + 1) / longitudePatchCount) * Math.PI * 2;
9034
- const centerLongitude = (startLongitude + endLongitude) / 2;
9035
- const localCorners = [
9036
- sampleContinuousOctopusSurfacePoint(options, startLatitude, startLongitude),
9037
- sampleContinuousOctopusSurfacePoint(options, startLatitude, endLongitude),
9038
- sampleContinuousOctopusSurfacePoint(options, endLatitude, endLongitude),
9039
- sampleContinuousOctopusSurfacePoint(options, endLatitude, startLongitude),
9152
+ const transformedCorners = [
9153
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex],
9154
+ transformedCornerSamples[startCornerRowOffset + longitudeIndex + 1],
9155
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex + 1],
9156
+ transformedCornerSamples[endCornerRowOffset + longitudeIndex],
9040
9157
  ];
9041
- const transformedCorners = localCorners.map((localCorner) => transformScenePoint(localCorner, center, rotationX, rotationY));
9042
9158
  const surfaceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
9043
9159
  if (surfaceNormal.z <= 0.008) {
9044
9160
  continue;
9045
9161
  }
9046
- const projectedCorners = transformedCorners.map((transformedCorner) => projectScenePoint(transformedCorner, size, sceneCenterX, sceneCenterY));
9047
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, centerLongitude);
9048
- const lowerLobeWave = resolveContinuousLobeWave(options, centerLongitude);
9162
+ const projectedCorners = [
9163
+ projectScenePoint(transformedCorners[0], size, sceneCenterX, sceneCenterY),
9164
+ projectScenePoint(transformedCorners[1], size, sceneCenterX, sceneCenterY),
9165
+ projectScenePoint(transformedCorners[2], size, sceneCenterX, sceneCenterY),
9166
+ projectScenePoint(transformedCorners[3], size, sceneCenterX, sceneCenterY),
9167
+ ];
9049
9168
  surfacePatches.push({
9050
9169
  corners: projectedCorners,
9051
- averageDepth: transformedCorners.reduce((depthSum, transformedCorner) => depthSum + transformedCorner.z, 0) /
9052
- transformedCorners.length,
9170
+ averageDepth: (transformedCorners[0].z +
9171
+ transformedCorners[1].z +
9172
+ transformedCorners[2].z +
9173
+ transformedCorners[3].z) /
9174
+ 4,
9053
9175
  lightIntensity: clampNumber$1(dotProduct3D(surfaceNormal, LIGHT_DIRECTION), -1, 1),
9054
- fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, Math.max(0, Math.cos(centerLongitude)), tentacleInfluence.core, lowerLobeWave),
9176
+ fillStyle: resolveContinuousSurfacePatchFillStyle(palette, verticalProgress, cachedCosByPatchCenterLongitude[longitudeIndex], cachedTentacleInfluencesByPatchCenterLongitude[longitudeIndex].core, cachedLobeWavesByPatchCenterLongitude[longitudeIndex]),
9055
9177
  outlineColor: verticalProgress < 0.54 ? `${palette.highlight}69` : `${palette.shadow}78`,
9056
9178
  });
9057
9179
  }
@@ -9067,16 +9189,27 @@ function resolveVisibleContinuousOctopusPatches(options) {
9067
9189
  * @private helper of `octopus3d3AvatarVisual`
9068
9190
  */
9069
9191
  function sampleContinuousOctopusSurfacePoint(options, latitude, longitude) {
9192
+ return sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, resolveContinuousTentacleInfluence(options, longitude), resolveContinuousLobeWave(options, longitude));
9193
+ }
9194
+ /**
9195
+ * Samples one point on the continuous Octopus 3D 3 surface using precomputed longitude-only
9196
+ * values to skip the per-call `Math.exp` tentacle-influence loop and the lobe-wave trig call.
9197
+ *
9198
+ * The patch loop quantizes the mesh into a fixed `(latitudePatchCount + 1) * (longitudePatchCount + 1)`
9199
+ * corner grid, so the same longitude is reused across every latitude row and each
9200
+ * tentacle/lobe value can be computed once per frame instead of `latitudePatchCount * 4` times.
9201
+ *
9202
+ * @private helper of `octopus3d3AvatarVisual`
9203
+ */
9204
+ function sampleContinuousOctopusSurfacePointWithLongitudeCache(options, latitude, longitude, tentacleInfluence, lowerLobeWave) {
9070
9205
  const { radiusX, radiusY, radiusZ, morphologyProfile, timeMs, animationPhase } = options;
9071
9206
  const cosineLatitude = Math.max(0, Math.cos(latitude));
9072
9207
  const verticalProgress = (Math.sin(latitude) + 1) / 2;
9073
9208
  const upperBlend = Math.pow(1 - verticalProgress, 1.28);
9074
9209
  const lowerBlend = smoothStep(0.38, 1, verticalProgress);
9075
9210
  const tipBlend = smoothStep(0.68, 1, verticalProgress);
9076
- const tentacleInfluence = resolveContinuousTentacleInfluence(options, longitude);
9077
9211
  const centerPull = resolveSignedAngularDistance(longitude, tentacleInfluence.centerLongitude);
9078
9212
  const effectiveLongitude = longitude + centerPull * lowerBlend * tentacleInfluence.core * (0.24 + tipBlend * 0.2);
9079
- const lowerLobeWave = resolveContinuousLobeWave(options, longitude);
9080
9213
  const mantleRipple = Math.sin(longitude * morphologyProfile.body.lobeCount +
9081
9214
  animationPhase * 0.6 +
9082
9215
  timeMs / (1750 + morphologyProfile.body.lobeCount * 30)) *
@@ -12481,7 +12614,15 @@ function buildTeammateMetadata(entry) {
12481
12614
  * Builds the teammate request text, optionally including context.
12482
12615
  */
12483
12616
  function buildTeammateRequest(message, context) {
12484
- return context ? `${message}\n\nContext:\n${context}` : message;
12617
+ if (!context) {
12618
+ return message;
12619
+ }
12620
+ return spaceTrim$1((block) => `
12621
+ ${block(message)}
12622
+
12623
+ Context:
12624
+ ${block(context)}
12625
+ `);
12485
12626
  }
12486
12627
  /**
12487
12628
  * Builds a minimal chat prompt for teammate calls.
@@ -16504,7 +16645,11 @@ function createUseProjectToolFunctions() {
16504
16645
  const lineRangedContent = applyOptionalLineRange(decodedContent, args.startLine, args.endLine);
16505
16646
  const wasCharacterTruncated = lineRangedContent.length > MAX_PROJECT_FILE_CONTENT_CHARACTERS;
16506
16647
  const contentToReturn = wasCharacterTruncated
16507
- ? `${lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS)}\n\n[...truncated...]`
16648
+ ? spaceTrim$1((block) => `
16649
+ ${block(lineRangedContent.slice(0, MAX_PROJECT_FILE_CONTENT_CHARACTERS))}
16650
+
16651
+ [...truncated...]
16652
+ `)
16508
16653
  : lineRangedContent;
16509
16654
  const wasTruncated = decoded.isTruncated || wasCharacterTruncated;
16510
16655
  if (wasCharacterTruncated) {
@@ -28753,11 +28898,19 @@ const JsonFileImportPlugin = {
28753
28898
  try {
28754
28899
  const json = JSON.parse(content);
28755
28900
  const formattedJson = JSON.stringify(json, null, 4);
28756
- return `\`\`\`json\n${formattedJson}\n\`\`\``;
28901
+ return spaceTrim$1((block) => `
28902
+ \`\`\`json
28903
+ ${block(formattedJson)}
28904
+ \`\`\`
28905
+ `);
28757
28906
  }
28758
28907
  catch (error) {
28759
28908
  // If JSON is invalid, still import it but maybe not as pretty JSON
28760
- return `\`\`\`json\n${content}\n\`\`\``;
28909
+ return spaceTrim$1((block) => `
28910
+ \`\`\`json
28911
+ ${block(content)}
28912
+ \`\`\`
28913
+ `);
28761
28914
  }
28762
28915
  },
28763
28916
  };
@@ -28781,7 +28934,11 @@ const TextFileImportPlugin = {
28781
28934
  import(content, mimeType) {
28782
28935
  const extension = mimeTypeToExtension(mimeType);
28783
28936
  const codeBlockType = extension || 'txt';
28784
- return `\`\`\`${codeBlockType}\n${content}\n\`\`\``;
28937
+ return spaceTrim$1((block) => `
28938
+ \`\`\`${codeBlockType}
28939
+ ${block(content)}
28940
+ \`\`\`
28941
+ `);
28785
28942
  },
28786
28943
  };
28787
28944
 
@@ -29028,11 +29185,19 @@ function collectExampleInteractionLines(parseResult, samples) {
29028
29185
  const examples = [];
29029
29186
  const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
29030
29187
  if (initialMessage) {
29031
- examples.push(`**Agent:**\n${initialMessage}`);
29188
+ examples.push(spaceTrim$1((block) => `
29189
+ **Agent:**
29190
+ ${block(initialMessage)}
29191
+ `));
29032
29192
  }
29033
29193
  if (samples && samples.length > 0) {
29034
29194
  for (const sample of samples) {
29035
- examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
29195
+ examples.push(spaceTrim$1((block) => `
29196
+ **User:** ${block(String(sample.question))}
29197
+
29198
+ **Agent:**
29199
+ ${block(sample.answer)}
29200
+ `));
29036
29201
  }
29037
29202
  }
29038
29203
  return examples;
@@ -35727,7 +35892,11 @@ function truncateAttachmentInlineText(content, maxCharacters) {
35727
35892
  };
35728
35893
  }
35729
35894
  return {
35730
- content: `${content.slice(0, Math.max(0, maxCharacters))}\n\n[...truncated...]`,
35895
+ content: spaceTrim$1((block) => `
35896
+ ${block(content.slice(0, Math.max(0, maxCharacters)))}
35897
+
35898
+ [...truncated...]
35899
+ `),
35731
35900
  isTruncated: true,
35732
35901
  };
35733
35902
  }