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