@promptbook/pdf 0.74.0-8 → 0.75.0-1

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 (57) hide show
  1. package/README.md +2 -11
  2. package/esm/index.es.js +92 -52
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +3 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +25 -1
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
  9. package/esm/typings/src/cli/main.d.ts +4 -1
  10. package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
  11. package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
  12. package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
  13. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  14. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  15. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
  16. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +11 -0
  17. package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
  18. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
  19. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  20. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -0
  21. package/esm/typings/src/commands/index.d.ts +1 -1
  22. package/esm/typings/src/config.d.ts +7 -0
  23. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  24. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  25. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  26. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  27. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
  28. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  29. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
  30. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +14 -0
  31. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +34 -0
  32. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
  33. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
  34. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +15 -0
  35. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +14 -0
  36. package/esm/typings/src/formfactors/index.d.ts +39 -0
  37. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +14 -0
  38. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +14 -0
  39. package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
  40. package/esm/typings/src/pipeline/pipeline-interface/constants.d.ts +9 -0
  41. package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
  42. package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
  43. package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
  44. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  45. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  46. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  47. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +11 -4
  48. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  49. package/esm/typings/src/types/Prompt.d.ts +1 -1
  50. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  51. package/esm/typings/src/utils/expectation-counters/constants.d.ts +15 -0
  52. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  53. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  54. package/package.json +2 -2
  55. package/umd/index.umd.js +92 -52
  56. package/umd/index.umd.js.map +1 -1
  57. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/README.md CHANGED
@@ -18,7 +18,7 @@ Build responsible, controlled and transparent applications on top of LLM models!
18
18
 
19
19
  ## ✨ New Features
20
20
 
