@promptbook/markdown-utils 0.104.0-8 → 0.104.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 (62) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +34 -25
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +0 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +8 -6
  6. package/esm/typings/src/_packages/types.index.d.ts +8 -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 +24 -0
  9. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +12 -2
  10. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
  11. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.closed.test.d.ts +1 -0
  12. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
  13. package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
  14. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +6 -3
  15. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
  16. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
  17. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
  18. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
  19. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
  20. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
  21. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
  22. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
  23. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
  24. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +18 -12
  25. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +6 -3
  26. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  27. package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
  28. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
  29. package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
  30. package/esm/typings/src/config.d.ts +8 -1
  31. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +8 -4
  36. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +12 -8
  39. package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
  40. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  41. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
  42. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
  43. package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
  44. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  45. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  46. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  47. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  48. package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
  49. package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
  50. package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
  51. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
  52. package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
  53. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  54. package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
  55. package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
  56. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  57. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
  58. package/esm/typings/src/version.d.ts +1 -1
  59. package/package.json +1 -1
  60. package/umd/index.umd.js +34 -25
  61. package/umd/index.umd.js.map +1 -1
  62. package/esm/typings/servers.d.ts +0 -50
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.104.0-8';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.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
@@ -1561,9 +1561,10 @@ function isValidFilePath(filename) {
1561
1561
  *
1562
1562
  * Note: [🔂] This function is idempotent.
1563
1563
  * Note: Dataurl are considered perfectly valid.
1564
- * Note: There are two similar functions:
1565
- * - `isValidUrl` which tests any URL
1566
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
1564
+ * Note: There are few similar functions:
1565
+ * - `isValidUrl` *(this one)* which tests any URL
1566
+ * - `isValidAgentUrl` which tests just agent URL
1567
+ * - `isValidPipelineUrl` which tests just pipeline URL
1567
1568
  *
1568
1569
  * @public exported from `@promptbook/utils`
1569
1570
  */
@@ -2131,8 +2132,9 @@ function isValidPromptbookVersion(version) {
2131
2132
  /**
2132
2133
  * Tests if given string is valid pipeline URL URL.
2133
2134
  *
2134
- * Note: There are two similar functions:
2135
+ * Note: There are few similar functions:
2135
2136
  * - `isValidUrl` which tests any URL
2137
+ * - `isValidAgentUrl` which tests just agent URL
2136
2138
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
2137
2139
  *
2138
2140
  * @public exported from `@promptbook/utils`
@@ -3427,7 +3429,7 @@ async function forEachAsync(array, options, callbackfunction) {
3427
3429
  tasks.push(task);
3428
3430
  runningTasks.push(task);
3429
3431
  /* not await */ Promise.resolve(task).then(() => {
3430
- runningTasks = runningTasks.filter((t) => t !== task);
3432
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
3431
3433
  });
3432
3434
  if (maxParallelCount < runningTasks.length) {
3433
3435
  await Promise.race(runningTasks);
@@ -3484,10 +3486,14 @@ function addUsage(...usageItems) {
3484
3486
  }
3485
3487
 
3486
3488
  /**
3487
- * Intercepts LLM tools and counts total usage of the tools
3489
+ * Intercepts LLM tools and counts total usage of the tools.
3490
+ *
3491
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
3492
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
3493
+ * in real-time through an observable.
3488
3494
  *
3489
- * @param llmTools LLM tools to be intercepted with usage counting
3490
- * @returns LLM tools with same functionality with added total cost counting
3495
+ * @param llmTools - The LLM tools to be intercepted and tracked
3496
+ * @returns An augmented version of the tools that includes usage tracking capabilities
3491
3497
  * @public exported from `@promptbook/core`
3492
3498
  */
3493
3499
  function countUsage(llmTools) {
@@ -3562,7 +3568,7 @@ function countUsage(llmTools) {
3562
3568
  * TODO: [🧠] Is there some meaningfull way how to test this util
3563
3569
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
3564
3570
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
3565
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3571
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
3566
3572
  */
3567
3573
 
3568
3574
  /**
@@ -3752,17 +3758,21 @@ class MultipleLlmExecutionTools {
3752
3758
  */
3753
3759
 
3754
3760
  /**
3755
- * Joins multiple LLM Execution Tools into one
3761
+ * Joins multiple LLM Execution Tools into one.
3756
3762
  *
3757
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
3763
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
3764
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
3758
3765
  *
3759
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
3760
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
3761
- * 2) If there are multiple LlmExecutionTools, first will be used first, second will be used if the first hasn`t defined model variant or fails, etc.
3762
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
3766
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
3767
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
3768
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
3769
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
3763
3770
  *
3771
+ * @param title - A descriptive title for this collection of joined tools
3772
+ * @param llmExecutionTools - An array of execution tools to be joined
3773
+ * @returns A single unified execution tool wrapper
3764
3774
  *
3765
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
3775
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
3766
3776
  *
3767
3777
  * @public exported from `@promptbook/core`
3768
3778
  */
@@ -3802,7 +3812,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
3802
3812
  }
3803
3813
  /**
3804
3814
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
3805
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3815
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
3806
3816
  */
3807
3817
 
3808
3818
  /**
@@ -3819,7 +3829,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
3819
3829
  }
3820
3830
  /**
3821
3831
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
3822
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3832
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
3823
3833
  */
3824
3834
 
3825
3835
  /**
@@ -4389,8 +4399,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
4389
4399
  */
4390
4400
  function removeDiacritics(input) {
4391
4401
  /*eslint no-control-regex: "off"*/
4392
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
4393
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
4402
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
4403
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
4394
4404
  });
4395
4405
  }
4396
4406
  /**
@@ -4619,7 +4629,6 @@ const promptbookFetch = async (urlOrRequest, init) => {
4619
4629
  * @public exported from `@promptbook/core`
4620
4630
  */
4621
4631
  async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4622
- // console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
4623
4632
  var _a;
4624
4633
  const { fetch = promptbookFetch } = tools;
4625
4634
  const { knowledgeSourceContent } = knowledgeSource;
@@ -6589,7 +6598,7 @@ async function getKnowledgeForTask(options) {
6589
6598
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6590
6599
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6591
6600
  const { index } = knowledgePiece;
6592
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
6601
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
6593
6602
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6594
6603
  if (knowledgePieceIndex === undefined) {
6595
6604
  return {
@@ -7037,7 +7046,7 @@ async function executePipeline(options) {
7037
7046
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
7038
7047
  })
7039
7048
  .then(() => {
7040
- resolving = resolving.filter((w) => w !== work);
7049
+ resolving = resolving.filter((workItem) => workItem !== work);
7041
7050
  });
7042
7051
  // <- Note: Errors are catched here [3]
7043
7052
  // TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
@@ -7203,7 +7212,7 @@ function createPipelineExecutor(options) {
7203
7212
  // Calculate and update tldr based on pipeline progress
7204
7213
  const cv = newOngoingResult;
7205
7214
  // Calculate progress based on parameters resolved vs total parameters
7206
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
7215
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
7207
7216
  let resolvedParameters = 0;
7208
7217
  let currentTaskTitle = '';
7209
7218
  // Get the resolved parameters from output parameters