@promptbook/remote-server 0.103.0-55 โ†’ 0.103.0-56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('child_process'), require('colors'), require('spacetrim'), require('waitasecond'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('crypto'), require('fs/promises'), require('rxjs'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse'), require('react'), require('react-dom/server')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'path', 'child_process', 'colors', 'spacetrim', 'waitasecond', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', 'crypto', 'fs/promises', 'rxjs', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse', 'react', 'react-dom/server'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.path, global.child_process, global.colors, global.spaceTrim, global.waitasecond, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.crypto, global.promises, global.rxjs, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse, global.react, global.server));
5
- })(this, (function (exports, path, child_process, colors, spaceTrim, waitasecond, express, OpenApiValidator, http, socket_io, swaggerUi, crypto, promises, rxjs, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse, react, server) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.path, global.child_process, global.colors, global.spaceTrim$1, global.waitasecond, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.crypto, global.promises, global.rxjs, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse, global.react, global.server));
5
+ })(this, (function (exports, path, child_process, colors, spaceTrim$1, waitasecond, express, OpenApiValidator, http, socket_io, swaggerUi, crypto, promises, rxjs, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse, react, server) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,7 +25,7 @@
25
25
  }
26
26
 
27
27
  var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
28
- var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
28
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
29
29
  var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
30
30
  var OpenApiValidator__namespace = /*#__PURE__*/_interopNamespace(OpenApiValidator);
31
31
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
@@ -47,12 +47,23 @@
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
54
54
  */
55
55
 
56
+ /**
57
+ * Trims string from all 4 sides
58
+ *
59
+ * Note: This is a re-exported function from the `spacetrim` package which is
60
+ * Developed by same author @hejny as this package
61
+ *
62
+ * @public exported from `@promptbook/utils`
63
+ * @see https://github.com/hejny/spacetrim#usage
64
+ */
65
+ const spaceTrim = spaceTrim$1.spaceTrim;
66
+
56
67
  /**
57
68
  * @private util of `@promptbook/color`
58
69
  * @de
@@ -101,6 +112,7 @@
101
112
  * @public exported from `@promptbook/color`
102
113
  */
103
114
  const CSS_COLORS = {
115
+ promptbook: '#79EAFD',
104
116
  transparent: 'rgba(0,0,0,0)',
105
117
  aliceblue: '#f0f8ff',
106
118
  antiquewhite: '#faebd7',
@@ -316,6 +328,28 @@
316
328
  throw new Error(`Can not create color from given object`);
317
329
  }
318
330
  }
331
+ /**
332
+ * Creates a new Color instance from miscellaneous formats
333
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
334
+ *
335
+ * @param color
336
+ * @returns Color object
337
+ */
338
+ static fromSafe(color) {
339
+ try {
340
+ return Color.from(color);
341
+ }
342
+ catch (error) {
343
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
344
+ console.warn(spaceTrim((block) => `
345
+ Color.fromSafe error:
346
+ ${block(error.message)}
347
+
348
+ Returning default PROMPTBOOK_COLOR.
349
+ `));
350
+ return Color.fromString('promptbook');
351
+ }
352
+ }
319
353
  /**
320
354
  * Creates a new Color instance from miscellaneous string formats
321
355
  *
@@ -933,7 +967,7 @@
933
967
  *
934
968
  * @public exported from `@promptbook/core`
935
969
  */
936
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
970
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
937
971
  // <- TODO: [๐Ÿง ][๐Ÿˆต] Using `Color` here increases the package size approx 3kb, maybe remove it
938
972
  /**
939
973
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1280,11 +1314,11 @@
1280
1314
  console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
1281
1315
  // <- TODO: [๐Ÿฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1282
1316
  }
1283
- resolve(spaceTrim.spaceTrim(output.join('\n')));
1317
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1284
1318
  }
1285
1319
  }
1286
1320
  else {
1287
- resolve(spaceTrim.spaceTrim(output.join('\n')));
1321
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1288
1322
  }
1289
1323
  };
1290
1324
  commandProcess.on('close', finishWithCode);
@@ -1302,7 +1336,7 @@
1302
1336
  console.warn(error);
1303
1337
  // <- TODO: [๐Ÿฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1304
1338
  }
1305
- resolve(spaceTrim.spaceTrim(output.join('\n')));
1339
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1306
1340
  }
1307
1341
  });
1308
1342
  }
@@ -1396,7 +1430,7 @@
1396
1430
  */
