@promptbook/markdown-utils 0.81.0-21 → 0.81.0-23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +4 -20
  2. package/esm/index.es.js +52 -37
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  6. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  7. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -2
  8. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -0
  9. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  10. package/esm/typings/src/commands/index.d.ts +1 -1
  11. package/esm/typings/src/config.d.ts +2 -2
  12. package/esm/typings/src/conversion/parsePipeline.d.ts +1 -1
  13. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  14. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +7 -7
  15. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +1 -1
  16. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  17. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  18. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  19. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  20. package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +1 -1
  21. package/esm/typings/src/other/templates/getBookTemplates.d.ts +1 -1
  22. package/esm/typings/src/personas/preparePersona.d.ts +4 -4
  23. package/esm/typings/src/pipeline/PipelineString.d.ts +0 -3
  24. package/esm/typings/src/pipeline/book-notation.d.ts +0 -1
  25. package/esm/typings/src/pipeline/isValidPipelineString.d.ts +3 -1
  26. package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
  27. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
  28. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -1
  29. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +1 -1
  30. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  31. package/esm/typings/src/types/typeAliases.d.ts +8 -2
  32. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  33. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/umd/index.umd.js +52 -37
  36. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-20';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-22';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -362,6 +362,26 @@
362
362
 
363
363
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n\\`\\`\\`json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book.md",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the task:\n\n> {book}\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Title starts with emoticon",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book.md`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the task:\n\n> {book}\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Title starts with emoticon\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
364
364
 
365
+ /**
366
+ * Function `validatePipelineString` will validate the if the string is a valid pipeline string
367
+ * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
368
+ *
369
+ * @param {string} pipelineString the candidate for a pipeline string
370
+ * @returns {PipelineString} the same string as input, but validated as valid
371
+ * @throws {ParseError} if the string is not a valid pipeline string
372
+ * @public exported from `@promptbook/core`
373
+ */
374
+ function validatePipelineString(pipelineString) {
375
+ if (isValidJsonString(pipelineString)) {
376
+ throw new ParseError('Expected a book, but got a JSON string');
377
+ }
378
+ // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
379
+ return pipelineString;
380
+ }
381
+ /**
382
+ * TODO: [🧠][🈴] Where is the best location for this file
383
+ */
384
+
365
385
  /**
366
386
  * Prettify the html code
367
387
  *
@@ -419,7 +439,7 @@
419
439
  if (bookVersion !== "undefined") {
420
440
  commands.push("BOOK VERSION ".concat(bookVersion));
421
441
  }
422
- // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
442
+ // TODO: [main] !!5 This increases size of the bundle and is probbably not necessary
423
443
  pipelineString = prettifyMarkdown(pipelineString);
424
444
  try {
425
445
  for (var _g = __values(parameters.filter(function (_a) {
@@ -567,12 +587,12 @@
567
587
  pipelineString += '```' + contentLanguage;
568
588
  pipelineString += '\n';
569
589
  pipelineString += spaceTrim__default["default"](content);
570
- // <- TODO: [main] !!! Escape
590
+ // <- TODO: [main] !!3 Escape
571
591
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
572
592
  pipelineString += '\n';
573
593
  pipelineString += '```';
574
594
  pipelineString += '\n\n';
575
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
595
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!3 If the parameter here has description, add it and use taskParameterJsonToString
576
596
  }
577
597
  }
578
598
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -582,7 +602,7 @@
582
602
  }
583
603
  finally { if (e_3) throw e_3.error; }
584
604
  }
585
- return pipelineString;
605
+ return validatePipelineString(pipelineString);
586
606
  }
587
607
  /**
588
608
  * @private internal utility of `pipelineJsonToString`
@@ -806,7 +826,7 @@
806
826
  /**
807
827
  * Make error report URL for the given error
808
828
  *
809
- * @private !!!!!!
829
+ * @private private within the repository
810
830
  */
811
831
  function getErrorReportUrl(error) {
812
832
  var report = {
@@ -957,7 +977,7 @@
957
977
  }
958
978
  /**
959
979
  * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
960
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
980
+ * TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
961
981
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
962
982
  */
963
983
 
@@ -1134,7 +1154,7 @@
1134
1154
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
1135
1155
  return false;
1136
1156
  }
1137
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
1157
+ // <- TODO: [main] !!3 Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
1138
1158
  return true;
1139
1159
  }
1140
1160
 
@@ -1264,11 +1284,11 @@
1264
1284
  */
