@promptbook/website-crawler 0.103.0-42 → 0.103.0-43

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 (79) hide show
  1. package/esm/index.es.js +40 -113
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +6 -0
  4. package/esm/typings/src/_packages/node.index.d.ts +0 -2
  5. package/esm/typings/src/_packages/types.index.d.ts +14 -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 +2 -4
  8. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
  9. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +1 -0
  10. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +1 -1
  11. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
  12. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
  13. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  14. package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +1 -1
  15. package/esm/typings/src/book-components/Qr/useQrCode.d.ts +1 -1
  16. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +1 -1
  17. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
  18. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -1
  19. package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -1
  20. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +1 -1
  21. package/esm/typings/src/cli/cli-commands/login.d.ts +1 -1
  22. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  23. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -1
  24. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
  25. package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +1 -1
  26. package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
  27. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -1
  28. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +1 -1
  29. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +11 -12
  30. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +55 -0
  31. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +129 -0
  32. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  33. package/esm/typings/src/config.d.ts +1 -1
  34. package/esm/typings/src/errors/0-index.d.ts +3 -0
  35. package/esm/typings/src/errors/DatabaseError.d.ts +9 -0
  36. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -1
  37. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
  40. package/esm/typings/src/llm-providers/agent/Agent.d.ts +5 -2
  41. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +4 -2
  43. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +2 -2
  44. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -1
  45. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
  46. package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
  47. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +0 -19
  48. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +1 -1
  49. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +5 -1
  50. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +1 -1
  51. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +1 -1
  52. package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +4 -1
  53. package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
  54. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +4 -1
  55. package/esm/typings/src/transpilers/openai-sdk/register.d.ts +1 -1
  56. package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
  57. package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
  58. package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
  59. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
  60. package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
  61. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
  62. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +1 -1
  63. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -1
  64. package/esm/typings/src/utils/files/$induceBookDownload.d.ts +2 -2
  65. package/esm/typings/src/utils/files/$induceFileDownload.d.ts +2 -2
  66. package/esm/typings/src/utils/files/ObjectUrl.d.ts +1 -1
  67. package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +6 -0
  68. package/esm/typings/src/utils/organization/$side_effect.d.ts +1 -1
  69. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +22 -0
  70. package/esm/typings/src/utils/random/$randomToken.d.ts +1 -0
  71. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  72. package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
  73. package/esm/typings/src/version.d.ts +1 -1
  74. package/package.json +2 -2
  75. package/umd/index.umd.js +40 -113
  76. package/umd/index.umd.js.map +1 -1
  77. package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +0 -89
  78. package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.test.d.ts +0 -1
  79. package/esm/typings/src/execution/utils/logLlmCall.d.ts +0 -8
