@promptbook/core 0.100.0-22 → 0.100.0-24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
1
+ import spaceTrim$1, { spaceTrim } from 'spacetrim';
2
2
  import { format } from 'prettier';
3
3
  import parserHtml from 'prettier/parser-html';
4
4
  import { randomBytes } from 'crypto';
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-22';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-24';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -208,24 +208,47 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
208
208
  super('ACTION');
209
209
  }
210
210
  /**
211
- * Markdown documentation for ACTION commitment.
211
+ * Short one-line description of ACTION.
212
212
  */
213
213
  get description() {
214
- return [
215
- '# ACTION',
216
- '',
217
- 'Defines specific actions or capabilities that the agent can perform.',
218
- '',
219
- 'Effects on system message:',
220
- '- Appends a "Capability: ..." line to the system message.',
221
- '',
222
- 'Examples:',
223
- '```book',
224
- 'ACTION Can generate code snippets and explain programming concepts',
225
- 'ACTION Able to analyze data and provide insights',
226
- '```',
227
- '',
228
- ].join('\n');
214
+ return 'Define agent capabilities and actions it can perform.';
215
+ }
216
+ /**
217
+ * Markdown documentation for ACTION commitment.
218
+ */
219
+ get documentation() {
220
+ return spaceTrim(`
221
+ # ACTION
222
+
223
+ Defines specific actions or capabilities that the agent can perform.
224
+
225
+ ## Key behaviors
226
+
227
+ - Multiple \`ACTION\` commitments are applied sequentially.
228
+ - Each action adds to the agent's capability list.
229
+ - Actions help users understand what the agent can do.
230
+
231
+ ## Examples
232
+
233
+ \`\`\`book
234
+ Code Assistant
235
+
236
+ PERSONA You are a programming assistant
237
+ ACTION Can generate code snippets and explain programming concepts
238
+ ACTION Able to debug existing code and suggest improvements
239
+ ACTION Can create unit tests for functions
240
+ \`\`\`
241
+
242
+ \`\`\`book
243
+ Data Scientist
244
+
245
+ PERSONA You are a data analysis expert
246
+ ACTION Able to analyze data and provide insights
247
+ ACTION Can create visualizations and charts
248
+ ACTION Capable of statistical analysis and modeling
249
+ KNOWLEDGE Data analysis best practices and statistical methods
250
+ \`\`\`
251
+ `);
229
252
  }
230
253
  applyToAgentModelRequirements(requirements, content) {
231
254
  const trimmedContent = content.trim();
@@ -268,24 +291,45 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
268
291
  super('FORMAT');
269
292
  }
270
293
  /**
271
- * Markdown documentation for FORMAT commitment.
294
+ * Short one-line description of FORMAT.
272
295
  */
273
296
  get description() {
274
- return [
275
- '# FORMAT',
276
- '',
277
- 'Defines the specific output structure and formatting for responses (data formats, templates, structure).',
278
- '',
279
- 'Effects on system message:',
280
- '- Appends an "Output Format: ..." line to the system message.',
281
- '',
282
- 'Examples:',
283
- '```book',
284
- "FORMAT Always respond in JSON format with 'status' and 'data' fields",
285
- 'FORMAT Use markdown formatting for all code blocks',
286
- '```',
287
- '',
288
- ].join('\n');
297
+ return 'Specify output structure or formatting requirements.';
298
+ }
299
+ /**
300
+ * Markdown documentation for FORMAT commitment.
301
+ */
302
+ get documentation() {
303
+ return spaceTrim(`
304
+ # FORMAT
305
+
306
+ Defines the specific output structure and formatting for responses (data formats, templates, structure).
307
+
308
+ ## Key behaviors
309
+
310
+ - Multiple \`FORMAT\` commitments are applied sequentially.
311
+ - If they are in conflict, the last one takes precedence.
312
+ - You can specify both data formats and presentation styles.
313
+
314
+ ## Examples
315
+
316
+ \`\`\`book
317
+ Customer Support Bot
318
+
319
+ PERSONA You are a helpful customer support agent
320
+ FORMAT Always respond in JSON format with 'status' and 'data' fields
321
+ FORMAT Use markdown formatting for all code blocks
322
+ \`\`\`
323
+
324
+ \`\`\`book
325
+ Data Analyst
326
+
327
+ PERSONA You are a data analysis expert
328
+ FORMAT Present results in structured tables
329
+ FORMAT Include confidence scores for all predictions
330
+ STYLE Be concise and precise in explanations
331
+ \`\`\`
332
+ `);
289
333
  }
