@promptbook/pdf 0.103.0-42 → 0.103.0-44

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 (92) hide show
  1. package/README.md +6 -18
  2. package/esm/index.es.js +47 -114
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -0
  5. package/esm/typings/src/_packages/node.index.d.ts +0 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +22 -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 +2 -4
  9. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
  10. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +1 -0
  11. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
  12. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
  13. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
  14. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  15. package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +1 -1
  16. package/esm/typings/src/book-components/Qr/useQrCode.d.ts +1 -1
  17. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +1 -1
  18. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
  19. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -1
  20. package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -1
  21. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +1 -1
  22. package/esm/typings/src/cli/cli-commands/login.d.ts +1 -1
  23. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  24. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -1
  25. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
  26. package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +1 -1
  27. package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
  28. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -1
  29. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +1 -1
  30. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +2 -29
  31. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +107 -0
  32. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +129 -0
  33. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  34. package/esm/typings/src/config.d.ts +1 -1
  35. package/esm/typings/src/errors/0-index.d.ts +3 -0
  36. package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
  37. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -1
  38. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -1
  40. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
  41. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
  42. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
  43. package/esm/typings/src/llm-providers/agent/Agent.d.ts +5 -2
  44. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  45. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +4 -2
  46. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +4 -3
  47. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -1
  48. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  51. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
  52. package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
  53. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +0 -19
  54. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +1 -1
  55. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +5 -1
  56. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +1 -1
  57. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +1 -1
  58. package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +4 -1
  59. package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
  60. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +4 -1
  61. package/esm/typings/src/transpilers/openai-sdk/register.d.ts +1 -1
  62. package/esm/typings/src/types/typeAliases.d.ts +19 -1
  63. package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
  64. package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
  65. package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
  66. package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
  67. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
  68. package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
  69. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
  70. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +1 -1
  71. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -1
  72. package/esm/typings/src/utils/files/$induceBookDownload.d.ts +2 -2
  73. package/esm/typings/src/utils/files/$induceFileDownload.d.ts +2 -2
  74. package/esm/typings/src/utils/files/ObjectUrl.d.ts +1 -1
  75. package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +6 -0
  76. package/esm/typings/src/utils/organization/$side_effect.d.ts +1 -1
  77. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
  78. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
  79. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
  80. package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
  81. package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
  82. package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
  83. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  84. package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
  85. package/esm/typings/src/version.d.ts +1 -1
  86. package/package.json +2 -2
  87. package/umd/index.umd.js +47 -114
  88. package/umd/index.umd.js.map +1 -1
  89. package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +0 -89
  90. package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.test.d.ts +0 -1
  91. package/esm/typings/src/commands/_common/parseCommand.test.d.ts +0 -1
  92. package/esm/typings/src/execution/utils/logLlmCall.d.ts +0 -8
package/umd/index.umd.js CHANGED
@@ -17,14 +17,14 @@
17
17
  * @generated
18
18
  * @see https://github.com/webgptorg/book
19
19
  */
20
- const BOOK_LANGUAGE_VERSION = '1.0.0';
20
+ const BOOK_LANGUAGE_VERSION = '2.0.0';
21
21
  /**
22
22
  * The version of the Promptbook engine
23
23
  *
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-42';
27
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-44';
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
@@ -718,6 +718,23 @@
718
718
  * TODO: Maybe connect with textures
719
719
  */
720
720
 
721
+ /**
722
+ * Makes color transformer which returns a grayscale version of the color
723
+ *
724
+ * @param amount from 0 to 1
725
+ *
726
+ * @public exported from `@promptbook/color`
727
+ */
728
+ function grayscale(amount) {
729
+ return ({ red, green, blue, alpha }) => {
730
+ const average = (red + green + blue) / 3;
731
+ red = Math.round(average * amount + red * (1 - amount));
732
+ green = Math.round(average * amount + green * (1 - amount));
733
+ blue = Math.round(average * amount + blue * (1 - amount));
734
+ return Color.fromValues(red, green, blue, alpha);
735
+ };
736
+ }
737
+
721
738
  /**
722
739
  * Converts HSL values to RGB values
723
740
  *
@@ -833,102 +850,6 @@
833
850
  * TODO: Maybe implement by mix+hsl
834
851
  */
835
852
 