package/esm/index.es.js CHANGED
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-42';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-43';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -735,6 +735,23 @@ class Color {
735
735
  * TODO: Maybe connect with textures
736
736
  */
737
737
 
738
+ /**
739
+ * Makes color transformer which returns a grayscale version of the color
740
+ *
741
+ * @param amount from 0 to 1
742
+ *
743
+ * @public exported from `@promptbook/color`
744
+ */
745
+ function grayscale(amount) {
746
+ return ({ red, green, blue, alpha }) => {
747
+ const average = (red + green + blue) / 3;
748
+ red = Math.round(average * amount + red * (1 - amount));
749
+ green = Math.round(average * amount + green * (1 - amount));
750
+ blue = Math.round(average * amount + blue * (1 - amount));
751
+ return Color.fromValues(red, green, blue, alpha);
752
+ };
753
+ }
754
+
738
755
  /**
739
756
  * Converts HSL values to RGB values
740
757
  *
@@ -850,102 +867,6 @@ function lighten(amount) {
850
867
  * TODO: Maybe implement by mix+hsl
851
868
  */
852
869
 
853
- /**
854
- * Calculates distance between two colors
855
- *
856
- * @param color1 first color
857
- * @param color2 second color
858
- *
859
- * Note: This function is inefficient. Use colorDistanceSquared instead if possible.
860
- *
861
- * @public exported from `@promptbook/color`
862
- */
863
- /**
864
- * Calculates distance between two colors without square root
865
- *
866
- * @param color1 first color
867
- * @param color2 second color
868
- *
869
- * @public exported from `@promptbook/color`
870
- */
871
- function colorDistanceSquared(color1, color2) {
872
- const rmean = (color1.red + color2.red) / 2;
873
- const r = color1.red - color2.red;
874
- const g = color1.green - color2.green;
875
- const b = color1.blue - color2.blue;
876
- const weightR = 2 + rmean / 256;
877
- const weightG = 4.0;
878
- const weightB = 2 + (255 - rmean) / 256;
879
- const distance = weightR * r * r + weightG * g * g + weightB * b * b;
880
- return distance;
881
- }
882
-
883
- /**
884
- * Makes color transformer which finds the nearest color from the given list
885
- *
886
- * @param colors array of colors to choose from
887
- *
888
- * @public exported from `@promptbook/color`
889
- */
890
- function nearest(...colors) {
891
- return (color) => {
892
- const distances = colors.map((c) => colorDistanceSquared(c, color));
893
- const minDistance = Math.min(...distances);
894
- const minIndex = distances.indexOf(minDistance);
895
- const nearestColor = colors[minIndex];
896
- return nearestColor;
897
- };
898
- }
899
-
900
- /**
901
- * Color transformer which returns the negative color
902
- *
903
- * @public exported from `@promptbook/color`
904
- */
905
- function negative(color) {
906
- const r = 255 - color.red;
907
- const g = 255 - color.green;
908
- const b = 255 - color.blue;
909
- return Color.fromValues(r, g, b, color.alpha);
910
- }
911
-
912
- /**
913
- * Makes color transformer which finds the furthest color from the given list
914
- *
915
- * @param colors array of colors to choose from
916
- *
917
- * @public exported from `@promptbook/color`
918
- */
919
- function furthest(...colors) {
920
- return (color) => {
921
- const furthestColor = negative(nearest(...colors.map(negative))(color));
922
- return furthestColor;
923
- };
924
- }
925
- /**
926
- * Makes color transformer which finds the best text color (black or white) for the given background color
927
- *
928
- * @public exported from `@promptbook/color`
929
- */
930
- furthest(Color.get('white'), Color.from('black'));
931
-
932
- /**
933
- * Makes color transformer which returns a grayscale version of the color
934
- *
935
- * @param amount from 0 to 1
936
- *
937
- * @public exported from `@promptbook/color`
938
- */
939
- function grayscale(amount) {
940
- return ({ red, green, blue, alpha }) => {
941
- const average = (red + green + blue) / 3;
942
- red = Math.round(average * amount + red * (1 - amount));
943
- green = Math.round(average * amount + green * (1 - amount));
944
- blue = Math.round(average * amount + blue * (1 - amount));
945
- return Color.fromValues(red, green, blue, alpha);
946
- };
947
- }
948
-
949
870
  /**
950
871
  * Makes color transformer which saturate the given color
951
872
  *
@@ -3182,6 +3103,7 @@ class MissingToolsError extends Error {
3182
3103
  /**
3183
3104
  * Generates random token
3184
3105
  *
3106
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
3185
3107
  * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
3186
3108
  *
3187
3109
  * @private internal helper function
@@ -3309,6 +3231,19 @@ class CollectionError extends Error {
3309
3231
  }
3310
3232
  }
3311
3233
 
3234
+ /**
3235
+ * This error indicates error from the database
3236
+ *
3237
+ * @public exported from `@promptbook/core`
3238
+ */
3239
+ class DatabaseError extends Error {
3240
+ constructor(message) {
3241
+ super(message);
3242
+ this.name = 'DatabaseError';
3243
+ Object.setPrototypeOf(this, DatabaseError.prototype);
3244
+ }
3245
+ }
3246
+
3312
3247
  /**
3313
3248
  * This error occurs when some expectation is not met in the execution of the pipeline
3314
3249
  *
@@ -3389,6 +3324,7 @@ const PROMPTBOOK_ERRORS = {
3389
3324
  UnexpectedError,
3390
3325
  WrappedError,
3391
3326
  NotAllowed,
3327
+ DatabaseError,
3392
3328
  // TODO: [🪑]> VersionMismatchError,
3393
3329
  };
3394
3330
  /**
@@ -5707,18 +5643,6 @@ function templateParameters(template, parameters) {
5707
5643
  return replacedTemplates;
5708
5644
  }
5709
5645
 
5710
- /**
5711
- * Logs an LLM call with the given report.
5712
- *
5713
- * @private internal utility of `createPipelineExecutor`
5714
- */
5715
- function logLlmCall(logLlmCall, report) {
5716
- logLlmCall({
5717
- modelName: 'model' /* <- TODO: How to get model name from the report */,
5718
- report,
5719
- });
5720
- }
5721
-
5722
5646
  /**
5723
5647
  * Extracts all code blocks from markdown.
5724
5648
  *
@@ -6064,7 +5988,7 @@ function validatePromptResult(options) {
6064
5988
  */
6065
5989
  async function executeAttempts(options) {
6066
5990
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
6067
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall: logLlmCall$1, } = options;
5991
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
6068
5992
  const $ongoingTaskResult = {
6069
5993
  $result: null,
6070
5994
  $resultString: null,
@@ -6326,8 +6250,11 @@ async function executeAttempts(options) {
6326
6250
  : serializeError($ongoingTaskResult.$expectError),
6327
6251
  };
6328
6252
  $executionReport.promptExecutions.push(executionPromptReport);
6329
- if (logLlmCall$1) {
6330
- logLlmCall(logLlmCall$1, executionPromptReport);
6253
+ if (logLlmCall) {
6254
+ logLlmCall({
6255
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
6256
+ report: executionPromptReport,
6257
+ });
6331
6258
  }
6332
6259
  }
6333
6260
  }
@@ -6601,7 +6528,7 @@ async function getKnowledgeForTask(options) {
6601
6528
  },
6602
6529
  content: task.content,
6603
6530
  parameters,
6604
- };
6531
+ }; /* <- Note: [🤛] */
6605
6532
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6606
6533
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6607
6534
  const { index } = knowledgePiece;