@promptbook/markdown-utils 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 +159 -107
  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 +2 -2
  38. package/umd/index.umd.js +124 -72
  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,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-66';
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',
@@ -420,21 +432,61 @@ class Color {
420
432
  * @param color
421
433
  * @returns Color object
422
434
  */
423
- static from(color) {
424
- if (color instanceof Color) {
435
+ static from(color, _isSingleValue = false) {
436
+ if (color === '') {
437
+ throw new Error(`Can not create color from empty string`);
438
+ }
439
+ else if (color instanceof Color) {
425
440
  return take(color);
426
441
  }
427
442
  else if (Color.isColor(color)) {
428
443
  return take(color);
429
444
  }
430
445
  else if (typeof color === 'string') {
431
- return Color.fromString(color);
446
+ try {
447
+ return Color.fromString(color);
448
+ }
449
+ catch (error) {
450
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
451
+ if (_isSingleValue) {
452
+ throw error;
453
+ }
454
+ const parts = color.split(/[\s+,;|]/);
455
+ if (parts.length > 0) {
456
+ return Color.from(parts[0].trim(), true);
457
+ }
458
+ else {
459
+ throw new Error(`Can not create color from given string "${color}"`);
460
+ }
461
+ }
432
462
  }
433
463
  else {
434
464
  console.error({ color });
435
465
  throw new Error(`Can not create color from given object`);
436
466
  }
437
467
  }
468
+ /**
469
+ * Creates a new Color instance from miscellaneous formats
470
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
471
+ *
472
+ * @param color
473
+ * @returns Color object
474
+ */
475
+ static fromSafe(color) {
476
+ try {
477
+ return Color.from(color);
478
+ }
479
+ catch (error) {
480
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
481
+ console.warn(spaceTrim((block) => `
482
+ Color.fromSafe error:
483
+ ${block(error.message)}
484
+
485
+ Returning default PROMPTBOOK_COLOR.
486
+ `));
487
+ return Color.fromString('promptbook');
488
+ }
489
+ }
438
490
  /**
439
491
  * Creates a new Color instance from miscellaneous string formats
440
492
  *
@@ -1050,7 +1102,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
1050
1102
  *
1051
1103
  * @public exported from `@promptbook/core`
1052
1104
  */
1053
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1105
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1054
1106
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1055
1107
  /**
1056
1108
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1248,7 +1300,7 @@ true);
1248
1300
  function getErrorReportUrl(error) {
1249
1301
  const report = {
1250
1302
  title: `🐜 Error report from ${NAME}`,
1251
- body: spaceTrim((block) => `
1303
+ body: spaceTrim$1((block) => `
1252
1304
 
1253
1305
 
1254
1306
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1291,7 +1343,7 @@ function getErrorReportUrl(error) {
1291
1343
  */
1292
1344
  class UnexpectedError extends Error {
1293
1345
  constructor(message) {
1294
- super(spaceTrim$1((block) => `
1346
+ super(spaceTrim$2((block) => `
1295
1347
  ${block(message)}
1296
1348
 
1297
1349
  Note: This error should not happen.
@@ -1317,7 +1369,7 @@ class WrappedError extends Error {
1317
1369
  constructor(whatWasThrown) {
1318
1370
  const tag = `[🤮]`;
1319
1371
  console.error(tag, whatWasThrown);
1320
- super(spaceTrim$1(`
1372
+ super(spaceTrim$2(`
1321
1373
  Non-Error object was thrown
1322
1374
 
1323
1375
  Note: Look for ${tag} in the console for more details
@@ -1688,7 +1740,7 @@ function pipelineJsonToString(pipelineJson) {
1688
1740
  pipelineString += '\n\n';
1689
1741
  pipelineString += '```' + contentLanguage;
1690
1742
  pipelineString += '\n';
1691
- pipelineString += spaceTrim(content);
1743
+ pipelineString += spaceTrim$1(content);
1692
1744
  // <- TODO: [main] !!3 Escape
1693
1745
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
1694
1746
  pipelineString += '\n';
@@ -1809,7 +1861,7 @@ function checkSerializableAsJson(options) {
1809
1861
  }
1810
1862
  else if (typeof value === 'object') {
1811
1863
  if (value instanceof Date) {
1812
- throw new UnexpectedError(spaceTrim((block) => `
1864
+ throw new UnexpectedError(spaceTrim$1((block) => `
1813
1865
  \`${name}\` is Date
1814
1866
 
1815
1867
  Use \`string_date_iso8601\` instead
@@ -1828,7 +1880,7 @@ function checkSerializableAsJson(options) {
1828
1880
  throw new UnexpectedError(`${name} is RegExp`);
1829
1881
  }
1830
1882
  else if (value instanceof Error) {
1831
- throw new UnexpectedError(spaceTrim((block) => `
1883
+ throw new UnexpectedError(spaceTrim$1((block) => `
1832
1884
  \`${name}\` is unserialized Error
1833
1885
 
1834
1886
  Use function \`serializeError\`
@@ -1851,7 +1903,7 @@ function checkSerializableAsJson(options) {
1851
1903
  }
1852
1904
  catch (error) {
1853
1905
  assertsError(error);
1854
- throw new UnexpectedError(spaceTrim((block) => `
1906
+ throw new UnexpectedError(spaceTrim$1((block) => `
1855
1907
  \`${name}\` is not serializable
1856
1908
 
1857
1909
  ${block(error.stack || error.message)}
@@ -1883,7 +1935,7 @@ function checkSerializableAsJson(options) {
1883
1935
  }
1884
1936
  }
1885
1937
  else {
1886
- throw new UnexpectedError(spaceTrim((block) => `
1938
+ throw new UnexpectedError(spaceTrim$1((block) => `
1887
1939
  \`${name}\` is unknown type
1888
1940
 
1889
1941
  Additional message for \`${name}\`:
@@ -2137,7 +2189,7 @@ function validatePipeline(pipeline) {
2137
2189
  if (!(error instanceof PipelineLogicError)) {
2138
2190
  throw error;
2139
2191
  }
2140
- console.error(spaceTrim$1((block) => `
2192
+ console.error(spaceTrim$2((block) => `
2141
2193
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2142
2194
 
2143
2195
  ${block(error.message)}
@@ -2164,7 +2216,7 @@ function validatePipeline_InnerFunction(pipeline) {
2164
2216
  })();
2165
2217
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2166
2218
  // <- Note: [🚲]
2167
- throw new PipelineLogicError(spaceTrim$1((block) => `
2219
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2168
2220
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2169
2221
 
2170
2222
  ${block(pipelineIdentification)}
@@ -2172,7 +2224,7 @@ function validatePipeline_InnerFunction(pipeline) {
2172
2224
  }
2173
2225
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2174
2226
  // <- Note: [🚲]
2175
- throw new PipelineLogicError(spaceTrim$1((block) => `
2227
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2176
2228
  Invalid Promptbook Version "${pipeline.bookVersion}"
2177
2229
 
2178
2230
  ${block(pipelineIdentification)}
@@ -2181,7 +2233,7 @@ function validatePipeline_InnerFunction(pipeline) {
2181
2233
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2182
2234
  if (!Array.isArray(pipeline.parameters)) {
2183
2235
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2184
- throw new ParseError(spaceTrim$1((block) => `
2236
+ throw new ParseError(spaceTrim$2((block) => `
2185
2237
  Pipeline is valid JSON but with wrong structure
2186
2238
 
2187
2239
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2192,7 +2244,7 @@ function validatePipeline_InnerFunction(pipeline) {
2192
2244
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2193
2245
  if (!Array.isArray(pipeline.tasks)) {
2194
2246
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2195
- throw new ParseError(spaceTrim$1((block) => `
2247
+ throw new ParseError(spaceTrim$2((block) => `
2196
2248
  Pipeline is valid JSON but with wrong structure
2197
2249
 
2198
2250
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2218,7 +2270,7 @@ function validatePipeline_InnerFunction(pipeline) {
2218
2270
  // Note: Check each parameter individually
2219
2271
  for (const parameter of pipeline.parameters) {
2220
2272
  if (parameter.isInput && parameter.isOutput) {
2221
- throw new PipelineLogicError(spaceTrim$1((block) => `
2273
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2222
2274
 
2223
2275
  Parameter \`{${parameter.name}}\` can not be both input and output
2224
2276
 
@@ -2229,7 +2281,7 @@ function validatePipeline_InnerFunction(pipeline) {
2229
2281
  if (!parameter.isInput &&
2230
2282
  !parameter.isOutput &&
2231
2283
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2232
- throw new PipelineLogicError(spaceTrim$1((block) => `
2284
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2233
2285
  Parameter \`{${parameter.name}}\` is created but not used
2234
2286
 
2235
2287
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2241,7 +2293,7 @@ function validatePipeline_InnerFunction(pipeline) {
2241
2293
  }
2242
2294
  // Note: Testing that parameter is either input or result of some task
2243
2295
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2244
- throw new PipelineLogicError(spaceTrim$1((block) => `
2296
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2245
2297
  Parameter \`{${parameter.name}}\` is declared but not defined
2246
2298
 
2247
2299
  You can do one of these:
@@ -2257,14 +2309,14 @@ function validatePipeline_InnerFunction(pipeline) {
2257
2309
  // Note: Checking each task individually
2258
2310
  for (const task of pipeline.tasks) {
2259
2311
  if (definedParameters.has(task.resultingParameterName)) {
2260
- throw new PipelineLogicError(spaceTrim$1((block) => `
2312
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2261
2313
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2262
2314
 
2263
2315
  ${block(pipelineIdentification)}
2264
2316
  `));
2265
2317
  }
2266
2318
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2267
- throw new PipelineLogicError(spaceTrim$1((block) => `
2319
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2268
2320
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2269
2321
 
2270
2322
  ${block(pipelineIdentification)}
@@ -2274,7 +2326,7 @@ function validatePipeline_InnerFunction(pipeline) {
2274
2326
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2275
2327
  if (!task.format &&
2276
2328
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2277
- throw new PipelineLogicError(spaceTrim$1((block) => `
2329
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2278
2330
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2279
2331
 
2280
2332
  ${block(pipelineIdentification)}
@@ -2282,7 +2334,7 @@ function validatePipeline_InnerFunction(pipeline) {
2282
2334
  }
2283
2335
  for (const joker of task.jokerParameterNames) {
2284
2336
  if (!task.dependentParameterNames.includes(joker)) {
2285
- throw new PipelineLogicError(spaceTrim$1((block) => `
2337
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2286
2338
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2287
2339
 
2288
2340
  ${block(pipelineIdentification)}
@@ -2293,21 +2345,21 @@ function validatePipeline_InnerFunction(pipeline) {
2293
2345
  if (task.expectations) {
2294
2346
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2295
2347
  if (min !== undefined && max !== undefined && min > max) {
2296
- throw new PipelineLogicError(spaceTrim$1((block) => `
2348
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2297
2349
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2298
2350
 
2299
2351
  ${block(pipelineIdentification)}
2300
2352
  `));
2301
2353
  }
2302
2354
  if (min !== undefined && min < 0) {
2303
- throw new PipelineLogicError(spaceTrim$1((block) => `
2355
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2304
2356
  Min expectation of ${unit} must be zero or positive
2305
2357
 
2306
2358
  ${block(pipelineIdentification)}
2307
2359
  `));
2308
2360
  }
2309
2361
  if (max !== undefined && max <= 0) {
2310
- throw new PipelineLogicError(spaceTrim$1((block) => `
2362
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2311
2363
  Max expectation of ${unit} must be positive
2312
2364
 
2313
2365
  ${block(pipelineIdentification)}
@@ -2329,7 +2381,7 @@ function validatePipeline_InnerFunction(pipeline) {
2329
2381
  while (unresovedTasks.length > 0) {
2330
2382
  if (loopLimit-- < 0) {
2331
2383
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2332
- throw new UnexpectedError(spaceTrim$1((block) => `
2384
+ throw new UnexpectedError(spaceTrim$2((block) => `
2333
2385
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2334
2386
 
2335
2387
  ${block(pipelineIdentification)}
@@ -2339,7 +2391,7 @@ function validatePipeline_InnerFunction(pipeline) {
2339
2391
  if (currentlyResovedTasks.length === 0) {
2340
2392
  throw new PipelineLogicError(
2341
2393
  // TODO: [🐎] DRY
2342
- spaceTrim$1((block) => `
2394
+ spaceTrim$2((block) => `
2343
2395
 
2344
2396
  Can not resolve some parameters:
2345
2397
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2503,7 +2555,7 @@ class SimplePipelineCollection {
2503
2555
  for (const pipeline of pipelines) {
2504
2556
  // TODO: [👠] DRY
2505
2557
  if (pipeline.pipelineUrl === undefined) {
2506
- throw new PipelineUrlError(spaceTrim$1(`
2558
+ throw new PipelineUrlError(spaceTrim$2(`
2507
2559
  Pipeline with name "${pipeline.title}" does not have defined URL
2508
2560
 
2509
2561
  File:
@@ -2525,7 +2577,7 @@ class SimplePipelineCollection {
2525
2577
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
2526
2578
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
2527
2579
  const existing = this.collection.get(pipeline.pipelineUrl);
2528
- throw new PipelineUrlError(spaceTrim$1(`
2580
+ throw new PipelineUrlError(spaceTrim$2(`
2529
2581
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
2530
2582
 
2531
2583
  Conflicting files:
@@ -2557,13 +2609,13 @@ class SimplePipelineCollection {
2557
2609
  const pipeline = this.collection.get(url);
2558
2610
  if (!pipeline) {
2559
2611
  if (this.listPipelines().length === 0) {
2560
- throw new NotFoundError(spaceTrim$1(`
2612
+ throw new NotFoundError(spaceTrim$2(`
2561
2613
  Pipeline with url "${url}" not found
2562
2614
 
2563
2615
  No pipelines available
2564
2616
  `));
2565
2617
  }
2566
- throw new NotFoundError(spaceTrim$1((block) => `
2618
+ throw new NotFoundError(spaceTrim$2((block) => `
2567
2619
  Pipeline with url "${url}" not found
2568
2620
 
2569
2621
  Available pipelines:
@@ -2604,7 +2656,7 @@ function createPipelineCollectionFromJson(...promptbooks) {
2604
2656
  */
2605
2657
  class MissingToolsError extends Error {
2606
2658
  constructor(message) {
2607
- super(spaceTrim$1((block) => `
2659
+ super(spaceTrim$2((block) => `
2608
2660
  ${block(message)}
2609
2661
 
2610
2662
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -2838,7 +2890,7 @@ class NotAllowed extends Error {
2838
2890
  */
2839
2891
  class NotYetImplementedError extends Error {
2840
2892
  constructor(message) {
2841
- super(spaceTrim$1((block) => `
2893
+ super(spaceTrim$2((block) => `
2842
2894
  ${block(message)}
2843
2895
 
2844
2896
  Note: This feature is not implemented yet but it will be soon.
@@ -2940,7 +2992,7 @@ function serializeError(error) {
2940
2992
  const { name, message, stack } = error;
2941
2993
  const { id } = error;
2942
2994
  if (!Object.keys(ALL_ERRORS).includes(name)) {
2943
- console.error(spaceTrim((block) => `
2995
+ console.error(spaceTrim$1((block) => `
2944
2996
 
2945
2997
  Cannot serialize error with name "${name}"
2946
2998
 
@@ -2973,7 +3025,7 @@ function jsonParse(value) {
2973
3025
  }
2974
3026
  else if (typeof value !== 'string') {
2975
3027
  console.error('Can not parse JSON from non-string value.', { text: value });
2976
- throw new Error(spaceTrim(`
3028
+ throw new Error(spaceTrim$1(`
2977
3029
  Can not parse JSON from non-string value.
2978
3030
 
2979
3031
  The value type: ${typeof value}
@@ -2987,7 +3039,7 @@ function jsonParse(value) {
2987
3039
  if (!(error instanceof Error)) {
2988
3040
  throw error;
2989
3041
  }
2990
- throw new Error(spaceTrim((block) => `
3042
+ throw new Error(spaceTrim$1((block) => `
2991
3043
  ${block(error.message)}
2992
3044
 
2993
3045
  The expected JSON text:
@@ -3040,7 +3092,7 @@ function deserializeError(error) {
3040
3092
  message = `${name}: ${message}`;
3041
3093
  }
3042
3094
  if (stack !== undefined && stack !== '') {
3043
- message = spaceTrim((block) => `
3095
+ message = spaceTrim$1((block) => `
3044
3096
  ${block(message)}
3045
3097
 
3046
3098
  Original stack trace:
@@ -3077,11 +3129,11 @@ function assertsTaskSuccessful(executionResult) {
3077
3129
  throw deserializeError(errors[0]);
3078
3130
  }
3079
3131
  else {
3080
- throw new PipelineExecutionError(spaceTrim$1((block) => `
3132
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
3081
3133
  Multiple errors occurred during Promptbook execution
3082
3134
 
3083
3135
  ${block(errors
3084
- .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
3136
+ .map(({ name, stack, message }, index) => spaceTrim$2((block) => `
3085
3137
  ${name} ${index + 1}:
3086
3138
  ${block(stack || message)}
3087
3139
  `))
@@ -3552,14 +3604,14 @@ class MultipleLlmExecutionTools {
3552
3604
  if (description === undefined) {
3553
3605
  return headLine;
3554
3606
  }
3555
- return spaceTrim((block) => `
3607
+ return spaceTrim$1((block) => `
3556
3608
  ${headLine}
3557
3609
 
3558
3610
  ${ /* <- Note: Indenting the description: */block(description)}
3559
3611
  `);
3560
3612
  })
3561
3613
  .join('\n\n');
3562
- return spaceTrim((block) => `
3614
+ return spaceTrim$1((block) => `
3563
3615
  Multiple LLM Providers:
3564
3616
 
3565
3617
  ${block(innerModelsTitlesAndDescriptions)}
@@ -3650,7 +3702,7 @@ class MultipleLlmExecutionTools {
3650
3702
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3651
3703
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3652
3704
  // 3) ...
3653
- spaceTrim((block) => `
3705
+ spaceTrim$1((block) => `
3654
3706
  All execution tools of ${this.title} failed:
3655
3707
 
3656
3708
  ${block(errors
@@ -3663,7 +3715,7 @@ class MultipleLlmExecutionTools {
3663
3715
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
3664
3716
  }
3665
3717
  else {
3666
- throw new PipelineExecutionError(spaceTrim((block) => `
3718
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
3667
3719
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
3668
3720
 
3669
3721
  Available \`LlmExecutionTools\`:
@@ -3696,7 +3748,7 @@ class MultipleLlmExecutionTools {
3696
3748
  */
3697
3749
  function joinLlmExecutionTools(title, ...llmExecutionTools) {
3698
3750
  if (llmExecutionTools.length === 0) {
3699
- const warningMessage = spaceTrim(`
3751
+ const warningMessage = spaceTrim$1(`
3700
3752
  You have not provided any \`LlmExecutionTools\`
3701
3753
  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
3754
 
@@ -4013,14 +4065,14 @@ function $registeredScrapersMessage(availableScrapers) {
4013
4065
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
4014
4066
  });
4015
4067
  if (metadata.length === 0) {
4016
- return spaceTrim(`
4068
+ return spaceTrim$1(`
4017
4069
  **No scrapers are available**
4018
4070
 
4019
4071
  This is a unexpected behavior, you are probably using some broken version of Promptbook
4020
4072
  At least there should be available the metadata of the scrapers
4021
4073
  `);
4022
4074
  }
4023
- return spaceTrim((block) => `
4075
+ return spaceTrim$1((block) => `
4024
4076
  Available scrapers are:
4025
4077
  ${block(metadata
4026
4078
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -4526,7 +4578,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
4526
4578
  else if (urlOrRequest instanceof Request) {
4527
4579
  url = urlOrRequest.url;
4528
4580
  }
4529
- throw new PromptbookFetchError(spaceTrim((block) => `
4581
+ throw new PromptbookFetchError(spaceTrim$1((block) => `
4530
4582
  Can not fetch "${url}"
4531
4583
 
4532
4584
  Fetch error:
@@ -4687,7 +4739,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4687
4739
  const fileExtension = getFileExtension(filename);
4688
4740
  const mimeType = extensionToMimeType(fileExtension || '');
4689
4741
  if (!(await isFileExisting(filename, tools.fs))) {
4690
- throw new NotFoundError(spaceTrim((block) => `
4742
+ throw new NotFoundError(spaceTrim$1((block) => `
4691
4743
  Can not make source handler for file which does not exist:
4692
4744
 
4693
4745
  File:
@@ -4780,7 +4832,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4780
4832
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
4781
4833
  break;
4782
4834
  }
4783
- console.warn(spaceTrim((block) => `
4835
+ console.warn(spaceTrim$1((block) => `
4784
4836
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
4785
4837
 
4786
4838
  The source:
@@ -4796,7 +4848,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4796
4848
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4797
4849
  }
4798
4850
  if (partialPieces === null) {
4799
- throw new KnowledgeScrapeError(spaceTrim((block) => `
4851
+ throw new KnowledgeScrapeError(spaceTrim$1((block) => `
4800
4852
  Cannot scrape knowledge
4801
4853
 
4802
4854
  The source:
@@ -4875,7 +4927,7 @@ async function prepareTasks(pipeline, tools, options) {
4875
4927
  if (task.taskType === 'PROMPT_TASK' &&
4876
4928
  knowledgePiecesCount > 0 &&
4877
4929
  !dependentParameterNames.includes('knowledge')) {
4878
- preparedContent = spaceTrim$1(`
4930
+ preparedContent = spaceTrim$2(`
4879
4931
  {content}
4880
4932
 
4881
4933
  ## Knowledge
@@ -5188,7 +5240,7 @@ function extractVariablesFromJavascript(script) {
5188
5240
  }
5189
5241
  catch (error) {
5190
5242
  assertsError(error);
5191
- throw new ParseError(spaceTrim$1((block) => `
5243
+ throw new ParseError(spaceTrim$2((block) => `
5192
5244
  Can not extract variables from the script
5193
5245
  ${block(error.stack || error.message)}
5194
5246
 
@@ -5371,7 +5423,7 @@ const CsvFormatParser = {
5371
5423
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
5372
5424
  const csv = csvParse(value, settings);
5373
5425
  if (csv.errors.length !== 0) {
5374
- throw new CsvFormatError(spaceTrim((block) => `
5426
+ throw new CsvFormatError(spaceTrim$1((block) => `
5375
5427
  CSV parsing error
5376
5428
 
5377
5429
  Error(s) from CSV parsing:
@@ -5416,7 +5468,7 @@ const CsvFormatParser = {
5416
5468
  const { value, settings, mapCallback, onProgress } = options;
5417
5469
  const csv = csvParse(value, settings);
5418
5470
  if (csv.errors.length !== 0) {
5419
- throw new CsvFormatError(spaceTrim((block) => `
5471
+ throw new CsvFormatError(spaceTrim$1((block) => `
5420
5472
  CSV parsing error
5421
5473
 
5422
5474
  Error(s) from CSV parsing:
@@ -5626,7 +5678,7 @@ function mapAvailableToExpectedParameters(options) {
5626
5678
  }
5627
5679
  // Phase 2️⃣: Non-matching mapping
5628
5680
  if (expectedParameterNames.size !== availableParametersNames.size) {
5629
- throw new PipelineExecutionError(spaceTrim((block) => `
5681
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
5630
5682
  Can not map available parameters to expected parameters
5631
5683
 
5632
5684
  Mapped parameters:
@@ -5923,7 +5975,7 @@ function validatePromptResult(options) {
5923
5975
  }
5924
5976
  catch (error) {
5925
5977
  keepUnused(error);
5926
- throw new ExpectError(spaceTrim$1((block) => `
5978
+ throw new ExpectError(spaceTrim$2((block) => `
5927
5979
  Expected valid JSON string
5928
5980
 
5929
5981
  The expected JSON text:
@@ -5986,7 +6038,7 @@ async function executeAttempts(options) {
5986
6038
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
5987
6039
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
5988
6040
  if (isJokerAttempt && !jokerParameterName) {
5989
- throw new UnexpectedError(spaceTrim$1((block) => `
6041
+ throw new UnexpectedError(spaceTrim$2((block) => `
5990
6042
  Joker not found in attempt ${attemptIndex}
5991
6043
 
5992
6044
  ${block(pipelineIdentification)}
@@ -5997,7 +6049,7 @@ async function executeAttempts(options) {
5997
6049
  $ongoingTaskResult.$expectError = null;
5998
6050
  if (isJokerAttempt) {
5999
6051
  if (parameters[jokerParameterName] === undefined) {
6000
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6052
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6001
6053
  Joker parameter {${jokerParameterName}} not defined
6002
6054
 
6003
6055
  ${block(pipelineIdentification)}
@@ -6055,7 +6107,7 @@ async function executeAttempts(options) {
6055
6107
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6056
6108
  break variant;
6057
6109
  case 'EMBEDDING':
6058
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6110
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6059
6111
  Embedding model can not be used in pipeline
6060
6112
 
6061
6113
  This should be catched during parsing
@@ -6066,7 +6118,7 @@ async function executeAttempts(options) {
6066
6118
  break variant;
6067
6119
  // <- case [🤖]:
6068
6120
  default:
6069
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6121
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6070
6122
  Unknown model variant "${task.modelRequirements.modelVariant}"
6071
6123
 
6072
6124
  ${block(pipelineIdentification)}
@@ -6077,14 +6129,14 @@ async function executeAttempts(options) {
6077
6129
  break;
6078
6130
  case 'SCRIPT_TASK':
6079
6131
  if (arrayableToArray(tools.script).length === 0) {
6080
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6132
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6081
6133
  No script execution tools are available
6082
6134
 
6083
6135
  ${block(pipelineIdentification)}
6084
6136
  `));
6085
6137
  }
6086
6138
  if (!task.contentLanguage) {
6087
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6139
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6088
6140
  Script language is not defined for SCRIPT TASK "${task.name}"
6089
6141
 
6090
6142
  ${block(pipelineIdentification)}
@@ -6115,7 +6167,7 @@ async function executeAttempts(options) {
6115
6167
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6116
6168
  }
6117
6169
  else {
6118
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6170
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6119
6171
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6120
6172
 
6121
6173
  ${block(pipelineIdentification)}
@@ -6129,7 +6181,7 @@ async function executeAttempts(options) {
6129
6181
  break taskType;
6130
6182
  case 'DIALOG_TASK':
6131
6183
  if (tools.userInterface === undefined) {
6132
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6184
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6133
6185
  User interface tools are not available
6134
6186
 
6135
6187
  ${block(pipelineIdentification)}
@@ -6147,7 +6199,7 @@ async function executeAttempts(options) {
6147
6199
  break taskType;
6148
6200
  // <- case: [🅱]
6149
6201
  default:
6150
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6202
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6151
6203
  Unknown execution type "${task.taskType}"
6152
6204
 
6153
6205
  ${block(pipelineIdentification)}
@@ -6245,7 +6297,7 @@ async function executeAttempts(options) {
6245
6297
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6246
6298
  // Note: Create a summary of all failures
6247
6299
  const failuresSummary = $ongoingTaskResult.$failedResults
6248
- .map((failure) => spaceTrim$1((block) => {
6300
+ .map((failure) => spaceTrim$2((block) => {
6249
6301
  var _a, _b;
6250
6302
  return `
6251
6303
  Attempt ${failure.attemptIndex + 1}:
@@ -6255,14 +6307,14 @@ async function executeAttempts(options) {
6255
6307
  Result:
6256
6308
  ${block(failure.result === null
6257
6309
  ? 'null'
6258
- : spaceTrim$1(failure.result)
6310
+ : spaceTrim$2(failure.result)
6259
6311
  .split('\n')
6260
6312
  .map((line) => `> ${line}`)
6261
6313
  .join('\n'))}
6262
6314
  `;
6263
6315
  }))
6264
6316
  .join('\n\n---\n\n');
6265
- throw new PipelineExecutionError(spaceTrim$1((block) => {
6317
+ throw new PipelineExecutionError(spaceTrim$2((block) => {
6266
6318
  var _a;
6267
6319
  return `
6268
6320
  LLM execution failed ${maxExecutionAttempts}x
@@ -6282,7 +6334,7 @@ async function executeAttempts(options) {
6282
6334
  }
6283
6335
  }
6284
6336
  if ($ongoingTaskResult.$resultString === null) {
6285
- throw new UnexpectedError(spaceTrim$1((block) => `
6337
+ throw new UnexpectedError(spaceTrim$2((block) => `
6286
6338
  Something went wrong and prompt result is null
6287
6339
 
6288
6340
  ${block(pipelineIdentification)}
@@ -6309,7 +6361,7 @@ async function executeFormatSubvalues(options) {
6309
6361
  return /* not await */ executeAttempts({ ...options, logLlmCall });
6310
6362
  }
6311
6363
  if (jokerParameterNames.length !== 0) {
6312
- throw new UnexpectedError(spaceTrim((block) => `
6364
+ throw new UnexpectedError(spaceTrim$1((block) => `
6313
6365
  JOKER parameters are not supported together with FOREACH command
6314
6366
 
6315
6367
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6322,7 +6374,7 @@ async function executeFormatSubvalues(options) {
6322
6374
  if (formatDefinition === undefined) {
6323
6375
  throw new UnexpectedError(
6324
6376
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6325
- spaceTrim((block) => `
6377
+ spaceTrim$1((block) => `
6326
6378
  Unsupported format "${task.foreach.formatName}"
6327
6379
 
6328
6380
  Available formats:
@@ -6339,7 +6391,7 @@ async function executeFormatSubvalues(options) {
6339
6391
  if (subvalueParser === undefined) {
6340
6392
  throw new UnexpectedError(
6341
6393
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6342
- spaceTrim((block) => `
6394
+ spaceTrim$1((block) => `
6343
6395
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6344
6396
 
6345
6397
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6379,7 +6431,7 @@ async function executeFormatSubvalues(options) {
6379
6431
  if (!(error instanceof PipelineExecutionError)) {
6380
6432
  throw error;
6381
6433
  }
6382
- const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
6434
+ const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6383
6435
  ${error.message}
6384
6436
 
6385
6437
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6403,7 +6455,7 @@ async function executeFormatSubvalues(options) {
6403
6455
  ...options,
6404
6456
  priority: priority + index,
6405
6457
  parameters: allSubparameters,
6406
- pipelineIdentification: spaceTrim((block) => `
6458
+ pipelineIdentification: spaceTrim$1((block) => `
6407
6459
  ${block(pipelineIdentification)}
6408
6460
  Subparameter index: ${index}
6409
6461
  `),
@@ -6412,7 +6464,7 @@ async function executeFormatSubvalues(options) {
6412
6464
  }
6413
6465
  catch (error) {
6414
6466
  if (length > BIG_DATASET_TRESHOLD) {
6415
- console.error(spaceTrim((block) => `
6467
+ console.error(spaceTrim$1((block) => `
6416
6468
  ${error.message}
6417
6469
 
6418
6470
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6588,7 +6640,7 @@ async function getReservedParametersForTask(options) {
6588
6640
  // Note: Doublecheck that ALL reserved parameters are defined:
6589
6641
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6590
6642
  if (reservedParameters[parameterName] === undefined) {
6591
- throw new UnexpectedError(spaceTrim$1((block) => `
6643
+ throw new UnexpectedError(spaceTrim$2((block) => `
6592
6644
  Reserved parameter {${parameterName}} is not defined
6593
6645
 
6594
6646
  ${block(pipelineIdentification)}
@@ -6614,7 +6666,7 @@ async function executeTask(options) {
6614
6666
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6615
6667
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6616
6668
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6617
- throw new UnexpectedError(spaceTrim$1((block) => `
6669
+ throw new UnexpectedError(spaceTrim$2((block) => `
6618
6670
  Dependent parameters are not consistent with used parameters:
6619
6671
 
6620
6672
  Dependent parameters:
@@ -6658,7 +6710,7 @@ async function executeTask(options) {
6658
6710
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
6659
6711
  // Houston, we have a problem
6660
6712
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
6661
- throw new UnexpectedError(spaceTrim$1((block) => `
6713
+ throw new UnexpectedError(spaceTrim$2((block) => `
6662
6714
  Parameter \`{${parameterName}}\` is NOT defined
6663
6715
  BUT used in task "${currentTask.title || currentTask.name}"
6664
6716
 
@@ -6727,7 +6779,7 @@ function filterJustOutputParameters(options) {
6727
6779
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
6728
6780
  if (parametersToPass[parameter.name] === undefined) {
6729
6781
  // [4]
6730
- $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6782
+ $warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
6731
6783
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
6732
6784
 
6733
6785
  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 +6887,7 @@ async function executePipeline(options) {
6835
6887
  for (const parameterName of Object.keys(inputParameters)) {
6836
6888
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
6837
6889
  if (parameter === undefined) {
6838
- warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6890
+ warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
6839
6891
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
6840
6892
 
6841
6893
  ${block(pipelineIdentification)}
@@ -6850,7 +6902,7 @@ async function executePipeline(options) {
6850
6902
  // TODO: [🧠] This should be also non-critical error
6851
6903
  return exportJson({
6852
6904
  name: 'pipelineExecutorResult',
6853
- message: spaceTrim$1((block) => `
6905
+ message: spaceTrim$2((block) => `
6854
6906
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
6855
6907
 
6856
6908
  ${block(pipelineIdentification)}
@@ -6859,7 +6911,7 @@ async function executePipeline(options) {
6859
6911
  value: {
6860
6912
  isSuccessful: false,
6861
6913
  errors: [
6862
- new PipelineExecutionError(spaceTrim$1((block) => `
6914
+ new PipelineExecutionError(spaceTrim$2((block) => `
6863
6915
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
6864
6916
 
6865
6917
  ${block(pipelineIdentification)}
@@ -6886,7 +6938,7 @@ async function executePipeline(options) {
6886
6938
  while (unresovedTasks.length > 0) {
6887
6939
  if (loopLimit-- < 0) {
6888
6940
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
6889
- throw new UnexpectedError(spaceTrim$1((block) => `
6941
+ throw new UnexpectedError(spaceTrim$2((block) => `
6890
6942
  Loop limit reached during resolving parameters pipeline execution
6891
6943
 
6892
6944
  ${block(pipelineIdentification)}
@@ -6896,7 +6948,7 @@ async function executePipeline(options) {
6896
6948
  if (!currentTask && resolving.length === 0) {
6897
6949
  throw new UnexpectedError(
6898
6950
  // TODO: [🐎] DRY
6899
- spaceTrim$1((block) => `
6951
+ spaceTrim$2((block) => `
6900
6952
  Can not resolve some parameters:
6901
6953
 
6902
6954
  ${block(pipelineIdentification)}
@@ -6936,7 +6988,7 @@ async function executePipeline(options) {
6936
6988
  tools,
6937
6989
  onProgress(newOngoingResult) {
6938
6990
  if (isReturned) {
6939
- throw new UnexpectedError(spaceTrim$1((block) => `
6991
+ throw new UnexpectedError(spaceTrim$2((block) => `
6940
6992
  Can not call \`onProgress\` after pipeline execution is finished
6941
6993
 
6942
6994
  ${block(pipelineIdentification)}
@@ -6953,7 +7005,7 @@ async function executePipeline(options) {
6953
7005
  },
6954
7006
  logLlmCall,
6955
7007
  $executionReport: executionReport,
6956
- pipelineIdentification: spaceTrim$1((block) => `
7008
+ pipelineIdentification: spaceTrim$2((block) => `
6957
7009
  ${block(pipelineIdentification)}
6958
7010
  Task name: ${currentTask.name}
6959
7011
  Task title: ${currentTask.title}
@@ -7062,7 +7114,7 @@ function createPipelineExecutor(options) {
7062
7114
  preparedPipeline = pipeline;
7063
7115
  }
7064
7116
  else if (isNotPreparedWarningSuppressed !== true) {
7065
- console.warn(spaceTrim$1((block) => `
7117
+ console.warn(spaceTrim$2((block) => `
7066
7118
  Pipeline is not prepared
7067
7119
 
7068
7120
  ${block(pipelineIdentification)}
@@ -7087,7 +7139,7 @@ function createPipelineExecutor(options) {
7087
7139
  tools,
7088
7140
  onProgress,
7089
7141
  logLlmCall,
7090
- pipelineIdentification: spaceTrim$1((block) => `
7142
+ pipelineIdentification: spaceTrim$2((block) => `
7091
7143
  ${block(pipelineIdentification)}
7092
7144
  ${runCount === 1 ? '' : `Run #${runCount}`}
7093
7145
  `),
@@ -7284,8 +7336,8 @@ class MarkdownScraper {
7284
7336
  knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
7285
7337
  // Note: These are just default values, they will be overwritten by the actual values:
7286
7338
  let name = `piece-${i}`;
7287
- let title = spaceTrim(knowledgeTextPiece.substring(0, 100));
7288
- const knowledgePieceContent = spaceTrim(knowledgeTextPiece);
7339
+ let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
7340
+ const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
7289
7341
  let keywords = [];
7290
7342
  const index = [];
7291
7343
  /*
@@ -7298,7 +7350,7 @@ class MarkdownScraper {
7298
7350
  isCrashedOnError: true,
7299
7351
  });
7300
7352
  const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
7301
- title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
7353
+ title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
7302
7354
  name = titleToName(title);
7303
7355
  // --- Keywords
7304
7356
  const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
@@ -7395,7 +7447,7 @@ const _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownSc
7395
7447
  * @public exported from `@promptbook/markdown-utils`
7396
7448
  */
7397
7449
  function removeMarkdownComments(content) {
7398
- return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
7450
+ return spaceTrim$2(content.replace(/<!--(.*?)-->/gs, ''));
7399
7451
  }
7400
7452
 
7401
7453
  /**
@@ -7408,7 +7460,7 @@ function addAutoGeneratedSection(content, options) {
7408
7460
  const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
7409
7461
  const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
7410
7462
  const sectionMatch = content.match(sectionRegex);
7411
- const contentToInsert = spaceTrim$1((block) => `
7463
+ const contentToInsert = spaceTrim$2((block) => `
7412
7464
  <!--${sectionName}-->
7413
7465
  ${block(warningLine)}
7414
7466
  ${block(sectionContent)}
@@ -7421,7 +7473,7 @@ function addAutoGeneratedSection(content, options) {
7421
7473
  const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
7422
7474
  if (placeForSection !== null) {
7423
7475
  const [heading] = placeForSection;
7424
- return content.replace(heading, spaceTrim$1((block) => `
7476
+ return content.replace(heading, spaceTrim$2((block) => `
7425
7477
  ${block(contentToInsert)}
7426
7478
 
7427
7479
  ${block(heading)}
@@ -7430,7 +7482,7 @@ function addAutoGeneratedSection(content, options) {
7430
7482
  console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
7431
7483
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7432
7484
  // <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
7433
- return spaceTrim$1((block) => `
7485
+ return spaceTrim$2((block) => `
7434
7486
  ${block(content)}
7435
7487
 
7436
7488
  ${block(contentToInsert)}
@@ -7551,7 +7603,7 @@ function parseMarkdownSection(value) {
7551
7603
  }
7552
7604
  const title = lines[0].replace(/^#+\s*/, '');
7553
7605
  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'));
7606
+ const content = spaceTrim$1(lines.slice(1).join('\n'));
7555
7607
  if (level < 1 || level > 6) {
7556
7608
  throw new ParseError('Markdown section must have heading level between 1 and 6');
7557
7609
  }
@@ -7579,7 +7631,7 @@ function splitMarkdownIntoSections(markdown) {
7579
7631
  if (buffer.length === 0) {
7580
7632
  return;
7581
7633
  }
7582
- let section = spaceTrim(buffer.join('\n'));
7634
+ let section = spaceTrim$1(buffer.join('\n'));
7583
7635
  if (section === '') {
7584
7636
  return;
7585
7637
  }
@@ -7654,7 +7706,7 @@ function flattenMarkdown(markdown) {
7654
7706
  flattenedMarkdown += `## ${title}` + `\n\n`;
7655
7707
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
7656
7708
  }
7657
- return spaceTrim(flattenedMarkdown);
7709
+ return spaceTrim$1(flattenedMarkdown);
7658
7710
  }
7659
7711
  /**
7660
7712
  * TODO: [🏛] This can be part of markdown builder
@@ -7845,13 +7897,13 @@ function removeMarkdownLinks(str) {
7845
7897
  * @public exported from `@promptbook/markdown-utils`
7846
7898
  */
7847
7899
  function trimCodeBlock(value) {
7848
- value = spaceTrim$1(value);
7900
+ value = spaceTrim$2(value);
7849
7901
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
7850
7902
  return value;
7851
7903
  }
7852
7904
  value = value.replace(/^```[a-z]*/i, '');
7853
7905
  value = value.replace(/```$/i, '');
7854
- value = spaceTrim$1(value);
7906
+ value = spaceTrim$2(value);
7855
7907
  return value;
7856
7908
  }
7857
7909
 
@@ -7864,9 +7916,9 @@ function trimCodeBlock(value) {
7864
7916
  * @public exported from `@promptbook/markdown-utils`
7865
7917
  */
7866
7918
  function trimEndOfCodeBlock(value) {
7867
- value = spaceTrim$1(value);
7919
+ value = spaceTrim$2(value);
7868
7920
  value = value.replace(/```$/g, '');
7869
- value = spaceTrim$1(value);
7921
+ value = spaceTrim$2(value);
7870
7922
  return value;
7871
7923
  }
7872
7924