@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/esm/index.es.js CHANGED
@@ -36,12 +36,23 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
36
36
  * @generated
37
37
  * @see https://github.com/webgptorg/promptbook
38
38
  */
39
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-51';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-53';
40
40
  /**
41
41
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
42
42
  * Note: [💞] Ignore a discrepancy between file name and entity name
43
43
  */
44
44
 
45
+ /**
46
+ * Core Promptbook server configuration.
47
+ *
48
+ * This server is also used for auto-federation in the Agents Server.
49
+ */
50
+ const CORE_SERVER = {
51
+ title: 'Promptbook Core',
52
+ description: `Core Promptbook server used for auto-federation`,
53
+ owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
54
+ urls: ['https://core.ptbk.io/'],
55
+ };
45
56
  /**
46
57
  * Available remote servers for the Promptbook
47
58
  *
@@ -63,6 +74,7 @@ const REMOTE_SERVER_URLS = [
63
74
  owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
64
75
  urls: ['https://s6.ptbk.io/'],
65
76
  },
77
+ CORE_SERVER,
66
78
  /*
67
79
  Note: Working on older version of Promptbook and not supported anymore
68
80
  {
@@ -75,7 +87,6 @@ const REMOTE_SERVER_URLS = [
75
87
  */
76
88
  ];
77
89
  /**
78
- * TODO: [🐱‍🚀] Auto-federated server from url in here
79
90
  * Note: [💞] Ignore a discrepancy between file name and entity name
80
91
  */
81
92
 
@@ -7062,12 +7073,15 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
7062
7073
  fileStreams.push(file);
7063
7074
  }
7064
7075
  else {
7076
+ /*
7077
+ TODO: [🐱‍🚀] Resolve problem with browser environment
7065
7078
  // Assume it's a local file path
7066
7079
  // Note: This will work in Node.js environment
7067
7080
  // For browser environments, this would need different handling
7068
7081
  const fs = await import('fs');
7069
7082
  const fileStream = fs.createReadStream(source);
7070
7083
  fileStreams.push(fileStream);
7084
+ */
7071
7085
  }
7072
7086
  }
7073
7087
  catch (error) {
@@ -7156,12 +7170,15 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
7156
7170
  fileStreams.push(file);
7157
7171
  }
7158
7172
  else {
7173
+ /*
7174
+ TODO: [🐱‍🚀] Resolve problem with browser environment
7159
7175
  // Assume it's a local file path
7160
7176
  // Note: This will work in Node.js environment
7161
7177
  // For browser environments, this would need different handling
7162
7178
  const fs = await import('fs');
7163
7179
  const fileStream = fs.createReadStream(source);
7164
7180
  fileStreams.push(fileStream);
7181
+ */
7165
7182
  }
7166
7183
  }