836
- /**
837
- * Calculates distance between two colors
838
- *
839
- * @param color1 first color
840
- * @param color2 second color
841
- *
842
- * Note: This function is inefficient. Use colorDistanceSquared instead if possible.
843
- *
844
- * @public exported from `@promptbook/color`
845
- */
846
- /**
847
- * Calculates distance between two colors without square root
848
- *
849
- * @param color1 first color
850
- * @param color2 second color
851
- *
852
- * @public exported from `@promptbook/color`
853
- */
854
- function colorDistanceSquared(color1, color2) {
855
- const rmean = (color1.red + color2.red) / 2;
856
- const r = color1.red - color2.red;
857
- const g = color1.green - color2.green;
858
- const b = color1.blue - color2.blue;
859
- const weightR = 2 + rmean / 256;
860
- const weightG = 4.0;
861
- const weightB = 2 + (255 - rmean) / 256;
862
- const distance = weightR * r * r + weightG * g * g + weightB * b * b;
863
- return distance;
864
- }
865
-
866
- /**
867
- * Makes color transformer which finds the nearest color from the given list
868
- *
869
- * @param colors array of colors to choose from
870
- *
871
- * @public exported from `@promptbook/color`
872
- */
873
- function nearest(...colors) {
874
- return (color) => {
875
- const distances = colors.map((c) => colorDistanceSquared(c, color));
876
- const minDistance = Math.min(...distances);
877
- const minIndex = distances.indexOf(minDistance);
878
- const nearestColor = colors[minIndex];
879
- return nearestColor;
880
- };
881
- }
882
-
883
- /**
884
- * Color transformer which returns the negative color
885
- *
886
- * @public exported from `@promptbook/color`
887
- */
888
- function negative(color) {
889
- const r = 255 - color.red;
890
- const g = 255 - color.green;
891
- const b = 255 - color.blue;
892
- return Color.fromValues(r, g, b, color.alpha);
893
- }
894
-
895
- /**
896
- * Makes color transformer which finds the furthest color from the given list
897
- *
898
- * @param colors array of colors to choose from
899
- *
900
- * @public exported from `@promptbook/color`
901
- */
902
- function furthest(...colors) {
903
- return (color) => {
904
- const furthestColor = negative(nearest(...colors.map(negative))(color));
905
- return furthestColor;
906
- };
907
- }
908
- /**
909
- * Makes color transformer which finds the best text color (black or white) for the given background color
910
- *
911
- * @public exported from `@promptbook/color`
912
- */
913
- furthest(Color.get('white'), Color.from('black'));
914
-
915
- /**
916
- * Makes color transformer which returns a grayscale version of the color
917
- *
918
- * @param amount from 0 to 1
919
- *
920
- * @public exported from `@promptbook/color`
921
- */
922
- function grayscale(amount) {
923
- return ({ red, green, blue, alpha }) => {
924
- const average = (red + green + blue) / 3;
925
- red = Math.round(average * amount + red * (1 - amount));
926
- green = Math.round(average * amount + green * (1 - amount));
927
- blue = Math.round(average * amount + blue * (1 - amount));
928
- return Color.fromValues(red, green, blue, alpha);
929
- };
930
- }
931
-
932
853
  /**
933
854
  * Makes color transformer which saturate the given color
934
855
  *
@@ -3039,6 +2960,7 @@
3039
2960
  /**
3040
2961
  * Generates random token
3041
2962
  *
2963
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
3042
2964
  * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
3043
2965
  *
3044
2966
  * @private internal helper function
@@ -3048,6 +2970,7 @@
3048
2970
  return crypto.randomBytes(randomness).toString('hex');
3049
2971
  }
3050
2972
  /**
2973
+ * TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
3051
2974
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
3052
2975
  */
3053
2976
 
@@ -3166,6 +3089,22 @@
3166
3089
  }
3167
3090
  }
3168
3091
 
3092
+ /**
3093
+ * This error indicates error from the database
3094
+ *
3095
+ * @public exported from `@promptbook/core`
3096
+ */
3097
+ class DatabaseError extends Error {
3098
+ constructor(message) {
3099
+ super(message);
3100
+ this.name = 'DatabaseError';
3101
+ Object.setPrototypeOf(this, DatabaseError.prototype);
3102
+ }
3103
+ }
3104
+ /**
3105
+ * TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
3106
+ */
3107
+
3169
3108
  /**
3170
3109
  * This error occurs when some expectation is not met in the execution of the pipeline
3171
3110
  *
@@ -3269,6 +3208,7 @@
3269
3208
  UnexpectedError,
3270
3209
  WrappedError,
3271
3210
  NotAllowed,
3211
+ DatabaseError,
3272
3212
  // TODO: [🪑]> VersionMismatchError,
3273
3213
  };
3274
3214
  /**
@@ -4105,6 +4045,7 @@
4105
4045
  return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
4106
4046
  }
4107
4047
  /**
4048
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4108
4049
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4109
4050
  */
4110
4051
 
@@ -4121,6 +4062,7 @@
4121
4062
  return llmTools;
4122
4063
  }
4123
4064
  /**
4065
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4124
4066
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4125
4067
  */
4126
4068
 
@@ -5706,18 +5648,6 @@
5706
5648
  return replacedTemplates;
5707
5649
  }
5708
5650
 
5709
- /**
5710
- * Logs an LLM call with the given report.
5711
- *
5712
- * @private internal utility of `createPipelineExecutor`
5713
- */
5714
- function logLlmCall(logLlmCall, report) {
5715
- logLlmCall({
5716
- modelName: 'model' /* <- TODO: How to get model name from the report */,
5717
- report,
5718
- });
5719
- }
5720
-
5721
5651
  /**
5722
5652
  * Extracts all code blocks from markdown.
5723
5653
  *
@@ -6063,7 +5993,7 @@
6063
5993
  */
6064
5994
  async function executeAttempts(options) {
6065
5995
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
6066
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall: logLlmCall$1, } = options;
5996
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
6067
5997
  const $ongoingTaskResult = {
6068
5998
  $result: null,
6069
5999
  $resultString: null,
@@ -6325,8 +6255,11 @@
6325
6255
  : serializeError($ongoingTaskResult.$expectError),
6326
6256
  };
6327
6257
  $executionReport.promptExecutions.push(executionPromptReport);
6328
- if (logLlmCall$1) {
6329
- logLlmCall(logLlmCall$1, executionPromptReport);
6258
+ if (logLlmCall) {
6259
+ logLlmCall({
6260
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
6261
+ report: executionPromptReport,
6262
+ });
6330
6263
  }
6331
6264
  }
6332
6265
  }
@@ -6600,7 +6533,7 @@
6600
6533
  },
6601
6534
  content: task.content,
6602
6535
  parameters,
6603
- };
6536
+ }; /* <- Note: [🤛] */
6604
6537
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6605
6538
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6606
6539
  const { index } = knowledgePiece;