@promptbook/remote-server 0.103.0-55 → 0.103.0-66

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 (42) hide show
  1. package/esm/index.es.js +164 -112
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +2 -2
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -8
  5. package/esm/typings/src/_packages/types.index.d.ts +7 -1
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  7. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
  8. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +3 -0
  9. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  10. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  11. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
  12. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
  13. package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
  14. package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +4 -0
  15. package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
  16. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
  17. package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
  18. package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
  19. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
  20. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
  21. package/esm/typings/src/commitments/{IMPORTANT/IMPORTANT.d.ts → USE_MCP/USE_MCP.d.ts} +16 -5
  22. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
  23. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  24. package/esm/typings/src/commitments/index.d.ts +93 -1
  25. package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -1
  26. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  27. package/esm/typings/src/playground/playground.d.ts +3 -0
  28. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  29. package/esm/typings/src/utils/color/Color.d.ts +9 -1
  30. package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
  31. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +6 -0
  32. package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
  33. package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
  34. package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
  35. package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
  36. package/esm/typings/src/version.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/umd/index.umd.js +126 -74
  39. package/umd/index.umd.js.map +1 -1
  40. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +0 -29
  41. package/esm/typings/src/commitments/registry.d.ts +0 -68
  42. package/esm/typings/src/playground/playground1.d.ts +0 -2
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-66';
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',
@@ -287,21 +299,61 @@ class Color {
287
299
  * @param color
288
300
  * @returns Color object
289
301
  */
290
- static from(color) {
291
- if (color instanceof Color) {
302
+ static from(color, _isSingleValue = false) {
303
+ if (color === '') {
304
+ throw new Error(`Can not create color from empty string`);
305
+ }
306
+ else if (color instanceof Color) {
292
307
  return take(color);
293
308
  }
294
309
  else if (Color.isColor(color)) {
295
310
  return take(color);
296
311
  }
297
312
  else if (typeof color === 'string') {
298
- return Color.fromString(color);
313
+ try {
314
+ return Color.fromString(color);
315
+ }
316
+ catch (error) {
317
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
318
+ if (_isSingleValue) {
319
+ throw error;
320
+ }
321
+ const parts = color.split(/[\s+,;|]/);
322
+ if (parts.length > 0) {
323
+ return Color.from(parts[0].trim(), true);
324
+ }
325
+ else {
326
+ throw new Error(`Can not create color from given string "${color}"`);
327
+ }
328
+ }
299
329
  }
300
330
  else {
301
331
  console.error({ color });
302
332
  throw new Error(`Can not create color from given object`);
303
333
  }
304
334
  }
335
+ /**
336
+ * Creates a new Color instance from miscellaneous formats
337
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
338
+ *
339
+ * @param color
340
+ * @returns Color object
341
+ */
342
+ static fromSafe(color) {
343
+ try {
344
+ return Color.from(color);
345
+ }
346
+ catch (error) {
347
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
348
+ console.warn(spaceTrim((block) => `
349
+ Color.fromSafe error:
350
+ ${block(error.message)}
351
+
352
+ Returning default PROMPTBOOK_COLOR.
353
+ `));
354
+ return Color.fromString('promptbook');
355
+ }
356
+ }
305
357
  /**
306
358
  * Creates a new Color instance from miscellaneous string formats
307
359
  *
@@ -919,7 +971,7 @@ const CLAIM = `Turn your company's scattered knowledge into AI ready books`;
919
971
  *
920
972
  * @public exported from `@promptbook/core`
921
973
  */
922
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
974
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
923
975
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
924
976
  /**
925
977
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1266,11 +1318,11 @@ function $execCommand(options) {
1266
1318
  console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
1267
1319
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1268
1320
  }
1269
- resolve(spaceTrim(output.join('\n')));
1321
+ resolve(spaceTrim$1(output.join('\n')));
1270
1322
  }
1271
1323
  }
1272
1324
  else {
1273
- resolve(spaceTrim(output.join('\n')));
1325
+ resolve(spaceTrim$1(output.join('\n')));
1274
1326
  }
1275
1327
  };
1276
1328
  commandProcess.on('close', finishWithCode);
@@ -1288,7 +1340,7 @@ function $execCommand(options) {
1288
1340
  console.warn(error);
1289
1341
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1290
1342
  }
1291
- resolve(spaceTrim(output.join('\n')));
1343
+ resolve(spaceTrim$1(output.join('\n')));
1292
1344
  }
1293
1345
  });
1294
1346
  }
@@ -1339,7 +1391,7 @@ async function startAgentServer(options) {
1339
1391
  function getErrorReportUrl(error) {
1340
1392
  const report = {
1341
1393
  title: `🐜 Error report from ${NAME}`,
1342
- body: spaceTrim$1((block) => `
1394
+ body: spaceTrim$2((block) => `
1343
1395
 
1344
1396
 
1345
1397
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1382,7 +1434,7 @@ function getErrorReportUrl(error) {
1382
1434
  */
1383
1435
  class UnexpectedError extends Error {
1384
1436
  constructor(message) {
1385
- super(spaceTrim((block) => `
1437
+ super(spaceTrim$1((block) => `
1386
1438
  ${block(message)}
1387
1439
 
1388
1440
  Note: This error should not happen.
@@ -1408,7 +1460,7 @@ class WrappedError extends Error {
1408
1460
  constructor(whatWasThrown) {
1409
1461
  const tag = `[🤮]`;
1410
1462
  console.error(tag, whatWasThrown);
1411
- super(spaceTrim(`
1463
+ super(spaceTrim$1(`
1412
1464
  Non-Error object was thrown
1413
1465
 
1414
1466
  Note: Look for ${tag} in the console for more details
@@ -1604,7 +1656,7 @@ class LimitReachedError extends Error {
1604
1656
  */
1605
1657
  class MissingToolsError extends Error {
1606
1658
  constructor(message) {
1607
- super(spaceTrim((block) => `
1659
+ super(spaceTrim$1((block) => `
1608
1660
  ${block(message)}
1609
1661
 
1610
1662
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -1648,7 +1700,7 @@ class NotFoundError extends Error {
1648
1700
  */
1649
1701
  class NotYetImplementedError extends Error {
1650
1702
  constructor(message) {
1651
- super(spaceTrim((block) => `
1703
+ super(spaceTrim$1((block) => `
1652
1704
  ${block(message)}
1653
1705
 
1654
1706
  Note: This feature is not implemented yet but it will be soon.
@@ -1792,7 +1844,7 @@ function serializeError(error) {
1792
1844
  const { name, message, stack } = error;
1793
1845
  const { id } = error;
1794
1846
  if (!Object.keys(ALL_ERRORS).includes(name)) {
1795
- console.error(spaceTrim$1((block) => `
1847
+ console.error(spaceTrim$2((block) => `
1796
1848
 
1797
1849
  Cannot serialize error with name "${name}"
1798
1850
 
@@ -2136,7 +2188,7 @@ function checkSerializableAsJson(options) {
2136
2188
  }
2137
2189
  else if (typeof value === 'object') {
2138
2190
  if (value instanceof Date) {
2139
- throw new UnexpectedError(spaceTrim$1((block) => `
2191
+ throw new UnexpectedError(spaceTrim$2((block) => `
2140
2192
  \`${name}\` is Date
2141
2193
 
2142
2194
  Use \`string_date_iso8601\` instead
@@ -2155,7 +2207,7 @@ function checkSerializableAsJson(options) {
2155
2207
  throw new UnexpectedError(`${name} is RegExp`);
2156
2208
  }
2157
2209
  else if (value instanceof Error) {
2158
- throw new UnexpectedError(spaceTrim$1((block) => `
2210
+ throw new UnexpectedError(spaceTrim$2((block) => `
2159
2211
  \`${name}\` is unserialized Error
2160
2212
 
2161
2213
  Use function \`serializeError\`
@@ -2178,7 +2230,7 @@ function checkSerializableAsJson(options) {
2178
2230
  }
2179
2231
  catch (error) {
2180
2232
  assertsError(error);
2181
- throw new UnexpectedError(spaceTrim$1((block) => `
2233
+ throw new UnexpectedError(spaceTrim$2((block) => `
2182
2234
  \`${name}\` is not serializable
2183
2235
 
2184
2236
  ${block(error.stack || error.message)}
@@ -2210,7 +2262,7 @@ function checkSerializableAsJson(options) {
2210
2262
  }
2211
2263
  }
2212
2264
  else {
2213
- throw new UnexpectedError(spaceTrim$1((block) => `
2265
+ throw new UnexpectedError(spaceTrim$2((block) => `
2214
2266
  \`${name}\` is unknown type
2215
2267
 
2216
2268
  Additional message for \`${name}\`:
@@ -2481,7 +2533,7 @@ function validatePipeline(pipeline) {
2481
2533
  if (!(error instanceof PipelineLogicError)) {
2482
2534
  throw error;
2483
2535
  }
2484
- console.error(spaceTrim((block) => `
2536
+ console.error(spaceTrim$1((block) => `
2485
2537
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2486
2538
 
2487
2539
  ${block(error.message)}
@@ -2508,7 +2560,7 @@ function validatePipeline_InnerFunction(pipeline) {
2508
2560
  })();
2509
2561
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2510
2562
  // <- Note: [🚲]
2511
- throw new PipelineLogicError(spaceTrim((block) => `
2563
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2512
2564
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2513
2565
 
2514
2566
  ${block(pipelineIdentification)}
@@ -2516,7 +2568,7 @@ function validatePipeline_InnerFunction(pipeline) {
2516
2568
  }
2517
2569
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2518
2570
  // <- Note: [🚲]
2519
- throw new PipelineLogicError(spaceTrim((block) => `
2571
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2520
2572
  Invalid Promptbook Version "${pipeline.bookVersion}"
2521
2573
 
2522
2574
  ${block(pipelineIdentification)}
@@ -2525,7 +2577,7 @@ function validatePipeline_InnerFunction(pipeline) {
2525
2577
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2526
2578
  if (!Array.isArray(pipeline.parameters)) {
2527
2579
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2528
- throw new ParseError(spaceTrim((block) => `
2580
+ throw new ParseError(spaceTrim$1((block) => `
2529
2581
  Pipeline is valid JSON but with wrong structure
2530
2582
 
2531
2583
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2536,7 +2588,7 @@ function validatePipeline_InnerFunction(pipeline) {
2536
2588
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2537
2589
  if (!Array.isArray(pipeline.tasks)) {
2538
2590
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2539
- throw new ParseError(spaceTrim((block) => `
2591
+ throw new ParseError(spaceTrim$1((block) => `
2540
2592
  Pipeline is valid JSON but with wrong structure
2541
2593
 
2542
2594
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2562,7 +2614,7 @@ function validatePipeline_InnerFunction(pipeline) {
2562
2614
  // Note: Check each parameter individually
2563
2615
  for (const parameter of pipeline.parameters) {
2564
2616
  if (parameter.isInput && parameter.isOutput) {
2565
- throw new PipelineLogicError(spaceTrim((block) => `
2617
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2566
2618
 
2567
2619
  Parameter \`{${parameter.name}}\` can not be both input and output
2568
2620
 
@@ -2573,7 +2625,7 @@ function validatePipeline_InnerFunction(pipeline) {
2573
2625
  if (!parameter.isInput &&
2574
2626
  !parameter.isOutput &&
2575
2627
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2576
- throw new PipelineLogicError(spaceTrim((block) => `
2628
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2577
2629
  Parameter \`{${parameter.name}}\` is created but not used
2578
2630
 
2579
2631
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2585,7 +2637,7 @@ function validatePipeline_InnerFunction(pipeline) {
2585
2637
  }
2586
2638
  // Note: Testing that parameter is either input or result of some task
2587
2639
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2588
- throw new PipelineLogicError(spaceTrim((block) => `
2640
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2589
2641
  Parameter \`{${parameter.name}}\` is declared but not defined
2590
2642
 
2591
2643
  You can do one of these:
@@ -2601,14 +2653,14 @@ function validatePipeline_InnerFunction(pipeline) {
2601
2653
  // Note: Checking each task individually
2602
2654
  for (const task of pipeline.tasks) {
2603
2655
  if (definedParameters.has(task.resultingParameterName)) {
2604
- throw new PipelineLogicError(spaceTrim((block) => `
2656
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2605
2657
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2606
2658
 
2607
2659
  ${block(pipelineIdentification)}
2608
2660
  `));
2609
2661
  }
2610
2662
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2611
- throw new PipelineLogicError(spaceTrim((block) => `
2663
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2612
2664
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2613
2665
 
2614
2666
  ${block(pipelineIdentification)}
@@ -2618,7 +2670,7 @@ function validatePipeline_InnerFunction(pipeline) {
2618
2670
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2619
2671
  if (!task.format &&
2620
2672
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2621
- throw new PipelineLogicError(spaceTrim((block) => `
2673
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2622
2674
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2623
2675
 
2624
2676
  ${block(pipelineIdentification)}
@@ -2626,7 +2678,7 @@ function validatePipeline_InnerFunction(pipeline) {
2626
2678
  }
2627
2679
  for (const joker of task.jokerParameterNames) {
2628
2680
  if (!task.dependentParameterNames.includes(joker)) {
2629
- throw new PipelineLogicError(spaceTrim((block) => `
2681
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2630
2682
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2631
2683
 
2632
2684
  ${block(pipelineIdentification)}
@@ -2637,21 +2689,21 @@ function validatePipeline_InnerFunction(pipeline) {
2637
2689
  if (task.expectations) {
2638
2690
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2639
2691
  if (min !== undefined && max !== undefined && min > max) {
2640
- throw new PipelineLogicError(spaceTrim((block) => `
2692
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2641
2693
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2642
2694
 
2643
2695
  ${block(pipelineIdentification)}
2644
2696
  `));
2645
2697
  }
2646
2698
  if (min !== undefined && min < 0) {
2647
- throw new PipelineLogicError(spaceTrim((block) => `
2699
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2648
2700
  Min expectation of ${unit} must be zero or positive
2649
2701
 
2650
2702
  ${block(pipelineIdentification)}
2651
2703
  `));
2652
2704
  }
2653
2705
  if (max !== undefined && max <= 0) {
2654
- throw new PipelineLogicError(spaceTrim((block) => `
2706
+ throw new PipelineLogicError(spaceTrim$1((block) => `
2655
2707
  Max expectation of ${unit} must be positive
2656
2708
 
2657
2709
  ${block(pipelineIdentification)}
@@ -2673,7 +2725,7 @@ function validatePipeline_InnerFunction(pipeline) {
2673
2725
  while (unresovedTasks.length > 0) {
2674
2726
  if (loopLimit-- < 0) {
2675
2727
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2676
- throw new UnexpectedError(spaceTrim((block) => `
2728
+ throw new UnexpectedError(spaceTrim$1((block) => `
2677
2729
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2678
2730
 
2679
2731
  ${block(pipelineIdentification)}
@@ -2683,7 +2735,7 @@ function validatePipeline_InnerFunction(pipeline) {
2683
2735
  if (currentlyResovedTasks.length === 0) {
2684
2736
  throw new PipelineLogicError(
2685
2737
  // TODO: [🐎] DRY
2686
- spaceTrim((block) => `
2738
+ spaceTrim$1((block) => `
2687
2739
 
2688
2740
  Can not resolve some parameters:
2689
2741
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2820,7 +2872,7 @@ function jsonParse(value) {
2820
2872
  }
2821
2873
  else if (typeof value !== 'string') {
2822
2874
  console.error('Can not parse JSON from non-string value.', { text: value });
2823
- throw new Error(spaceTrim$1(`
2875
+ throw new Error(spaceTrim$2(`
2824
2876
  Can not parse JSON from non-string value.
2825
2877
 
2826
2878
  The value type: ${typeof value}
@@ -2834,7 +2886,7 @@ function jsonParse(value) {
2834
2886
  if (!(error instanceof Error)) {
2835
2887
  throw error;
2836
2888
  }
2837
- throw new Error(spaceTrim$1((block) => `
2889
+ throw new Error(spaceTrim$2((block) => `
2838
2890
  ${block(error.message)}
2839
2891
 
2840
2892
  The expected JSON text:
@@ -2887,7 +2939,7 @@ function deserializeError(error) {
2887
2939
  message = `${name}: ${message}`;
2888
2940
  }
2889
2941
  if (stack !== undefined && stack !== '') {
2890
- message = spaceTrim$1((block) => `
2942
+ message = spaceTrim$2((block) => `
2891
2943
  ${block(message)}
2892
2944
 
2893
2945
  Original stack trace:
@@ -2924,11 +2976,11 @@ function assertsTaskSuccessful(executionResult) {
2924
2976
  throw deserializeError(errors[0]);
2925
2977
  }
2926
2978
  else {
2927
- throw new PipelineExecutionError(spaceTrim((block) => `
2979
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
2928
2980
  Multiple errors occurred during Promptbook execution
2929
2981
 
2930
2982
  ${block(errors
2931
- .map(({ name, stack, message }, index) => spaceTrim((block) => `
2983
+ .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
2932
2984
  ${name} ${index + 1}:
2933
2985
  ${block(stack || message)}
2934
2986
  `))
@@ -3440,7 +3492,7 @@ function pipelineJsonToString(pipelineJson) {
3440
3492
  pipelineString += '\n\n';
3441
3493
  pipelineString += '```' + contentLanguage;
3442
3494
  pipelineString += '\n';
3443
- pipelineString += spaceTrim$1(content);
3495
+ pipelineString += spaceTrim$2(content);
3444
3496
  // <- TODO: [main] !!3 Escape
3445
3497
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
3446
3498
  pipelineString += '\n';
@@ -3545,7 +3597,7 @@ class SimplePipelineCollection {
3545
3597
  for (const pipeline of pipelines) {
3546
3598
  // TODO: [👠] DRY
3547
3599
  if (pipeline.pipelineUrl === undefined) {
3548
- throw new PipelineUrlError(spaceTrim(`
3600
+ throw new PipelineUrlError(spaceTrim$1(`
3549
3601
  Pipeline with name "${pipeline.title}" does not have defined URL
3550
3602
 
3551
3603
  File:
@@ -3567,7 +3619,7 @@ class SimplePipelineCollection {
3567
3619
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3568
3620
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3569
3621
  const existing = this.collection.get(pipeline.pipelineUrl);
3570
- throw new PipelineUrlError(spaceTrim(`
3622
+ throw new PipelineUrlError(spaceTrim$1(`
3571
3623
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
3572
3624
 
3573
3625
  Conflicting files:
@@ -3599,13 +3651,13 @@ class SimplePipelineCollection {
3599
3651
  const pipeline = this.collection.get(url);
3600
3652
  if (!pipeline) {
3601
3653
  if (this.listPipelines().length === 0) {
3602
- throw new NotFoundError(spaceTrim(`
3654
+ throw new NotFoundError(spaceTrim$1(`
3603
3655
  Pipeline with url "${url}" not found
3604
3656
 
3605
3657
  No pipelines available
3606
3658
  `));
3607
3659
  }
3608
- throw new NotFoundError(spaceTrim((block) => `
3660
+ throw new NotFoundError(spaceTrim$1((block) => `
3609
3661
  Pipeline with url "${url}" not found
3610
3662
 
3611
3663
  Available pipelines:
@@ -3836,14 +3888,14 @@ class MultipleLlmExecutionTools {
3836
3888
  if (description === undefined) {
3837
3889
  return headLine;
3838
3890
  }
3839
- return spaceTrim$1((block) => `
3891
+ return spaceTrim$2((block) => `
3840
3892
  ${headLine}
3841
3893
 
3842
3894
  ${ /* <- Note: Indenting the description: */block(description)}
3843
3895
  `);
3844
3896
  })
3845
3897
  .join('\n\n');
3846
- return spaceTrim$1((block) => `
3898
+ return spaceTrim$2((block) => `
3847
3899
  Multiple LLM Providers:
3848
3900
 
3849
3901
  ${block(innerModelsTitlesAndDescriptions)}
@@ -3934,7 +3986,7 @@ class MultipleLlmExecutionTools {
3934
3986
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3935
3987
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3936
3988
  // 3) ...
3937
- spaceTrim$1((block) => `
3989
+ spaceTrim$2((block) => `
3938
3990
  All execution tools of ${this.title} failed:
3939
3991
 
3940
3992
  ${block(errors
@@ -3947,7 +3999,7 @@ class MultipleLlmExecutionTools {
3947
3999
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
3948
4000
  }
3949
4001
  else {
3950
- throw new PipelineExecutionError(spaceTrim$1((block) => `
4002
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
3951
4003
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
3952
4004
 
3953
4005
  Available \`LlmExecutionTools\`:
@@ -3980,7 +4032,7 @@ class MultipleLlmExecutionTools {
3980
4032
  */
3981
4033
  function joinLlmExecutionTools(title, ...llmExecutionTools) {
3982
4034
  if (llmExecutionTools.length === 0) {
3983
- const warningMessage = spaceTrim$1(`
4035
+ const warningMessage = spaceTrim$2(`
3984
4036
  You have not provided any \`LlmExecutionTools\`
3985
4037
  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
4038
 
@@ -4297,14 +4349,14 @@ function $registeredScrapersMessage(availableScrapers) {
4297
4349
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
4298
4350
  });
4299
4351
  if (metadata.length === 0) {
4300
- return spaceTrim$1(`
4352
+ return spaceTrim$2(`
4301
4353
  **No scrapers are available**
4302
4354
 
4303
4355
  This is a unexpected behavior, you are probably using some broken version of Promptbook
4304
4356
  At least there should be available the metadata of the scrapers
4305
4357
  `);
4306
4358
  }
4307
- return spaceTrim$1((block) => `
4359
+ return spaceTrim$2((block) => `
4308
4360
  Available scrapers are:
4309
4361
  ${block(metadata
4310
4362
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -4810,7 +4862,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
4810
4862
  else if (urlOrRequest instanceof Request) {
4811
4863
  url = urlOrRequest.url;
4812
4864
  }
4813
- throw new PromptbookFetchError(spaceTrim$1((block) => `
4865
+ throw new PromptbookFetchError(spaceTrim$2((block) => `
4814
4866
  Can not fetch "${url}"
4815
4867
 
4816
4868
  Fetch error:
@@ -4971,7 +5023,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4971
5023
  const fileExtension = getFileExtension(filename);
4972
5024
  const mimeType = extensionToMimeType(fileExtension || '');
4973
5025
  if (!(await isFileExisting(filename, tools.fs))) {
4974
- throw new NotFoundError(spaceTrim$1((block) => `
5026
+ throw new NotFoundError(spaceTrim$2((block) => `
4975
5027
  Can not make source handler for file which does not exist:
4976
5028
 
4977
5029
  File:
@@ -5064,7 +5116,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
5064
5116
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5065
5117
  break;
5066
5118
  }
5067
- console.warn(spaceTrim$1((block) => `
5119
+ console.warn(spaceTrim$2((block) => `
5068
5120
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
5069
5121
 
5070
5122
  The source:
@@ -5080,7 +5132,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
5080
5132
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
5081
5133
  }
5082
5134
  if (partialPieces === null) {
5083
- throw new KnowledgeScrapeError(spaceTrim$1((block) => `
5135
+ throw new KnowledgeScrapeError(spaceTrim$2((block) => `
5084
5136
  Cannot scrape knowledge
5085
5137
 
5086
5138
  The source:
@@ -5159,7 +5211,7 @@ async function prepareTasks(pipeline, tools, options) {
5159
5211
  if (task.taskType === 'PROMPT_TASK' &&
5160
5212
  knowledgePiecesCount > 0 &&
5161
5213
  !dependentParameterNames.includes('knowledge')) {
5162
- preparedContent = spaceTrim(`
5214
+ preparedContent = spaceTrim$1(`
5163
5215
  {content}
5164
5216
 
5165
5217
  ## Knowledge
@@ -5472,7 +5524,7 @@ function extractVariablesFromJavascript(script) {
5472
5524
  }
5473
5525
  catch (error) {
5474
5526
  assertsError(error);
5475
- throw new ParseError(spaceTrim((block) => `
5527
+ throw new ParseError(spaceTrim$1((block) => `
5476
5528
  Can not extract variables from the script
5477
5529
  ${block(error.stack || error.message)}
5478
5530
 
@@ -5655,7 +5707,7 @@ const CsvFormatParser = {
5655
5707
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
5656
5708
  const csv = csvParse(value, settings);
5657
5709
  if (csv.errors.length !== 0) {
5658
- throw new CsvFormatError(spaceTrim$1((block) => `
5710
+ throw new CsvFormatError(spaceTrim$2((block) => `
5659
5711
  CSV parsing error
5660
5712
 
5661
5713
  Error(s) from CSV parsing:
@@ -5700,7 +5752,7 @@ const CsvFormatParser = {
5700
5752
  const { value, settings, mapCallback, onProgress } = options;
5701
5753
  const csv = csvParse(value, settings);
5702
5754
  if (csv.errors.length !== 0) {
5703
- throw new CsvFormatError(spaceTrim$1((block) => `
5755
+ throw new CsvFormatError(spaceTrim$2((block) => `
5704
5756
  CSV parsing error
5705
5757
 
5706
5758
  Error(s) from CSV parsing:
@@ -5910,7 +5962,7 @@ function mapAvailableToExpectedParameters(options) {
5910
5962
  }
5911
5963
  // Phase 2️⃣: Non-matching mapping
5912
5964
  if (expectedParameterNames.size !== availableParametersNames.size) {
5913
- throw new PipelineExecutionError(spaceTrim$1((block) => `
5965
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
5914
5966
  Can not map available parameters to expected parameters
5915
5967
 
5916
5968
  Mapped parameters:
@@ -6326,7 +6378,7 @@ function validatePromptResult(options) {
6326
6378
  }
6327
6379
  catch (error) {
6328
6380
  keepUnused(error);
6329
- throw new ExpectError(spaceTrim((block) => `
6381
+ throw new ExpectError(spaceTrim$1((block) => `
6330
6382
  Expected valid JSON string
6331
6383
 
6332
6384
  The expected JSON text:
@@ -6389,7 +6441,7 @@ async function executeAttempts(options) {
6389
6441
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
6390
6442
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
6391
6443
  if (isJokerAttempt && !jokerParameterName) {
6392
- throw new UnexpectedError(spaceTrim((block) => `
6444
+ throw new UnexpectedError(spaceTrim$1((block) => `
6393
6445
  Joker not found in attempt ${attemptIndex}
6394
6446
 
6395
6447
  ${block(pipelineIdentification)}
@@ -6400,7 +6452,7 @@ async function executeAttempts(options) {
6400
6452
  $ongoingTaskResult.$expectError = null;
6401
6453
  if (isJokerAttempt) {
6402
6454
  if (parameters[jokerParameterName] === undefined) {
6403
- throw new PipelineExecutionError(spaceTrim((block) => `
6455
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6404
6456
  Joker parameter {${jokerParameterName}} not defined
6405
6457
 
6406
6458
  ${block(pipelineIdentification)}
@@ -6458,7 +6510,7 @@ async function executeAttempts(options) {
6458
6510
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6459
6511
  break variant;
6460
6512
  case 'EMBEDDING':
6461
- throw new PipelineExecutionError(spaceTrim((block) => `
6513
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6462
6514
  Embedding model can not be used in pipeline
6463
6515
 
6464
6516
  This should be catched during parsing
@@ -6469,7 +6521,7 @@ async function executeAttempts(options) {
6469
6521
  break variant;
6470
6522
  // <- case [🤖]:
6471
6523
  default:
6472
- throw new PipelineExecutionError(spaceTrim((block) => `
6524
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6473
6525
  Unknown model variant "${task.modelRequirements.modelVariant}"
6474
6526
 
6475
6527
  ${block(pipelineIdentification)}
@@ -6480,14 +6532,14 @@ async function executeAttempts(options) {
6480
6532
  break;
6481
6533
  case 'SCRIPT_TASK':
6482
6534
  if (arrayableToArray(tools.script).length === 0) {
6483
- throw new PipelineExecutionError(spaceTrim((block) => `
6535
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6484
6536
  No script execution tools are available
6485
6537
 
6486
6538
  ${block(pipelineIdentification)}
6487
6539
  `));
6488
6540
  }
6489
6541
  if (!task.contentLanguage) {
6490
- throw new PipelineExecutionError(spaceTrim((block) => `
6542
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6491
6543
  Script language is not defined for SCRIPT TASK "${task.name}"
6492
6544
 
6493
6545
  ${block(pipelineIdentification)}
@@ -6518,7 +6570,7 @@ async function executeAttempts(options) {
6518
6570
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6519
6571
  }
6520
6572
  else {
6521
- throw new PipelineExecutionError(spaceTrim((block) => `
6573
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6522
6574
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6523
6575
 
6524
6576
  ${block(pipelineIdentification)}
@@ -6532,7 +6584,7 @@ async function executeAttempts(options) {
6532
6584
  break taskType;
6533
6585
  case 'DIALOG_TASK':
6534
6586
  if (tools.userInterface === undefined) {
6535
- throw new PipelineExecutionError(spaceTrim((block) => `
6587
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6536
6588
  User interface tools are not available
6537
6589
 
6538
6590
  ${block(pipelineIdentification)}
@@ -6550,7 +6602,7 @@ async function executeAttempts(options) {
6550
6602
  break taskType;
6551
6603
  // <- case: [🅱]
6552
6604
  default:
6553
- throw new PipelineExecutionError(spaceTrim((block) => `
6605
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
6554
6606
  Unknown execution type "${task.taskType}"
6555
6607
 
6556
6608
  ${block(pipelineIdentification)}
@@ -6648,7 +6700,7 @@ async function executeAttempts(options) {
6648
6700
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6649
6701
  // Note: Create a summary of all failures
6650
6702
  const failuresSummary = $ongoingTaskResult.$failedResults
6651
- .map((failure) => spaceTrim((block) => {
6703
+ .map((failure) => spaceTrim$1((block) => {
6652
6704
  var _a, _b;
6653
6705
  return `
6654
6706
  Attempt ${failure.attemptIndex + 1}:
@@ -6658,14 +6710,14 @@ async function executeAttempts(options) {
6658
6710
  Result:
6659
6711
  ${block(failure.result === null
6660
6712
  ? 'null'
6661
- : spaceTrim(failure.result)
6713
+ : spaceTrim$1(failure.result)
6662
6714
  .split('\n')
6663
6715
  .map((line) => `> ${line}`)
6664
6716
  .join('\n'))}
6665
6717
  `;
6666
6718
  }))
6667
6719
  .join('\n\n---\n\n');
6668
- throw new PipelineExecutionError(spaceTrim((block) => {
6720
+ throw new PipelineExecutionError(spaceTrim$1((block) => {
6669
6721
  var _a;
6670
6722
  return `
6671
6723
  LLM execution failed ${maxExecutionAttempts}x
@@ -6685,7 +6737,7 @@ async function executeAttempts(options) {
6685
6737
  }
6686
6738
  }
6687
6739
  if ($ongoingTaskResult.$resultString === null) {
6688
- throw new UnexpectedError(spaceTrim((block) => `
6740
+ throw new UnexpectedError(spaceTrim$1((block) => `
6689
6741
  Something went wrong and prompt result is null
6690
6742
 
6691
6743
  ${block(pipelineIdentification)}
@@ -6712,7 +6764,7 @@ async function executeFormatSubvalues(options) {
6712
6764
  return /* not await */ executeAttempts({ ...options, logLlmCall });
6713
6765
  }
6714
6766
  if (jokerParameterNames.length !== 0) {
6715
- throw new UnexpectedError(spaceTrim$1((block) => `
6767
+ throw new UnexpectedError(spaceTrim$2((block) => `
6716
6768
  JOKER parameters are not supported together with FOREACH command
6717
6769
 
6718
6770
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6725,7 +6777,7 @@ async function executeFormatSubvalues(options) {
6725
6777
  if (formatDefinition === undefined) {
6726
6778
  throw new UnexpectedError(
6727
6779
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6728
- spaceTrim$1((block) => `
6780
+ spaceTrim$2((block) => `
6729
6781
  Unsupported format "${task.foreach.formatName}"
6730
6782
 
6731
6783
  Available formats:
@@ -6742,7 +6794,7 @@ async function executeFormatSubvalues(options) {
6742
6794
  if (subvalueParser === undefined) {
6743
6795
  throw new UnexpectedError(
6744
6796
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6745
- spaceTrim$1((block) => `
6797
+ spaceTrim$2((block) => `
6746
6798
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6747
6799
 
6748
6800
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6782,7 +6834,7 @@ async function executeFormatSubvalues(options) {
6782
6834
  if (!(error instanceof PipelineExecutionError)) {
6783
6835
  throw error;
6784
6836
  }
6785
- const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6837
+ const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
6786
6838
  ${error.message}
6787
6839
 
6788
6840
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6806,7 +6858,7 @@ async function executeFormatSubvalues(options) {
6806
6858
  ...options,
6807
6859
  priority: priority + index,
6808
6860
  parameters: allSubparameters,
6809
- pipelineIdentification: spaceTrim$1((block) => `
6861
+ pipelineIdentification: spaceTrim$2((block) => `
6810
6862
  ${block(pipelineIdentification)}
6811
6863
  Subparameter index: ${index}
6812
6864
  `),
@@ -6815,7 +6867,7 @@ async function executeFormatSubvalues(options) {
6815
6867
  }
6816
6868
  catch (error) {
6817
6869
  if (length > BIG_DATASET_TRESHOLD) {
6818
- console.error(spaceTrim$1((block) => `
6870
+ console.error(spaceTrim$2((block) => `
6819
6871
  ${error.message}
6820
6872
 
6821
6873
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6991,7 +7043,7 @@ async function getReservedParametersForTask(options) {
6991
7043
  // Note: Doublecheck that ALL reserved parameters are defined:
6992
7044
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6993
7045
  if (reservedParameters[parameterName] === undefined) {
6994
- throw new UnexpectedError(spaceTrim((block) => `
7046
+ throw new UnexpectedError(spaceTrim$1((block) => `
6995
7047
  Reserved parameter {${parameterName}} is not defined
6996
7048
 
6997
7049
  ${block(pipelineIdentification)}
@@ -7017,7 +7069,7 @@ async function executeTask(options) {
7017
7069
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
7018
7070
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
7019
7071
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
7020
- throw new UnexpectedError(spaceTrim((block) => `
7072
+ throw new UnexpectedError(spaceTrim$1((block) => `
7021
7073
  Dependent parameters are not consistent with used parameters:
7022
7074
 
7023
7075
  Dependent parameters:
@@ -7061,7 +7113,7 @@ async function executeTask(options) {
7061
7113
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
7062
7114
  // Houston, we have a problem
7063
7115
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
7064
- throw new UnexpectedError(spaceTrim((block) => `
7116
+ throw new UnexpectedError(spaceTrim$1((block) => `
7065
7117
  Parameter \`{${parameterName}}\` is NOT defined
7066
7118
  BUT used in task "${currentTask.title || currentTask.name}"
7067
7119
 
@@ -7130,7 +7182,7 @@ function filterJustOutputParameters(options) {
7130
7182
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
7131
7183
  if (parametersToPass[parameter.name] === undefined) {
7132
7184
  // [4]
7133
- $warnings.push(new PipelineExecutionError(spaceTrim((block) => `
7185
+ $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
7134
7186
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
7135
7187
 
7136
7188
  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 +7290,7 @@ async function executePipeline(options) {
7238
7290
  for (const parameterName of Object.keys(inputParameters)) {
7239
7291
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
7240
7292
  if (parameter === undefined) {
7241
- warnings.push(new PipelineExecutionError(spaceTrim((block) => `
7293
+ warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
7242
7294
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
7243
7295
 
7244
7296
  ${block(pipelineIdentification)}
@@ -7253,7 +7305,7 @@ async function executePipeline(options) {
7253
7305
  // TODO: [🧠] This should be also non-critical error
7254
7306
  return exportJson({
7255
7307
  name: 'pipelineExecutorResult',
7256
- message: spaceTrim((block) => `
7308
+ message: spaceTrim$1((block) => `
7257
7309
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
7258
7310
 
7259
7311
  ${block(pipelineIdentification)}
@@ -7262,7 +7314,7 @@ async function executePipeline(options) {
7262
7314
  value: {
7263
7315
  isSuccessful: false,
7264
7316
  errors: [
7265
- new PipelineExecutionError(spaceTrim((block) => `
7317
+ new PipelineExecutionError(spaceTrim$1((block) => `
7266
7318
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
7267
7319
 
7268
7320
  ${block(pipelineIdentification)}
@@ -7289,7 +7341,7 @@ async function executePipeline(options) {
7289
7341
  while (unresovedTasks.length > 0) {
7290
7342
  if (loopLimit-- < 0) {
7291
7343
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
7292
- throw new UnexpectedError(spaceTrim((block) => `
7344
+ throw new UnexpectedError(spaceTrim$1((block) => `
7293
7345
  Loop limit reached during resolving parameters pipeline execution
7294
7346
 
7295
7347
  ${block(pipelineIdentification)}
@@ -7299,7 +7351,7 @@ async function executePipeline(options) {
7299
7351
  if (!currentTask && resolving.length === 0) {
7300
7352
  throw new UnexpectedError(
7301
7353
  // TODO: [🐎] DRY
7302
- spaceTrim((block) => `
7354
+ spaceTrim$1((block) => `
7303
7355
  Can not resolve some parameters:
7304
7356
 
7305
7357
  ${block(pipelineIdentification)}
@@ -7339,7 +7391,7 @@ async function executePipeline(options) {
7339
7391
  tools,
7340
7392
  onProgress(newOngoingResult) {
7341
7393
  if (isReturned) {
7342
- throw new UnexpectedError(spaceTrim((block) => `
7394
+ throw new UnexpectedError(spaceTrim$1((block) => `
7343
7395
  Can not call \`onProgress\` after pipeline execution is finished
7344
7396
 
7345
7397
  ${block(pipelineIdentification)}
@@ -7356,7 +7408,7 @@ async function executePipeline(options) {
7356
7408
  },
7357
7409
  logLlmCall,
7358
7410
  $executionReport: executionReport,
7359
- pipelineIdentification: spaceTrim((block) => `
7411
+ pipelineIdentification: spaceTrim$1((block) => `
7360
7412
  ${block(pipelineIdentification)}
7361
7413
  Task name: ${currentTask.name}
7362
7414
  Task title: ${currentTask.title}
@@ -7465,7 +7517,7 @@ function createPipelineExecutor(options) {
7465
7517
  preparedPipeline = pipeline;
7466
7518
  }
7467
7519
  else if (isNotPreparedWarningSuppressed !== true) {
7468
- console.warn(spaceTrim((block) => `
7520
+ console.warn(spaceTrim$1((block) => `
7469
7521
  Pipeline is not prepared
7470
7522
 
7471
7523
  ${block(pipelineIdentification)}
@@ -7490,7 +7542,7 @@ function createPipelineExecutor(options) {
7490
7542
  tools,
7491
7543
  onProgress,
7492
7544
  logLlmCall,
7493
- pipelineIdentification: spaceTrim((block) => `
7545
+ pipelineIdentification: spaceTrim$1((block) => `
7494
7546
  ${block(pipelineIdentification)}
7495
7547
  ${runCount === 1 ? '' : `Run #${runCount}`}
7496
7548
  `),
@@ -7704,13 +7756,13 @@ function $registeredLlmToolsMessage() {
7704
7756
  });
7705
7757
  const usedEnvMessage = `Unknown \`.env\` file` ;
7706
7758
  if (metadata.length === 0) {
7707
- return spaceTrim$1((block) => `
7759
+ return spaceTrim$2((block) => `
7708
7760
  No LLM providers are available.
7709
7761
 
7710
7762
  ${block(usedEnvMessage)}
7711
7763
  `);
7712
7764
  }
7713
- return spaceTrim$1((block) => `
7765
+ return spaceTrim$2((block) => `
7714
7766
 
7715
7767
  ${block(usedEnvMessage)}
7716
7768
 
@@ -7756,7 +7808,7 @@ function $registeredLlmToolsMessage() {
7756
7808
  morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
7757
7809
  }
7758
7810
  }
7759
- let providerMessage = spaceTrim$1(`
7811
+ let providerMessage = spaceTrim$2(`
7760
7812
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
7761
7813
  ${morePieces.join('; ')}
7762
7814
  `);
@@ -7802,7 +7854,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
7802
7854
  .find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
7803
7855
  if (registeredItem === undefined) {
7804
7856
  // console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
7805
- throw new Error(spaceTrim$1((block) => `
7857
+ throw new Error(spaceTrim$2((block) => `
7806
7858
  There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
7807
7859
  Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
7808
7860
 
@@ -8068,7 +8120,7 @@ function unwrapResult(text, options) {
8068
8120
  let trimmedText = text;
8069
8121
  // Remove leading and trailing spaces and newlines
8070
8122
  if (isTrimmed) {
8071
- trimmedText = spaceTrim(trimmedText);
8123
+ trimmedText = spaceTrim$1(trimmedText);
8072
8124
  }
8073
8125
  let processedText = trimmedText;
8074
8126
  if (isIntroduceSentenceRemoved) {
@@ -8077,7 +8129,7 @@ function unwrapResult(text, options) {
8077
8129
  // Remove the introduce sentence and quotes by replacing it with an empty string
8078
8130
  processedText = processedText.replace(introduceSentenceRegex, '');
8079
8131
  }
8080
- processedText = spaceTrim(processedText);
8132
+ processedText = spaceTrim$1(processedText);
8081
8133
  }
8082
8134
  if (processedText.length < 3) {
8083
8135
  return trimmedText;
@@ -8140,7 +8192,7 @@ function unwrapResult(text, options) {
8140
8192
  function extractOneBlockFromMarkdown(markdown) {
8141
8193
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
8142
8194
  if (codeBlocks.length !== 1) {
8143
- throw new ParseError(spaceTrim$1((block) => `
8195
+ throw new ParseError(spaceTrim$2((block) => `
8144
8196
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
8145
8197
 
8146
8198
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -8181,13 +8233,13 @@ function extractBlock(markdown) {
8181
8233
  * @public exported from `@promptbook/markdown-utils`
8182
8234
  */
8183
8235
  function trimCodeBlock(value) {
8184
- value = spaceTrim(value);
8236
+ value = spaceTrim$1(value);
8185
8237
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
8186
8238
  return value;
8187
8239
  }
8188
8240
  value = value.replace(/^```[a-z]*/i, '');
8189
8241
  value = value.replace(/```$/i, '');
8190
- value = spaceTrim(value);
8242
+ value = spaceTrim$1(value);
8191
8243
  return value;
8192
8244
  }
8193
8245
 
@@ -8200,9 +8252,9 @@ function trimCodeBlock(value) {
8200
8252
  * @public exported from `@promptbook/markdown-utils`
8201
8253
  */
8202
8254
  function trimEndOfCodeBlock(value) {
8203
- value = spaceTrim(value);
8255
+ value = spaceTrim$1(value);
8204
8256
  value = value.replace(/```$/g, '');
8205
- value = spaceTrim(value);
8257
+ value = spaceTrim$1(value);
8206
8258
  return value;
8207
8259
  }
8208
8260
 
@@ -8249,7 +8301,7 @@ class JavascriptEvalExecutionTools {
8249
8301
  }
8250
8302
  // Note: [💎]
8251
8303
  // 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(_);
8304
+ const spaceTrim = (_) => spaceTrim$2(_);
8253
8305
  $preserve(spaceTrim);
8254
8306
  const removeQuotes$1 = removeQuotes;
8255
8307
  $preserve(removeQuotes$1);
@@ -8340,7 +8392,7 @@ class JavascriptEvalExecutionTools {
8340
8392
  .join('\n');
8341
8393
  // script = templateParameters(script, parameters);
8342
8394
  // <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
8343
- const statementToEvaluate = spaceTrim$1((block) => `
8395
+ const statementToEvaluate = spaceTrim$2((block) => `
8344
8396
 
8345
8397
  // Build-in functions:
8346
8398
  ${block(buildinFunctionsStatement)}
@@ -8355,7 +8407,7 @@ class JavascriptEvalExecutionTools {
8355
8407
  (()=>{ ${script} })()
8356
8408
  `);
8357
8409
  if (this.options.isVerbose) {
8358
- console.info(spaceTrim$1((block) => `
8410
+ console.info(spaceTrim$2((block) => `
8359
8411
  🚀 Evaluating ${scriptLanguage} script:
8360
8412
 
8361
8413
  ${block(statementToEvaluate)}`));
@@ -8377,7 +8429,7 @@ class JavascriptEvalExecutionTools {
8377
8429
  To: [PipelineExecutionError: Parameter `{thing}` is not defined],
8378
8430
  */
8379
8431
  if (!statementToEvaluate.includes(undefinedName + '(')) {
8380
- throw new PipelineExecutionError(spaceTrim$1((block) => `
8432
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
8381
8433
 
8382
8434
  Parameter \`{${undefinedName}}\` is not defined
8383
8435
 
@@ -8399,7 +8451,7 @@ class JavascriptEvalExecutionTools {
8399
8451
  `));
8400
8452
  }
8401
8453
  else {
8402
- throw new PipelineExecutionError(spaceTrim$1((block) => `
8454
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
8403
8455
  Function ${undefinedName}() is not defined
8404
8456
 
8405
8457
  - Make sure that the function is one of built-in functions
@@ -9266,7 +9318,7 @@ function startRemoteServer(options) {
9266
9318
  response.type('text/html').send(renderServerIndexHtml(serverInfo));
9267
9319
  }
9268
9320
  else {
9269
- response.type('text/markdown').send(await spaceTrim(async (block) => `
9321
+ response.type('text/markdown').send(await spaceTrim$1(async (block) => `
9270
9322
  # Promptbook
9271
9323
 
9272
9324
  > ${block(CLAIM)}