7167
7184
  catch (error) {
@@ -13418,9 +13435,13 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
13418
13435
  *
13419
13436
  * @private - TODO: [🧠] Maybe should be public?
13420
13437
  */
13421
- function createCommitmentRegex(commitment) {
13422
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13423
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
13438
+ function createCommitmentRegex(commitment, aliases = []) {
13439
+ const allCommitments = [commitment, ...aliases];
13440
+ const patterns = allCommitments.map((c) => {
13441
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13442
+ return escapedCommitment.split(/\s+/).join('\\s+');
13443
+ });
13444
+ const keywordPattern = patterns.join('|');
13424
13445
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
13425
13446
  return regex;
13426
13447
  }
@@ -13433,9 +13454,13 @@ function createCommitmentRegex(commitment) {
13433
13454
  *
13434
13455
  * @private
13435
13456
  */
13436
- function createCommitmentTypeRegex(commitment) {
13437
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13438
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
13457
+ function createCommitmentTypeRegex(commitment, aliases = []) {
13458
+ const allCommitments = [commitment, ...aliases];
13459
+ const patterns = allCommitments.map((c) => {
13460
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13461
+ return escapedCommitment.split(/\s+/).join('\\s+');
13462
+ });
13463
+ const keywordPattern = patterns.join('|');
13439
13464
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
13440
13465
  return regex;
13441
13466
  }
@@ -13447,22 +13472,23 @@ function createCommitmentTypeRegex(commitment) {
13447
13472
  * @private
13448
13473
  */
13449
13474
  class BaseCommitmentDefinition {
13450
- constructor(type) {
13475
+ constructor(type, aliases = []) {
13451
13476
  this.type = type;
13477
+ this.aliases = aliases;
13452
13478
  }
13453
13479
  /**
13454
13480
  * Creates a regex pattern to match this commitment in agent source
13455
13481
  * Uses the existing createCommitmentRegex function as internal helper
13456
13482
  */
13457
13483
  createRegex() {
13458
- return createCommitmentRegex(this.type);
13484
+ return createCommitmentRegex(this.type, this.aliases);
13459
13485
  }
13460
13486
  /**
13461
13487
  * Creates a regex pattern to match just the commitment type
13462
13488
  * Uses the existing createCommitmentTypeRegex function as internal helper
13463
13489
  */
13464
13490
  createTypeRegex() {
13465
- return createCommitmentTypeRegex(this.type);
13491
+ return createCommitmentTypeRegex(this.type, this.aliases);
13466
13492
  }
13467
13493
  /**
13468
13494
  * Helper method to create a new requirements object with updated system message
@@ -14073,6 +14099,77 @@ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
14073
14099
  * Note: [💞] Ignore a discrepancy between file name and entity name
14074
14100
  */
14075
14101
 
14102
+ /**
14103
+ * AGENT MESSAGE commitment definition
14104
+ *
14105
+ * The AGENT MESSAGE commitment defines a message from the agent in the conversation history.
14106
+ * It is used to pre-fill the chat with a conversation history or to provide few-shot examples.
14107
+ *
14108
+ * Example usage in agent source:
14109
+ *
14110
+ * ```book
14111
+ * AGENT MESSAGE What seems to be the issue?
14112
+ * ```
14113
+ *
14114
+ * @private [🪔] Maybe export the commitments through some package
14115
+ */
14116
+ class AgentMessageCommitmentDefinition extends BaseCommitmentDefinition {
14117
+ constructor() {
14118
+ super('AGENT MESSAGE');
14119
+ }
14120
+ /**
14121
+ * Short one-line description of AGENT MESSAGE.
14122
+ */
14123
+ get description() {
14124
+ return 'Defines a **message from the agent** in the conversation history.';
14125
+ }
14126
+ /**
14127
+ * Markdown documentation for AGENT MESSAGE commitment.
14128
+ */
14129
+ get documentation() {
14130
+ return spaceTrim$1(`
14131
+ # ${this.type}
14132
+
14133
+ 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.
14134
+
14135
+ ## Key aspects
14136
+
14137
+ - Represents a message sent by the agent.
14138
+ - Used for setting up conversation context.
14139
+ - Can be used in conjunction with USER MESSAGE.
14140
+
14141
+ ## Examples
14142
+
14143
+ \`\`\`book
14144
+ Conversation History
14145
+
14146
+ USER MESSAGE Hello, I have a problem.
14147
+ AGENT MESSAGE What seems to be the issue?
14148
+ USER MESSAGE My computer is not starting.
14149
+ \`\`\`
14150
+ `);
14151
+ }
14152
+ applyToAgentModelRequirements(requirements, content) {
14153
+ // AGENT MESSAGE is for UI display purposes / conversation history construction
14154
+ // and typically doesn't need to be added to the system prompt or model requirements directly.
14155
+ // It is extracted separately for the chat interface.
14156
+ var _a;
14157
+ const pendingUserMessage = (_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.pendingUserMessage;
14158
+ if (pendingUserMessage) {
14159
+ const newSample = { question: pendingUserMessage, answer: content };
14160
+ const newSamples = [...(requirements.samples || []), newSample];
14161
+ const newMetadata = { ...requirements.metadata };
14162
+ delete newMetadata.pendingUserMessage;
14163
+ return {
14164
+ ...requirements,
14165
+ samples: newSamples,
14166
+ metadata: newMetadata,
14167
+ };
14168
+ }
14169
+ return requirements;
14170
+ }
14171
+ }
14172
+
14076
14173
  /**
14077
14174
  * INITIAL MESSAGE commitment definition
14078
14175
  *
@@ -14237,6 +14334,67 @@ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
14237
14334
  * Note: [💞] Ignore a discrepancy between file name and entity name
14238
14335
  */
14239
14336
 
14337
+ /**
14338
+ * USER MESSAGE commitment definition
14339
+ *
14340
+ * The USER MESSAGE commitment defines a message from the user in the conversation history.
14341
+ * It is used to pre-fill the chat with a conversation history or to provide few-shot examples.
14342
+ *
14343
+ * Example usage in agent source:
14344
+ *
14345
+ * ```book
14346
+ * USER MESSAGE Hello, I have a problem.
14347
+ * ```
14348
+ *
14349
+ * @private [🪔] Maybe export the commitments through some package
14350
+ */
14351
+ class UserMessageCommitmentDefinition extends BaseCommitmentDefinition {
14352
+ constructor() {
14353
+ super('USER MESSAGE');
14354
+ }
14355
+ /**
14356
+ * Short one-line description of USER MESSAGE.
14357
+ */
14358
+ get description() {
14359
+ return 'Defines a **message from the user** in the conversation history.';
14360
+ }
14361
+ /**
14362
+ * Markdown documentation for USER MESSAGE commitment.
14363
+ */
14364
+ get documentation() {
14365
+ return spaceTrim$1(`
14366
+ # ${this.type}
14367
+
14368
+ 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.
14369
+
14370
+ ## Key aspects
14371
+
14372
+ - Represents a message sent by the user.
14373
+ - Used for setting up conversation context.
14374
+ - Can be used in conjunction with AGENT MESSAGE.
14375
+
14376
+ ## Examples
14377
+
14378
+ \`\`\`book
14379
+ Conversation History
14380
+
14381
+ USER MESSAGE Hello, I have a problem.
14382
+ AGENT MESSAGE What seems to be the issue?
14383
+ USER MESSAGE My computer is not starting.
14384
+ \`\`\`
14385
+ `);
14386
+ }
14387
+ applyToAgentModelRequirements(requirements, content) {
14388
+ return {
14389
+ ...requirements,
14390
+ metadata: {
14391
+ ...requirements.metadata,
14392
+ pendingUserMessage: content,
14393
+ },
14394
+ };
14395
+ }
14396
+ }
14397
+
14240
14398
  /**
14241
14399
  * META commitment definition
14242
14400
  *
@@ -14374,6 +14532,165 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
14374
14532
  * Note: [💞] Ignore a discrepancy between file name and entity name
14375
14533
  */
14376
14534
 
14535
+ /**
14536
+ * META COLOR commitment definition
14537
+ *
14538
+ * The META COLOR commitment sets the agent's accent color.
14539
+ * This commitment is special because it doesn't affect the system message,
14540
+ * but is handled separately in the parsing logic.
14541
+ *
14542
+ * Example usage in agent source:
14543
+ *
14544
+ * ```book
14545
+ * META COLOR #ff0000
14546
+ * META COLOR #00ff00
14547
+ * ```
14548
+ *
14549
+ * @private [🪔] Maybe export the commitments through some package
14550
+ */
14551
+ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
14552
+ constructor() {
14553
+ super('META COLOR', ['COLOR']);
14554
+ }
14555
+ /**
14556
+ * Short one-line description of META COLOR.
14557
+ */
14558
+ get description() {
14559
+ return "Set the agent's accent color.";
14560
+ }
14561
+ /**
14562
+ * Markdown documentation for META COLOR commitment.
14563
+ */
14564
+ get documentation() {
14565
+ return spaceTrim$1(`
14566
+ # META COLOR
14567
+
14568
+ Sets the agent's accent color.
14569
+
14570
+ ## Key aspects
14571
+
14572
+ - Does not modify the agent's behavior or responses.
14573
+ - Only one \`META COLOR\` should be used per agent.
14574
+ - If multiple are specified, the last one takes precedence.
14575
+ - Used for visual representation in user interfaces.
14576
+
14577
+ ## Examples
14578
+
14579
+ \`\`\`book
14580
+ Professional Assistant
14581
+
14582
+ META COLOR #3498db
14583
+ PERSONA You are a professional business assistant
14584
+ \`\`\`
14585
+
14586
+ \`\`\`book
14587
+ Creative Helper
14588
+
14589
+ META COLOR #e74c3c
14590
+ PERSONA You are a creative and inspiring assistant
14591
+ \`\`\`
14592
+ `);
14593
+ }
14594
+ applyToAgentModelRequirements(requirements, content) {
14595
+ // META COLOR doesn't modify the system message or model requirements
14596
+ // It's handled separately in the parsing logic for profile color extraction
14597
+ // This method exists for consistency with the CommitmentDefinition interface
14598
+ return requirements;
14599
+ }
14600
+ /**
14601
+ * Extracts the profile color from the content
14602
+ * This is used by the parsing logic
14603
+ */
14604
+ extractProfileColor(content) {
14605
+ const trimmedContent = content.trim();
14606
+ return trimmedContent || null;
14607
+ }
14608
+ }
14609
+ /**
14610
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14611
+ */
14612
+
14613
+ /**
14614
+ * META IMAGE commitment definition
14615
+ *
14616
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
14617
+ * This commitment is special because it doesn't affect the system message,
14618
+ * but is handled separately in the parsing logic.
14619
+ *
14620
+ * Example usage in agent source:
14621
+ *
14622
+ * ```book
14623
+ * META IMAGE https://example.com/avatar.jpg
14624
+ * META IMAGE /assets/agent-avatar.png
14625
+ * ```
14626
+ *
14627
+ * @private [🪔] Maybe export the commitments through some package
14628
+ */
14629
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
14630
+ constructor() {
14631
+ super('META IMAGE', ['IMAGE']);
14632
+ }
14633
+ /**
14634
+ * Short one-line description of META IMAGE.
14635
+ */
14636
+ get description() {
14637
+ return "Set the agent's profile image URL.";
14638
+ }
14639
+ /**
14640
+ * Markdown documentation for META IMAGE commitment.
14641
+ */
14642
+ get documentation() {
14643
+ return spaceTrim$1(`
14644
+ # META IMAGE
14645
+
14646
+ Sets the agent's avatar/profile image URL.
14647
+
14648
+ ## Key aspects
14649
+
14650
+ - Does not modify the agent's behavior or responses.
14651
+ - Only one \`META IMAGE\` should be used per agent.
14652
+ - If multiple are specified, the last one takes precedence.
14653
+ - Used for visual representation in user interfaces.
14654
+
14655
+ ## Examples
14656
+
14657
+ \`\`\`book
14658
+ Professional Assistant
14659
+
14660
+ META IMAGE https://example.com/professional-avatar.jpg
14661
+ PERSONA You are a professional business assistant
14662
+ STYLE Maintain a formal and courteous tone
14663
+ \`\`\`
14664
+
14665
+ \`\`\`book
14666
+ Creative Helper
14667
+
14668
+ META IMAGE /assets/creative-bot-avatar.png
14669
+ PERSONA You are a creative and inspiring assistant
14670
+ STYLE Be enthusiastic and encouraging
14671
+ ACTION Can help with brainstorming and ideation
14672
+ \`\`\`
14673
+ `);
14674
+ }
14675
+ applyToAgentModelRequirements(requirements, content) {
14676
+ // META IMAGE doesn't modify the system message or model requirements
14677
+ // It's handled separately in the parsing logic for profile image extraction
14678
+ // This method exists for consistency with the CommitmentDefinition interface
14679
+ return requirements;
14680
+ }
14681
+ /**
14682
+ * Extracts the profile image URL from the content
14683
+ * This is used by the parsing logic
14684
+ */
14685
+ extractProfileImageUrl(content) {
14686
+ const trimmedContent = content.trim();
14687
+ return trimmedContent || null;
14688
+ }
14689
+ }
14690
+ /**
14691
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14692
+ */
14693
+
14377
14694
  /**
14378
14695
  * MODEL commitment definition
14379
14696
  *
@@ -15281,6 +15598,8 @@ const COMMITMENT_REGISTRY = [
15281
15598
  new ModelCommitmentDefinition('MODELS'),
15282
15599
  new ActionCommitmentDefinition('ACTION'),
15283
15600
  new ActionCommitmentDefinition('ACTIONS'),
15601
+ new MetaImageCommitmentDefinition(),
15602
+ new MetaColorCommitmentDefinition(),
15284
15603
  new MetaCommitmentDefinition(),
15285
15604
  new NoteCommitmentDefinition('NOTE'),
15286
15605
  new NoteCommitmentDefinition('NOTES'),
@@ -15289,6 +15608,8 @@ const COMMITMENT_REGISTRY = [
15289
15608
  new GoalCommitmentDefinition('GOAL'),
15290
15609
  new GoalCommitmentDefinition('GOALS'),
15291
15610
  new InitialMessageCommitmentDefinition(),
15611
+ new UserMessageCommitmentDefinition(),
15612
+ new AgentMessageCommitmentDefinition(),
15292
15613
  new MessageCommitmentDefinition('MESSAGE'),
15293
15614
  new MessageCommitmentDefinition('MESSAGES'),
15294
15615
  new ScenarioCommitmentDefinition('SCENARIO'),
@@ -16114,6 +16435,14 @@ function parseAgentSource(agentSource) {
16114
16435
  links.push(spaceTrim(commitment.content));
16115
16436
  continue;
16116
16437
  }
16438
+ if (commitment.type === 'META IMAGE') {
16439
+ meta.image = spaceTrim(commitment.content);
16440
+ continue;
16441
+ }
16442
+ if (commitment.type === 'META COLOR') {
16443
+ meta.color = spaceTrim(commitment.content);
16444
+ continue;
16445
+ }
16117
16446
  if (commitment.type !== 'META') {
16118
16447
  continue;
16119
16448
  }
@@ -16129,6 +16458,10 @@ function parseAgentSource(agentSource) {
16129
16458
  if (!meta.image) {
16130
16459
  meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
16131
16460
  }
16461
+ // Generate fullname fallback if no meta fullname specified
16462
+ if (!meta.fullname) {
16463
+ meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
16464
+ }
16132
16465
  // Parse parameters using unified approach - both @Parameter and {parameter} notations
16133
16466
  // are treated as the same syntax feature with unified representation
16134
16467
  const parameters = parseParameters(agentSource);