1397
1431
  class UnexpectedError extends Error {
1398
1432
  constructor(message) {
1399
- super(spaceTrim.spaceTrim((block) => `
1433
+ super(spaceTrim$1.spaceTrim((block) => `
1400
1434
  ${block(message)}
1401
1435
 
1402
1436
  Note: This error should not happen.
@@ -1422,7 +1456,7 @@
1422
1456
  constructor(whatWasThrown) {
1423
1457
  const tag = `[๐Ÿคฎ]`;
1424
1458
  console.error(tag, whatWasThrown);
1425
- super(spaceTrim.spaceTrim(`
1459
+ super(spaceTrim$1.spaceTrim(`
1426
1460
  Non-Error object was thrown
1427
1461
 
1428
1462
  Note: Look for ${tag} in the console for more details
@@ -1618,7 +1652,7 @@
1618
1652
  */
1619
1653
  class MissingToolsError extends Error {
1620
1654
  constructor(message) {
1621
- super(spaceTrim.spaceTrim((block) => `
1655
+ super(spaceTrim$1.spaceTrim((block) => `
1622
1656
  ${block(message)}
1623
1657
 
1624
1658
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -1662,7 +1696,7 @@
1662
1696
  */
1663
1697
  class NotYetImplementedError extends Error {
1664
1698
  constructor(message) {
1665
- super(spaceTrim.spaceTrim((block) => `
1699
+ super(spaceTrim$1.spaceTrim((block) => `
1666
1700
  ${block(message)}
1667
1701
 
1668
1702
  Note: This feature is not implemented yet but it will be soon.
@@ -2495,7 +2529,7 @@
2495
2529
  if (!(error instanceof PipelineLogicError)) {
2496
2530
  throw error;
2497
2531
  }
2498
- console.error(spaceTrim.spaceTrim((block) => `
2532
+ console.error(spaceTrim$1.spaceTrim((block) => `
2499
2533
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2500
2534
 
2501
2535
  ${block(error.message)}
@@ -2522,7 +2556,7 @@
2522
2556
  })();
2523
2557
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2524
2558
  // <- Note: [๐Ÿšฒ]
2525
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2559
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2526
2560
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2527
2561
 
2528
2562
  ${block(pipelineIdentification)}
@@ -2530,7 +2564,7 @@
2530
2564
  }
2531
2565
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2532
2566
  // <- Note: [๐Ÿšฒ]
2533
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2567
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2534
2568
  Invalid Promptbook Version "${pipeline.bookVersion}"
2535
2569
 
2536
2570
  ${block(pipelineIdentification)}
@@ -2539,7 +2573,7 @@
2539
2573
  // TODO: [๐Ÿง ] Maybe do here some proper JSON-schema / ZOD checking
2540
2574
  if (!Array.isArray(pipeline.parameters)) {
2541
2575
  // TODO: [๐Ÿง ] what is the correct error tp throw - maybe PromptbookSchemaError
2542
- throw new ParseError(spaceTrim.spaceTrim((block) => `
2576
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
2543
2577
  Pipeline is valid JSON but with wrong structure
2544
2578
 
2545
2579
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2550,7 +2584,7 @@
2550
2584
  // TODO: [๐Ÿง ] Maybe do here some proper JSON-schema / ZOD checking
2551
2585
  if (!Array.isArray(pipeline.tasks)) {
2552
2586
  // TODO: [๐Ÿง ] what is the correct error tp throw - maybe PromptbookSchemaError
2553
- throw new ParseError(spaceTrim.spaceTrim((block) => `
2587
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
2554
2588
  Pipeline is valid JSON but with wrong structure
2555
2589
 
2556
2590
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2576,7 +2610,7 @@
2576
2610
  // Note: Check each parameter individually
2577
2611
  for (const parameter of pipeline.parameters) {
2578
2612
  if (parameter.isInput && parameter.isOutput) {
2579
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2613
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2580
2614
 
2581
2615
  Parameter \`{${parameter.name}}\` can not be both input and output
2582
2616
 
@@ -2587,7 +2621,7 @@
2587
2621
  if (!parameter.isInput &&
2588
2622
  !parameter.isOutput &&
2589
2623
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2590
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2624
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2591
2625
  Parameter \`{${parameter.name}}\` is created but not used
2592
2626
 
2593
2627
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2599,7 +2633,7 @@
2599
2633
  }
2600
2634
  // Note: Testing that parameter is either input or result of some task
2601
2635
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2602
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2636
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2603
2637
  Parameter \`{${parameter.name}}\` is declared but not defined
2604
2638
 
2605
2639
  You can do one of these:
@@ -2615,14 +2649,14 @@
2615
2649
  // Note: Checking each task individually
2616
2650
  for (const task of pipeline.tasks) {
2617
2651
  if (definedParameters.has(task.resultingParameterName)) {
2618
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2652
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2619
2653
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2620
2654
 
2621
2655
  ${block(pipelineIdentification)}
2622
2656
  `));
2623
2657
  }
2624
2658
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2625
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2659
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2626
2660
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2627
2661
 
2628
2662
  ${block(pipelineIdentification)}
@@ -2632,7 +2666,7 @@
2632
2666
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2633
2667
  if (!task.format &&
2634
2668
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2635
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2669
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2636
2670
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2637
2671
 
2638
2672
  ${block(pipelineIdentification)}
@@ -2640,7 +2674,7 @@
2640
2674
  }
2641
2675
  for (const joker of task.jokerParameterNames) {
2642
2676
  if (!task.dependentParameterNames.includes(joker)) {
2643
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2677
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2644
2678
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2645
2679
 
2646
2680
  ${block(pipelineIdentification)}
@@ -2651,21 +2685,21 @@
2651
2685
  if (task.expectations) {
2652
2686
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2653
2687
  if (min !== undefined && max !== undefined && min > max) {
2654
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2688
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2655
2689
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2656
2690
 
2657
2691
  ${block(pipelineIdentification)}
2658
2692
  `));
2659
2693
  }
2660
2694
  if (min !== undefined && min < 0) {
2661
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2695
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2662
2696
  Min expectation of ${unit} must be zero or positive
2663
2697
 
2664
2698
  ${block(pipelineIdentification)}
2665
2699
  `));
2666
2700
  }
2667
2701
  if (max !== undefined && max <= 0) {
2668
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2702
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2669
2703
  Max expectation of ${unit} must be positive
2670
2704
 
2671
2705
  ${block(pipelineIdentification)}
@@ -2687,7 +2721,7 @@
2687
2721
  while (unresovedTasks.length > 0) {
2688
2722
  if (loopLimit-- < 0) {
2689
2723
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2690
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
2724
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
2691
2725
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2692
2726
 
2693
2727
  ${block(pipelineIdentification)}
@@ -2697,7 +2731,7 @@
2697
2731
  if (currentlyResovedTasks.length === 0) {
2698
2732
  throw new PipelineLogicError(
2699
2733
  // TODO: [๐ŸŽ] DRY
2700
- spaceTrim.spaceTrim((block) => `
2734
+ spaceTrim$1.spaceTrim((block) => `
2701
2735
 
2702
2736
  Can not resolve some parameters:
2703
2737
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2938,11 +2972,11 @@
2938
2972
  throw deserializeError(errors[0]);
2939
2973
  }
2940
2974
  else {
2941
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
2975
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
2942
2976
  Multiple errors occurred during Promptbook execution
2943
2977
 
2944
2978
  ${block(errors
2945
- .map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
2979
+ .map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
2946
2980
  ${name} ${index + 1}:
2947
2981
  ${block(stack || message)}
2948
2982
  `))
@@ -3559,7 +3593,7 @@
3559
3593
  for (const pipeline of pipelines) {
3560
3594
  // TODO: [๐Ÿ‘ ] DRY
3561
3595
  if (pipeline.pipelineUrl === undefined) {
3562
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
3596
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
3563
3597
  Pipeline with name "${pipeline.title}" does not have defined URL
3564
3598
 
3565
3599
  File:
@@ -3581,7 +3615,7 @@
3581
3615
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3582
3616
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3583
3617
  const existing = this.collection.get(pipeline.pipelineUrl);
3584
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
3618
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
3585
3619
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection ๐ŸŽ
3586
3620
 
3587
3621
  Conflicting files:
@@ -3613,13 +3647,13 @@
3613
3647
  const pipeline = this.collection.get(url);
3614
3648
  if (!pipeline) {
3615
3649
  if (this.listPipelines().length === 0) {
3616
- throw new NotFoundError(spaceTrim.spaceTrim(`
3650
+ throw new NotFoundError(spaceTrim$1.spaceTrim(`
3617
3651
  Pipeline with url "${url}" not found
3618
3652
 
3619
3653
  No pipelines available
3620
3654
  `));
3621
3655
  }
3622
- throw new NotFoundError(spaceTrim.spaceTrim((block) => `
3656
+ throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
3623
3657
  Pipeline with url "${url}" not found
3624
3658
 
3625
3659
  Available pipelines:
@@ -5173,7 +5207,7 @@
5173
5207
  if (task.taskType === 'PROMPT_TASK' &&
5174
5208
  knowledgePiecesCount > 0 &&
5175
5209
  !dependentParameterNames.includes('knowledge')) {
5176
- preparedContent = spaceTrim.spaceTrim(`
5210
+ preparedContent = spaceTrim$1.spaceTrim(`
5177
5211
  {content}
5178
5212
 
5179
5213
  ## Knowledge
@@ -5486,7 +5520,7 @@
5486
5520
  }
5487
5521
  catch (error) {
5488
5522
  assertsError(error);
5489
- throw new ParseError(spaceTrim.spaceTrim((block) => `
5523
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
5490
5524
  Can not extract variables from the script
5491
5525
  ${block(error.stack || error.message)}
5492
5526
 
@@ -6340,7 +6374,7 @@
6340
6374
  }
6341
6375
  catch (error) {
6342
6376
  keepUnused(error);
6343
- throw new ExpectError(spaceTrim.spaceTrim((block) => `
6377
+ throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
6344
6378
  Expected valid JSON string
6345
6379
 
6346
6380
  The expected JSON text:
@@ -6403,7 +6437,7 @@
6403
6437
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
6404
6438
  // TODO: [๐Ÿง ][๐Ÿญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
6405
6439
  if (isJokerAttempt && !jokerParameterName) {
6406
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
6440
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6407
6441
  Joker not found in attempt ${attemptIndex}
6408
6442
 
6409
6443
  ${block(pipelineIdentification)}
@@ -6414,7 +6448,7 @@
6414
6448
  $ongoingTaskResult.$expectError = null;
6415
6449
  if (isJokerAttempt) {
6416
6450
  if (parameters[jokerParameterName] === undefined) {
6417
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6451
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6418
6452
  Joker parameter {${jokerParameterName}} not defined
6419
6453
 
6420
6454
  ${block(pipelineIdentification)}
@@ -6472,7 +6506,7 @@
6472
6506
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6473
6507
  break variant;
6474
6508
  case 'EMBEDDING':
6475
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6509
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6476
6510
  Embedding model can not be used in pipeline
6477
6511
 
6478
6512
  This should be catched during parsing
@@ -6483,7 +6517,7 @@
6483
6517
  break variant;
6484
6518
  // <- case [๐Ÿค–]:
6485
6519
  default:
6486
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6520
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6487
6521
  Unknown model variant "${task.modelRequirements.modelVariant}"
6488
6522
 
6489
6523
  ${block(pipelineIdentification)}
@@ -6494,14 +6528,14 @@
6494
6528
  break;
6495
6529
  case 'SCRIPT_TASK':
6496
6530
  if (arrayableToArray(tools.script).length === 0) {
6497
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6531
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6498
6532
  No script execution tools are available
6499
6533
 
6500
6534
  ${block(pipelineIdentification)}
6501
6535
  `));
6502
6536
  }
6503
6537
  if (!task.contentLanguage) {
6504
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6538
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6505
6539
  Script language is not defined for SCRIPT TASK "${task.name}"
6506
6540
 
6507
6541
  ${block(pipelineIdentification)}
@@ -6532,7 +6566,7 @@
6532
6566
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6533
6567
  }
6534
6568
  else {
6535
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6569
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6536
6570
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6537
6571
 
6538
6572
  ${block(pipelineIdentification)}
@@ -6546,7 +6580,7 @@
6546
6580
  break taskType;
6547
6581
  case 'DIALOG_TASK':
6548
6582
  if (tools.userInterface === undefined) {
6549
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6583
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6550
6584
  User interface tools are not available
6551
6585
 
6552
6586
  ${block(pipelineIdentification)}
@@ -6564,7 +6598,7 @@
6564
6598
  break taskType;
6565
6599
  // <- case: [๐Ÿ…ฑ]
6566
6600
  default:
6567
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6601
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6568
6602
  Unknown execution type "${task.taskType}"
6569
6603
 
6570
6604
  ${block(pipelineIdentification)}
@@ -6662,7 +6696,7 @@
6662
6696
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6663
6697
  // Note: Create a summary of all failures
6664
6698
  const failuresSummary = $ongoingTaskResult.$failedResults
6665
- .map((failure) => spaceTrim.spaceTrim((block) => {
6699
+ .map((failure) => spaceTrim$1.spaceTrim((block) => {
6666
6700
  var _a, _b;
6667
6701
  return `
6668
6702
  Attempt ${failure.attemptIndex + 1}:
@@ -6672,14 +6706,14 @@
6672
6706
  Result:
6673
6707
  ${block(failure.result === null
6674
6708
  ? 'null'
6675
- : spaceTrim.spaceTrim(failure.result)
6709
+ : spaceTrim$1.spaceTrim(failure.result)
6676
6710
  .split('\n')
6677
6711
  .map((line) => `> ${line}`)
6678
6712
  .join('\n'))}
6679
6713
  `;
6680
6714
  }))
6681
6715
  .join('\n\n---\n\n');
6682
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
6716
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
6683
6717
  var _a;
6684
6718
  return `
6685
6719
  LLM execution failed ${maxExecutionAttempts}x
@@ -6699,7 +6733,7 @@
6699
6733
  }
6700
6734
  }
6701
6735
  if ($ongoingTaskResult.$resultString === null) {
6702
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
6736
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6703
6737
  Something went wrong and prompt result is null
6704
6738
 
6705
6739
  ${block(pipelineIdentification)}
@@ -7005,7 +7039,7 @@
7005
7039
  // Note: Doublecheck that ALL reserved parameters are defined:
7006
7040
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
7007
7041
  if (reservedParameters[parameterName] === undefined) {
7008
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7042
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7009
7043
  Reserved parameter {${parameterName}} is not defined
7010
7044
 
7011
7045
  ${block(pipelineIdentification)}
@@ -7031,7 +7065,7 @@
7031
7065
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
7032
7066
  // TODO: [๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿป] Use here `mapAvailableToExpectedParameters`
7033
7067
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
7034
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7068
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7035
7069
  Dependent parameters are not consistent with used parameters:
7036
7070
 
7037
7071
  Dependent parameters:
@@ -7075,7 +7109,7 @@
7075
7109
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
7076
7110
  // Houston, we have a problem
7077
7111
  // Note: Checking part is also done in `validatePipeline`, but itโ€™s good to doublecheck
7078
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7112
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7079
7113
  Parameter \`{${parameterName}}\` is NOT defined
7080
7114
  BUT used in task "${currentTask.title || currentTask.name}"
7081
7115
 
@@ -7144,7 +7178,7 @@
7144
7178
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
7145
7179
  if (parametersToPass[parameter.name] === undefined) {
7146
7180
  // [4]
7147
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7181
+ $warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7148
7182
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
7149
7183
 
7150
7184
  Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
@@ -7252,7 +7286,7 @@
7252
7286
  for (const parameterName of Object.keys(inputParameters)) {
7253
7287
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
7254
7288
  if (parameter === undefined) {
7255
- warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7289
+ warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7256
7290
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
7257
7291
 
7258
7292
  ${block(pipelineIdentification)}
@@ -7267,7 +7301,7 @@
7267
7301
  // TODO: [๐Ÿง ] This should be also non-critical error
7268
7302
  return exportJson({
7269
7303
  name: 'pipelineExecutorResult',
7270
- message: spaceTrim.spaceTrim((block) => `
7304
+ message: spaceTrim$1.spaceTrim((block) => `
7271
7305
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
7272
7306
 
7273
7307
  ${block(pipelineIdentification)}
@@ -7276,7 +7310,7 @@
7276
7310
  value: {
7277
7311
  isSuccessful: false,
7278
7312
  errors: [
7279
- new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7313
+ new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7280
7314
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
7281
7315
 
7282
7316
  ${block(pipelineIdentification)}
@@ -7303,7 +7337,7 @@
7303
7337
  while (unresovedTasks.length > 0) {
7304
7338
  if (loopLimit-- < 0) {
7305
7339
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
7306
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7340
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7307
7341
  Loop limit reached during resolving parameters pipeline execution
7308
7342
 
7309
7343
  ${block(pipelineIdentification)}
@@ -7313,7 +7347,7 @@
7313
7347
  if (!currentTask && resolving.length === 0) {
7314
7348
  throw new UnexpectedError(
7315
7349
  // TODO: [๐ŸŽ] DRY
7316
- spaceTrim.spaceTrim((block) => `
7350
+ spaceTrim$1.spaceTrim((block) => `
7317
7351
  Can not resolve some parameters:
7318
7352
 
7319
7353
  ${block(pipelineIdentification)}
@@ -7353,7 +7387,7 @@
7353
7387
  tools,
7354
7388
  onProgress(newOngoingResult) {
7355
7389
  if (isReturned) {
7356
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7390
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7357
7391
  Can not call \`onProgress\` after pipeline execution is finished
7358
7392
 
7359
7393
  ${block(pipelineIdentification)}
@@ -7370,7 +7404,7 @@
7370
7404
  },
7371
7405
  logLlmCall,
7372
7406
  $executionReport: executionReport,
7373
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
7407
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
7374
7408
  ${block(pipelineIdentification)}
7375
7409
  Task name: ${currentTask.name}
7376
7410
  Task title: ${currentTask.title}
@@ -7479,7 +7513,7 @@
7479
7513
  preparedPipeline = pipeline;
7480
7514
  }
7481
7515
  else if (isNotPreparedWarningSuppressed !== true) {
7482
- console.warn(spaceTrim.spaceTrim((block) => `
7516
+ console.warn(spaceTrim$1.spaceTrim((block) => `
7483
7517
  Pipeline is not prepared
7484
7518
 
7485
7519
  ${block(pipelineIdentification)}
@@ -7504,7 +7538,7 @@
7504
7538
  tools,
7505
7539
  onProgress,
7506
7540
  logLlmCall,
7507
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
7541
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
7508
7542
  ${block(pipelineIdentification)}
7509
7543
  ${runCount === 1 ? '' : `Run #${runCount}`}
7510
7544
  `),
@@ -8082,7 +8116,7 @@
8082
8116
  let trimmedText = text;
8083
8117
  // Remove leading and trailing spaces and newlines
8084
8118
  if (isTrimmed) {
8085
- trimmedText = spaceTrim.spaceTrim(trimmedText);
8119
+ trimmedText = spaceTrim$1.spaceTrim(trimmedText);
8086
8120
  }
8087
8121
  let processedText = trimmedText;
8088
8122
  if (isIntroduceSentenceRemoved) {
@@ -8091,7 +8125,7 @@
8091
8125
  // Remove the introduce sentence and quotes by replacing it with an empty string
8092
8126
  processedText = processedText.replace(introduceSentenceRegex, '');
8093
8127
  }
8094
- processedText = spaceTrim.spaceTrim(processedText);
8128
+ processedText = spaceTrim$1.spaceTrim(processedText);
8095
8129
  }
8096
8130
  if (processedText.length < 3) {
8097
8131
  return trimmedText;
@@ -8195,13 +8229,13 @@
8195
8229
  * @public exported from `@promptbook/markdown-utils`
8196
8230
  */
8197
8231
  function trimCodeBlock(value) {
8198
- value = spaceTrim.spaceTrim(value);
8232
+ value = spaceTrim$1.spaceTrim(value);
8199
8233
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
8200
8234
  return value;
8201
8235
  }
8202
8236
  value = value.replace(/^```[a-z]*/i, '');
8203
8237
  value = value.replace(/```$/i, '');
8204
- value = spaceTrim.spaceTrim(value);
8238
+ value = spaceTrim$1.spaceTrim(value);
8205
8239
  return value;
8206
8240
  }
8207
8241
 
@@ -8214,9 +8248,9 @@
8214
8248
  * @public exported from `@promptbook/markdown-utils`
8215
8249
  */
8216
8250
  function trimEndOfCodeBlock(value) {
8217
- value = spaceTrim.spaceTrim(value);
8251
+ value = spaceTrim$1.spaceTrim(value);
8218
8252
  value = value.replace(/```$/g, '');
8219
- value = spaceTrim.spaceTrim(value);
8253
+ value = spaceTrim$1.spaceTrim(value);
8220
8254
  return value;
8221
8255
  }
8222
8256
 
@@ -9280,7 +9314,7 @@
9280
9314
  response.type('text/html').send(renderServerIndexHtml(serverInfo));
9281
9315
  }
9282
9316
  else {
9283
- response.type('text/markdown').send(await spaceTrim.spaceTrim(async (block) => `
9317
+ response.type('text/markdown').send(await spaceTrim$1.spaceTrim(async (block) => `
9284
9318
  # Promptbook
9285
9319
 
9286
9320
  > ${block(CLAIM)}