1265
1285
  function validatePipeline(pipeline) {
1266
1286
  if (IS_PIPELINE_LOGIC_VALIDATED) {
1267
- validatePipelineCore(pipeline);
1287
+ validatePipeline_InnerFunction(pipeline);
1268
1288
  }
1269
1289
  else {
1270
1290
  try {
1271
- validatePipelineCore(pipeline);
1291
+ validatePipeline_InnerFunction(pipeline);
1272
1292
  }
1273
1293
  catch (error) {
1274
1294
  if (!(error instanceof PipelineLogicError)) {
@@ -1282,7 +1302,7 @@
1282
1302
  /**
1283
1303
  * @private internal function for `validatePipeline`
1284
1304
  */
1285
- function validatePipelineCore(pipeline) {
1305
+ function validatePipeline_InnerFunction(pipeline) {
1286
1306
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
1287
1307
  var e_1, _a, e_2, _b, e_3, _c;
1288
1308
  var pipelineIdentification = (function () {
@@ -1506,11 +1526,11 @@
1506
1526
  _loop_3();
1507
1527
  }
1508
1528
  // Note: Check that formfactor is corresponding to the pipeline interface
1509
- // TODO: !!!!!! Implement this
1529
+ // TODO: !!6 Implement this
1510
1530
  // pipeline.formfactorName
1511
1531
  }
1512
1532
  /**
1513
- * TODO: !! [🧞‍♀️] Do not allow joker + foreach
1533
+ * TODO: [🧞‍♀️] Do not allow joker + foreach
1514
1534
  * TODO: [🧠] Work with promptbookVersion
1515
1535
  * TODO: Use here some json-schema, Zod or something similar and change it to:
1516
1536
  * > /**
@@ -1522,11 +1542,11 @@
1522
1542
  * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
1523
1543
  */
1524
1544
  /**
1525
- * TODO: [🧳][main] !!!! Validate that all examples match expectations
1526
- * TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
1527
- * TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
1528
- * TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1529
- * TODO: [🧳][main] !!!! Validate that reserved parameter is not used as joker
1545
+ * TODO: [🧳][main] !!4 Validate that all examples match expectations
1546
+ * TODO: [🧳][🐝][main] !!4 Validate that knowledge is valid (non-void)
1547
+ * TODO: [🧳][main] !!4 Validate that persona can be used only with CHAT variant
1548
+ * TODO: [🧳][main] !!4 Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1549
+ * TODO: [🧳][main] !!4 Validate that reserved parameter is not used as joker
1530
1550
  * TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
1531
1551
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
1532
1552
  */
@@ -1662,7 +1682,7 @@
1662
1682
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
1663
1683
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
1664
1684
  var existing = this.collection.get(pipeline.pipelineUrl);
1665
- throw new PipelineUrlError(spaceTrim.spaceTrim("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
1685
+ throw new PipelineUrlError(spaceTrim.spaceTrim("\n Pipeline with URL ".concat(pipeline.pipelineUrl, " is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
1666
1686
  }
1667
1687
  // Note: [🧠] Overwrite existing pipeline with the same URL
1668
1688
  this.collection.set(pipeline.pipelineUrl, pipeline);
@@ -2023,7 +2043,7 @@
2023
2043
  return true;
2024
2044
  }
2025
2045
  /**
2026
- * TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
2046
+ * TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2027
2047
  * TODO: [🐠] Maybe base this on `makeValidator`
2028
2048
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2029
2049
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -2788,10 +2808,10 @@
2788
2808
  });
2789
2809
  }
2790
2810
  /**
2791
- * TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
2792
- * TODO: [🏢] !! Check validity of `modelName` in pipeline
2793
- * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
2794
- * TODO: [🏢] !! Check validity of `temperature` in pipeline
2811
+ * TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
2812
+ * TODO: [🏢] Check validity of `modelName` in pipeline
2813
+ * TODO: [🏢] Check validity of `systemMessage` in pipeline
2814
+ * TODO: [🏢] Check validity of `temperature` in pipeline
2795
2815
  */
2796
2816
 
2797
2817
  /**
@@ -3875,7 +3895,7 @@
3875
3895
  * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
3876
3896
  * TODO: [🧠] Add context to each task (if missing)
3877
3897
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
3878
- * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
3898
+ * TODO: [♨][main] !!3 Prepare index the examples and maybe tasks
3879
3899
  * TODO: Write tests for `preparePipeline`
3880
3900
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3881
3901
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -3938,17 +3958,10 @@
3938
3958
  _d.tools = tools,
3939
3959
  _d)]);
3940
3960
  return [4 /*yield*/, prepareTitleExecutor({
3941
- book: sources
3942
- .map(function (_a) {
3961
+ book: sources.map(function (_a) {
3943
3962
  var content = _a.content;
3944
3963
  return content;
3945
- })
3946
- .join('\n\n')
3947
- // TODO: !!!!!!! Parameters in parameters - DO NOT ALLOW, ESCAPE:
3948
- .split('{')
3949
- .join('[')
3950
- .split('}')
3951
- .join(']'),
3964
+ }).join('\n\n'),
3952
3965
  })];
3953
3966
  case 2:
3954
3967
  result = _e.sent();
@@ -4616,6 +4629,8 @@
4616
4629
  throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4617
4630
  }
4618
4631
  parameterValue = valueToString(parameterValue);
4632
+ // Escape curly braces in parameter values to prevent prompt-injection
4633
+ parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
4619
4634
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
4620
4635
  parameterValue = parameterValue
4621
4636
  .split('\n')
@@ -4975,7 +4990,7 @@
4975
4990
  promptTitle: task.title,
4976
4991
  promptMessage: templateParameters(task.description || '', parameters),
4977
4992
  defaultValue: templateParameters(preparedContent, parameters),
4978
- // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4993
+ // TODO: [🧠] Figure out how to define placeholder in .book.md file
4979
4994
  placeholder: undefined,
4980
4995
  priority: priority,
4981
4996
  }))];
@@ -6060,12 +6075,12 @@
6060
6075
  outputParameters = result.outputParameters;
6061
6076
  knowledgePiecesRaw = outputParameters.knowledgePieces;
6062
6077
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
6063
- // <- TODO: [main] !! Smarter split and filter out empty pieces
6078
+ // <- TODO: [main] Smarter split and filter out empty pieces
6064
6079
  if (isVerbose) {
6065
6080
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
6066
6081
  }
6067
6082
  return [4 /*yield*/, Promise.all(
6068
- // TODO: [🪂] !! Do not send all at once but in chunks
6083
+ // TODO: [🪂] Do not send all at once but in chunks
6069
6084
  knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
6070
6085
  var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
6071
6086
  return __generator(this, function (_c) {