@promptbook/browser 0.103.0-51 → 0.103.0-53

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 (30) hide show
  1. package/esm/index.es.js +326 -10
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/servers.d.ts +8 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +6 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  8. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
  9. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +7 -0
  10. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +2 -2
  11. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
  12. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +6 -0
  13. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
  14. package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
  15. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +17 -0
  16. package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +28 -0
  17. package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +28 -0
  18. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +38 -0
  19. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +2 -1
  20. package/esm/typings/src/commitments/index.d.ts +22 -1
  21. package/esm/typings/src/execution/LlmExecutionTools.d.ts +9 -0
  22. package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -0
  23. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +2 -1
  24. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +10 -1
  25. package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
  26. package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
  27. package/esm/typings/src/version.d.ts +1 -1
  28. package/package.json +2 -2
  29. package/umd/index.umd.js +326 -10
  30. package/umd/index.umd.js.map +1 -1
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-53';
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
@@ -3319,6 +3328,77 @@
3319
3328
  * Note: [💞] Ignore a discrepancy between file name and entity name
3320
3329
  */
3321
3330
 
3331
+ /**
3332
+ * AGENT MESSAGE commitment definition
3333
+ *
3334
+ * The AGENT MESSAGE commitment defines a message from the agent in the conversation history.
3335
+ * It is used to pre-fill the chat with a conversation history or to provide few-shot examples.
3336
+ *
3337
+ * Example usage in agent source:
3338
+ *
3339
+ * ```book
3340
+ * AGENT MESSAGE What seems to be the issue?
3341
+ * ```
3342
+ *
3343
+ * @private [🪔] Maybe export the commitments through some package
3344
+ */
3345
+ class AgentMessageCommitmentDefinition extends BaseCommitmentDefinition {
3346
+ constructor() {
3347
+ super('AGENT MESSAGE');
3348
+ }
3349
+ /**
3350
+ * Short one-line description of AGENT MESSAGE.
3351
+ */
3352
+ get description() {
3353
+ return 'Defines a **message from the agent** in the conversation history.';
3354
+ }
3355
+ /**
3356
+ * Markdown documentation for AGENT MESSAGE commitment.
3357
+ */
3358
+ get documentation() {
3359
+ return spaceTrim.spaceTrim(`
3360
+ # ${this.type}
3361
+
3362
+ Defines a message from the agent in the conversation history. This is used to pre-fill the chat with a conversation history or to provide few-shot examples.
3363
+
3364
+ ## Key aspects
3365
+
3366
+ - Represents a message sent by the agent.
3367
+ - Used for setting up conversation context.
3368
+ - Can be used in conjunction with USER MESSAGE.
3369
+
3370
+ ## Examples
3371
+
3372
+ \`\`\`book
3373
+ Conversation History
3374
+
3375
+ USER MESSAGE Hello, I have a problem.
3376
+ AGENT MESSAGE What seems to be the issue?
3377
+ USER MESSAGE My computer is not starting.
3378
+ \`\`\`
3379
+ `);
3380
+ }
3381
+ applyToAgentModelRequirements(requirements, content) {
3382
+ // AGENT MESSAGE is for UI display purposes / conversation history construction
3383
+ // and typically doesn't need to be added to the system prompt or model requirements directly.
3384
+ // It is extracted separately for the chat interface.
3385
+ var _a;
3386
+ const pendingUserMessage = (_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.pendingUserMessage;
3387
+ if (pendingUserMessage) {
3388
+ const newSample = { question: pendingUserMessage, answer: content };
3389
+ const newSamples = [...(requirements.samples || []), newSample];
3390
+ const newMetadata = { ...requirements.metadata };
3391
+ delete newMetadata.pendingUserMessage;
3392
+ return {
3393
+ ...requirements,
3394
+ samples: newSamples,
3395
+ metadata: newMetadata,
3396
+ };
3397
+ }
3398
+ return requirements;
3399
+ }
3400
+ }
3401
+
3322
3402
  /**
3323
3403
  * INITIAL MESSAGE commitment definition
3324
3404
  *
@@ -3483,6 +3563,67 @@
3483
3563
  * Note: [💞] Ignore a discrepancy between file name and entity name
3484
3564
  */
3485
3565
 
3566
+ /**
3567
+ * USER MESSAGE commitment definition
3568
+ *
3569
+ * The USER MESSAGE commitment defines a message from the user in the conversation history.
3570
+ * It is used to pre-fill the chat with a conversation history or to provide few-shot examples.
3571
+ *
3572
+ * Example usage in agent source:
3573
+ *
3574
+ * ```book
3575
+ * USER MESSAGE Hello, I have a problem.
3576
+ * ```
3577
+ *
3578
+ * @private [🪔] Maybe export the commitments through some package
3579
+ */
3580
+ class UserMessageCommitmentDefinition extends BaseCommitmentDefinition {
3581
+ constructor() {
3582
+ super('USER MESSAGE');
3583
+ }
3584
+ /**
3585
+ * Short one-line description of USER MESSAGE.
3586
+ */
3587
+ get description() {
3588
+ return 'Defines a **message from the user** in the conversation history.';
3589
+ }
3590
+ /**
3591
+ * Markdown documentation for USER MESSAGE commitment.
3592
+ */
3593
+ get documentation() {
3594
+ return spaceTrim.spaceTrim(`
3595
+ # ${this.type}
3596
+
3597
+ Defines a message from the user in the conversation history. This is used to pre-fill the chat with a conversation history or to provide few-shot examples.
3598
+
3599
+ ## Key aspects
3600
+
3601
+ - Represents a message sent by the user.
3602
+ - Used for setting up conversation context.
3603
+ - Can be used in conjunction with AGENT MESSAGE.
3604
+
3605
+ ## Examples
3606
+
3607
+ \`\`\`book
3608
+ Conversation History
3609
+
3610
+ USER MESSAGE Hello, I have a problem.
3611
+ AGENT MESSAGE What seems to be the issue?
3612
+ USER MESSAGE My computer is not starting.
3613
+ \`\`\`
3614
+ `);
3615
+ }
3616
+ applyToAgentModelRequirements(requirements, content) {
3617
+ return {
3618
+ ...requirements,
3619
+ metadata: {
3620
+ ...requirements.metadata,
3621
+ pendingUserMessage: content,
3622
+ },
3623
+ };
3624
+ }
3625
+ }
3626
+
3486
3627
  /**
3487
3628
  * META commitment definition
3488
3629
  *
@@ -3620,6 +3761,165 @@
3620
3761
  * Note: [💞] Ignore a discrepancy between file name and entity name
3621
3762
  */
3622
3763
 
3764
+ /**
3765
+ * META COLOR commitment definition
3766
+ *
3767
+ * The META COLOR commitment sets the agent's accent color.
3768
+ * This commitment is special because it doesn't affect the system message,
3769
+ * but is handled separately in the parsing logic.
3770
+ *
3771
+ * Example usage in agent source:
3772
+ *
3773
+ * ```book
3774
+ * META COLOR #ff0000
3775
+ * META COLOR #00ff00
3776
+ * ```
3777
+ *
3778
+ * @private [🪔] Maybe export the commitments through some package
3779
+ */
3780
+ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3781
+ constructor() {
3782
+ super('META COLOR', ['COLOR']);
3783
+ }
3784
+ /**
3785
+ * Short one-line description of META COLOR.
3786
+ */
3787
+ get description() {
3788
+ return "Set the agent's accent color.";
3789
+ }
3790
+ /**
3791
+ * Markdown documentation for META COLOR commitment.
3792
+ */
3793
+ get documentation() {
3794
+ return spaceTrim.spaceTrim(`
3795
+ # META COLOR
3796
+
3797
+ Sets the agent's accent color.
3798
+
3799
+ ## Key aspects
3800
+
3801
+ - Does not modify the agent's behavior or responses.
3802
+ - Only one \`META COLOR\` should be used per agent.
3803
+ - If multiple are specified, the last one takes precedence.
3804
+ - Used for visual representation in user interfaces.
3805
+
3806
+ ## Examples
3807
+
3808
+ \`\`\`book
3809
+ Professional Assistant
3810
+
3811
+ META COLOR #3498db
3812
+ PERSONA You are a professional business assistant
3813
+ \`\`\`
3814
+
3815
+ \`\`\`book
3816
+ Creative Helper
3817
+
3818
+ META COLOR #e74c3c
3819
+ PERSONA You are a creative and inspiring assistant
3820
+ \`\`\`
3821
+ `);
3822
+ }
3823
+ applyToAgentModelRequirements(requirements, content) {
3824
+ // META COLOR doesn't modify the system message or model requirements
3825
+ // It's handled separately in the parsing logic for profile color extraction
3826
+ // This method exists for consistency with the CommitmentDefinition interface
3827
+ return requirements;
3828
+ }
3829
+ /**
3830
+ * Extracts the profile color from the content
3831
+ * This is used by the parsing logic
3832
+ */
3833
+ extractProfileColor(content) {
3834
+ const trimmedContent = content.trim();
3835
+ return trimmedContent || null;
3836
+ }
3837
+ }
3838
+ /**
3839
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3840
+ */
3841
+
3842
+ /**
3843
+ * META IMAGE commitment definition
3844
+ *
3845
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
3846
+ * This commitment is special because it doesn't affect the system message,
3847
+ * but is handled separately in the parsing logic.
3848
+ *
3849
+ * Example usage in agent source:
3850
+ *
3851
+ * ```book
3852
+ * META IMAGE https://example.com/avatar.jpg
3853
+ * META IMAGE /assets/agent-avatar.png
3854
+ * ```
3855
+ *
3856
+ * @private [🪔] Maybe export the commitments through some package
3857
+ */
3858
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
3859
+ constructor() {
3860
+ super('META IMAGE', ['IMAGE']);
3861
+ }
3862
+ /**
3863
+ * Short one-line description of META IMAGE.
3864
+ */
3865
+ get description() {
3866
+ return "Set the agent's profile image URL.";
3867
+ }
3868
+ /**
3869
+ * Markdown documentation for META IMAGE commitment.
3870
+ */
3871
+ get documentation() {
3872
+ return spaceTrim.spaceTrim(`
3873
+ # META IMAGE
3874
+
3875
+ Sets the agent's avatar/profile image URL.
3876
+
3877
+ ## Key aspects
3878
+
3879
+ - Does not modify the agent's behavior or responses.
3880
+ - Only one \`META IMAGE\` should be used per agent.
3881
+ - If multiple are specified, the last one takes precedence.
3882
+ - Used for visual representation in user interfaces.
3883
+
3884
+ ## Examples
3885
+
3886
+ \`\`\`book
3887
+ Professional Assistant
3888
+
3889
+ META IMAGE https://example.com/professional-avatar.jpg
3890
+ PERSONA You are a professional business assistant
3891
+ STYLE Maintain a formal and courteous tone
3892
+ \`\`\`
3893
+
3894
+ \`\`\`book
3895
+ Creative Helper
3896
+
3897
+ META IMAGE /assets/creative-bot-avatar.png
3898
+ PERSONA You are a creative and inspiring assistant
3899
+ STYLE Be enthusiastic and encouraging
3900
+ ACTION Can help with brainstorming and ideation
3901
+ \`\`\`
3902
+ `);
3903
+ }
3904
+ applyToAgentModelRequirements(requirements, content) {
3905
+ // META IMAGE doesn't modify the system message or model requirements
3906
+ // It's handled separately in the parsing logic for profile image extraction
3907
+ // This method exists for consistency with the CommitmentDefinition interface
3908
+ return requirements;
3909
+ }
3910
+ /**
3911
+ * Extracts the profile image URL from the content
3912
+ * This is used by the parsing logic
3913
+ */
3914
+ extractProfileImageUrl(content) {
3915
+ const trimmedContent = content.trim();
3916
+ return trimmedContent || null;
3917
+ }
3918
+ }
3919
+ /**
3920
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3921
+ */
3922
+
3623
3923
  /**
3624
3924
  * MODEL commitment definition
3625
3925
  *
@@ -4527,6 +4827,8 @@
4527
4827
  new ModelCommitmentDefinition('MODELS'),
4528
4828
  new ActionCommitmentDefinition('ACTION'),
4529
4829
  new ActionCommitmentDefinition('ACTIONS'),
4830
+ new MetaImageCommitmentDefinition(),
4831
+ new MetaColorCommitmentDefinition(),
4530
4832
  new MetaCommitmentDefinition(),
4531
4833
  new NoteCommitmentDefinition('NOTE'),
4532
4834
  new NoteCommitmentDefinition('NOTES'),
@@ -4535,6 +4837,8 @@
4535
4837
  new GoalCommitmentDefinition('GOAL'),
4536
4838
  new GoalCommitmentDefinition('GOALS'),
4537
4839
  new InitialMessageCommitmentDefinition(),
4840
+ new UserMessageCommitmentDefinition(),
4841
+ new AgentMessageCommitmentDefinition(),
4538
4842
  new MessageCommitmentDefinition('MESSAGE'),
4539
4843
  new MessageCommitmentDefinition('MESSAGES'),
4540
4844
  new ScenarioCommitmentDefinition('SCENARIO'),
@@ -4756,6 +5060,14 @@
4756
5060
  links.push(spaceTrim__default["default"](commitment.content));
4757
5061
  continue;
4758
5062
  }
5063
+ if (commitment.type === 'META IMAGE') {
5064
+ meta.image = spaceTrim__default["default"](commitment.content);
5065
+ continue;
5066
+ }
5067
+ if (commitment.type === 'META COLOR') {
5068
+ meta.color = spaceTrim__default["default"](commitment.content);
5069
+ continue;
5070
+ }
4759
5071
  if (commitment.type !== 'META') {
4760
5072
  continue;
4761
5073
  }
@@ -4771,6 +5083,10 @@
4771
5083
  if (!meta.image) {
4772
5084
  meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
4773
5085
  }
5086
+ // Generate fullname fallback if no meta fullname specified
5087
+ if (!meta.fullname) {
5088
+ meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
5089
+ }
4774
5090
  // Parse parameters using unified approach - both @Parameter and {parameter} notations
4775
5091
  // are treated as the same syntax feature with unified representation
4776
5092
  const parameters = parseParameters(agentSource);