@promptbook/wizard 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 +344 -11
  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 +344 -11
  30. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -48,12 +48,23 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-51';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-53';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
55
55
  */
56
56
 
57
+ /**
58
+ * Core Promptbook server configuration.
59
+ *
60
+ * This server is also used for auto-federation in the Agents Server.
61
+ */
62
+ const CORE_SERVER = {
63
+ title: 'Promptbook Core',
64
+ description: `Core Promptbook server used for auto-federation`,
65
+ owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
66
+ urls: ['https://core.ptbk.io/'],
67
+ };
57
68
  /**
58
69
  * Available remote servers for the Promptbook
59
70
  *
@@ -75,6 +86,7 @@
75
86
  owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
76
87
  urls: ['https://s6.ptbk.io/'],
77
88
  },
89
+ CORE_SERVER,
78
90
  /*
79
91
  Note: Working on older version of Promptbook and not supported anymore
80
92
  {
@@ -87,7 +99,6 @@
87
99
  */
88
100
  ];
89
101
  /**
90
- * TODO: [🐱‍🚀] Auto-federated server from url in here
91
102
  * Note: [💞] Ignore a discrepancy between file name and entity name
92
103
  */
93
104
 
@@ -7074,12 +7085,15 @@
7074
7085
  fileStreams.push(file);
7075
7086
  }
7076
7087
  else {
7088
+ /*
7089
+ TODO: [🐱‍🚀] Resolve problem with browser environment
7077
7090
  // Assume it's a local file path
7078
7091
  // Note: This will work in Node.js environment
7079
7092
  // For browser environments, this would need different handling
7080
7093
  const fs = await import('fs');
7081
7094
  const fileStream = fs.createReadStream(source);
7082
7095
  fileStreams.push(fileStream);
7096
+ */
7083
7097
  }
7084
7098
  }
7085
7099
  catch (error) {
@@ -7168,12 +7182,15 @@
7168
7182
  fileStreams.push(file);
7169
7183
  }
7170
7184
  else {
7185
+ /*
7186
+ TODO: [🐱‍🚀] Resolve problem with browser environment
7171
7187
  // Assume it's a local file path
7172
7188
  // Note: This will work in Node.js environment
7173
7189
  // For browser environments, this would need different handling
7174
7190
  const fs = await import('fs');
7175
7191
  const fileStream = fs.createReadStream(source);
7176
7192
  fileStreams.push(fileStream);
7193
+ */
7177
7194
  }
7178
7195
  }
