@promptbook/legacy-documents 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 +2 -2
  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
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-9';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1755,8 +1755,8 @@
1755
1755
  */
1756
1756
  function removeDiacritics(input) {
1757
1757
  /*eslint no-control-regex: "off"*/
1758
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
1759
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
1758
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
1759
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
1760
1760
  });
1761
1761
  }
1762
1762
  /**
@@ -1877,9 +1877,10 @@
1877
1877
  *
1878
1878
  * Note: [🔂] This function is idempotent.
1879
1879
  * Note: Dataurl are considered perfectly valid.
1880
- * Note: There are two similar functions:
1881
- * - `isValidUrl` which tests any URL
1882
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
1880
+ * Note: There are few similar functions:
1881
+ * - `isValidUrl` *(this one)* which tests any URL
1882
+ * - `isValidAgentUrl` which tests just agent URL
1883
+ * - `isValidPipelineUrl` which tests just pipeline URL
1883
1884
  *
1884
1885
  * @public exported from `@promptbook/utils`
1885
1886
  */
@@ -2675,8 +2676,9 @@
2675
2676
  /**
2676
2677
  * Tests if given string is valid pipeline URL URL.
2677
2678
  *
2678
- * Note: There are two similar functions:
2679
+ * Note: There are few similar functions:
2679
2680
  * - `isValidUrl` which tests any URL
2681
+ * - `isValidAgentUrl` which tests just agent URL
2680
2682
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
2681
2683
  *
2682
2684
  * @public exported from `@promptbook/utils`
@@ -3927,7 +3929,7 @@
3927
3929
  tasks.push(task);
3928
3930
  runningTasks.push(task);
3929
3931
  /* not await */ Promise.resolve(task).then(() => {
3930
- runningTasks = runningTasks.filter((t) => t !== task);
3932
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
3931
3933
  });
3932
3934
  if (maxParallelCount < runningTasks.length) {
3933
3935
  await Promise.race(runningTasks);
@@ -3984,10 +3986,14 @@
3984
3986
  }
3985
3987
 
3986
3988
  /**
3987
- * Intercepts LLM tools and counts total usage of the tools
3989
+ * Intercepts LLM tools and counts total usage of the tools.
3990
+ *
3991
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
3992
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
3993
+ * in real-time through an observable.
3988
3994
  *
3989
- * @param llmTools LLM tools to be intercepted with usage counting
3990
- * @returns LLM tools with same functionality with added total cost counting
3995
+ * @param llmTools - The LLM tools to be intercepted and tracked
3996
+ * @returns An augmented version of the tools that includes usage tracking capabilities
3991
3997
  * @public exported from `@promptbook/core`
3992
3998
  */
3993
3999
  function countUsage(llmTools) {
@@ -4062,7 +4068,7 @@
4062
4068
  * TODO: [🧠] Is there some meaningfull way how to test this util
4063
4069
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
4064
4070
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
4065
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4071
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
4066
4072
  */
4067
4073
 
4068
4074
  /**
@@ -4252,17 +4258,21 @@
4252
4258
  */
4253
4259
 
4254
4260
  /**
4255
- * Joins multiple LLM Execution Tools into one
4261
+ * Joins multiple LLM Execution Tools into one.
4256
4262
  *
4257
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
4263
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
4264
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
4258
4265
  *
4259
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
4260
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
4261
- * 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.
4262
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
4266
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
4267
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
4268
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
4269
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
4263
4270
  *
4271
+ * @param title - A descriptive title for this collection of joined tools
4272
+ * @param llmExecutionTools - An array of execution tools to be joined
4273
+ * @returns A single unified execution tool wrapper
4264
4274
  *
4265
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
4275
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
4266
4276
  *
4267
4277
  * @public exported from `@promptbook/core`
4268
4278
  */
@@ -4302,7 +4312,7 @@
4302
4312
  }
4303
4313
  /**
4304
4314
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4305
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4315
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
4306
4316
  */
4307
4317
 
4308
4318
  /**
@@ -4319,7 +4329,7 @@
4319
4329
  }
4320
4330
  /**
4321
4331
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4322
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4332
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
4323
4333
  */
4324
4334
 
4325
4335
  /**
@@ -4714,7 +4724,6 @@
4714
4724
  * @public exported from `@promptbook/core`
4715
4725
  */
4716
4726
  async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4717
- // console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
4718
4727
  var _a;
4719
4728
  const { fetch = promptbookFetch } = tools;
4720
4729
  const { knowledgeSourceContent } = knowledgeSource;
@@ -6786,7 +6795,7 @@
6786
6795
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6787
6796
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6788
6797
  const { index } = knowledgePiece;
6789
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
6798
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
6790
6799
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6791
6800
  if (knowledgePieceIndex === undefined) {
6792
6801
  return {
@@ -7234,7 +7243,7 @@
7234
7243
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
7235
7244
  })
7236
7245
  .then(() => {
7237
- resolving = resolving.filter((w) => w !== work);
7246
+ resolving = resolving.filter((workItem) => workItem !== work);
7238
7247
  });
7239
7248
  // <- Note: Errors are catched here [3]
7240
7249
  // 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
@@ -7400,7 +7409,7 @@
7400
7409
  // Calculate and update tldr based on pipeline progress
7401
7410
  const cv = newOngoingResult;
7402
7411
  // Calculate progress based on parameters resolved vs total parameters
7403
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
7412
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
7404
7413
  let resolvedParameters = 0;
7405
7414
  let currentTaskTitle = '';
7406
7415
  // Get the resolved parameters from output parameters