@promptbook/markdown-utils 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,4 +1,4 @@
1
- import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
1
+ import spaceTrim$1, { spaceTrim as spaceTrim$2 } from 'spacetrim';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { Subject } from 'rxjs';
4
4
  import { forTime } from 'waitasecond';
@@ -23,7 +23,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -141,7 +141,7 @@ function extractAllBlocksFromMarkdown(markdown) {
141
141
  function extractOneBlockFromMarkdown(markdown) {
142
142
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
143
143
  if (codeBlocks.length !== 1) {
144
- throw new ParseError(spaceTrim((block) => `
144
+ throw new ParseError(spaceTrim$1((block) => `
145
145
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
146
146
 
147
147
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -172,6 +172,17 @@ function extractBlock(markdown) {
172
172
  return content;
173
173
  }
174
174
 
175
+ /**
176
+ * Trims string from all 4 sides
177
+ *
178
+ * Note: This is a re-exported function from the `spacetrim` package which is
179
+ * Developed by same author @hejny as this package
180
+ *
181
+ * @public exported from `@promptbook/utils`
182
+ * @see https://github.com/hejny/spacetrim#usage
183
+ */
184
+ const spaceTrim = spaceTrim$2;
185
+
175
186
  /**
176
187
  * @private util of `@promptbook/color`
177
188
  * @de
@@ -220,6 +231,7 @@ function take(initialValue) {
220
231
  * @public exported from `@promptbook/color`
221
232
  */
222
233
  const CSS_COLORS = {
234
+ promptbook: '#79EAFD',
223
235
  transparent: 'rgba(0,0,0,0)',
224
236
  aliceblue: '#f0f8ff',
225
237
  antiquewhite: '#faebd7',
@@ -435,6 +447,28 @@ class Color {
435
447
  throw new Error(`Can not create color from given object`);
436
448
  }
437
449
  }
450
+ /**
451
+ * Creates a new Color instance from miscellaneous formats
452
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
453
+ *
454
+ * @param color
455
+ * @returns Color object
456
+ */
457
+ static fromSafe(color) {
458
+ try {
459
+ return Color.from(color);
460
+ }
461
+ catch (error) {
462
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
463
+ console.warn(spaceTrim((block) => `
464
+ Color.fromSafe error:
465
+ ${block(error.message)}
466
+
467
+ Returning default PROMPTBOOK_COLOR.
468
+ `));
469
+ return Color.fromString('promptbook');
470
+ }
471
+ }
438
472
  /**
439
473
  * Creates a new Color instance from miscellaneous string formats
440
474
  *
@@ -1050,7 +1084,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
1050
1084
  *
1051
1085
  * @public exported from `@promptbook/core`
1052
1086
  */
1053
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1087
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1054
1088
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1055
1089
  /**
1056
1090
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1248,7 +1282,7 @@ true);
1248
1282
  function getErrorReportUrl(error) {
1249
1283
  const report = {
1250
1284
  title: `🐜 Error report from ${NAME}`,
1251
- body: spaceTrim((block) => `
1285
+ body: spaceTrim$1((block) => `
1252
1286
 
1253
1287
 
1254
1288
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1291,7 +1325,7 @@ function getErrorReportUrl(error) {
1291
1325
  */
1292
1326
  class UnexpectedError extends Error {
1293
1327
  constructor(message) {
1294
- super(spaceTrim$1((block) => `
1328
+ super(spaceTrim$2((block) => `
1295
1329
  ${block(message)}
1296
1330
 
1297
1331
  Note: This error should not happen.
@@ -1317,7 +1351,7 @@ class WrappedError extends Error {
1317
1351
  constructor(whatWasThrown) {
1318
1352
  const tag = `[🤮]`;
1319
1353
  console.error(tag, whatWasThrown);
1320
- super(spaceTrim$1(`
1354
+ super(spaceTrim$2(`
1321
1355
  Non-Error object was thrown
1322
1356
 
1323
1357
  Note: Look for ${tag} in the console for more details
@@ -1688,7 +1722,7 @@ function pipelineJsonToString(pipelineJson) {
1688
1722
  pipelineString += '\n\n';
1689
1723
  pipelineString += '```' + contentLanguage;
1690
1724
  pipelineString += '\n';
1691
- pipelineString += spaceTrim(content);
1725
+ pipelineString += spaceTrim$1(content);
1692
1726
  // <- TODO: [main] !!3 Escape
1693
1727
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
1694
1728
  pipelineString += '\n';
@@ -1809,7 +1843,7 @@ function checkSerializableAsJson(options) {
1809
1843
  }
1810
1844
  else if (typeof value === 'object') {
1811
1845
  if (value instanceof Date) {
1812
- throw new UnexpectedError(spaceTrim((block) => `
1846
+ throw new UnexpectedError(spaceTrim$1((block) => `
1813
1847
  \`${name}\` is Date
1814
1848
 
1815
1849
  Use \`string_date_iso8601\` instead
@@ -1828,7 +1862,7 @@ function checkSerializableAsJson(options) {
1828
1862
  throw new UnexpectedError(`${name} is RegExp`);
1829
1863
  }
1830
1864
  else if (value instanceof Error) {
1831
- throw new UnexpectedError(spaceTrim((block) => `
1865
+ throw new UnexpectedError(spaceTrim$1((block) => `
1832
1866
  \`${name}\` is unserialized Error
1833
1867
 
1834
1868
  Use function \`serializeError\`
@@ -1851,7 +1885,7 @@ function checkSerializableAsJson(options) {
1851
1885
  }
1852
1886
  catch (error) {
1853
1887
  assertsError(error);
1854
- throw new UnexpectedError(spaceTrim((block) => `
1888
+ throw new UnexpectedError(spaceTrim$1((block) => `
1855
1889
  \`${name}\` is not serializable
1856
1890
 
1857
1891
  ${block(error.stack || error.message)}
@@ -1883,7 +1917,7 @@ function checkSerializableAsJson(options) {
1883
1917
  }
1884
1918
  }
1885
1919
  else {
1886
- throw new UnexpectedError(spaceTrim((block) => `
1920
+ throw new UnexpectedError(spaceTrim$1((block) => `
1887
1921
  \`${name}\` is unknown type
1888
1922
 
1889
1923
  Additional message for \`${name}\`:
@@ -2137,7 +2171,7 @@ function validatePipeline(pipeline) {
2137
2171
  if (!(error instanceof PipelineLogicError)) {
2138
2172
  throw error;
2139
2173
  }
2140
- console.error(spaceTrim$1((block) => `
2174
+ console.error(spaceTrim$2((block) => `
2141
2175
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2142
2176
 
2143
2177
  ${block(error.message)}
@@ -2164,7 +2198,7 @@ function validatePipeline_InnerFunction(pipeline) {
2164
2198
  })();
2165
2199
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2166
2200
  // <- Note: [🚲]
2167
- throw new PipelineLogicError(spaceTrim$1((block) => `
2201
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2168
2202
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2169
2203
 
2170
2204
  ${block(pipelineIdentification)}
@@ -2172,7 +2206,7 @@ function validatePipeline_InnerFunction(pipeline) {
2172
2206
  }
2173
2207
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2174
2208
  // <- Note: [🚲]
2175
- throw new PipelineLogicError(spaceTrim$1((block) => `
2209
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2176
2210
  Invalid Promptbook Version "${pipeline.bookVersion}"
2177
2211
 
2178
2212
  ${block(pipelineIdentification)}
@@ -2181,7 +2215,7 @@ function validatePipeline_InnerFunction(pipeline) {
2181
2215
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2182
2216
  if (!Array.isArray(pipeline.parameters)) {
2183
2217
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2184
- throw new ParseError(spaceTrim$1((block) => `
2218
+ throw new ParseError(spaceTrim$2((block) => `
2185
2219
  Pipeline is valid JSON but with wrong structure
2186
2220
 
2187
2221
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2192,7 +2226,7 @@ function validatePipeline_InnerFunction(pipeline) {
2192
2226
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2193
2227
  if (!Array.isArray(pipeline.tasks)) {
2194
2228
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2195
- throw new ParseError(spaceTrim$1((block) => `
2229
+ throw new ParseError(spaceTrim$2((block) => `
2196
2230
  Pipeline is valid JSON but with wrong structure
2197
2231
 
2198
2232
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2218,7 +2252,7 @@ function validatePipeline_InnerFunction(pipeline) {
2218
2252
  // Note: Check each parameter individually
2219
2253
  for (const parameter of pipeline.parameters) {
2220
2254
  if (parameter.isInput && parameter.isOutput) {
2221
- throw new PipelineLogicError(spaceTrim$1((block) => `
2255
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2222
2256
 
2223
2257
  Parameter \`{${parameter.name}}\` can not be both input and output
2224
2258
 
@@ -2229,7 +2263,7 @@ function validatePipeline_InnerFunction(pipeline) {
2229
2263
  if (!parameter.isInput &&
2230
2264
  !parameter.isOutput &&
2231
2265
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2232
- throw new PipelineLogicError(spaceTrim$1((block) => `
2266
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2233
2267
  Parameter \`{${parameter.name}}\` is created but not used
2234
2268
 
2235
2269
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2241,7 +2275,7 @@ function validatePipeline_InnerFunction(pipeline) {
2241
2275
  }
2242
2276
  // Note: Testing that parameter is either input or result of some task
2243
2277
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2244
- throw new PipelineLogicError(spaceTrim$1((block) => `
2278
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2245
2279
  Parameter \`{${parameter.name}}\` is declared but not defined
2246
2280
 
2247
2281
  You can do one of these:
@@ -2257,14 +2291,14 @@ function validatePipeline_InnerFunction(pipeline) {
2257
2291
  // Note: Checking each task individually
2258
2292
  for (const task of pipeline.tasks) {
2259
2293
  if (definedParameters.has(task.resultingParameterName)) {
2260
- throw new PipelineLogicError(spaceTrim$1((block) => `
2294
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2261
2295
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2262
2296
 
2263
2297
  ${block(pipelineIdentification)}
2264
2298
  `));
2265
2299
  }
2266
2300
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2267
- throw new PipelineLogicError(spaceTrim$1((block) => `
2301
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2268
2302
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2269
2303
 
2270
2304
  ${block(pipelineIdentification)}
@@ -2274,7 +2308,7 @@ function validatePipeline_InnerFunction(pipeline) {
2274
2308
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2275
2309
  if (!task.format &&
2276
2310
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2277
- throw new PipelineLogicError(spaceTrim$1((block) => `
2311
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2278
2312
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2279
2313
 
2280
2314
  ${block(pipelineIdentification)}
@@ -2282,7 +2316,7 @@ function validatePipeline_InnerFunction(pipeline) {
2282
2316
  }
2283
2317
  for (const joker of task.jokerParameterNames) {
2284
2318
  if (!task.dependentParameterNames.includes(joker)) {
2285
- throw new PipelineLogicError(spaceTrim$1((block) => `
2319
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2286
2320
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2287
2321
 
2288
2322
  ${block(pipelineIdentification)}
@@ -2293,21 +2327,21 @@ function validatePipeline_InnerFunction(pipeline) {
2293
2327
  if (task.expectations) {
2294
2328
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2295
2329
  if (min !== undefined && max !== undefined && min > max) {
2296
- throw new PipelineLogicError(spaceTrim$1((block) => `
2330
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2297
2331
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2298
2332
 
2299
2333
  ${block(pipelineIdentification)}
2300
2334
  `));
2301
2335
  }
2302
2336
  if (min !== undefined && min < 0) {
2303
- throw new PipelineLogicError(spaceTrim$1((block) => `
2337
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2304
2338
  Min expectation of ${unit} must be zero or positive
2305
2339
 
2306
2340
  ${block(pipelineIdentification)}
2307
2341
  `));
2308
2342
  }
2309
2343
  if (max !== undefined && max <= 0) {
2310
- throw new PipelineLogicError(spaceTrim$1((block) => `
2344
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2311
2345
  Max expectation of ${unit} must be positive
2312
2346
 
2313
2347
  ${block(pipelineIdentification)}
@@ -2329,7 +2363,7 @@ function validatePipeline_InnerFunction(pipeline) {
2329
2363
  while (unresovedTasks.length > 0) {
2330
2364
  if (loopLimit-- < 0) {
2331
2365
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2332
- throw new UnexpectedError(spaceTrim$1((block) => `
2366
+ throw new UnexpectedError(spaceTrim$2((block) => `
2333
2367
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2334
2368
 
2335
2369
  ${block(pipelineIdentification)}
@@ -2339,7 +2373,7 @@ function validatePipeline_InnerFunction(pipeline) {
2339
2373
  if (currentlyResovedTasks.length === 0) {
2340
2374
  throw new PipelineLogicError(
2341
2375
  // TODO: [🐎] DRY
2342
- spaceTrim$1((block) => `
2376
+ spaceTrim$2((block) => `
2343
2377
 
2344
2378
  Can not resolve some parameters:
2345
2379
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2503,7 +2537,7 @@ class SimplePipelineCollection {
2503
2537
  for (const pipeline of pipelines) {
2504
2538
  // TODO: [👠] DRY
2505
2539
  if (pipeline.pipelineUrl === undefined) {
2506
- throw new PipelineUrlError(spaceTrim$1(`
2540
+ throw new PipelineUrlError(spaceTrim$2(`
2507
2541
  Pipeline with name "${pipeline.title}" does not have defined URL
2508
2542
 
2509
2543
  File:
@@ -2525,7 +2559,7 @@ class SimplePipelineCollection {
2525
2559
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
2526
2560
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
2527
2561
  const existing = this.collection.get(pipeline.pipelineUrl);
2528
- throw new PipelineUrlError(spaceTrim$1(`
2562
+ throw new PipelineUrlError(spaceTrim$2(`
2529
2563
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
2530
2564
 
2531
2565
  Conflicting files:
@@ -2557,13 +2591,13 @@ class SimplePipelineCollection {
2557
2591
  const pipeline = this.collection.get(url);
2558
2592
  if (!pipeline) {
2559
2593
  if (this.listPipelines().length === 0) {
2560
- throw new NotFoundError(spaceTrim$1(`
2594
+ throw new NotFoundError(spaceTrim$2(`
2561
2595
  Pipeline with url "${url}" not found
2562
2596
 
2563
2597
  No pipelines available
2564
2598
  `));
2565
2599
  }
2566
- throw new NotFoundError(spaceTrim$1((block) => `
2600
+ throw new NotFoundError(spaceTrim$2((block) => `
2567
2601
  Pipeline with url "${url}" not found
2568
2602
 
2569
2603
  Available pipelines:
@@ -2604,7 +2638,7 @@ function createPipelineCollectionFromJson(...promptbooks) {
2604
2638
  */
2605
2639
  class MissingToolsError extends Error {
2606
2640
  constructor(message) {
2607
- super(spaceTrim$1((block) => `
2641
+ super(spaceTrim$2((block) => `
2608
2642
  ${block(message)}
2609
2643
 
2610
2644
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -2838,7 +2872,7 @@ class NotAllowed extends Error {
2838
2872
  */
2839
2873
  class NotYetImplementedError extends Error {
2840
2874
  constructor(message) {
2841
- super(spaceTrim$1((block) => `
2875
+ super(spaceTrim$2((block) => `
2842
2876
  ${block(message)}
2843
2877
 
2844
2878
  Note: This feature is not implemented yet but it will be soon.
@@ -2940,7 +2974,7 @@ function serializeError(error) {
2940
2974
  const { name, message, stack } = error;
2941
2975
  const { id } = error;
2942
2976
  if (!Object.keys(ALL_ERRORS).includes(name)) {
2943
- console.error(spaceTrim((block) => `
2977
+ console.error(spaceTrim$1((block) => `
2944
2978
 
2945
2979
  Cannot serialize error with name "${name}"
2946
2980
 
@@ -2973,7 +3007,7 @@ function jsonParse(value) {
2973
3007
  }
2974
3008
  else if (typeof value !== 'string') {
2975
3009
  console.error('Can not parse JSON from non-string value.', { text: value });
2976
- throw new Error(spaceTrim(`
3010
+ throw new Error(spaceTrim$1(`
2977
3011
  Can not parse JSON from non-string value.
2978
3012
 
2979
3013
  The value type: ${typeof value}
@@ -2987,7 +3021,7 @@ function jsonParse(value) {
2987
3021
  if (!(error instanceof Error)) {
2988
3022
  throw error;
2989
3023
  }
2990
- throw new Error(spaceTrim((block) => `
3024
+ throw new Error(spaceTrim$1((block) => `
2991
3025
  ${block(error.message)}
2992
3026
 
2993
3027
  The expected JSON text:
@@ -3040,7 +3074,7 @@ function deserializeError(error) {
3040
3074
  message = `${name}: ${message}`;
3041
3075
  }
3042
3076
  if (stack !== undefined && stack !== '') {
3043
- message = spaceTrim((block) => `
3077
+ message = spaceTrim$1((block) => `
3044
3078
  ${block(message)}
3045
3079
 
3046
3080
  Original stack trace:
@@ -3077,11 +3111,11 @@ function assertsTaskSuccessful(executionResult) {
3077
3111
  throw deserializeError(errors[0]);
3078
3112
  }
3079
3113
  else {
3080
- throw new PipelineExecutionError(spaceTrim$1((block) => `
3114
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
3081
3115
  Multiple errors occurred during Promptbook execution
3082
3116
 
3083
3117
  ${block(errors
3084
- .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
3118
+ .map(({ name, stack, message }, index) => spaceTrim$2((block) => `
3085
3119
  ${name} ${index + 1}:
3086
3120
  ${block(stack || message)}
3087
3121
  `))
@@ -3552,14 +3586,14 @@ class MultipleLlmExecutionTools {
3552
3586
  if (description === undefined) {
3553
3587
  return headLine;
3554
3588
  }
3555
- return spaceTrim((block) => `
3589
+ return spaceTrim$1((block) => `
3556
3590
  ${headLine}
3557
3591
 
3558
3592
  ${ /* <- Note: Indenting the description: */block(description)}
3559
3593
  `);
3560
3594
  })
3561
3595
  .join('\n\n');
3562
- return spaceTrim((block) => `
3596
+ return spaceTrim$1((block) => `
3563
3597
  Multiple LLM Providers:
3564
3598
 
3565
3599
  ${block(innerModelsTitlesAndDescriptions)}
@@ -3650,7 +3684,7 @@ class MultipleLlmExecutionTools {
3650
3684
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3651
3685
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3652
3686
  // 3) ...
3653
- spaceTrim((block) => `
3687
+ spaceTrim$1((block) => `
3654
3688
  All execution tools of ${this.title} failed:
3655
3689
 
3656
3690
  ${block(errors
@@ -3663,7 +3697,7 @@ class MultipleLlmExecutionTools {
3663
3697
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
3664
3698
  }
3665
3699
  else {
3666
- throw new PipelineExecutionError(spaceTrim((block) => `
3700
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
3667
3701
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
3668
3702
 
3669
3703
  Available \`LlmExecutionTools\`:
@@ -3696,7 +3730,7 @@ class MultipleLlmExecutionTools {
3696
3730
  */
3697
3731
  function joinLlmExecutionTools(title, ...llmExecutionTools) {
3698
3732
  if (llmExecutionTools.length === 0) {
3699
- const warningMessage = spaceTrim(`
3733
+ const warningMessage = spaceTrim$1(`
3700
3734
  You have not provided any \`LlmExecutionTools\`
3701
3735
  This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
3702
3736
 
@@ -4013,14 +4047,14 @@ function $registeredScrapersMessage(availableScrapers) {
4013
4047
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
4014
4048
  });
4015
4049
  if (metadata.length === 0) {
4016
- return spaceTrim(`
4050
+ return spaceTrim$1(`
4017
4051
  **No scrapers are available**
4018
4052
 
4019
4053
  This is a unexpected behavior, you are probably using some broken version of Promptbook
4020
4054
  At least there should be available the metadata of the scrapers
4021
4055
  `);
4022
4056
  }
4023
- return spaceTrim((block) => `
4057
+ return spaceTrim$1((block) => `
4024
4058
  Available scrapers are:
4025
4059
  ${block(metadata
4026
4060
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -4526,7 +4560,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
4526
4560
  else if (urlOrRequest instanceof Request) {
4527
4561
  url = urlOrRequest.url;
4528
4562
  }
4529
- throw new PromptbookFetchError(spaceTrim((block) => `
4563
+ throw new PromptbookFetchError(spaceTrim$1((block) => `
4530
4564
  Can not fetch "${url}"
4531
4565
 
4532
4566
  Fetch error:
@@ -4687,7 +4721,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4687
4721
  const fileExtension = getFileExtension(filename);
4688
4722
  const mimeType = extensionToMimeType(fileExtension || '');
4689
4723
  if (!(await isFileExisting(filename, tools.fs))) {
4690
- throw new NotFoundError(spaceTrim((block) => `
4724
+ throw new NotFoundError(spaceTrim$1((block) => `
4691
4725
  Can not make source handler for file which does not exist:
4692
4726
 
4693
4727
  File:
@@ -4780,7 +4814,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4780
4814
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
4781
4815
  break;
4782
4816
  }
4783
- console.warn(spaceTrim((block) => `
4817
+ console.warn(spaceTrim$1((block) => `
4784
4818
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
4785
4819
 
4786
4820
  The source:
@@ -4796,7 +4830,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4796
4830
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4797
4831
  }
4798
4832
  if (partialPieces === null) {
4799
- throw new KnowledgeScrapeError(spaceTrim((block) => `
4833
+ throw new KnowledgeScrapeError(spaceTrim$1((block) => `
4800
4834
  Cannot scrape knowledge
4801
4835
 
4802
4836
  The source:
@@ -4875,7 +4909,7 @@ async function prepareTasks(pipeline, tools, options) {
4875
4909
  if (task.taskType === 'PROMPT_TASK' &&
4876
4910
  knowledgePiecesCount > 0 &&
4877
4911
  !dependentParameterNames.includes('knowledge')) {
4878
- preparedContent = spaceTrim$1(`
4912
+ preparedContent = spaceTrim$2(`
4879
4913
  {content}
4880
4914
 
4881
4915
  ## Knowledge
@@ -5188,7 +5222,7 @@ function extractVariablesFromJavascript(script) {
5188
5222
  }
5189
5223
  catch (error) {
5190
5224
  assertsError(error);
5191
- throw new ParseError(spaceTrim$1((block) => `
5225
+ throw new ParseError(spaceTrim$2((block) => `
5192
5226
  Can not extract variables from the script
5193
5227
  ${block(error.stack || error.message)}
5194
5228
 
@@ -5371,7 +5405,7 @@ const CsvFormatParser = {
5371
5405
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
5372
5406
  const csv = csvParse(value, settings);
5373
5407
  if (csv.errors.length !== 0) {
5374
- throw new CsvFormatError(spaceTrim((block) => `
5408
+ throw new CsvFormatError(spaceTrim$1((block) => `
5375
5409
  CSV parsing error
5376
5410
 
5377
5411
  Error(s) from CSV parsing:
@@ -5416,7 +5450,7 @@ const CsvFormatParser = {
5416
5450
  const { value, settings, mapCallback, onProgress } = options;
5417
5451
  const csv = csvParse(value, settings);
5418
5452
  if (csv.errors.length !== 0) {
5419
- throw new CsvFormatError(spaceTrim((block) => `
5453
+ throw new CsvFormatError(spaceTrim$1((block) => `
5420
5454
  CSV parsing error
5421
5455
 
5422
5456
  Error(s) from CSV parsing:
@@ -5626,7 +5660,7 @@ function mapAvailableToExpectedParameters(options) {
5626
5660
  }
5627
5661
  // Phase 2️⃣: Non-matching mapping
5628
5662
  if (expectedParameterNames.size !== availableParametersNames.size) {
5629
- throw new PipelineExecutionError(spaceTrim((block) => `
5663
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
5630
5664
  Can not map available parameters to expected parameters
5631
5665
 
5632
5666
  Mapped parameters:
@@ -5923,7 +5957,7 @@ function validatePromptResult(options) {
5923
5957
  }
5924
5958
  catch (error) {
5925
5959
  keepUnused(error);
5926
- throw new ExpectError(spaceTrim$1((block) => `
5960
+ throw new ExpectError(spaceTrim$2((block) => `
5927
5961
  Expected valid JSON string
5928
5962
 
5929
5963
  The expected JSON text:
@@ -5986,7 +6020,7 @@ async function executeAttempts(options) {
5986
6020
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
5987
6021
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
5988
6022
  if (isJokerAttempt && !jokerParameterName) {
5989
- throw new UnexpectedError(spaceTrim$1((block) => `
6023
+ throw new UnexpectedError(spaceTrim$2((block) => `
5990
6024
  Joker not found in attempt ${attemptIndex}
5991
6025
 
5992
6026
  ${block(pipelineIdentification)}
@@ -5997,7 +6031,7 @@ async function executeAttempts(options) {
5997
6031
  $ongoingTaskResult.$expectError = null;
5998
6032
  if (isJokerAttempt) {
5999
6033
  if (parameters[jokerParameterName] === undefined) {
6000
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6034
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6001
6035
  Joker parameter {${jokerParameterName}} not defined
6002
6036
 
6003
6037
  ${block(pipelineIdentification)}
@@ -6055,7 +6089,7 @@ async function executeAttempts(options) {
6055
6089
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6056
6090
  break variant;
6057
6091
  case 'EMBEDDING':
6058
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6092
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6059
6093
  Embedding model can not be used in pipeline
6060
6094
 
6061
6095
  This should be catched during parsing
@@ -6066,7 +6100,7 @@ async function executeAttempts(options) {
6066
6100
  break variant;
6067
6101
  // <- case [🤖]:
6068
6102
  default:
6069
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6103
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6070
6104
  Unknown model variant "${task.modelRequirements.modelVariant}"
6071
6105
 
6072
6106
  ${block(pipelineIdentification)}
@@ -6077,14 +6111,14 @@ async function executeAttempts(options) {
6077
6111
  break;
6078
6112
  case 'SCRIPT_TASK':
6079
6113
  if (arrayableToArray(tools.script).length === 0) {
6080
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6114
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6081
6115
  No script execution tools are available
6082
6116
 
6083
6117
  ${block(pipelineIdentification)}
6084
6118
  `));
6085
6119
  }
6086
6120
  if (!task.contentLanguage) {
6087
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6121
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6088
6122
  Script language is not defined for SCRIPT TASK "${task.name}"
6089
6123
 
6090
6124
  ${block(pipelineIdentification)}
@@ -6115,7 +6149,7 @@ async function executeAttempts(options) {
6115
6149
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6116
6150
  }
6117
6151
  else {
6118
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6152
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6119
6153
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6120
6154
 
6121
6155
  ${block(pipelineIdentification)}
@@ -6129,7 +6163,7 @@ async function executeAttempts(options) {
6129
6163
  break taskType;
6130
6164
  case 'DIALOG_TASK':
6131
6165
  if (tools.userInterface === undefined) {
6132
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6166
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6133
6167
  User interface tools are not available
6134
6168
 
6135
6169
  ${block(pipelineIdentification)}
@@ -6147,7 +6181,7 @@ async function executeAttempts(options) {
6147
6181
  break taskType;
6148
6182
  // <- case: [🅱]
6149
6183
  default:
6150
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6184
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6151
6185
  Unknown execution type "${task.taskType}"
6152
6186
 
6153
6187
  ${block(pipelineIdentification)}
@@ -6245,7 +6279,7 @@ async function executeAttempts(options) {
6245
6279
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6246
6280
  // Note: Create a summary of all failures
6247
6281
  const failuresSummary = $ongoingTaskResult.$failedResults
6248
- .map((failure) => spaceTrim$1((block) => {
6282
+ .map((failure) => spaceTrim$2((block) => {
6249
6283
  var _a, _b;
6250
6284
  return `
6251
6285
  Attempt ${failure.attemptIndex + 1}:
@@ -6255,14 +6289,14 @@ async function executeAttempts(options) {
6255
6289
  Result:
6256
6290
  ${block(failure.result === null
6257
6291
  ? 'null'
6258
- : spaceTrim$1(failure.result)
6292
+ : spaceTrim$2(failure.result)
6259
6293
  .split('\n')
6260
6294
  .map((line) => `> ${line}`)
6261
6295
  .join('\n'))}
6262
6296
  `;
6263
6297
  }))
6264
6298
  .join('\n\n---\n\n');
6265
- throw new PipelineExecutionError(spaceTrim$1((block) => {
6299
+ throw new PipelineExecutionError(spaceTrim$2((block) => {
6266
6300
  var _a;
6267
6301
  return `
6268
6302
  LLM execution failed ${maxExecutionAttempts}x
@@ -6282,7 +6316,7 @@ async function executeAttempts(options) {
6282
6316
  }
6283
6317
  }
6284
6318
  if ($ongoingTaskResult.$resultString === null) {
6285
- throw new UnexpectedError(spaceTrim$1((block) => `
6319
+ throw new UnexpectedError(spaceTrim$2((block) => `
6286
6320
  Something went wrong and prompt result is null
6287
6321
 
6288
6322
  ${block(pipelineIdentification)}
@@ -6309,7 +6343,7 @@ async function executeFormatSubvalues(options) {
6309
6343
  return /* not await */ executeAttempts({ ...options, logLlmCall });
6310
6344
  }
6311
6345
  if (jokerParameterNames.length !== 0) {
6312
- throw new UnexpectedError(spaceTrim((block) => `
6346
+ throw new UnexpectedError(spaceTrim$1((block) => `
6313
6347
  JOKER parameters are not supported together with FOREACH command
6314
6348
 
6315
6349
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6322,7 +6356,7 @@ async function executeFormatSubvalues(options) {
6322
6356
  if (formatDefinition === undefined) {
6323
6357
  throw new UnexpectedError(
6324
6358
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6325
- spaceTrim((block) => `
6359
+ spaceTrim$1((block) => `
6326
6360
  Unsupported format "${task.foreach.formatName}"
6327
6361
 
6328
6362
  Available formats:
@@ -6339,7 +6373,7 @@ async function executeFormatSubvalues(options) {
6339
6373
  if (subvalueParser === undefined) {
6340
6374
  throw new UnexpectedError(
6341
6375
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6342
- spaceTrim((block) => `
6376
+ spaceTrim$1((block) => `
6343
6377
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6344
6378
 
6345
6379
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6379,7 +6413,7 @@ async function executeFormatSubvalues(options) {
6379
6413
  if (!(error instanceof PipelineExecutionError)) {
6380
6414
  throw error;
6381
6415
  }
6382
- const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
6416
+ const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6383
6417
  ${error.message}
6384
6418
 
6385
6419
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6403,7 +6437,7 @@ async function executeFormatSubvalues(options) {
6403
6437
  ...options,
6404
6438
  priority: priority + index,
6405
6439
  parameters: allSubparameters,
6406
- pipelineIdentification: spaceTrim((block) => `
6440
+ pipelineIdentification: spaceTrim$1((block) => `
6407
6441
  ${block(pipelineIdentification)}
6408
6442
  Subparameter index: ${index}
6409
6443
  `),
@@ -6412,7 +6446,7 @@ async function executeFormatSubvalues(options) {
6412
6446
  }
6413
6447
  catch (error) {
6414
6448
  if (length > BIG_DATASET_TRESHOLD) {
6415
- console.error(spaceTrim((block) => `
6449
+ console.error(spaceTrim$1((block) => `
6416
6450
  ${error.message}
6417
6451
 
6418
6452
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6588,7 +6622,7 @@ async function getReservedParametersForTask(options) {
6588
6622
  // Note: Doublecheck that ALL reserved parameters are defined:
6589
6623
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6590
6624
  if (reservedParameters[parameterName] === undefined) {
6591
- throw new UnexpectedError(spaceTrim$1((block) => `
6625
+ throw new UnexpectedError(spaceTrim$2((block) => `
6592
6626
  Reserved parameter {${parameterName}} is not defined
6593
6627
 
6594
6628
  ${block(pipelineIdentification)}
@@ -6614,7 +6648,7 @@ async function executeTask(options) {
6614
6648
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6615
6649
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6616
6650
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6617
- throw new UnexpectedError(spaceTrim$1((block) => `
6651
+ throw new UnexpectedError(spaceTrim$2((block) => `
6618
6652
  Dependent parameters are not consistent with used parameters:
6619
6653
 
6620
6654
  Dependent parameters:
@@ -6658,7 +6692,7 @@ async function executeTask(options) {
6658
6692
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
6659
6693
  // Houston, we have a problem
6660
6694
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
6661
- throw new UnexpectedError(spaceTrim$1((block) => `
6695
+ throw new UnexpectedError(spaceTrim$2((block) => `
6662
6696
  Parameter \`{${parameterName}}\` is NOT defined
6663
6697
  BUT used in task "${currentTask.title || currentTask.name}"
6664
6698
 
@@ -6727,7 +6761,7 @@ function filterJustOutputParameters(options) {
6727
6761
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
6728
6762
  if (parametersToPass[parameter.name] === undefined) {
6729
6763
  // [4]
6730
- $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6764
+ $warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
6731
6765
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
6732
6766
 
6733
6767
  Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
@@ -6835,7 +6869,7 @@ async function executePipeline(options) {
6835
6869
  for (const parameterName of Object.keys(inputParameters)) {
6836
6870
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
6837
6871
  if (parameter === undefined) {
6838
- warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6872
+ warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
6839
6873
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
6840
6874
 
6841
6875
  ${block(pipelineIdentification)}
@@ -6850,7 +6884,7 @@ async function executePipeline(options) {
6850
6884
  // TODO: [🧠] This should be also non-critical error
6851
6885
  return exportJson({
6852
6886
  name: 'pipelineExecutorResult',
6853
- message: spaceTrim$1((block) => `
6887
+ message: spaceTrim$2((block) => `
6854
6888
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
6855
6889
 
6856
6890
  ${block(pipelineIdentification)}
@@ -6859,7 +6893,7 @@ async function executePipeline(options) {
6859
6893
  value: {
6860
6894
  isSuccessful: false,
6861
6895
  errors: [
6862
- new PipelineExecutionError(spaceTrim$1((block) => `
6896
+ new PipelineExecutionError(spaceTrim$2((block) => `
6863
6897
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
6864
6898
 
6865
6899
  ${block(pipelineIdentification)}
@@ -6886,7 +6920,7 @@ async function executePipeline(options) {
6886
6920
  while (unresovedTasks.length > 0) {
6887
6921
  if (loopLimit-- < 0) {
6888
6922
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
6889
- throw new UnexpectedError(spaceTrim$1((block) => `
6923
+ throw new UnexpectedError(spaceTrim$2((block) => `
6890
6924
  Loop limit reached during resolving parameters pipeline execution
6891
6925
 
6892
6926
  ${block(pipelineIdentification)}
@@ -6896,7 +6930,7 @@ async function executePipeline(options) {
6896
6930
  if (!currentTask && resolving.length === 0) {
6897
6931
  throw new UnexpectedError(
6898
6932
  // TODO: [🐎] DRY
6899
- spaceTrim$1((block) => `
6933
+ spaceTrim$2((block) => `
6900
6934
  Can not resolve some parameters:
6901
6935
 
6902
6936
  ${block(pipelineIdentification)}
@@ -6936,7 +6970,7 @@ async function executePipeline(options) {
6936
6970
  tools,
6937
6971
  onProgress(newOngoingResult) {
6938
6972
  if (isReturned) {
6939
- throw new UnexpectedError(spaceTrim$1((block) => `
6973
+ throw new UnexpectedError(spaceTrim$2((block) => `
6940
6974
  Can not call \`onProgress\` after pipeline execution is finished
6941
6975
 
6942
6976
  ${block(pipelineIdentification)}
@@ -6953,7 +6987,7 @@ async function executePipeline(options) {
6953
6987
  },
6954
6988
  logLlmCall,
6955
6989
  $executionReport: executionReport,
6956
- pipelineIdentification: spaceTrim$1((block) => `
6990
+ pipelineIdentification: spaceTrim$2((block) => `
6957
6991
  ${block(pipelineIdentification)}
6958
6992
  Task name: ${currentTask.name}
6959
6993
  Task title: ${currentTask.title}
@@ -7062,7 +7096,7 @@ function createPipelineExecutor(options) {
7062
7096
  preparedPipeline = pipeline;
7063
7097
  }
7064
7098
  else if (isNotPreparedWarningSuppressed !== true) {
7065
- console.warn(spaceTrim$1((block) => `
7099
+ console.warn(spaceTrim$2((block) => `
7066
7100
  Pipeline is not prepared
7067
7101
 
7068
7102
  ${block(pipelineIdentification)}
@@ -7087,7 +7121,7 @@ function createPipelineExecutor(options) {
7087
7121
  tools,
7088
7122
  onProgress,
7089
7123
  logLlmCall,
7090
- pipelineIdentification: spaceTrim$1((block) => `
7124
+ pipelineIdentification: spaceTrim$2((block) => `
7091
7125
  ${block(pipelineIdentification)}
7092
7126
  ${runCount === 1 ? '' : `Run #${runCount}`}
7093
7127
  `),
@@ -7284,8 +7318,8 @@ class MarkdownScraper {
7284
7318
  knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
7285
7319
  // Note: These are just default values, they will be overwritten by the actual values:
7286
7320
  let name = `piece-${i}`;
7287
- let title = spaceTrim(knowledgeTextPiece.substring(0, 100));
7288
- const knowledgePieceContent = spaceTrim(knowledgeTextPiece);
7321
+ let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
7322
+ const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
7289
7323
  let keywords = [];
7290
7324
  const index = [];
7291
7325
  /*
@@ -7298,7 +7332,7 @@ class MarkdownScraper {
7298
7332
  isCrashedOnError: true,
7299
7333
  });
7300
7334
  const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
7301
- title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
7335
+ title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
7302
7336
  name = titleToName(title);
7303
7337
  // --- Keywords
7304
7338
  const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
@@ -7395,7 +7429,7 @@ const _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownSc
7395
7429
  * @public exported from `@promptbook/markdown-utils`
7396
7430
  */
7397
7431
  function removeMarkdownComments(content) {
7398
- return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
7432
+ return spaceTrim$2(content.replace(/<!--(.*?)-->/gs, ''));
7399
7433
  }
7400
7434
 
7401
7435
  /**
@@ -7408,7 +7442,7 @@ function addAutoGeneratedSection(content, options) {
7408
7442
  const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
7409
7443
  const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
7410
7444
  const sectionMatch = content.match(sectionRegex);
7411
- const contentToInsert = spaceTrim$1((block) => `
7445
+ const contentToInsert = spaceTrim$2((block) => `
7412
7446
  <!--${sectionName}-->
7413
7447
  ${block(warningLine)}
7414
7448
  ${block(sectionContent)}
@@ -7421,7 +7455,7 @@ function addAutoGeneratedSection(content, options) {
7421
7455
  const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
7422
7456
  if (placeForSection !== null) {
7423
7457
  const [heading] = placeForSection;
7424
- return content.replace(heading, spaceTrim$1((block) => `
7458
+ return content.replace(heading, spaceTrim$2((block) => `
7425
7459
  ${block(contentToInsert)}
7426
7460
 
7427
7461
  ${block(heading)}
@@ -7430,7 +7464,7 @@ function addAutoGeneratedSection(content, options) {
7430
7464
  console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
7431
7465
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7432
7466
  // <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
7433
- return spaceTrim$1((block) => `
7467
+ return spaceTrim$2((block) => `
7434
7468
  ${block(content)}
7435
7469
 
7436
7470
  ${block(contentToInsert)}
@@ -7551,7 +7585,7 @@ function parseMarkdownSection(value) {
7551
7585
  }
7552
7586
  const title = lines[0].replace(/^#+\s*/, '');
7553
7587
  const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
7554
- const content = spaceTrim(lines.slice(1).join('\n'));
7588
+ const content = spaceTrim$1(lines.slice(1).join('\n'));
7555
7589
  if (level < 1 || level > 6) {
7556
7590
  throw new ParseError('Markdown section must have heading level between 1 and 6');
7557
7591
  }
@@ -7579,7 +7613,7 @@ function splitMarkdownIntoSections(markdown) {
7579
7613
  if (buffer.length === 0) {
7580
7614
  return;
7581
7615
  }
7582
- let section = spaceTrim(buffer.join('\n'));
7616
+ let section = spaceTrim$1(buffer.join('\n'));
7583
7617
  if (section === '') {
7584
7618
  return;
7585
7619
  }
@@ -7654,7 +7688,7 @@ function flattenMarkdown(markdown) {
7654
7688
  flattenedMarkdown += `## ${title}` + `\n\n`;
7655
7689
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
7656
7690
  }
7657
- return spaceTrim(flattenedMarkdown);
7691
+ return spaceTrim$1(flattenedMarkdown);
7658
7692
  }
7659
7693
  /**
7660
7694
  * TODO: [🏛] This can be part of markdown builder
@@ -7845,13 +7879,13 @@ function removeMarkdownLinks(str) {
7845
7879
  * @public exported from `@promptbook/markdown-utils`
7846
7880
  */
7847
7881
  function trimCodeBlock(value) {
7848
- value = spaceTrim$1(value);
7882
+ value = spaceTrim$2(value);
7849
7883
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
7850
7884
  return value;
7851
7885
  }
7852
7886
  value = value.replace(/^```[a-z]*/i, '');
7853
7887
  value = value.replace(/```$/i, '');
7854
- value = spaceTrim$1(value);
7888
+ value = spaceTrim$2(value);
7855
7889
  return value;
7856
7890
  }
7857
7891
 
@@ -7864,9 +7898,9 @@ function trimCodeBlock(value) {
7864
7898
  * @public exported from `@promptbook/markdown-utils`
7865
7899
  */
7866
7900
  function trimEndOfCodeBlock(value) {
7867
- value = spaceTrim$1(value);
7901
+ value = spaceTrim$2(value);
7868
7902
  value = value.replace(/```$/g, '');
7869
- value = spaceTrim$1(value);
7903
+ value = spaceTrim$2(value);
7870
7904
  return value;
7871
7905
  }
7872
7906