7179
7196
  catch (error) {
@@ -13430,9 +13447,13 @@
13430
13447
  *
13431
13448
  * @private - TODO: [🧠] Maybe should be public?
13432
13449
  */
13433
- function createCommitmentRegex(commitment) {
13434
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13435
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
13450
+ function createCommitmentRegex(commitment, aliases = []) {
13451
+ const allCommitments = [commitment, ...aliases];
13452
+ const patterns = allCommitments.map((c) => {
13453
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13454
+ return escapedCommitment.split(/\s+/).join('\\s+');
13455
+ });
13456
+ const keywordPattern = patterns.join('|');
13436
13457
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
13437
13458
  return regex;
13438
13459
  }
@@ -13445,9 +13466,13 @@
13445
13466
  *
13446
13467
  * @private
13447
13468
  */
13448
- function createCommitmentTypeRegex(commitment) {
13449
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13450
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
13469
+ function createCommitmentTypeRegex(commitment, aliases = []) {
13470
+ const allCommitments = [commitment, ...aliases];
13471
+ const patterns = allCommitments.map((c) => {
13472
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13473
+ return escapedCommitment.split(/\s+/).join('\\s+');
13474
+ });
13475
+ const keywordPattern = patterns.join('|');
13451
13476
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
13452
13477
  return regex;
13453
13478
  }
@@ -13459,22 +13484,23 @@
13459
13484
  * @private
13460
13485
  */
13461
13486
  class BaseCommitmentDefinition {
13462
- constructor(type) {
13487
+ constructor(type, aliases = []) {
13463
13488
  this.type = type;
13489
+ this.aliases = aliases;
13464
13490
  }
13465
13491
  /**
13466
13492
  * Creates a regex pattern to match this commitment in agent source
13467
13493
  * Uses the existing createCommitmentRegex function as internal helper
13468
13494
  */
13469
13495
  createRegex() {
13470
- return createCommitmentRegex(this.type);
13496
+ return createCommitmentRegex(this.type, this.aliases);
13471
13497
  }
13472
13498
  /**
13473
13499
  * Creates a regex pattern to match just the commitment type
13474
13500
  * Uses the existing createCommitmentTypeRegex function as internal helper
13475
13501
  */
13476
13502
  createTypeRegex() {
13477
- return createCommitmentTypeRegex(this.type);
13503
+ return createCommitmentTypeRegex(this.type, this.aliases);
13478
13504
  }
13479
13505
  /**
13480
13506
  * Helper method to create a new requirements object with updated system message
@@ -14085,6 +14111,77 @@
14085
14111
  * Note: [💞] Ignore a discrepancy between file name and entity name
14086
14112
  */
14087
14113
 
14114
+ /**
14115
+ * AGENT MESSAGE commitment definition
14116
+ *
14117
+ * The AGENT MESSAGE commitment defines a message from the agent in the conversation history.
14118
+ * It is used to pre-fill the chat with a conversation history or to provide few-shot examples.
14119
+ *
14120
+ * Example usage in agent source:
14121
+ *
14122
+ * ```book
14123
+ * AGENT MESSAGE What seems to be the issue?
14124
+ * ```
14125
+ *
14126
+ * @private [🪔] Maybe export the commitments through some package
14127
+ */
14128
+ class AgentMessageCommitmentDefinition extends BaseCommitmentDefinition {
14129
+ constructor() {
14130
+ super('AGENT MESSAGE');
14131
+ }
14132
+ /**
14133
+ * Short one-line description of AGENT MESSAGE.
14134
+ */
14135
+ get description() {
14136
+ return 'Defines a **message from the agent** in the conversation history.';
14137
+ }
14138
+ /**
14139
+ * Markdown documentation for AGENT MESSAGE commitment.
14140
+ */
14141
+ get documentation() {
14142
+ return spaceTrim.spaceTrim(`
14143
+ # ${this.type}
14144
+
14145
+ 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.
14146
+
14147
+ ## Key aspects
14148
+
14149
+ - Represents a message sent by the agent.
14150
+ - Used for setting up conversation context.
14151
+ - Can be used in conjunction with USER MESSAGE.
14152
+
14153
+ ## Examples
14154
+
14155
+ \`\`\`book
14156
+ Conversation History
14157
+
14158
+ USER MESSAGE Hello, I have a problem.
14159
+ AGENT MESSAGE What seems to be the issue?
14160
+ USER MESSAGE My computer is not starting.
14161
+ \`\`\`
14162
+ `);
14163
+ }
14164
+ applyToAgentModelRequirements(requirements, content) {
14165
+ // AGENT MESSAGE is for UI display purposes / conversation history construction
14166
+ // and typically doesn't need to be added to the system prompt or model requirements directly.
14167
+ // It is extracted separately for the chat interface.
14168
+ var _a;
14169
+ const pendingUserMessage = (_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.pendingUserMessage;
14170
+ if (pendingUserMessage) {
14171
+ const newSample = { question: pendingUserMessage, answer: content };
14172
+ const newSamples = [...(requirements.samples || []), newSample];
14173
+ const newMetadata = { ...requirements.metadata };
14174
+ delete newMetadata.pendingUserMessage;
14175
+ return {
14176
+ ...requirements,
14177
+ samples: newSamples,
14178
+ metadata: newMetadata,
14179
+ };
14180
+ }
14181
+ return requirements;
14182
+ }
14183
+ }
14184
+
14088
14185
  /**
14089
14186
  * INITIAL MESSAGE commitment definition
14090
14187
  *
@@ -14249,6 +14346,67 @@
14249
14346
  * Note: [💞] Ignore a discrepancy between file name and entity name
14250
14347
  */
14251
14348
 
14349
+ /**
14350
+ * USER MESSAGE commitment definition
14351
+ *
14352
+ * The USER MESSAGE commitment defines a message from the user in the conversation history.
14353
+ * It is used to pre-fill the chat with a conversation history or to provide few-shot examples.
14354
+ *
14355
+ * Example usage in agent source:
14356
+ *
14357
+ * ```book
14358
+ * USER MESSAGE Hello, I have a problem.
14359
+ * ```
14360
+ *
14361
+ * @private [🪔] Maybe export the commitments through some package
14362
+ */
14363
+ class UserMessageCommitmentDefinition extends BaseCommitmentDefinition {
14364
+ constructor() {
14365
+ super('USER MESSAGE');
14366
+ }
14367
+ /**
14368
+ * Short one-line description of USER MESSAGE.
14369
+ */
14370
+ get description() {
14371
+ return 'Defines a **message from the user** in the conversation history.';
14372
+ }
14373
+ /**
14374
+ * Markdown documentation for USER MESSAGE commitment.
14375
+ */
14376
+ get documentation() {
14377
+ return spaceTrim.spaceTrim(`
14378
+ # ${this.type}
14379
+
14380
+ 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.
14381
+
14382
+ ## Key aspects
14383
+
14384
+ - Represents a message sent by the user.
14385
+ - Used for setting up conversation context.
14386
+ - Can be used in conjunction with AGENT MESSAGE.
14387
+
14388
+ ## Examples
14389
+
14390
+ \`\`\`book
14391
+ Conversation History
14392
+
14393
+ USER MESSAGE Hello, I have a problem.
14394
+ AGENT MESSAGE What seems to be the issue?
14395
+ USER MESSAGE My computer is not starting.
14396
+ \`\`\`
14397
+ `);
14398
+ }
14399
+ applyToAgentModelRequirements(requirements, content) {
14400
+ return {
14401
+ ...requirements,
14402
+ metadata: {
14403
+ ...requirements.metadata,
14404
+ pendingUserMessage: content,
14405
+ },
14406
+ };
14407
+ }
14408
+ }
14409
+
14252
14410
  /**
14253
14411
  * META commitment definition
14254
14412
  *
@@ -14386,6 +14544,165 @@
14386
14544
  * Note: [💞] Ignore a discrepancy between file name and entity name
14387
14545
  */
14388
14546
 
14547
+ /**
14548
+ * META COLOR commitment definition
14549
+ *
14550
+ * The META COLOR commitment sets the agent's accent color.
14551
+ * This commitment is special because it doesn't affect the system message,
14552
+ * but is handled separately in the parsing logic.
14553
+ *
14554
+ * Example usage in agent source:
14555
+ *
14556
+ * ```book
14557
+ * META COLOR #ff0000
14558
+ * META COLOR #00ff00
14559
+ * ```
14560
+ *
14561
+ * @private [🪔] Maybe export the commitments through some package
14562
+ */
14563
+ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
14564
+ constructor() {
14565
+ super('META COLOR', ['COLOR']);
14566
+ }
14567
+ /**
14568
+ * Short one-line description of META COLOR.
14569
+ */
14570
+ get description() {
14571
+ return "Set the agent's accent color.";
14572
+ }
14573
+ /**
14574
+ * Markdown documentation for META COLOR commitment.
14575
+ */
14576
+ get documentation() {
14577
+ return spaceTrim.spaceTrim(`
14578
+ # META COLOR
14579
+
14580
+ Sets the agent's accent color.
14581
+
14582
+ ## Key aspects
14583
+
14584
+ - Does not modify the agent's behavior or responses.
14585
+ - Only one \`META COLOR\` should be used per agent.
14586
+ - If multiple are specified, the last one takes precedence.
14587
+ - Used for visual representation in user interfaces.
14588
+
14589
+ ## Examples
14590
+
14591
+ \`\`\`book
14592
+ Professional Assistant
14593
+
14594
+ META COLOR #3498db
14595
+ PERSONA You are a professional business assistant
14596
+ \`\`\`
14597
+
14598
+ \`\`\`book
14599
+ Creative Helper
14600
+
14601
+ META COLOR #e74c3c
14602
+ PERSONA You are a creative and inspiring assistant
14603
+ \`\`\`
14604
+ `);
14605
+ }
14606
+ applyToAgentModelRequirements(requirements, content) {
14607
+ // META COLOR doesn't modify the system message or model requirements
14608
+ // It's handled separately in the parsing logic for profile color extraction
14609
+ // This method exists for consistency with the CommitmentDefinition interface
14610
+ return requirements;
14611
+ }
14612
+ /**
14613
+ * Extracts the profile color from the content
14614
+ * This is used by the parsing logic
14615
+ */
14616
+ extractProfileColor(content) {
14617
+ const trimmedContent = content.trim();
14618
+ return trimmedContent || null;
14619
+ }
14620
+ }
14621
+ /**
14622
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14623
+ */
14624
+
14625
+ /**
14626
+ * META IMAGE commitment definition
14627
+ *
14628
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
14629
+ * This commitment is special because it doesn't affect the system message,
14630
+ * but is handled separately in the parsing logic.
14631
+ *
14632
+ * Example usage in agent source:
14633
+ *
14634
+ * ```book
14635
+ * META IMAGE https://example.com/avatar.jpg
14636
+ * META IMAGE /assets/agent-avatar.png
14637
+ * ```
14638
+ *
14639
+ * @private [🪔] Maybe export the commitments through some package
14640
+ */
14641
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
14642
+ constructor() {
14643
+ super('META IMAGE', ['IMAGE']);
14644
+ }
14645
+ /**
14646
+ * Short one-line description of META IMAGE.
14647
+ */
14648
+ get description() {
14649
+ return "Set the agent's profile image URL.";
14650
+ }
14651
+ /**
14652
+ * Markdown documentation for META IMAGE commitment.
14653
+ */
14654
+ get documentation() {
14655
+ return spaceTrim.spaceTrim(`
14656
+ # META IMAGE
14657
+
14658
+ Sets the agent's avatar/profile image URL.
14659
+
14660
+ ## Key aspects
14661
+
14662
+ - Does not modify the agent's behavior or responses.
14663
+ - Only one \`META IMAGE\` should be used per agent.
14664
+ - If multiple are specified, the last one takes precedence.
14665
+ - Used for visual representation in user interfaces.
14666
+
14667
+ ## Examples
14668
+
14669
+ \`\`\`book
14670
+ Professional Assistant
14671
+
14672
+ META IMAGE https://example.com/professional-avatar.jpg
14673
+ PERSONA You are a professional business assistant
14674
+ STYLE Maintain a formal and courteous tone
14675
+ \`\`\`
14676
+
14677
+ \`\`\`book
14678
+ Creative Helper
14679
+
14680
+ META IMAGE /assets/creative-bot-avatar.png
14681
+ PERSONA You are a creative and inspiring assistant
14682
+ STYLE Be enthusiastic and encouraging
14683
+ ACTION Can help with brainstorming and ideation
14684
+ \`\`\`
14685
+ `);
14686
+ }
14687
+ applyToAgentModelRequirements(requirements, content) {
14688
+ // META IMAGE doesn't modify the system message or model requirements
14689
+ // It's handled separately in the parsing logic for profile image extraction
14690
+ // This method exists for consistency with the CommitmentDefinition interface
14691
+ return requirements;
14692
+ }
14693
+ /**
14694
+ * Extracts the profile image URL from the content
14695
+ * This is used by the parsing logic
14696
+ */
14697
+ extractProfileImageUrl(content) {
14698
+ const trimmedContent = content.trim();
14699
+ return trimmedContent || null;
14700
+ }
14701
+ }
14702
+ /**
14703
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14704
+ */
14705
+
14389
14706
  /**
14390
14707
  * MODEL commitment definition
14391
14708
  *
@@ -15293,6 +15610,8 @@
15293
15610
  new ModelCommitmentDefinition('MODELS'),
15294
15611
  new ActionCommitmentDefinition('ACTION'),
15295
15612
  new ActionCommitmentDefinition('ACTIONS'),
15613
+ new MetaImageCommitmentDefinition(),
15614
+ new MetaColorCommitmentDefinition(),
15296
15615
  new MetaCommitmentDefinition(),
15297
15616
  new NoteCommitmentDefinition('NOTE'),
15298
15617
  new NoteCommitmentDefinition('NOTES'),
@@ -15301,6 +15620,8 @@
15301
15620
  new GoalCommitmentDefinition('GOAL'),
15302
15621
  new GoalCommitmentDefinition('GOALS'),
15303
15622
  new InitialMessageCommitmentDefinition(),
15623
+ new UserMessageCommitmentDefinition(),
15624
+ new AgentMessageCommitmentDefinition(),
15304
15625
  new MessageCommitmentDefinition('MESSAGE'),
15305
15626
  new MessageCommitmentDefinition('MESSAGES'),
15306
15627
  new ScenarioCommitmentDefinition('SCENARIO'),
@@ -16126,6 +16447,14 @@
16126
16447
  links.push(spaceTrim__default["default"](commitment.content));
16127
16448
  continue;
16128
16449
  }
16450
+ if (commitment.type === 'META IMAGE') {
16451
+ meta.image = spaceTrim__default["default"](commitment.content);
16452
+ continue;
16453
+ }
16454
+ if (commitment.type === 'META COLOR') {
16455
+ meta.color = spaceTrim__default["default"](commitment.content);
16456
+ continue;
16457
+ }
16129
16458
  if (commitment.type !== 'META') {
16130
16459
  continue;
16131
16460
  }
@@ -16141,6 +16470,10 @@
16141
16470
  if (!meta.image) {
16142
16471
  meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
16143
16472
  }
16473
+ // Generate fullname fallback if no meta fullname specified
16474
+ if (!meta.fullname) {
16475
+ meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
16476
+ }
16144
16477
  // Parse parameters using unified approach - both @Parameter and {parameter} notations
16145
16478
  // are treated as the same syntax feature with unified representation
16146
16479
  const parameters = parseParameters(agentSource);