@promptbook/remote-server 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 +2 -2
  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/remote-server`
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
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-8';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2448,9 +2448,10 @@ function isValidPromptbookVersion(version) {
2448
2448
  *
2449
2449
  * Note: [🔂] This function is idempotent.
2450
2450
  * Note: Dataurl are considered perfectly valid.
2451
- * Note: There are two similar functions:
2452
- * - `isValidUrl` which tests any URL
2453
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
2451
+ * Note: There are few similar functions:
2452
+ * - `isValidUrl` *(this one)* which tests any URL
2453
+ * - `isValidAgentUrl` which tests just agent URL
2454
+ * - `isValidPipelineUrl` which tests just pipeline URL
2454
2455
  *
2455
2456
  * @public exported from `@promptbook/utils`
2456
2457
  */
@@ -2476,8 +2477,9 @@ function isValidUrl(url) {
2476
2477
  /**
2477
2478
  * Tests if given string is valid pipeline URL URL.
2478
2479
  *
2479
- * Note: There are two similar functions:
2480
+ * Note: There are few similar functions:
2480
2481
  * - `isValidUrl` which tests any URL
2482
+ * - `isValidAgentUrl` which tests just agent URL
2481
2483
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
2482
2484
  *
2483
2485
  * @public exported from `@promptbook/utils`
@@ -3712,7 +3714,7 @@ async function forEachAsync(array, options, callbackfunction) {
3712
3714
  tasks.push(task);
3713
3715
  runningTasks.push(task);
3714
3716
  /* not await */ Promise.resolve(task).then(() => {
3715
- runningTasks = runningTasks.filter((t) => t !== task);
3717
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
3716
3718
  });
3717
3719
  if (maxParallelCount < runningTasks.length) {
3718
3720
  await Promise.race(runningTasks);
@@ -3769,10 +3771,14 @@ function addUsage(...usageItems) {
3769
3771
  }
3770
3772
 
3771
3773
  /**
3772
- * Intercepts LLM tools and counts total usage of the tools
3774
+ * Intercepts LLM tools and counts total usage of the tools.
3775
+ *
3776
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
3777
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
3778
+ * in real-time through an observable.
3773
3779
  *
3774
- * @param llmTools LLM tools to be intercepted with usage counting
3775
- * @returns LLM tools with same functionality with added total cost counting
3780
+ * @param llmTools - The LLM tools to be intercepted and tracked
3781
+ * @returns An augmented version of the tools that includes usage tracking capabilities
3776
3782
  * @public exported from `@promptbook/core`
3777
3783
  */
3778
3784
  function countUsage(llmTools) {
@@ -3847,7 +3853,7 @@ function countUsage(llmTools) {
3847
3853
  * TODO: [🧠] Is there some meaningfull way how to test this util
3848
3854
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
3849
3855
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
3850
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3856
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
3851
3857
  */
3852
3858
 
3853
3859
  /**
@@ -4037,17 +4043,21 @@ class MultipleLlmExecutionTools {
4037
4043
  */
4038
4044
 
4039
4045
  /**
4040
- * Joins multiple LLM Execution Tools into one
4046
+ * Joins multiple LLM Execution Tools into one.
4041
4047
  *
4042
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
4048
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
4049
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
4043
4050
  *
4044
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
4045
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
4046
- * 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.
4047
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
4051
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
4052
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
4053
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
4054
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
4048
4055
  *
4056
+ * @param title - A descriptive title for this collection of joined tools
4057
+ * @param llmExecutionTools - An array of execution tools to be joined
4058
+ * @returns A single unified execution tool wrapper
4049
4059
  *
4050
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
4060
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
4051
4061
  *
4052
4062
  * @public exported from `@promptbook/core`
4053
4063
  */
@@ -4087,7 +4097,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
4087
4097
  }
4088
4098
  /**
4089
4099
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4090
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4100
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
4091
4101
  */
4092
4102
 
4093
4103
  /**
@@ -4104,7 +4114,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
4104
4114
  }
4105
4115
  /**
4106
4116
  * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4107
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4117
+ * TODO: [👷‍♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
4108
4118
  */
4109
4119
 
4110
4120
  /**
@@ -4674,8 +4684,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
4674
4684
  */
4675
4685
  function removeDiacritics(input) {
4676
4686
  /*eslint no-control-regex: "off"*/
4677
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
4678
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
4687
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
4688
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
4679
4689
  });
4680
4690
  }
4681
4691
  /**
@@ -4904,7 +4914,6 @@ const promptbookFetch = async (urlOrRequest, init) => {
4904
4914
  * @public exported from `@promptbook/core`
4905
4915
  */
4906
4916
  async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4907
- // console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
4908
4917
  var _a;
4909
4918
  const { fetch = promptbookFetch } = tools;
4910
4919
  const { knowledgeSourceContent } = knowledgeSource;
@@ -6993,7 +7002,7 @@ async function getKnowledgeForTask(options) {
6993
7002
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6994
7003
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6995
7004
  const { index } = knowledgePiece;
6996
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
7005
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
6997
7006
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6998
7007
  if (knowledgePieceIndex === undefined) {
6999
7008
  return {
@@ -7441,7 +7450,7 @@ async function executePipeline(options) {
7441
7450
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
7442
7451
  })
7443
7452
  .then(() => {
7444
- resolving = resolving.filter((w) => w !== work);
7453
+ resolving = resolving.filter((workItem) => workItem !== work);
7445
7454
  });
7446
7455
  // <- Note: Errors are catched here [3]
7447
7456
  // 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
@@ -7607,7 +7616,7 @@ function createPipelineExecutor(options) {
7607
7616
  // Calculate and update tldr based on pipeline progress
7608
7617
  const cv = newOngoingResult;
7609
7618
  // Calculate progress based on parameters resolved vs total parameters
7610
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
7619
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
7611
7620
  let resolvedParameters = 0;
7612
7621
  let currentTaskTitle = '';
7613
7622
  // Get the resolved parameters from output parameters