21
- - 💙 Working on [the **Book** language v1](https://github.com/webgptorg/book)
21
+ - 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
22
22
  - 📚 Support of `.docx`, `.doc` and `.pdf` documents
23
23
  - ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
24
24
 
@@ -150,7 +150,7 @@ Following is the documentation and blueprint of the Book language.
150
150
 
151
151
  File is designed to be easy to read and write. It is strict subset of markdown. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
152
152
 
153
- It has file with `.ptbk.md` or `.book` extension with `UTF-8` non BOM encoding.
153
+ It has file with `.book.md` or `.book` extension with `UTF-8` non BOM encoding.
154
154
 
155
155
  As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
156
156
 
@@ -243,11 +243,6 @@ Or you can install them separately:
243
243
 
244
244
  ## 📚 Dictionary
245
245
 
246
-
247
-
248
-
249
-
250
-
251
246
  ### 📚 Dictionary
252
247
 
253
248
  The following glossary is used to clarify certain concepts:
@@ -263,8 +258,6 @@ The following glossary is used to clarify certain concepts:
263
258
  - **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
264
259
  - **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
265
260
 
266
-
267
-
268
261
  _Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
269
262
 
270
263
  #### Promptbook core
@@ -325,8 +318,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
325
318
  - [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
326
319
  - [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
327
320
 
328
-
329
-
330
321
  ### Terms specific to Promptbook TypeScript implementation
331
322
 
332
323
  - Anonymous mode
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  *
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-7';
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.0-0';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  */
@@ -173,7 +173,7 @@ var NotYetImplementedError = /** @class */ (function (_super) {
173
173
  function TODO_USE() {
174
174
  }
175
175
 
176
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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\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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
176
+ 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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.book.md"},{title:"Prepare 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}],templates:[{templateType:"PROMPT_TEMPLATE",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\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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.book.md"}];
177
177
 
178
178
  /**
179
179
  * Prettify the html code
@@ -221,13 +221,13 @@ function capitalize(word) {
221
221
  /**
222
222
  * Converts promptbook in JSON format to string format
223
223
  *
224
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
225
- * @returns Promptbook in string format (.ptbk.md)
224
+ * @param pipelineJson Promptbook in JSON format (.book.json)
225
+ * @returns Promptbook in string format (.book.md)
226
226
  * @public exported from `@promptbook/core`
227
227
  */
228
228
  function pipelineJsonToString(pipelineJson) {
229
229
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
230
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
230
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
231
231
  var pipelineString = "# ".concat(title);
232
232
  if (description) {
233
233
  pipelineString += '\n\n';
@@ -237,8 +237,10 @@ function pipelineJsonToString(pipelineJson) {
237
237
  if (pipelineUrl) {
238
238
  commands.push("PIPELINE URL ".concat(pipelineUrl));
239
239
  }
240
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
241
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
240
+ if (bookVersion !== "undefined") {
241
+ commands.push("BOOK VERSION ".concat(bookVersion));
242
+ }
243
+ // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
242
244
  pipelineString = prettifyMarkdown(pipelineString);
243
245
  try {
244
246
  for (var _g = __values(parameters.filter(function (_a) {
@@ -418,7 +420,7 @@ function templateParameterJsonToString(templateParameterJson) {
418
420
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
419
421
  * TODO: [🏛] Maybe make some markdown builder
420
422
  * TODO: [🏛] Escape all
421
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
423
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
422
424
  */
423
425
 
424
426
  /**
@@ -722,6 +724,7 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
722
724
  // Note: In normal situations, we check the pipeline logic:
723
725
  true);
724
726
  /**
727
+ * TODO: Extract `constants.ts` from `config.ts`
725
728
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
726
729
  */
727
730
 
@@ -898,7 +901,7 @@ function isValidPipelineUrl(url) {
898
901
  if (!url.startsWith('https://')) {
899
902
  return false;
900
903
  }
901
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
904
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
902
905
  return false;
903
906
  }
904
907
  if (url.includes('#')) {
@@ -967,9 +970,9 @@ function validatePipelineCore(pipeline) {
967
970
  // <- Note: [🚲]
968
971
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
969
972
  }
970
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
973
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
971
974
  // <- Note: [🚲]
972
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
975
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
973
976
  }
974
977
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
975
978
  if (!Array.isArray(pipeline.parameters)) {
@@ -983,18 +986,18 @@ function validatePipelineCore(pipeline) {
983
986
  }
984
987
  var _loop_1 = function (parameter) {
985
988
  if (parameter.isInput && parameter.isOutput) {
986
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
989
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
987
990
  }
988
991
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
989
992
  if (!parameter.isInput &&
990
993
  !parameter.isOutput &&
991
994
  !pipeline.templates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
992
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
995
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
993
996
  }
994
997
  // Note: Testing that parameter is either input or result of some template
995
998
  if (!parameter.isInput &&
996
999
  !pipeline.templates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
997
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of {").concat(parameter.name, "}\n 2) Add template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
1000
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add template that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
998
1001
  }
999
1002
  };
1000
1003
  try {
@@ -1022,7 +1025,7 @@ function validatePipelineCore(pipeline) {
1022
1025
  var _loop_2 = function (template) {
1023
1026
  var e_4, _h, e_5, _j;
1024
1027
  if (definedParameters.has(template.resultingParameterName)) {
1025
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1028
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(template.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
1026
1029
  }
1027
1030
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
1028
1031
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
@@ -1035,7 +1038,7 @@ function validatePipelineCore(pipeline) {
1035
1038
  }
1036
1039
  var _loop_4 = function (joker) {
1037
1040
  if (!template.dependentParameterNames.includes(joker)) {
1038
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1041
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
1039
1042
  }
1040
1043
  };
1041
1044
  try {
@@ -1130,14 +1133,24 @@ function validatePipelineCore(pipeline) {
1130
1133
  if (currentlyResovedTemplates.length === 0) {
1131
1134
  throw new PipelineLogicError(
1132
1135
  // TODO: [🐎] DRY
1133
- spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates
1136
+ spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
1134
1137
  .map(function (_a) {
1135
1138
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
1136
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
1137
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
1139
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
1140
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
1138
1141
  .join(' and '));
1139
1142
  })
1140
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n\n "); }));
1143
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
1144
+ .filter(function (name) {
1145
+ return !RESERVED_PARAMETER_NAMES.includes(name);
1146
+ })
1147
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1148
+ .join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
1149
+ .filter(function (name) {
1150
+ return RESERVED_PARAMETER_NAMES.includes(name);
1151
+ })
1152
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
1153
+ .join('\n')), "\n\n\n "); }));
1141
1154
  }
1142
1155
  resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
1143
1156
  var resultingParameterName = _a.resultingParameterName;
@@ -1148,6 +1161,7 @@ function validatePipelineCore(pipeline) {
1148
1161
  while (unresovedTemplates.length > 0) {
1149
1162
  _loop_3();
1150
1163
  }
1164
+ // TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
1151
1165
  }
1152
1166
  /**
1153
1167
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -2487,8 +2501,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2487
2501
  else if (errors.length > 1) {
2488
2502
  throw new PipelineExecutionError(
2489
2503
  // TODO: Tell which execution tools failed like
2490
- // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2491
- // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2504
+ // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2505
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
2492
2506
  // 3) ...
2493
2507
  spaceTrim$1(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2494
2508
  .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
@@ -2602,7 +2616,7 @@ function preparePersona(personaDescription, tools, options) {
2602
2616
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2603
2617
  _b = createPipelineExecutor;
2604
2618
  _c = {};
2605
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
2619
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
2606
2620
  case 1:
2607
2621
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
2608
2622
  _c.tools = tools,
@@ -3274,13 +3288,14 @@ TODO: [🧊] This is how it can look in future
3274
3288
  */
3275
3289
  function clonePipeline(pipeline) {
3276
3290
  // Note: Not using spread operator (...) because @@@
3277
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3291
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3278
3292
  return {
3279
3293
  pipelineUrl: pipelineUrl,
3280
3294
  sourceFile: sourceFile,
3281
3295
  title: title,
3282
- promptbookVersion: promptbookVersion,
3296
+ bookVersion: bookVersion,
3283
3297
  description: description,
3298
+ formfactorName: formfactorName,
3284
3299
  parameters: parameters,
3285
3300
  templates: templates,
3286
3301
  knowledgeSources: knowledgeSources,
@@ -4145,11 +4160,11 @@ function replaceParameters(template, parameters) {
4145
4160
  for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
4146
4161
  var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
4147
4162
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
4148
- throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
4163
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
4149
4164
  }
4150
4165
  else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
4151
4166
  // TODO: [🍵]
4152
- throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
4167
+ throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
4153
4168
  }
4154
4169
  }
4155
4170
  }
@@ -4176,11 +4191,11 @@ function replaceParameters(template, parameters) {
4176
4191
  throw new PipelineExecutionError('Parameter is already opened or not closed');
4177
4192
  }
4178
4193
  if (parameters[parameterName] === undefined) {
4179
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
4194
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4180
4195
  }
4181
4196
  var parameterValue = parameters[parameterName];
4182
4197
  if (parameterValue === undefined) {
4183
- throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
4198
+ throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
4184
4199
  }
4185
4200
  parameterValue = parameterValue.toString();
4186
4201
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
@@ -4224,30 +4239,45 @@ function countCharacters(text) {
4224
4239
  return text.length;
4225
4240
  }
4226
4241
 
4242
+ /**
4243
+ * Number of characters per standard line with 11pt Arial font size.
4244
+ *
4245
+ * @public exported from `@promptbook/utils`
4246
+ */
4247
+ var CHARACTERS_PER_STANDARD_LINE = 63;
4248
+ /**
4249
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
4250
+ *
4251
+ * @public exported from `@promptbook/utils`
4252
+ */
4253
+ var LINES_PER_STANDARD_PAGE = 44;
4254
+ /**
4255
+ * TODO: [🧠] Should be this `constants.ts` or `config.ts`?
4256
+ */
4257
+
4227
4258
  /**
4228
4259
  * Counts number of lines in the text
4229
4260
  *
4261
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
4262
+ *
4230
4263
  * @public exported from `@promptbook/utils`
4231
4264
  */
4232
4265
  function countLines(text) {
4233
- if (text === '') {
4234
- return 0;
4235
- }
4236
- return text.split('\n').length;
4266
+ text = text.replace('\r\n', '\n');
4267
+ text = text.replace('\r', '\n');
4268
+ var lines = text.split('\n');
4269
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
4237
4270
  }
4238
4271
 
4239
4272
  /**
4240
4273
  * Counts number of pages in the text
4241
4274
  *
4275
+ * Note: This does not check only for the count of newlines, but also for the length of the standard line and length of the standard page.
4276
+ *
4242
4277
  * @public exported from `@promptbook/utils`
4243
4278
  */
4244
4279
  function countPages(text) {
4245
- if (text === '') {
4246
- return 0;
4247
- }
4248
- var pagesByLinesCount = Math.ceil(countLines(text) / 44);
4249
- var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
4250
- return Math.max(pagesByLinesCount, pagesByCharactersCount);
4280
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
4251
4281
  }
4252
4282
 
4253
4283
  /**
@@ -4527,7 +4557,7 @@ function executeAttempts(options) {
4527
4557
  promptTitle: template.title,
4528
4558
  promptMessage: replaceParameters(template.description || '', parameters),
4529
4559
  defaultValue: replaceParameters(preparedContent, parameters),
4530
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
4560
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4531
4561
  placeholder: undefined,
4532
4562
  priority: priority,
4533
4563
  }))];
@@ -4955,7 +4985,7 @@ function executeTemplate(options) {
4955
4985
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
4956
4986
  // Houston, we have a problem
4957
4987
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
4958
- throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4988
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in template \"").concat(currentTemplate.title || currentTemplate.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4959
4989
  }
4960
4990
  };
4961
4991
  try {
@@ -5034,7 +5064,7 @@ function filterJustOutputParameters(options) {
5034
5064
  var _loop_1 = function (parameter) {
5035
5065
  if (parametersToPass[parameter.name] === undefined) {
5036
5066
  // [4]
5037
- $warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
5067
+ $warnings.push(new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
5038
5068
  return "continue";
5039
5069
  }
5040
5070
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -5093,7 +5123,7 @@ function executePipeline(options) {
5093
5123
  pipelineUrl: preparedPipeline.pipelineUrl,
5094
5124
  title: preparedPipeline.title,
5095
5125
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5096
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5126
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
5097
5127
  description: preparedPipeline.description,
5098
5128
  promptExecutions: [],
5099
5129
  };
@@ -5121,7 +5151,7 @@ function executePipeline(options) {
5121
5151
  case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
5122
5152
  isSuccessful: false,
5123
5153
  errors: __spreadArray([
5124
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
5154
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5125
5155
  ], __read(errors), false).map(serializeError),
5126
5156
  warnings: [],
5127
5157
  executionReport: executionReport,
@@ -5169,7 +5199,7 @@ function executePipeline(options) {
5169
5199
  case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
5170
5200
  isSuccessful: false,
5171
5201
  errors: __spreadArray([
5172
- new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
5202
+ new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
5173
5203
  ], __read(errors), false).map(serializeError),
5174
5204
  warnings: warnings.map(serializeError),
5175
5205
  executionReport: executionReport,
@@ -5243,14 +5273,24 @@ function executePipeline(options) {
5243
5273
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
5244
5274
  throw new UnexpectedError(
5245
5275
  // TODO: [🐎] DRY
5246
- spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve:\n ").concat(block(unresovedTemplates_1
5276
+ spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates_1
5247
5277
  .map(function (_a) {
5248
5278
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
5249
- return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
5250
- .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
5279
+ return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
5280
+ .map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
5251
5281
  .join(' and '));
5252
5282
  })
5253
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
5283
+ .join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
5284
+ .filter(function (name) {
5285
+ return !RESERVED_PARAMETER_NAMES.includes(name);
5286
+ })
5287
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5288
+ .join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
5289
+ .filter(function (name) {
5290
+ return RESERVED_PARAMETER_NAMES.includes(name);
5291
+ })
5292
+ .map(function (name) { return "- Parameter `{".concat(name, "}`"); })
5293
+ .join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
5254
5294
  case 1:
5255
5295
  if (!!currentTemplate) return [3 /*break*/, 3];
5256
5296
  /* [🤹‍♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -5489,7 +5529,7 @@ var MarkdownScraper = /** @class */ (function () {
5489
5529
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5490
5530
  _d = createPipelineExecutor;
5491
5531
  _g = {};
5492
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
5532
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
5493
5533
  case 1:
5494
5534
  prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
5495
5535
  _g.tools = {
@@ -5498,7 +5538,7 @@ var MarkdownScraper = /** @class */ (function () {
5498
5538
  _g)]);
5499
5539
  _e = createPipelineExecutor;
5500
5540
  _h = {};
5501
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
5541
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
5502
5542
  case 2:
5503
5543
  prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
5504
5544
  _h.tools = {
@@ -5507,7 +5547,7 @@ var MarkdownScraper = /** @class */ (function () {
5507
5547
  _h)]);
5508
5548
  _f = createPipelineExecutor;
5509
5549
  _j = {};
5510
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
5550
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
5511
5551
  case 3:
5512
5552
  prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
5513
5553
  _j.tools = {