@promptbook/remote-client 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$1, { spaceTrim } from 'spacetrim';
1
+ import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { io } from 'socket.io-client';
4
4
  import { SHA256 } from 'crypto-js';
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -160,7 +160,7 @@ class LimitReachedError extends Error {
160
160
  */
161
161
  class MissingToolsError extends Error {
162
162
  constructor(message) {
163
- super(spaceTrim((block) => `
163
+ super(spaceTrim$1((block) => `
164
164
  ${block(message)}
165
165
 
166
166
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -204,7 +204,7 @@ class NotFoundError extends Error {
204
204
  */
205
205
  class NotYetImplementedError extends Error {
206
206
  constructor(message) {
207
- super(spaceTrim((block) => `
207
+ super(spaceTrim$1((block) => `
208
208
  ${block(message)}
209
209
 
210
210
  Note: This feature is not implemented yet but it will be soon.
@@ -311,6 +311,17 @@ class PromptbookFetchError extends Error {
311
311
  }
312
312
  }
313
313
 
314
+ /**
315
+ * Trims string from all 4 sides
316
+ *
317
+ * Note: This is a re-exported function from the `spacetrim` package which is
318
+ * Developed by same author @hejny as this package
319
+ *
320
+ * @public exported from `@promptbook/utils`
321
+ * @see https://github.com/hejny/spacetrim#usage
322
+ */
323
+ const spaceTrim = spaceTrim$1;
324
+
314
325
  /**
315
326
  * @private util of `@promptbook/color`
316
327
  * @de
@@ -359,6 +370,7 @@ function take(initialValue) {
359
370
  * @public exported from `@promptbook/color`
360
371
  */
361
372
  const CSS_COLORS = {
373
+ promptbook: '#79EAFD',
362
374
  transparent: 'rgba(0,0,0,0)',
363
375
  aliceblue: '#f0f8ff',
364
376
  antiquewhite: '#faebd7',
@@ -574,6 +586,28 @@ class Color {
574
586
  throw new Error(`Can not create color from given object`);
575
587
  }
576
588
  }
589
+ /**
590
+ * Creates a new Color instance from miscellaneous formats
591
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
592
+ *
593
+ * @param color
594
+ * @returns Color object
595
+ */
596
+ static fromSafe(color) {
597
+ try {
598
+ return Color.from(color);
599
+ }
600
+ catch (error) {
601
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
602
+ console.warn(spaceTrim((block) => `
603
+ Color.fromSafe error:
604
+ ${block(error.message)}
605
+
606
+ Returning default PROMPTBOOK_COLOR.
607
+ `));
608
+ return Color.fromString('promptbook');
609
+ }
610
+ }
577
611
  /**
578
612
  * Creates a new Color instance from miscellaneous string formats
579
613
  *
@@ -1183,7 +1217,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
1183
1217
  *
1184
1218
  * @public exported from `@promptbook/core`
1185
1219
  */
1186
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1220
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1187
1221
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1188
1222
  /**
1189
1223
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1288,7 +1322,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1288
1322
  function getErrorReportUrl(error) {
1289
1323
  const report = {
1290
1324
  title: `🐜 Error report from ${NAME}`,
1291
- body: spaceTrim$1((block) => `
1325
+ body: spaceTrim$2((block) => `
1292
1326
 
1293
1327
 
1294
1328
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1331,7 +1365,7 @@ function getErrorReportUrl(error) {
1331
1365
  */
1332
1366
  class UnexpectedError extends Error {
1333
1367
  constructor(message) {
1334
- super(spaceTrim((block) => `
1368
+ super(spaceTrim$1((block) => `
1335
1369
  ${block(message)}
1336
1370
 
1337
1371
  Note: This error should not happen.
@@ -1357,7 +1391,7 @@ class WrappedError extends Error {
1357
1391
  constructor(whatWasThrown) {
1358
1392
  const tag = `[🤮]`;
1359
1393
  console.error(tag, whatWasThrown);
1360
- super(spaceTrim(`
1394
+ super(spaceTrim$1(`
1361
1395
  Non-Error object was thrown
1362
1396
 
1363
1397
  Note: Look for ${tag} in the console for more details
@@ -1446,7 +1480,7 @@ function deserializeError(error) {
1446
1480
  message = `${name}: ${message}`;
1447
1481
  }
1448
1482
  if (stack !== undefined && stack !== '') {
1449
- message = spaceTrim$1((block) => `
1483
+ message = spaceTrim$2((block) => `
1450
1484
  ${block(message)}
1451
1485
 
1452
1486
  Original stack trace:
@@ -1503,7 +1537,7 @@ async function createRemoteClient(options) {
1503
1537
  const remoteServerUrlParsed = new URL(remoteServerUrl);
1504
1538
  if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
1505
1539
  remoteServerUrlParsed.pathname = '/';
1506
- throw new Error(spaceTrim$1((block) => `
1540
+ throw new Error(spaceTrim$2((block) => `
1507
1541
  Remote server requires root url \`/\`
1508
1542
 
1509
1543
  You have provided \`remoteServerUrl\`:
@@ -2039,7 +2073,7 @@ const knowledgeCommandParser = {
2039
2073
  */
2040
2074
  parse(input) {
2041
2075
  const { args } = input;
2042
- const knowledgeSourceContent = spaceTrim$1(args[0] || '');
2076
+ const knowledgeSourceContent = spaceTrim$2(args[0] || '');
2043
2077
  if (knowledgeSourceContent === '') {
2044
2078
  throw new ParseError(`Source is not defined`);
2045
2079
  }
@@ -2183,7 +2217,7 @@ const sectionCommandParser = {
2183
2217
  normalized = normalized.split('DIALOGUE').join('DIALOG');
2184
2218
  const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
2185
2219
  if (taskTypes.length !== 1) {
2186
- throw new ParseError(spaceTrim$1((block) => `
2220
+ throw new ParseError(spaceTrim$2((block) => `
2187
2221
  Unknown section type "${normalized}"
2188
2222
 
2189
2223
  Supported section types are:
@@ -2203,7 +2237,7 @@ const sectionCommandParser = {
2203
2237
  */
2204
2238
  $applyToTaskJson(command, $taskJson, $pipelineJson) {
2205
2239
  if ($taskJson.isSectionTypeSet === true) {
2206
- throw new ParseError(spaceTrim$1(`
2240
+ throw new ParseError(spaceTrim$2(`
2207
2241
  Section type is already defined in the section.
2208
2242
  It can be defined only once.
2209
2243
  `));
@@ -2622,7 +2656,7 @@ const expectCommandParser = {
2622
2656
  /**
2623
2657
  * Description of the FORMAT command
2624
2658
  */
2625
- description: spaceTrim$1(`
2659
+ description: spaceTrim$2(`
2626
2660
  Expect command describes the desired output of the task *(after post-processing)*
2627
2661
  It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
2628
2662
  `),
@@ -2696,7 +2730,7 @@ const expectCommandParser = {
2696
2730
  }
2697
2731
  catch (error) {
2698
2732
  assertsError(error);
2699
- throw new ParseError(spaceTrim$1((block) => `
2733
+ throw new ParseError(spaceTrim$2((block) => `
2700
2734
  Invalid FORMAT command
2701
2735
  ${block(error.message)}:
2702
2736
  `));
@@ -2818,7 +2852,7 @@ const CsvFormatParser = {
2818
2852
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
2819
2853
  const csv = csvParse(value, settings);
2820
2854
  if (csv.errors.length !== 0) {
2821
- throw new CsvFormatError(spaceTrim$1((block) => `
2855
+ throw new CsvFormatError(spaceTrim$2((block) => `
2822
2856
  CSV parsing error
2823
2857
 
2824
2858
  Error(s) from CSV parsing:
@@ -2863,7 +2897,7 @@ const CsvFormatParser = {
2863
2897
  const { value, settings, mapCallback, onProgress } = options;
2864
2898
  const csv = csvParse(value, settings);
2865
2899
  if (csv.errors.length !== 0) {
2866
- throw new CsvFormatError(spaceTrim$1((block) => `
2900
+ throw new CsvFormatError(spaceTrim$2((block) => `
2867
2901
  CSV parsing error
2868
2902
 
2869
2903
  Error(s) from CSV parsing:
@@ -3208,7 +3242,7 @@ function checkSerializableAsJson(options) {
3208
3242
  }
3209
3243
  else if (typeof value === 'object') {
3210
3244
  if (value instanceof Date) {
3211
- throw new UnexpectedError(spaceTrim$1((block) => `
3245
+ throw new UnexpectedError(spaceTrim$2((block) => `
3212
3246
  \`${name}\` is Date
3213
3247
 
3214
3248
  Use \`string_date_iso8601\` instead
@@ -3227,7 +3261,7 @@ function checkSerializableAsJson(options) {
3227
3261
  throw new UnexpectedError(`${name} is RegExp`);
3228
3262
  }
3229
3263
  else if (value instanceof Error) {
3230
- throw new UnexpectedError(spaceTrim$1((block) => `
3264
+ throw new UnexpectedError(spaceTrim$2((block) => `
3231
3265
  \`${name}\` is unserialized Error
3232
3266
 
3233
3267
  Use function \`serializeError\`
@@ -3250,7 +3284,7 @@ function checkSerializableAsJson(options) {
3250
3284
  }
3251
3285
  catch (error) {
3252
3286
  assertsError(error);
3253
- throw new UnexpectedError(spaceTrim$1((block) => `
3287
+ throw new UnexpectedError(spaceTrim$2((block) => `
3254
3288
  \`${name}\` is not serializable
3255
3289
 
3256
3290
  ${block(error.stack || error.message)}
@@ -3282,7 +3316,7 @@ function checkSerializableAsJson(options) {
3282
3316
  }
3283
3317
  }
3284
3318
  else {
3285
- throw new UnexpectedError(spaceTrim$1((block) => `
3319
+ throw new UnexpectedError(spaceTrim$2((block) => `
3286
3320
  \`${name}\` is unknown type
3287
3321
 
3288
3322
  Additional message for \`${name}\`:
@@ -3563,7 +3597,7 @@ function validateParameterName(parameterName) {
3563
3597
  if (!(error instanceof ParseError)) {
3564
3598
  throw error;
3565
3599
  }
3566
- throw new ParseError(spaceTrim$1((block) => `
3600
+ throw new ParseError(spaceTrim$2((block) => `
3567
3601
  ${block(error.message)}
3568
3602
 
3569
3603
  Tried to validate parameter name:
@@ -3622,7 +3656,7 @@ const foreachCommandParser = {
3622
3656
  const assignSign = args[3];
3623
3657
  const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
3624
3658
  if (formatDefinition === undefined) {
3625
- throw new ParseError(spaceTrim$1((block) => `
3659
+ throw new ParseError(spaceTrim$2((block) => `
3626
3660
  Unsupported format "${formatName}"
3627
3661
 
3628
3662
  Available formats:
@@ -3634,7 +3668,7 @@ const foreachCommandParser = {
3634
3668
  }
3635
3669
  const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
3636
3670
  if (subvalueParser === undefined) {
3637
- throw new ParseError(spaceTrim$1((block) => `
3671
+ throw new ParseError(spaceTrim$2((block) => `
3638
3672
  Unsupported subformat name "${subformatName}" for format "${formatName}"
3639
3673
 
3640
3674
  Available subformat names for format "${formatDefinition.formatName}":
@@ -3682,7 +3716,7 @@ const foreachCommandParser = {
3682
3716
  outputSubparameterName = 'newLine';
3683
3717
  }
3684
3718
  else {
3685
- throw new ParseError(spaceTrim$1(`
3719
+ throw new ParseError(spaceTrim$2(`
3686
3720
  FOREACH ${formatName} ${subformatName} must specify output subparameter
3687
3721
 
3688
3722
  Correct example:
@@ -3758,7 +3792,7 @@ const formatCommandParser = {
3758
3792
  /**
3759
3793
  * Description of the FORMAT command
3760
3794
  */
3761
- description: spaceTrim$1(`
3795
+ description: spaceTrim$2(`
3762
3796
  Format command describes the desired output of the task (after post-processing)
3763
3797
  It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
3764
3798
  `),
@@ -4130,7 +4164,7 @@ const formfactorCommandParser = {
4130
4164
  const formfactorNameCandidate = args[0].toUpperCase();
4131
4165
  const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
4132
4166
  if (formfactor === undefined) {
4133
- throw new ParseError(spaceTrim$1((block) => `
4167
+ throw new ParseError(spaceTrim$2((block) => `
4134
4168
  Unknown formfactor name "${formfactorNameCandidate}"
4135
4169
 
4136
4170
  Available formfactors:
@@ -4149,7 +4183,7 @@ const formfactorCommandParser = {
4149
4183
  */
4150
4184
  $applyToPipelineJson(command, $pipelineJson) {
4151
4185
  if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
4152
- throw new ParseError(spaceTrim$1(`
4186
+ throw new ParseError(spaceTrim$2(`
4153
4187
  Redefinition of \`FORMFACTOR\` in the pipeline head
4154
4188
 
4155
4189
  You have used:
@@ -4292,7 +4326,7 @@ const modelCommandParser = {
4292
4326
  */
4293
4327
  parse(input) {
4294
4328
  const { args, normalized } = input;
4295
- const availableVariantsMessage = spaceTrim$1((block) => `
4329
+ const availableVariantsMessage = spaceTrim$2((block) => `
4296
4330
  Available variants are:
4297
4331
  ${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
4298
4332
  `);
@@ -4314,14 +4348,14 @@ const modelCommandParser = {
4314
4348
  // <- Note: [🤖]
4315
4349
  }
4316
4350
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
4317
- spaceTrim$1((block) => `
4351
+ spaceTrim$2((block) => `
4318
4352
  Embedding model can not be used in pipeline
4319
4353
 
4320
4354
  ${block(availableVariantsMessage)}
4321
4355
  `);
4322
4356
  }
4323
4357
  else {
4324
- throw new ParseError(spaceTrim$1((block) => `
4358
+ throw new ParseError(spaceTrim$2((block) => `
4325
4359
  Unknown model variant in command:
4326
4360
 
4327
4361
  ${block(availableVariantsMessage)}
@@ -4336,7 +4370,7 @@ const modelCommandParser = {
4336
4370
  };
4337
4371
  }
4338
4372
  else {
4339
- throw new ParseError(spaceTrim$1((block) => `
4373
+ throw new ParseError(spaceTrim$2((block) => `
4340
4374
  Unknown model key in command.
4341
4375
 
4342
4376
  Supported model keys are:
@@ -4363,7 +4397,7 @@ const modelCommandParser = {
4363
4397
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4364
4398
  }
4365
4399
  else {
4366
- throw new ParseError(spaceTrim$1(`
4400
+ throw new ParseError(spaceTrim$2(`
4367
4401
  Redefinition of \`MODEL ${command.key}\` in the pipeline head
4368
4402
 
4369
4403
  You have used:
@@ -4395,7 +4429,7 @@ const modelCommandParser = {
4395
4429
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4396
4430
  }
4397
4431
  else {
4398
- throw new ParseError(spaceTrim$1(`
4432
+ throw new ParseError(spaceTrim$2(`
4399
4433
  Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
4400
4434
 
4401
4435
  You have used:
@@ -4405,7 +4439,7 @@ const modelCommandParser = {
4405
4439
  }
4406
4440
  }
4407
4441
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
4408
- console.log(spaceTrim$1(`
4442
+ console.log(spaceTrim$2(`
4409
4443
  Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
4410
4444
 
4411
4445
  In pipeline head:
@@ -4488,7 +4522,7 @@ const parameterCommandParser = {
4488
4522
  // <- TODO: When [🥶] fixed, change to:
4489
4523
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
4490
4524
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
4491
- throw new ParseError(spaceTrim$1((block) => `
4525
+ throw new ParseError(spaceTrim$2((block) => `
4492
4526
  Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
4493
4527
 
4494
4528
  The description:
@@ -4670,7 +4704,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
4670
4704
  persona.description = personaDescription;
4671
4705
  return;
4672
4706
  }
4673
- console.warn(spaceTrim$1(`
4707
+ console.warn(spaceTrim$2(`
4674
4708
 
4675
4709
  Persona "${personaName}" is defined multiple times with different description:
4676
4710
 
@@ -4681,7 +4715,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
4681
4715
  ${personaDescription}
4682
4716
 
4683
4717
  `));
4684
- persona.description += spaceTrim$1('\n\n' + personaDescription);
4718
+ persona.description += spaceTrim$2('\n\n' + personaDescription);
4685
4719
  }
4686
4720
 
4687
4721
  /**
@@ -5078,7 +5112,7 @@ const COMMANDS = [
5078
5112
  function getParserForCommand(command) {
5079
5113
  const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
5080
5114
  if (commandParser === undefined) {
5081
- throw new UnexpectedError(spaceTrim((block) => `
5115
+ throw new UnexpectedError(spaceTrim$1((block) => `
5082
5116
  Command ${command.type} parser is not found
5083
5117
 
5084
5118
  ${block(JSON.stringify(command, null, 4)
@@ -5154,7 +5188,7 @@ function parseCommand(raw, usagePlace) {
5154
5188
  .map(removeMarkdownFormatting)
5155
5189
  .map((item) => item.trim());
5156
5190
  if (items.length === 0 || items[0] === '') {
5157
- throw new ParseError(spaceTrim((block) => `
5191
+ throw new ParseError(spaceTrim$1((block) => `
5158
5192
  Malformed command:
5159
5193
  - ${raw}
5160
5194
 
@@ -5190,7 +5224,7 @@ function parseCommand(raw, usagePlace) {
5190
5224
  return command;
5191
5225
  }
5192
5226
  }
5193
- throw new ParseError(spaceTrim((block) => `
5227
+ throw new ParseError(spaceTrim$1((block) => `
5194
5228
  Malformed or unknown command:
5195
5229
  - ${raw}
5196
5230
 
@@ -5241,7 +5275,7 @@ function parseCommandVariant(input) {
5241
5275
  if (!(error instanceof ParseError)) {
5242
5276
  throw error;
5243
5277
  }
5244
- throw new ParseError(spaceTrim((block) => `
5278
+ throw new ParseError(spaceTrim$1((block) => `
5245
5279
  Invalid ${commandName} command:
5246
5280
 
5247
5281
  Your command:
@@ -5603,7 +5637,7 @@ function padBook(content) {
5603
5637
  * @public exported from `@promptbook/markdown-utils`
5604
5638
  */
5605
5639
  function removeMarkdownComments(content) {
5606
- return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
5640
+ return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
5607
5641
  }
5608
5642
 
5609
5643
  /**
@@ -5614,7 +5648,7 @@ function removeMarkdownComments(content) {
5614
5648
  */
5615
5649
  function isFlatPipeline(pipelineString) {
5616
5650
  pipelineString = removeMarkdownComments(pipelineString);
5617
- pipelineString = spaceTrim$1(pipelineString);
5651
+ pipelineString = spaceTrim$2(pipelineString);
5618
5652
  const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
5619
5653
  //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
5620
5654
  const isBacktickBlockUsed = pipelineString.includes('```');
@@ -5640,7 +5674,7 @@ function deflatePipeline(pipelineString) {
5640
5674
  if (!isFlatPipeline(pipelineString)) {
5641
5675
  return pipelineString;
5642
5676
  }
5643
- pipelineString = spaceTrim$1(pipelineString);
5677
+ pipelineString = spaceTrim$2(pipelineString);
5644
5678
  const pipelineStringLines = pipelineString.split('\n');
5645
5679
  const potentialReturnStatement = pipelineStringLines.pop();
5646
5680
  let returnStatement;
@@ -5653,19 +5687,19 @@ function deflatePipeline(pipelineString) {
5653
5687
  returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
5654
5688
  pipelineStringLines.push(potentialReturnStatement);
5655
5689
  }
5656
- const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
5690
+ const prompt = spaceTrim$2(pipelineStringLines.join('\n'));
5657
5691
  let quotedPrompt;
5658
5692
  if (prompt.split('\n').length <= 1) {
5659
5693
  quotedPrompt = `> ${prompt}`;
5660
5694
  }
5661
5695
  else {
5662
- quotedPrompt = spaceTrim$1((block) => `
5696
+ quotedPrompt = spaceTrim$2((block) => `
5663
5697
  \`\`\`
5664
5698
  ${block(prompt.split('`').join('\\`'))}
5665
5699
  \`\`\`
5666
5700
  `);
5667
5701
  }
5668
- pipelineString = validatePipelineString(spaceTrim$1((block) => `
5702
+ pipelineString = validatePipelineString(spaceTrim$2((block) => `
5669
5703
  # ${DEFAULT_BOOK_TITLE}
5670
5704
 
5671
5705
  ## Prompt
@@ -5806,7 +5840,7 @@ function extractAllBlocksFromMarkdown(markdown) {
5806
5840
  function extractOneBlockFromMarkdown(markdown) {
5807
5841
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
5808
5842
  if (codeBlocks.length !== 1) {
5809
- throw new ParseError(spaceTrim$1((block) => `
5843
+ throw new ParseError(spaceTrim$2((block) => `
5810
5844
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
5811
5845
 
5812
5846
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -5831,7 +5865,7 @@ function parseMarkdownSection(value) {
5831
5865
  }
5832
5866
  const title = lines[0].replace(/^#+\s*/, '');
5833
5867
  const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
5834
- const content = spaceTrim$1(lines.slice(1).join('\n'));
5868
+ const content = spaceTrim$2(lines.slice(1).join('\n'));
5835
5869
  if (level < 1 || level > 6) {
5836
5870
  throw new ParseError('Markdown section must have heading level between 1 and 6');
5837
5871
  }
@@ -5859,7 +5893,7 @@ function splitMarkdownIntoSections(markdown) {
5859
5893
  if (buffer.length === 0) {
5860
5894
  return;
5861
5895
  }
5862
- let section = spaceTrim$1(buffer.join('\n'));
5896
+ let section = spaceTrim$2(buffer.join('\n'));
5863
5897
  if (section === '') {
5864
5898
  return;
5865
5899
  }
@@ -5934,7 +5968,7 @@ function flattenMarkdown(markdown) {
5934
5968
  flattenedMarkdown += `## ${title}` + `\n\n`;
5935
5969
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
5936
5970
  }
5937
- return spaceTrim$1(flattenedMarkdown);
5971
+ return spaceTrim$2(flattenedMarkdown);
5938
5972
  }
5939
5973
  /**
5940
5974
  * TODO: [🏛] This can be part of markdown builder
@@ -6022,7 +6056,7 @@ function extractVariablesFromJavascript(script) {
6022
6056
  }
6023
6057
  catch (error) {
6024
6058
  assertsError(error);
6025
- throw new ParseError(spaceTrim((block) => `
6059
+ throw new ParseError(spaceTrim$1((block) => `
6026
6060
  Can not extract variables from the script
6027
6061
  ${block(error.stack || error.message)}
6028
6062
 
@@ -6164,7 +6198,7 @@ function parsePipeline(pipelineString) {
6164
6198
  if (pipelineString.startsWith('#!')) {
6165
6199
  const [shebangLine, ...restLines] = pipelineString.split('\n');
6166
6200
  if (!(shebangLine || '').includes('ptbk')) {
6167
- throw new ParseError(spaceTrim((block) => `
6201
+ throw new ParseError(spaceTrim$1((block) => `
6168
6202
  It seems that you try to parse a book file which has non-standard shebang line for book files:
6169
6203
  Shebang line must contain 'ptbk'
6170
6204
 
@@ -6180,7 +6214,7 @@ function parsePipeline(pipelineString) {
6180
6214
  pipelineString = validatePipelineString(restLines.join('\n'));
6181
6215
  }
6182
6216
  pipelineString = removeMarkdownComments(pipelineString);
6183
- pipelineString = spaceTrim(pipelineString);
6217
+ pipelineString = spaceTrim$1(pipelineString);
6184
6218
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
6185
6219
  pipelineString = deflatePipeline(pipelineString);
6186
6220
  // ==============
@@ -6192,7 +6226,7 @@ function parsePipeline(pipelineString) {
6192
6226
  // ==============
6193
6227
  // Note: 1️⃣◽4️⃣ Check markdown structure
6194
6228
  if (pipelineHead === undefined) {
6195
- throw new UnexpectedError(spaceTrim((block) => `
6229
+ throw new UnexpectedError(spaceTrim$1((block) => `
6196
6230
  Pipeline head is not defined
6197
6231
 
6198
6232
  ${block(getPipelineIdentification())}
@@ -6201,7 +6235,7 @@ function parsePipeline(pipelineString) {
6201
6235
  `));
6202
6236
  }
6203
6237
  if (pipelineHead.level !== 1) {
6204
- throw new UnexpectedError(spaceTrim((block) => `
6238
+ throw new UnexpectedError(spaceTrim$1((block) => `
6205
6239
  Pipeline head is not h1
6206
6240
 
6207
6241
  ${block(getPipelineIdentification())}
@@ -6210,7 +6244,7 @@ function parsePipeline(pipelineString) {
6210
6244
  `));
6211
6245
  }
6212
6246
  if (!pipelineSections.every((section) => section.level === 2)) {
6213
- throw new UnexpectedError(spaceTrim((block) => `
6247
+ throw new UnexpectedError(spaceTrim$1((block) => `
6214
6248
  Not every pipeline section is h2
6215
6249
 
6216
6250
  ${block(getPipelineIdentification())}
@@ -6223,7 +6257,7 @@ function parsePipeline(pipelineString) {
6223
6257
  const defineParam = (parameterCommand) => {
6224
6258
  const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
6225
6259
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
6226
- throw new ParseError(spaceTrim((block) => `
6260
+ throw new ParseError(spaceTrim$1((block) => `
6227
6261
  Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
6228
6262
 
6229
6263
  ${block(getPipelineIdentification())}
@@ -6234,7 +6268,7 @@ function parsePipeline(pipelineString) {
6234
6268
  existingParameter.description &&
6235
6269
  existingParameter.description !== parameterDescription &&
6236
6270
  parameterDescription) {
6237
- throw new ParseError(spaceTrim((block) => `
6271
+ throw new ParseError(spaceTrim$1((block) => `
6238
6272
  Parameter \`{${parameterName}}\` is defined multiple times with different description:
6239
6273
 
6240
6274
  ${block(getPipelineIdentification())}
@@ -6272,7 +6306,7 @@ function parsePipeline(pipelineString) {
6272
6306
  description = description.split(/^>.*$/gm).join('');
6273
6307
  //Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
6274
6308
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
6275
- description = spaceTrim(description);
6309
+ description = spaceTrim$1(description);
6276
6310
  if (description === '') {
6277
6311
  description = undefined;
6278
6312
  }
@@ -6283,7 +6317,7 @@ function parsePipeline(pipelineString) {
6283
6317
  const command = parseCommand(listItem, 'PIPELINE_HEAD');
6284
6318
  const commandParser = getParserForCommand(command);
6285
6319
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
6286
- throw new ParseError(spaceTrim((block) => `
6320
+ throw new ParseError(spaceTrim$1((block) => `
6287
6321
  Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
6288
6322
 
6289
6323
  ${block(getPipelineIdentification())}
@@ -6297,7 +6331,7 @@ function parsePipeline(pipelineString) {
6297
6331
  if (!(error instanceof ParseError)) {
6298
6332
  throw error;
6299
6333
  }
6300
- throw new ParseError(spaceTrim((block) => `
6334
+ throw new ParseError(spaceTrim$1((block) => `
6301
6335
  Command ${command.type} failed to apply to the pipeline
6302
6336
 
6303
6337
  The error:
@@ -6350,7 +6384,7 @@ function parsePipeline(pipelineString) {
6350
6384
  description = description.split(/^>.*$/gm).join('');
6351
6385
  //Note: Remove lists and return statement - TODO: [🎾]
6352
6386
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
6353
- description = spaceTrim(description);
6387
+ description = spaceTrim$1(description);
6354
6388
  if (description === '') {
6355
6389
  description = undefined;
6356
6390
  }
@@ -6384,7 +6418,7 @@ function parsePipeline(pipelineString) {
6384
6418
  for (const { listItem, command } of commands) {
6385
6419
  const commandParser = getParserForCommand(command);
6386
6420
  if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
6387
- throw new ParseError(spaceTrim((block) => `
6421
+ throw new ParseError(spaceTrim$1((block) => `
6388
6422
  Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
6389
6423
 
6390
6424
  ${block(getPipelineIdentification())}
@@ -6399,7 +6433,7 @@ function parsePipeline(pipelineString) {
6399
6433
  if (!(error instanceof ParseError)) {
6400
6434
  throw error;
6401
6435
  }
6402
- throw new ParseError(spaceTrim((block) => `
6436
+ throw new ParseError(spaceTrim$1((block) => `
6403
6437
  Command \`${command.type}\` failed to apply to the task
6404
6438
 
6405
6439
  The error:
@@ -6430,14 +6464,14 @@ function parsePipeline(pipelineString) {
6430
6464
  // TODO: [🍧] Should be done in SECTION command
6431
6465
  if ($taskJson.taskType === 'SCRIPT_TASK') {
6432
6466
  if (!language) {
6433
- throw new ParseError(spaceTrim((block) => `
6467
+ throw new ParseError(spaceTrim$1((block) => `
6434
6468
  You must specify the language of the script in the \`SCRIPT\` task
6435
6469
 
6436
6470
  ${block(getPipelineIdentification())}
6437
6471
  `));
6438
6472
  }
6439
6473
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6440
- throw new ParseError(spaceTrim((block) => `
6474
+ throw new ParseError(spaceTrim$1((block) => `
6441
6475
  Script language ${language} is not supported.
6442
6476
 
6443
6477
  Supported languages are: