@promptbook/remote-server 0.103.0-55 → 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,7 +1,7 @@
1
1
  import { join, basename, dirname, isAbsolute } from 'path';
2
2
  import { spawn } from 'child_process';
3
3
  import colors from 'colors';
4
- import spaceTrim$1, { spaceTrim } from 'spacetrim';
4
+ import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
5
5
  import { forTime } from 'waitasecond';
6
6
  import express from 'express';
7
7
  import * as OpenApiValidator from 'express-openapi-validator';
@@ -33,12 +33,23 @@ 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.103.0-55';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
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
40
40
  */
41
41
 
42
+ /**
43
+ * Trims string from all 4 sides
44
+ *
45
+ * Note: This is a re-exported function from the `spacetrim` package which is
46
+ * Developed by same author @hejny as this package
47
+ *
48
+ * @public exported from `@promptbook/utils`
49
+ * @see https://github.com/hejny/spacetrim#usage
50
+ */
51
+ const spaceTrim = spaceTrim$1;
52
+
42
53
  /**
43
54
  * @private util of `@promptbook/color`
44
55
  * @de
@@ -87,6 +98,7 @@ function take(initialValue) {
87
98
  * @public exported from `@promptbook/color`
88
99
  */
89
100
  const CSS_COLORS = {
101
+ promptbook: '#79EAFD',
90
102
  transparent: 'rgba(0,0,0,0)',
91
103
  aliceblue: '#f0f8ff',
92
104
  antiquewhite: '#faebd7',
@@ -302,6 +314,28 @@ class Color {
302
314
  throw new Error(`Can not create color from given object`);
303
315
  }
304
316
  }
317
+ /**
318
+ * Creates a new Color instance from miscellaneous formats
319
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
320
+ *
321
+ * @param color
322
+ * @returns Color object
323
+ */
324
+ static fromSafe(color) {
325
+ try {
326
+ return Color.from(color);
327
+ }
328
+ catch (error) {
329
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
330
+ console.warn(spaceTrim((block) => `
331
+ Color.fromSafe error:
332
+ ${block(error.message)}
333
+
334
+ Returning default PROMPTBOOK_COLOR.
335
+ `));
336
+ return Color.fromString('promptbook');
337
+ }
338
+ }
305
339
  /**
306
340
  * Creates a new Color instance from miscellaneous string formats
307
341
  *
@@ -919,7 +953,7 @@ const CLAIM = `Turn your company's scattered knowledge into AI ready books`;
919
953
  *
920
954
  * @public exported from `@promptbook/core`
921
955
  */
922
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
956
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
923
957
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
924
958
  /**
925
959
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1266,11 +1300,11 @@ function $execCommand(options) {
1266
1300
  console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
1267
1301
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1268
1302
  }
1269
- resolve(spaceTrim(output.join('\n')));
1303
+ resolve(spaceTrim$1(output.join('\n')));
1270
1304
  }
1271
1305
  }
1272
1306
  else {
1273
- resolve(spaceTrim(output.join('\n')));
1307
+ resolve(spaceTrim$1(output.join('\n')));
1274
1308
  }
1275
1309
  };
1276
1310
  commandProcess.on('close', finishWithCode);
@@ -1288,7 +1322,7 @@ function $execCommand(options) {
1288
1322
  console.warn(error);
1289
1323
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1290
1324
  }
1291
- resolve(spaceTrim(output.join('\n')));
1325
+ resolve(spaceTrim$1(output.join('\n')));
1292
1326
  }
1293
1327
  });
1294
1328
  }
@@ -1339,7 +1373,7 @@ async function startAgentServer(options) {
1339
1373
  function getErrorReportUrl(error) {
1340
1374
  const report = {
1341
1375
  title: `🐜 Error report from ${NAME}`,
1342
- body: spaceTrim$1((block) => `
1376
+ body: spaceTrim$2((block) => `
1343
1377
 
1344
1378
 
1345
1379
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1382,7 +1416,7 @@ function getErrorReportUrl(error) {
1382
1416
  */
