@promptbook/browser 0.103.0-51 → 0.103.0-52

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.
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-51';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-52';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2664,9 +2664,13 @@
2664
2664
  *
2665
2665
  * @private - TODO: [🧠] Maybe should be public?
2666
2666
  */
2667
- function createCommitmentRegex(commitment) {
2668
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2669
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
2667
+ function createCommitmentRegex(commitment, aliases = []) {
2668
+ const allCommitments = [commitment, ...aliases];
2669
+ const patterns = allCommitments.map((c) => {
2670
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2671
+ return escapedCommitment.split(/\s+/).join('\\s+');
2672
+ });
2673
+ const keywordPattern = patterns.join('|');
2670
2674
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
2671
2675
  return regex;
2672
2676
  }
@@ -2679,9 +2683,13 @@
2679
2683
  *
2680
2684
  * @private
2681
2685
  */
2682
- function createCommitmentTypeRegex(commitment) {
2683
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2684
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
2686
+ function createCommitmentTypeRegex(commitment, aliases = []) {
2687
+ const allCommitments = [commitment, ...aliases];
2688
+ const patterns = allCommitments.map((c) => {
2689
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2690
+ return escapedCommitment.split(/\s+/).join('\\s+');
2691
+ });
2692
+ const keywordPattern = patterns.join('|');
2685
2693
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
2686
2694
  return regex;
2687
2695
  }
@@ -2693,22 +2701,23 @@
2693
2701
  * @private
2694
2702
  */
2695
2703
  class BaseCommitmentDefinition {
2696
- constructor(type) {
2704
+ constructor(type, aliases = []) {
2697
2705
  this.type = type;
2706
+ this.aliases = aliases;
2698
2707
  }
2699
2708
  /**
2700
2709
  * Creates a regex pattern to match this commitment in agent source
2701
2710
  * Uses the existing createCommitmentRegex function as internal helper
2702
2711
  */
2703
2712
  createRegex() {
2704
- return createCommitmentRegex(this.type);
2713
+ return createCommitmentRegex(this.type, this.aliases);
2705
2714
  }
2706
2715
  /**
2707
2716
  * Creates a regex pattern to match just the commitment type
2708
2717
  * Uses the existing createCommitmentTypeRegex function as internal helper
2709
2718
  */
2710
2719
  createTypeRegex() {
2711
- return createCommitmentTypeRegex(this.type);
2720
+ return createCommitmentTypeRegex(this.type, this.aliases);
2712
2721
  }
2713
2722
  /**
2714
2723
  * Helper method to create a new requirements object with updated system message
@@ -3620,6 +3629,165 @@
3620
3629
  * Note: [💞] Ignore a discrepancy between file name and entity name
3621
3630
  */
3622
3631
 
3632
+ /**
3633
+ * META COLOR commitment definition
3634
+ *
3635
+ * The META COLOR commitment sets the agent's accent color.
3636
+ * This commitment is special because it doesn't affect the system message,
3637
+ * but is handled separately in the parsing logic.
3638
+ *
3639
+ * Example usage in agent source:
3640
+ *
3641
+ * ```book
3642
+ * META COLOR #ff0000
3643
+ * META COLOR #00ff00
3644
+ * ```
3645
+ *
3646
+ * @private [🪔] Maybe export the commitments through some package
3647
+ */
3648
+ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3649
+ constructor() {
3650
+ super('META COLOR', ['COLOR']);
3651
+ }
3652
+ /**
3653
+ * Short one-line description of META COLOR.
3654
+ */
3655
+ get description() {
3656
+ return "Set the agent's accent color.";
3657
+ }
3658
+ /**
3659
+ * Markdown documentation for META COLOR commitment.
3660
+ */
3661
+ get documentation() {
3662
+ return spaceTrim.spaceTrim(`
3663
+ # META COLOR
3664
+
3665
+ Sets the agent's accent color.
3666
+
3667
+ ## Key aspects
3668
+
3669
+ - Does not modify the agent's behavior or responses.
3670
+ - Only one \`META COLOR\` should be used per agent.
3671
+ - If multiple are specified, the last one takes precedence.
3672
+ - Used for visual representation in user interfaces.
3673
+
3674
+ ## Examples
3675
+
3676
+ \`\`\`book
3677
+ Professional Assistant
3678
+
3679
+ META COLOR #3498db
3680
+ PERSONA You are a professional business assistant
3681
+ \`\`\`
3682
+
3683
+ \`\`\`book
3684
+ Creative Helper
3685
+
3686
+ META COLOR #e74c3c
3687
+ PERSONA You are a creative and inspiring assistant
3688
+ \`\`\`
3689
+ `);
3690
+ }
3691
+ applyToAgentModelRequirements(requirements, content) {
3692
+ // META COLOR doesn't modify the system message or model requirements
3693
+ // It's handled separately in the parsing logic for profile color extraction
3694
+ // This method exists for consistency with the CommitmentDefinition interface
3695
+ return requirements;
3696
+ }
3697
+ /**
3698
+ * Extracts the profile color from the content
3699
+ * This is used by the parsing logic
3700
+ */
3701
+ extractProfileColor(content) {
3702
+ const trimmedContent = content.trim();
3703
+ return trimmedContent || null;
3704
+ }
3705
+ }
3706
+ /**
3707
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3708
+ */
3709
+
3710
+ /**
3711
+ * META IMAGE commitment definition
3712
+ *
3713
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
3714
+ * This commitment is special because it doesn't affect the system message,
3715
+ * but is handled separately in the parsing logic.
3716
+ *
3717
+ * Example usage in agent source:
3718
+ *
3719
+ * ```book
3720
+ * META IMAGE https://example.com/avatar.jpg
3721
+ * META IMAGE /assets/agent-avatar.png
3722
+ * ```
3723
+ *
3724
+ * @private [🪔] Maybe export the commitments through some package
3725
+ */
3726
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
3727
+ constructor() {
3728
+ super('META IMAGE', ['IMAGE']);
3729
+ }
3730
+ /**
3731
+ * Short one-line description of META IMAGE.
3732
+ */
3733
+ get description() {
3734
+ return "Set the agent's profile image URL.";
3735
+ }
3736
+ /**
3737
+ * Markdown documentation for META IMAGE commitment.
3738
+ */
3739
+ get documentation() {
3740
+ return spaceTrim.spaceTrim(`
3741
+ # META IMAGE
3742
+
3743
+ Sets the agent's avatar/profile image URL.
3744
+
3745
+ ## Key aspects
3746
+
3747
+ - Does not modify the agent's behavior or responses.
3748
+ - Only one \`META IMAGE\` should be used per agent.
3749
+ - If multiple are specified, the last one takes precedence.
3750
+ - Used for visual representation in user interfaces.
3751
+
3752
+ ## Examples
3753
+
3754
+ \`\`\`book
3755
+ Professional Assistant
3756
+
3757
+ META IMAGE https://example.com/professional-avatar.jpg
3758
+ PERSONA You are a professional business assistant
3759
+ STYLE Maintain a formal and courteous tone
3760
+ \`\`\`
3761
+
3762
+ \`\`\`book
3763
+ Creative Helper
3764
+
3765
+ META IMAGE /assets/creative-bot-avatar.png
3766
+ PERSONA You are a creative and inspiring assistant
3767
+ STYLE Be enthusiastic and encouraging
3768
+ ACTION Can help with brainstorming and ideation
3769
+ \`\`\`
3770
+ `);
3771
+ }
3772
+ applyToAgentModelRequirements(requirements, content) {
3773
+ // META IMAGE doesn't modify the system message or model requirements
3774
+ // It's handled separately in the parsing logic for profile image extraction
3775
+ // This method exists for consistency with the CommitmentDefinition interface
3776
+ return requirements;
3777
+ }
3778
+ /**
3779
+ * Extracts the profile image URL from the content
3780
+ * This is used by the parsing logic
3781
+ */
3782
+ extractProfileImageUrl(content) {
3783
+ const trimmedContent = content.trim();
3784
+ return trimmedContent || null;
3785
+ }
3786
+ }
3787
+ /**
3788
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3789
+ */
3790
+
3623
3791
  /**
3624
3792
  * MODEL commitment definition
3625
3793
  *
@@ -4527,6 +4695,8 @@
4527
4695
  new ModelCommitmentDefinition('MODELS'),
4528
4696
  new ActionCommitmentDefinition('ACTION'),
4529
4697
  new ActionCommitmentDefinition('ACTIONS'),
4698
+ new MetaImageCommitmentDefinition(),
4699
+ new MetaColorCommitmentDefinition(),
4530
4700
  new MetaCommitmentDefinition(),
4531
4701
  new NoteCommitmentDefinition('NOTE'),
4532
4702
  new NoteCommitmentDefinition('NOTES'),
@@ -4756,6 +4926,14 @@
4756
4926
  links.push(spaceTrim__default["default"](commitment.content));
4757
4927
  continue;
4758
4928
  }
4929
+ if (commitment.type === 'META IMAGE') {
4930
+ meta.image = spaceTrim__default["default"](commitment.content);
4931
+ continue;
4932
+ }
4933
+ if (commitment.type === 'META COLOR') {
4934
+ meta.color = spaceTrim__default["default"](commitment.content);
4935
+ continue;
4936
+ }
4759
4937
  if (commitment.type !== 'META') {
4760
4938
  continue;
4761
4939
  }
@@ -4771,6 +4949,10 @@
4771
4949
  if (!meta.image) {
4772
4950
  meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
4773
4951
  }
4952
+ // Generate fullname fallback if no meta fullname specified
4953
+ if (!meta.fullname) {
4954
+ meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
4955
+ }
4774
4956
  // Parse parameters using unified approach - both @Parameter and {parameter} notations
4775
4957
  // are treated as the same syntax feature with unified representation
4776
4958
  const parameters = parseParameters(agentSource);