290
334
  applyToAgentModelRequirements(requirements, content) {
291
335
  const trimmedContent = content.trim();
@@ -678,7 +722,7 @@ true);
678
722
  function getErrorReportUrl(error) {
679
723
  const report = {
680
724
  title: `🐜 Error report from ${NAME}`,
681
- body: spaceTrim((block) => `
725
+ body: spaceTrim$1((block) => `
682
726
 
683
727
 
684
728
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -721,7 +765,7 @@ function getErrorReportUrl(error) {
721
765
  */
722
766
  class UnexpectedError extends Error {
723
767
  constructor(message) {
724
- super(spaceTrim$1((block) => `
768
+ super(spaceTrim((block) => `
725
769
  ${block(message)}
726
770
 
727
771
  Note: This error should not happen.
@@ -747,7 +791,7 @@ class WrappedError extends Error {
747
791
  constructor(whatWasThrown) {
748
792
  const tag = `[🤮]`;
749
793
  console.error(tag, whatWasThrown);
750
- super(spaceTrim$1(`
794
+ super(spaceTrim(`
751
795
  Non-Error object was thrown
752
796
 
753
797
  Note: Look for ${tag} in the console for more details
@@ -804,7 +848,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
804
848
  else if (urlOrRequest instanceof Request) {
805
849
  url = urlOrRequest.url;
806
850
  }
807
- throw new PromptbookFetchError(spaceTrim((block) => `
851
+ throw new PromptbookFetchError(spaceTrim$1((block) => `
808
852
  Can not fetch "${url}"
809
853
 
810
854
  Fetch error:
@@ -1040,30 +1084,54 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
1040
1084
  this.ragService = new FrontendRAGService();
1041
1085
  }
1042
1086
  /**
1043
- * Markdown documentation for KNOWLEDGE commitment.
1087
+ * Short one-line description of KNOWLEDGE.
1044
1088
  */
1045
1089
  get description() {
1046
- return [
1047
- '# KNOWLEDGE',
1048
- '',
1049
- 'Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.',
1050
- '',
1051
- 'Two modes:',
1052
- '- Direct text knowledge: Appends a "Knowledge: ..." line to the system message.',
1053
- '- URL knowledge source: Stores the URL in metadata.knowledgeSources and a ragService for retrieval at chat time, and appends an informational line to the system message.',
1054
- '',
1055
- 'Metadata effects when URL is used:',
1056
- '- metadata.ragService = FrontendRAGService instance',
1057
- '- metadata.knowledgeSources += [url]',
1058
- '',
1059
- 'Examples:',
1060
- '```book',
1061
- 'KNOWLEDGE The company was founded in 2020 and specializes in AI-powered solutions',
1062
- 'KNOWLEDGE https://example.com/company-handbook.pdf',
1063
- 'KNOWLEDGE https://example.com/product-documentation.pdf',
1064
- '```',
1065
- '',
1066
- ].join('\n');
1090
+ return 'Add domain **knowledge** via direct text or external sources (RAG).';
1091
+ }
1092
+ /**
1093
+ * Markdown documentation for KNOWLEDGE commitment.
1094
+ */
1095
+ get documentation() {
1096
+ return spaceTrim(`
1097
+ # KNOWLEDGE
1098
+
1099
+ Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
1100
+
1101
+ ## Key behaviors
1102
+
1103
+ - Multiple \`KNOWLEDGE\` commitments are applied sequentially.
1104
+ - Supports both direct text knowledge and external URLs.
1105
+ - External sources (PDFs, websites) are processed via RAG for context retrieval.
1106
+
1107
+ ## Supported formats
1108
+
1109
+ - Direct text: Immediate knowledge incorporated into agent
1110
+ - URLs: External documents processed for contextual retrieval
1111
+ - Supported file types: PDF, text, markdown, HTML
1112
+
1113
+ ## Examples
1114
+
1115
+ \`\`\`book
1116
+ Customer Support Bot
1117
+
1118
+ PERSONA You are a helpful customer support agent for TechCorp
1119
+ KNOWLEDGE TechCorp was founded in 2020 and specializes in AI-powered solutions
1120
+ KNOWLEDGE https://example.com/company-handbook.pdf
1121
+ KNOWLEDGE https://example.com/product-documentation.pdf
1122
+ RULE Always be polite and professional
1123
+ \`\`\`
1124
+
1125
+ \`\`\`book
1126
+ Research Assistant
1127
+
1128
+ PERSONA You are a knowledgeable research assistant
1129
+ KNOWLEDGE Academic research requires careful citation and verification
1130
+ KNOWLEDGE https://example.com/research-guidelines.pdf
1131
+ ACTION Can help with literature reviews and data analysis
1132
+ STYLE Present information in clear, academic format
1133
+ \`\`\`
1134
+ `);
1067
1135
  }
1068
1136
  applyToAgentModelRequirements(requirements, content) {
1069
1137
  var _a;
@@ -1145,25 +1213,46 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
1145
1213
  super('META IMAGE');
1146
1214
  }
1147
1215
  /**
1148
- * Markdown documentation for META IMAGE commitment.
1216
+ * Short one-line description of META IMAGE.
1149
1217
  */
1150
1218
  get description() {
1151
- return [
1152
- '# META IMAGE',
1153
- '',
1154
- "Sets the agent's avatar/profile image URL.",
1155
- '',
1156
- 'Behavior:',
1157
- '- Does not modify the system message.',
1158
- '- Handled separately by parsing logic to extract and store a profile image URL.',
1159
- '',
1160
- 'Examples:',
1161
- '```book',
1162
- 'META IMAGE https://example.com/avatar.jpg',
1163
- 'META IMAGE /assets/agent-avatar.png',
1164
- '```',
1165
- '',
1166
- ].join('\\n').replace(/\\\\n/g, '\\n');
1219
+ return "Set the agent's profile image URL.";
1220
+ }
1221
+ /**
1222
+ * Markdown documentation for META IMAGE commitment.
1223
+ */
1224
+ get documentation() {
1225
+ return spaceTrim(`
1226
+ # META IMAGE
1227
+
1228
+ Sets the agent's avatar/profile image URL.
1229
+
1230
+ ## Key behaviors
1231
+
1232
+ - Does not modify the agent's behavior or responses.
1233
+ - Only one \`META IMAGE\` should be used per agent.
1234
+ - If multiple are specified, the last one takes precedence.
1235
+ - Used for visual representation in user interfaces.
1236
+
1237
+ ## Examples
1238
+
1239
+ \`\`\`book
1240
+ Professional Assistant
1241
+
1242
+ META IMAGE https://example.com/professional-avatar.jpg
1243
+ PERSONA You are a professional business assistant
1244
+ STYLE Maintain a formal and courteous tone
1245
+ \`\`\`
1246
+
1247
+ \`\`\`book
1248
+ Creative Helper
1249
+
1250
+ META IMAGE /assets/creative-bot-avatar.png
1251
+ PERSONA You are a creative and inspiring assistant
1252
+ STYLE Be enthusiastic and encouraging
1253
+ ACTION Can help with brainstorming and ideation
1254
+ \`\`\`
1255
+ `);
1167
1256
  }
1168
1257
  applyToAgentModelRequirements(requirements, content) {
1169
1258
  // META IMAGE doesn't modify the system message or model requirements
@@ -1219,27 +1308,48 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
1219
1308
  super('META LINK');
1220
1309
  }
1221
1310
  /**
1222
- * Markdown documentation for META LINK commitment.
1311
+ * Short one-line description of META LINK.
1223
1312
  */
1224
1313
  get description() {
1225
- return [
1226
- '# META LINK',
1227
- '',
1228
- 'Represents a profile or source link for the person the agent is modeled after.',
1229
- '',
1230
- 'Behavior:',
1231
- '- Does not modify the system message.',
1232
- '- Parsing logic extracts and stores the link for profile display.',
1233
- '- Multiple META LINK lines are allowed when there are multiple sources.',
1234
- '',
1235
- 'Examples:',
1236
- '```book',
1237
- 'META LINK https://twitter.com/username',
1238
- 'META LINK https://linkedin.com/in/profile',
1239
- 'META LINK https://github.com/username',
1240
- '```',
1241
- '',
1242
- ].join('\\n').replace(/\\\\n/g, '\\n');
1314
+ return 'Provide profile/source links for the person the agent models.';
1315
+ }
1316
+ /**
1317
+ * Markdown documentation for META LINK commitment.
1318
+ */
1319
+ get documentation() {
1320
+ return spaceTrim(`
1321
+ # META LINK
1322
+
1323
+ Represents a profile or source link for the person the agent is modeled after.
1324
+
1325
+ ## Key behaviors
1326
+
1327
+ - Does not modify the agent's behavior or responses.
1328
+ - Multiple \`META LINK\` commitments can be used for different social profiles.
1329
+ - Used for attribution and crediting the original person.
1330
+ - Displayed in user interfaces for transparency.
1331
+
1332
+ ## Examples
1333
+
1334
+ \`\`\`book
1335
+ Expert Consultant
1336
+
1337
+ META LINK https://twitter.com/expertname
1338
+ META LINK https://linkedin.com/in/expertprofile
1339
+ PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
1340
+ KNOWLEDGE Extensive background in machine learning and neural networks
1341
+ \`\`\`
1342
+
1343
+ \`\`\`book
1344
+ Open Source Developer
1345
+
1346
+ META LINK https://github.com/developer
1347
+ META LINK https://twitter.com/devhandle
1348
+ PERSONA You are an experienced open source developer
1349
+ ACTION Can help with code reviews and architecture decisions
1350
+ STYLE Be direct and technical in explanations
1351
+ \`\`\`
1352
+ `);
1243
1353
  }
1244
1354
  applyToAgentModelRequirements(requirements, content) {
1245
1355
  // META LINK doesn't modify the system message or model requirements
@@ -1299,31 +1409,51 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
1299
1409
  super('MODEL');
1300
1410
  }
1301
1411
  /**
1302
- * Markdown documentation for MODEL commitment.
1412
+ * Short one-line description of MODEL.
1303
1413
  */
1304
1414
  get description() {
1305
- return [
1306
- '# MODEL',
1307
- '',
1308
- 'Specifies which AI model to use and optional decoding parameters.',
1309
- '',
1310
- 'Supported parameters:',
1311
- '- temperature: number',
1312
- '- topP (aka top_p): number',
1313
- '- topK (aka top_k): integer',
1314
- '',
1315
- 'Effects on requirements:',
1316
- '- Sets modelName from the first token.',
1317
- '- Parses optional parameters and assigns them to requirements (temperature, topP, topK).',
1318
- '',
1319
- 'Examples:',
1320
- '```book',
1321
- 'MODEL gpt-4',
1322
- 'MODEL claude-3-opus temperature=0.3',
1323
- 'MODEL gpt-3.5-turbo temperature=0.8 topP=0.9',
1324
- '```',
1325
- '',
1326
- ].join('\n');
1415
+ return 'Select the AI model and optional decoding parameters.';
1416
+ }
1417
+ /**
1418
+ * Markdown documentation for MODEL commitment.
1419
+ */
1420
+ get documentation() {
1421
+ return spaceTrim(`
1422
+ # MODEL
1423
+
1424
+ Specifies which AI model to use and optional decoding parameters.
1425
+
1426
+ ## Key behaviors
1427
+
1428
+ - Only one \`MODEL\` commitment should be used per agent.
1429
+ - If multiple are specified, the last one takes precedence.
1430
+ - Parameters control the randomness and creativity of responses.
1431
+
1432
+ ## Supported parameters
1433
+
1434
+ - \`temperature\`: Controls randomness (0.0 = deterministic, 1.0+ = creative)
1435
+ - \`topP\` (aka \`top_p\`): Nucleus sampling parameter
1436
+ - \`topK\` (aka \`top_k\`): Top-k sampling parameter
1437
+
1438
+ ## Examples
1439
+
1440
+ \`\`\`book
1441
+ Precise Assistant
1442
+
1443
+ PERSONA You are a precise and accurate assistant
1444
+ MODEL gpt-4 temperature=0.1
1445
+ RULE Always provide factual information
1446
+ \`\`\`
1447
+
1448
+ \`\`\`book
1449
+ Creative Writer
1450
+
1451
+ PERSONA You are a creative writing assistant
1452
+ MODEL claude-3-opus temperature=0.8 topP=0.9
1453
+ STYLE Be imaginative and expressive
1454
+ ACTION Can help with storytelling and character development
1455
+ \`\`\`
1456
+ `);
1327
1457
  }
1328
1458
  applyToAgentModelRequirements(requirements, content) {
1329
1459
  const trimmedContent = content.trim();
@@ -1411,27 +1541,49 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
1411
1541
  super('NOTE');
1412
1542
  }
1413
1543
  /**
1414
- * Markdown documentation for NOTE commitment.
1544
+ * Short one-line description of NOTE.
1415
1545
  */
1416
1546
  get description() {
1417
- return [
1418
- '# NOTE',
1419
- '',
1420
- 'Adds comments for documentation without changing system message or model requirements.',
1421
- '',
1422
- 'Key behaviors:',
1423
- '- Makes no changes to the system message.',
1424
- '- Makes no changes to requirements.',
1425
- '- Aggregates multiple NOTE lines into metadata.NOTE.',
1426
- '',
1427
- 'Examples:',
1428
- '```book',
1429
- 'NOTE This agent was designed for customer support scenarios',
1430
- 'NOTE Remember to update the knowledge base monthly',
1431
- 'NOTE Performance optimized for quick response times',
1432
- '```',
1433
- '',
1434
- ].join('\n');
1547
+ return 'Add developer-facing notes without changing behavior or output.';
1548
+ }
1549
+ /**
1550
+ * Markdown documentation for NOTE commitment.
1551
+ */
1552
+ get documentation() {
1553
+ return spaceTrim(`
1554
+ # NOTE
1555
+
1556
+ Adds comments for documentation without changing agent behavior.
1557
+
1558
+ ## Key behaviors
1559
+
1560
+ - Does not modify the agent's behavior or responses.
1561
+ - Multiple \`NOTE\` commitments are aggregated for debugging.
1562
+ - Useful for documenting design decisions and reminders.
1563
+ - Content is preserved in metadata for inspection.
1564
+
1565
+ ## Examples
1566
+
1567
+ \`\`\`book
1568
+ Customer Support Bot
1569
+
1570
+ NOTE This agent was designed for customer support scenarios
1571
+ NOTE Remember to update the knowledge base monthly
1572
+ PERSONA You are a helpful customer support representative
1573
+ KNOWLEDGE Company policies and procedures
1574
+ RULE Always be polite and professional
1575
+ \`\`\`
1576
+
1577
+ \`\`\`book
1578
+ Research Assistant
1579
+
1580
+ NOTE Performance optimized for quick response times
1581
+ NOTE Uses RAG for accessing latest research papers
1582
+ PERSONA You are a knowledgeable research assistant
1583
+ ACTION Can help with literature reviews and citations
1584
+ STYLE Present information in academic format
1585
+ \`\`\`
1586
+ `);
1435
1587
  }
1436
1588
  applyToAgentModelRequirements(requirements, content) {
1437
1589
  var _a;
@@ -1496,35 +1648,35 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
1496
1648
  super('PERSONA');
1497
1649
  }
1498
1650
  /**
1499
- * Markdown documentation for PERSONA commitment.
1651
+ * Short one-line description of PERSONA.
1500
1652
  */
1501
1653
  get description() {
1502
- return [
1503
- '# PERSONA',
1504
- '',
1505
- 'Defines who the agent is, their background, expertise, and personality traits.',
1506
- '',
1507
- 'Key behaviors:',
1508
- '- Multiple PERSONA commitments are merged together.',
1509
- '- The merged content is placed at the beginning of the system message.',
1510
- '- Original PERSONA lines are preserved in metadata.PERSONA.',
1511
- '- Comment lines (# PERSONA) are removed from the final system message.',
1512
- '',
1513
- 'Effects on system message:',
1514
- '- Creates a section:',
1515
- ' ```',
1516
- ' # PERSONA',
1517
- ' You are {agentName}',
1518
- ' {merged persona content}',
1519
- ' ```',
1520
- '',
1521
- 'Examples:',
1522
- '```book',
1523
- 'PERSONA You are a helpful programming assistant with expertise in TypeScript and React',
1524
- 'PERSONA You have deep knowledge of modern web development practices',
1525
- '```',
1526
- '',
1527
- ].join('\n');
1654
+ return 'Define who the agent is: background, expertise, and personality.';
1655
+ }
1656
+ /**
1657
+ * Markdown documentation for PERSONA commitment.
1658
+ */
1659
+ get documentation() {
1660
+ return spaceTrim(`
1661
+ # PERSONA
1662
+
1663
+ Defines who the agent is, their background, expertise, and personality traits.
1664
+
1665
+ ## Key behaviors
1666
+
1667
+ - Multiple \`PERSONA\` commitments are merged together.
1668
+ - If they are in conflict, the last one takes precedence.
1669
+ - You can write persona content in multiple lines.
1670
+
1671
+ ## Examples
1672
+
1673
+ \`\`\`book
1674
+ Programming Assistant
1675
+
1676
+ PERSONA You are a helpful programming assistant with expertise in TypeScript and React
1677
+ PERSONA You have deep knowledge of modern web development practices
1678
+ \`\`\`
1679
+ `);
1528
1680
  }
1529
1681
  applyToAgentModelRequirements(requirements, content) {
1530
1682
  var _a, _b;
@@ -1627,24 +1779,48 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
1627
1779
  super(type);
1628
1780
  }
1629
1781
  /**
1630
- * Markdown documentation for RULE/RULES commitment.
1782
+ * Short one-line description of RULE/RULES.
1631
1783
  */
1632
1784
  get description() {
1633
- return [
1634
- `# ${this.type}`,
1635
- '',
1636
- 'Adds behavioral constraints and guidelines that the agent must follow.',
1637
- '',
1638
- 'Effects on system message:',
1639
- '- Appends a "Rule: ..." line to the system message.',
1640
- '',
1641
- 'Examples:',
1642
- '```book',
1643
- 'RULE Always ask for clarification if the user\'s request is ambiguous',
1644
- 'RULES Never provide medical advice, always refer to healthcare professionals',
1645
- '```',
1646
- '',
1647
- ].join('\n');
1785
+ return 'Add behavioral rules the agent must follow.';
1786
+ }
1787
+ /**
1788
+ * Markdown documentation for RULE/RULES commitment.
1789
+ */
1790
+ get documentation() {
1791
+ return spaceTrim(`
1792
+ # ${this.type}
1793
+
1794
+ Adds behavioral constraints and guidelines that the agent must follow.
1795
+
1796
+ ## Key behaviors
1797
+
1798
+ - Multiple \`RULE\` and \`RULES\` commitments are applied sequentially.
1799
+ - All rules are treated equally regardless of singular/plural form.
1800
+ - Rules define what the agent must or must not do.
1801
+
1802
+ ## Examples
1803
+
1804
+ \`\`\`book
1805
+ Customer Support Agent
1806
+
1807
+ PERSONA You are a helpful customer support representative
1808
+ RULE Always ask for clarification if the user's request is ambiguous
1809
+ RULE Be polite and professional in all interactions
1810
+ RULES Never provide medical or legal advice
1811
+ STYLE Maintain a friendly and helpful tone
1812
+ \`\`\`
1813
+
1814
+ \`\`\`book
1815
+ Educational Tutor
1816
+
1817
+ PERSONA You are a patient and knowledgeable tutor
1818
+ RULE Break down complex concepts into simple steps
1819
+ RULE Always encourage students and celebrate their progress
1820
+ RULE If you don't know something, admit it and suggest resources
1821
+ SAMPLE When explaining math: "Let's work through this step by step..."
1822
+ \`\`\`
1823
+ `);
1648
1824
  }
1649
1825
  applyToAgentModelRequirements(requirements, content) {
1650
1826
  const trimmedContent = content.trim();
@@ -1692,24 +1868,47 @@ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
1692
1868
  super(type);
1693
1869
  }
1694
1870
  /**
1695
- * Markdown documentation for SAMPLE/EXAMPLE commitment.
1871
+ * Short one-line description of SAMPLE/EXAMPLE.
1696
1872
  */
1697
1873
  get description() {
1698
- return [
1699
- `# ${this.type}`,
1700
- '',
1701
- 'Provides examples of how the agent should respond or behave in certain situations.',
1702
- '',
1703
- 'Effects on system message:',
1704
- '- Appends an "Example: ..." line to the system message.',
1705
- '',
1706
- 'Examples:',
1707
- '```book',
1708
- 'SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."',
1709
- 'EXAMPLE For code questions, always include working code snippets',
1710
- '```',
1711
- '',
1712
- ].join('\\n').replace(/\\\\n/g, '\\n');
1874
+ return 'Provide example responses to guide behavior.';
1875
+ }
1876
+ /**
1877
+ * Markdown documentation for SAMPLE/EXAMPLE commitment.
1878
+ */
1879
+ get documentation() {
1880
+ return spaceTrim(`
1881
+ # ${this.type}
1882
+
1883
+ Provides examples of how the agent should respond or behave in certain situations.
1884
+
1885
+ ## Key behaviors
1886
+
1887
+ - Multiple \`SAMPLE\` and \`EXAMPLE\` commitments are applied sequentially.
1888
+ - Both terms work identically and can be used interchangeably.
1889
+ - Examples help guide the agent's response patterns and style.
1890
+
1891
+ ## Examples
1892
+
1893
+ \`\`\`book
1894
+ Sales Assistant
1895
+
1896
+ PERSONA You are a knowledgeable sales representative
1897
+ SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
1898
+ SAMPLE For feature comparisons, create a clear comparison table
1899
+ RULE Always be honest about limitations
1900
+ \`\`\`
1901
+
1902
+ \`\`\`book
1903
+ Code Reviewer
1904
+
1905
+ PERSONA You are an experienced software engineer
1906
+ EXAMPLE For code questions, always include working code snippets
1907
+ EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
1908
+ RULE Explain the reasoning behind your suggestions
1909
+ STYLE Be constructive and encouraging in feedback
1910
+ \`\`\`
1911
+ `);
1713
1912
  }
1714
1913
  applyToAgentModelRequirements(requirements, content) {
1715
1914
  const trimmedContent = content.trim();
@@ -1757,24 +1956,47 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
1757
1956
  super('STYLE');
1758
1957
  }
1759
1958
  /**
1760
- * Markdown documentation for STYLE commitment.
1959
+ * Short one-line description of STYLE.
1761
1960
  */
1762
1961
  get description() {
1763
- return [
1764
- '# STYLE',
1765
- '',
1766
- 'Defines how the agent should format and present its responses (tone, writing style, formatting).',
1767
- '',
1768
- 'Effects on system message:',
1769
- '- Appends a "Style: ..." line to the system message.',
1770
- '',
1771
- 'Examples:',
1772
- '```book',
1773
- 'STYLE Write in a professional but friendly tone, use bullet points for lists',
1774
- 'STYLE Always provide code examples when explaining programming concepts',
1775
- '```',
1776
- '',
1777
- ].join('\n');
1962
+ return 'Control the tone and writing style of responses.';
1963
+ }
1964
+ /**
1965
+ * Markdown documentation for STYLE commitment.
1966
+ */
1967
+ get documentation() {
1968
+ return spaceTrim(`
1969
+ # STYLE
1970
+
1971
+ Defines how the agent should format and present its responses (tone, writing style, formatting).
1972
+
1973
+ ## Key behaviors
1974
+
1975
+ - Multiple \`STYLE\` commitments are applied sequentially.
1976
+ - Later style instructions can override earlier ones.
1977
+ - Style affects both tone and presentation format.
1978
+
1979
+ ## Examples
1980
+
1981
+ \`\`\`book
1982
+ Technical Writer
1983
+
1984
+ PERSONA You are a technical documentation expert
1985
+ STYLE Write in a professional but friendly tone, use bullet points for lists
1986
+ STYLE Always provide code examples when explaining programming concepts
1987
+ FORMAT Use markdown formatting with clear headings
1988
+ \`\`\`
1989
+
1990
+ \`\`\`book
1991
+ Creative Assistant
1992
+
1993
+ PERSONA You are a creative writing helper
1994
+ STYLE Be enthusiastic and encouraging in your responses
1995
+ STYLE Use vivid metaphors and analogies to explain concepts
1996
+ STYLE Keep responses conversational and engaging
1997
+ RULE Always maintain a positive and supportive tone
1998
+ \`\`\`
1999
+ `);
1778
2000
  }
1779
2001
  applyToAgentModelRequirements(requirements, content) {
1780
2002
  const trimmedContent = content.trim();
@@ -1809,24 +2031,42 @@ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
1809
2031
  super(type);
1810
2032
  }
1811
2033
  /**
1812
- * Markdown documentation available at runtime.
2034
+ * Short one-line description of a placeholder commitment.
1813
2035
  */
1814
2036
  get description() {
1815
- return [
1816
- `# ${this.type}`,
1817
- ``,
1818
- `This commitment is not yet fully implemented.`,
1819
- `Until it is, its content is appended 1:1 to the system message, preserving current behavior.`,
1820
- ``,
1821
- `- Status: Placeholder`,
1822
- `- Effect: Appends a line to the system message prefixed by the commitment type`,
1823
- ``,
1824
- `Example:`,
1825
- `\`\`\`book`,
1826
- `${this.type} Your content here`,
1827
- `\`\`\``,
1828
- ``,
1829
- ].join('\n');
2037
+ return 'Placeholder commitment that appends content verbatim to the system message.';
2038
+ }
2039
+ /**
2040
+ * Markdown documentation available at runtime.
2041
+ */
2042
+ get documentation() {
2043
+ return spaceTrim(`
2044
+ # ${this.type}
2045
+
2046
+ This commitment is not yet fully implemented.
2047
+
2048
+ ## Key behaviors
2049
+
2050
+ - Content is appended directly to the system message.
2051
+ - No special processing or validation is performed.
2052
+ - Behavior preserved until proper implementation is added.
2053
+
2054
+ ## Status
2055
+
2056
+ - **Status:** Placeholder implementation
2057
+ - **Effect:** Appends content prefixed by commitment type
2058
+ - **Future:** Will be replaced with specialized logic
2059
+
2060
+ ## Examples
2061
+
2062
+ \`\`\`book
2063
+ Example Agent
2064
+
2065
+ PERSONA You are a helpful assistant
2066
+ ${this.type} Your content here
2067
+ RULE Always be helpful
2068
+ \`\`\`
2069
+ `);
1830
2070
  }
1831
2071
  applyToAgentModelRequirements(requirements, content) {
1832
2072
  const trimmedContent = content.trim();
@@ -1959,7 +2199,7 @@ function parseAgentSourceWithCommitments(agentSource) {
1959
2199
  const fullContent = currentCommitment.contentLines.join('\n');
1960
2200
  commitments.push({
1961
2201
  type: currentCommitment.type,
1962
- content: spaceTrim$1(fullContent),
2202
+ content: spaceTrim(fullContent),
1963
2203
  originalLine: currentCommitment.originalStartLine,
1964
2204
  lineNumber: currentCommitment.startLineNumber,
1965
2205
  });
@@ -1995,7 +2235,7 @@ function parseAgentSourceWithCommitments(agentSource) {
1995
2235
  const fullContent = currentCommitment.contentLines.join('\n');
1996
2236
  commitments.push({
1997
2237
  type: currentCommitment.type,
1998
- content: spaceTrim$1(fullContent),
2238
+ content: spaceTrim(fullContent),
1999
2239
  originalLine: currentCommitment.originalStartLine,
2000
2240
  lineNumber: currentCommitment.startLineNumber,
2001
2241
  });
@@ -2089,7 +2329,7 @@ function validateBook(source) {
2089
2329
  *
2090
2330
  * @public exported from `@promptbook/core`
2091
2331
  */
2092
- const DEFAULT_BOOK = validateBook(spaceTrim(`
2332
+ const DEFAULT_BOOK = validateBook(spaceTrim$1(`
2093
2333
  AI Avatar
2094
2334
 
2095
2335
  PERSONA A friendly AI assistant that helps you with your tasks
@@ -2626,7 +2866,7 @@ function pipelineJsonToString(pipelineJson) {
2626
2866
  pipelineString += '\n\n';
2627
2867
  pipelineString += '```' + contentLanguage;
2628
2868
  pipelineString += '\n';
2629
- pipelineString += spaceTrim(content);
2869
+ pipelineString += spaceTrim$1(content);
2630
2870
  // <- TODO: [main] !!3 Escape
2631
2871
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
2632
2872
  pipelineString += '\n';
@@ -2720,7 +2960,7 @@ function checkSerializableAsJson(options) {
2720
2960
  }
2721
2961
  else if (typeof value === 'object') {
2722
2962
  if (value instanceof Date) {
2723
- throw new UnexpectedError(spaceTrim((block) => `
2963
+ throw new UnexpectedError(spaceTrim$1((block) => `
2724
2964
  \`${name}\` is Date
2725
2965
 
2726
2966
  Use \`string_date_iso8601\` instead
@@ -2739,7 +2979,7 @@ function checkSerializableAsJson(options) {
2739
2979
  throw new UnexpectedError(`${name} is RegExp`);
2740
2980
  }
2741
2981
  else if (value instanceof Error) {
2742
- throw new UnexpectedError(spaceTrim((block) => `
2982
+ throw new UnexpectedError(spaceTrim$1((block) => `
2743
2983
  \`${name}\` is unserialized Error
2744
2984
 
2745
2985
  Use function \`serializeError\`
@@ -2762,7 +3002,7 @@ function checkSerializableAsJson(options) {
2762
3002
  }
2763
3003
  catch (error) {
2764
3004
  assertsError(error);
2765
- throw new UnexpectedError(spaceTrim((block) => `
3005
+ throw new UnexpectedError(spaceTrim$1((block) => `
2766
3006
  \`${name}\` is not serializable
2767
3007
 
2768
3008
  ${block(error.stack || error.message)}
@@ -2794,7 +3034,7 @@ function checkSerializableAsJson(options) {
2794
3034
  }
2795
3035
  }
2796
3036
  else {
2797
- throw new UnexpectedError(spaceTrim((block) => `
3037
+ throw new UnexpectedError(spaceTrim$1((block) => `
2798
3038
  \`${name}\` is unknown type
2799
3039
 
2800
3040
  Additional message for \`${name}\`:
@@ -3081,7 +3321,7 @@ function validatePipeline(pipeline) {
3081
3321
  if (!(error instanceof PipelineLogicError)) {
3082
3322
  throw error;
3083
3323
  }
3084
- console.error(spaceTrim$1((block) => `
3324
+ console.error(spaceTrim((block) => `
3085
3325
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
3086
3326
 
3087
3327
  ${block(error.message)}
@@ -3108,7 +3348,7 @@ function validatePipeline_InnerFunction(pipeline) {
3108
3348
  })();
3109
3349
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
3110
3350
  // <- Note: [🚲]
3111
- throw new PipelineLogicError(spaceTrim$1((block) => `
3351
+ throw new PipelineLogicError(spaceTrim((block) => `
3112
3352
  Invalid promptbook URL "${pipeline.pipelineUrl}"
3113
3353
 
3114
3354
  ${block(pipelineIdentification)}
@@ -3116,7 +3356,7 @@ function validatePipeline_InnerFunction(pipeline) {
3116
3356
  }
3117
3357
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
3118
3358
  // <- Note: [🚲]
3119
- throw new PipelineLogicError(spaceTrim$1((block) => `
3359
+ throw new PipelineLogicError(spaceTrim((block) => `
3120
3360
  Invalid Promptbook Version "${pipeline.bookVersion}"
3121
3361
 
3122
3362
  ${block(pipelineIdentification)}
@@ -3125,7 +3365,7 @@ function validatePipeline_InnerFunction(pipeline) {
3125
3365
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
3126
3366
  if (!Array.isArray(pipeline.parameters)) {
3127
3367
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
3128
- throw new ParseError(spaceTrim$1((block) => `
3368
+ throw new ParseError(spaceTrim((block) => `
3129
3369
  Pipeline is valid JSON but with wrong structure
3130
3370
 
3131
3371
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -3136,7 +3376,7 @@ function validatePipeline_InnerFunction(pipeline) {
3136
3376
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
3137
3377
  if (!Array.isArray(pipeline.tasks)) {
3138
3378
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
3139
- throw new ParseError(spaceTrim$1((block) => `
3379
+ throw new ParseError(spaceTrim((block) => `
3140
3380
  Pipeline is valid JSON but with wrong structure
3141
3381
 
3142
3382
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -3162,7 +3402,7 @@ function validatePipeline_InnerFunction(pipeline) {
3162
3402
  // Note: Check each parameter individually
3163
3403
  for (const parameter of pipeline.parameters) {
3164
3404
  if (parameter.isInput && parameter.isOutput) {
3165
- throw new PipelineLogicError(spaceTrim$1((block) => `
3405
+ throw new PipelineLogicError(spaceTrim((block) => `
3166
3406
 
3167
3407
  Parameter \`{${parameter.name}}\` can not be both input and output
3168
3408
 
@@ -3173,7 +3413,7 @@ function validatePipeline_InnerFunction(pipeline) {
3173
3413
  if (!parameter.isInput &&
3174
3414
  !parameter.isOutput &&
3175
3415
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
3176
- throw new PipelineLogicError(spaceTrim$1((block) => `
3416
+ throw new PipelineLogicError(spaceTrim((block) => `
3177
3417
  Parameter \`{${parameter.name}}\` is created but not used
3178
3418
 
3179
3419
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -3185,7 +3425,7 @@ function validatePipeline_InnerFunction(pipeline) {
3185
3425
  }
3186
3426
  // Note: Testing that parameter is either input or result of some task
3187
3427
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
3188
- throw new PipelineLogicError(spaceTrim$1((block) => `
3428
+ throw new PipelineLogicError(spaceTrim((block) => `
3189
3429
  Parameter \`{${parameter.name}}\` is declared but not defined
3190
3430
 
3191
3431
  You can do one of these:
@@ -3201,14 +3441,14 @@ function validatePipeline_InnerFunction(pipeline) {
3201
3441
  // Note: Checking each task individually
3202
3442
  for (const task of pipeline.tasks) {
3203
3443
  if (definedParameters.has(task.resultingParameterName)) {
3204
- throw new PipelineLogicError(spaceTrim$1((block) => `
3444
+ throw new PipelineLogicError(spaceTrim((block) => `
3205
3445
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
3206
3446
 
3207
3447
  ${block(pipelineIdentification)}
3208
3448
  `));
3209
3449
  }
3210
3450
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
3211
- throw new PipelineLogicError(spaceTrim$1((block) => `
3451
+ throw new PipelineLogicError(spaceTrim((block) => `
3212
3452
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
3213
3453
 
3214
3454
  ${block(pipelineIdentification)}
@@ -3218,7 +3458,7 @@ function validatePipeline_InnerFunction(pipeline) {
3218
3458
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
3219
3459
  if (!task.format &&
3220
3460
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
3221
- throw new PipelineLogicError(spaceTrim$1((block) => `
3461
+ throw new PipelineLogicError(spaceTrim((block) => `
3222
3462
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
3223
3463
 
3224
3464
  ${block(pipelineIdentification)}
@@ -3226,7 +3466,7 @@ function validatePipeline_InnerFunction(pipeline) {
3226
3466
  }
3227
3467
  for (const joker of task.jokerParameterNames) {
3228
3468
  if (!task.dependentParameterNames.includes(joker)) {
3229
- throw new PipelineLogicError(spaceTrim$1((block) => `
3469
+ throw new PipelineLogicError(spaceTrim((block) => `
3230
3470
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
3231
3471
 
3232
3472
  ${block(pipelineIdentification)}
@@ -3237,21 +3477,21 @@ function validatePipeline_InnerFunction(pipeline) {
3237
3477
  if (task.expectations) {
3238
3478
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
3239
3479
  if (min !== undefined && max !== undefined && min > max) {
3240
- throw new PipelineLogicError(spaceTrim$1((block) => `
3480
+ throw new PipelineLogicError(spaceTrim((block) => `
3241
3481
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
3242
3482
 
3243
3483
  ${block(pipelineIdentification)}
3244
3484
  `));
3245
3485
  }
3246
3486
  if (min !== undefined && min < 0) {
3247
- throw new PipelineLogicError(spaceTrim$1((block) => `
3487
+ throw new PipelineLogicError(spaceTrim((block) => `
3248
3488
  Min expectation of ${unit} must be zero or positive
3249
3489
 
3250
3490
  ${block(pipelineIdentification)}
3251
3491
  `));
3252
3492
  }
3253
3493
  if (max !== undefined && max <= 0) {
3254
- throw new PipelineLogicError(spaceTrim$1((block) => `
3494
+ throw new PipelineLogicError(spaceTrim((block) => `
3255
3495
  Max expectation of ${unit} must be positive
3256
3496
 
3257
3497
  ${block(pipelineIdentification)}
@@ -3273,7 +3513,7 @@ function validatePipeline_InnerFunction(pipeline) {
3273
3513
  while (unresovedTasks.length > 0) {
3274
3514
  if (loopLimit-- < 0) {
3275
3515
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
3276
- throw new UnexpectedError(spaceTrim$1((block) => `
3516
+ throw new UnexpectedError(spaceTrim((block) => `
3277
3517
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
3278
3518
 
3279
3519
  ${block(pipelineIdentification)}
@@ -3283,7 +3523,7 @@ function validatePipeline_InnerFunction(pipeline) {
3283
3523
  if (currentlyResovedTasks.length === 0) {
3284
3524
  throw new PipelineLogicError(
3285
3525
  // TODO: [🐎] DRY
3286
- spaceTrim$1((block) => `
3526
+ spaceTrim((block) => `
3287
3527
 
3288
3528
  Can not resolve some parameters:
3289
3529
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -3447,7 +3687,7 @@ class SimplePipelineCollection {
3447
3687
  for (const pipeline of pipelines) {
3448
3688
  // TODO: [👠] DRY
3449
3689
  if (pipeline.pipelineUrl === undefined) {
3450
- throw new PipelineUrlError(spaceTrim$1(`
3690
+ throw new PipelineUrlError(spaceTrim(`
3451
3691
  Pipeline with name "${pipeline.title}" does not have defined URL
3452
3692
 
3453
3693
  File:
@@ -3469,7 +3709,7 @@ class SimplePipelineCollection {
3469
3709
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3470
3710
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3471
3711
  const existing = this.collection.get(pipeline.pipelineUrl);
3472
- throw new PipelineUrlError(spaceTrim$1(`
3712
+ throw new PipelineUrlError(spaceTrim(`
3473
3713
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
3474
3714
 
3475
3715
  Conflicting files:
@@ -3501,13 +3741,13 @@ class SimplePipelineCollection {
3501
3741
  const pipeline = this.collection.get(url);
3502
3742
  if (!pipeline) {
3503
3743
  if (this.listPipelines().length === 0) {
3504
- throw new NotFoundError(spaceTrim$1(`
3744
+ throw new NotFoundError(spaceTrim(`
3505
3745
  Pipeline with url "${url}" not found
3506
3746
 
3507
3747
  No pipelines available
3508
3748
  `));
3509
3749
  }
3510
- throw new NotFoundError(spaceTrim$1((block) => `
3750
+ throw new NotFoundError(spaceTrim((block) => `
3511
3751
  Pipeline with url "${url}" not found
3512
3752
 
3513
3753
  Available pipelines:
@@ -3637,7 +3877,7 @@ function createSubcollection(collection, predicate) {
3637
3877
  }
3638
3878
  async function getPipelineByUrl(url) {
3639
3879
  if (!predicate(url)) {
3640
- throw new NotFoundError(await spaceTrim$1(async (block) => `
3880
+ throw new NotFoundError(await spaceTrim(async (block) => `
3641
3881
  Promptbook with url "${url}" not found or not accessible
3642
3882
 
3643
3883
  Available promptbooks:
@@ -3672,7 +3912,7 @@ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"
3672
3912
  */
3673
3913
  class MissingToolsError extends Error {
3674
3914
  constructor(message) {
3675
- super(spaceTrim$1((block) => `
3915
+ super(spaceTrim((block) => `
3676
3916
  ${block(message)}
3677
3917
 
3678
3918
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -3841,7 +4081,7 @@ class LimitReachedError extends Error {
3841
4081
  */
3842
4082
  class NotYetImplementedError extends Error {
3843
4083
  constructor(message) {
3844
- super(spaceTrim$1((block) => `
4084
+ super(spaceTrim((block) => `
3845
4085
  ${block(message)}
3846
4086
 
3847
4087
  Note: This feature is not implemented yet but it will be soon.
@@ -3962,7 +4202,7 @@ function serializeError(error) {
3962
4202
  const { name, message, stack } = error;
3963
4203
  const { id } = error;
3964
4204
  if (!Object.keys(ALL_ERRORS).includes(name)) {
3965
- console.error(spaceTrim((block) => `
4205
+ console.error(spaceTrim$1((block) => `
3966
4206
 
3967
4207
  Cannot serialize error with name "${name}"
3968
4208
 
@@ -3995,7 +4235,7 @@ function jsonParse(value) {
3995
4235
  }
3996
4236
  else if (typeof value !== 'string') {
3997
4237
  console.error('Can not parse JSON from non-string value.', { text: value });
3998
- throw new Error(spaceTrim(`
4238
+ throw new Error(spaceTrim$1(`
3999
4239
  Can not parse JSON from non-string value.
4000
4240
 
4001
4241
  The value type: ${typeof value}
@@ -4009,7 +4249,7 @@ function jsonParse(value) {
4009
4249
  if (!(error instanceof Error)) {
4010
4250
  throw error;
4011
4251
  }
4012
- throw new Error(spaceTrim((block) => `
4252
+ throw new Error(spaceTrim$1((block) => `
4013
4253
  ${block(error.message)}
4014
4254
 
4015
4255
  The expected JSON text:
@@ -4062,7 +4302,7 @@ function deserializeError(error) {
4062
4302
  message = `${name}: ${message}`;
4063
4303
  }
4064
4304
  if (stack !== undefined && stack !== '') {
4065
- message = spaceTrim((block) => `
4305
+ message = spaceTrim$1((block) => `
4066
4306
  ${block(message)}
4067
4307
 
4068
4308
  Original stack trace:
@@ -4099,11 +4339,11 @@ function assertsTaskSuccessful(executionResult) {
4099
4339
  throw deserializeError(errors[0]);
4100
4340
  }
4101
4341
  else {
4102
- throw new PipelineExecutionError(spaceTrim$1((block) => `
4342
+ throw new PipelineExecutionError(spaceTrim((block) => `
4103
4343
  Multiple errors occurred during Promptbook execution
4104
4344
 
4105
4345
  ${block(errors
4106
- .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
4346
+ .map(({ name, stack, message }, index) => spaceTrim((block) => `
4107
4347
  ${name} ${index + 1}:
4108
4348
  ${block(stack || message)}
4109
4349
  `))
@@ -4473,7 +4713,7 @@ function extractVariablesFromJavascript(script) {
4473
4713
  }
4474
4714
  catch (error) {
4475
4715
  assertsError(error);
4476
- throw new ParseError(spaceTrim$1((block) => `
4716
+ throw new ParseError(spaceTrim((block) => `
4477
4717
  Can not extract variables from the script
4478
4718
  ${block(error.stack || error.message)}
4479
4719
 
@@ -4656,7 +4896,7 @@ const CsvFormatParser = {
4656
4896
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
4657
4897
  const csv = csvParse(value, settings);
4658
4898
  if (csv.errors.length !== 0) {
4659
- throw new CsvFormatError(spaceTrim((block) => `
4899
+ throw new CsvFormatError(spaceTrim$1((block) => `
4660
4900
  CSV parsing error
4661
4901
 
4662
4902
  Error(s) from CSV parsing:
@@ -4701,7 +4941,7 @@ const CsvFormatParser = {
4701
4941
  const { value, settings, mapCallback, onProgress } = options;
4702
4942
  const csv = csvParse(value, settings);
4703
4943
  if (csv.errors.length !== 0) {
4704
- throw new CsvFormatError(spaceTrim((block) => `
4944
+ throw new CsvFormatError(spaceTrim$1((block) => `
4705
4945
  CSV parsing error
4706
4946
 
4707
4947
  Error(s) from CSV parsing:
@@ -4911,7 +5151,7 @@ function mapAvailableToExpectedParameters(options) {
4911
5151
  }
4912
5152
  // Phase 2️⃣: Non-matching mapping
4913
5153
  if (expectedParameterNames.size !== availableParametersNames.size) {
4914
- throw new PipelineExecutionError(spaceTrim((block) => `
5154
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
4915
5155
  Can not map available parameters to expected parameters
4916
5156
 
4917
5157
  Mapped parameters:
@@ -4964,14 +5204,14 @@ class MultipleLlmExecutionTools {
4964
5204
  if (description === undefined) {
4965
5205
  return headLine;
4966
5206
  }
4967
- return spaceTrim((block) => `
5207
+ return spaceTrim$1((block) => `
4968
5208
  ${headLine}
4969
5209
 
4970
5210
  ${ /* <- Note: Indenting the description: */block(description)}
4971
5211
  `);
4972
5212
  })
4973
5213
  .join('\n\n');
4974
- return spaceTrim((block) => `
5214
+ return spaceTrim$1((block) => `
4975
5215
  Multiple LLM Providers:
4976
5216
 
4977
5217
  ${block(innerModelsTitlesAndDescriptions)}
@@ -5062,7 +5302,7 @@ class MultipleLlmExecutionTools {
5062
5302
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
5063
5303
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
5064
5304
  // 3) ...
5065
- spaceTrim((block) => `
5305
+ spaceTrim$1((block) => `
5066
5306
  All execution tools failed:
5067
5307
 
5068
5308
  ${block(errors
@@ -5075,7 +5315,7 @@ class MultipleLlmExecutionTools {
5075
5315
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\``);
5076
5316
  }
5077
5317
  else {
5078
- throw new PipelineExecutionError(spaceTrim((block) => `
5318
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
5079
5319
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
5080
5320
 
5081
5321
  Available \`LlmExecutionTools\`:
@@ -5108,7 +5348,7 @@ class MultipleLlmExecutionTools {
5108
5348
  */
5109
5349
  function joinLlmExecutionTools(...llmExecutionTools) {
5110
5350
  if (llmExecutionTools.length === 0) {
5111
- const warningMessage = spaceTrim(`
5351
+ const warningMessage = spaceTrim$1(`
5112
5352
  You have not provided any \`LlmExecutionTools\`
5113
5353
  This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
5114
5354
 
@@ -5820,7 +6060,7 @@ function validatePromptResult(options) {
5820
6060
  }
5821
6061
  catch (error) {
5822
6062
  keepUnused(error);
5823
- throw new ExpectError(spaceTrim$1((block) => `
6063
+ throw new ExpectError(spaceTrim((block) => `
5824
6064
  Expected valid JSON string
5825
6065
 
5826
6066
  The expected JSON text:
@@ -5885,7 +6125,7 @@ async function executeAttempts(options) {
5885
6125
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
5886
6126
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
5887
6127
  if (isJokerAttempt && !jokerParameterName) {
5888
- throw new UnexpectedError(spaceTrim$1((block) => `
6128
+ throw new UnexpectedError(spaceTrim((block) => `
5889
6129
  Joker not found in attempt ${attemptIndex}
5890
6130
 
5891
6131
  ${block(pipelineIdentification)}
@@ -5896,7 +6136,7 @@ async function executeAttempts(options) {
5896
6136
  $ongoingTaskResult.$expectError = null;
5897
6137
  if (isJokerAttempt) {
5898
6138
  if (parameters[jokerParameterName] === undefined) {
5899
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6139
+ throw new PipelineExecutionError(spaceTrim((block) => `
5900
6140
  Joker parameter {${jokerParameterName}} not defined
5901
6141
 
5902
6142
  ${block(pipelineIdentification)}
@@ -5954,7 +6194,7 @@ async function executeAttempts(options) {
5954
6194
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
5955
6195
  break variant;
5956
6196
  case 'EMBEDDING':
5957
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6197
+ throw new PipelineExecutionError(spaceTrim((block) => `
5958
6198
  Embedding model can not be used in pipeline
5959
6199
 
5960
6200
  This should be catched during parsing
@@ -5965,7 +6205,7 @@ async function executeAttempts(options) {
5965
6205
  break variant;
5966
6206
  // <- case [🤖]:
5967
6207
  default:
5968
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6208
+ throw new PipelineExecutionError(spaceTrim((block) => `
5969
6209
  Unknown model variant "${task.modelRequirements.modelVariant}"
5970
6210
 
5971
6211
  ${block(pipelineIdentification)}
@@ -5976,14 +6216,14 @@ async function executeAttempts(options) {
5976
6216
  break;
5977
6217
  case 'SCRIPT_TASK':
5978
6218
  if (arrayableToArray(tools.script).length === 0) {
5979
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6219
+ throw new PipelineExecutionError(spaceTrim((block) => `
5980
6220
  No script execution tools are available
5981
6221
 
5982
6222
  ${block(pipelineIdentification)}
5983
6223
  `));
5984
6224
  }
5985
6225
  if (!task.contentLanguage) {
5986
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6226
+ throw new PipelineExecutionError(spaceTrim((block) => `
5987
6227
  Script language is not defined for SCRIPT TASK "${task.name}"
5988
6228
 
5989
6229
  ${block(pipelineIdentification)}
@@ -6014,7 +6254,7 @@ async function executeAttempts(options) {
6014
6254
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6015
6255
  }
6016
6256
  else {
6017
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6257
+ throw new PipelineExecutionError(spaceTrim((block) => `
6018
6258
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6019
6259
 
6020
6260
  ${block(pipelineIdentification)}
@@ -6028,7 +6268,7 @@ async function executeAttempts(options) {
6028
6268
  break taskType;
6029
6269
  case 'DIALOG_TASK':
6030
6270
  if (tools.userInterface === undefined) {
6031
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6271
+ throw new PipelineExecutionError(spaceTrim((block) => `
6032
6272
  User interface tools are not available
6033
6273
 
6034
6274
  ${block(pipelineIdentification)}
@@ -6046,7 +6286,7 @@ async function executeAttempts(options) {
6046
6286
  break taskType;
6047
6287
  // <- case: [🅱]
6048
6288
  default:
6049
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6289
+ throw new PipelineExecutionError(spaceTrim((block) => `
6050
6290
  Unknown execution type "${task.taskType}"
6051
6291
 
6052
6292
  ${block(pipelineIdentification)}
@@ -6137,7 +6377,7 @@ async function executeAttempts(options) {
6137
6377
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6138
6378
  // Note: Create a summary of all failures
6139
6379
  const failuresSummary = $ongoingTaskResult.$failedResults
6140
- .map((failure) => spaceTrim$1((block) => {
6380
+ .map((failure) => spaceTrim((block) => {
6141
6381
  var _a, _b;
6142
6382
  return `
6143
6383
  Attempt ${failure.attemptIndex + 1}:
@@ -6147,14 +6387,14 @@ async function executeAttempts(options) {
6147
6387
  Result:
6148
6388
  ${block(failure.result === null
6149
6389
  ? 'null'
6150
- : spaceTrim$1(failure.result)
6390
+ : spaceTrim(failure.result)
6151
6391
  .split('\n')
6152
6392
  .map((line) => `> ${line}`)
6153
6393
  .join('\n'))}
6154
6394
  `;
6155
6395
  }))
6156
6396
  .join('\n\n---\n\n');
6157
- throw new PipelineExecutionError(spaceTrim$1((block) => {
6397
+ throw new PipelineExecutionError(spaceTrim((block) => {
6158
6398
  var _a;
6159
6399
  return `
6160
6400
  LLM execution failed ${maxExecutionAttempts}x
@@ -6174,7 +6414,7 @@ async function executeAttempts(options) {
6174
6414
  }
6175
6415
  }
6176
6416
  if ($ongoingTaskResult.$resultString === null) {
6177
- throw new UnexpectedError(spaceTrim$1((block) => `
6417
+ throw new UnexpectedError(spaceTrim((block) => `
6178
6418
  Something went wrong and prompt result is null
6179
6419
 
6180
6420
  ${block(pipelineIdentification)}
@@ -6201,7 +6441,7 @@ async function executeFormatSubvalues(options) {
6201
6441
  return /* not await */ executeAttempts(options);
6202
6442
  }
6203
6443
  if (jokerParameterNames.length !== 0) {
6204
- throw new UnexpectedError(spaceTrim((block) => `
6444
+ throw new UnexpectedError(spaceTrim$1((block) => `
6205
6445
  JOKER parameters are not supported together with FOREACH command
6206
6446
 
6207
6447
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6214,7 +6454,7 @@ async function executeFormatSubvalues(options) {
6214
6454
  if (formatDefinition === undefined) {
6215
6455
  throw new UnexpectedError(
6216
6456
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6217
- spaceTrim((block) => `
6457
+ spaceTrim$1((block) => `
6218
6458
  Unsupported format "${task.foreach.formatName}"
6219
6459
 
6220
6460
  Available formats:
@@ -6231,7 +6471,7 @@ async function executeFormatSubvalues(options) {
6231
6471
  if (subvalueParser === undefined) {
6232
6472
  throw new UnexpectedError(
6233
6473
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6234
- spaceTrim((block) => `
6474
+ spaceTrim$1((block) => `
6235
6475
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6236
6476
 
6237
6477
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6271,7 +6511,7 @@ async function executeFormatSubvalues(options) {
6271
6511
  if (!(error instanceof PipelineExecutionError)) {
6272
6512
  throw error;
6273
6513
  }
6274
- const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
6514
+ const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6275
6515
  ${error.message}
6276
6516
 
6277
6517
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6295,7 +6535,7 @@ async function executeFormatSubvalues(options) {
6295
6535
  ...options,
6296
6536
  priority: priority + index,
6297
6537
  parameters: allSubparameters,
6298
- pipelineIdentification: spaceTrim((block) => `
6538
+ pipelineIdentification: spaceTrim$1((block) => `
6299
6539
  ${block(pipelineIdentification)}
6300
6540
  Subparameter index: ${index}
6301
6541
  `),
@@ -6304,7 +6544,7 @@ async function executeFormatSubvalues(options) {
6304
6544
  }
6305
6545
  catch (error) {
6306
6546
  if (length > BIG_DATASET_TRESHOLD) {
6307
- console.error(spaceTrim((block) => `
6547
+ console.error(spaceTrim$1((block) => `
6308
6548
  ${error.message}
6309
6549
 
6310
6550
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6482,7 +6722,7 @@ async function getReservedParametersForTask(options) {
6482
6722
  // Note: Doublecheck that ALL reserved parameters are defined:
6483
6723
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6484
6724
  if (reservedParameters[parameterName] === undefined) {
6485
- throw new UnexpectedError(spaceTrim$1((block) => `
6725
+ throw new UnexpectedError(spaceTrim((block) => `
6486
6726
  Reserved parameter {${parameterName}} is not defined
6487
6727
 
6488
6728
  ${block(pipelineIdentification)}
@@ -6508,7 +6748,7 @@ async function executeTask(options) {
6508
6748
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6509
6749
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6510
6750
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6511
- throw new UnexpectedError(spaceTrim$1((block) => `
6751
+ throw new UnexpectedError(spaceTrim((block) => `
6512
6752
  Dependent parameters are not consistent with used parameters:
6513
6753
 
6514
6754
  Dependent parameters:
@@ -6552,7 +6792,7 @@ async function executeTask(options) {
6552
6792
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
6553
6793
  // Houston, we have a problem
6554
6794
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
6555
- throw new UnexpectedError(spaceTrim$1((block) => `
6795
+ throw new UnexpectedError(spaceTrim((block) => `
6556
6796
  Parameter \`{${parameterName}}\` is NOT defined
6557
6797
  BUT used in task "${currentTask.title || currentTask.name}"
6558
6798
 
@@ -6620,7 +6860,7 @@ function filterJustOutputParameters(options) {
6620
6860
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
6621
6861
  if (parametersToPass[parameter.name] === undefined) {
6622
6862
  // [4]
6623
- $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6863
+ $warnings.push(new PipelineExecutionError(spaceTrim((block) => `
6624
6864
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
6625
6865
 
6626
6866
  ${block(pipelineIdentification)}
@@ -6705,7 +6945,7 @@ async function executePipeline(options) {
6705
6945
  for (const parameterName of Object.keys(inputParameters)) {
6706
6946
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
6707
6947
  if (parameter === undefined) {
6708
- warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6948
+ warnings.push(new PipelineExecutionError(spaceTrim((block) => `
6709
6949
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
6710
6950
 
6711
6951
  ${block(pipelineIdentification)}
@@ -6720,7 +6960,7 @@ async function executePipeline(options) {
6720
6960
  // TODO: [🧠] This should be also non-critical error
6721
6961
  return exportJson({
6722
6962
  name: 'pipelineExecutorResult',
6723
- message: spaceTrim$1((block) => `
6963
+ message: spaceTrim((block) => `
6724
6964
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
6725
6965
 
6726
6966
  ${block(pipelineIdentification)}
@@ -6729,7 +6969,7 @@ async function executePipeline(options) {
6729
6969
  value: {
6730
6970
  isSuccessful: false,
6731
6971
  errors: [
6732
- new PipelineExecutionError(spaceTrim$1((block) => `
6972
+ new PipelineExecutionError(spaceTrim((block) => `
6733
6973
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
6734
6974
 
6735
6975
  ${block(pipelineIdentification)}
@@ -6756,7 +6996,7 @@ async function executePipeline(options) {
6756
6996
  while (unresovedTasks.length > 0) {
6757
6997
  if (loopLimit-- < 0) {
6758
6998
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
6759
- throw new UnexpectedError(spaceTrim$1((block) => `
6999
+ throw new UnexpectedError(spaceTrim((block) => `
6760
7000
  Loop limit reached during resolving parameters pipeline execution
6761
7001
 
6762
7002
  ${block(pipelineIdentification)}
@@ -6766,7 +7006,7 @@ async function executePipeline(options) {
6766
7006
  if (!currentTask && resolving.length === 0) {
6767
7007
  throw new UnexpectedError(
6768
7008
  // TODO: [🐎] DRY
6769
- spaceTrim$1((block) => `
7009
+ spaceTrim((block) => `
6770
7010
  Can not resolve some parameters:
6771
7011
 
6772
7012
  ${block(pipelineIdentification)}
@@ -6806,7 +7046,7 @@ async function executePipeline(options) {
6806
7046
  tools,
6807
7047
  onProgress(newOngoingResult) {
6808
7048
  if (isReturned) {
6809
- throw new UnexpectedError(spaceTrim$1((block) => `
7049
+ throw new UnexpectedError(spaceTrim((block) => `
6810
7050
  Can not call \`onProgress\` after pipeline execution is finished
6811
7051
 
6812
7052
  ${block(pipelineIdentification)}
@@ -6822,7 +7062,7 @@ async function executePipeline(options) {
6822
7062
  }
6823
7063
  },
6824
7064
  $executionReport: executionReport,
6825
- pipelineIdentification: spaceTrim$1((block) => `
7065
+ pipelineIdentification: spaceTrim((block) => `
6826
7066
  ${block(pipelineIdentification)}
6827
7067
  Task name: ${currentTask.name}
6828
7068
  Task title: ${currentTask.title}
@@ -6931,7 +7171,7 @@ function createPipelineExecutor(options) {
6931
7171
  preparedPipeline = pipeline;
6932
7172
  }
6933
7173
  else if (isNotPreparedWarningSuppressed !== true) {
6934
- console.warn(spaceTrim$1((block) => `
7174
+ console.warn(spaceTrim((block) => `
6935
7175
  Pipeline is not prepared
6936
7176
 
6937
7177
  ${block(pipelineIdentification)}
@@ -6955,7 +7195,7 @@ function createPipelineExecutor(options) {
6955
7195
  inputParameters,
6956
7196
  tools,
6957
7197
  onProgress,
6958
- pipelineIdentification: spaceTrim$1((block) => `
7198
+ pipelineIdentification: spaceTrim((block) => `
6959
7199
  ${block(pipelineIdentification)}
6960
7200
  ${runCount === 1 ? '' : `Run #${runCount}`}
6961
7201
  `),
@@ -7366,14 +7606,14 @@ function $registeredScrapersMessage(availableScrapers) {
7366
7606
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
7367
7607
  });
7368
7608
  if (metadata.length === 0) {
7369
- return spaceTrim(`
7609
+ return spaceTrim$1(`
7370
7610
  **No scrapers are available**
7371
7611
 
7372
7612
  This is a unexpected behavior, you are probably using some broken version of Promptbook
7373
7613
  At least there should be available the metadata of the scrapers
7374
7614
  `);
7375
7615
  }
7376
- return spaceTrim((block) => `
7616
+ return spaceTrim$1((block) => `
7377
7617
  Available scrapers are:
7378
7618
  ${block(metadata
7379
7619
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -7718,7 +7958,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
7718
7958
  const fileExtension = getFileExtension(filename);
7719
7959
  const mimeType = extensionToMimeType(fileExtension || '');
7720
7960
  if (!(await isFileExisting(filename, tools.fs))) {
7721
- throw new NotFoundError(spaceTrim((block) => `
7961
+ throw new NotFoundError(spaceTrim$1((block) => `
7722
7962
  Can not make source handler for file which does not exist:
7723
7963
 
7724
7964
  File:
@@ -7805,7 +8045,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
7805
8045
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
7806
8046
  break;
7807
8047
  }
7808
- console.warn(spaceTrim((block) => `
8048
+ console.warn(spaceTrim$1((block) => `
7809
8049
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
7810
8050
 
7811
8051
  The source:
@@ -7821,7 +8061,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
7821
8061
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7822
8062
  }
7823
8063
  if (partialPieces === null) {
7824
- throw new KnowledgeScrapeError(spaceTrim((block) => `
8064
+ throw new KnowledgeScrapeError(spaceTrim$1((block) => `
7825
8065
  Cannot scrape knowledge
7826
8066
 
7827
8067
  The source:
@@ -7900,7 +8140,7 @@ async function prepareTasks(pipeline, tools, options) {
7900
8140
  if (task.taskType === 'PROMPT_TASK' &&
7901
8141
  knowledgePiecesCount > 0 &&
7902
8142
  !dependentParameterNames.includes('knowledge')) {
7903
- preparedContent = spaceTrim$1(`
8143
+ preparedContent = spaceTrim(`
7904
8144
  {content}
7905
8145
 
7906
8146
  ## Knowledge
@@ -8159,7 +8399,7 @@ const knowledgeCommandParser = {
8159
8399
  */
8160
8400
  parse(input) {
8161
8401
  const { args } = input;
8162
- const knowledgeSourceContent = spaceTrim(args[0] || '');
8402
+ const knowledgeSourceContent = spaceTrim$1(args[0] || '');
8163
8403
  if (knowledgeSourceContent === '') {
8164
8404
  throw new ParseError(`Source is not defined`);
8165
8405
  }
@@ -8303,7 +8543,7 @@ const sectionCommandParser = {
8303
8543
  normalized = normalized.split('DIALOGUE').join('DIALOG');
8304
8544
  const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
8305
8545
  if (taskTypes.length !== 1) {
8306
- throw new ParseError(spaceTrim((block) => `
8546
+ throw new ParseError(spaceTrim$1((block) => `
8307
8547
  Unknown section type "${normalized}"
8308
8548
 
8309
8549
  Supported section types are:
@@ -8323,7 +8563,7 @@ const sectionCommandParser = {
8323
8563
  */
8324
8564
  $applyToTaskJson(command, $taskJson, $pipelineJson) {
8325
8565
  if ($taskJson.isSectionTypeSet === true) {
8326
- throw new ParseError(spaceTrim(`
8566
+ throw new ParseError(spaceTrim$1(`
8327
8567
  Section type is already defined in the section.
8328
8568
  It can be defined only once.
8329
8569
  `));
@@ -8671,7 +8911,7 @@ const expectCommandParser = {
8671
8911
  /**
8672
8912
  * Description of the FORMAT command
8673
8913
  */
8674
- description: spaceTrim(`
8914
+ description: spaceTrim$1(`
8675
8915
  Expect command describes the desired output of the task *(after post-processing)*
8676
8916
  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.
8677
8917
  `),
@@ -8745,7 +8985,7 @@ const expectCommandParser = {
8745
8985
  }
8746
8986
  catch (error) {
8747
8987
  assertsError(error);
8748
- throw new ParseError(spaceTrim((block) => `
8988
+ throw new ParseError(spaceTrim$1((block) => `
8749
8989
  Invalid FORMAT command
8750
8990
  ${block(error.message)}:
8751
8991
  `));
@@ -8930,7 +9170,7 @@ function validateParameterName(parameterName) {
8930
9170
  if (!(error instanceof ParseError)) {
8931
9171
  throw error;
8932
9172
  }
8933
- throw new ParseError(spaceTrim((block) => `
9173
+ throw new ParseError(spaceTrim$1((block) => `
8934
9174
  ${block(error.message)}
8935
9175
 
8936
9176
  Tried to validate parameter name:
@@ -8989,7 +9229,7 @@ const foreachCommandParser = {
8989
9229
  const assignSign = args[3];
8990
9230
  const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
8991
9231
  if (formatDefinition === undefined) {
8992
- throw new ParseError(spaceTrim((block) => `
9232
+ throw new ParseError(spaceTrim$1((block) => `
8993
9233
  Unsupported format "${formatName}"
8994
9234
 
8995
9235
  Available formats:
@@ -9001,7 +9241,7 @@ const foreachCommandParser = {
9001
9241
  }
9002
9242
  const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
9003
9243
  if (subvalueParser === undefined) {
9004
- throw new ParseError(spaceTrim((block) => `
9244
+ throw new ParseError(spaceTrim$1((block) => `
9005
9245
  Unsupported subformat name "${subformatName}" for format "${formatName}"
9006
9246
 
9007
9247
  Available subformat names for format "${formatDefinition.formatName}":
@@ -9049,7 +9289,7 @@ const foreachCommandParser = {
9049
9289
  outputSubparameterName = 'newLine';
9050
9290
  }
9051
9291
  else {
9052
- throw new ParseError(spaceTrim(`
9292
+ throw new ParseError(spaceTrim$1(`
9053
9293
  FOREACH ${formatName} ${subformatName} must specify output subparameter
9054
9294
 
9055
9295
  Correct example:
@@ -9125,7 +9365,7 @@ const formatCommandParser = {
9125
9365
  /**
9126
9366
  * Description of the FORMAT command
9127
9367
  */
9128
- description: spaceTrim(`
9368
+ description: spaceTrim$1(`
9129
9369
  Format command describes the desired output of the task (after post-processing)
9130
9370
  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.
9131
9371
  `),
@@ -9497,7 +9737,7 @@ const formfactorCommandParser = {
9497
9737
  const formfactorNameCandidate = args[0].toUpperCase();
9498
9738
  const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
9499
9739
  if (formfactor === undefined) {
9500
- throw new ParseError(spaceTrim((block) => `
9740
+ throw new ParseError(spaceTrim$1((block) => `
9501
9741
  Unknown formfactor name "${formfactorNameCandidate}"
9502
9742
 
9503
9743
  Available formfactors:
@@ -9516,7 +9756,7 @@ const formfactorCommandParser = {
9516
9756
  */
9517
9757
  $applyToPipelineJson(command, $pipelineJson) {
9518
9758
  if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
9519
- throw new ParseError(spaceTrim(`
9759
+ throw new ParseError(spaceTrim$1(`
9520
9760
  Redefinition of \`FORMFACTOR\` in the pipeline head
9521
9761
 
9522
9762
  You have used:
@@ -9659,7 +9899,7 @@ const modelCommandParser = {
9659
9899
  */
9660
9900
  parse(input) {
9661
9901
  const { args, normalized } = input;
9662
- const availableVariantsMessage = spaceTrim((block) => `
9902
+ const availableVariantsMessage = spaceTrim$1((block) => `
9663
9903
  Available variants are:
9664
9904
  ${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
9665
9905
  `);
@@ -9681,14 +9921,14 @@ const modelCommandParser = {
9681
9921
  // <- Note: [🤖]
9682
9922
  }
9683
9923
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
9684
- spaceTrim((block) => `
9924
+ spaceTrim$1((block) => `
9685
9925
  Embedding model can not be used in pipeline
9686
9926
 
9687
9927
  ${block(availableVariantsMessage)}
9688
9928
  `);
9689
9929
  }
9690
9930
  else {
9691
- throw new ParseError(spaceTrim((block) => `
9931
+ throw new ParseError(spaceTrim$1((block) => `
9692
9932
  Unknown model variant in command:
9693
9933
 
9694
9934
  ${block(availableVariantsMessage)}
@@ -9703,7 +9943,7 @@ const modelCommandParser = {
9703
9943
  };
9704
9944
  }
9705
9945
  else {
9706
- throw new ParseError(spaceTrim((block) => `
9946
+ throw new ParseError(spaceTrim$1((block) => `
9707
9947
  Unknown model key in command.
9708
9948
 
9709
9949
  Supported model keys are:
@@ -9730,7 +9970,7 @@ const modelCommandParser = {
9730
9970
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
9731
9971
  }
9732
9972
  else {
9733
- throw new ParseError(spaceTrim(`
9973
+ throw new ParseError(spaceTrim$1(`
9734
9974
  Redefinition of \`MODEL ${command.key}\` in the pipeline head
9735
9975
 
9736
9976
  You have used:
@@ -9762,7 +10002,7 @@ const modelCommandParser = {
9762
10002
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
9763
10003
  }
9764
10004
  else {
9765
- throw new ParseError(spaceTrim(`
10005
+ throw new ParseError(spaceTrim$1(`
9766
10006
  Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
9767
10007
 
9768
10008
  You have used:
@@ -9772,7 +10012,7 @@ const modelCommandParser = {
9772
10012
  }
9773
10013
  }
9774
10014
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
9775
- console.log(spaceTrim(`
10015
+ console.log(spaceTrim$1(`
9776
10016
  Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
9777
10017
 
9778
10018
  In pipeline head:
@@ -9855,7 +10095,7 @@ const parameterCommandParser = {
9855
10095
  // <- TODO: When [🥶] fixed, change to:
9856
10096
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
9857
10097
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
9858
- throw new ParseError(spaceTrim((block) => `
10098
+ throw new ParseError(spaceTrim$1((block) => `
9859
10099
  Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
9860
10100
 
9861
10101
  The description:
@@ -10037,7 +10277,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
10037
10277
  persona.description = personaDescription;
10038
10278
  return;
10039
10279
  }
10040
- console.warn(spaceTrim(`
10280
+ console.warn(spaceTrim$1(`
10041
10281
 
10042
10282
  Persona "${personaName}" is defined multiple times with different description:
10043
10283
 
@@ -10048,7 +10288,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
10048
10288
  ${personaDescription}
10049
10289
 
10050
10290
  `));
10051
- persona.description += spaceTrim('\n\n' + personaDescription);
10291
+ persona.description += spaceTrim$1('\n\n' + personaDescription);
10052
10292
  }
10053
10293
 
10054
10294
  /**
@@ -10413,7 +10653,7 @@ const COMMANDS = [
10413
10653
  function getParserForCommand(command) {
10414
10654
  const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
10415
10655
  if (commandParser === undefined) {
10416
- throw new UnexpectedError(spaceTrim$1((block) => `
10656
+ throw new UnexpectedError(spaceTrim((block) => `
10417
10657
  Command ${command.type} parser is not found
10418
10658
 
10419
10659
  ${block(JSON.stringify(command, null, 4)
@@ -10489,7 +10729,7 @@ function parseCommand(raw, usagePlace) {
10489
10729
  .map(removeMarkdownFormatting)
10490
10730
  .map((item) => item.trim());
10491
10731
  if (items.length === 0 || items[0] === '') {
10492
- throw new ParseError(spaceTrim$1((block) => `
10732
+ throw new ParseError(spaceTrim((block) => `
10493
10733
  Malformed command:
10494
10734
  - ${raw}
10495
10735
 
@@ -10525,7 +10765,7 @@ function parseCommand(raw, usagePlace) {
10525
10765
  return command;
10526
10766
  }
10527
10767
  }
10528
- throw new ParseError(spaceTrim$1((block) => `
10768
+ throw new ParseError(spaceTrim((block) => `
10529
10769
  Malformed or unknown command:
10530
10770
  - ${raw}
10531
10771
 
@@ -10576,7 +10816,7 @@ function parseCommandVariant(input) {
10576
10816
  if (!(error instanceof ParseError)) {
10577
10817
  throw error;
10578
10818
  }
10579
- throw new ParseError(spaceTrim$1((block) => `
10819
+ throw new ParseError(spaceTrim((block) => `
10580
10820
  Invalid ${commandName} command:
10581
10821
 
10582
10822
  Your command:
@@ -10850,7 +11090,7 @@ const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
10850
11090
  * @public exported from `@promptbook/markdown-utils`
10851
11091
  */
10852
11092
  function removeMarkdownComments(content) {
10853
- return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
11093
+ return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
10854
11094
  }
10855
11095
 
10856
11096
  /**
@@ -10861,7 +11101,7 @@ function removeMarkdownComments(content) {
10861
11101
  */
10862
11102
  function isFlatPipeline(pipelineString) {
10863
11103
  pipelineString = removeMarkdownComments(pipelineString);
10864
- pipelineString = spaceTrim(pipelineString);
11104
+ pipelineString = spaceTrim$1(pipelineString);
10865
11105
  const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
10866
11106
  //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
10867
11107
  const isBacktickBlockUsed = pipelineString.includes('```');
@@ -10899,19 +11139,19 @@ function deflatePipeline(pipelineString) {
10899
11139
  returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
10900
11140
  pipelineStringLines.push(potentialReturnStatement);
10901
11141
  }
10902
- const prompt = spaceTrim(pipelineStringLines.join('\n'));
11142
+ const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
10903
11143
  let quotedPrompt;
10904
11144
  if (prompt.split('\n').length <= 1) {
10905
11145
  quotedPrompt = `> ${prompt}`;
10906
11146
  }
10907
11147
  else {
10908
- quotedPrompt = spaceTrim((block) => `
11148
+ quotedPrompt = spaceTrim$1((block) => `
10909
11149
  \`\`\`
10910
11150
  ${block(prompt.split('`').join('\\`'))}
10911
11151
  \`\`\`
10912
11152
  `);
10913
11153
  }
10914
- pipelineString = validatePipelineString(spaceTrim((block) => `
11154
+ pipelineString = validatePipelineString(spaceTrim$1((block) => `
10915
11155
  # ${DEFAULT_BOOK_TITLE}
10916
11156
 
10917
11157
  ## Prompt
@@ -10975,7 +11215,7 @@ function extractAllListItemsFromMarkdown(markdown) {
10975
11215
  function extractOneBlockFromMarkdown(markdown) {
10976
11216
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
10977
11217
  if (codeBlocks.length !== 1) {
10978
- throw new ParseError(spaceTrim((block) => `
11218
+ throw new ParseError(spaceTrim$1((block) => `
10979
11219
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
10980
11220
 
10981
11221
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -11000,7 +11240,7 @@ function parseMarkdownSection(value) {
11000
11240
  }
11001
11241
  const title = lines[0].replace(/^#+\s*/, '');
11002
11242
  const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
11003
- const content = spaceTrim(lines.slice(1).join('\n'));
11243
+ const content = spaceTrim$1(lines.slice(1).join('\n'));
11004
11244
  if (level < 1 || level > 6) {
11005
11245
  throw new ParseError('Markdown section must have heading level between 1 and 6');
11006
11246
  }
@@ -11028,7 +11268,7 @@ function splitMarkdownIntoSections(markdown) {
11028
11268
  if (buffer.length === 0) {
11029
11269
  return;
11030
11270
  }
11031
- let section = spaceTrim(buffer.join('\n'));
11271
+ let section = spaceTrim$1(buffer.join('\n'));
11032
11272
  if (section === '') {
11033
11273
  return;
11034
11274
  }
@@ -11103,7 +11343,7 @@ function flattenMarkdown(markdown) {
11103
11343
  flattenedMarkdown += `## ${title}` + `\n\n`;
11104
11344
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
11105
11345
  }
11106
- return spaceTrim(flattenedMarkdown);
11346
+ return spaceTrim$1(flattenedMarkdown);
11107
11347
  }
11108
11348
  /**
11109
11349
  * TODO: [🏛] This can be part of markdown builder
@@ -11165,7 +11405,7 @@ function parsePipeline(pipelineString) {
11165
11405
  if (pipelineString.startsWith('#!')) {
11166
11406
  const [shebangLine, ...restLines] = pipelineString.split('\n');
11167
11407
  if (!(shebangLine || '').includes('ptbk')) {
11168
- throw new ParseError(spaceTrim$1((block) => `
11408
+ throw new ParseError(spaceTrim((block) => `
11169
11409
  It seems that you try to parse a book file which has non-standard shebang line for book files:
11170
11410
  Shebang line must contain 'ptbk'
11171
11411
 
@@ -11181,7 +11421,7 @@ function parsePipeline(pipelineString) {
11181
11421
  pipelineString = validatePipelineString(restLines.join('\n'));
11182
11422
  }
11183
11423
  pipelineString = removeMarkdownComments(pipelineString);
11184
- pipelineString = spaceTrim$1(pipelineString);
11424
+ pipelineString = spaceTrim(pipelineString);
11185
11425
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
11186
11426
  pipelineString = deflatePipeline(pipelineString);
11187
11427
  // ==============
@@ -11193,7 +11433,7 @@ function parsePipeline(pipelineString) {
11193
11433
  // ==============
11194
11434
  // Note: 1️⃣◽4️⃣ Check markdown structure
11195
11435
  if (pipelineHead === undefined) {
11196
- throw new UnexpectedError(spaceTrim$1((block) => `
11436
+ throw new UnexpectedError(spaceTrim((block) => `
11197
11437
  Pipeline head is not defined
11198
11438
 
11199
11439
  ${block(getPipelineIdentification())}
@@ -11202,7 +11442,7 @@ function parsePipeline(pipelineString) {
11202
11442
  `));
11203
11443
  }
11204
11444
  if (pipelineHead.level !== 1) {
11205
- throw new UnexpectedError(spaceTrim$1((block) => `
11445
+ throw new UnexpectedError(spaceTrim((block) => `
11206
11446
  Pipeline head is not h1
11207
11447
 
11208
11448
  ${block(getPipelineIdentification())}
@@ -11211,7 +11451,7 @@ function parsePipeline(pipelineString) {
11211
11451
  `));
11212
11452
  }
11213
11453
  if (!pipelineSections.every((section) => section.level === 2)) {
11214
- throw new UnexpectedError(spaceTrim$1((block) => `
11454
+ throw new UnexpectedError(spaceTrim((block) => `
11215
11455
  Not every pipeline section is h2
11216
11456
 
11217
11457
  ${block(getPipelineIdentification())}
@@ -11224,7 +11464,7 @@ function parsePipeline(pipelineString) {
11224
11464
  const defineParam = (parameterCommand) => {
11225
11465
  const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
11226
11466
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
11227
- throw new ParseError(spaceTrim$1((block) => `
11467
+ throw new ParseError(spaceTrim((block) => `
11228
11468
  Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
11229
11469
 
11230
11470
  ${block(getPipelineIdentification())}
@@ -11235,7 +11475,7 @@ function parsePipeline(pipelineString) {
11235
11475
  existingParameter.description &&
11236
11476
  existingParameter.description !== parameterDescription &&
11237
11477
  parameterDescription) {
11238
- throw new ParseError(spaceTrim$1((block) => `
11478
+ throw new ParseError(spaceTrim((block) => `
11239
11479
  Parameter \`{${parameterName}}\` is defined multiple times with different description:
11240
11480
 
11241
11481
  ${block(getPipelineIdentification())}
@@ -11273,7 +11513,7 @@ function parsePipeline(pipelineString) {
11273
11513
  description = description.split(/^>.*$/gm).join('');
11274
11514
  //Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
11275
11515
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
11276
- description = spaceTrim$1(description);
11516
+ description = spaceTrim(description);
11277
11517
  if (description === '') {
11278
11518
  description = undefined;
11279
11519
  }
@@ -11284,7 +11524,7 @@ function parsePipeline(pipelineString) {
11284
11524
  const command = parseCommand(listItem, 'PIPELINE_HEAD');
11285
11525
  const commandParser = getParserForCommand(command);
11286
11526
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
11287
- throw new ParseError(spaceTrim$1((block) => `
11527
+ throw new ParseError(spaceTrim((block) => `
11288
11528
  Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
11289
11529
 
11290
11530
  ${block(getPipelineIdentification())}
@@ -11298,7 +11538,7 @@ function parsePipeline(pipelineString) {
11298
11538
  if (!(error instanceof ParseError)) {
11299
11539
  throw error;
11300
11540
  }
11301
- throw new ParseError(spaceTrim$1((block) => `
11541
+ throw new ParseError(spaceTrim((block) => `
11302
11542
  Command ${command.type} failed to apply to the pipeline
11303
11543
 
11304
11544
  The error:
@@ -11351,7 +11591,7 @@ function parsePipeline(pipelineString) {
11351
11591
  description = description.split(/^>.*$/gm).join('');
11352
11592
  //Note: Remove lists and return statement - TODO: [🎾]
11353
11593
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
11354
- description = spaceTrim$1(description);
11594
+ description = spaceTrim(description);
11355
11595
  if (description === '') {
11356
11596
  description = undefined;
11357
11597
  }
@@ -11385,7 +11625,7 @@ function parsePipeline(pipelineString) {
11385
11625
  for (const { listItem, command } of commands) {
11386
11626
  const commandParser = getParserForCommand(command);
11387
11627
  if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
11388
- throw new ParseError(spaceTrim$1((block) => `
11628
+ throw new ParseError(spaceTrim((block) => `
11389
11629
  Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
11390
11630
 
11391
11631
  ${block(getPipelineIdentification())}
@@ -11400,7 +11640,7 @@ function parsePipeline(pipelineString) {
11400
11640
  if (!(error instanceof ParseError)) {
11401
11641
  throw error;
11402
11642
  }
11403
- throw new ParseError(spaceTrim$1((block) => `
11643
+ throw new ParseError(spaceTrim((block) => `
11404
11644
  Command \`${command.type}\` failed to apply to the task
11405
11645
 
11406
11646
  The error:
@@ -11431,14 +11671,14 @@ function parsePipeline(pipelineString) {
11431
11671
  // TODO: [🍧] Should be done in SECTION command
11432
11672
  if ($taskJson.taskType === 'SCRIPT_TASK') {
11433
11673
  if (!language) {
11434
- throw new ParseError(spaceTrim$1((block) => `
11674
+ throw new ParseError(spaceTrim((block) => `
11435
11675
  You must specify the language of the script in the \`SCRIPT\` task
11436
11676
 
11437
11677
  ${block(getPipelineIdentification())}
11438
11678
  `));
11439
11679
  }
11440
11680
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
11441
- throw new ParseError(spaceTrim$1((block) => `
11681
+ throw new ParseError(spaceTrim((block) => `
11442
11682
  Script language ${language} is not supported.
11443
11683
 
11444
11684
  Supported languages are:
@@ -11600,7 +11840,7 @@ function addAutoGeneratedSection(content, options) {
11600
11840
  const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
11601
11841
  const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
11602
11842
  const sectionMatch = content.match(sectionRegex);
11603
- const contentToInsert = spaceTrim$1((block) => `
11843
+ const contentToInsert = spaceTrim((block) => `
11604
11844
  <!--${sectionName}-->
11605
11845
  ${block(warningLine)}
11606
11846
  ${block(sectionContent)}
@@ -11613,7 +11853,7 @@ function addAutoGeneratedSection(content, options) {
11613
11853
  const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
11614
11854
  if (placeForSection !== null) {
11615
11855
  const [heading] = placeForSection;
11616
- return content.replace(heading, spaceTrim$1((block) => `
11856
+ return content.replace(heading, spaceTrim((block) => `
11617
11857
  ${block(contentToInsert)}
11618
11858
 
11619
11859
  ${block(heading)}
@@ -11622,7 +11862,7 @@ function addAutoGeneratedSection(content, options) {
11622
11862
  console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
11623
11863
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
11624
11864
  // <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
11625
- return spaceTrim$1((block) => `
11865
+ return spaceTrim((block) => `
11626
11866
  ${block(content)}
11627
11867
 
11628
11868
  ${block(contentToInsert)}
@@ -11698,7 +11938,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
11698
11938
  .filter(([MERMAID_NAME]) => (inputAndIntermediateParametersMermaid + outputParametersMermaid).includes(MERMAID_NAME))
11699
11939
  .map(([MERMAID_NAME, title]) => `${MERMAID_NAME}((${title})):::${MERMAID_NAME}`)
11700
11940
  .join('\n');
11701
- const promptbookMermaid = spaceTrim$1((block) => `
11941
+ const promptbookMermaid = spaceTrim((block) => `
11702
11942
 
11703
11943
  %% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
11704
11944
 
@@ -11754,7 +11994,7 @@ async function prettifyPipelineString(pipelineString, options) {
11754
11994
  return { href: `#${task.name}`, title: task.title };
11755
11995
  },
11756
11996
  });
11757
- const promptbookMermaidBlock = spaceTrim$1((block) => `
11997
+ const promptbookMermaidBlock = spaceTrim((block) => `
11758
11998
  \`\`\`mermaid
11759
11999
  ${block(promptbookMermaid)}
11760
12000
  \`\`\`
@@ -11792,7 +12032,7 @@ class CallbackInterfaceTools {
11792
12032
  async promptDialog(options) {
11793
12033
  const answer = await this.options.callback(options);
11794
12034
  if (this.options.isVerbose) {
11795
- console.info(spaceTrim$1((block) => `
12035
+ console.info(spaceTrim((block) => `
11796
12036
  📖 ${block(options.promptTitle)}
11797
12037
  👤 ${block(answer)}
11798
12038
  `));
@@ -11931,7 +12171,7 @@ function countWorkingDuration(items) {
11931
12171
  function executionReportJsonToString(executionReportJson, options) {
11932
12172
  var _a, _b, _c, _d, _e, _f;
11933
12173
  const { taxRate, chartsWidth } = { ...ExecutionReportStringOptionsDefaults, ...(options || {}) };
11934
- let executionReportString = spaceTrim$1((block) => `
12174
+ let executionReportString = spaceTrim((block) => `
11935
12175
  # ${executionReportJson.title || 'Execution report'}
11936
12176
 
11937
12177
  ${block(executionReportJson.description || '')}
@@ -12053,7 +12293,7 @@ function executionReportJsonToString(executionReportJson, options) {
12053
12293
  if (just(true)) {
12054
12294
  executionReportString +=
12055
12295
  '\n\n\n\n' +
12056
- spaceTrim$1((block) => {
12296
+ spaceTrim((block) => {
12057
12297
  var _a;
12058
12298
  return `
12059
12299
 
@@ -12072,7 +12312,7 @@ function executionReportJsonToString(executionReportJson, options) {
12072
12312
  executionReportString += '*No result*';
12073
12313
  }
12074
12314
  else if (typeof promptExecution.result.content === 'string') {
12075
- executionReportString += spaceTrim$1((block) => `
12315
+ executionReportString += spaceTrim((block) => `
12076
12316
  \`\`\`
12077
12317
  ${block(escapeMarkdownBlock(promptExecution.result.content))}
12078
12318
  \`\`\`
@@ -12085,7 +12325,7 @@ function executionReportJsonToString(executionReportJson, options) {
12085
12325
  if (promptExecution.error && promptExecution.error.message) {
12086
12326
  executionReportString +=
12087
12327
  '\n\n\n\n' +
12088
- spaceTrim$1((block) => `
12328
+ spaceTrim((block) => `
12089
12329
 
12090
12330
  ### Error
12091
12331
 
@@ -12161,7 +12401,7 @@ function usageToHuman(usage) {
12161
12401
  // Note: For negligible usage, we report at least something
12162
12402
  reportItems.push('Negligible');
12163
12403
  }
12164
- return spaceTrim((block) => `
12404
+ return spaceTrim$1((block) => `
12165
12405
  Usage:
12166
12406
  ${block(reportItems.map((item) => `- ${item}`).join('\n'))}
12167
12407
  `);
@@ -12406,13 +12646,13 @@ function $registeredLlmToolsMessage() {
12406
12646
  });
12407
12647
  const usedEnvMessage = `Unknown \`.env\` file` ;
12408
12648
  if (metadata.length === 0) {
12409
- return spaceTrim((block) => `
12649
+ return spaceTrim$1((block) => `
12410
12650
  No LLM providers are available.
12411
12651
 
12412
12652
  ${block(usedEnvMessage)}
12413
12653
  `);
12414
12654
  }
12415
- return spaceTrim((block) => `
12655
+ return spaceTrim$1((block) => `
12416
12656
 
12417
12657
  ${block(usedEnvMessage)}
12418
12658
 
@@ -12458,7 +12698,7 @@ function $registeredLlmToolsMessage() {
12458
12698
  morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
12459
12699
  }
12460
12700
  }
12461
- let providerMessage = spaceTrim(`
12701
+ let providerMessage = spaceTrim$1(`
12462
12702
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
12463
12703
  ${morePieces.join('; ')}
12464
12704
  `);
@@ -12504,7 +12744,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
12504
12744
  .find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
12505
12745
  if (registeredItem === undefined) {
12506
12746
  // console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
12507
- throw new Error(spaceTrim((block) => `
12747
+ throw new Error(spaceTrim$1((block) => `
12508
12748
  There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
12509
12749
  Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
12510
12750
 
@@ -12641,7 +12881,7 @@ function cacheLlmTools(llmTools, options = {}) {
12641
12881
  let normalizedContent = content;
12642
12882
  normalizedContent = normalizedContent.replace(/\s+/g, ' ');
12643
12883
  normalizedContent = normalizedContent.split('\r\n').join('\n');
12644
- normalizedContent = spaceTrim(normalizedContent);
12884
+ normalizedContent = spaceTrim$1(normalizedContent);
12645
12885
  // Note: Do not need to save everything in the cache, just the relevant parameters
12646
12886
  const relevantParameterNames = extractParameterNames(content);
12647
12887
  const relevantParameters = Object.fromEntries(Object.entries(parameters).filter(([key]) => relevantParameterNames.has(key)));
@@ -13321,7 +13561,7 @@ function isValidPipelineString(pipelineString) {
13321
13561
  */
13322
13562
  function prompt(strings, ...values) {
13323
13563
  if (values.length === 0) {
13324
- return spaceTrim(strings.join(''));
13564
+ return spaceTrim$1(strings.join(''));
13325
13565
  }
13326
13566
  const stringsWithHiddenParameters = strings.map((stringsItem) =>
13327
13567
  // TODO: [0] DRY
@@ -13332,7 +13572,7 @@ function prompt(strings, ...values) {
13332
13572
  let pipelineString = stringsWithHiddenParameters.reduce((result, stringsItem, i) => placeholderParameterNames[i] === undefined
13333
13573
  ? `${result}${stringsItem}`
13334
13574
  : `${result}${stringsItem}{${placeholderParameterNames[i]}}`, '');
13335
- pipelineString = spaceTrim(pipelineString);
13575
+ pipelineString = spaceTrim$1(pipelineString);
13336
13576
  try {
13337
13577
  pipelineString = templateParameters(pipelineString, parameters);
13338
13578
  }
@@ -13341,7 +13581,7 @@ function prompt(strings, ...values) {
13341
13581
  throw error;
13342
13582
  }
13343
13583
  console.error({ pipelineString, parameters, placeholderParameterNames, error });
13344
- throw new UnexpectedError(spaceTrim((block) => `
13584
+ throw new UnexpectedError(spaceTrim$1((block) => `
13345
13585
  Internal error in prompt template literal
13346
13586
 
13347
13587
  ${block(JSON.stringify({ strings, values }, null, 4))}}
@@ -13378,7 +13618,7 @@ function book(strings, ...values) {
13378
13618
  const bookString = prompt(strings, ...values);
13379
13619
  if (!isValidPipelineString(bookString)) {
13380
13620
  // TODO: Make the CustomError for this
13381
- throw new Error(spaceTrim(`
13621
+ throw new Error(spaceTrim$1(`
13382
13622
  The string is not a valid pipeline string
13383
13623
 
13384
13624
  book\`
@@ -13388,7 +13628,7 @@ function book(strings, ...values) {
13388
13628
  }
13389
13629
  if (!isValidBook(bookString)) {
13390
13630
  // TODO: Make the CustomError for this
13391
- throw new Error(spaceTrim(`
13631
+ throw new Error(spaceTrim$1(`
13392
13632
  The string is not a valid book
13393
13633
 
13394
13634
  book\`