@promptbook/wizard 0.103.0-56 → 0.103.0-66

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 (29) hide show
  1. package/esm/index.es.js +65 -10
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +2 -2
  4. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  5. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  6. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
  7. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +3 -0
  8. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  9. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
  10. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
  11. package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
  12. package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +4 -0
  13. package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
  14. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +4 -0
  15. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  16. package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -1
  17. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  18. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  19. package/esm/typings/src/utils/color/Color.d.ts +1 -1
  20. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +6 -0
  21. package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
  22. package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
  23. package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
  24. package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
  25. package/esm/typings/src/version.d.ts +1 -1
  26. package/package.json +3 -3
  27. package/umd/index.umd.js +65 -10
  28. package/umd/index.umd.js.map +1 -1
  29. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +0 -29
package/esm/index.es.js CHANGED
@@ -36,7 +36,7 @@ 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-56';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-66';
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
@@ -363,15 +363,33 @@ class Color {
363
363
  * @param color
364
364
  * @returns Color object
365
365
  */
366
- static from(color) {
367
- if (color instanceof Color) {
366
+ static from(color, _isSingleValue = false) {
367
+ if (color === '') {
368
+ throw new Error(`Can not create color from empty string`);
369
+ }
370
+ else if (color instanceof Color) {
368
371
  return take(color);
369
372
  }
370
373
  else if (Color.isColor(color)) {
371
374
  return take(color);
372
375
  }
373
376
  else if (typeof color === 'string') {
374
- return Color.fromString(color);
377
+ try {
378
+ return Color.fromString(color);
379
+ }
380
+ catch (error) {
381
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
382
+ if (_isSingleValue) {
383
+ throw error;
384
+ }
385
+ const parts = color.split(/[\s+,;|]/);
386
+ if (parts.length > 0) {
387
+ return Color.from(parts[0].trim(), true);
388
+ }
389
+ else {
390
+ throw new Error(`Can not create color from given string "${color}"`);
391
+ }
392
+ }
375
393
  }
376
394
  else {
377
395
  console.error({ color });
@@ -13477,15 +13495,19 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
13477
13495
  *
13478
13496
  * @private - TODO: [🧠] Maybe should be public?
13479
13497
  */
13480
- function createCommitmentRegex(commitment, aliases = []) {
13498
+ function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
13481
13499
  const allCommitments = [commitment, ...aliases];
13482
13500
  const patterns = allCommitments.map((c) => {
13483
13501
  const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13484
13502
  return escapedCommitment.split(/\s+/).join('\\s+');
13485
13503
  });
13486
13504
  const keywordPattern = patterns.join('|');
13487
- const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
13488
- return regex;
13505
+ if (requiresContent) {
13506
+ return new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
13507
+ }
13508
+ else {
13509
+ return new RegExp(`^\\s*(?<type>${keywordPattern})\\b(?:\\s+(?<contents>.+))?$`, 'gim');
13510
+ }
13489
13511
  }
13490
13512
  /**
13491
13513
  * Generates a regex pattern to match a specific commitment type
@@ -13518,12 +13540,20 @@ class BaseCommitmentDefinition {
13518
13540
  this.type = type;
13519
13541
  this.aliases = aliases;
13520
13542
  }
13543
+ /**
13544
+ * Whether this commitment requires content.
13545
+ * If true, regex will match only if there is content after the commitment keyword.
13546
+ * If false, regex will match even if there is no content.
13547
+ */
13548
+ get requiresContent() {
13549
+ return true;
13550
+ }
13521
13551
  /**
13522
13552
  * Creates a regex pattern to match this commitment in agent source
13523
13553
  * Uses the existing createCommitmentRegex function as internal helper
13524
13554
  */
13525
13555
  createRegex() {
13526
- return createCommitmentRegex(this.type, this.aliases);
13556
+ return createCommitmentRegex(this.type, this.aliases, this.requiresContent);
13527
13557
  }
13528
13558
  /**
13529
13559
  * Creates a regex pattern to match just the commitment type
@@ -13675,6 +13705,12 @@ class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
13675
13705
  constructor() {
13676
13706
  super('CLOSED');
13677
13707
  }
13708
+ /**
13709
+ * The `CLOSED` commitment is standalone.
13710
+ */
13711
+ get requiresContent() {
13712
+ return false;
13713
+ }
13678
13714
  /**
13679
13715
  * Short one-line description of CLOSED.
13680
13716
  */
@@ -16354,6 +16390,12 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
16354
16390
  constructor() {
16355
16391
  super('USE BROWSER', ['BROWSER']);
16356
16392
  }
16393
+ /**
16394
+ * The `USE BROWSER` commitment is standalone.
16395
+ */
16396
+ get requiresContent() {
16397
+ return false;
16398
+ }
16357
16399
  /**
16358
16400
  * Short one-line description of USE BROWSER.
16359
16401
  */
@@ -17575,11 +17617,11 @@ function parseAgentSource(agentSource) {
17575
17617
  continue;
17576
17618
  }
17577
17619
  if (commitment.type === 'META COLOR') {
17578
- meta.color = spaceTrim$2(commitment.content);
17620
+ meta.color = normalizeSeparator(commitment.content);
17579
17621
  continue;
17580
17622
  }
17581
17623
  if (commitment.type === 'META FONT') {
17582
- meta.font = spaceTrim$2(commitment.content);
17624
+ meta.font = normalizeSeparator(commitment.content);
17583
17625
  continue;
17584
17626
  }
17585
17627
  if (commitment.type !== 'META') {
@@ -17615,6 +17657,19 @@ function parseAgentSource(agentSource) {
17615
17657
  parameters,
17616
17658
  };
17617
17659
  }
17660
+ /**
17661
+ * Normalizes the separator in the content
17662
+ *
17663
+ * @param content - The content to normalize
17664
+ * @returns The content with normalized separators
17665
+ */
17666
+ function normalizeSeparator(content) {
17667
+ const trimmed = spaceTrim$2(content);
17668
+ if (trimmed.includes(',')) {
17669
+ return trimmed;
17670
+ }
17671
+ return trimmed.split(/\s+/).join(', ');
17672
+ }
17618
17673
  /**
17619
17674
  * TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
17620
17675
  */