@promptbook/website-crawler 0.103.0-54 → 0.103.0-56

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.
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import spaceTrim$1, { spaceTrim } from 'spacetrim';
1
+ import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
2
2
  import { Readability } from '@mozilla/readability';
3
3
  import { JSDOM } from 'jsdom';
4
4
  import { SHA256 } from 'crypto-js';
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-54';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
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
@@ -77,6 +77,17 @@ function $deepFreeze(objectValue) {
77
77
  * TODO: [🧠] Is there a way how to meaningfully test this utility
78
78
  */
79
79
 
80
+ /**
81
+ * Trims string from all 4 sides
82
+ *
83
+ * Note: This is a re-exported function from the `spacetrim` package which is
84
+ * Developed by same author @hejny as this package
85
+ *
86
+ * @public exported from `@promptbook/utils`
87
+ * @see https://github.com/hejny/spacetrim#usage
88
+ */
89
+ const spaceTrim = spaceTrim$1;
90
+
80
91
  /**
81
92
  * @private util of `@promptbook/color`
82
93
  * @de
@@ -125,6 +136,7 @@ function take(initialValue) {
125
136
  * @public exported from `@promptbook/color`
126
137
  */
127
138
  const CSS_COLORS = {
139
+ promptbook: '#79EAFD',
128
140
  transparent: 'rgba(0,0,0,0)',
129
141
  aliceblue: '#f0f8ff',
130
142
  antiquewhite: '#faebd7',
@@ -340,6 +352,28 @@ class Color {
340
352
  throw new Error(`Can not create color from given object`);
341
353
  }
342
354
  }
355
+ /**
356
+ * Creates a new Color instance from miscellaneous formats
357
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
358
+ *
359
+ * @param color
360
+ * @returns Color object
361
+ */
362
+ static fromSafe(color) {
363
+ try {
364
+ return Color.from(color);
365
+ }
366
+ catch (error) {
367
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
368
+ console.warn(spaceTrim((block) => `
369
+ Color.fromSafe error:
370
+ ${block(error.message)}
371
+
372
+ Returning default PROMPTBOOK_COLOR.
373
+ `));
374
+ return Color.fromString('promptbook');
375
+ }
376
+ }
343
377
  /**
344
378
  * Creates a new Color instance from miscellaneous string formats
345
379
  *
@@ -949,7 +983,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
949
983
  *
950
984
  * @public exported from `@promptbook/core`
951
985
  */
952
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
986
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
953
987
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
954
988
  /**
955
989
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1146,7 +1180,7 @@ true);
1146
1180
  */
1147
1181
  class NotYetImplementedError extends Error {
1148
1182
  constructor(message) {
1149
- super(spaceTrim((block) => `
1183
+ super(spaceTrim$1((block) => `
1150
1184
  ${block(message)}
1151
1185
 
1152
1186
  Note: This feature is not implemented yet but it will be soon.
@@ -1170,7 +1204,7 @@ class NotYetImplementedError extends Error {
1170
1204
  function getErrorReportUrl(error) {
1171
1205
  const report = {
1172
1206
  title: `🐜 Error report from ${NAME}`,
1173
- body: spaceTrim$1((block) => `
1207
+ body: spaceTrim$2((block) => `
1174
1208
 
1175
1209
 
1176
1210
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1213,7 +1247,7 @@ function getErrorReportUrl(error) {
1213
1247
  */
1214
1248
  class UnexpectedError extends Error {
1215
1249
  constructor(message) {
1216
- super(spaceTrim((block) => `
1250
+ super(spaceTrim$1((block) => `
1217
1251
  ${block(message)}
1218
1252
 
1219
1253
  Note: This error should not happen.
@@ -1997,7 +2031,7 @@ class WrappedError extends Error {
1997
2031
  constructor(whatWasThrown) {
1998
2032
  const tag = `[🤮]`;
1999
2033
  console.error(tag, whatWasThrown);
2000
- super(spaceTrim(`
2034
+ super(spaceTrim$1(`
2001
2035
  Non-Error object was thrown
2002
2036
 
2003
2037
  Note: Look for ${tag} in the console for more details
@@ -2223,7 +2257,7 @@ function pipelineJsonToString(pipelineJson) {
2223
2257
  pipelineString += '\n\n';
2224
2258
  pipelineString += '```' + contentLanguage;
2225
2259
  pipelineString += '\n';
2226
- pipelineString += spaceTrim$1(content);
2260
+ pipelineString += spaceTrim$2(content);
2227
2261
  // <- TODO: [main] !!3 Escape
2228
2262
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
2229
2263
  pipelineString += '\n';
@@ -2317,7 +2351,7 @@ function checkSerializableAsJson(options) {
2317
2351
  }
2318
2352
  else if (typeof value === 'object') {
2319
2353
  if (value instanceof Date) {
2320
- throw new UnexpectedError(spaceTrim$1((block) => `
2354
+ throw new UnexpectedError(spaceTrim$2((block) => `
2321
2355
  \`${name}\` is Date
2322
2356
 
2323
2357
  Use \`string_date_iso8601\` instead
@@ -2336,7 +2370,7 @@ function checkSerializableAsJson(options) {
2336
2370
  throw new UnexpectedError(`${name} is RegExp`);
2337
2371
  }
2338
2372
  else if (value instanceof Error) {
2339
- throw new UnexpectedError(spaceTrim$1((block) => `
2373
+ throw new UnexpectedError(spaceTrim$2((block) => `
2340
2374
  \`${name}\` is unserialized Error
2341
2375
 
2342
2376
  Use function \`serializeError\`
@@ -2359,7 +2393,7 @@ function checkSerializableAsJson(options) {
2359
2393
  }
2360
2394
  catch (error) {
2361
2395
  assertsError(error);
2362
- throw new UnexpectedError(spaceTrim$1((block) => `
2396
+ throw new UnexpectedError(spaceTrim$2((block) => `
2363
2397
  \`${name}\` is not serializable
2364
2398
 
2365
2399
  ${block(error.stack || error.message)}
@@ -2391,7 +2425,7 @@ function checkSerializableAsJson(options) {
2391
2425
  }
2392
2426
  }
2393
2427
  else {
2394
- throw new UnexpectedError(spaceTrim$1((block) => `
2428
+ throw new UnexpectedError(spaceTrim$2((block) => `
2395
2429
  \`${name}\` is unknown type
2396
2430
 
2397
2431
  Additional message for \`${name}\`:
@@ -2645,7 +2679,7 @@ function validatePipeline(pipeline) {
2645
2679
  if (!(error instanceof PipelineLogicError)) {
2646
2680
  throw error;
2647
2681
  }
2648
- console.error(spaceTrim((block) => `
2682
+ console.error(spaceTrim$1((block) => `
2649
2683
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2650
2684
 
2651
2685
  ${block(error.message)}
@@ -2672,7 +2706,7 @@ function validatePipeline_InnerFunction(pipeline) {
2672
2706
  })();
2673
2707
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2674
2708
  // <- Note: [🚲]
2675
- throw new PipelineLogicError(spaceTrim((block) => `
2709
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2676
2710
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2677
2711
 
2678
2712
  ${block(pipelineIdentification)}
@@ -2680,7 +2714,7 @@ function validatePipeline_InnerFunction(pipeline) {
2680
2714
  }
2681
2715
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2682
2716
  // <- Note: [🚲]
2683
- throw new PipelineLogicError(spaceTrim((block) => `
2717
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2684
2718
  Invalid Promptbook Version "${pipeline.bookVersion}"
2685
2719
 
2686
2720
  ${block(pipelineIdentification)}
@@ -2689,7 +2723,7 @@ function validatePipeline_InnerFunction(pipeline) {
2689
2723
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2690
2724
  if (!Array.isArray(pipeline.parameters)) {
2691
2725
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2692
- throw new ParseError(spaceTrim((block) => `
2726
+ throw new ParseError(spaceTrim$1((block) => `
2693
2727
  Pipeline is valid JSON but with wrong structure
2694
2728
 
2695
2729
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2700,7 +2734,7 @@ function validatePipeline_InnerFunction(pipeline) {
2700
2734
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2701
2735
  if (!Array.isArray(pipeline.tasks)) {
2702
2736
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2703
- throw new ParseError(spaceTrim((block) => `
2737
+ throw new ParseError(spaceTrim$1((block) => `
2704
2738
  Pipeline is valid JSON but with wrong structure
2705
2739
 
2706
2740
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2726,7 +2760,7 @@ function validatePipeline_InnerFunction(pipeline) {
2726
2760
  // Note: Check each parameter individually
2727
2761
  for (const parameter of pipeline.parameters) {
2728
2762
  if (parameter.isInput && parameter.isOutput) {
2729
- throw new PipelineLogicError(spaceTrim((block) => `
2763
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2730
2764
 
2731
2765
  Parameter \`{${parameter.name}}\` can not be both input and output
2732
2766
 
@@ -2737,7 +2771,7 @@ function validatePipeline_InnerFunction(pipeline) {
2737
2771
  if (!parameter.isInput &&
2738
2772
  !parameter.isOutput &&
2739
2773
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2740
- throw new PipelineLogicError(spaceTrim((block) => `
2774
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2741
2775
  Parameter \`{${parameter.name}}\` is created but not used
2742
2776
 
2743
2777
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2749,7 +2783,7 @@ function validatePipeline_InnerFunction(pipeline) {
2749
2783
  }
2750
2784
  // Note: Testing that parameter is either input or result of some task
2751
2785
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2752
- throw new PipelineLogicError(spaceTrim((block) => `
2786
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2753
2787
  Parameter \`{${parameter.name}}\` is declared but not defined
2754
2788
 
2755
2789
  You can do one of these:
@@ -2765,14 +2799,14 @@ function validatePipeline_InnerFunction(pipeline) {
2765
2799
  // Note: Checking each task individually
2766
2800
  for (const task of pipeline.tasks) {
2767
2801
  if (definedParameters.has(task.resultingParameterName)) {
2768
- throw new PipelineLogicError(spaceTrim((block) => `
2802
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2769
2803
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2770
2804
 
2771
2805
  ${block(pipelineIdentification)}
2772
2806
  `));
2773
2807
  }
2774
2808
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2775
- throw new PipelineLogicError(spaceTrim((block) => `
2809
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2776
2810
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2777
2811
 
2778
2812
  ${block(pipelineIdentification)}
@@ -2782,7 +2816,7 @@ function validatePipeline_InnerFunction(pipeline) {
2782
2816
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2783
2817
  if (!task.format &&
2784
2818
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2785
- throw new PipelineLogicError(spaceTrim((block) => `
2819
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2786
2820
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2787
2821
 
2788
2822
  ${block(pipelineIdentification)}
@@ -2790,7 +2824,7 @@ function validatePipeline_InnerFunction(pipeline) {
2790
2824
  }
2791
2825
  for (const joker of task.jokerParameterNames) {
2792
2826
  if (!task.dependentParameterNames.includes(joker)) {
2793
- throw new PipelineLogicError(spaceTrim((block) => `
2827
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2794
2828
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2795
2829
 
2796
2830
  ${block(pipelineIdentification)}
@@ -2801,21 +2835,21 @@ function validatePipeline_InnerFunction(pipeline) {
2801
2835
  if (task.expectations) {
2802
2836
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2803
2837
  if (min !== undefined && max !== undefined && min > max) {
2804
- throw new PipelineLogicError(spaceTrim((block) => `
2838
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2805
2839
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2806
2840
 
2807
2841
  ${block(pipelineIdentification)}
2808
2842
  `));
2809
2843
  }
2810
2844
  if (min !== undefined && min < 0) {
2811
- throw new PipelineLogicError(spaceTrim((block) => `
2845
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2812
2846
  Min expectation of ${unit} must be zero or positive
2813
2847
 
2814
2848
  ${block(pipelineIdentification)}
2815
2849
  `));
2816
2850
  }
2817
2851
  if (max !== undefined && max <= 0) {
2818
- throw new PipelineLogicError(spaceTrim((block) => `
2852
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2819
2853
  Max expectation of ${unit} must be positive
2820
2854
 
2821
2855
  ${block(pipelineIdentification)}
@@ -2837,7 +2871,7 @@ function validatePipeline_InnerFunction(pipeline) {
2837
2871
  while (unresovedTasks.length > 0) {
2838
2872
  if (loopLimit-- < 0) {
2839
2873
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2840
- throw new UnexpectedError(spaceTrim((block) => `
2874
+ throw new UnexpectedError(spaceTrim$1((block) => `
2841
2875
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2842
2876
 
2843
2877
  ${block(pipelineIdentification)}
@@ -2847,7 +2881,7 @@ function validatePipeline_InnerFunction(pipeline) {
2847
2881
  if (currentlyResovedTasks.length === 0) {
2848
2882
  throw new PipelineLogicError(
2849
2883
  // TODO: [🐎] DRY
2850
- spaceTrim((block) => `
2884
+ spaceTrim$1((block) => `
2851
2885
 
2852
2886
  Can not resolve some parameters:
2853
2887
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -3011,7 +3045,7 @@ class SimplePipelineCollection {
3011
3045
  for (const pipeline of pipelines) {
3012
3046
  // TODO: [👠] DRY
3013
3047
  if (pipeline.pipelineUrl === undefined) {
3014
- throw new PipelineUrlError(spaceTrim(`
3048
+ throw new PipelineUrlError(spaceTrim$1(`
3015
3049
  Pipeline with name "${pipeline.title}" does not have defined URL
3016
3050
 
3017
3051
  File:
@@ -3033,7 +3067,7 @@ class SimplePipelineCollection {
3033
3067
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3034
3068
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3035
3069
  const existing = this.collection.get(pipeline.pipelineUrl);
3036
- throw new PipelineUrlError(spaceTrim(`
3070
+ throw new PipelineUrlError(spaceTrim$1(`
3037
3071
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
3038
3072
 
3039
3073
  Conflicting files:
@@ -3065,13 +3099,13 @@ class SimplePipelineCollection {
3065
3099
  const pipeline = this.collection.get(url);
3066
3100
  if (!pipeline) {
3067
3101
  if (this.listPipelines().length === 0) {
3068
- throw new NotFoundError(spaceTrim(`
3102
+ throw new NotFoundError(spaceTrim$1(`
3069
3103
  Pipeline with url "${url}" not found
3070
3104
 
3071
3105
  No pipelines available
3072
3106
  `));
3073
3107
  }
3074
- throw new NotFoundError(spaceTrim((block) => `
3108
+ throw new NotFoundError(spaceTrim$1((block) => `
3075
3109
  Pipeline with url "${url}" not found
3076
3110
 
3077
3111
  Available pipelines:
@@ -3112,7 +3146,7 @@ function createPipelineCollectionFromJson(...promptbooks) {
3112
3146
  */
3113
3147
  class MissingToolsError extends Error {
3114
3148
  constructor(message) {
3115
- super(spaceTrim((block) => `
3149
+ super(spaceTrim$1((block) => `
3116
3150
  ${block(message)}
3117
3151
 
3118
3152
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -3399,7 +3433,7 @@ function serializeError(error) {
3399
3433
  const { name, message, stack } = error;
3400
3434
  const { id } = error;
3401
3435
  if (!Object.keys(ALL_ERRORS).includes(name)) {
3402
- console.error(spaceTrim$1((block) => `
3436
+ console.error(spaceTrim$2((block) => `
3403
3437
 
3404
3438
  Cannot serialize error with name "${name}"
3405
3439
 
@@ -3432,7 +3466,7 @@ function jsonParse(value) {
3432
3466
  }
3433
3467
  else if (typeof value !== 'string') {
3434
3468
  console.error('Can not parse JSON from non-string value.', { text: value });
3435
- throw new Error(spaceTrim$1(`
3469
+ throw new Error(spaceTrim$2(`
3436
3470
  Can not parse JSON from non-string value.
3437
3471
 
3438
3472
  The value type: ${typeof value}
@@ -3446,7 +3480,7 @@ function jsonParse(value) {
3446
3480
  if (!(error instanceof Error)) {
3447
3481
  throw error;
3448
3482
  }
3449
- throw new Error(spaceTrim$1((block) => `
3483
+ throw new Error(spaceTrim$2((block) => `
3450
3484
  ${block(error.message)}
3451
3485
 
3452
3486
  The expected JSON text:
@@ -3499,7 +3533,7 @@ function deserializeError(error) {
3499
3533
  message = `${name}: ${message}`;
3500
3534
  }
3501
3535
  if (stack !== undefined && stack !== '') {
3502
- message = spaceTrim$1((block) => `
3536
+ message = spaceTrim$2((block) => `
3503
3537
  ${block(message)}
3504
3538
 
3505
3539
  Original stack trace:
@@ -3536,11 +3570,11 @@ function assertsTaskSuccessful(executionResult) {
3536
3570
  throw deserializeError(errors[0]);
3537
3571
  }
3538
3572
  else {
3539
- throw new PipelineExecutionError(spaceTrim((block) => `
3573
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
3540
3574
  Multiple errors occurred during Promptbook execution
3541
3575
 
3542
3576
  ${block(errors
3543
- .map(({ name, stack, message }, index) => spaceTrim((block) => `
3577
+ .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
3544
3578
  ${name} ${index + 1}:
3545
3579
  ${block(stack || message)}
3546
3580
  `))
@@ -4011,14 +4045,14 @@ class MultipleLlmExecutionTools {
4011
4045
  if (description === undefined) {
4012
4046
  return headLine;
4013
4047
  }
4014
- return spaceTrim$1((block) => `
4048
+ return spaceTrim$2((block) => `
4015
4049
  ${headLine}
4016
4050
 
4017
4051
  ${ /* <- Note: Indenting the description: */block(description)}
4018
4052
  `);
4019
4053
  })
4020
4054
  .join('\n\n');
4021
- return spaceTrim$1((block) => `
4055
+ return spaceTrim$2((block) => `
4022
4056
  Multiple LLM Providers:
4023
4057
 
4024
4058
  ${block(innerModelsTitlesAndDescriptions)}
@@ -4109,7 +4143,7 @@ class MultipleLlmExecutionTools {
4109
4143
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
4110
4144
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
4111
4145
  // 3) ...
4112
- spaceTrim$1((block) => `
4146
+ spaceTrim$2((block) => `
4113
4147
  All execution tools of ${this.title} failed:
4114
4148
 
4115
4149
  ${block(errors
@@ -4122,7 +4156,7 @@ class MultipleLlmExecutionTools {
4122
4156
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
4123
4157
  }
4124
4158
  else {
4125
- throw new PipelineExecutionError(spaceTrim$1((block) => `
4159
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
4126
4160
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
4127
4161
 
4128
4162
  Available \`LlmExecutionTools\`:
@@ -4155,7 +4189,7 @@ class MultipleLlmExecutionTools {
4155
4189
  */
4156
4190
  function joinLlmExecutionTools(title, ...llmExecutionTools) {
4157
4191
  if (llmExecutionTools.length === 0) {
4158
- const warningMessage = spaceTrim$1(`
4192
+ const warningMessage = spaceTrim$2(`
4159
4193
  You have not provided any \`LlmExecutionTools\`
4160
4194
  This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
4161
4195
 
@@ -4328,14 +4362,14 @@ function $registeredScrapersMessage(availableScrapers) {
4328
4362
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
4329
4363
  });
4330
4364
  if (metadata.length === 0) {
4331
- return spaceTrim$1(`
4365
+ return spaceTrim$2(`
4332
4366
  **No scrapers are available**
4333
4367
 
4334
4368
  This is a unexpected behavior, you are probably using some broken version of Promptbook
4335
4369
  At least there should be available the metadata of the scrapers
4336
4370
  `);
4337
4371
  }
4338
- return spaceTrim$1((block) => `
4372
+ return spaceTrim$2((block) => `
4339
4373
  Available scrapers are:
4340
4374
  ${block(metadata
4341
4375
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -4471,7 +4505,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
4471
4505
  else if (urlOrRequest instanceof Request) {
4472
4506
  url = urlOrRequest.url;
4473
4507
  }
4474
- throw new PromptbookFetchError(spaceTrim$1((block) => `
4508
+ throw new PromptbookFetchError(spaceTrim$2((block) => `
4475
4509
  Can not fetch "${url}"
4476
4510
 
4477
4511
  Fetch error:
@@ -4632,7 +4666,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4632
4666
  const fileExtension = getFileExtension(filename);
4633
4667
  const mimeType = extensionToMimeType(fileExtension || '');
4634
4668
  if (!(await isFileExisting(filename, tools.fs))) {
4635
- throw new NotFoundError(spaceTrim$1((block) => `
4669
+ throw new NotFoundError(spaceTrim$2((block) => `
4636
4670
  Can not make source handler for file which does not exist:
4637
4671
 
4638
4672
  File:
@@ -4725,7 +4759,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4725
4759
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
4726
4760
  break;
4727
4761
  }
4728
- console.warn(spaceTrim$1((block) => `
4762
+ console.warn(spaceTrim$2((block) => `
4729
4763
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
4730
4764
 
4731
4765
  The source:
@@ -4741,7 +4775,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4741
4775
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4742
4776
  }
4743
4777
  if (partialPieces === null) {
4744
- throw new KnowledgeScrapeError(spaceTrim$1((block) => `
4778
+ throw new KnowledgeScrapeError(spaceTrim$2((block) => `
4745
4779
  Cannot scrape knowledge
4746
4780
 
4747
4781
  The source:
@@ -4820,7 +4854,7 @@ async function prepareTasks(pipeline, tools, options) {
4820
4854
  if (task.taskType === 'PROMPT_TASK' &&
4821
4855
  knowledgePiecesCount > 0 &&
4822
4856
  !dependentParameterNames.includes('knowledge')) {
4823
- preparedContent = spaceTrim(`
4857
+ preparedContent = spaceTrim$1(`
4824
4858
  {content}
4825
4859
 
4826
4860
  ## Knowledge
@@ -5133,7 +5167,7 @@ function extractVariablesFromJavascript(script) {
5133
5167
  }
5134
5168
  catch (error) {
5135
5169
  assertsError(error);
5136
- throw new ParseError(spaceTrim((block) => `
5170
+ throw new ParseError(spaceTrim$1((block) => `
5137
5171
  Can not extract variables from the script
5138
5172
  ${block(error.stack || error.message)}
5139
5173
 
@@ -5316,7 +5350,7 @@ const CsvFormatParser = {
5316
5350
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
5317
5351
  const csv = csvParse(value, settings);
5318
5352
  if (csv.errors.length !== 0) {
5319
- throw new CsvFormatError(spaceTrim$1((block) => `
5353
+ throw new CsvFormatError(spaceTrim$2((block) => `
5320
5354
  CSV parsing error
5321
5355
 
5322
5356
  Error(s) from CSV parsing:
@@ -5361,7 +5395,7 @@ const CsvFormatParser = {
5361
5395
  const { value, settings, mapCallback, onProgress } = options;
5362
5396
  const csv = csvParse(value, settings);
5363
5397
  if (csv.errors.length !== 0) {
5364
- throw new CsvFormatError(spaceTrim$1((block) => `
5398
+ throw new CsvFormatError(spaceTrim$2((block) => `
5365
5399
  CSV parsing error
5366
5400
 
5367
5401
  Error(s) from CSV parsing:
@@ -5571,7 +5605,7 @@ function mapAvailableToExpectedParameters(options) {
5571
5605
  }
5572
5606
  // Phase 2️⃣: Non-matching mapping
5573
5607
  if (expectedParameterNames.size !== availableParametersNames.size) {
5574
- throw new PipelineExecutionError(spaceTrim$1((block) => `
5608
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
5575
5609
  Can not map available parameters to expected parameters
5576
5610
 
5577
5611
  Mapped parameters:
@@ -5970,7 +6004,7 @@ function validatePromptResult(options) {
5970
6004
  }
5971
6005
  catch (error) {
5972
6006
  keepUnused(error);
5973
- throw new ExpectError(spaceTrim((block) => `
6007
+ throw new ExpectError(spaceTrim$1((block) => `
5974
6008
  Expected valid JSON string
5975
6009
 
5976
6010
  The expected JSON text:
@@ -6033,7 +6067,7 @@ async function executeAttempts(options) {
6033
6067
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
6034
6068
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
6035
6069
  if (isJokerAttempt && !jokerParameterName) {
6036
- throw new UnexpectedError(spaceTrim((block) => `
6070
+ throw new UnexpectedError(spaceTrim$1((block) => `
6037
6071
  Joker not found in attempt ${attemptIndex}
6038
6072
 
6039
6073
  ${block(pipelineIdentification)}
@@ -6044,7 +6078,7 @@ async function executeAttempts(options) {
6044
6078
  $ongoingTaskResult.$expectError = null;
6045
6079
  if (isJokerAttempt) {
6046
6080
  if (parameters[jokerParameterName] === undefined) {
6047
- throw new PipelineExecutionError(spaceTrim((block) => `
6081
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6048
6082
  Joker parameter {${jokerParameterName}} not defined
6049
6083
 
6050
6084
  ${block(pipelineIdentification)}
@@ -6102,7 +6136,7 @@ async function executeAttempts(options) {
6102
6136
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6103
6137
  break variant;
6104
6138
  case 'EMBEDDING':
6105
- throw new PipelineExecutionError(spaceTrim((block) => `
6139
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6106
6140
  Embedding model can not be used in pipeline
6107
6141
 
6108
6142
  This should be catched during parsing
@@ -6113,7 +6147,7 @@ async function executeAttempts(options) {
6113
6147
  break variant;
6114
6148
  // <- case [🤖]:
6115
6149
  default:
6116
- throw new PipelineExecutionError(spaceTrim((block) => `
6150
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6117
6151
  Unknown model variant "${task.modelRequirements.modelVariant}"
6118
6152
 
6119
6153
  ${block(pipelineIdentification)}
@@ -6124,14 +6158,14 @@ async function executeAttempts(options) {
6124
6158
  break;
6125
6159
  case 'SCRIPT_TASK':
6126
6160
  if (arrayableToArray(tools.script).length === 0) {
6127
- throw new PipelineExecutionError(spaceTrim((block) => `
6161
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6128
6162
  No script execution tools are available
6129
6163
 
6130
6164
  ${block(pipelineIdentification)}
6131
6165
  `));
6132
6166
  }
6133
6167
  if (!task.contentLanguage) {
6134
- throw new PipelineExecutionError(spaceTrim((block) => `
6168
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6135
6169
  Script language is not defined for SCRIPT TASK "${task.name}"
6136
6170
 
6137
6171
  ${block(pipelineIdentification)}
@@ -6162,7 +6196,7 @@ async function executeAttempts(options) {
6162
6196
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6163
6197
  }
6164
6198
  else {
6165
- throw new PipelineExecutionError(spaceTrim((block) => `
6199
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6166
6200
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6167
6201
 
6168
6202
  ${block(pipelineIdentification)}
@@ -6176,7 +6210,7 @@ async function executeAttempts(options) {
6176
6210
  break taskType;
6177
6211
  case 'DIALOG_TASK':
6178
6212
  if (tools.userInterface === undefined) {
6179
- throw new PipelineExecutionError(spaceTrim((block) => `
6213
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6180
6214
  User interface tools are not available
6181
6215
 
6182
6216
  ${block(pipelineIdentification)}
@@ -6194,7 +6228,7 @@ async function executeAttempts(options) {
6194
6228
  break taskType;
6195
6229
  // <- case: [🅱]
6196
6230
  default:
6197
- throw new PipelineExecutionError(spaceTrim((block) => `
6231
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6198
6232
  Unknown execution type "${task.taskType}"
6199
6233
 
6200
6234
  ${block(pipelineIdentification)}
@@ -6292,7 +6326,7 @@ async function executeAttempts(options) {
6292
6326
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6293
6327
  // Note: Create a summary of all failures
6294
6328
  const failuresSummary = $ongoingTaskResult.$failedResults
6295
- .map((failure) => spaceTrim((block) => {
6329
+ .map((failure) => spaceTrim$1((block) => {
6296
6330
  var _a, _b;
6297
6331
  return `
6298
6332
  Attempt ${failure.attemptIndex + 1}:
@@ -6302,14 +6336,14 @@ async function executeAttempts(options) {
6302
6336
  Result:
6303
6337
  ${block(failure.result === null
6304
6338
  ? 'null'
6305
- : spaceTrim(failure.result)
6339
+ : spaceTrim$1(failure.result)
6306
6340
  .split('\n')
6307
6341
  .map((line) => `> ${line}`)
6308
6342
  .join('\n'))}
6309
6343
  `;
6310
6344
  }))
6311
6345
  .join('\n\n---\n\n');
6312
- throw new PipelineExecutionError(spaceTrim((block) => {
6346
+ throw new PipelineExecutionError(spaceTrim$1((block) => {
6313
6347
  var _a;
6314
6348
  return `
6315
6349
  LLM execution failed ${maxExecutionAttempts}x
@@ -6329,7 +6363,7 @@ async function executeAttempts(options) {
6329
6363
  }
6330
6364
  }
6331
6365
  if ($ongoingTaskResult.$resultString === null) {
6332
- throw new UnexpectedError(spaceTrim((block) => `
6366
+ throw new UnexpectedError(spaceTrim$1((block) => `
6333
6367
  Something went wrong and prompt result is null
6334
6368
 
6335
6369
  ${block(pipelineIdentification)}
@@ -6356,7 +6390,7 @@ async function executeFormatSubvalues(options) {
6356
6390
  return /* not await */ executeAttempts({ ...options, logLlmCall });
6357
6391
  }
6358
6392
  if (jokerParameterNames.length !== 0) {
6359
- throw new UnexpectedError(spaceTrim$1((block) => `
6393
+ throw new UnexpectedError(spaceTrim$2((block) => `
6360
6394
  JOKER parameters are not supported together with FOREACH command
6361
6395
 
6362
6396
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6369,7 +6403,7 @@ async function executeFormatSubvalues(options) {
6369
6403
  if (formatDefinition === undefined) {
6370
6404
  throw new UnexpectedError(
6371
6405
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6372
- spaceTrim$1((block) => `
6406
+ spaceTrim$2((block) => `
6373
6407
  Unsupported format "${task.foreach.formatName}"
6374
6408
 
6375
6409
  Available formats:
@@ -6386,7 +6420,7 @@ async function executeFormatSubvalues(options) {
6386
6420
  if (subvalueParser === undefined) {
6387
6421
  throw new UnexpectedError(
6388
6422
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6389
- spaceTrim$1((block) => `
6423
+ spaceTrim$2((block) => `
6390
6424
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6391
6425
 
6392
6426
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6426,7 +6460,7 @@ async function executeFormatSubvalues(options) {
6426
6460
  if (!(error instanceof PipelineExecutionError)) {
6427
6461
  throw error;
6428
6462
  }
6429
- const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6463
+ const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
6430
6464
  ${error.message}
6431
6465
 
6432
6466
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6450,7 +6484,7 @@ async function executeFormatSubvalues(options) {
6450
6484
  ...options,
6451
6485
  priority: priority + index,
6452
6486
  parameters: allSubparameters,
6453
- pipelineIdentification: spaceTrim$1((block) => `
6487
+ pipelineIdentification: spaceTrim$2((block) => `
6454
6488
  ${block(pipelineIdentification)}
6455
6489
  Subparameter index: ${index}
6456
6490
  `),
@@ -6459,7 +6493,7 @@ async function executeFormatSubvalues(options) {
6459
6493
  }
6460
6494
  catch (error) {
6461
6495
  if (length > BIG_DATASET_TRESHOLD) {
6462
- console.error(spaceTrim$1((block) => `
6496
+ console.error(spaceTrim$2((block) => `
6463
6497
  ${error.message}
6464
6498
 
6465
6499
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6635,7 +6669,7 @@ async function getReservedParametersForTask(options) {
6635
6669
  // Note: Doublecheck that ALL reserved parameters are defined:
6636
6670
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6637
6671
  if (reservedParameters[parameterName] === undefined) {
6638
- throw new UnexpectedError(spaceTrim((block) => `
6672
+ throw new UnexpectedError(spaceTrim$1((block) => `
6639
6673
  Reserved parameter {${parameterName}} is not defined
6640
6674
 
6641
6675
  ${block(pipelineIdentification)}
@@ -6661,7 +6695,7 @@ async function executeTask(options) {
6661
6695
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6662
6696
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6663
6697
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6664
- throw new UnexpectedError(spaceTrim((block) => `
6698
+ throw new UnexpectedError(spaceTrim$1((block) => `
6665
6699
  Dependent parameters are not consistent with used parameters:
6666
6700
 
6667
6701
  Dependent parameters:
@@ -6705,7 +6739,7 @@ async function executeTask(options) {
6705
6739
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
6706
6740
  // Houston, we have a problem
6707
6741
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
6708
- throw new UnexpectedError(spaceTrim((block) => `
6742
+ throw new UnexpectedError(spaceTrim$1((block) => `
6709
6743
  Parameter \`{${parameterName}}\` is NOT defined
6710
6744
  BUT used in task "${currentTask.title || currentTask.name}"
6711
6745
 
@@ -6774,7 +6808,7 @@ function filterJustOutputParameters(options) {
6774
6808
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
6775
6809
  if (parametersToPass[parameter.name] === undefined) {
6776
6810
  // [4]
6777
- $warnings.push(new PipelineExecutionError(spaceTrim((block) => `
6811
+ $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6778
6812
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
6779
6813
 
6780
6814
  Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
@@ -6882,7 +6916,7 @@ async function executePipeline(options) {
6882
6916
  for (const parameterName of Object.keys(inputParameters)) {
6883
6917
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
6884
6918
  if (parameter === undefined) {
6885
- warnings.push(new PipelineExecutionError(spaceTrim((block) => `
6919
+ warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6886
6920
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
6887
6921
 
6888
6922
  ${block(pipelineIdentification)}
@@ -6897,7 +6931,7 @@ async function executePipeline(options) {
6897
6931
  // TODO: [🧠] This should be also non-critical error
6898
6932
  return exportJson({
6899
6933
  name: 'pipelineExecutorResult',
6900
- message: spaceTrim((block) => `
6934
+ message: spaceTrim$1((block) => `
6901
6935
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
6902
6936
 
6903
6937
  ${block(pipelineIdentification)}
@@ -6906,7 +6940,7 @@ async function executePipeline(options) {
6906
6940
  value: {
6907
6941
  isSuccessful: false,
6908
6942
  errors: [
6909
- new PipelineExecutionError(spaceTrim((block) => `
6943
+ new PipelineExecutionError(spaceTrim$1((block) => `
6910
6944
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
6911
6945
 
6912
6946
  ${block(pipelineIdentification)}
@@ -6933,7 +6967,7 @@ async function executePipeline(options) {
6933
6967
  while (unresovedTasks.length > 0) {
6934
6968
  if (loopLimit-- < 0) {
6935
6969
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
6936
- throw new UnexpectedError(spaceTrim((block) => `
6970
+ throw new UnexpectedError(spaceTrim$1((block) => `
6937
6971
  Loop limit reached during resolving parameters pipeline execution
6938
6972
 
6939
6973
  ${block(pipelineIdentification)}
@@ -6943,7 +6977,7 @@ async function executePipeline(options) {
6943
6977
  if (!currentTask && resolving.length === 0) {
6944
6978
  throw new UnexpectedError(
6945
6979
  // TODO: [🐎] DRY
6946
- spaceTrim((block) => `
6980
+ spaceTrim$1((block) => `
6947
6981
  Can not resolve some parameters:
6948
6982
 
6949
6983
  ${block(pipelineIdentification)}
@@ -6983,7 +7017,7 @@ async function executePipeline(options) {
6983
7017
  tools,
6984
7018
  onProgress(newOngoingResult) {
6985
7019
  if (isReturned) {
6986
- throw new UnexpectedError(spaceTrim((block) => `
7020
+ throw new UnexpectedError(spaceTrim$1((block) => `
6987
7021
  Can not call \`onProgress\` after pipeline execution is finished
6988
7022
 
6989
7023
  ${block(pipelineIdentification)}
@@ -7000,7 +7034,7 @@ async function executePipeline(options) {
7000
7034
  },
7001
7035
  logLlmCall,
7002
7036
  $executionReport: executionReport,
7003
- pipelineIdentification: spaceTrim((block) => `
7037
+ pipelineIdentification: spaceTrim$1((block) => `
7004
7038
  ${block(pipelineIdentification)}
7005
7039
  Task name: ${currentTask.name}
7006
7040
  Task title: ${currentTask.title}
@@ -7109,7 +7143,7 @@ function createPipelineExecutor(options) {
7109
7143
  preparedPipeline = pipeline;
7110
7144
  }
7111
7145
  else if (isNotPreparedWarningSuppressed !== true) {
7112
- console.warn(spaceTrim((block) => `
7146
+ console.warn(spaceTrim$1((block) => `
7113
7147
  Pipeline is not prepared
7114
7148
 
7115
7149
  ${block(pipelineIdentification)}
@@ -7134,7 +7168,7 @@ function createPipelineExecutor(options) {
7134
7168
  tools,
7135
7169
  onProgress,
7136
7170
  logLlmCall,
7137
- pipelineIdentification: spaceTrim((block) => `
7171
+ pipelineIdentification: spaceTrim$1((block) => `
7138
7172
  ${block(pipelineIdentification)}
7139
7173
  ${runCount === 1 ? '' : `Run #${runCount}`}
7140
7174
  `),
@@ -7331,8 +7365,8 @@ class MarkdownScraper {
7331
7365
  knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
7332
7366
  // Note: These are just default values, they will be overwritten by the actual values:
7333
7367
  let name = `piece-${i}`;
7334
- let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
7335
- const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
7368
+ let title = spaceTrim$2(knowledgeTextPiece.substring(0, 100));
7369
+ const knowledgePieceContent = spaceTrim$2(knowledgeTextPiece);
7336
7370
  let keywords = [];
7337
7371
  const index = [];
7338
7372
  /*
@@ -7345,7 +7379,7 @@ class MarkdownScraper {
7345
7379
  isCrashedOnError: true,
7346
7380
  });
7347
7381
  const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
7348
- title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
7382
+ title = spaceTrim$2(titleRaw) /* <- TODO: Maybe do in pipeline */;
7349
7383
  name = titleToName(title);
7350
7384
  // --- Keywords
7351
7385
  const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({