@promptbook/markdown-utils 0.105.0-8 β†’ 0.105.0

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 (114) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +26 -29
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/browser.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/components.index.d.ts +20 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +21 -11
  7. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  8. package/esm/typings/src/_packages/openai.index.d.ts +4 -0
  9. package/esm/typings/src/_packages/types.index.d.ts +32 -2
  10. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  11. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +10 -1
  12. package/esm/typings/src/book-2.0/agent-source/parseTeamCommitment.d.ts +28 -0
  13. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
  14. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +5 -0
  15. package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
  16. package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
  17. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +33 -1
  18. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +87 -6
  19. package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +23 -0
  20. package/esm/typings/src/book-components/Chat/Chat/ClockIcon.d.ts +9 -0
  21. package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
  22. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  23. package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
  24. package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
  25. package/esm/typings/src/book-components/Chat/effects/ChatEffectsSystem.d.ts +14 -0
  26. package/esm/typings/src/book-components/Chat/effects/components/ConfettiEffect.d.ts +18 -0
  27. package/esm/typings/src/book-components/Chat/effects/components/HeartsEffect.d.ts +18 -0
  28. package/esm/typings/src/book-components/Chat/effects/configs/defaultEffectConfigs.d.ts +7 -0
  29. package/esm/typings/src/book-components/Chat/effects/index.d.ts +18 -0
  30. package/esm/typings/src/book-components/Chat/effects/types/ChatEffect.d.ts +20 -0
  31. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectConfig.d.ts +21 -0
  32. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectType.d.ts +6 -0
  33. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectsSystemProps.d.ts +32 -0
  34. package/esm/typings/src/book-components/Chat/effects/utils/detectEffects.d.ts +12 -0
  35. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +34 -6
  36. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +8 -0
  37. package/esm/typings/src/book-components/Chat/utils/createTeamToolNameFromUrl.d.ts +12 -0
  38. package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +40 -0
  39. package/esm/typings/src/book-components/Chat/utils/loadAgentProfile.d.ts +69 -0
  40. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
  41. package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.d.ts +11 -0
  42. package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.test.d.ts +1 -0
  43. package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +64 -0
  44. package/esm/typings/src/book-components/icons/EmailIcon.d.ts +15 -0
  45. package/esm/typings/src/commitments/TEAM/TEAM.d.ts +45 -0
  46. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
  47. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
  48. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +19 -1
  49. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
  50. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
  51. package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +48 -0
  52. package/esm/typings/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +11 -0
  53. package/esm/typings/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +18 -0
  54. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +46 -0
  55. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.test.d.ts +1 -0
  56. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +5 -0
  57. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +1 -0
  58. package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +6 -0
  59. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  60. package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +6 -0
  61. package/esm/typings/src/commitments/_base/formatOptionalInstructionBlock.d.ts +6 -0
  62. package/esm/typings/src/commitments/_common/commitmentToolFunctions.d.ts +26 -0
  63. package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
  64. package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
  65. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +9 -0
  66. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +13 -0
  67. package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
  68. package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
  69. package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
  70. package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
  71. package/esm/typings/src/commitments/index.d.ts +5 -58
  72. package/esm/typings/src/config.d.ts +6 -0
  73. package/esm/typings/src/constants.d.ts +129 -0
  74. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
  75. package/esm/typings/src/execution/AvailableModel.d.ts +5 -4
  76. package/esm/typings/src/execution/PromptResult.d.ts +2 -19
  77. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
  78. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
  79. package/esm/typings/src/llm-providers/agent/Agent.d.ts +15 -1
  80. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
  81. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +5 -0
  82. package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +1 -0
  83. package/esm/typings/src/llm-providers/openai/OpenAiAgentExecutionTools.d.ts +43 -0
  84. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +4 -2
  85. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +1 -1
  86. package/esm/typings/src/llm-providers/openai/createOpenAiAgentExecutionTools.d.ts +11 -0
  87. package/esm/typings/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +7 -0
  88. package/esm/typings/src/pipeline/prompt-notation.d.ts +27 -2
  89. package/esm/typings/src/pipeline/prompt-notation.test.d.ts +1 -1
  90. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
  91. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
  92. package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
  93. package/esm/typings/src/search-engines/SearchEngine.d.ts +1 -1
  94. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
  95. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
  96. package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +1 -1
  97. package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +1 -1
  98. package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +3 -0
  99. package/esm/typings/src/types/ModelRequirements.d.ts +6 -0
  100. package/esm/typings/src/types/Prompt.d.ts +12 -0
  101. package/esm/typings/src/types/ToolCall.d.ts +37 -0
  102. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -2
  103. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -1
  104. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -1
  105. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -1
  106. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +1 -3
  107. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -2
  108. package/esm/typings/src/utils/misc/linguisticHash.d.ts +4 -1
  109. package/esm/typings/src/utils/parameters/templateParameters.d.ts +1 -2
  110. package/esm/typings/src/version.d.ts +1 -1
  111. package/esm/typings/src/wizard/wizard.d.ts +1 -4
  112. package/package.json +1 -1
  113. package/umd/index.umd.js +26 -29
  114. package/umd/index.umd.js.map +1 -1
