@promptbook/utils 0.41.0 → 0.41.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 (352) hide show
  1. package/bin/promptbook-cli.js +1 -0
  2. package/esm/index.es.js +794 -794
  3. package/esm/typings/_packages/core.index.d.ts +20 -20
  4. package/esm/typings/_packages/execute-javascript.index.d.ts +3 -3
  5. package/esm/typings/_packages/openai.index.d.ts +3 -3
  6. package/esm/typings/_packages/remote-client.index.d.ts +4 -4
  7. package/esm/typings/_packages/remote-server.index.d.ts +3 -3
  8. package/esm/typings/_packages/types.index.d.ts +27 -27
  9. package/esm/typings/_packages/utils.index.d.ts +30 -30
  10. package/esm/typings/_packages/wizzard.index.d.ts +5 -5
  11. package/esm/typings/config.d.ts +4 -4
  12. package/esm/typings/conversion/promptbookStringToJson.d.ts +13 -13
  13. package/esm/typings/conversion/test/_importPromptbook.d.ts +12 -12
  14. package/esm/typings/conversion/test/promptbookStringToJson-syntaxErrors.test.d.ts +1 -1
  15. package/esm/typings/conversion/test/promptbookStringToJson.test.d.ts +1 -1
  16. package/esm/typings/conversion/test/validatePromptbookJson-logicErrors.test.d.ts +1 -1
  17. package/esm/typings/conversion/test/validatePromptbookJson.d.ts +26 -26
  18. package/esm/typings/conversion/test/validatePromptbookJson.test.d.ts +1 -1
  19. package/esm/typings/conversion/utils/extractVariables.d.ts +10 -10
  20. package/esm/typings/conversion/utils/extractVariables.test.d.ts +1 -1
  21. package/esm/typings/conversion/utils/parseCommand.d.ts +8 -8
  22. package/esm/typings/conversion/utils/parseCommand.test.d.ts +4 -4
  23. package/esm/typings/conversion/utils/parseNumber.d.ts +12 -12
  24. package/esm/typings/conversion/utils/parseNumber.test.d.ts +1 -1
  25. package/esm/typings/errors/ExpectError.d.ts +9 -9
  26. package/esm/typings/errors/NotFoundError.d.ts +7 -7
  27. package/esm/typings/errors/PromptbookExecutionError.d.ts +7 -7
  28. package/esm/typings/errors/PromptbookLogicError.d.ts +7 -7
  29. package/esm/typings/errors/PromptbookReferenceError.d.ts +7 -7
  30. package/esm/typings/errors/PromptbookSyntaxError.d.ts +7 -7
  31. package/esm/typings/errors/UnexpectedError.d.ts +7 -7
  32. package/esm/typings/execution/CommonExecutionToolsOptions.d.ts +9 -9
  33. package/esm/typings/execution/ExecutionTools.d.ts +25 -25
  34. package/esm/typings/execution/NaturalExecutionTools.d.ts +23 -23
  35. package/esm/typings/execution/PromptResult.d.ts +74 -74
  36. package/esm/typings/execution/PromptbookExecutor.d.ts +39 -39
  37. package/esm/typings/execution/ScriptExecutionTools.d.ts +37 -37
  38. package/esm/typings/execution/UserInterfaceTools.d.ts +45 -45
  39. package/esm/typings/execution/assertsExecutionSuccessful.d.ts +11 -11
  40. package/esm/typings/execution/createPromptbookExecutor.d.ts +41 -41
  41. package/esm/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +22 -22
  42. package/esm/typings/execution/plugins/natural-execution-tools/mocked/joker.test.d.ts +4 -4
  43. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +4 -4
  44. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +4 -4
  45. package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools.d.ts +28 -28
  46. package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +16 -16
  47. package/esm/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts +3 -3
  48. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionTools.d.ts +35 -35
  49. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +23 -23
  50. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Error.d.ts +11 -11
  51. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Progress.d.ts +12 -12
  52. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Request.d.ts +17 -17
  53. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Response.d.ts +12 -12
  54. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +27 -27
  55. package/esm/typings/execution/plugins/natural-execution-tools/remote/startRemoteServer.d.ts +17 -17
  56. package/esm/typings/execution/plugins/script-execution-tools/custom-function-async.test.ts.test.d.ts +1 -1
  57. package/esm/typings/execution/plugins/script-execution-tools/custom-function-missing.test.d.ts +1 -1
  58. package/esm/typings/execution/plugins/script-execution-tools/custom-function-with-dependencies.test.d.ts +1 -1
  59. package/esm/typings/execution/plugins/script-execution-tools/custom-function.test.d.ts +1 -1
  60. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +20 -20
  61. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -4
  62. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +20 -20
  63. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +22 -22
  64. package/esm/typings/execution/plugins/script-execution-tools/javascript/utils/preserve.d.ts +11 -11
  65. package/esm/typings/execution/plugins/script-execution-tools/postprocessing.test.d.ts +1 -1
  66. package/esm/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +15 -15
  67. package/esm/typings/execution/plugins/script-execution-tools/script-execution-errors.test.d.ts +1 -1
  68. package/esm/typings/execution/plugins/script-execution-tools/script-execution-tools.test.d.ts +1 -1
  69. package/esm/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +15 -15
  70. package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +14 -14
  71. package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +12 -12
  72. package/esm/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +16 -16
  73. package/esm/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts +1 -1
  74. package/esm/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +4 -4
  75. package/esm/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +9 -9
  76. package/esm/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +5 -5
  77. package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -11
  78. package/esm/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +4 -4
  79. package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
  80. package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -1
  81. package/esm/typings/execution/translation/automatic-translate/translateMessages.d.ts +5 -5
  82. package/esm/typings/execution/utils/replaceParameters.d.ts +12 -12
  83. package/esm/typings/execution/utils/replaceParameters.test.d.ts +1 -1
  84. package/esm/typings/library/PromptbookLibrary.d.ts +25 -25
  85. package/esm/typings/library/SimplePromptbookLibrary.d.ts +35 -35
  86. package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +5 -5
  87. package/esm/typings/library/constructors/createPromptbookLibraryFromList.d.ts +5 -5
  88. package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +7 -7
  89. package/esm/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +16 -16
  90. package/esm/typings/library/constructors/createPromptbookSublibrary.d.ts +6 -6
  91. package/esm/typings/types/Command.d.ts +98 -98
  92. package/esm/typings/types/ExecutionTypes.d.ts +13 -13
  93. package/esm/typings/types/ModelRequirements.d.ts +41 -41
  94. package/esm/typings/types/Parameters.d.ts +14 -14
  95. package/esm/typings/types/Prompt.d.ts +41 -41
  96. package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +126 -126
  97. package/esm/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +25 -25
  98. package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +51 -51
  99. package/esm/typings/types/PromptbookString.d.ts +12 -12
  100. package/esm/typings/types/ScriptLanguage.d.ts +9 -9
  101. package/esm/typings/types/TaskProgress.d.ts +42 -42
  102. package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +56 -56
  103. package/esm/typings/types/execution-report/ExecutionReportString.d.ts +16 -16
  104. package/esm/typings/types/execution-report/ExecutionReportStringOptions.d.ts +21 -21
  105. package/esm/typings/types/execution-report/config.d.ts +8 -8
  106. package/esm/typings/types/execution-report/countWorkingDuration.d.ts +7 -7
  107. package/esm/typings/types/execution-report/countWorkingDuration.test.d.ts +1 -1
  108. package/esm/typings/types/execution-report/executionReportJsonToString.d.ts +11 -11
  109. package/esm/typings/types/execution-report/executionReportJsonToString.test.d.ts +1 -1
  110. package/esm/typings/types/typeAliasEmoji.d.ts +9 -9
  111. package/esm/typings/types/typeAliases.d.ts +432 -432
  112. package/esm/typings/utils/FromtoItems.d.ts +19 -19
  113. package/esm/typings/utils/emojis.d.ts +22 -22
  114. package/esm/typings/utils/expectation-counters/countCharacters.d.ts +5 -5
  115. package/esm/typings/utils/expectation-counters/countCharacters.test.d.ts +1 -1
  116. package/esm/typings/utils/expectation-counters/countLines.d.ts +5 -5
  117. package/esm/typings/utils/expectation-counters/countLines.test.d.ts +1 -1
  118. package/esm/typings/utils/expectation-counters/countPages.d.ts +5 -5
  119. package/esm/typings/utils/expectation-counters/countPages.test.d.ts +1 -1
  120. package/esm/typings/utils/expectation-counters/countParagraphs.d.ts +5 -5
  121. package/esm/typings/utils/expectation-counters/countParagraphs.test.d.ts +1 -1
  122. package/esm/typings/utils/expectation-counters/countSentences.d.ts +5 -5
  123. package/esm/typings/utils/expectation-counters/countSentences.test.d.ts +1 -1
  124. package/esm/typings/utils/expectation-counters/countWords.d.ts +5 -5
  125. package/esm/typings/utils/expectation-counters/countWords.test.d.ts +1 -1
  126. package/esm/typings/utils/expectation-counters/index.d.ts +5 -5
  127. package/esm/typings/utils/extractParameters.d.ts +10 -10
  128. package/esm/typings/utils/extractParameters.test.d.ts +1 -1
  129. package/esm/typings/utils/formatNumber.d.ts +6 -6
  130. package/esm/typings/utils/formatNumber.test.d.ts +1 -1
  131. package/esm/typings/utils/getCurrentIsoDate.d.ts +7 -7
  132. package/esm/typings/utils/isRunningInWhatever.d.ts +12 -12
  133. package/esm/typings/utils/isValidJsonString.d.ts +4 -4
  134. package/esm/typings/utils/isValidJsonString.test.d.ts +1 -1
  135. package/esm/typings/utils/just.d.ts +10 -10
  136. package/esm/typings/utils/markdown/addAutoGeneratedSection.d.ts +10 -10
  137. package/esm/typings/utils/markdown/addAutoGeneratedSection.test.d.ts +1 -1
  138. package/esm/typings/utils/markdown/createMarkdownChart.d.ts +41 -41
  139. package/esm/typings/utils/markdown/createMarkdownChart.test.d.ts +1 -1
  140. package/esm/typings/utils/markdown/createMarkdownTable.d.ts +7 -7
  141. package/esm/typings/utils/markdown/createMarkdownTable.test.d.ts +1 -1
  142. package/esm/typings/utils/markdown/escapeMarkdownBlock.d.ts +6 -6
  143. package/esm/typings/utils/markdown/escapeMarkdownBlock.test.d.ts +1 -1
  144. package/esm/typings/utils/markdown/extractAllBlocksFromMarkdown.d.ts +27 -27
  145. package/esm/typings/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts +1 -1
  146. package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +13 -13
  147. package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -1
  148. package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +19 -19
  149. package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -1
  150. package/esm/typings/utils/markdown/prettifyMarkdown.d.ts +8 -8
  151. package/esm/typings/utils/markdown/prettifyMarkdown.test.d.ts +1 -1
  152. package/esm/typings/utils/markdown/removeContentComments.d.ts +8 -8
  153. package/esm/typings/utils/markdown/removeContentComments.test.d.ts +1 -1
  154. package/esm/typings/utils/markdown/removeMarkdownFormatting.d.ts +8 -8
  155. package/esm/typings/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -1
  156. package/esm/typings/utils/markdown-json/MarkdownStructure.d.ts +25 -25
  157. package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +7 -7
  158. package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts +1 -1
  159. package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +13 -13
  160. package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.test.d.ts +1 -1
  161. package/esm/typings/utils/postprocessing/extractBlock.d.ts +12 -12
  162. package/esm/typings/utils/removeEmojis.d.ts +7 -7
  163. package/esm/typings/utils/removeEmojis.test.d.ts +1 -1
  164. package/esm/typings/utils/removeQuotes.d.ts +13 -13
  165. package/esm/typings/utils/removeQuotes.test.d.ts +1 -1
  166. package/esm/typings/utils/trimCodeBlock.d.ts +8 -8
  167. package/esm/typings/utils/trimCodeBlock.test.d.ts +1 -1
  168. package/esm/typings/utils/trimEndOfCodeBlock.d.ts +7 -7
  169. package/esm/typings/utils/trimEndOfCodeBlock.test.d.ts +1 -1
  170. package/esm/typings/utils/unwrapResult.d.ts +36 -36
  171. package/esm/typings/utils/unwrapResult.test.d.ts +1 -1
  172. package/esm/typings/utils/validators/url/isValidUrl.d.ts +7 -7
  173. package/esm/typings/utils/validators/url/isValidUrl.test.d.ts +1 -1
  174. package/esm/typings/version.d.ts +5 -5
  175. package/esm/typings/wizzard/Wizzard.d.ts +4 -4
  176. package/esm/typings/wizzard/sample.d.ts +6 -6
  177. package/package.json +4 -1
  178. package/umd/index.umd.js +794 -794
  179. package/umd/typings/_packages/core.index.d.ts +20 -20
  180. package/umd/typings/_packages/execute-javascript.index.d.ts +3 -3
  181. package/umd/typings/_packages/openai.index.d.ts +3 -3
  182. package/umd/typings/_packages/remote-client.index.d.ts +4 -4
  183. package/umd/typings/_packages/remote-server.index.d.ts +3 -3
  184. package/umd/typings/_packages/types.index.d.ts +27 -27
  185. package/umd/typings/_packages/utils.index.d.ts +30 -30
  186. package/umd/typings/_packages/wizzard.index.d.ts +5 -5
  187. package/umd/typings/config.d.ts +4 -4
  188. package/umd/typings/conversion/promptbookStringToJson.d.ts +13 -13
  189. package/umd/typings/conversion/test/_importPromptbook.d.ts +12 -12
  190. package/umd/typings/conversion/test/promptbookStringToJson-syntaxErrors.test.d.ts +1 -1
  191. package/umd/typings/conversion/test/promptbookStringToJson.test.d.ts +1 -1
  192. package/umd/typings/conversion/test/validatePromptbookJson-logicErrors.test.d.ts +1 -1
  193. package/umd/typings/conversion/test/validatePromptbookJson.d.ts +26 -26
  194. package/umd/typings/conversion/test/validatePromptbookJson.test.d.ts +1 -1
  195. package/umd/typings/conversion/utils/extractVariables.d.ts +10 -10
  196. package/umd/typings/conversion/utils/extractVariables.test.d.ts +1 -1
  197. package/umd/typings/conversion/utils/parseCommand.d.ts +8 -8
  198. package/umd/typings/conversion/utils/parseCommand.test.d.ts +4 -4
  199. package/umd/typings/conversion/utils/parseNumber.d.ts +12 -12
  200. package/umd/typings/conversion/utils/parseNumber.test.d.ts +1 -1
  201. package/umd/typings/errors/ExpectError.d.ts +9 -9
  202. package/umd/typings/errors/NotFoundError.d.ts +7 -7
  203. package/umd/typings/errors/PromptbookExecutionError.d.ts +7 -7
  204. package/umd/typings/errors/PromptbookLogicError.d.ts +7 -7
  205. package/umd/typings/errors/PromptbookReferenceError.d.ts +7 -7
  206. package/umd/typings/errors/PromptbookSyntaxError.d.ts +7 -7
  207. package/umd/typings/errors/UnexpectedError.d.ts +7 -7
  208. package/umd/typings/execution/CommonExecutionToolsOptions.d.ts +9 -9
  209. package/umd/typings/execution/ExecutionTools.d.ts +25 -25
  210. package/umd/typings/execution/NaturalExecutionTools.d.ts +23 -23
  211. package/umd/typings/execution/PromptResult.d.ts +74 -74
  212. package/umd/typings/execution/PromptbookExecutor.d.ts +39 -39
  213. package/umd/typings/execution/ScriptExecutionTools.d.ts +37 -37
  214. package/umd/typings/execution/UserInterfaceTools.d.ts +45 -45
  215. package/umd/typings/execution/assertsExecutionSuccessful.d.ts +11 -11
  216. package/umd/typings/execution/createPromptbookExecutor.d.ts +41 -41
  217. package/umd/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +22 -22
  218. package/umd/typings/execution/plugins/natural-execution-tools/mocked/joker.test.d.ts +4 -4
  219. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +4 -4
  220. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +4 -4
  221. package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools.d.ts +28 -28
  222. package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +16 -16
  223. package/umd/typings/execution/plugins/natural-execution-tools/openai/computeOpenaiUsage.d.ts +3 -3
  224. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionTools.d.ts +35 -35
  225. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +23 -23
  226. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Error.d.ts +11 -11
  227. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Progress.d.ts +12 -12
  228. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Request.d.ts +17 -17
  229. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Promptbook_Server_Response.d.ts +12 -12
  230. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +27 -27
  231. package/umd/typings/execution/plugins/natural-execution-tools/remote/startRemoteServer.d.ts +17 -17
  232. package/umd/typings/execution/plugins/script-execution-tools/custom-function-async.test.ts.test.d.ts +1 -1
  233. package/umd/typings/execution/plugins/script-execution-tools/custom-function-missing.test.d.ts +1 -1
  234. package/umd/typings/execution/plugins/script-execution-tools/custom-function-with-dependencies.test.d.ts +1 -1
  235. package/umd/typings/execution/plugins/script-execution-tools/custom-function.test.d.ts +1 -1
  236. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +20 -20
  237. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -4
  238. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +20 -20
  239. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +22 -22
  240. package/umd/typings/execution/plugins/script-execution-tools/javascript/utils/preserve.d.ts +11 -11
  241. package/umd/typings/execution/plugins/script-execution-tools/postprocessing.test.d.ts +1 -1
  242. package/umd/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +15 -15
  243. package/umd/typings/execution/plugins/script-execution-tools/script-execution-errors.test.d.ts +1 -1
  244. package/umd/typings/execution/plugins/script-execution-tools/script-execution-tools.test.d.ts +1 -1
  245. package/umd/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +15 -15
  246. package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +14 -14
  247. package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +12 -12
  248. package/umd/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +16 -16
  249. package/umd/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts +1 -1
  250. package/umd/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +4 -4
  251. package/umd/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +9 -9
  252. package/umd/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +5 -5
  253. package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -11
  254. package/umd/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +4 -4
  255. package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
  256. package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -1
  257. package/umd/typings/execution/translation/automatic-translate/translateMessages.d.ts +5 -5
  258. package/umd/typings/execution/utils/replaceParameters.d.ts +12 -12
  259. package/umd/typings/execution/utils/replaceParameters.test.d.ts +1 -1
  260. package/umd/typings/library/PromptbookLibrary.d.ts +25 -25
  261. package/umd/typings/library/SimplePromptbookLibrary.d.ts +35 -35
  262. package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +5 -5
  263. package/umd/typings/library/constructors/createPromptbookLibraryFromList.d.ts +5 -5
  264. package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +7 -7
  265. package/umd/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +16 -16
  266. package/umd/typings/library/constructors/createPromptbookSublibrary.d.ts +6 -6
  267. package/umd/typings/types/Command.d.ts +98 -98
  268. package/umd/typings/types/ExecutionTypes.d.ts +13 -13
  269. package/umd/typings/types/ModelRequirements.d.ts +41 -41
  270. package/umd/typings/types/Parameters.d.ts +14 -14
  271. package/umd/typings/types/Prompt.d.ts +41 -41
  272. package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +126 -126
  273. package/umd/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +25 -25
  274. package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +51 -51
  275. package/umd/typings/types/PromptbookString.d.ts +12 -12
  276. package/umd/typings/types/ScriptLanguage.d.ts +9 -9
  277. package/umd/typings/types/TaskProgress.d.ts +42 -42
  278. package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +56 -56
  279. package/umd/typings/types/execution-report/ExecutionReportString.d.ts +16 -16
  280. package/umd/typings/types/execution-report/ExecutionReportStringOptions.d.ts +21 -21
  281. package/umd/typings/types/execution-report/config.d.ts +8 -8
  282. package/umd/typings/types/execution-report/countWorkingDuration.d.ts +7 -7
  283. package/umd/typings/types/execution-report/countWorkingDuration.test.d.ts +1 -1
  284. package/umd/typings/types/execution-report/executionReportJsonToString.d.ts +11 -11
  285. package/umd/typings/types/execution-report/executionReportJsonToString.test.d.ts +1 -1
  286. package/umd/typings/types/typeAliasEmoji.d.ts +9 -9
  287. package/umd/typings/types/typeAliases.d.ts +432 -432
  288. package/umd/typings/utils/FromtoItems.d.ts +19 -19
  289. package/umd/typings/utils/emojis.d.ts +22 -22
  290. package/umd/typings/utils/expectation-counters/countCharacters.d.ts +5 -5
  291. package/umd/typings/utils/expectation-counters/countCharacters.test.d.ts +1 -1
  292. package/umd/typings/utils/expectation-counters/countLines.d.ts +5 -5
  293. package/umd/typings/utils/expectation-counters/countLines.test.d.ts +1 -1
  294. package/umd/typings/utils/expectation-counters/countPages.d.ts +5 -5
  295. package/umd/typings/utils/expectation-counters/countPages.test.d.ts +1 -1
  296. package/umd/typings/utils/expectation-counters/countParagraphs.d.ts +5 -5
  297. package/umd/typings/utils/expectation-counters/countParagraphs.test.d.ts +1 -1
  298. package/umd/typings/utils/expectation-counters/countSentences.d.ts +5 -5
  299. package/umd/typings/utils/expectation-counters/countSentences.test.d.ts +1 -1
  300. package/umd/typings/utils/expectation-counters/countWords.d.ts +5 -5
  301. package/umd/typings/utils/expectation-counters/countWords.test.d.ts +1 -1
  302. package/umd/typings/utils/expectation-counters/index.d.ts +5 -5
  303. package/umd/typings/utils/extractParameters.d.ts +10 -10
  304. package/umd/typings/utils/extractParameters.test.d.ts +1 -1
  305. package/umd/typings/utils/formatNumber.d.ts +6 -6
  306. package/umd/typings/utils/formatNumber.test.d.ts +1 -1
  307. package/umd/typings/utils/getCurrentIsoDate.d.ts +7 -7
  308. package/umd/typings/utils/isRunningInWhatever.d.ts +12 -12
  309. package/umd/typings/utils/isValidJsonString.d.ts +4 -4
  310. package/umd/typings/utils/isValidJsonString.test.d.ts +1 -1
  311. package/umd/typings/utils/just.d.ts +10 -10
  312. package/umd/typings/utils/markdown/addAutoGeneratedSection.d.ts +10 -10
  313. package/umd/typings/utils/markdown/addAutoGeneratedSection.test.d.ts +1 -1
  314. package/umd/typings/utils/markdown/createMarkdownChart.d.ts +41 -41
  315. package/umd/typings/utils/markdown/createMarkdownChart.test.d.ts +1 -1
  316. package/umd/typings/utils/markdown/createMarkdownTable.d.ts +7 -7
  317. package/umd/typings/utils/markdown/createMarkdownTable.test.d.ts +1 -1
  318. package/umd/typings/utils/markdown/escapeMarkdownBlock.d.ts +6 -6
  319. package/umd/typings/utils/markdown/escapeMarkdownBlock.test.d.ts +1 -1
  320. package/umd/typings/utils/markdown/extractAllBlocksFromMarkdown.d.ts +27 -27
  321. package/umd/typings/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts +1 -1
  322. package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +13 -13
  323. package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -1
  324. package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +19 -19
  325. package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -1
  326. package/umd/typings/utils/markdown/prettifyMarkdown.d.ts +8 -8
  327. package/umd/typings/utils/markdown/prettifyMarkdown.test.d.ts +1 -1
  328. package/umd/typings/utils/markdown/removeContentComments.d.ts +8 -8
  329. package/umd/typings/utils/markdown/removeContentComments.test.d.ts +1 -1
  330. package/umd/typings/utils/markdown/removeMarkdownFormatting.d.ts +8 -8
  331. package/umd/typings/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -1
  332. package/umd/typings/utils/markdown-json/MarkdownStructure.d.ts +25 -25
  333. package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +7 -7
  334. package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts +1 -1
  335. package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +13 -13
  336. package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.test.d.ts +1 -1
  337. package/umd/typings/utils/postprocessing/extractBlock.d.ts +12 -12
  338. package/umd/typings/utils/removeEmojis.d.ts +7 -7
  339. package/umd/typings/utils/removeEmojis.test.d.ts +1 -1
  340. package/umd/typings/utils/removeQuotes.d.ts +13 -13
  341. package/umd/typings/utils/removeQuotes.test.d.ts +1 -1
  342. package/umd/typings/utils/trimCodeBlock.d.ts +8 -8
  343. package/umd/typings/utils/trimCodeBlock.test.d.ts +1 -1
  344. package/umd/typings/utils/trimEndOfCodeBlock.d.ts +7 -7
  345. package/umd/typings/utils/trimEndOfCodeBlock.test.d.ts +1 -1
  346. package/umd/typings/utils/unwrapResult.d.ts +36 -36
  347. package/umd/typings/utils/unwrapResult.test.d.ts +1 -1
  348. package/umd/typings/utils/validators/url/isValidUrl.d.ts +7 -7
  349. package/umd/typings/utils/validators/url/isValidUrl.test.d.ts +1 -1
  350. package/umd/typings/version.d.ts +5 -5
  351. package/umd/typings/wizzard/Wizzard.d.ts +4 -4
  352. package/umd/typings/wizzard/sample.d.ts +6 -6
package/esm/index.es.js CHANGED
@@ -85,858 +85,858 @@ function __spreadArray(to, from, pack) {
85
85
  return to.concat(ar || Array.prototype.slice.call(from));
86
86
  }
87
87
 
88
- /**
89
- * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
90
- */
91
- var PromptbookSyntaxError = /** @class */ (function (_super) {
92
- __extends(PromptbookSyntaxError, _super);
93
- function PromptbookSyntaxError(message) {
94
- var _this = _super.call(this, message) || this;
95
- _this.name = 'PromptbookSyntaxError';
96
- Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
97
- return _this;
98
- }
99
- return PromptbookSyntaxError;
88
+ /**
89
+ * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
90
+ */
91
+ var PromptbookSyntaxError = /** @class */ (function (_super) {
92
+ __extends(PromptbookSyntaxError, _super);
93
+ function PromptbookSyntaxError(message) {
94
+ var _this = _super.call(this, message) || this;
95
+ _this.name = 'PromptbookSyntaxError';
96
+ Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
97
+ return _this;
98
+ }
99
+ return PromptbookSyntaxError;
100
100
  }(Error));
101
101
 
102
- /**
103
- * Function parseNumber will parse number from string
104
- *
105
- * Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
106
- * Note: it also works only with decimal numbers
107
- *
108
- * @private within the parseCommand
109
- */
110
- function parseNumber(value) {
111
- var originalValue = value;
112
- if (typeof value === 'number') {
113
- value = value.toString(); // <- TODO: Maybe more efficient way to do this
114
- }
115
- if (typeof value !== 'string') {
116
- return 0;
117
- }
118
- value = value.trim();
119
- if (value.startsWith('+')) {
120
- return parseNumber(value.substring(1));
121
- }
122
- if (value.startsWith('-')) {
123
- var number = parseNumber(value.substring(1));
124
- if (number === 0) {
125
- return 0; // <- Note: To prevent -0
126
- }
127
- return -number;
128
- }
129
- value = value.replace(/,/g, '.');
130
- value = value.toUpperCase();
131
- if (value === '') {
132
- return 0;
133
- }
134
- if (value === '♾' || value.startsWith('INF')) {
135
- return Infinity;
136
- }
137
- if (value.includes('/')) {
138
- var _a = __read(value.split('/'), 2), numerator_ = _a[0], denominator_ = _a[1];
139
- var numerator = parseNumber(numerator_);
140
- var denominator = parseNumber(denominator_);
141
- if (denominator === 0) {
142
- throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
143
- }
144
- return numerator / denominator;
145
- }
146
- if (/^(NAN|NULL|NONE|UNDEFINED|ZERO|NO.*)$/.test(value)) {
147
- return 0;
148
- }
149
- if (value.includes('E')) {
150
- var _b = __read(value.split('E'), 2), significand = _b[0], exponent = _b[1];
151
- return parseNumber(significand) * Math.pow(10, parseNumber(exponent));
152
- }
153
- if (!/^[0-9.]+$/.test(value) || value.split('.').length > 2) {
154
- throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\""));
155
- }
156
- var num = parseFloat(value);
157
- if (isNaN(num)) {
158
- throw new PromptbookSyntaxError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
159
- }
160
- return num;
161
- }
162
- /**
163
- * TODO: Maybe use sth. like safe-eval in fraction/calculation case @see https://www.npmjs.com/package/safe-eval
164
- */
165
-
166
- /**
167
- * This error indicates errors during the execution of the promptbook
168
- */
169
- var PromptbookExecutionError = /** @class */ (function (_super) {
170
- __extends(PromptbookExecutionError, _super);
171
- function PromptbookExecutionError(message) {
172
- var _this = _super.call(this, message) || this;
173
- _this.name = 'PromptbookExecutionError';
174
- Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
175
- return _this;
176
- }
177
- return PromptbookExecutionError;
102
+ /**
103
+ * Function parseNumber will parse number from string
104
+ *
105
+ * Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
106
+ * Note: it also works only with decimal numbers
107
+ *
108
+ * @private within the parseCommand
109
+ */
110
+ function parseNumber(value) {
111
+ var originalValue = value;
112
+ if (typeof value === 'number') {
113
+ value = value.toString(); // <- TODO: Maybe more efficient way to do this
114
+ }
115
+ if (typeof value !== 'string') {
116
+ return 0;
117
+ }
118
+ value = value.trim();
119
+ if (value.startsWith('+')) {
120
+ return parseNumber(value.substring(1));
121
+ }
122
+ if (value.startsWith('-')) {
123
+ var number = parseNumber(value.substring(1));
124
+ if (number === 0) {
125
+ return 0; // <- Note: To prevent -0
126
+ }
127
+ return -number;
128
+ }
129
+ value = value.replace(/,/g, '.');
130
+ value = value.toUpperCase();
131
+ if (value === '') {
132
+ return 0;
133
+ }
134
+ if (value === '♾' || value.startsWith('INF')) {
135
+ return Infinity;
136
+ }
137
+ if (value.includes('/')) {
138
+ var _a = __read(value.split('/'), 2), numerator_ = _a[0], denominator_ = _a[1];
139
+ var numerator = parseNumber(numerator_);
140
+ var denominator = parseNumber(denominator_);
141
+ if (denominator === 0) {
142
+ throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
143
+ }
144
+ return numerator / denominator;
145
+ }
146
+ if (/^(NAN|NULL|NONE|UNDEFINED|ZERO|NO.*)$/.test(value)) {
147
+ return 0;
148
+ }
149
+ if (value.includes('E')) {
150
+ var _b = __read(value.split('E'), 2), significand = _b[0], exponent = _b[1];
151
+ return parseNumber(significand) * Math.pow(10, parseNumber(exponent));
152
+ }
153
+ if (!/^[0-9.]+$/.test(value) || value.split('.').length > 2) {
154
+ throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\""));
155
+ }
156
+ var num = parseFloat(value);
157
+ if (isNaN(num)) {
158
+ throw new PromptbookSyntaxError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
159
+ }
160
+ return num;
161
+ }
162
+ /**
163
+ * TODO: Maybe use sth. like safe-eval in fraction/calculation case @see https://www.npmjs.com/package/safe-eval
164
+ */
165
+
166
+ /**
167
+ * This error indicates errors during the execution of the promptbook
168
+ */
169
+ var PromptbookExecutionError = /** @class */ (function (_super) {
170
+ __extends(PromptbookExecutionError, _super);
171
+ function PromptbookExecutionError(message) {
172
+ var _this = _super.call(this, message) || this;
173
+ _this.name = 'PromptbookExecutionError';
174
+ Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
175
+ return _this;
176
+ }
177
+ return PromptbookExecutionError;
178
178
  }(Error));
179
179
 
180
- /**
181
- * Asserts that the execution of a promptnook is successful
182
- *
183
- * @param executionResult - The partial result of the promptnook execution
184
- * @throws Error - If the execution is not successful or if multiple errors occurred
185
- */
186
- function assertsExecutionSuccessful(executionResult) {
187
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
188
- if (isSuccessful === true) {
189
- return;
190
- }
191
- if (errors.length === 0) {
192
- throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
193
- }
194
- else if (errors.length === 1) {
195
- throw errors[0];
196
- }
197
- else {
198
- throw new PromptbookExecutionError(spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
199
- }
200
- }
201
- /**
202
- * TODO: [🧠] Can this return type be better typed than void
180
+ /**
181
+ * Asserts that the execution of a promptnook is successful
182
+ *
183
+ * @param executionResult - The partial result of the promptnook execution
184
+ * @throws Error - If the execution is not successful or if multiple errors occurred
185
+ */
186
+ function assertsExecutionSuccessful(executionResult) {
187
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
188
+ if (isSuccessful === true) {
189
+ return;
190
+ }
191
+ if (errors.length === 0) {
192
+ throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
193
+ }
194
+ else if (errors.length === 1) {
195
+ throw errors[0];
196
+ }
197
+ else {
198
+ throw new PromptbookExecutionError(spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
199
+ }
200
+ }
201
+ /**
202
+ * TODO: [🧠] Can this return type be better typed than void
203
203
  */
204
204
 
205
- /**
206
- * Default options for generating an execution report string
207
- */
208
- var ExecutionReportStringOptionsDefaults = {
209
- taxRate: 0,
210
- chartsWidth: 36,
205
+ /**
206
+ * Default options for generating an execution report string
207
+ */
208
+ var ExecutionReportStringOptionsDefaults = {
209
+ taxRate: 0,
210
+ chartsWidth: 36,
211
211
  };
212
212
 
213
- /**
214
- * Format either small or big number
215
- *
216
- * @private within the library
217
- */
218
- function formatNumber(value) {
219
- if (value === 0) {
220
- return '0';
221
- }
222
- for (var exponent = 0; exponent < 15; exponent++) {
223
- var factor = Math.pow(10, exponent);
224
- var valueRounded = Math.round(value * factor) / factor;
225
- if (Math.abs(value - valueRounded) / value <
226
- 0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
227
- return valueRounded.toFixed(exponent);
228
- }
229
- }
230
- return value.toString();
213
+ /**
214
+ * Format either small or big number
215
+ *
216
+ * @private within the library
217
+ */
218
+ function formatNumber(value) {
219
+ if (value === 0) {
220
+ return '0';
221
+ }
222
+ for (var exponent = 0; exponent < 15; exponent++) {
223
+ var factor = Math.pow(10, exponent);
224
+ var valueRounded = Math.round(value * factor) / factor;
225
+ if (Math.abs(value - valueRounded) / value <
226
+ 0.001 /* <- TODO: Pass as option, pass to executionReportJsonToString as option */) {
227
+ return valueRounded.toFixed(exponent);
228
+ }
229
+ }
230
+ return value.toString();
231
231
  }
232
232
 
233
- /**
234
- * Returns the same value that is passed as argument.
235
- * No side effects.
236
- *
237
- * Note: It can be usefull for leveling indentation
238
- *
239
- * @param value any values
240
- * @returns the same values
241
- */
242
- function just(value) {
243
- if (value === undefined) {
244
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
- return undefined;
246
- }
247
- return value;
233
+ /**
234
+ * Returns the same value that is passed as argument.
235
+ * No side effects.
236
+ *
237
+ * Note: It can be usefull for leveling indentation
238
+ *
239
+ * @param value any values
240
+ * @returns the same values
241
+ */
242
+ function just(value) {
243
+ if (value === undefined) {
244
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
+ return undefined;
246
+ }
247
+ return value;
248
248
  }
249
249
 
250
- /**
251
- * Removes emojis from a string and fix whitespaces
252
- *
253
- * @param text with emojis
254
- * @returns text without emojis
255
- */
256
- function removeEmojis(text) {
257
- // Replace emojis (and also ZWJ sequence) with hyphens
258
- text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
259
- text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
260
- text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
261
- text = text.replace(/\p{Extended_Pictographic}/gu, '');
262
- return text;
250
+ /**
251
+ * Removes emojis from a string and fix whitespaces
252
+ *
253
+ * @param text with emojis
254
+ * @returns text without emojis
255
+ */
256
+ function removeEmojis(text) {
257
+ // Replace emojis (and also ZWJ sequence) with hyphens
258
+ text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
259
+ text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
260
+ text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
261
+ text = text.replace(/\p{Extended_Pictographic}/gu, '');
262
+ return text;
263
263
  }
264
264
 
265
- /**
266
- * Create a markdown table from a 2D array of strings
267
- *
268
- * @private within the library
269
- */
270
- function createMarkdownTable(table) {
271
- var columnWidths = table.reduce(function (widths, row) {
272
- row.forEach(function (cell, columnIndex) {
273
- var cellLength = cell.length;
274
- if (!widths[columnIndex] || cellLength > widths[columnIndex]) {
275
- widths[columnIndex] = cellLength;
276
- }
277
- });
278
- return widths;
279
- }, []);
280
- var header = "| ".concat(table[0]
281
- .map(function (cell, columnIndex) { return cell.padEnd(columnWidths[columnIndex]); })
282
- .join(' | '), " |");
283
- var separator = "|".concat(columnWidths.map(function (width) { return '-'.repeat(width + 2); }).join('|'), "|");
284
- var rows = table.slice(1).map(function (row) {
285
- var paddedRow = row.map(function (cell, columnIndex) {
286
- return cell.padEnd(columnWidths[columnIndex]);
287
- });
288
- return "| ".concat(paddedRow.join(' | '), " |");
289
- });
290
- return __spreadArray([header, separator], __read(rows), false).join('\n');
265
+ /**
266
+ * Create a markdown table from a 2D array of strings
267
+ *
268
+ * @private within the library
269
+ */
270
+ function createMarkdownTable(table) {
271
+ var columnWidths = table.reduce(function (widths, row) {
272
+ row.forEach(function (cell, columnIndex) {
273
+ var cellLength = cell.length;
274
+ if (!widths[columnIndex] || cellLength > widths[columnIndex]) {
275
+ widths[columnIndex] = cellLength;
276
+ }
277
+ });
278
+ return widths;
279
+ }, []);
280
+ var header = "| ".concat(table[0]
281
+ .map(function (cell, columnIndex) { return cell.padEnd(columnWidths[columnIndex]); })
282
+ .join(' | '), " |");
283
+ var separator = "|".concat(columnWidths.map(function (width) { return '-'.repeat(width + 2); }).join('|'), "|");
284
+ var rows = table.slice(1).map(function (row) {
285
+ var paddedRow = row.map(function (cell, columnIndex) {
286
+ return cell.padEnd(columnWidths[columnIndex]);
287
+ });
288
+ return "| ".concat(paddedRow.join(' | '), " |");
289
+ });
290
+ return __spreadArray([header, separator], __read(rows), false).join('\n');
291
291
  }
292
292
 
293
- /**
294
- * Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
295
- *
296
- * @private within the library
297
- */
298
- function createMarkdownChart(options) {
299
- var e_1, _a;
300
- var nameHeader = options.nameHeader, valueHeader = options.valueHeader, items = options.items, width = options.width, unitName = options.unitName;
301
- var from = Math.min.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.from; })), false));
302
- var to = Math.max.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.to; })), false));
303
- var scale = width / (to - from);
304
- var table = [[nameHeader, valueHeader]];
305
- try {
306
- for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
307
- var item = items_1_1.value;
308
- var before = Math.round((item.from - from) * scale);
309
- var during = Math.round((item.to - item.from) * scale);
310
- var after = width - before - during;
311
- table.push([removeEmojis(item.title).trim(), '░'.repeat(before) + '█'.repeat(during) + '░'.repeat(after)]);
312
- }
313
- }
314
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
315
- finally {
316
- try {
317
- if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
318
- }
319
- finally { if (e_1) throw e_1.error; }
320
- }
321
- var legend = "_Note: Each \u2588 represents ".concat(formatNumber(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(formatNumber(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
322
- return createMarkdownTable(table) + '\n\n' + legend;
323
- }
324
- /**
325
- * TODO: Maybe use Mermain Gant Diagrams
326
- * @see https://jojozhuang.github.io/tutorial/mermaid-cheat-sheet/
293
+ /**
294
+ * Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
295
+ *
296
+ * @private within the library
297
+ */
298
+ function createMarkdownChart(options) {
299
+ var e_1, _a;
300
+ var nameHeader = options.nameHeader, valueHeader = options.valueHeader, items = options.items, width = options.width, unitName = options.unitName;
301
+ var from = Math.min.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.from; })), false));
302
+ var to = Math.max.apply(Math, __spreadArray([], __read(items.map(function (item) { return item.to; })), false));
303
+ var scale = width / (to - from);
304
+ var table = [[nameHeader, valueHeader]];
305
+ try {
306
+ for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
307
+ var item = items_1_1.value;
308
+ var before = Math.round((item.from - from) * scale);
309
+ var during = Math.round((item.to - item.from) * scale);
310
+ var after = width - before - during;
311
+ table.push([removeEmojis(item.title).trim(), '░'.repeat(before) + '█'.repeat(during) + '░'.repeat(after)]);
312
+ }
313
+ }
314
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
315
+ finally {
316
+ try {
317
+ if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
318
+ }
319
+ finally { if (e_1) throw e_1.error; }
320
+ }
321
+ var legend = "_Note: Each \u2588 represents ".concat(formatNumber(1 / scale), " ").concat(unitName, ", width of ").concat(valueHeader.toLowerCase(), " is ").concat(formatNumber(to - from), " ").concat(unitName, " = ").concat(width, " squares_");
322
+ return createMarkdownTable(table) + '\n\n' + legend;
323
+ }
324
+ /**
325
+ * TODO: Maybe use Mermain Gant Diagrams
326
+ * @see https://jojozhuang.github.io/tutorial/mermaid-cheat-sheet/
327
327
  */