1383
1417
  class UnexpectedError extends Error {
1384
1418
  constructor(message) {
1385
- super(spaceTrim((block) => `
1419
+ super(spaceTrim$1((block) => `
1386
1420
  ${block(message)}
1387
1421
 
1388
1422
  Note: This error should not happen.
@@ -1408,7 +1442,7 @@ class WrappedError extends Error {
1408
1442
  constructor(whatWasThrown) {
1409
1443
  const tag = `[🤮]`;
1410
1444
  console.error(tag, whatWasThrown);
1411
- super(spaceTrim(`
1445
+ super(spaceTrim$1(`
1412
1446
  Non-Error object was thrown
1413
1447
 
1414
1448
  Note: Look for ${tag} in the console for more details
@@ -1604,7 +1638,7 @@ class LimitReachedError extends Error {
1604
1638
  */
1605
1639
  class MissingToolsError extends Error {
1606
1640
  constructor(message) {
1607
- super(spaceTrim((block) => `
1641
+ super(spaceTrim$1((block) => `
1608
1642
  ${block(message)}
1609
1643
 
1610
1644
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -1648,7 +1682,7 @@ class NotFoundError extends Error {
1648
1682
  */
1649
1683
  class NotYetImplementedError extends Error {
1650
1684
  constructor(message) {
1651
- super(spaceTrim((block) => `
1685
+ super(spaceTrim$1((block) => `
1652
1686
  ${block(message)}
1653
1687
 
1654
1688
  Note: This feature is not implemented yet but it will be soon.
@@ -1792,7 +1826,7 @@ function serializeError(error) {
1792
1826
  const { name, message, stack } = error;
1793
1827
  const { id } = error;
1794
1828
  if (!Object.keys(ALL_ERRORS).includes(name)) {
1795
- console.error(spaceTrim$1((block) => `
1829
+ console.error(spaceTrim$2((block) => `
1796
1830
 
1797
1831
  Cannot serialize error with name "${name}"
1798
1832
 
@@ -2136,7 +2170,7 @@ function checkSerializableAsJson(options) {
2136
2170
  }
2137
2171
  else if (typeof value === 'object') {
2138
2172
  if (value instanceof Date) {
2139
- throw new UnexpectedError(spaceTrim$1((block) => `
2173
+ throw new UnexpectedError(spaceTrim$2((block) => `
2140
2174
  \`${name}\` is Date
2141
2175
 
2142
2176
  Use \`string_date_iso8601\` instead
@@ -2155,7 +2189,7 @@ function checkSerializableAsJson(options) {
2155
2189
  throw new UnexpectedError(`${name} is RegExp`);
2156
2190
  }
2157
2191
  else if (value instanceof Error) {
2158
- throw new UnexpectedError(spaceTrim$1((block) => `
2192
+ throw new UnexpectedError(spaceTrim$2((block) => `
2159
2193
  \`${name}\` is unserialized Error
2160
2194
 
2161
2195
  Use function \`serializeError\`
@@ -2178,7 +2212,7 @@ function checkSerializableAsJson(options) {
2178
2212
  }
2179
2213
  catch (error) {
2180
2214
  assertsError(error);
2181
- throw new UnexpectedError(spaceTrim$1((block) => `
2215
+ throw new UnexpectedError(spaceTrim$2((block) => `
2182
2216
  \`${name}\` is not serializable
2183
2217
 
2184
2218
  ${block(error.stack || error.message)}
@@ -2210,7 +2244,7 @@ function checkSerializableAsJson(options) {
2210
2244
  }
2211
2245
  }
2212
2246
  else {
2213
- throw new UnexpectedError(spaceTrim$1((block) => `
2247
+ throw new UnexpectedError(spaceTrim$2((block) => `
2214
2248
  \`${name}\` is unknown type
2215
2249
 
2216
2250
  Additional message for \`${name}\`:
@@ -2481,7 +2515,7 @@ function validatePipeline(pipeline) {
2481
2515
  if (!(error instanceof PipelineLogicError)) {
2482
2516
  throw error;
2483
2517
  }
2484
- console.error(spaceTrim((block) => `
2518
+ console.error(spaceTrim$1((block) => `
2485
2519
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2486
2520
 
2487
2521
  ${block(error.message)}
@@ -2508,7 +2542,7 @@ function validatePipeline_InnerFunction(pipeline) {
2508
2542
  })();
2509
2543
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2510
2544
  // <- Note: [🚲]
2511
- throw new PipelineLogicError(spaceTrim((block) => `
2545
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2512
2546
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2513
2547
 
2514
2548
  ${block(pipelineIdentification)}
@@ -2516,7 +2550,7 @@ function validatePipeline_InnerFunction(pipeline) {
2516
2550
  }
2517
2551
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2518
2552
  // <- Note: [🚲]
2519
- throw new PipelineLogicError(spaceTrim((block) => `
2553
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2520
2554
  Invalid Promptbook Version "${pipeline.bookVersion}"
2521
2555
 
2522
2556
  ${block(pipelineIdentification)}
@@ -2525,7 +2559,7 @@ function validatePipeline_InnerFunction(pipeline) {
2525
2559
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2526
2560
  if (!Array.isArray(pipeline.parameters)) {
2527
2561
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2528
- throw new ParseError(spaceTrim((block) => `
2562
+ throw new ParseError(spaceTrim$1((block) => `
2529
2563
  Pipeline is valid JSON but with wrong structure
2530
2564
 
2531
2565
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2536,7 +2570,7 @@ function validatePipeline_InnerFunction(pipeline) {
2536
2570
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2537
2571
  if (!Array.isArray(pipeline.tasks)) {
2538
2572
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2539
- throw new ParseError(spaceTrim((block) => `
2573
+ throw new ParseError(spaceTrim$1((block) => `
2540
2574
  Pipeline is valid JSON but with wrong structure
2541
2575
 
2542
2576
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2562,7 +2596,7 @@ function validatePipeline_InnerFunction(pipeline) {
2562
2596
  // Note: Check each parameter individually
2563
2597
  for (const parameter of pipeline.parameters) {
2564
2598
  if (parameter.isInput && parameter.isOutput) {
2565
- throw new PipelineLogicError(spaceTrim((block) => `
2599
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2566
2600
 
2567
2601
  Parameter \`{${parameter.name}}\` can not be both input and output
2568
2602
 
@@ -2573,7 +2607,7 @@ function validatePipeline_InnerFunction(pipeline) {
2573
2607
  if (!parameter.isInput &&
2574
2608
  !parameter.isOutput &&
2575
2609
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2576
- throw new PipelineLogicError(spaceTrim((block) => `
2610
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2577
2611
  Parameter \`{${parameter.name}}\` is created but not used
2578
2612
 
2579
2613
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2585,7 +2619,7 @@ function validatePipeline_InnerFunction(pipeline) {
2585
2619
  }
2586
2620
  // Note: Testing that parameter is either input or result of some task
2587
2621
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2588
- throw new PipelineLogicError(spaceTrim((block) => `
2622
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2589
2623
  Parameter \`{${parameter.name}}\` is declared but not defined
2590
2624
 
2591
2625
  You can do one of these:
@@ -2601,14 +2635,14 @@ function validatePipeline_InnerFunction(pipeline) {
2601
2635
  // Note: Checking each task individually
2602
2636
  for (const task of pipeline.tasks) {
2603
2637
  if (definedParameters.has(task.resultingParameterName)) {
2604
- throw new PipelineLogicError(spaceTrim((block) => `
2638
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2605
2639
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2606
2640
 
2607
2641
  ${block(pipelineIdentification)}
2608
2642
  `));
2609
2643
  }
2610
2644
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2611
- throw new PipelineLogicError(spaceTrim((block) => `
2645
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2612
2646
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2613
2647
 
2614
2648
  ${block(pipelineIdentification)}
@@ -2618,7 +2652,7 @@ function validatePipeline_InnerFunction(pipeline) {
2618
2652
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2619
2653
  if (!task.format &&
2620
2654
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2621
- throw new PipelineLogicError(spaceTrim((block) => `
2655
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2622
2656
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2623
2657
 
2624
2658
  ${block(pipelineIdentification)}
@@ -2626,7 +2660,7 @@ function validatePipeline_InnerFunction(pipeline) {
2626
2660
  }
2627
2661
  for (const joker of task.jokerParameterNames) {
2628
2662
  if (!task.dependentParameterNames.includes(joker)) {
2629
- throw new PipelineLogicError(spaceTrim((block) => `
2663
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2630
2664
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2631
2665
 
2632
2666
  ${block(pipelineIdentification)}
@@ -2637,21 +2671,21 @@ function validatePipeline_InnerFunction(pipeline) {
2637
2671
  if (task.expectations) {
2638
2672
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2639
2673
  if (min !== undefined && max !== undefined && min > max) {
2640
- throw new PipelineLogicError(spaceTrim((block) => `
2674
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2641
2675
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2642
2676
 
2643
2677
  ${block(pipelineIdentification)}
2644
2678
  `));
2645
2679
  }
2646
2680
  if (min !== undefined && min < 0) {
2647
- throw new PipelineLogicError(spaceTrim((block) => `
2681
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2648
2682
  Min expectation of ${unit} must be zero or positive
2649
2683
 
2650
2684
  ${block(pipelineIdentification)}
2651
2685
  `));
2652
2686
  }
2653
2687
  if (max !== undefined && max <= 0) {
2654
- throw new PipelineLogicError(spaceTrim((block) => `
2688
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2655
2689
  Max expectation of ${unit} must be positive
2656
2690
 
2657
2691
  ${block(pipelineIdentification)}
@@ -2673,7 +2707,7 @@ function validatePipeline_InnerFunction(pipeline) {
2673
2707
  while (unresovedTasks.length > 0) {
2674
2708
  if (loopLimit-- < 0) {
2675
2709
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2676
- throw new UnexpectedError(spaceTrim((block) => `
2710
+ throw new UnexpectedError(spaceTrim$1((block) => `
2677
2711
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2678
2712
 
2679
2713
  ${block(pipelineIdentification)}
@@ -2683,7 +2717,7 @@ function validatePipeline_InnerFunction(pipeline) {
2683
2717
  if (currentlyResovedTasks.length === 0) {
2684
2718
  throw new PipelineLogicError(
2685
2719
  // TODO: [🐎] DRY
2686
- spaceTrim((block) => `
2720
+ spaceTrim$1((block) => `
2687
2721
 
2688
2722
  Can not resolve some parameters:
2689
2723
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2820,7 +2854,7 @@ function jsonParse(value) {
2820
2854
  }
2821
2855
  else if (typeof value !== 'string') {
2822
2856
  console.error('Can not parse JSON from non-string value.', { text: value });
2823
- throw new Error(spaceTrim$1(`
2857
+ throw new Error(spaceTrim$2(`
2824
2858
  Can not parse JSON from non-string value.
2825
2859
 
2826
2860
  The value type: ${typeof value}
@@ -2834,7 +2868,7 @@ function jsonParse(value) {
2834
2868
  if (!(error instanceof Error)) {
2835
2869
  throw error;
2836
2870
  }
2837
- throw new Error(spaceTrim$1((block) => `
2871
+ throw new Error(spaceTrim$2((block) => `
2838
2872
  ${block(error.message)}
2839
2873
 
2840
2874
  The expected JSON text:
@@ -2887,7 +2921,7 @@ function deserializeError(error) {
2887
2921
  message = `${name}: ${message}`;
2888
2922
  }
2889
2923
  if (stack !== undefined && stack !== '') {
2890
- message = spaceTrim$1((block) => `
2924
+ message = spaceTrim$2((block) => `
2891
2925
  ${block(message)}
2892
2926
 
2893
2927
  Original stack trace:
@@ -2924,11 +2958,11 @@ function assertsTaskSuccessful(executionResult) {
2924
2958
  throw deserializeError(errors[0]);
2925
2959
  }
2926
2960
  else {
2927
- throw new PipelineExecutionError(spaceTrim((block) => `
2961
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
2928
2962
  Multiple errors occurred during Promptbook execution
2929
2963
 
2930
2964
  ${block(errors
2931
- .map(({ name, stack, message }, index) => spaceTrim((block) => `
2965
+ .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
2932
2966
  ${name} ${index + 1}:
2933
2967
  ${block(stack || message)}
2934
2968
  `))
@@ -3440,7 +3474,7 @@ function pipelineJsonToString(pipelineJson) {
3440
3474
  pipelineString += '\n\n';
3441
3475
  pipelineString += '```' + contentLanguage;
3442
3476
  pipelineString += '\n';
3443
- pipelineString += spaceTrim$1(content);
3477
+ pipelineString += spaceTrim$2(content);
3444
3478
  // <- TODO: [main] !!3 Escape
3445
3479
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
3446
3480
  pipelineString += '\n';
@@ -3545,7 +3579,7 @@ class SimplePipelineCollection {
3545
3579
  for (const pipeline of pipelines) {
3546
3580
  // TODO: [👠] DRY
3547
3581
  if (pipeline.pipelineUrl === undefined) {
3548
- throw new PipelineUrlError(spaceTrim(`
3582
+ throw new PipelineUrlError(spaceTrim$1(`
3549
3583
  Pipeline with name "${pipeline.title}" does not have defined URL
3550
3584
 
3551
3585
  File:
@@ -3567,7 +3601,7 @@ class SimplePipelineCollection {
3567
3601
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3568
3602
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3569
3603
  const existing = this.collection.get(pipeline.pipelineUrl);
3570
- throw new PipelineUrlError(spaceTrim(`
3604
+ throw new PipelineUrlError(spaceTrim$1(`
3571
3605
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
3572
3606
 
3573
3607
  Conflicting files:
@@ -3599,13 +3633,13 @@ class SimplePipelineCollection {
3599
3633
  const pipeline = this.collection.get(url);
3600
3634
  if (!pipeline) {
3601
3635
  if (this.listPipelines().length === 0) {
3602
- throw new NotFoundError(spaceTrim(`
3636
+ throw new NotFoundError(spaceTrim$1(`
3603
3637
  Pipeline with url "${url}" not found
3604
3638
 
3605
3639
  No pipelines available
3606
3640
  `));
3607
3641
  }
3608
- throw new NotFoundError(spaceTrim((block) => `
3642
+ throw new NotFoundError(spaceTrim$1((block) => `
3609
3643
  Pipeline with url "${url}" not found
3610
3644
 
3611
3645
  Available pipelines:
@@ -3836,14 +3870,14 @@ class MultipleLlmExecutionTools {
3836
3870
  if (description === undefined) {
3837
3871
  return headLine;
3838
3872
  }
3839
- return spaceTrim$1((block) => `
3873
+ return spaceTrim$2((block) => `
3840
3874
  ${headLine}
3841
3875
 
3842
3876
  ${ /* <- Note: Indenting the description: */block(description)}
3843
3877
  `);
3844
3878
  })
3845
3879
  .join('\n\n');
3846
- return spaceTrim$1((block) => `
3880
+ return spaceTrim$2((block) => `
3847
3881
  Multiple LLM Providers:
3848
3882
 
3849
3883
  ${block(innerModelsTitlesAndDescriptions)}
@@ -3934,7 +3968,7 @@ class MultipleLlmExecutionTools {
3934
3968
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3935
3969
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3936
3970
  // 3) ...
3937
- spaceTrim$1((block) => `
3971
+ spaceTrim$2((block) => `
3938
3972
  All execution tools of ${this.title} failed:
3939
3973
 
3940
3974
  ${block(errors
@@ -3947,7 +3981,7 @@ class MultipleLlmExecutionTools {
3947
3981
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
3948
3982
  }
3949
3983
  else {
3950
- throw new PipelineExecutionError(spaceTrim$1((block) => `
3984
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
3951
3985
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
3952
3986
 
3953
3987
  Available \`LlmExecutionTools\`:
@@ -3980,7 +4014,7 @@ class MultipleLlmExecutionTools {
3980
4014
  */
3981
4015
  function joinLlmExecutionTools(title, ...llmExecutionTools) {
3982
4016
  if (llmExecutionTools.length === 0) {
3983
- const warningMessage = spaceTrim$1(`
4017
+ const warningMessage = spaceTrim$2(`
3984
4018
  You have not provided any \`LlmExecutionTools\`
3985
4019
  This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
3986
4020
 
@@ -4297,14 +4331,14 @@ function $registeredScrapersMessage(availableScrapers) {
4297
4331
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
4298
4332
  });
4299
4333
  if (metadata.length === 0) {
4300
- return spaceTrim$1(`
4334
+ return spaceTrim$2(`
4301
4335
  **No scrapers are available**
4302
4336
 
4303
4337
  This is a unexpected behavior, you are probably using some broken version of Promptbook
4304
4338
  At least there should be available the metadata of the scrapers
4305
4339
  `);
4306
4340
  }
4307
- return spaceTrim$1((block) => `
4341
+ return spaceTrim$2((block) => `
4308
4342
  Available scrapers are:
4309
4343
  ${block(metadata
4310
4344
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -4810,7 +4844,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
4810
4844
  else if (urlOrRequest instanceof Request) {
4811
4845
  url = urlOrRequest.url;
4812
4846
  }
4813
- throw new PromptbookFetchError(spaceTrim$1((block) => `
4847
+ throw new PromptbookFetchError(spaceTrim$2((block) => `
4814
4848
  Can not fetch "${url}"
4815
4849
 
4816
4850
  Fetch error:
@@ -4971,7 +5005,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4971
5005
  const fileExtension = getFileExtension(filename);
4972
5006
  const mimeType = extensionToMimeType(fileExtension || '');
4973
5007
  if (!(await isFileExisting(filename, tools.fs))) {
4974
- throw new NotFoundError(spaceTrim$1((block) => `
5008
+ throw new NotFoundError(spaceTrim$2((block) => `
4975
5009
  Can not make source handler for file which does not exist:
4976
5010
 
4977
5011
  File:
@@ -5064,7 +5098,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
5064
5098
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5065
5099
  break;
5066
5100
  }
5067
- console.warn(spaceTrim$1((block) => `
5101
+ console.warn(spaceTrim$2((block) => `
5068
5102
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
5069
5103
 
5070
5104
  The source:
@@ -5080,7 +5114,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
5080
5114
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
5081
5115
  }
5082
5116
  if (partialPieces === null) {
5083
- throw new KnowledgeScrapeError(spaceTrim$1((block) => `
5117
+ throw new KnowledgeScrapeError(spaceTrim$2((block) => `
5084
5118
  Cannot scrape knowledge
5085
5119
 
5086
5120
  The source:
@@ -5159,7 +5193,7 @@ async function prepareTasks(pipeline, tools, options) {
5159
5193
  if (task.taskType === 'PROMPT_TASK' &&
5160
5194
  knowledgePiecesCount > 0 &&
5161
5195
  !dependentParameterNames.includes('knowledge')) {
5162
- preparedContent = spaceTrim(`
5196
+ preparedContent = spaceTrim$1(`
5163
5197
  {content}
5164
5198
 
5165
5199
  ## Knowledge
@@ -5472,7 +5506,7 @@ function extractVariablesFromJavascript(script) {
5472
5506
  }
5473
5507
  catch (error) {
5474
5508
  assertsError(error);
5475
- throw new ParseError(spaceTrim((block) => `
5509
+ throw new ParseError(spaceTrim$1((block) => `
5476
5510
  Can not extract variables from the script
5477
5511
  ${block(error.stack || error.message)}
5478
5512
 
@@ -5655,7 +5689,7 @@ const CsvFormatParser = {
5655
5689
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
5656
5690
  const csv = csvParse(value, settings);
5657
5691
  if (csv.errors.length !== 0) {
5658
- throw new CsvFormatError(spaceTrim$1((block) => `
5692
+ throw new CsvFormatError(spaceTrim$2((block) => `
5659
5693
  CSV parsing error
5660
5694
 
5661
5695
  Error(s) from CSV parsing:
@@ -5700,7 +5734,7 @@ const CsvFormatParser = {
5700
5734
  const { value, settings, mapCallback, onProgress } = options;
5701
5735
  const csv = csvParse(value, settings);
5702
5736
  if (csv.errors.length !== 0) {
5703
- throw new CsvFormatError(spaceTrim$1((block) => `
5737
+ throw new CsvFormatError(spaceTrim$2((block) => `
5704
5738
  CSV parsing error
5705
5739
 
5706
5740
  Error(s) from CSV parsing:
@@ -5910,7 +5944,7 @@ function mapAvailableToExpectedParameters(options) {
5910
5944
  }
5911
5945
  // Phase 2️⃣: Non-matching mapping
5912
5946
  if (expectedParameterNames.size !== availableParametersNames.size) {
5913
- throw new PipelineExecutionError(spaceTrim$1((block) => `
5947
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
5914
5948
  Can not map available parameters to expected parameters
5915
5949
 
5916
5950
  Mapped parameters:
@@ -6326,7 +6360,7 @@ function validatePromptResult(options) {
6326
6360
  }
6327
6361
  catch (error) {
6328
6362
  keepUnused(error);
6329
- throw new ExpectError(spaceTrim((block) => `
6363
+ throw new ExpectError(spaceTrim$1((block) => `
6330
6364
  Expected valid JSON string
6331
6365
 
6332
6366
  The expected JSON text:
@@ -6389,7 +6423,7 @@ async function executeAttempts(options) {
6389
6423
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
6390
6424
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
6391
6425
  if (isJokerAttempt && !jokerParameterName) {
6392
- throw new UnexpectedError(spaceTrim((block) => `
6426
+ throw new UnexpectedError(spaceTrim$1((block) => `
6393
6427
  Joker not found in attempt ${attemptIndex}
6394
6428
 
6395
6429
  ${block(pipelineIdentification)}
@@ -6400,7 +6434,7 @@ async function executeAttempts(options) {
6400
6434
  $ongoingTaskResult.$expectError = null;
6401
6435
  if (isJokerAttempt) {
6402
6436
  if (parameters[jokerParameterName] === undefined) {
6403
- throw new PipelineExecutionError(spaceTrim((block) => `
6437
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6404
6438
  Joker parameter {${jokerParameterName}} not defined
6405
6439
 
6406
6440
  ${block(pipelineIdentification)}
@@ -6458,7 +6492,7 @@ async function executeAttempts(options) {
6458
6492
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6459
6493
  break variant;
6460
6494
  case 'EMBEDDING':
6461
- throw new PipelineExecutionError(spaceTrim((block) => `
6495
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6462
6496
  Embedding model can not be used in pipeline
6463
6497
 
6464
6498
  This should be catched during parsing
@@ -6469,7 +6503,7 @@ async function executeAttempts(options) {
6469
6503
  break variant;
6470
6504
  // <- case [🤖]:
6471
6505
  default:
6472
- throw new PipelineExecutionError(spaceTrim((block) => `
6506
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6473
6507
  Unknown model variant "${task.modelRequirements.modelVariant}"
6474
6508
 
6475
6509
  ${block(pipelineIdentification)}
@@ -6480,14 +6514,14 @@ async function executeAttempts(options) {
6480
6514
  break;
6481
6515
  case 'SCRIPT_TASK':
6482
6516
  if (arrayableToArray(tools.script).length === 0) {
6483
- throw new PipelineExecutionError(spaceTrim((block) => `
6517
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6484
6518
  No script execution tools are available
6485
6519
 
6486
6520
  ${block(pipelineIdentification)}
6487
6521
  `));
6488
6522
  }
6489
6523
  if (!task.contentLanguage) {
6490
- throw new PipelineExecutionError(spaceTrim((block) => `
6524
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6491
6525
  Script language is not defined for SCRIPT TASK "${task.name}"
6492
6526
 
6493
6527
  ${block(pipelineIdentification)}
@@ -6518,7 +6552,7 @@ async function executeAttempts(options) {
6518
6552
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6519
6553
  }
6520
6554
  else {
6521
- throw new PipelineExecutionError(spaceTrim((block) => `
6555
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6522
6556
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6523
6557
 
6524
6558
  ${block(pipelineIdentification)}
@@ -6532,7 +6566,7 @@ async function executeAttempts(options) {
6532
6566
  break taskType;
6533
6567
  case 'DIALOG_TASK':
6534
6568
  if (tools.userInterface === undefined) {
6535
- throw new PipelineExecutionError(spaceTrim((block) => `
6569
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6536
6570
  User interface tools are not available
6537
6571
 
6538
6572
  ${block(pipelineIdentification)}
@@ -6550,7 +6584,7 @@ async function executeAttempts(options) {
6550
6584
  break taskType;
6551
6585
  // <- case: [🅱]
6552
6586
  default:
6553
- throw new PipelineExecutionError(spaceTrim((block) => `
6587
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6554
6588
  Unknown execution type "${task.taskType}"
6555
6589
 
6556
6590
  ${block(pipelineIdentification)}
@@ -6648,7 +6682,7 @@ async function executeAttempts(options) {
6648
6682
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6649
6683
  // Note: Create a summary of all failures
6650
6684
  const failuresSummary = $ongoingTaskResult.$failedResults
6651
- .map((failure) => spaceTrim((block) => {
6685
+ .map((failure) => spaceTrim$1((block) => {
6652
6686
  var _a, _b;
6653
6687
  return `
6654
6688
  Attempt ${failure.attemptIndex + 1}:
@@ -6658,14 +6692,14 @@ async function executeAttempts(options) {
6658
6692
  Result:
6659
6693
  ${block(failure.result === null
6660
6694
  ? 'null'
6661
- : spaceTrim(failure.result)
6695
+ : spaceTrim$1(failure.result)
6662
6696
  .split('\n')
6663
6697
  .map((line) => `> ${line}`)
6664
6698
  .join('\n'))}
6665
6699
  `;
6666
6700
  }))
6667
6701
  .join('\n\n---\n\n');
6668
- throw new PipelineExecutionError(spaceTrim((block) => {
6702
+ throw new PipelineExecutionError(spaceTrim$1((block) => {
6669
6703
  var _a;
6670
6704
  return `
6671
6705
  LLM execution failed ${maxExecutionAttempts}x
@@ -6685,7 +6719,7 @@ async function executeAttempts(options) {
6685
6719
  }
6686
6720
  }
6687
6721
  if ($ongoingTaskResult.$resultString === null) {
6688
- throw new UnexpectedError(spaceTrim((block) => `
6722
+ throw new UnexpectedError(spaceTrim$1((block) => `
6689
6723
  Something went wrong and prompt result is null
6690
6724
 
6691
6725
  ${block(pipelineIdentification)}
@@ -6712,7 +6746,7 @@ async function executeFormatSubvalues(options) {
6712
6746
  return /* not await */ executeAttempts({ ...options, logLlmCall });
6713
6747
  }
6714
6748
  if (jokerParameterNames.length !== 0) {
6715
- throw new UnexpectedError(spaceTrim$1((block) => `
6749
+ throw new UnexpectedError(spaceTrim$2((block) => `
6716
6750
  JOKER parameters are not supported together with FOREACH command
6717
6751
 
6718
6752
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6725,7 +6759,7 @@ async function executeFormatSubvalues(options) {
6725
6759
  if (formatDefinition === undefined) {
6726
6760
  throw new UnexpectedError(
6727
6761
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6728
- spaceTrim$1((block) => `
6762
+ spaceTrim$2((block) => `
6729
6763
  Unsupported format "${task.foreach.formatName}"
6730
6764
 
6731
6765
  Available formats:
@@ -6742,7 +6776,7 @@ async function executeFormatSubvalues(options) {
6742
6776
  if (subvalueParser === undefined) {
6743
6777
  throw new UnexpectedError(
6744
6778
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6745
- spaceTrim$1((block) => `
6779
+ spaceTrim$2((block) => `
6746
6780
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6747
6781
 
6748
6782
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6782,7 +6816,7 @@ async function executeFormatSubvalues(options) {
6782
6816
  if (!(error instanceof PipelineExecutionError)) {
6783
6817
  throw error;
6784
6818
  }
6785
- const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6819
+ const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
6786
6820
  ${error.message}
6787
6821
 
6788
6822
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6806,7 +6840,7 @@ async function executeFormatSubvalues(options) {
6806
6840
  ...options,
6807
6841
  priority: priority + index,
6808
6842
  parameters: allSubparameters,
6809
- pipelineIdentification: spaceTrim$1((block) => `
6843
+ pipelineIdentification: spaceTrim$2((block) => `
6810
6844
  ${block(pipelineIdentification)}
6811
6845
  Subparameter index: ${index}
6812
6846
  `),
@@ -6815,7 +6849,7 @@ async function executeFormatSubvalues(options) {
6815
6849
  }
6816
6850
  catch (error) {
6817
6851
  if (length > BIG_DATASET_TRESHOLD) {
6818
- console.error(spaceTrim$1((block) => `
6852
+ console.error(spaceTrim$2((block) => `
6819
6853
  ${error.message}
6820
6854
 
6821
6855
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6991,7 +7025,7 @@ async function getReservedParametersForTask(options) {
6991
7025
  // Note: Doublecheck that ALL reserved parameters are defined:
6992
7026
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6993
7027
  if (reservedParameters[parameterName] === undefined) {
6994
- throw new UnexpectedError(spaceTrim((block) => `
7028
+ throw new UnexpectedError(spaceTrim$1((block) => `
6995
7029
  Reserved parameter {${parameterName}} is not defined
6996
7030
 
6997
7031
  ${block(pipelineIdentification)}
@@ -7017,7 +7051,7 @@ async function executeTask(options) {
7017
7051
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
7018
7052
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
7019
7053
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
7020
- throw new UnexpectedError(spaceTrim((block) => `
7054
+ throw new UnexpectedError(spaceTrim$1((block) => `
7021
7055
  Dependent parameters are not consistent with used parameters:
7022
7056
 
7023
7057
  Dependent parameters:
@@ -7061,7 +7095,7 @@ async function executeTask(options) {
7061
7095
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
7062
7096
  // Houston, we have a problem
7063
7097
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
7064
- throw new UnexpectedError(spaceTrim((block) => `
7098
+ throw new UnexpectedError(spaceTrim$1((block) => `
7065
7099
  Parameter \`{${parameterName}}\` is NOT defined
7066
7100
  BUT used in task "${currentTask.title || currentTask.name}"
7067
7101
 
@@ -7130,7 +7164,7 @@ function filterJustOutputParameters(options) {
7130
7164
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
7131
7165
  if (parametersToPass[parameter.name] === undefined) {
7132
7166
  // [4]
7133
- $warnings.push(new PipelineExecutionError(spaceTrim((block) => `
7167
+ $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
7134
7168
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
7135
7169
 
7136
7170
  Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
@@ -7238,7 +7272,7 @@ async function executePipeline(options) {
7238
7272
  for (const parameterName of Object.keys(inputParameters)) {
7239
7273
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
7240
7274
  if (parameter === undefined) {
7241
- warnings.push(new PipelineExecutionError(spaceTrim((block) => `
7275
+ warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
7242
7276
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
7243
7277
 
7244
7278
  ${block(pipelineIdentification)}
@@ -7253,7 +7287,7 @@ async function executePipeline(options) {
7253
7287
  // TODO: [🧠] This should be also non-critical error
7254
7288
  return exportJson({
7255
7289
  name: 'pipelineExecutorResult',
7256
- message: spaceTrim((block) => `
7290
+ message: spaceTrim$1((block) => `
7257
7291
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
7258
7292
 
7259
7293
  ${block(pipelineIdentification)}
@@ -7262,7 +7296,7 @@ async function executePipeline(options) {
7262
7296
  value: {
7263
7297
  isSuccessful: false,
7264
7298
  errors: [
7265
- new PipelineExecutionError(spaceTrim((block) => `
7299
+ new PipelineExecutionError(spaceTrim$1((block) => `
7266
7300
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
7267
7301
 
7268
7302
  ${block(pipelineIdentification)}
@@ -7289,7 +7323,7 @@ async function executePipeline(options) {
7289
7323
  while (unresovedTasks.length > 0) {
7290
7324
  if (loopLimit-- < 0) {
7291
7325
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
7292
- throw new UnexpectedError(spaceTrim((block) => `
7326
+ throw new UnexpectedError(spaceTrim$1((block) => `
7293
7327
  Loop limit reached during resolving parameters pipeline execution
7294
7328
 
7295
7329
  ${block(pipelineIdentification)}
@@ -7299,7 +7333,7 @@ async function executePipeline(options) {
7299
7333
  if (!currentTask && resolving.length === 0) {
7300
7334
  throw new UnexpectedError(
7301
7335
  // TODO: [🐎] DRY
7302
- spaceTrim((block) => `
7336
+ spaceTrim$1((block) => `
7303
7337
  Can not resolve some parameters:
7304
7338
 
7305
7339
  ${block(pipelineIdentification)}
@@ -7339,7 +7373,7 @@ async function executePipeline(options) {
7339
7373
  tools,
7340
7374
  onProgress(newOngoingResult) {
7341
7375
  if (isReturned) {
7342
- throw new UnexpectedError(spaceTrim((block) => `
7376
+ throw new UnexpectedError(spaceTrim$1((block) => `
7343
7377
  Can not call \`onProgress\` after pipeline execution is finished
7344
7378
 
7345
7379
  ${block(pipelineIdentification)}
@@ -7356,7 +7390,7 @@ async function executePipeline(options) {
7356
7390
  },
7357
7391
  logLlmCall,
7358
7392
  $executionReport: executionReport,
7359
- pipelineIdentification: spaceTrim((block) => `
7393
+ pipelineIdentification: spaceTrim$1((block) => `
7360
7394
  ${block(pipelineIdentification)}
7361
7395
  Task name: ${currentTask.name}
7362
7396
  Task title: ${currentTask.title}
@@ -7465,7 +7499,7 @@ function createPipelineExecutor(options) {
7465
7499
  preparedPipeline = pipeline;
7466
7500
  }
7467
7501
  else if (isNotPreparedWarningSuppressed !== true) {
7468
- console.warn(spaceTrim((block) => `
7502
+ console.warn(spaceTrim$1((block) => `
7469
7503
  Pipeline is not prepared
7470
7504
 
7471
7505
  ${block(pipelineIdentification)}
@@ -7490,7 +7524,7 @@ function createPipelineExecutor(options) {
7490
7524
  tools,
7491
7525
  onProgress,
7492
7526
  logLlmCall,
7493
- pipelineIdentification: spaceTrim((block) => `
7527
+ pipelineIdentification: spaceTrim$1((block) => `
7494
7528
  ${block(pipelineIdentification)}
7495
7529
  ${runCount === 1 ? '' : `Run #${runCount}`}
7496
7530
  `),
@@ -7704,13 +7738,13 @@ function $registeredLlmToolsMessage() {
7704
7738
  });
7705
7739
  const usedEnvMessage = `Unknown \`.env\` file` ;
7706
7740
  if (metadata.length === 0) {
7707
- return spaceTrim$1((block) => `
7741
+ return spaceTrim$2((block) => `
7708
7742
  No LLM providers are available.
7709
7743
 
7710
7744
  ${block(usedEnvMessage)}
7711
7745
  `);
7712
7746
  }
7713
- return spaceTrim$1((block) => `
7747
+ return spaceTrim$2((block) => `
7714
7748
 
7715
7749
  ${block(usedEnvMessage)}
7716
7750
 
@@ -7756,7 +7790,7 @@ function $registeredLlmToolsMessage() {
7756
7790
  morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
7757
7791
  }
7758
7792
  }
7759
- let providerMessage = spaceTrim$1(`
7793
+ let providerMessage = spaceTrim$2(`
7760
7794
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
7761
7795
  ${morePieces.join('; ')}
7762
7796
  `);
@@ -7802,7 +7836,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
7802
7836
  .find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
7803
7837
  if (registeredItem === undefined) {
7804
7838
  // console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
7805
- throw new Error(spaceTrim$1((block) => `
7839
+ throw new Error(spaceTrim$2((block) => `
7806
7840
  There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
7807
7841
  Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
7808
7842
 
@@ -8068,7 +8102,7 @@ function unwrapResult(text, options) {
8068
8102
  let trimmedText = text;
8069
8103
  // Remove leading and trailing spaces and newlines
8070
8104
  if (isTrimmed) {
8071
- trimmedText = spaceTrim(trimmedText);
8105
+ trimmedText = spaceTrim$1(trimmedText);
8072
8106
  }
8073
8107
  let processedText = trimmedText;
8074
8108
  if (isIntroduceSentenceRemoved) {
@@ -8077,7 +8111,7 @@ function unwrapResult(text, options) {
8077
8111
  // Remove the introduce sentence and quotes by replacing it with an empty string
8078
8112
  processedText = processedText.replace(introduceSentenceRegex, '');
8079
8113
  }
8080
- processedText = spaceTrim(processedText);
8114
+ processedText = spaceTrim$1(processedText);
8081
8115
  }
8082
8116
  if (processedText.length < 3) {
8083
8117
  return trimmedText;
@@ -8140,7 +8174,7 @@ function unwrapResult(text, options) {
8140
8174
  function extractOneBlockFromMarkdown(markdown) {
8141
8175
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
8142
8176
  if (codeBlocks.length !== 1) {
8143
- throw new ParseError(spaceTrim$1((block) => `
8177
+ throw new ParseError(spaceTrim$2((block) => `
8144
8178
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
8145
8179
 
8146
8180
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -8181,13 +8215,13 @@ function extractBlock(markdown) {
8181
8215
  * @public exported from `@promptbook/markdown-utils`
8182
8216
  */
8183
8217
  function trimCodeBlock(value) {
8184
- value = spaceTrim(value);
8218
+ value = spaceTrim$1(value);
8185
8219
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
8186
8220
  return value;
8187
8221
  }
8188
8222
  value = value.replace(/^```[a-z]*/i, '');
8189
8223
  value = value.replace(/```$/i, '');
8190
- value = spaceTrim(value);
8224
+ value = spaceTrim$1(value);
8191
8225
  return value;
8192
8226
  }
8193
8227
 
@@ -8200,9 +8234,9 @@ function trimCodeBlock(value) {
8200
8234
  * @public exported from `@promptbook/markdown-utils`
8201
8235
  */
8202
8236
  function trimEndOfCodeBlock(value) {
8203
- value = spaceTrim(value);
8237
+ value = spaceTrim$1(value);
8204
8238
  value = value.replace(/```$/g, '');
8205
- value = spaceTrim(value);
8239
+ value = spaceTrim$1(value);
8206
8240
  return value;
8207
8241
  }
8208
8242
 
@@ -8249,7 +8283,7 @@ class JavascriptEvalExecutionTools {
8249
8283
  }
8250
8284
  // Note: [💎]
8251
8285
  // Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
8252
- const spaceTrim = (_) => spaceTrim$1(_);
8286
+ const spaceTrim = (_) => spaceTrim$2(_);
8253
8287
  $preserve(spaceTrim);
8254
8288
  const removeQuotes$1 = removeQuotes;
8255
8289
  $preserve(removeQuotes$1);
@@ -8340,7 +8374,7 @@ class JavascriptEvalExecutionTools {
8340
8374
  .join('\n');
8341
8375
  // script = templateParameters(script, parameters);
8342
8376
  // <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
8343
- const statementToEvaluate = spaceTrim$1((block) => `
8377
+ const statementToEvaluate = spaceTrim$2((block) => `
8344
8378
 
8345
8379
  // Build-in functions:
8346
8380
  ${block(buildinFunctionsStatement)}
@@ -8355,7 +8389,7 @@ class JavascriptEvalExecutionTools {
8355
8389
  (()=>{ ${script} })()
8356
8390
  `);
8357
8391
  if (this.options.isVerbose) {
8358
- console.info(spaceTrim$1((block) => `
8392
+ console.info(spaceTrim$2((block) => `
8359
8393
  🚀 Evaluating ${scriptLanguage} script:
8360
8394
 
8361
8395
  ${block(statementToEvaluate)}`));
@@ -8377,7 +8411,7 @@ class JavascriptEvalExecutionTools {
8377
8411
  To: [PipelineExecutionError: Parameter `{thing}` is not defined],
8378
8412
  */
8379
8413
  if (!statementToEvaluate.includes(undefinedName + '(')) {
8380
- throw new PipelineExecutionError(spaceTrim$1((block) => `
8414
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
8381
8415
 
8382
8416
  Parameter \`{${undefinedName}}\` is not defined
8383
8417
 
@@ -8399,7 +8433,7 @@ class JavascriptEvalExecutionTools {
8399
8433
  `));
8400
8434
  }
8401
8435
  else {
8402
- throw new PipelineExecutionError(spaceTrim$1((block) => `
8436
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
8403
8437
  Function ${undefinedName}() is not defined
8404
8438
 
8405
8439
  - Make sure that the function is one of built-in functions
@@ -9266,7 +9300,7 @@ function startRemoteServer(options) {
9266
9300
  response.type('text/html').send(renderServerIndexHtml(serverInfo));
9267
9301
  }
9268
9302
  else {
9269
- response.type('text/markdown').send(await spaceTrim(async (block) => `
9303
+ response.type('text/markdown').send(await spaceTrim$1(async (block) => `
9270
9304
  # Promptbook
9271
9305
 
9272
9306
  > ${block(CLAIM)}