@promptbook/remote-client 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 +123 -71
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +2 -2
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -8
  5. package/esm/typings/src/_packages/types.index.d.ts +7 -1
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  7. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
  8. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +3 -0
  9. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  10. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  11. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
  12. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
  13. package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
  14. package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +4 -0
  15. package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
  16. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
  17. package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
  18. package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
  19. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
  20. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
  21. package/esm/typings/src/commitments/{IMPORTANT/IMPORTANT.d.ts → USE_MCP/USE_MCP.d.ts} +16 -5
  22. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
  23. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  24. package/esm/typings/src/commitments/index.d.ts +93 -1
  25. package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -1
  26. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  27. package/esm/typings/src/playground/playground.d.ts +3 -0
  28. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  29. package/esm/typings/src/utils/color/Color.d.ts +9 -1
  30. package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
  31. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +6 -0
  32. package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
  33. package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
  34. package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
  35. package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
  36. package/esm/typings/src/version.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/umd/index.umd.js +85 -33
  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$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-66';
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',
@@ -559,21 +571,61 @@ class Color {
559
571
  * @param color
560
572
  * @returns Color object
561
573
  */
562
- static from(color) {
563
- if (color instanceof Color) {
574
+ static from(color, _isSingleValue = false) {
575
+ if (color === '') {
576
+ throw new Error(`Can not create color from empty string`);
577
+ }
578
+ else if (color instanceof Color) {
564
579
  return take(color);
565
580
  }
566
581
  else if (Color.isColor(color)) {
567
582
  return take(color);
568
583
  }
569
584
  else if (typeof color === 'string') {
570
- return Color.fromString(color);
585
+ try {
586
+ return Color.fromString(color);
587
+ }
588
+ catch (error) {
589
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
590
+ if (_isSingleValue) {
591
+ throw error;
592
+ }
593
+ const parts = color.split(/[\s+,;|]/);
594
+ if (parts.length > 0) {
595
+ return Color.from(parts[0].trim(), true);
596
+ }
597
+ else {
598
+ throw new Error(`Can not create color from given string "${color}"`);
599
+ }
600
+ }
571
601
  }
572
602
  else {
573
603
  console.error({ color });
574
604
  throw new Error(`Can not create color from given object`);
575
605
  }
576
606
  }
607
+ /**
608
+ * Creates a new Color instance from miscellaneous formats
609
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
610
+ *
611
+ * @param color
612
+ * @returns Color object
613
+ */
614
+ static fromSafe(color) {
615
+ try {
616
+ return Color.from(color);
617
+ }
618
+ catch (error) {
619
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
620
+ console.warn(spaceTrim((block) => `
621
+ Color.fromSafe error:
622
+ ${block(error.message)}
623
+
624
+ Returning default PROMPTBOOK_COLOR.
625
+ `));
626
+ return Color.fromString('promptbook');
627
+ }
628
+ }
577
629
  /**
578
630
  * Creates a new Color instance from miscellaneous string formats
579
631
  *
@@ -1183,7 +1235,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
1183
1235
  *
1184
1236
  * @public exported from `@promptbook/core`
1185
1237
  */
1186
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1238
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1187
1239
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1188
1240
  /**
1189
1241
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1288,7 +1340,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1288
1340
  function getErrorReportUrl(error) {
1289
1341
  const report = {
1290
1342
  title: `🐜 Error report from ${NAME}`,
1291
- body: spaceTrim$1((block) => `
1343
+ body: spaceTrim$2((block) => `
1292
1344
 
1293
1345
 
1294
1346
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1331,7 +1383,7 @@ function getErrorReportUrl(error) {
1331
1383
  */
1332
1384
  class UnexpectedError extends Error {
1333
1385
  constructor(message) {
1334
- super(spaceTrim((block) => `
1386
+ super(spaceTrim$1((block) => `
1335
1387
  ${block(message)}
1336
1388
 
1337
1389
  Note: This error should not happen.
@@ -1357,7 +1409,7 @@ class WrappedError extends Error {
1357
1409
  constructor(whatWasThrown) {
1358
1410
  const tag = `[🤮]`;
1359
1411
  console.error(tag, whatWasThrown);
1360
- super(spaceTrim(`
1412
+ super(spaceTrim$1(`
1361
1413
  Non-Error object was thrown
1362
1414
 
1363
1415
  Note: Look for ${tag} in the console for more details
@@ -1446,7 +1498,7 @@ function deserializeError(error) {
1446
1498
  message = `${name}: ${message}`;
1447
1499
  }
1448
1500
  if (stack !== undefined && stack !== '') {
1449
- message = spaceTrim$1((block) => `
1501
+ message = spaceTrim$2((block) => `
1450
1502
  ${block(message)}
1451
1503
 
1452
1504
  Original stack trace:
@@ -1503,7 +1555,7 @@ async function createRemoteClient(options) {
1503
1555
  const remoteServerUrlParsed = new URL(remoteServerUrl);
1504
1556
  if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
1505
1557
  remoteServerUrlParsed.pathname = '/';
1506
- throw new Error(spaceTrim$1((block) => `
1558
+ throw new Error(spaceTrim$2((block) => `
1507
1559
  Remote server requires root url \`/\`
1508
1560
 
1509
1561
  You have provided \`remoteServerUrl\`:
@@ -2039,7 +2091,7 @@ const knowledgeCommandParser = {
2039
2091
  */
2040
2092
  parse(input) {
2041
2093
  const { args } = input;
2042
- const knowledgeSourceContent = spaceTrim$1(args[0] || '');
2094
+ const knowledgeSourceContent = spaceTrim$2(args[0] || '');
2043
2095
  if (knowledgeSourceContent === '') {
2044
2096
  throw new ParseError(`Source is not defined`);
2045
2097
  }
@@ -2183,7 +2235,7 @@ const sectionCommandParser = {
2183
2235
  normalized = normalized.split('DIALOGUE').join('DIALOG');
2184
2236
  const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
2185
2237
  if (taskTypes.length !== 1) {
2186
- throw new ParseError(spaceTrim$1((block) => `
2238
+ throw new ParseError(spaceTrim$2((block) => `
2187
2239
  Unknown section type "${normalized}"
2188
2240
 
2189
2241
  Supported section types are:
@@ -2203,7 +2255,7 @@ const sectionCommandParser = {
2203
2255
  */
2204
2256
  $applyToTaskJson(command, $taskJson, $pipelineJson) {
2205
2257
  if ($taskJson.isSectionTypeSet === true) {
2206
- throw new ParseError(spaceTrim$1(`
2258
+ throw new ParseError(spaceTrim$2(`
2207
2259
  Section type is already defined in the section.
2208
2260
  It can be defined only once.
2209
2261
  `));
@@ -2622,7 +2674,7 @@ const expectCommandParser = {
2622
2674
  /**
2623
2675
  * Description of the FORMAT command
2624
2676
  */
2625
- description: spaceTrim$1(`
2677
+ description: spaceTrim$2(`
2626
2678
  Expect command describes the desired output of the task *(after post-processing)*
2627
2679
  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
2680
  `),
@@ -2696,7 +2748,7 @@ const expectCommandParser = {
2696
2748
  }
2697
2749
  catch (error) {
2698
2750
  assertsError(error);
2699
- throw new ParseError(spaceTrim$1((block) => `
2751
+ throw new ParseError(spaceTrim$2((block) => `
2700
2752
  Invalid FORMAT command
2701
2753
  ${block(error.message)}:
2702
2754
  `));
@@ -2818,7 +2870,7 @@ const CsvFormatParser = {
2818
2870
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
2819
2871
  const csv = csvParse(value, settings);
2820
2872
  if (csv.errors.length !== 0) {
2821
- throw new CsvFormatError(spaceTrim$1((block) => `
2873
+ throw new CsvFormatError(spaceTrim$2((block) => `
2822
2874
  CSV parsing error
2823
2875
 
2824
2876
  Error(s) from CSV parsing:
@@ -2863,7 +2915,7 @@ const CsvFormatParser = {
2863
2915
  const { value, settings, mapCallback, onProgress } = options;
2864
2916
  const csv = csvParse(value, settings);
2865
2917
  if (csv.errors.length !== 0) {
2866
- throw new CsvFormatError(spaceTrim$1((block) => `
2918
+ throw new CsvFormatError(spaceTrim$2((block) => `
2867
2919
  CSV parsing error
2868
2920
 
2869
2921
  Error(s) from CSV parsing:
@@ -3208,7 +3260,7 @@ function checkSerializableAsJson(options) {
3208
3260
  }
3209
3261
  else if (typeof value === 'object') {
3210
3262
  if (value instanceof Date) {
3211
- throw new UnexpectedError(spaceTrim$1((block) => `
3263
+ throw new UnexpectedError(spaceTrim$2((block) => `
3212
3264
  \`${name}\` is Date
3213
3265
 
3214
3266
  Use \`string_date_iso8601\` instead
@@ -3227,7 +3279,7 @@ function checkSerializableAsJson(options) {
3227
3279
  throw new UnexpectedError(`${name} is RegExp`);
3228
3280
  }
3229
3281
  else if (value instanceof Error) {
3230
- throw new UnexpectedError(spaceTrim$1((block) => `
3282
+ throw new UnexpectedError(spaceTrim$2((block) => `
3231
3283
  \`${name}\` is unserialized Error
3232
3284
 
3233
3285
  Use function \`serializeError\`
@@ -3250,7 +3302,7 @@ function checkSerializableAsJson(options) {
3250
3302
  }
3251
3303
  catch (error) {
3252
3304
  assertsError(error);
3253
- throw new UnexpectedError(spaceTrim$1((block) => `
3305
+ throw new UnexpectedError(spaceTrim$2((block) => `
3254
3306
  \`${name}\` is not serializable
3255
3307
 
3256
3308
  ${block(error.stack || error.message)}
@@ -3282,7 +3334,7 @@ function checkSerializableAsJson(options) {
3282
3334
  }
3283
3335
  }
3284
3336
  else {
3285
- throw new UnexpectedError(spaceTrim$1((block) => `
3337
+ throw new UnexpectedError(spaceTrim$2((block) => `
3286
3338
  \`${name}\` is unknown type
3287
3339
 
3288
3340
  Additional message for \`${name}\`:
@@ -3563,7 +3615,7 @@ function validateParameterName(parameterName) {
3563
3615
  if (!(error instanceof ParseError)) {
3564
3616
  throw error;
3565
3617
  }
3566
- throw new ParseError(spaceTrim$1((block) => `
3618
+ throw new ParseError(spaceTrim$2((block) => `
3567
3619
  ${block(error.message)}
3568
3620
 
3569
3621
  Tried to validate parameter name:
@@ -3622,7 +3674,7 @@ const foreachCommandParser = {
3622
3674
  const assignSign = args[3];
3623
3675
  const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
3624
3676
  if (formatDefinition === undefined) {
3625
- throw new ParseError(spaceTrim$1((block) => `
3677
+ throw new ParseError(spaceTrim$2((block) => `
3626
3678
  Unsupported format "${formatName}"
3627
3679
 
3628
3680
  Available formats:
@@ -3634,7 +3686,7 @@ const foreachCommandParser = {
3634
3686
  }
3635
3687
  const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
3636
3688
  if (subvalueParser === undefined) {
3637
- throw new ParseError(spaceTrim$1((block) => `
3689
+ throw new ParseError(spaceTrim$2((block) => `
3638
3690
  Unsupported subformat name "${subformatName}" for format "${formatName}"
3639
3691
 
3640
3692
  Available subformat names for format "${formatDefinition.formatName}":
@@ -3682,7 +3734,7 @@ const foreachCommandParser = {
3682
3734
  outputSubparameterName = 'newLine';
3683
3735
  }
3684
3736
  else {
3685
- throw new ParseError(spaceTrim$1(`
3737
+ throw new ParseError(spaceTrim$2(`
3686
3738
  FOREACH ${formatName} ${subformatName} must specify output subparameter
3687
3739
 
3688
3740
  Correct example:
@@ -3758,7 +3810,7 @@ const formatCommandParser = {
3758
3810
  /**
3759
3811
  * Description of the FORMAT command
3760
3812
  */
3761
- description: spaceTrim$1(`
3813
+ description: spaceTrim$2(`
3762
3814
  Format command describes the desired output of the task (after post-processing)
3763
3815
  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
3816
  `),
@@ -4130,7 +4182,7 @@ const formfactorCommandParser = {
4130
4182
  const formfactorNameCandidate = args[0].toUpperCase();
4131
4183
  const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
4132
4184
  if (formfactor === undefined) {
4133
- throw new ParseError(spaceTrim$1((block) => `
4185
+ throw new ParseError(spaceTrim$2((block) => `
4134
4186
  Unknown formfactor name "${formfactorNameCandidate}"
4135
4187
 
4136
4188
  Available formfactors:
@@ -4149,7 +4201,7 @@ const formfactorCommandParser = {
4149
4201
  */
4150
4202
  $applyToPipelineJson(command, $pipelineJson) {
4151
4203
  if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
4152
- throw new ParseError(spaceTrim$1(`
4204
+ throw new ParseError(spaceTrim$2(`
4153
4205
  Redefinition of \`FORMFACTOR\` in the pipeline head
4154
4206
 
4155
4207
  You have used:
@@ -4292,7 +4344,7 @@ const modelCommandParser = {
4292
4344
  */
4293
4345
  parse(input) {
4294
4346
  const { args, normalized } = input;
4295
- const availableVariantsMessage = spaceTrim$1((block) => `
4347
+ const availableVariantsMessage = spaceTrim$2((block) => `
4296
4348
  Available variants are:
4297
4349
  ${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
4298
4350
  `);
@@ -4314,14 +4366,14 @@ const modelCommandParser = {
4314
4366
  // <- Note: [🤖]
4315
4367
  }
4316
4368
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
4317
- spaceTrim$1((block) => `
4369
+ spaceTrim$2((block) => `
4318
4370
  Embedding model can not be used in pipeline
4319
4371
 
4320
4372
  ${block(availableVariantsMessage)}
4321
4373
  `);
4322
4374
  }
4323
4375
  else {
4324
- throw new ParseError(spaceTrim$1((block) => `
4376
+ throw new ParseError(spaceTrim$2((block) => `
4325
4377
  Unknown model variant in command:
4326
4378
 
4327
4379
  ${block(availableVariantsMessage)}
@@ -4336,7 +4388,7 @@ const modelCommandParser = {
4336
4388
  };
4337
4389
  }
4338
4390
  else {
4339
- throw new ParseError(spaceTrim$1((block) => `
4391
+ throw new ParseError(spaceTrim$2((block) => `
4340
4392
  Unknown model key in command.
4341
4393
 
4342
4394
  Supported model keys are:
@@ -4363,7 +4415,7 @@ const modelCommandParser = {
4363
4415
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4364
4416
  }
4365
4417
  else {
4366
- throw new ParseError(spaceTrim$1(`
4418
+ throw new ParseError(spaceTrim$2(`
4367
4419
  Redefinition of \`MODEL ${command.key}\` in the pipeline head
4368
4420
 
4369
4421
  You have used:
@@ -4395,7 +4447,7 @@ const modelCommandParser = {
4395
4447
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4396
4448
  }
4397
4449
  else {
4398
- throw new ParseError(spaceTrim$1(`
4450
+ throw new ParseError(spaceTrim$2(`
4399
4451
  Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
4400
4452
 
4401
4453
  You have used:
@@ -4405,7 +4457,7 @@ const modelCommandParser = {
4405
4457
  }
4406
4458
  }
4407
4459
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
4408
- console.log(spaceTrim$1(`
4460
+ console.log(spaceTrim$2(`
4409
4461
  Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
4410
4462
 
4411
4463
  In pipeline head:
@@ -4488,7 +4540,7 @@ const parameterCommandParser = {
4488
4540
  // <- TODO: When [🥶] fixed, change to:
4489
4541
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
4490
4542
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
4491
- throw new ParseError(spaceTrim$1((block) => `
4543
+ throw new ParseError(spaceTrim$2((block) => `
4492
4544
  Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
4493
4545
 
4494
4546
  The description:
@@ -4670,7 +4722,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
4670
4722
  persona.description = personaDescription;
4671
4723
  return;
4672
4724
  }
4673
- console.warn(spaceTrim$1(`
4725
+ console.warn(spaceTrim$2(`
4674
4726
 
4675
4727
  Persona "${personaName}" is defined multiple times with different description:
4676
4728
 
@@ -4681,7 +4733,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
4681
4733
  ${personaDescription}
4682
4734
 
4683
4735
  `));
4684
- persona.description += spaceTrim$1('\n\n' + personaDescription);
4736
+ persona.description += spaceTrim$2('\n\n' + personaDescription);
4685
4737
  }
4686
4738
 
4687
4739
  /**
@@ -5078,7 +5130,7 @@ const COMMANDS = [
5078
5130
  function getParserForCommand(command) {
5079
5131
  const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
5080
5132
  if (commandParser === undefined) {
5081
- throw new UnexpectedError(spaceTrim((block) => `
5133
+ throw new UnexpectedError(spaceTrim$1((block) => `
5082
5134
  Command ${command.type} parser is not found
5083
5135
 
5084
5136
  ${block(JSON.stringify(command, null, 4)
@@ -5154,7 +5206,7 @@ function parseCommand(raw, usagePlace) {
5154
5206
  .map(removeMarkdownFormatting)
5155
5207
  .map((item) => item.trim());
5156
5208
  if (items.length === 0 || items[0] === '') {
5157
- throw new ParseError(spaceTrim((block) => `
5209
+ throw new ParseError(spaceTrim$1((block) => `
5158
5210
  Malformed command:
5159
5211
  - ${raw}
5160
5212
 
@@ -5190,7 +5242,7 @@ function parseCommand(raw, usagePlace) {
5190
5242
  return command;
5191
5243
  }
5192
5244
  }
5193
- throw new ParseError(spaceTrim((block) => `
5245
+ throw new ParseError(spaceTrim$1((block) => `
5194
5246
  Malformed or unknown command:
5195
5247
  - ${raw}
5196
5248
 
@@ -5241,7 +5293,7 @@ function parseCommandVariant(input) {
5241
5293
  if (!(error instanceof ParseError)) {
5242
5294
  throw error;
5243
5295
  }
5244
- throw new ParseError(spaceTrim((block) => `
5296
+ throw new ParseError(spaceTrim$1((block) => `
5245
5297
  Invalid ${commandName} command:
5246
5298
 
5247
5299
  Your command:
@@ -5603,7 +5655,7 @@ function padBook(content) {
5603
5655
  * @public exported from `@promptbook/markdown-utils`
5604
5656
  */
5605
5657
  function removeMarkdownComments(content) {
5606
- return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
5658
+ return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
5607
5659
  }
5608
5660
 
5609
5661
  /**
@@ -5614,7 +5666,7 @@ function removeMarkdownComments(content) {
5614
5666
  */
5615
5667
  function isFlatPipeline(pipelineString) {
5616
5668
  pipelineString = removeMarkdownComments(pipelineString);
5617
- pipelineString = spaceTrim$1(pipelineString);
5669
+ pipelineString = spaceTrim$2(pipelineString);
5618
5670
  const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
5619
5671
  //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
5620
5672
  const isBacktickBlockUsed = pipelineString.includes('```');
@@ -5640,7 +5692,7 @@ function deflatePipeline(pipelineString) {
5640
5692
  if (!isFlatPipeline(pipelineString)) {
5641
5693
  return pipelineString;
5642
5694
  }
5643
- pipelineString = spaceTrim$1(pipelineString);
5695
+ pipelineString = spaceTrim$2(pipelineString);
5644
5696
  const pipelineStringLines = pipelineString.split('\n');
5645
5697
  const potentialReturnStatement = pipelineStringLines.pop();
5646
5698
  let returnStatement;
@@ -5653,19 +5705,19 @@ function deflatePipeline(pipelineString) {
5653
5705
  returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
5654
5706
  pipelineStringLines.push(potentialReturnStatement);
5655
5707
  }
5656
- const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
5708
+ const prompt = spaceTrim$2(pipelineStringLines.join('\n'));
5657
5709
  let quotedPrompt;
5658
5710
  if (prompt.split('\n').length <= 1) {
5659
5711
  quotedPrompt = `> ${prompt}`;
5660
5712
  }
5661
5713
  else {
5662
- quotedPrompt = spaceTrim$1((block) => `
5714
+ quotedPrompt = spaceTrim$2((block) => `
5663
5715
  \`\`\`
5664
5716
  ${block(prompt.split('`').join('\\`'))}
5665
5717
  \`\`\`
5666
5718
  `);
5667
5719
  }
5668
- pipelineString = validatePipelineString(spaceTrim$1((block) => `
5720
+ pipelineString = validatePipelineString(spaceTrim$2((block) => `
5669
5721
  # ${DEFAULT_BOOK_TITLE}
5670
5722
 
5671
5723
  ## Prompt
@@ -5806,7 +5858,7 @@ function extractAllBlocksFromMarkdown(markdown) {
5806
5858
  function extractOneBlockFromMarkdown(markdown) {
5807
5859
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
5808
5860
  if (codeBlocks.length !== 1) {
5809
- throw new ParseError(spaceTrim$1((block) => `
5861
+ throw new ParseError(spaceTrim$2((block) => `
5810
5862
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
5811
5863
 
5812
5864
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -5831,7 +5883,7 @@ function parseMarkdownSection(value) {
5831
5883
  }
5832
5884
  const title = lines[0].replace(/^#+\s*/, '');
5833
5885
  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'));
5886
+ const content = spaceTrim$2(lines.slice(1).join('\n'));
5835
5887
  if (level < 1 || level > 6) {
5836
5888
  throw new ParseError('Markdown section must have heading level between 1 and 6');
5837
5889
  }
@@ -5859,7 +5911,7 @@ function splitMarkdownIntoSections(markdown) {
5859
5911
  if (buffer.length === 0) {
5860
5912
  return;
5861
5913
  }
5862
- let section = spaceTrim$1(buffer.join('\n'));
5914
+ let section = spaceTrim$2(buffer.join('\n'));
5863
5915
  if (section === '') {
5864
5916
  return;
5865
5917
  }
@@ -5934,7 +5986,7 @@ function flattenMarkdown(markdown) {
5934
5986
  flattenedMarkdown += `## ${title}` + `\n\n`;
5935
5987
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
5936
5988
  }
5937
- return spaceTrim$1(flattenedMarkdown);
5989
+ return spaceTrim$2(flattenedMarkdown);
5938
5990
  }
5939
5991
  /**
5940
5992
  * TODO: [🏛] This can be part of markdown builder
@@ -6022,7 +6074,7 @@ function extractVariablesFromJavascript(script) {
6022
6074
  }
6023
6075
  catch (error) {
6024
6076
  assertsError(error);
6025
- throw new ParseError(spaceTrim((block) => `
6077
+ throw new ParseError(spaceTrim$1((block) => `
6026
6078
  Can not extract variables from the script
6027
6079
  ${block(error.stack || error.message)}
6028
6080
 
@@ -6164,7 +6216,7 @@ function parsePipeline(pipelineString) {
6164
6216
  if (pipelineString.startsWith('#!')) {
6165
6217
  const [shebangLine, ...restLines] = pipelineString.split('\n');
6166
6218
  if (!(shebangLine || '').includes('ptbk')) {
6167
- throw new ParseError(spaceTrim((block) => `
6219
+ throw new ParseError(spaceTrim$1((block) => `
6168
6220
  It seems that you try to parse a book file which has non-standard shebang line for book files:
6169
6221
  Shebang line must contain 'ptbk'
6170
6222
 
@@ -6180,7 +6232,7 @@ function parsePipeline(pipelineString) {
6180
6232
  pipelineString = validatePipelineString(restLines.join('\n'));
6181
6233
  }
6182
6234
  pipelineString = removeMarkdownComments(pipelineString);
6183
- pipelineString = spaceTrim(pipelineString);
6235
+ pipelineString = spaceTrim$1(pipelineString);
6184
6236
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
6185
6237
  pipelineString = deflatePipeline(pipelineString);
6186
6238
  // ==============
@@ -6192,7 +6244,7 @@ function parsePipeline(pipelineString) {
6192
6244
  // ==============
6193
6245
  // Note: 1️⃣◽4️⃣ Check markdown structure
6194
6246
  if (pipelineHead === undefined) {
6195
- throw new UnexpectedError(spaceTrim((block) => `
6247
+ throw new UnexpectedError(spaceTrim$1((block) => `
6196
6248
  Pipeline head is not defined
6197
6249
 
6198
6250
  ${block(getPipelineIdentification())}
@@ -6201,7 +6253,7 @@ function parsePipeline(pipelineString) {
6201
6253
  `));
6202
6254
  }
6203
6255
  if (pipelineHead.level !== 1) {
6204
- throw new UnexpectedError(spaceTrim((block) => `
6256
+ throw new UnexpectedError(spaceTrim$1((block) => `
6205
6257
  Pipeline head is not h1
6206
6258
 
6207
6259
  ${block(getPipelineIdentification())}
@@ -6210,7 +6262,7 @@ function parsePipeline(pipelineString) {
6210
6262
  `));
6211
6263
  }
6212
6264
  if (!pipelineSections.every((section) => section.level === 2)) {
6213
- throw new UnexpectedError(spaceTrim((block) => `
6265
+ throw new UnexpectedError(spaceTrim$1((block) => `
6214
6266
  Not every pipeline section is h2
6215
6267
 
6216
6268
  ${block(getPipelineIdentification())}
@@ -6223,7 +6275,7 @@ function parsePipeline(pipelineString) {
6223
6275
  const defineParam = (parameterCommand) => {
6224
6276
  const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
6225
6277
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
6226
- throw new ParseError(spaceTrim((block) => `
6278
+ throw new ParseError(spaceTrim$1((block) => `
6227
6279
  Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
6228
6280
 
6229
6281
  ${block(getPipelineIdentification())}
@@ -6234,7 +6286,7 @@ function parsePipeline(pipelineString) {
6234
6286
  existingParameter.description &&
6235
6287
  existingParameter.description !== parameterDescription &&
6236
6288
  parameterDescription) {
6237
- throw new ParseError(spaceTrim((block) => `
6289
+ throw new ParseError(spaceTrim$1((block) => `
6238
6290
  Parameter \`{${parameterName}}\` is defined multiple times with different description:
6239
6291
 
6240
6292
  ${block(getPipelineIdentification())}
@@ -6272,7 +6324,7 @@ function parsePipeline(pipelineString) {
6272
6324
  description = description.split(/^>.*$/gm).join('');
6273
6325
  //Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
6274
6326
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
6275
- description = spaceTrim(description);
6327
+ description = spaceTrim$1(description);
6276
6328
  if (description === '') {
6277
6329
  description = undefined;
6278
6330
  }
@@ -6283,7 +6335,7 @@ function parsePipeline(pipelineString) {
6283
6335
  const command = parseCommand(listItem, 'PIPELINE_HEAD');
6284
6336
  const commandParser = getParserForCommand(command);
6285
6337
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
6286
- throw new ParseError(spaceTrim((block) => `
6338
+ throw new ParseError(spaceTrim$1((block) => `
6287
6339
  Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
6288
6340
 
6289
6341
  ${block(getPipelineIdentification())}
@@ -6297,7 +6349,7 @@ function parsePipeline(pipelineString) {
6297
6349
  if (!(error instanceof ParseError)) {
6298
6350
  throw error;
6299
6351
  }
6300
- throw new ParseError(spaceTrim((block) => `
6352
+ throw new ParseError(spaceTrim$1((block) => `
6301
6353
  Command ${command.type} failed to apply to the pipeline
6302
6354
 
6303
6355
  The error:
@@ -6350,7 +6402,7 @@ function parsePipeline(pipelineString) {
6350
6402
  description = description.split(/^>.*$/gm).join('');
6351
6403
  //Note: Remove lists and return statement - TODO: [🎾]
6352
6404
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
6353
- description = spaceTrim(description);
6405
+ description = spaceTrim$1(description);
6354
6406
  if (description === '') {
6355
6407
  description = undefined;
6356
6408
  }
@@ -6384,7 +6436,7 @@ function parsePipeline(pipelineString) {
6384
6436
  for (const { listItem, command } of commands) {
6385
6437
  const commandParser = getParserForCommand(command);
6386
6438
  if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
6387
- throw new ParseError(spaceTrim((block) => `
6439
+ throw new ParseError(spaceTrim$1((block) => `
6388
6440
  Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
6389
6441
 
6390
6442
  ${block(getPipelineIdentification())}
@@ -6399,7 +6451,7 @@ function parsePipeline(pipelineString) {
6399
6451
  if (!(error instanceof ParseError)) {
6400
6452
  throw error;
6401
6453
  }
6402
- throw new ParseError(spaceTrim((block) => `
6454
+ throw new ParseError(spaceTrim$1((block) => `
6403
6455
  Command \`${command.type}\` failed to apply to the task
6404
6456
 
6405
6457
  The error:
@@ -6430,14 +6482,14 @@ function parsePipeline(pipelineString) {
6430
6482
  // TODO: [🍧] Should be done in SECTION command
6431
6483
  if ($taskJson.taskType === 'SCRIPT_TASK') {
6432
6484
  if (!language) {
6433
- throw new ParseError(spaceTrim((block) => `
6485
+ throw new ParseError(spaceTrim$1((block) => `
6434
6486
  You must specify the language of the script in the \`SCRIPT\` task
6435
6487
 
6436
6488
  ${block(getPipelineIdentification())}
6437
6489
  `));
6438
6490
  }
6439
6491
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6440
- throw new ParseError(spaceTrim((block) => `
6492
+ throw new ParseError(spaceTrim$1((block) => `
6441
6493
  Script language ${language} is not supported.
6442
6494
 
6443
6495
  Supported languages are: