@promptbook/pdf 0.104.0-9 → 0.105.0-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 (66) hide show
  1. package/esm/index.es.js +36 -29
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +0 -6
  4. package/esm/typings/src/_packages/core.index.d.ts +10 -6
  5. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  6. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -0
  8. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +16 -2
  9. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
  10. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
  11. package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
  12. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +23 -3
  13. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
  14. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
  15. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
  16. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
  17. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
  18. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
  19. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
  20. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
  21. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
  22. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
  23. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  24. package/esm/typings/src/commitments/IMPORT/IMPORT.d.ts +34 -0
  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/commitments/index.d.ts +2 -1
  29. package/esm/typings/src/config.d.ts +14 -1
  30. package/esm/typings/src/errors/utils/deserializeError.d.ts +1 -1
  31. package/esm/typings/src/execution/PromptResult.d.ts +24 -1
  32. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +8 -4
  37. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +12 -8
  40. package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
  41. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +5 -0
  43. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
  44. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
  45. package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
  46. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  47. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  48. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  49. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  50. package/esm/typings/src/types/LlmToolDefinition.d.ts +27 -0
  51. package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
  52. package/esm/typings/src/types/Prompt.d.ts +13 -0
  53. package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
  54. package/esm/typings/src/utils/misc/parseNumber.d.ts +1 -1
  55. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
  56. package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
  57. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  58. package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
  59. package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
  60. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  61. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
  62. package/esm/typings/src/version.d.ts +1 -1
  63. package/package.json +2 -2
  64. package/umd/index.umd.js +36 -29
  65. package/umd/index.umd.js.map +1 -1
  66. package/esm/typings/servers.d.ts +0 -50
package/esm/index.es.js CHANGED
@@ -24,7 +24,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
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.105.0-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
@@ -1577,8 +1577,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
1577
1577
  */
1578
1578
  function removeDiacritics(input) {
1579
1579
  /*eslint no-control-regex: "off"*/
1580
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
1581
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
1580
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
1581
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
1582
1582
  });
1583
1583
  }
1584
1584
  /**
@@ -1699,9 +1699,10 @@ function isValidFilePath(filename) {
1699
1699
  *
1700
1700
  * Note: [🔂] This function is idempotent.
1701
1701
  * Note: Dataurl are considered perfectly valid.
1702
- * Note: There are two similar functions:
1703
- * - `isValidUrl` which tests any URL
1704
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
1702
+ * Note: There are few similar functions:
1703
+ * - `isValidUrl` *(this one)* which tests any URL
1704
+ * - `isValidAgentUrl` which tests just agent URL
1705
+ * - `isValidPipelineUrl` which tests just pipeline URL
1705
1706
  *
1706
1707
  * @public exported from `@promptbook/utils`
1707
1708
  */
@@ -2497,8 +2498,9 @@ function isValidPromptbookVersion(version) {
2497
2498
  /**
2498
2499
  * Tests if given string is valid pipeline URL URL.
2499
2500
  *
2500
- * Note: There are two similar functions:
2501
+ * Note: There are few similar functions:
2501
2502
  * - `isValidUrl` which tests any URL
2503
+ * - `isValidAgentUrl` which tests just agent URL
2502
2504
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
2503
2505
  *
2504
2506
  * @public exported from `@promptbook/utils`
@@ -3423,7 +3425,7 @@ function jsonStringsToJsons(object) {
3423
3425
  *
3424
3426
  * @public exported from `@promptbook/utils`
3425
3427
  */
3426
- function deserializeError(error) {
3428
+ function deserializeError(error, isStackAddedToMessage = true) {
3427
3429
  const { name, stack, id } = error; // Added id
3428
3430
  let { message } = error;
3429
3431
  let ErrorClass = ALL_ERRORS[error.name];
@@ -3431,7 +3433,7 @@ function deserializeError(error) {
3431
3433
  ErrorClass = Error;
3432
3434
  message = `${name}: ${message}`;
3433
3435
  }
3434
- if (stack !== undefined && stack !== '') {
3436
+ if (isStackAddedToMessage && stack !== undefined && stack !== '') {
3435
3437
  message = spaceTrim$2((block) => `
3436
3438
  ${block(message)}
3437
3439
 
@@ -3767,7 +3769,7 @@ async function forEachAsync(array, options, callbackfunction) {
3767
3769
  tasks.push(task);
3768
3770
  runningTasks.push(task);
3769
3771
  /* not await */ Promise.resolve(task).then(() => {
3770
- runningTasks = runningTasks.filter((t) => t !== task);
3772
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
3771
3773
  });
3772
3774
  if (maxParallelCount < runningTasks.length) {
3773
3775
  await Promise.race(runningTasks);
@@ -3824,10 +3826,14 @@ function addUsage(...usageItems) {
3824
3826
  }
3825
3827
 
3826
3828
  /**
3827
- * Intercepts LLM tools and counts total usage of the tools
3829
+ * Intercepts LLM tools and counts total usage of the tools.
3830
+ *
3831
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
3832
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
3833
+ * in real-time through an observable.
3828
3834
  *
3829
- * @param llmTools LLM tools to be intercepted with usage counting
3830
- * @returns LLM tools with same functionality with added total cost counting
3835
+ * @param llmTools - The LLM tools to be intercepted and tracked
3836
+ * @returns An augmented version of the tools that includes usage tracking capabilities
3831
3837
  * @public exported from `@promptbook/core`
3832
3838
  */
3833
3839
  function countUsage(llmTools) {
@@ -3902,7 +3908,7 @@ function countUsage(llmTools) {
3902
3908
  * TODO: [🧠] Is there some meaningfull way how to test this util
3903
3909
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
3904
3910
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
3905
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3911
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
3906
3912
  */
3907
3913
 
3908
3914
  /**
@@ -4092,17 +4098,21 @@ class MultipleLlmExecutionTools {
4092
4098
  */
4093
4099
 
4094
4100
  /**
4095
- * Joins multiple LLM Execution Tools into one
4101
+ * Joins multiple LLM Execution Tools into one.
4096
4102
  *
4097
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
4103
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
4104
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
4098
4105
  *
4099
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
4100
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
4101
- * 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.
4102
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
4106
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
4107
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
4108
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
4109
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
4103
4110
  *
4111
+ * @param title - A descriptive title for this collection of joined tools
4112
+ * @param llmExecutionTools - An array of execution tools to be joined
4113
+ * @returns A single unified execution tool wrapper
4104
4114
  *
4105
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
4115
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
4106
4116
  *
4107
4117
  * @public exported from `@promptbook/core`
4108
4118
  */
@@ -4142,7 +4152,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
4142
4152
  }
4143
4153
  /**
4144
4154
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4145
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4155
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
4146
4156
  */
4147
4157
 
4148
4158
  /**
@@ -4159,7 +4169,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
4159
4169
  }
4160
4170
  /**
4161
4171
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4162
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4172
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
4163
4173
  */
4164
4174
 
4165
4175
  /**
@@ -4564,7 +4574,6 @@ const promptbookFetch = async (urlOrRequest, init) => {
4564
4574
  * @public exported from `@promptbook/core`
4565
4575
  */
4566
4576
  async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4567
- // console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
4568
4577
  var _a;
4569
4578
  const { fetch = promptbookFetch } = tools;
4570
4579
  const { knowledgeSourceContent } = knowledgeSource;
@@ -6636,7 +6645,7 @@ async function getKnowledgeForTask(options) {
6636
6645
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6637
6646
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6638
6647
  const { index } = knowledgePiece;
6639
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
6648
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
6640
6649
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6641
6650
  if (knowledgePieceIndex === undefined) {
6642
6651
  return {
@@ -7084,7 +7093,7 @@ async function executePipeline(options) {
7084
7093
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
7085
7094
  })
7086
7095
  .then(() => {
7087
- resolving = resolving.filter((w) => w !== work);
7096
+ resolving = resolving.filter((workItem) => workItem !== work);
7088
7097
  });
7089
7098
  // <- Note: Errors are catched here [3]
7090
7099
  // 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
@@ -7250,7 +7259,7 @@ function createPipelineExecutor(options) {
7250
7259
  // Calculate and update tldr based on pipeline progress
7251
7260
  const cv = newOngoingResult;
7252
7261
  // Calculate progress based on parameters resolved vs total parameters
7253
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
7262
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
7254
7263
  let resolvedParameters = 0;
7255
7264
  let currentTaskTitle = '';
7256
7265
  // Get the resolved parameters from output parameters
@@ -7564,7 +7573,6 @@ class MarkitdownScraper {
7564
7573
  // Note: Running Markitdown conversion ONLY if the file in the cache does not exist
7565
7574
  if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
7566
7575
  const src = source.filename || source.url || null;
7567
- // console.log('!!', { src, source, cacheFilehandler });
7568
7576
  if (src === null) {
7569
7577
  throw new UnexpectedError('Source has no filename or url');
7570
7578
  }
@@ -7577,7 +7585,6 @@ class MarkitdownScraper {
7577
7585
  throw new Error(`Markitdown could not convert the "${source.source}"`);
7578
7586
  // <- TODO: [🍀] Make MarkitdownError
7579
7587
  }
7580
- // console.log('!!', { result, cacheFilehandler });
7581
7588
  // Note: Try to cache the converted content, but don't fail if the filesystem is read-only
7582
7589
  try {
7583
7590
  await this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content);