328
328
 
329
- /**
330
- * Function escapeMarkdownBlock will escape markdown block if needed
331
- * It is useful when you want have block in block
332
- */
333
- function escapeMarkdownBlock(value) {
334
- return value.replace(/```/g, '\\`\\`\\`');
329
+ /**
330
+ * Function escapeMarkdownBlock will escape markdown block if needed
331
+ * It is useful when you want have block in block
332
+ */
333
+ function escapeMarkdownBlock(value) {
334
+ return value.replace(/```/g, '\\`\\`\\`');
335
335
  }
336
336
 
337
- /**
338
- * Prettify the html code
339
- *
340
- * @param html raw html code
341
- * @returns formatted html code
342
- */
343
- function prettifyMarkdown(html) {
344
- try {
345
- return format(html, {
346
- parser: 'markdown',
347
- plugins: [parserHtml],
348
- // TODO: DRY - make some import or auto-copy of .prettierrc
349
- endOfLine: 'lf',
350
- tabWidth: 4,
351
- singleQuote: true,
352
- trailingComma: 'all',
353
- arrowParens: 'always',
354
- printWidth: 120,
355
- htmlWhitespaceSensitivity: 'ignore',
356
- jsxBracketSameLine: false,
357
- bracketSpacing: true,
358
- });
359
- }
360
- catch (error) {
361
- console.error('There was an error with prettifying the markdown, using the original as the fallback', {
362
- error: error,
363
- html: html,
364
- });
365
- return html;
366
- }
337
+ /**
338
+ * Prettify the html code
339
+ *
340
+ * @param html raw html code
341
+ * @returns formatted html code
342
+ */
343
+ function prettifyMarkdown(html) {
344
+ try {
345
+ return format(html, {
346
+ parser: 'markdown',
347
+ plugins: [parserHtml],
348
+ // TODO: DRY - make some import or auto-copy of .prettierrc
349
+ endOfLine: 'lf',
350
+ tabWidth: 4,
351
+ singleQuote: true,
352
+ trailingComma: 'all',
353
+ arrowParens: 'always',
354
+ printWidth: 120,
355
+ htmlWhitespaceSensitivity: 'ignore',
356
+ jsxBracketSameLine: false,
357
+ bracketSpacing: true,
358
+ });
359
+ }
360
+ catch (error) {
361
+ console.error('There was an error with prettifying the markdown, using the original as the fallback', {
362
+ error: error,
363
+ html: html,
364
+ });
365
+ return html;
366
+ }
367
367
  }
368
368
 
369
- /**
370
- * The thresholds for the relative time in the `moment` library.
371
- *
372
- * @see https://momentjscom.readthedocs.io/en/latest/moment/07-customization/13-relative-time-threshold/
373
- */
374
- var MOMENT_ARG_THRESHOLDS = {
375
- ss: 3, // <- least number of seconds to be counted in seconds, minus 1. Must be set after setting the `s` unit or without setting the `s` unit.
369
+ /**
370
+ * The thresholds for the relative time in the `moment` library.
371
+ *
372
+ * @see https://momentjscom.readthedocs.io/en/latest/moment/07-customization/13-relative-time-threshold/
373
+ */
374
+ var MOMENT_ARG_THRESHOLDS = {
375
+ ss: 3, // <- least number of seconds to be counted in seconds, minus 1. Must be set after setting the `s` unit or without setting the `s` unit.
376
376
  };
377
377
 
378
- /**
379
- * Count the duration of working time
380
- *
381
- * @private within the library
382
- */
383
- function countWorkingDuration(items) {
384
- var e_1, _a;
385
- var steps = Array.from(new Set(items.flatMap(function (item) { return [item.from, item.to]; })));
386
- steps.sort(function (a, b) { return a - b; });
387
- var intervals = steps.map(function (step, index) { return [step, steps[index + 1] || 0]; }).slice(0, -1);
388
- var duration = 0;
389
- var _loop_1 = function (interval) {
390
- var _b = __read(interval, 2), from = _b[0], to = _b[1];
391
- if (items.some(function (item) { return item.from < to && item.to > from; })) {
392
- duration += to - from;
393
- }
394
- };
395
- try {
396
- for (var intervals_1 = __values(intervals), intervals_1_1 = intervals_1.next(); !intervals_1_1.done; intervals_1_1 = intervals_1.next()) {
397
- var interval = intervals_1_1.value;
398
- _loop_1(interval);
399
- }
400
- }
401
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
402
- finally {
403
- try {
404
- if (intervals_1_1 && !intervals_1_1.done && (_a = intervals_1.return)) _a.call(intervals_1);
405
- }
406
- finally { if (e_1) throw e_1.error; }
407
- }
408
- return duration;
409
- }
410
-
411
- /**
412
- * Converts execution report from JSON to string format
413
- */
414
- function executionReportJsonToString(executionReportJson, options) {
415
- var e_1, _a;
416
- var _b, _c, _d, _e, _f, _g;
417
- var _h = __assign(__assign({}, ExecutionReportStringOptionsDefaults), (options || {})), taxRate = _h.taxRate, chartsWidth = _h.chartsWidth;
418
- var executionReportString = spaceTrim(function (block) { return "\n # ".concat(executionReportJson.title || 'Execution report', "\n\n ").concat(block(executionReportJson.description || ''), "\n "); });
419
- var headerList = [];
420
- if (executionReportJson.promptbookUrl) {
421
- headerList.push("PROMPTBOOK URL ".concat(executionReportJson.promptbookUrl));
422
- }
423
- headerList.push("PROMPTBOOK VERSION ".concat(executionReportJson.promptbookUsedVersion) +
424
- (!executionReportJson.promptbookRequestedVersion
425
- ? ''
426
- : " *(requested ".concat(executionReportJson.promptbookRequestedVersion, ")*")));
427
- if (executionReportJson.promptExecutions.length !== 0) {
428
- // TODO: What if startedAt OR/AND completedAt is not defined?
429
- var startedAt = moment(Math.min.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
430
- .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start; })
431
- .map(function (promptExecution) { return moment(promptExecution.result.timing.start).valueOf(); })), false)));
432
- var completedAt = moment(Math.max.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
433
- .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.complete; })
434
- .map(function (promptExecution) { return moment(promptExecution.result.timing.complete).valueOf(); })), false)));
435
- var timingItems = executionReportJson.promptExecutions.map(function (promptExecution) {
436
- var _a, _b, _c, _d;
437
- return ({
438
- title: promptExecution.prompt.title,
439
- from: moment((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start).valueOf() / 1000,
440
- to: moment((_d = (_c = promptExecution.result) === null || _c === void 0 ? void 0 : _c.timing) === null || _d === void 0 ? void 0 : _d.complete).valueOf() / 1000,
441
- });
442
- });
443
- var costItems = executionReportJson.promptExecutions
444
- .filter(function (promptExecution) { var _a, _b; return typeof ((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) === 'number'; })
445
- .map(function (promptExecution) {
446
- var _a, _b;
447
- return ({
448
- title: promptExecution.prompt.title,
449
- from: 0,
450
- to: ((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) * (1 + taxRate),
451
- });
452
- });
453
- var duration = moment.duration(completedAt.diff(startedAt));
454
- var naturalDuration = moment.duration(countWorkingDuration(timingItems) * 1000);
455
- var executionsWithKnownCost = executionReportJson.promptExecutions.filter(function (promptExecution) { var _a, _b; return (((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) || 'UNKNOWN') !== 'UNKNOWN'; });
456
- var cost = executionsWithKnownCost.reduce(function (cost, promptExecution) { return cost + (promptExecution.result.usage.price || 0); }, 0);
457
- headerList.push("STARTED AT ".concat(moment(startedAt).format("YYYY-MM-DD HH:mm:ss")));
458
- headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
459
- headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
460
- headerList.push("TOTAL NATURAL DURATION ".concat(naturalDuration.humanize(MOMENT_ARG_THRESHOLDS)));
461
- headerList.push("TOTAL COST $".concat(formatNumber(cost * (1 + taxRate))) +
462
- (executionsWithKnownCost.length === executionReportJson.promptExecutions.length
463
- ? ''
464
- : " *(Some cost is unknown)*") +
465
- (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
466
- executionReportString += '\n\n' + headerList.map(function (header) { return "- ".concat(header); }).join('\n');
467
- executionReportString +=
468
- '\n\n' +
469
- '## 🗃 Index' +
470
- '\n\n' +
471
- executionReportJson.promptExecutions
472
- .map(function (promptExecution) {
473
- // TODO: Make some better system to convert hedings to links
474
- var hash = normalizeToKebabCase(promptExecution.prompt.title);
475
- if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
476
- hash = '-' + hash;
477
- }
478
- // TODO: Make working hash link for the template in md + pdf
479
- return "- [".concat(promptExecution.prompt.title, "](#").concat(hash, ")");
480
- })
481
- .join('\n');
482
- executionReportString +=
483
- '\n\n' +
484
- '## ⌚ Time chart' +
485
- '\n\n' +
486
- createMarkdownChart({
487
- nameHeader: 'Template',
488
- valueHeader: 'Timeline',
489
- items: timingItems,
490
- width: chartsWidth,
491
- unitName: 'seconds',
492
- });
493
- executionReportString +=
494
- '\n\n' +
495
- '## 💸 Cost chart' +
496
- '\n\n' +
497
- createMarkdownChart({
498
- nameHeader: 'Template',
499
- valueHeader: 'Cost',
500
- items: costItems,
501
- width: chartsWidth,
502
- unitName: 'USD',
503
- });
504
- }
505
- else {
506
- headerList.push("TOTAL COST $0 *(Nothing executed)*");
507
- }
508
- var _loop_1 = function (promptExecution) {
509
- executionReportString += '\n\n\n\n' + "## ".concat(promptExecution.prompt.title);
510
- var templateList = [];
511
- // TODO: What if startedAt OR/AND completedAt is not defined?
512
- var startedAt = moment((_c = (_b = promptExecution.result) === null || _b === void 0 ? void 0 : _b.timing) === null || _c === void 0 ? void 0 : _c.start);
513
- var completedAt = moment((_e = (_d = promptExecution.result) === null || _d === void 0 ? void 0 : _d.timing) === null || _e === void 0 ? void 0 : _e.complete);
514
- var duration = moment.duration(completedAt.diff(startedAt));
515
- // Not need here:
516
- // > templateList.push(`STARTED AT ${moment(startedAt).calendar()}`);
517
- templateList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
518
- if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
519
- templateList.push("COST $".concat(formatNumber(promptExecution.result.usage.price * (1 + taxRate))) +
520
- (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
521
- }
522
- else {
523
- templateList.push("COST UNKNOWN");
524
- }
525
- executionReportString += '\n\n' + templateList.map(function (header) { return "- ".concat(header); }).join('\n');
526
- /*
527
- - MODEL VARIANT ${promptExecution.prompt.modelRequirements.modelVariant}
528
- - MODEL NAME \`${promptExecution.result?.model}\` (requested \`${
529
- promptExecution.prompt.modelRequirements.modelName
530
-
531
- */
532
- if (just(true)) {
533
- executionReportString +=
534
- '\n\n\n\n' +
535
- spaceTrim(function (block) { return "\n\n ### Prompt\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.prompt.content)), "\n ```\n\n "); });
536
- }
537
- if (promptExecution.result && promptExecution.result.content) {
538
- executionReportString +=
539
- '\n\n\n\n' +
540
- spaceTrim(function (block) { return "\n\n ### Result\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.result.content)), "\n ```\n "); });
541
- }
542
- if (promptExecution.error && promptExecution.error.message) {
543
- executionReportString +=
544
- '\n\n\n\n' +
545
- spaceTrim(function (block) { return "\n\n ### Error\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.error.message)), "\n ```\n\n "); });
546
- }
547
- };
548
- try {
549
- for (var _j = __values(executionReportJson.promptExecutions), _k = _j.next(); !_k.done; _k = _j.next()) {
550
- var promptExecution = _k.value;
551
- _loop_1(promptExecution);
552
- }
553
- }
554
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
555
- finally {
556
- try {
557
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
558
- }
559
- finally { if (e_1) throw e_1.error; }
560
- }
561
- executionReportString = prettifyMarkdown(executionReportString);
562
- return executionReportString;
378
+ /**
379
+ * Count the duration of working time
380
+ *
381
+ * @private within the library
382
+ */
383
+ function countWorkingDuration(items) {
384
+ var e_1, _a;
385
+ var steps = Array.from(new Set(items.flatMap(function (item) { return [item.from, item.to]; })));
386
+ steps.sort(function (a, b) { return a - b; });
387
+ var intervals = steps.map(function (step, index) { return [step, steps[index + 1] || 0]; }).slice(0, -1);
388
+ var duration = 0;
389
+ var _loop_1 = function (interval) {
390
+ var _b = __read(interval, 2), from = _b[0], to = _b[1];
391
+ if (items.some(function (item) { return item.from < to && item.to > from; })) {
392
+ duration += to - from;
393
+ }
394
+ };
395
+ try {
396
+ for (var intervals_1 = __values(intervals), intervals_1_1 = intervals_1.next(); !intervals_1_1.done; intervals_1_1 = intervals_1.next()) {
397
+ var interval = intervals_1_1.value;
398
+ _loop_1(interval);
399
+ }
400
+ }
401
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
402
+ finally {
403
+ try {
404
+ if (intervals_1_1 && !intervals_1_1.done && (_a = intervals_1.return)) _a.call(intervals_1);
405
+ }
406
+ finally { if (e_1) throw e_1.error; }
407
+ }
408
+ return duration;
563
409
  }
564
- /**
565
- * TODO: Add mermaid chart for every report
566
- * TODO: [🧠] Allow to filter out some parts of the report by options
567
- */
568
410
 
569
- /**
570
- * Counts number of characters in the text
571
- */
572
- function countCharacters(text) {
573
- // Remove null characters
574
- text = text.replace(/\0/g, '');
575
- // Replace emojis (and also ZWJ sequence) with hyphens
576
- text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
577
- text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
578
- text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
579
- return text.length;
411
+ /**
412
+ * Converts execution report from JSON to string format
413
+ */
414
+ function executionReportJsonToString(executionReportJson, options) {
415
+ var e_1, _a;
416
+ var _b, _c, _d, _e, _f, _g;
417
+ var _h = __assign(__assign({}, ExecutionReportStringOptionsDefaults), (options || {})), taxRate = _h.taxRate, chartsWidth = _h.chartsWidth;
418
+ var executionReportString = spaceTrim(function (block) { return "\n # ".concat(executionReportJson.title || 'Execution report', "\n\n ").concat(block(executionReportJson.description || ''), "\n "); });
419
+ var headerList = [];
420
+ if (executionReportJson.promptbookUrl) {
421
+ headerList.push("PROMPTBOOK URL ".concat(executionReportJson.promptbookUrl));
422
+ }
423
+ headerList.push("PROMPTBOOK VERSION ".concat(executionReportJson.promptbookUsedVersion) +
424
+ (!executionReportJson.promptbookRequestedVersion
425
+ ? ''
426
+ : " *(requested ".concat(executionReportJson.promptbookRequestedVersion, ")*")));
427
+ if (executionReportJson.promptExecutions.length !== 0) {
428
+ // TODO: What if startedAt OR/AND completedAt is not defined?
429
+ var startedAt = moment(Math.min.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
430
+ .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start; })
431
+ .map(function (promptExecution) { return moment(promptExecution.result.timing.start).valueOf(); })), false)));
432
+ var completedAt = moment(Math.max.apply(Math, __spreadArray([], __read(executionReportJson.promptExecutions
433
+ .filter(function (promptExecution) { var _a, _b; return (_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.complete; })
434
+ .map(function (promptExecution) { return moment(promptExecution.result.timing.complete).valueOf(); })), false)));
435
+ var timingItems = executionReportJson.promptExecutions.map(function (promptExecution) {
436
+ var _a, _b, _c, _d;
437
+ return ({
438
+ title: promptExecution.prompt.title,
439
+ from: moment((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.timing) === null || _b === void 0 ? void 0 : _b.start).valueOf() / 1000,
440
+ to: moment((_d = (_c = promptExecution.result) === null || _c === void 0 ? void 0 : _c.timing) === null || _d === void 0 ? void 0 : _d.complete).valueOf() / 1000,
441
+ });
442
+ });
443
+ var costItems = executionReportJson.promptExecutions
444
+ .filter(function (promptExecution) { var _a, _b; return typeof ((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) === 'number'; })
445
+ .map(function (promptExecution) {
446
+ var _a, _b;
447
+ return ({
448
+ title: promptExecution.prompt.title,
449
+ from: 0,
450
+ to: ((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) * (1 + taxRate),
451
+ });
452
+ });
453
+ var duration = moment.duration(completedAt.diff(startedAt));
454
+ var naturalDuration = moment.duration(countWorkingDuration(timingItems) * 1000);
455
+ var executionsWithKnownCost = executionReportJson.promptExecutions.filter(function (promptExecution) { var _a, _b; return (((_b = (_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.usage) === null || _b === void 0 ? void 0 : _b.price) || 'UNKNOWN') !== 'UNKNOWN'; });
456
+ var cost = executionsWithKnownCost.reduce(function (cost, promptExecution) { return cost + (promptExecution.result.usage.price || 0); }, 0);
457
+ headerList.push("STARTED AT ".concat(moment(startedAt).format("YYYY-MM-DD HH:mm:ss")));
458
+ headerList.push("COMPLETED AT ".concat(moment(completedAt).format("YYYY-MM-DD HH:mm:ss")));
459
+ headerList.push("TOTAL DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
460
+ headerList.push("TOTAL NATURAL DURATION ".concat(naturalDuration.humanize(MOMENT_ARG_THRESHOLDS)));
461
+ headerList.push("TOTAL COST $".concat(formatNumber(cost * (1 + taxRate))) +
462
+ (executionsWithKnownCost.length === executionReportJson.promptExecutions.length
463
+ ? ''
464
+ : " *(Some cost is unknown)*") +
465
+ (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
466
+ executionReportString += '\n\n' + headerList.map(function (header) { return "- ".concat(header); }).join('\n');
467
+ executionReportString +=
468
+ '\n\n' +
469
+ '## 🗃 Index' +
470
+ '\n\n' +
471
+ executionReportJson.promptExecutions
472
+ .map(function (promptExecution) {
473
+ // TODO: Make some better system to convert hedings to links
474
+ var hash = normalizeToKebabCase(promptExecution.prompt.title);
475
+ if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
476
+ hash = '-' + hash;
477
+ }
478
+ // TODO: Make working hash link for the template in md + pdf
479
+ return "- [".concat(promptExecution.prompt.title, "](#").concat(hash, ")");
480
+ })
481
+ .join('\n');
482
+ executionReportString +=
483
+ '\n\n' +
484
+ '## ⌚ Time chart' +
485
+ '\n\n' +
486
+ createMarkdownChart({
487
+ nameHeader: 'Template',
488
+ valueHeader: 'Timeline',
489
+ items: timingItems,
490
+ width: chartsWidth,
491
+ unitName: 'seconds',
492
+ });
493
+ executionReportString +=
494
+ '\n\n' +
495
+ '## 💸 Cost chart' +
496
+ '\n\n' +
497
+ createMarkdownChart({
498
+ nameHeader: 'Template',
499
+ valueHeader: 'Cost',
500
+ items: costItems,
501
+ width: chartsWidth,
502
+ unitName: 'USD',
503
+ });
504
+ }
505
+ else {
506
+ headerList.push("TOTAL COST $0 *(Nothing executed)*");
507
+ }
508
+ var _loop_1 = function (promptExecution) {
509
+ executionReportString += '\n\n\n\n' + "## ".concat(promptExecution.prompt.title);
510
+ var templateList = [];
511
+ // TODO: What if startedAt OR/AND completedAt is not defined?
512
+ var startedAt = moment((_c = (_b = promptExecution.result) === null || _b === void 0 ? void 0 : _b.timing) === null || _c === void 0 ? void 0 : _c.start);
513
+ var completedAt = moment((_e = (_d = promptExecution.result) === null || _d === void 0 ? void 0 : _d.timing) === null || _e === void 0 ? void 0 : _e.complete);
514
+ var duration = moment.duration(completedAt.diff(startedAt));
515
+ // Not need here:
516
+ // > templateList.push(`STARTED AT ${moment(startedAt).calendar()}`);
517
+ templateList.push("DURATION ".concat(duration.humanize(MOMENT_ARG_THRESHOLDS)));
518
+ if (typeof ((_g = (_f = promptExecution.result) === null || _f === void 0 ? void 0 : _f.usage) === null || _g === void 0 ? void 0 : _g.price) === 'number') {
519
+ templateList.push("COST $".concat(formatNumber(promptExecution.result.usage.price * (1 + taxRate))) +
520
+ (taxRate !== 0 ? " *(with tax ".concat(taxRate * 100, "%)*") : ''));
521
+ }
522
+ else {
523
+ templateList.push("COST UNKNOWN");
524
+ }
525
+ executionReportString += '\n\n' + templateList.map(function (header) { return "- ".concat(header); }).join('\n');
526
+ /*
527
+ - MODEL VARIANT ${promptExecution.prompt.modelRequirements.modelVariant}
528
+ - MODEL NAME \`${promptExecution.result?.model}\` (requested \`${
529
+ promptExecution.prompt.modelRequirements.modelName
530
+
531
+ */
532
+ if (just(true)) {
533
+ executionReportString +=
534
+ '\n\n\n\n' +
535
+ spaceTrim(function (block) { return "\n\n ### Prompt\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.prompt.content)), "\n ```\n\n "); });
536
+ }
537
+ if (promptExecution.result && promptExecution.result.content) {
538
+ executionReportString +=
539
+ '\n\n\n\n' +
540
+ spaceTrim(function (block) { return "\n\n ### Result\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.result.content)), "\n ```\n "); });
541
+ }
542
+ if (promptExecution.error && promptExecution.error.message) {
543
+ executionReportString +=
544
+ '\n\n\n\n' +
545
+ spaceTrim(function (block) { return "\n\n ### Error\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.error.message)), "\n ```\n\n "); });
546
+ }
547
+ };
548
+ try {
549
+ for (var _j = __values(executionReportJson.promptExecutions), _k = _j.next(); !_k.done; _k = _j.next()) {
550
+ var promptExecution = _k.value;
551
+ _loop_1(promptExecution);
552
+ }
553
+ }
554
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
555
+ finally {
556
+ try {
557
+ if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
558
+ }
559
+ finally { if (e_1) throw e_1.error; }
560
+ }
561
+ executionReportString = prettifyMarkdown(executionReportString);
562
+ return executionReportString;
563
+ }
564
+ /**
565
+ * TODO: Add mermaid chart for every report
566
+ * TODO: [🧠] Allow to filter out some parts of the report by options
567
+ */
568
+
569
+ /**
570
+ * Counts number of characters in the text
571
+ */
572
+ function countCharacters(text) {
573
+ // Remove null characters
574
+ text = text.replace(/\0/g, '');
575
+ // Replace emojis (and also ZWJ sequence) with hyphens
576
+ text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
577
+ text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
578
+ text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
579
+ return text.length;
580
580
  }
581
581
 
582
- /**
583
- * Counts number of lines in the text
584
- */
585
- function countLines(text) {
586
- if (text === '') {
587
- return 0;
588
- }
589
- return text.split('\n').length;
582
+ /**
583
+ * Counts number of lines in the text
584
+ */
585
+ function countLines(text) {
586
+ if (text === '') {
587
+ return 0;
588
+ }
589
+ return text.split('\n').length;
590
590
  }
591
591
 
592
- /**
593
- * Counts number of pages in the text
594
- */
595
- function countPages(text) {
596
- var sentencesPerPage = 5; // Assuming each page has 5 sentences
597
- var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
598
- var pageCount = Math.ceil(sentences.length / sentencesPerPage);
599
- return pageCount;
592
+ /**
593
+ * Counts number of pages in the text
594
+ */
595
+ function countPages(text) {
596
+ var sentencesPerPage = 5; // Assuming each page has 5 sentences
597
+ var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
598
+ var pageCount = Math.ceil(sentences.length / sentencesPerPage);
599
+ return pageCount;
600
600
  }
601
601
 
602
- /**
603
- * Counts number of paragraphs in the text
604
- */
605
- function countParagraphs(text) {
606
- return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
602
+ /**
603
+ * Counts number of paragraphs in the text
604
+ */
605
+ function countParagraphs(text) {
606
+ return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
607
607
  }
608
608
 
609
- /**
610
- * Counts number of sentences in the text
611
- */
612
- function countSentences(text) {
613
- return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; }).length;
609
+ /**
610
+ * Counts number of sentences in the text
611
+ */
612
+ function countSentences(text) {
613
+ return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; }).length;
614
614
  }
615
615
 
616
- /**
617
- * Counts number of words in the text
618
- */
619
- function countWords(text) {
620
- text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
621
- text = removeDiacritics(text);
622
- return text.split(/[^a-zа-я0-9]+/i).filter(function (word) { return word.length > 0; }).length;
616
+ /**
617
+ * Counts number of words in the text
618
+ */
619
+ function countWords(text) {
620
+ text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
621
+ text = removeDiacritics(text);
622
+ return text.split(/[^a-zа-я0-9]+/i).filter(function (word) { return word.length > 0; }).length;
623
623
  }
624
624
 
625
- /**
626
- * Index of all counter functions
627
- */
628
- var CountUtils = {
629
- CHARACTERS: countCharacters,
630
- WORDS: countWords,
631
- SENTENCES: countSentences,
632
- PARAGRAPHS: countParagraphs,
633
- LINES: countLines,
634
- PAGES: countPages,
625
+ /**
626
+ * Index of all counter functions
627
+ */
628
+ var CountUtils = {
629
+ CHARACTERS: countCharacters,
630
+ WORDS: countWords,
631
+ SENTENCES: countSentences,
632
+ PARAGRAPHS: countParagraphs,
633
+ LINES: countLines,
634
+ PAGES: countPages,
635
635
  };
636
636
 
637
- /**
638
- * Function isValidJsonString will tell you if the string is valid JSON or not
639
- */
640
- function isValidJsonString(value) {
641
- try {
642
- JSON.parse(value);
643
- return true;
644
- }
645
- catch (error) {
646
- if (!(error instanceof Error)) {
647
- throw error;
648
- }
649
- if (error.message.includes('Unexpected token')) {
650
- return false;
651
- }
652
- return false;
653
- }
654
- }
655
-
656
- /**
657
- * Extracts all code blocks from markdown.
658
- *
659
- * Note: There are 3 simmilar function:
660
- * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
661
- * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
662
- * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
663
- *
664
- * @param markdown any valid markdown
665
- * @returns code blocks with language and content
666
- *
667
- */
668
- function extractAllBlocksFromMarkdown(markdown) {
669
- var e_1, _a;
670
- var codeBlocks = [];
671
- var lines = markdown.split('\n');
672
- var currentCodeBlock = null;
673
- try {
674
- for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
675
- var line = lines_1_1.value;
676
- if (line.startsWith('```')) {
677
- var language = line.slice(3).trim() || null;
678
- if (currentCodeBlock === null) {
679
- currentCodeBlock = { language: language, content: '' };
680
- }
681
- else {
682
- if (language !== null) {
683
- // [🌻]
684
- throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
685
- }
686
- codeBlocks.push(currentCodeBlock);
687
- currentCodeBlock = null;
688
- }
689
- }
690
- else if (currentCodeBlock !== null) {
691
- if (currentCodeBlock.content !== '') {
692
- currentCodeBlock.content += '\n';
693
- }
694
- currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
695
- }
696
- }
697
- }
698
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
699
- finally {
700
- try {
701
- if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
702
- }
703
- finally { if (e_1) throw e_1.error; }
704
- }
705
- if (currentCodeBlock !== null) {
706
- // [🌻]
707
- throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
708
- }
709
- return codeBlocks;
637
+ /**
638
+ * Function isValidJsonString will tell you if the string is valid JSON or not
639
+ */
640
+ function isValidJsonString(value) {
641
+ try {
642
+ JSON.parse(value);
643
+ return true;
644
+ }
645
+ catch (error) {
646
+ if (!(error instanceof Error)) {
647
+ throw error;
648
+ }
649
+ if (error.message.includes('Unexpected token')) {
650
+ return false;
651
+ }
652
+ return false;
653
+ }
710
654
  }
711
655
 
712
- /**
713
- * Utility function to extract all list items from markdown
714
- *
715
- * Note: It works with both ul and ol
716
- * Note: It omits list items in code blocks
717
- * Note: It flattens nested lists
718
- * Note: It can not work with html syntax and comments
719
- *
720
- * @param markdown any valid markdown
721
- * @returns
722
- */
723
- function extractAllListItemsFromMarkdown(markdown) {
724
- var e_1, _a;
725
- var lines = markdown.split('\n');
726
- var listItems = [];
727
- var isInCodeBlock = false;
728
- try {
729
- for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
730
- var line = lines_1_1.value;
731
- var trimmedLine = line.trim();
732
- if (trimmedLine.startsWith('```')) {
733
- isInCodeBlock = !isInCodeBlock;
734
- }
735
- if (!isInCodeBlock && (trimmedLine.startsWith('-') || trimmedLine.match(/^\d+\./))) {
736
- var listItem = trimmedLine.replace(/^-|\d+\./, '').trim();
737
- listItems.push(listItem);
738
- }
739
- }
740
- }
741
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
742
- finally {
743
- try {
744
- if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
745
- }
746
- finally { if (e_1) throw e_1.error; }
747
- }
748
- return listItems;
656
+ /**
657
+ * Extracts all code blocks from markdown.
658
+ *
659
+ * Note: There are 3 simmilar function:
660
+ * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
661
+ * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
662
+ * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
663
+ *
664
+ * @param markdown any valid markdown
665
+ * @returns code blocks with language and content
666
+ *
667
+ */
668
+ function extractAllBlocksFromMarkdown(markdown) {
669
+ var e_1, _a;
670
+ var codeBlocks = [];
671
+ var lines = markdown.split('\n');
672
+ var currentCodeBlock = null;
673
+ try {
674
+ for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
675
+ var line = lines_1_1.value;
676
+ if (line.startsWith('```')) {
677
+ var language = line.slice(3).trim() || null;
678
+ if (currentCodeBlock === null) {
679
+ currentCodeBlock = { language: language, content: '' };
680
+ }
681
+ else {
682
+ if (language !== null) {
683
+ // [🌻]
684
+ throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
685
+ }
686
+ codeBlocks.push(currentCodeBlock);
687
+ currentCodeBlock = null;
688
+ }
689
+ }
690
+ else if (currentCodeBlock !== null) {
691
+ if (currentCodeBlock.content !== '') {
692
+ currentCodeBlock.content += '\n';
693
+ }
694
+ currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
695
+ }
696
+ }
697
+ }
698
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
699
+ finally {
700
+ try {
701
+ if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
702
+ }
703
+ finally { if (e_1) throw e_1.error; }
704
+ }
705
+ if (currentCodeBlock !== null) {
706
+ // [🌻]
707
+ throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
708
+ }
709
+ return codeBlocks;
749
710
  }
750
711
 
751
- /**
752
- * Extracts exactly ONE code block from markdown.
753
- *
754
- * Note: If there are multiple or no code blocks the function throws an error
755
- *
756
- * Note: There are 3 simmilar function:
757
- * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
758
- * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
759
- * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
760
- *
761
- * @param markdown any valid markdown
762
- * @returns code block with language and content
763
- */
764
- function extractOneBlockFromMarkdown(markdown) {
765
- var codeBlocks = extractAllBlocksFromMarkdown(markdown);
766
- if (codeBlocks.length !== 1) {
767
- // TODO: Report more specific place where the error happened
768
- throw new Error(/* <- [🌻] */ 'There should be exactly one code block in the markdown');
769
- }
770
- return codeBlocks[0];
712
+ /**
713
+ * Utility function to extract all list items from markdown
714
+ *
715
+ * Note: It works with both ul and ol
716
+ * Note: It omits list items in code blocks
717
+ * Note: It flattens nested lists
718
+ * Note: It can not work with html syntax and comments
719
+ *
720
+ * @param markdown any valid markdown
721
+ * @returns
722
+ */
723
+ function extractAllListItemsFromMarkdown(markdown) {
724
+ var e_1, _a;
725
+ var lines = markdown.split('\n');
726
+ var listItems = [];
727
+ var isInCodeBlock = false;
728
+ try {
729
+ for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
730
+ var line = lines_1_1.value;
731
+ var trimmedLine = line.trim();
732
+ if (trimmedLine.startsWith('```')) {
733
+ isInCodeBlock = !isInCodeBlock;
734
+ }
735
+ if (!isInCodeBlock && (trimmedLine.startsWith('-') || trimmedLine.match(/^\d+\./))) {
736
+ var listItem = trimmedLine.replace(/^-|\d+\./, '').trim();
737
+ listItems.push(listItem);
738
+ }
739
+ }
740
+ }
741
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
742
+ finally {
743
+ try {
744
+ if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
745
+ }
746
+ finally { if (e_1) throw e_1.error; }
747
+ }
748
+ return listItems;
771
749
  }
772
- /***
773
- * TODO: [🌻] !!! Decide of this is internal util, external util OR validator/postprocessor
774
- */
775
750
 
776
- /**
777
- * Removes HTML or Markdown comments from a string.
778
- *
779
- * @param {string} content - The string to remove comments from.
780
- * @returns {string} The input string with all comments removed.
781
- */
782
- function removeContentComments(content) {
783
- return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
751
+ /**
752
+ * Extracts exactly ONE code block from markdown.
753
+ *
754
+ * Note: If there are multiple or no code blocks the function throws an error
755
+ *
756
+ * Note: There are 3 simmilar function:
757
+ * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
758
+ * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
759
+ * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
760
+ *
761
+ * @param markdown any valid markdown
762
+ * @returns code block with language and content
763
+ */
764
+ function extractOneBlockFromMarkdown(markdown) {
765
+ var codeBlocks = extractAllBlocksFromMarkdown(markdown);
766
+ if (codeBlocks.length !== 1) {
767
+ // TODO: Report more specific place where the error happened
768
+ throw new Error(/* <- [🌻] */ 'There should be exactly one code block in the markdown');
769
+ }
770
+ return codeBlocks[0];
771
+ }
772
+ /***
773
+ * TODO: [🌻] !!! Decide of this is internal util, external util OR validator/postprocessor
774
+ */
775
+
776
+ /**
777
+ * Removes HTML or Markdown comments from a string.
778
+ *
779
+ * @param {string} content - The string to remove comments from.
780
+ * @returns {string} The input string with all comments removed.
781
+ */
782
+ function removeContentComments(content) {
783
+ return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
784
784
  }
785
785
 
786
- /**
787
- * Removes Markdown formatting tags from a string.
788
- *
789
- * @param {string} str - The string to remove Markdown tags from.
790
- * @returns {string} The input string with all Markdown tags removed.
791
- */
792
- function removeMarkdownFormatting(str) {
793
- // Remove bold formatting
794
- str = str.replace(/\*\*(.*?)\*\*/g, '$1');
795
- // Remove italic formatting
796
- str = str.replace(/\*(.*?)\*/g, '$1');
797
- // Remove code formatting
798
- str = str.replace(/`(.*?)`/g, '$1');
799
- return str;
786
+ /**
787
+ * Removes Markdown formatting tags from a string.
788
+ *
789
+ * @param {string} str - The string to remove Markdown tags from.
790
+ * @returns {string} The input string with all Markdown tags removed.
791
+ */
792
+ function removeMarkdownFormatting(str) {
793
+ // Remove bold formatting
794
+ str = str.replace(/\*\*(.*?)\*\*/g, '$1');
795
+ // Remove italic formatting
796
+ str = str.replace(/\*(.*?)\*/g, '$1');
797
+ // Remove code formatting
798
+ str = str.replace(/`(.*?)`/g, '$1');
799
+ return str;
800
800
  }
801
801
 
802
- /**
803
- * Extracts code block from markdown.
804
- *
805
- * Note: If there are multiple or no code blocks the function throws an error
806
- *
807
- * Note: There are 3 simmilar function:
808
- * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
809
- * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
810
- * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
811
- */
812
- function extractBlock(markdown) {
813
- var content = extractOneBlockFromMarkdown(markdown).content;
814
- return content;
815
- }
802
+ /**
803
+ * Extracts code block from markdown.
804
+ *
805
+ * Note: If there are multiple or no code blocks the function throws an error
806
+ *
807
+ * Note: There are 3 simmilar function:
808
+ * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
809
+ * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
810
+ * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
811
+ */
812
+ function extractBlock(markdown) {
813
+ var content = extractOneBlockFromMarkdown(markdown).content;
814
+ return content;
815
+ }
816
816
  //
817
817
 
818
- /**
819
- * Removes quotes from a string
820
- *
821
- * Tip: This is very usefull for post-processing of the result of the LLM model
822
- * Note: This function removes only the same quotes from the beginning and the end of the string
823
- * Note: There are two simmilar functions:
824
- * - `removeQuotes` which removes only bounding quotes
825
- * - `unwrapResult` which removes whole introduce sentence
826
- *
827
- * @param text optionally quoted text
828
- * @returns text without quotes
829
- */
830
- function removeQuotes(text) {
831
- if (text.startsWith('"') && text.endsWith('"')) {
832
- return text.slice(1, -1);
833
- }
834
- if (text.startsWith('\'') && text.endsWith('\'')) {
835
- return text.slice(1, -1);
836
- }
837
- return text;
818
+ /**
819
+ * Removes quotes from a string
820
+ *
821
+ * Tip: This is very usefull for post-processing of the result of the LLM model
822
+ * Note: This function removes only the same quotes from the beginning and the end of the string
823
+ * Note: There are two simmilar functions:
824
+ * - `removeQuotes` which removes only bounding quotes
825
+ * - `unwrapResult` which removes whole introduce sentence
826
+ *
827
+ * @param text optionally quoted text
828
+ * @returns text without quotes
829
+ */
830
+ function removeQuotes(text) {
831
+ if (text.startsWith('"') && text.endsWith('"')) {
832
+ return text.slice(1, -1);
833
+ }
834
+ if (text.startsWith('\'') && text.endsWith('\'')) {
835
+ return text.slice(1, -1);
836
+ }
837
+ return text;
838
838
  }
839
839
 
840
- /**
841
- * Function trimCodeBlock will trim starting and ending code block from the string if it is present.
842
- *
843
- * Note: This is usefull for post-processing of the result of the chat LLM model
844
- * when the model wraps the result in the (markdown) code block.
845
- *
846
- */
847
- function trimCodeBlock(value) {
848
- value = spaceTrim(value);
849
- if (!/^```[a-z]*(.*)```$/is.test(value)) {
850
- return value;
851
- }
852
- value = value.replace(/^```[a-z]*/i, '');
853
- value = value.replace(/```$/i, '');
854
- value = spaceTrim(value);
855
- return value;
840
+ /**
841
+ * Function trimCodeBlock will trim starting and ending code block from the string if it is present.
842
+ *
843
+ * Note: This is usefull for post-processing of the result of the chat LLM model
844
+ * when the model wraps the result in the (markdown) code block.
845
+ *
846
+ */
847
+ function trimCodeBlock(value) {
848
+ value = spaceTrim(value);
849
+ if (!/^```[a-z]*(.*)```$/is.test(value)) {
850
+ return value;
851
+ }
852
+ value = value.replace(/^```[a-z]*/i, '');
853
+ value = value.replace(/```$/i, '');
854
+ value = spaceTrim(value);
855
+ return value;
856
856
  }
857
857
 
858
- /**
859
- * Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
860
- *
861
- * Note: This is usefull for post-processing of the result of the completion LLM model
862
- * if you want to start code block in the prompt but you don't want to end it in the result.
863
- */
864
- function trimEndOfCodeBlock(value) {
865
- value = spaceTrim(value);
866
- value = value.replace(/```$/g, '');
867
- value = spaceTrim(value);
868
- return value;
858
+ /**
859
+ * Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
860
+ *
861
+ * Note: This is usefull for post-processing of the result of the completion LLM model
862
+ * if you want to start code block in the prompt but you don't want to end it in the result.
863
+ */
864
+ function trimEndOfCodeBlock(value) {
865
+ value = spaceTrim(value);
866
+ value = value.replace(/```$/g, '');
867
+ value = spaceTrim(value);
868
+ return value;
869
869
  }
870
870
 
871
- /**
872
- * Removes quotes and optional introduce text from a string
873
- *
874
- * Tip: This is very usefull for post-processing of the result of the LLM model
875
- * Note: This function trims the text and removes whole introduce sentence if it is present
876
- * Note: There are two simmilar functions:
877
- * - `removeQuotes` which removes only bounding quotes
878
- * - `unwrapResult` which removes whole introduce sentence
879
- *
880
- * @param text optionally quoted text
881
- * @returns text without quotes
882
- */
883
- function unwrapResult(text, options) {
884
- var _a = options || {}, _b = _a.isTrimmed, isTrimmed = _b === void 0 ? true : _b, _c = _a.isIntroduceSentenceRemoved, isIntroduceSentenceRemoved = _c === void 0 ? true : _c;
885
- var trimmedText = text;
886
- // Remove leading and trailing spaces and newlines
887
- if (isTrimmed) {
888
- trimmedText = spaceTrim(trimmedText);
889
- }
890
- var processedText = trimmedText;
891
- if (isIntroduceSentenceRemoved) {
892
- var introduceSentenceRegex = /^[a-zěščřžýáíéúů:\s]*:\s*/i;
893
- if (introduceSentenceRegex.test(text)) {
894
- // Remove the introduce sentence and quotes by replacing it with an empty string
895
- processedText = processedText.replace(introduceSentenceRegex, '');
896
- }
897
- processedText = spaceTrim(processedText);
898
- }
899
- if (processedText.length < 3) {
900
- return trimmedText;
901
- }
902
- if (processedText.includes('\n')) {
903
- return trimmedText;
904
- }
905
- // Remove the quotes by extracting the substring without the first and last characters
906
- var unquotedText = processedText.slice(1, -1);
907
- // Check if the text starts and ends with quotes
908
- if ([
909
- ['"', '"'],
910
- ["'", "'"],
911
- ['`', '`'],
912
- ['*', '*'],
913
- ['_', '_'],
914
- ['„', '“'],
915
- ['«', '»'] /* <- QUOTES to config */,
916
- ].some(function (_a) {
917
- var _b = __read(_a, 2), startQuote = _b[0], endQuote = _b[1];
918
- if (!processedText.startsWith(startQuote)) {
919
- return false;
920
- }
921
- if (!processedText.endsWith(endQuote)) {
922
- return false;
923
- }
924
- if (unquotedText.includes(startQuote) && !unquotedText.includes(endQuote)) {
925
- return false;
926
- }
927
- if (!unquotedText.includes(startQuote) && unquotedText.includes(endQuote)) {
928
- return false;
929
- }
930
- return true;
931
- })) {
932
- return unwrapResult(unquotedText, { isTrimmed: false, isIntroduceSentenceRemoved: false });
933
- }
934
- else {
935
- return processedText;
936
- }
937
- }
938
- /**
939
- * TODO: [🧠] Should this also unwrap the (parenthesis)
871
+ /**
872
+ * Removes quotes and optional introduce text from a string
873
+ *
874
+ * Tip: This is very usefull for post-processing of the result of the LLM model
875
+ * Note: This function trims the text and removes whole introduce sentence if it is present
876
+ * Note: There are two simmilar functions:
877
+ * - `removeQuotes` which removes only bounding quotes
878
+ * - `unwrapResult` which removes whole introduce sentence
879
+ *
880
+ * @param text optionally quoted text
881
+ * @returns text without quotes
882
+ */
883
+ function unwrapResult(text, options) {
884
+ var _a = options || {}, _b = _a.isTrimmed, isTrimmed = _b === void 0 ? true : _b, _c = _a.isIntroduceSentenceRemoved, isIntroduceSentenceRemoved = _c === void 0 ? true : _c;
885
+ var trimmedText = text;
886
+ // Remove leading and trailing spaces and newlines
887
+ if (isTrimmed) {
888
+ trimmedText = spaceTrim(trimmedText);
889
+ }
890
+ var processedText = trimmedText;
891
+ if (isIntroduceSentenceRemoved) {
892
+ var introduceSentenceRegex = /^[a-zěščřžýáíéúů:\s]*:\s*/i;
893
+ if (introduceSentenceRegex.test(text)) {
894
+ // Remove the introduce sentence and quotes by replacing it with an empty string
895
+ processedText = processedText.replace(introduceSentenceRegex, '');
896
+ }
897
+ processedText = spaceTrim(processedText);
898
+ }
899
+ if (processedText.length < 3) {
900
+ return trimmedText;
901
+ }
902
+ if (processedText.includes('\n')) {
903
+ return trimmedText;
904
+ }
905
+ // Remove the quotes by extracting the substring without the first and last characters
906
+ var unquotedText = processedText.slice(1, -1);
907
+ // Check if the text starts and ends with quotes
908
+ if ([
909
+ ['"', '"'],
910
+ ["'", "'"],
911
+ ['`', '`'],
912
+ ['*', '*'],
913
+ ['_', '_'],
914
+ ['„', '“'],
915
+ ['«', '»'] /* <- QUOTES to config */,
916
+ ].some(function (_a) {
917
+ var _b = __read(_a, 2), startQuote = _b[0], endQuote = _b[1];
918
+ if (!processedText.startsWith(startQuote)) {
919
+ return false;
920
+ }
921
+ if (!processedText.endsWith(endQuote)) {
922
+ return false;
923
+ }
924
+ if (unquotedText.includes(startQuote) && !unquotedText.includes(endQuote)) {
925
+ return false;
926
+ }
927
+ if (!unquotedText.includes(startQuote) && unquotedText.includes(endQuote)) {
928
+ return false;
929
+ }
930
+ return true;
931
+ })) {
932
+ return unwrapResult(unquotedText, { isTrimmed: false, isIntroduceSentenceRemoved: false });
933
+ }
934
+ else {
935
+ return processedText;
936
+ }
937
+ }
938
+ /**
939
+ * TODO: [🧠] Should this also unwrap the (parenthesis)
940
940
  */
941
941
 
942
942
  export { CountUtils, ExecutionReportStringOptionsDefaults, assertsExecutionSuccessful, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, executionReportJsonToString, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractBlock, extractOneBlockFromMarkdown, isValidJsonString, parseNumber, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, trimCodeBlock, trimEndOfCodeBlock, unwrapResult };