package/README.md CHANGED
@@ -27,10 +27,6 @@ Turn your company's scattered knowledge into AI ready Books
27
27
 
28
28
 
29
29
 
30
- <blockquote style="color: #ff8811">
31
- <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
32
- </blockquote>
33
-
34
30
  ## πŸ“¦ Package `@promptbook/markdown-utils`
35
31
 
36
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -23,7 +23,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.105.0-8';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0';
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
@@ -72,7 +72,7 @@ function capitalize(word) {
72
72
  */
73
73
  function extractAllBlocksFromMarkdown(markdown) {
74
74
  const codeBlocks = [];
75
- const lines = markdown.split('\n');
75
+ const lines = markdown.split(/\r?\n/);
76
76
  // Note: [0] Ensure that the last block notated by gt > will be closed
77
77
  lines.push('');
78
78
  let currentCodeBlock = null;
@@ -1495,7 +1495,7 @@ function isValidEmail(email) {
1495
1495
  if (typeof email !== 'string') {
1496
1496
  return false;
1497
1497
  }
1498
- if (email.split('\n').length > 1) {
1498
+ if (email.split(/\r?\n/).length > 1) {
1499
1499
  return false;
1500
1500
  }
1501
1501
  return /^.+@.+\..+$/.test(email);
@@ -1511,7 +1511,7 @@ function isValidFilePath(filename) {
1511
1511
  if (typeof filename !== 'string') {
1512
1512
  return false;
1513
1513
  }
1514
- if (filename.split('\n').length > 1) {
1514
+ if (filename.split(/\r?\n/).length > 1) {
1515
1515
  return false;
1516
1516
  }
1517
1517
  // Normalize slashes early so heuristics can detect path-like inputs
@@ -4883,7 +4883,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4883
4883
 
4884
4884
  The source:
4885
4885
  ${block(knowledgeSource.knowledgeSourceContent
4886
- .split('\n')
4886
+ .split(/\r?\n/)
4887
4887
  .map((line) => `> ${line}`)
4888
4888
  .join('\n'))}
4889
4889
 
@@ -4899,7 +4899,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4899
4899
 
4900
4900
  The source:
4901
4901
  > ${block(knowledgeSource.knowledgeSourceContent
4902
- .split('\n')
4902
+ .split(/\r?\n/)
4903
4903
  .map((line) => `> ${line}`)
4904
4904
  .join('\n'))}
4905
4905
 
@@ -5600,7 +5600,7 @@ const TextFormatParser = {
5600
5600
  subvalueName: 'LINE',
5601
5601
  async mapValues(options) {
5602
5602
  const { value, mapCallback, onProgress } = options;
5603
- const lines = value.split('\n');
5603
+ const lines = value.split(/\r?\n/);
5604
5604
  const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
5605
5605
  // TODO: [🧠] Maybe option to skip empty line
5606
5606
  /* not await */ mapCallback({
@@ -5805,7 +5805,7 @@ function templateParameters(template, parameters) {
5805
5805
  parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
5806
5806
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
5807
5807
  parameterValue = parameterValue
5808
- .split('\n')
5808
+ .split(/\r?\n/)
5809
5809
  .map((line, index) => (index === 0 ? line : `${precol}${line}`))
5810
5810
  .join('\n');
5811
5811
  }
@@ -5874,7 +5874,7 @@ function countLines(text) {
5874
5874
  }
5875
5875
  text = text.replace('\r\n', '\n');
5876
5876
  text = text.replace('\r', '\n');
5877
- const lines = text.split('\n');
5877
+ const lines = text.split(/\r?\n/);
5878
5878
  return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
5879
5879
  }
5880
5880
  /**
@@ -6349,13 +6349,13 @@ async function executeAttempts(options) {
6349
6349
  return `
6350
6350
  Attempt ${failure.attemptIndex + 1}:
6351
6351
  Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
6352
- ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
6352
+ ${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split(/\r?\n/).map((line) => `> ${line}`).join('\n'))}
6353
6353
 
6354
6354
  Result:
6355
6355
  ${block(failure.result === null
6356
6356
  ? 'null'
6357
6357
  : spaceTrim$2(failure.result)
6358
- .split('\n')
6358
+ .split(/\r?\n/)
6359
6359
  .map((line) => `> ${line}`)
6360
6360
  .join('\n'))}
6361
6361
  `;
@@ -6370,7 +6370,7 @@ async function executeAttempts(options) {
6370
6370
 
6371
6371
  The Prompt:
6372
6372
  ${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
6373
- .split('\n')
6373
+ .split(/\r?\n/)
6374
6374
  .map((line) => `> ${line}`)
6375
6375
  .join('\n'))}
6376
6376
 
@@ -7041,7 +7041,7 @@ async function executePipeline(options) {
7041
7041
  ${block(pipelineIdentification)}
7042
7042
 
7043
7043
  ${block(JSON.stringify(newOngoingResult, null, 4)
7044
- .split('\n')
7044
+ .split(/\r?\n/)
7045
7045
  .map((line) => `> ${line}`)
7046
7046
  .join('\n'))}
7047
7047
  `));
@@ -7621,7 +7621,7 @@ function escapeMarkdownBlock(value) {
7621
7621
  * @public exported from `@promptbook/markdown-utils`
7622
7622
  */
7623
7623
  function extractAllListItemsFromMarkdown(markdown) {
7624
- const lines = markdown.split('\n');
7624
+ const lines = markdown.split(/\r?\n/);
7625
7625
  const listItems = [];
7626
7626
  let isInCodeBlock = false;
7627
7627
  for (const line of lines) {
@@ -7644,7 +7644,7 @@ function extractAllListItemsFromMarkdown(markdown) {
7644
7644
  */
7645
7645
  function parseMarkdownSection(value) {
7646
7646
  var _a, _b;
7647
- const lines = value.split('\n');
7647
+ const lines = value.split(/\r?\n/);
7648
7648
  if (!lines[0].startsWith('#')) {
7649
7649
  throw new ParseError('Markdown section must start with heading');
7650
7650
  }
@@ -7669,7 +7669,7 @@ function parseMarkdownSection(value) {
7669
7669
  * @public exported from `@promptbook/markdown-utils`
7670
7670
  */
7671
7671
  function splitMarkdownIntoSections(markdown) {
7672
- const lines = markdown.split('\n');
7672
+ const lines = markdown.split(/\r?\n/);
7673
7673
  const sections = [];
7674
7674
  // TODO: [🧽] DRY
7675
7675
  let currentType = 'MARKDOWN';
@@ -7764,7 +7764,7 @@ function flattenMarkdown(markdown) {
7764
7764
  */
7765
7765
 
7766
7766
  /**
7767
- * Change ellipsis character to three dots `…` -> `...`
7767
+ * Change ellipsis characters and dot leaders to three dots `…` -> `...`
7768
7768
  *
7769
7769
  * Note: [πŸ”‚] This function is idempotent.
7770
7770
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
@@ -7772,14 +7772,14 @@ function flattenMarkdown(markdown) {
7772
7772
  * @public exported from `@promptbook/markdown-utils`
7773
7773
  */
7774
7774
  function humanizeAiTextEllipsis(aiText) {
7775
- return aiText.replace(/…/g, '...');
7775
+ return aiText.replace(/[…⋯]/g, '...').replace(/\.\s+\.\s+\./g, '...');
7776
7776
  }
7777
7777
  /**
7778
7778
  * Note: [πŸ‚] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
7779
7779
  */
7780
7780
 
7781
7781
  /**
7782
- * Change em-dashes to regular dashes `β€”` -> `-`
7782
+ * Change dash-like characters to regular dashes `β€”` -> `-` and remove soft hyphens
7783
7783
  *
7784
7784
  * Note: [πŸ”‚] This function is idempotent.
7785
7785
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
@@ -7787,7 +7787,7 @@ function humanizeAiTextEllipsis(aiText) {
7787
7787
  * @public exported from `@promptbook/markdown-utils`
7788
7788
  */
7789
7789
  function humanizeAiTextEmdashed(aiText) {
7790
- return aiText.replace(/β€”/g, '-');
7790
+ return aiText.replace(/\u00AD/g, '').replace(/[β€β€‘β€’β€“β€”β€•βˆ’βƒοΉ£οΌ]/g, '-');
7791
7791
  }
7792
7792
  /**
7793
7793
  * Note: [πŸ‚] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
@@ -7803,20 +7803,15 @@ function humanizeAiTextEmdashed(aiText) {
7803
7803
  */
7804
7804
  function humanizeAiTextQuotes(aiText) {
7805
7805
  return aiText
7806
- .replace(/[β€œβ€]/g, '"')
7807
- .replace(/[β€šβ€˜β€™]/g, "'")
7808
- .replace(/Β«/g, '"')
7809
- .replace(/Β»/g, '"')
7810
- .replace(/β€ž/g, '"')
7811
- .replace(/β€Ή/g, "'")
7812
- .replace(/β€Ί/g, "'");
7806
+ .replace(/[β€œβ€β€žβ€ŸΒ«Β»ββžγ€γ€žγ€ŸοΌ‚]/g, '"')
7807
+ .replace(/[β€šβ€˜β€™β€›β€Ήβ€Ίβ›βœοΌ‡ΚΌ]/g, "'");
7813
7808
  }
7814
7809
  /**
7815
7810
  * Note: [πŸ‚] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
7816
7811
  */
7817
7812
 
7818
7813
  /**
7819
- * Change unprintable hard spaces to regular spaces
7814
+ * Change unprintable hard spaces to regular spaces and drop zero-width spaces
7820
7815
  *
7821
7816
  * Note: [πŸ”‚] This function is idempotent.
7822
7817
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
@@ -7824,7 +7819,9 @@ function humanizeAiTextQuotes(aiText) {
7824
7819
  * @public exported from `@promptbook/markdown-utils`
7825
7820
  */
7826
7821
  function humanizeAiTextWhitespace(aiText) {
7827
- return aiText.replace(/\u00A0/g, ' ');
7822
+ return aiText
7823
+ .replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, ' ')
7824
+ .replace(/[\u200B\uFEFF\u2060]/g, '');
7828
7825
  }
7829
7826
  /**
7830
7827
  * Note: [πŸ‚] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`