@promptbook/core 0.57.2 → 0.59.0-0

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 (209) hide show
  1. package/esm/index.es.js +484 -434
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/_packages/anthropic-claude.index.d.ts +2 -2
  4. package/esm/typings/_packages/azure-openai.index.d.ts +3 -4
  5. package/esm/typings/_packages/core.index.d.ts +11 -10
  6. package/esm/typings/_packages/execute-javascript.index.d.ts +2 -2
  7. package/esm/typings/_packages/fake-llm.index.d.ts +2 -2
  8. package/esm/typings/_packages/langtail.index.d.ts +3 -4
  9. package/esm/typings/_packages/node.index.d.ts +1 -1
  10. package/esm/typings/_packages/openai.index.d.ts +4 -5
  11. package/esm/typings/_packages/remote-client.index.d.ts +4 -5
  12. package/esm/typings/_packages/remote-server.index.d.ts +3 -4
  13. package/esm/typings/_packages/types.index.d.ts +4 -2
  14. package/esm/typings/_packages/utils.index.d.ts +6 -4
  15. package/esm/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
  16. package/esm/typings/conversion/promptbookStringToJson.d.ts +7 -2
  17. package/esm/typings/execution/ScriptExecutionTools.d.ts +1 -1
  18. package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
  19. package/esm/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +1 -1
  20. package/esm/typings/expectations/drafts/isDomainNameFree.d.ts +6 -0
  21. package/esm/typings/expectations/drafts/isGithubNameFree.d.ts +6 -0
  22. package/esm/typings/formats/_common/FormatDefinition.d.ts +69 -0
  23. package/esm/typings/formats/csv/ListFormatDefinition.d.ts +11 -0
  24. package/esm/typings/formats/index.d.ts +4 -0
  25. package/esm/typings/formats/json/JsonFormatDefinition.d.ts +15 -0
  26. package/esm/typings/formats/list/ListFormatDefinition.d.ts +13 -0
  27. package/esm/typings/formats/xml/XmlFormatDefinition.d.ts +15 -0
  28. package/{umd/typings/execution/plugins/user-interface-execution-tools → esm/typings/knowledge/dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
  29. package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
  30. package/{umd/typings/execution/plugins/user-interface-execution-tools → esm/typings/knowledge/dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +4 -4
  31. package/esm/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +4 -0
  32. package/esm/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +7 -0
  33. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -6
  34. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  35. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +2 -2
  36. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -5
  37. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +3 -3
  38. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionTools.d.ts +1 -1
  39. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +7 -7
  40. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  41. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.d.ts +2 -2
  42. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +5 -5
  43. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +3 -3
  44. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/OpenAiExecutionTools.d.ts +6 -6
  45. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  46. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeOpenaiUsage.d.ts +3 -3
  47. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/openai-models.d.ts +2 -2
  48. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/RemoteLlmExecutionTools.d.ts +5 -5
  49. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +3 -3
  50. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
  51. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +2 -2
  52. package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
  53. package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/interfaces/RemoteServerOptions.d.ts +5 -5
  54. package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.d.ts +3 -0
  55. package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.d.ts +3 -0
  56. package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.d.ts +4 -1
  57. package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromUrl.d.ts +3 -0
  58. package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.d.ts +2 -2
  59. package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
  60. package/esm/typings/scripting/python/PythonExecutionTools.d.ts +16 -0
  61. package/esm/typings/scripting/typescript/TypescriptExecutionTools.d.ts +16 -0
  62. package/esm/typings/types/Prompt.d.ts +1 -1
  63. package/esm/typings/types/PromptbookJson/KnowledgeJson.d.ts +6 -0
  64. package/esm/typings/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +27 -0
  65. package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +8 -6
  66. package/package.json +2 -2
  67. package/umd/index.umd.js +484 -434
  68. package/umd/index.umd.js.map +1 -1
  69. package/umd/typings/_packages/anthropic-claude.index.d.ts +2 -2
  70. package/umd/typings/_packages/azure-openai.index.d.ts +3 -4
  71. package/umd/typings/_packages/core.index.d.ts +11 -10
  72. package/umd/typings/_packages/execute-javascript.index.d.ts +2 -2
  73. package/umd/typings/_packages/fake-llm.index.d.ts +2 -2
  74. package/umd/typings/_packages/langtail.index.d.ts +3 -4
  75. package/umd/typings/_packages/node.index.d.ts +1 -1
  76. package/umd/typings/_packages/openai.index.d.ts +4 -5
  77. package/umd/typings/_packages/remote-client.index.d.ts +4 -5
  78. package/umd/typings/_packages/remote-server.index.d.ts +3 -4
  79. package/umd/typings/_packages/types.index.d.ts +4 -2
  80. package/umd/typings/_packages/utils.index.d.ts +6 -4
  81. package/umd/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
  82. package/umd/typings/conversion/promptbookStringToJson.d.ts +7 -2
  83. package/umd/typings/execution/ScriptExecutionTools.d.ts +1 -1
  84. package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
  85. package/umd/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +1 -1
  86. package/umd/typings/expectations/drafts/isDomainNameFree.d.ts +6 -0
  87. package/umd/typings/expectations/drafts/isGithubNameFree.d.ts +6 -0
  88. package/umd/typings/formats/_common/FormatDefinition.d.ts +69 -0
  89. package/umd/typings/formats/csv/ListFormatDefinition.d.ts +11 -0
  90. package/umd/typings/formats/index.d.ts +4 -0
  91. package/umd/typings/formats/json/JsonFormatDefinition.d.ts +15 -0
  92. package/umd/typings/formats/list/ListFormatDefinition.d.ts +13 -0
  93. package/umd/typings/formats/xml/XmlFormatDefinition.d.ts +15 -0
  94. package/{esm/typings/execution/plugins/user-interface-execution-tools → umd/typings/knowledge/dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
  95. package/umd/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
  96. package/{esm/typings/execution/plugins/user-interface-execution-tools → umd/typings/knowledge/dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +4 -4
  97. package/umd/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +4 -0
  98. package/umd/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +7 -0
  99. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -6
  100. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  101. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +2 -2
  102. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -5
  103. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +3 -3
  104. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionTools.d.ts +1 -1
  105. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +7 -7
  106. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
  107. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.d.ts +2 -2
  108. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +5 -5
  109. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +3 -3
  110. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/OpenAiExecutionTools.d.ts +6 -6
  111. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  112. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeOpenaiUsage.d.ts +3 -3
  113. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/openai-models.d.ts +2 -2
  114. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/RemoteLlmExecutionTools.d.ts +5 -5
  115. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +3 -3
  116. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
  117. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +2 -2
  118. package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
  119. package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/interfaces/RemoteServerOptions.d.ts +5 -5
  120. package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.d.ts +3 -0
  121. package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.d.ts +3 -0
  122. package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.d.ts +4 -1
  123. package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromUrl.d.ts +3 -0
  124. package/umd/typings/scripting/_test/script-execution-errors.test.d.ts +1 -0
  125. package/umd/typings/scripting/_test/script-execution-tools.test.d.ts +1 -0
  126. package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.d.ts +2 -2
  127. package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
  128. package/umd/typings/scripting/python/PythonExecutionTools.d.ts +16 -0
  129. package/umd/typings/scripting/typescript/TypescriptExecutionTools.d.ts +16 -0
  130. package/umd/typings/types/Prompt.d.ts +1 -1
  131. package/umd/typings/types/PromptbookJson/KnowledgeJson.d.ts +6 -0
  132. package/umd/typings/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +27 -0
  133. package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +8 -6
  134. package/esm/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +0 -16
  135. package/esm/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +0 -16
  136. package/umd/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +0 -16
  137. package/umd/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +0 -16
  138. /package/esm/typings/{utils → formats/json/utils}/isValidJsonString.d.ts +0 -0
  139. /package/esm/typings/{utils → formats/json/utils}/isValidJsonString.test.d.ts +0 -0
  140. /package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/user-interface-execution-tools.test.d.ts +0 -0
  141. /package/esm/typings/{execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.test.d.ts → knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts} +0 -0
  142. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  143. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  144. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  145. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/playground/playground.d.ts +0 -0
  146. /package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/fakeTextToExpectations.test.d.ts +0 -0
  147. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/faked-completion.test.d.ts +0 -0
  148. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/joker.test.d.ts +0 -0
  149. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  150. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  151. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/multiple/playground/playground.d.ts +0 -0
  152. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.d.ts +0 -0
  153. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.test.d.ts +0 -0
  154. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/playground/playground.d.ts +0 -0
  155. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  156. /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/startRemoteServer.d.ts +0 -0
  157. /package/esm/typings/{library → promptbook-library}/PromptbookLibrary.d.ts +0 -0
  158. /package/esm/typings/{library → promptbook-library}/SimplePromptbookLibrary.d.ts +0 -0
  159. /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.test.d.ts +0 -0
  160. /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.test.d.ts +0 -0
  161. /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.test.d.ts +0 -0
  162. /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookSublibrary.d.ts +0 -0
  163. /package/esm/typings/{library → promptbook-library}/constructors/justTestFsImport.d.ts +0 -0
  164. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function-async.test.ts.test.d.ts +0 -0
  165. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function-missing.test.d.ts +0 -0
  166. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function-with-dependencies.test.d.ts +0 -0
  167. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function.test.d.ts +0 -0
  168. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/postprocessing.test.d.ts +0 -0
  169. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/script-execution-errors.test.d.ts +0 -0
  170. /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/script-execution-tools.test.d.ts +0 -0
  171. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  172. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  173. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/preserve.d.ts +0 -0
  174. /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/unknownToString.d.ts +0 -0
  175. /package/umd/typings/{utils → formats/json/utils}/isValidJsonString.d.ts +0 -0
  176. /package/umd/typings/{utils → formats/json/utils}/isValidJsonString.test.d.ts +0 -0
  177. /package/umd/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/user-interface-execution-tools.test.d.ts +0 -0
  178. /package/umd/typings/{execution/plugins/llm-execution-tools/mocked/faked-completion.test.d.ts → knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts} +0 -0
  179. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  180. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  181. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  182. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/playground/playground.d.ts +0 -0
  183. /package/umd/typings/{execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts → llm-providers/mocked/fakeTextToExpectations.test.d.ts} +0 -0
  184. /package/umd/typings/{execution/plugins/script-execution-tools/custom-function-async.test.ts.test.d.ts → llm-providers/mocked/faked-completion.test.d.ts} +0 -0
  185. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/joker.test.d.ts +0 -0
  186. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  187. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  188. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/multiple/playground/playground.d.ts +0 -0
  189. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.d.ts +0 -0
  190. /package/umd/typings/{execution/plugins/script-execution-tools/custom-function-missing.test.d.ts → llm-providers/openai/computeUsage.test.d.ts} +0 -0
  191. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/playground/playground.d.ts +0 -0
  192. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  193. /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/startRemoteServer.d.ts +0 -0
  194. /package/umd/typings/{library → promptbook-library}/PromptbookLibrary.d.ts +0 -0
  195. /package/umd/typings/{library → promptbook-library}/SimplePromptbookLibrary.d.ts +0 -0
  196. /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.test.d.ts +0 -0
  197. /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.test.d.ts +0 -0
  198. /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.test.d.ts +0 -0
  199. /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookSublibrary.d.ts +0 -0
  200. /package/umd/typings/{library → promptbook-library}/constructors/justTestFsImport.d.ts +0 -0
  201. /package/umd/typings/{execution/plugins/script-execution-tools/custom-function-with-dependencies.test.d.ts → scripting/_test/custom-function-async.test.ts.test.d.ts} +0 -0
  202. /package/umd/typings/{execution/plugins/script-execution-tools/custom-function.test.d.ts → scripting/_test/custom-function-missing.test.d.ts} +0 -0
  203. /package/umd/typings/{execution/plugins/script-execution-tools/postprocessing.test.d.ts → scripting/_test/custom-function-with-dependencies.test.d.ts} +0 -0
  204. /package/umd/typings/{execution/plugins/script-execution-tools/script-execution-errors.test.d.ts → scripting/_test/custom-function.test.d.ts} +0 -0
  205. /package/umd/typings/{execution/plugins/script-execution-tools/script-execution-tools.test.d.ts → scripting/_test/postprocessing.test.d.ts} +0 -0
  206. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  207. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  208. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/preserve.d.ts +0 -0
  209. /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/unknownToString.d.ts +0 -0
package/umd/index.umd.js CHANGED
@@ -129,6 +129,69 @@
129
129
  return to.concat(ar || Array.prototype.slice.call(from));
130
130
  }
131
131
 
132
+ /**
133
+ * Removes HTML or Markdown comments from a string.
134
+ *
135
+ * @param {string} content - The string to remove comments from.
136
+ * @returns {string} The input string with all comments removed.
137
+ */
138
+ function removeContentComments(content) {
139
+ return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
140
+ }
141
+
142
+ /**
143
+ * Add or modify an auto-generated section in a markdown file
144
+ *
145
+ * @private within the library
146
+ */
147
+ function addAutoGeneratedSection(content, options) {
148
+ var sectionName = options.sectionName, sectionContent = options.sectionContent;
149
+ var warningLine = "<!-- \u26A0\uFE0F WARNING: This section was auto-generated -->";
150
+ var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
151
+ var sectionMatch = content.match(sectionRegex);
152
+ if (sectionMatch) {
153
+ return content.replace(sectionRegex, spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
154
+ }
155
+ var placeForSection = removeContentComments(content).match(/^##.*$/im);
156
+ if (!placeForSection) {
157
+ throw new Error("No place where to put the section <!--".concat(sectionName, "-->"));
158
+ }
159
+ var _a = __read(placeForSection, 1), heading = _a[0];
160
+ return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
161
+ }
162
+
163
+ /**
164
+ * Prettify the html code
165
+ *
166
+ * @param content raw html code
167
+ * @returns formatted html code
168
+ */
169
+ function prettifyMarkdown(content) {
170
+ try {
171
+ return prettier.format(content, {
172
+ parser: 'markdown',
173
+ plugins: [parserHtml__default["default"]],
174
+ // TODO: DRY - make some import or auto-copy of .prettierrc
175
+ endOfLine: 'lf',
176
+ tabWidth: 4,
177
+ singleQuote: true,
178
+ trailingComma: 'all',
179
+ arrowParens: 'always',
180
+ printWidth: 120,
181
+ htmlWhitespaceSensitivity: 'ignore',
182
+ jsxBracketSameLine: false,
183
+ bracketSpacing: true,
184
+ });
185
+ }
186
+ catch (error) {
187
+ console.error('There was an error with prettifying the markdown, using the original as the fallback', {
188
+ error: error,
189
+ html: content,
190
+ });
191
+ return content;
192
+ }
193
+ }
194
+
132
195
  /**
133
196
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
134
197
  */
@@ -148,6 +211,23 @@
148
211
  */
149
212
  var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
150
213
 
214
+ /**
215
+ * Returns the same value that is passed as argument.
216
+ * No side effects.
217
+ *
218
+ * Note: It can be usefull for leveling indentation
219
+ *
220
+ * @param value any values
221
+ * @returns the same values
222
+ */
223
+ function just(value) {
224
+ if (value === undefined) {
225
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
226
+ return undefined;
227
+ }
228
+ return value;
229
+ }
230
+
151
231
  /**
152
232
  * Computes the deepness of the markdown structure.
153
233
  *
@@ -403,16 +483,6 @@
403
483
  * TODO: [🍓][🌻] !!! Decide of this is internal util, external util OR validator/postprocessor
404
484
  */
405
485
 
406
- /**
407
- * Removes HTML or Markdown comments from a string.
408
- *
409
- * @param {string} content - The string to remove comments from.
410
- * @returns {string} The input string with all comments removed.
411
- */
412
- function removeContentComments(content) {
413
- return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
414
- }
415
-
416
486
  /**
417
487
  * Creates a new set with all elements that are present in either set
418
488
  */
@@ -454,7 +524,7 @@
454
524
  /**
455
525
  * The version of the Promptbook library
456
526
  */
457
- var PROMPTBOOK_VERSION = '0.57.1';
527
+ var PROMPTBOOK_VERSION = '0.58.0';
458
528
 
459
529
  /**
460
530
  * Parses the template and returns the list of all parameter names
@@ -1325,250 +1395,255 @@
1325
1395
  }
1326
1396
 
1327
1397
  /**
1328
- * Parse promptbook from string format to JSON format
1398
+ * Compile promptbook from string (markdown) format to JSON format
1329
1399
  *
1400
+ * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
1401
+ * @param llmTools {LlmExecutionTools} - tools for processing required for knowledge processing *(not for actual execution)*
1402
+ * @returns {Promptbook} compiled in JSON format (.ptbk.json)
1330
1403
  * @throws {PromptbookSyntaxError} if the promptbook string is not valid
1331
1404
  *
1332
1405
  * Note: This function does not validate logic of the pipeline only the syntax
1406
+ * Note: This function acts as compilation process
1333
1407
  */
1334
- function promptbookStringToJson(promptbookString) {
1335
- var e_1, _a, e_2, _b;
1336
- var promptbookJson = {
1337
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1338
- title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
1339
- promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
1340
- promptbookVersion: PROMPTBOOK_VERSION,
1341
- description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
1342
- parameters: [],
1343
- promptTemplates: [],
1344
- };
1345
- // =============================================================
1346
- // Note: 1️⃣ Normalization of the PROMPTBOOK string
1347
- promptbookString = removeContentComments(promptbookString);
1348
- promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
1349
- promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
1350
- // =============================================================
1351
- ///Note: 2️⃣ Function for adding parameters
1352
- var addParam = function (parameterCommand) {
1353
- var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
1354
- var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
1355
- if (existingParameter &&
1356
- existingParameter.description &&
1357
- existingParameter.description !== parameterDescription &&
1358
- parameterDescription) {
1359
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
1360
- }
1361
- if (existingParameter) {
1362
- if (parameterDescription) {
1363
- existingParameter.description = parameterDescription;
1408
+ function promptbookStringToJson(promptbookString, llmTools) {
1409
+ return __awaiter(this, void 0, void 0, function () {
1410
+ var promptbookJson, addParam, markdownStructure, markdownStructureDeepness, description, defaultModelRequirements, listItems, listItems_1, listItems_1_1, listItem, command, _loop_1, _a, _b, section;
1411
+ var e_1, _c, e_2, _d;
1412
+ return __generator(this, function (_e) {
1413
+ promptbookJson = {
1414
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1415
+ title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
1416
+ promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
1417
+ promptbookVersion: PROMPTBOOK_VERSION,
1418
+ description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
1419
+ parameters: [],
1420
+ promptTemplates: [],
1421
+ knowledge: [],
1422
+ };
1423
+ // =============================================================
1424
+ // Note: 1️⃣ Normalization of the PROMPTBOOK string
1425
+ promptbookString = removeContentComments(promptbookString);
1426
+ promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
1427
+ promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
1428
+ addParam = function (parameterCommand) {
1429
+ var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
1430
+ var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
1431
+ if (existingParameter &&
1432
+ existingParameter.description &&
1433
+ existingParameter.description !== parameterDescription &&
1434
+ parameterDescription) {
1435
+ throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
1436
+ }
1437
+ if (existingParameter) {
1438
+ if (parameterDescription) {
1439
+ existingParameter.description = parameterDescription;
1440
+ }
1441
+ }
1442
+ else {
1443
+ promptbookJson.parameters.push({
1444
+ name: parameterName,
1445
+ description: parameterDescription || undefined,
1446
+ isInput: isInput,
1447
+ isOutput: isOutput,
1448
+ });
1449
+ }
1450
+ };
1451
+ markdownStructure = markdownToMarkdownStructure(promptbookString);
1452
+ markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
1453
+ if (markdownStructureDeepness !== 2) {
1454
+ throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
1455
+ }
1456
+ promptbookJson.title = markdownStructure.title;
1457
+ description = markdownStructure.content;
1458
+ // Note: Remove codeblocks
1459
+ description = description.split(/^```.*^```/gms).join('');
1460
+ //Note: Remove lists and return statement
1461
+ description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1462
+ description = spaceTrim.spaceTrim(description);
1463
+ if (description === '') {
1464
+ description = undefined;
1465
+ }
1466
+ promptbookJson.description = description;
1467
+ defaultModelRequirements = {};
1468
+ listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
1469
+ try {
1470
+ for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
1471
+ listItem = listItems_1_1.value;
1472
+ command = parseCommand(listItem);
1473
+ switch (command.type) {
1474
+ case 'PROMPTBOOK_URL':
1475
+ promptbookJson.promptbookUrl = command.promptbookUrl.href;
1476
+ break;
1477
+ case 'PROMPTBOOK_VERSION':
1478
+ promptbookJson.promptbookVersion = command.promptbookVersion;
1479
+ break;
1480
+ case 'MODEL':
1481
+ defaultModelRequirements[command.key] = command.value;
1482
+ break;
1483
+ case 'PARAMETER':
1484
+ addParam(command);
1485
+ break;
1486
+ default:
1487
+ throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
1488
+ }
1489
+ }
1364
1490
  }
1365
- }
1366
- else {
1367
- promptbookJson.parameters.push({
1368
- name: parameterName,
1369
- description: parameterDescription || undefined,
1370
- isInput: isInput,
1371
- isOutput: isOutput,
1372
- });
1373
- }
1374
- };
1375
- // =============================================================
1376
- // Note: 3️⃣ Parse the dynamic part - the template pipeline
1377
- var markdownStructure = markdownToMarkdownStructure(promptbookString);
1378
- var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
1379
- if (markdownStructureDeepness !== 2) {
1380
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
1381
- }
1382
- promptbookJson.title = markdownStructure.title;
1383
- // TODO: [1] DRY description
1384
- var description = markdownStructure.content;
1385
- // Note: Remove codeblocks
1386
- description = description.split(/^```.*^```/gms).join('');
1387
- //Note: Remove lists and return statement
1388
- description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1389
- description = spaceTrim.spaceTrim(description);
1390
- if (description === '') {
1391
- description = undefined;
1392
- }
1393
- promptbookJson.description = description;
1394
- var defaultModelRequirements = {};
1395
- var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
1396
- try {
1397
- for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
1398
- var listItem = listItems_1_1.value;
1399
- var command = parseCommand(listItem);
1400
- switch (command.type) {
1401
- case 'PROMPTBOOK_URL':
1402
- promptbookJson.promptbookUrl = command.promptbookUrl.href;
1403
- break;
1404
- case 'PROMPTBOOK_VERSION':
1405
- promptbookJson.promptbookVersion = command.promptbookVersion;
1406
- break;
1407
- case 'MODEL':
1408
- defaultModelRequirements[command.key] = command.value;
1409
- break;
1410
- case 'PARAMETER':
1411
- addParam(command);
1412
- break;
1413
- default:
1414
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
1491
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1492
+ finally {
1493
+ try {
1494
+ if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
1495
+ }
1496
+ finally { if (e_1) throw e_1.error; }
1415
1497
  }
1416
- }
1417
- }
1418
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1419
- finally {
1420
- try {
1421
- if (listItems_1_1 && !listItems_1_1.done && (_a = listItems_1.return)) _a.call(listItems_1);
1422
- }
1423
- finally { if (e_1) throw e_1.error; }
1424
- }
1425
- var _loop_1 = function (section) {
1426
- var e_3, _e;
1427
- // TODO: Parse prompt template description (the content out of the codeblock and lists)
1428
- var templateModelRequirements = __assign({}, defaultModelRequirements);
1429
- var listItems_3 = extractAllListItemsFromMarkdown(section.content);
1430
- var dependentParameterNames = new Set();
1431
- var executionType = 'PROMPT_TEMPLATE';
1432
- var jokers = [];
1433
- var postprocessing = [];
1434
- var expectAmount = {};
1435
- var expectFormat = undefined;
1436
- var isExecutionTypeChanged = false;
1437
- try {
1438
- for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
1439
- var listItem = listItems_2_1.value;
1440
- var command = parseCommand(listItem);
1441
- switch (command.type) {
1442
- case 'JOKER':
1443
- jokers.push(command.parameterName);
1444
- dependentParameterNames.add(command.parameterName);
1445
- break;
1446
- case 'EXECUTE':
1447
- if (isExecutionTypeChanged) {
1448
- throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
1449
- }
1450
- executionType = command.executionType;
1451
- isExecutionTypeChanged = true;
1452
- break;
1453
- case 'MODEL':
1454
- templateModelRequirements[command.key] = command.value;
1455
- break;
1456
- case 'PARAMETER':
1457
- // Note: This is just for detecting resulitng parameter name
1458
- addParam(command);
1459
- break;
1460
- case 'POSTPROCESS':
1461
- postprocessing.push(command.functionName);
1462
- break;
1463
- case 'EXPECT_AMOUNT':
1464
- // eslint-disable-next-line no-case-declarations
1465
- var unit = command.unit.toLowerCase();
1466
- expectAmount[unit] = expectAmount[unit] || {};
1467
- if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
1468
- if (expectAmount[unit].min !== undefined) {
1469
- throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
1470
- }
1471
- expectAmount[unit].min = command.amount;
1472
- } /* not else */
1473
- if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
1474
- if (expectAmount[unit].max !== undefined) {
1475
- throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
1476
- }
1477
- expectAmount[unit].max = command.amount;
1478
- }
1479
- break;
1480
- case 'EXPECT_FORMAT':
1481
- if (expectFormat !== undefined && command.format !== expectFormat) {
1482
- throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
1498
+ _loop_1 = function (section) {
1499
+ var e_3, _f;
1500
+ // TODO: Parse prompt template description (the content out of the codeblock and lists)
1501
+ var templateModelRequirements = __assign({}, defaultModelRequirements);
1502
+ var listItems_3 = extractAllListItemsFromMarkdown(section.content);
1503
+ var dependentParameterNames = new Set();
1504
+ var executionType = 'PROMPT_TEMPLATE';
1505
+ var jokers = [];
1506
+ var postprocessing = [];
1507
+ var expectAmount = {};
1508
+ var expectFormat = undefined;
1509
+ var isExecutionTypeChanged = false;
1510
+ try {
1511
+ for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
1512
+ var listItem = listItems_2_1.value;
1513
+ var command = parseCommand(listItem);
1514
+ switch (command.type) {
1515
+ case 'JOKER':
1516
+ jokers.push(command.parameterName);
1517
+ dependentParameterNames.add(command.parameterName);
1518
+ break;
1519
+ case 'EXECUTE':
1520
+ if (isExecutionTypeChanged) {
1521
+ throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
1522
+ }
1523
+ executionType = command.executionType;
1524
+ isExecutionTypeChanged = true;
1525
+ break;
1526
+ case 'MODEL':
1527
+ templateModelRequirements[command.key] = command.value;
1528
+ break;
1529
+ case 'PARAMETER':
1530
+ // Note: This is just for detecting resulitng parameter name
1531
+ addParam(command);
1532
+ break;
1533
+ case 'POSTPROCESS':
1534
+ postprocessing.push(command.functionName);
1535
+ break;
1536
+ case 'EXPECT_AMOUNT':
1537
+ // eslint-disable-next-line no-case-declarations
1538
+ var unit = command.unit.toLowerCase();
1539
+ expectAmount[unit] = expectAmount[unit] || {};
1540
+ if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
1541
+ if (expectAmount[unit].min !== undefined) {
1542
+ throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
1543
+ }
1544
+ expectAmount[unit].min = command.amount;
1545
+ } /* not else */
1546
+ if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
1547
+ if (expectAmount[unit].max !== undefined) {
1548
+ throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
1549
+ }
1550
+ expectAmount[unit].max = command.amount;
1551
+ }
1552
+ break;
1553
+ case 'EXPECT_FORMAT':
1554
+ if (expectFormat !== undefined && command.format !== expectFormat) {
1555
+ throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
1556
+ }
1557
+ expectFormat = command.format;
1558
+ break;
1559
+ default:
1560
+ throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
1483
1561
  }
1484
- expectFormat = command.format;
1485
- break;
1486
- default:
1487
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
1562
+ }
1488
1563
  }
1489
- }
1490
- }
1491
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1492
- finally {
1564
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1565
+ finally {
1566
+ try {
1567
+ if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
1568
+ }
1569
+ finally { if (e_3) throw e_3.error; }
1570
+ }
1571
+ var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
1572
+ if (executionType === 'SCRIPT') {
1573
+ if (!language) {
1574
+ throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
1575
+ }
1576
+ else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
1577
+ throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
1578
+ }
1579
+ }
1580
+ var lastLine = section.content.split('\n').pop();
1581
+ var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
1582
+ if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
1583
+ throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
1584
+ // TODO: Show code of invalid sections each time + DRY
1585
+ section.content
1586
+ .split('\n')
1587
+ .map(function (line) { return "> ".concat(line); })
1588
+ .join('\n')), "\n "); }));
1589
+ }
1590
+ var resultingParameterName = match.groups.resultingParamName;
1591
+ // TODO: [1] DRY description
1592
+ var description_1 = section.content;
1593
+ // Note: Remove codeblocks
1594
+ description_1 = description_1.split(/^```.*^```/gms).join('');
1595
+ //Note: Remove lists and return statement
1596
+ description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1597
+ description_1 = spaceTrim.spaceTrim(description_1);
1598
+ if (description_1 === '') {
1599
+ description_1 = undefined;
1600
+ }
1601
+ if (Object.keys(jokers).length === 0) {
1602
+ jokers = undefined;
1603
+ }
1604
+ if (Object.keys(expectAmount).length === 0) {
1605
+ expectAmount = undefined;
1606
+ }
1607
+ if (Object.keys(postprocessing).length === 0) {
1608
+ postprocessing = undefined;
1609
+ }
1610
+ dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
1611
+ if (templateModelRequirements.modelVariant === undefined) {
1612
+ templateModelRequirements.modelVariant = 'CHAT';
1613
+ }
1614
+ promptbookJson.promptTemplates.push({
1615
+ name: titleToName(section.title),
1616
+ title: section.title,
1617
+ description: description_1,
1618
+ dependentParameterNames: Array.from(dependentParameterNames),
1619
+ executionType: executionType,
1620
+ jokers: jokers,
1621
+ postprocessing: postprocessing,
1622
+ expectations: expectAmount,
1623
+ expectFormat: expectFormat,
1624
+ modelRequirements: templateModelRequirements,
1625
+ contentLanguage: executionType === 'SCRIPT' ? language : undefined,
1626
+ content: content,
1627
+ resultingParameterName: resultingParameterName,
1628
+ });
1629
+ };
1493
1630
  try {
1494
- if (listItems_2_1 && !listItems_2_1.done && (_e = listItems_2.return)) _e.call(listItems_2);
1495
- }
1496
- finally { if (e_3) throw e_3.error; }
1497
- }
1498
- var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
1499
- if (executionType === 'SCRIPT') {
1500
- if (!language) {
1501
- throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
1631
+ for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
1632
+ section = _b.value;
1633
+ _loop_1(section);
1634
+ }
1502
1635
  }
1503
- else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
1504
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
1636
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1637
+ finally {
1638
+ try {
1639
+ if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
1640
+ }
1641
+ finally { if (e_2) throw e_2.error; }
1505
1642
  }
1506
- }
1507
- var lastLine = section.content.split('\n').pop();
1508
- var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
1509
- if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
1510
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
1511
- // TODO: Show code of invalid sections each time + DRY
1512
- section.content
1513
- .split('\n')
1514
- .map(function (line) { return "> ".concat(line); })
1515
- .join('\n')), "\n "); }));
1516
- }
1517
- var resultingParameterName = match.groups.resultingParamName;
1518
- // TODO: [1] DRY description
1519
- var description_1 = section.content;
1520
- // Note: Remove codeblocks
1521
- description_1 = description_1.split(/^```.*^```/gms).join('');
1522
- //Note: Remove lists and return statement
1523
- description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1524
- description_1 = spaceTrim.spaceTrim(description_1);
1525
- if (description_1 === '') {
1526
- description_1 = undefined;
1527
- }
1528
- if (Object.keys(jokers).length === 0) {
1529
- jokers = undefined;
1530
- }
1531
- if (Object.keys(expectAmount).length === 0) {
1532
- expectAmount = undefined;
1533
- }
1534
- if (Object.keys(postprocessing).length === 0) {
1535
- postprocessing = undefined;
1536
- }
1537
- dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
1538
- if (templateModelRequirements.modelVariant === undefined) {
1539
- templateModelRequirements.modelVariant = 'CHAT';
1540
- }
1541
- promptbookJson.promptTemplates.push({
1542
- name: titleToName(section.title),
1543
- title: section.title,
1544
- description: description_1,
1545
- dependentParameterNames: Array.from(dependentParameterNames),
1546
- executionType: executionType,
1547
- jokers: jokers,
1548
- postprocessing: postprocessing,
1549
- expectations: expectAmount,
1550
- expectFormat: expectFormat,
1551
- modelRequirements: templateModelRequirements,
1552
- contentLanguage: executionType === 'SCRIPT' ? language : undefined,
1553
- content: content,
1554
- resultingParameterName: resultingParameterName,
1643
+ // =============================================================
1644
+ return [2 /*return*/, promptbookJson];
1555
1645
  });
1556
- };
1557
- try {
1558
- for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
1559
- var section = _d.value;
1560
- _loop_1(section);
1561
- }
1562
- }
1563
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1564
- finally {
1565
- try {
1566
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1567
- }
1568
- finally { if (e_2) throw e_2.error; }
1569
- }
1570
- // =============================================================
1571
- return promptbookJson;
1646
+ });
1572
1647
  }
1573
1648
  /**
1574
1649
  * TODO: Report here line/column of error
@@ -1576,59 +1651,6 @@
1576
1651
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
1577
1652
  */
1578
1653
 
1579
- /**
1580
- * Add or modify an auto-generated section in a markdown file
1581
- *
1582
- * @private within the library
1583
- */
1584
- function addAutoGeneratedSection(content, options) {
1585
- var sectionName = options.sectionName, sectionContent = options.sectionContent;
1586
- var warningLine = "<!-- \u26A0\uFE0F WARNING: This section was auto-generated -->";
1587
- var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
1588
- var sectionMatch = content.match(sectionRegex);
1589
- if (sectionMatch) {
1590
- return content.replace(sectionRegex, spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
1591
- }
1592
- var placeForSection = removeContentComments(content).match(/^##.*$/im);
1593
- if (!placeForSection) {
1594
- throw new Error("No place where to put the section <!--".concat(sectionName, "-->"));
1595
- }
1596
- var _a = __read(placeForSection, 1), heading = _a[0];
1597
- return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
1598
- }
1599
-
1600
- /**
1601
- * Prettify the html code
1602
- *
1603
- * @param content raw html code
1604
- * @returns formatted html code
1605
- */
1606
- function prettifyMarkdown(content) {
1607
- try {
1608
- return prettier.format(content, {
1609
- parser: 'markdown',
1610
- plugins: [parserHtml__default["default"]],
1611
- // TODO: DRY - make some import or auto-copy of .prettierrc
1612
- endOfLine: 'lf',
1613
- tabWidth: 4,
1614
- singleQuote: true,
1615
- trailingComma: 'all',
1616
- arrowParens: 'always',
1617
- printWidth: 120,
1618
- htmlWhitespaceSensitivity: 'ignore',
1619
- jsxBracketSameLine: false,
1620
- bracketSpacing: true,
1621
- });
1622
- }
1623
- catch (error) {
1624
- console.error('There was an error with prettifying the markdown, using the original as the fallback', {
1625
- error: error,
1626
- html: content,
1627
- });
1628
- return content;
1629
- }
1630
- }
1631
-
1632
1654
  /* tslint:disable */
1633
1655
  function normalizeTo_camelCase(sentence, __firstLetterCapital) {
1634
1656
  var e_1, _a;
@@ -1746,24 +1768,35 @@
1746
1768
  * Prettyfies Promptbook string and adds Mermaid graph
1747
1769
  */
1748
1770
  function prettifyPromptbookString(promptbookString, options) {
1749
- var isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
1750
- if (isGraphAdded) {
1751
- var promptbookJson = promptbookStringToJson(promptbookString);
1752
- var promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson, {
1753
- linkPromptTemplate: function (promptTemplate) {
1754
- return { href: "#".concat(promptTemplate.name), title: promptTemplate.title };
1755
- },
1756
- });
1757
- var promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
1758
- promptbookString = addAutoGeneratedSection(promptbookString, {
1759
- sectionName: 'Graph',
1760
- sectionContent: promptbookMermaidBlock,
1771
+ return __awaiter(this, void 0, void 0, function () {
1772
+ var isGraphAdded, isPrettifyed, promptbookJson, promptbookMermaid_1, promptbookMermaidBlock;
1773
+ return __generator(this, function (_a) {
1774
+ switch (_a.label) {
1775
+ case 0:
1776
+ isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
1777
+ if (!isGraphAdded) return [3 /*break*/, 2];
1778
+ return [4 /*yield*/, promptbookStringToJson(promptbookString /* , {!!!!} */)];
1779
+ case 1:
1780
+ promptbookJson = _a.sent();
1781
+ promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson, {
1782
+ linkPromptTemplate: function (promptTemplate) {
1783
+ return { href: "#".concat(promptTemplate.name), title: promptTemplate.title };
1784
+ },
1785
+ });
1786
+ promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
1787
+ promptbookString = addAutoGeneratedSection(promptbookString, {
1788
+ sectionName: 'Graph',
1789
+ sectionContent: promptbookMermaidBlock,
1790
+ });
1791
+ _a.label = 2;
1792
+ case 2:
1793
+ if (isPrettifyed) {
1794
+ promptbookString = prettifyMarkdown(promptbookString);
1795
+ }
1796
+ return [2 /*return*/, promptbookString];
1797
+ }
1761
1798
  });
1762
- }
1763
- if (isPrettifyed) {
1764
- promptbookString = prettifyMarkdown(promptbookString);
1765
- }
1766
- return promptbookString;
1799
+ });
1767
1800
  }
1768
1801
  /**
1769
1802
  * TODO: Maybe use some Mermaid library instead of string templating
@@ -2312,7 +2345,7 @@
2312
2345
  /**
2313
2346
  * Function isValidJsonString will tell you if the string is valid JSON or not
2314
2347
  */
2315
- function isValidJsonString(value) {
2348
+ function isValidJsonString(value /* <-[👨‍⚖️] */) {
2316
2349
  try {
2317
2350
  JSON.parse(value);
2318
2351
  return true;
@@ -3141,6 +3174,86 @@
3141
3174
  * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
3142
3175
  */
3143
3176
 
3177
+ /**
3178
+ * Function usageToWorktime will take usage and estimate saved worktime in hours of reading / writing
3179
+ *
3180
+ * Note: This is an estimate based of theese sources:
3181
+ * - https://jecas.cz/doba-cteni
3182
+ * - https://www.originalnitonery.cz/blog/psani-vsemi-deseti-se-muzete-naucit-i-sami-doma
3183
+ */
3184
+ function usageToWorktime(usage) {
3185
+ var value = usage.input.wordsCount.value / (200 /* words per minute */ * 60) +
3186
+ usage.output.wordsCount.value / (40 /* words per minute */ * 60);
3187
+ var isUncertain = usage.input.wordsCount.isUncertain || usage.output.wordsCount.isUncertain;
3188
+ var uncertainNumber = { value: value };
3189
+ if (isUncertain === true) {
3190
+ uncertainNumber.isUncertain = true;
3191
+ }
3192
+ return uncertainNumber;
3193
+ }
3194
+
3195
+ /**
3196
+ * Delagates the user interaction to a async callback function
3197
+ * You need to provide your own implementation of this callback function and its bind to UI.
3198
+ */
3199
+ var CallbackInterfaceTools = /** @class */ (function () {
3200
+ function CallbackInterfaceTools(options) {
3201
+ this.options = options;
3202
+ }
3203
+ /**
3204
+ * Trigger the custom callback function
3205
+ */
3206
+ CallbackInterfaceTools.prototype.promptDialog = function (options) {
3207
+ return __awaiter(this, void 0, void 0, function () {
3208
+ var answer;
3209
+ return __generator(this, function (_a) {
3210
+ switch (_a.label) {
3211
+ case 0: return [4 /*yield*/, this.options.callback(options)];
3212
+ case 1:
3213
+ answer = _a.sent();
3214
+ if (this.options.isVerbose) {
3215
+ console.info(spaceTrim.spaceTrim(function (block) { return "\n \uD83D\uDCD6 ".concat(block(options.promptTitle), "\n \uD83D\uDC64 ").concat(block(answer), "\n "); }));
3216
+ }
3217
+ return [2 /*return*/, answer];
3218
+ }
3219
+ });
3220
+ });
3221
+ };
3222
+ return CallbackInterfaceTools;
3223
+ }());
3224
+
3225
+ /**
3226
+ * Wrapper around `window.prompt` synchronous function that interacts with the user via browser prompt
3227
+ *
3228
+ * Warning: It is used for testing and mocking
3229
+ * **NOT intended to use in the production** due to its synchronous nature.
3230
+ */
3231
+ var SimplePromptInterfaceTools = /** @class */ (function () {
3232
+ function SimplePromptInterfaceTools(options) {
3233
+ if (options === void 0) { options = {}; }
3234
+ this.options = options;
3235
+ }
3236
+ /**
3237
+ * Trigger window.PROMPT DIALOG
3238
+ */
3239
+ SimplePromptInterfaceTools.prototype.promptDialog = function (options) {
3240
+ return __awaiter(this, void 0, void 0, function () {
3241
+ var answer;
3242
+ return __generator(this, function (_a) {
3243
+ answer = window.prompt(spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(options.promptTitle), "\n\n ").concat(block(options.promptMessage), "\n "); }));
3244
+ if (this.options.isVerbose) {
3245
+ console.info(spaceTrim.spaceTrim(function (block) { return "\n \uD83D\uDCD6 ".concat(block(options.promptTitle), "\n \uD83D\uDC64 ").concat(block(answer || '🚫 User cancelled prompt'), "\n "); }));
3246
+ }
3247
+ if (answer === null) {
3248
+ throw new PromptbookExecutionError('User cancelled prompt');
3249
+ }
3250
+ return [2 /*return*/, answer];
3251
+ });
3252
+ });
3253
+ };
3254
+ return SimplePromptInterfaceTools;
3255
+ }());
3256
+
3144
3257
  /**
3145
3258
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
3146
3259
  *
@@ -3272,85 +3385,6 @@
3272
3385
  return MultipleLlmExecutionTools;
3273
3386
  }());
3274
3387
 
3275
- /**
3276
- * Delagates the user interaction to a async callback function
3277
- * You need to provide your own implementation of this callback function and its bind to UI.
3278
- */
3279
- var CallbackInterfaceTools = /** @class */ (function () {
3280
- function CallbackInterfaceTools(options) {
3281
- this.options = options;
3282
- }
3283
- /**
3284
- * Trigger the custom callback function
3285
- */
3286
- CallbackInterfaceTools.prototype.promptDialog = function (options) {
3287
- return __awaiter(this, void 0, void 0, function () {
3288
- var answer;
3289
- return __generator(this, function (_a) {
3290
- switch (_a.label) {
3291
- case 0: return [4 /*yield*/, this.options.callback(options)];
3292
- case 1:
3293
- answer = _a.sent();
3294
- if (this.options.isVerbose) {
3295
- console.info(spaceTrim.spaceTrim(function (block) { return "\n \uD83D\uDCD6 ".concat(block(options.promptTitle), "\n \uD83D\uDC64 ").concat(block(answer), "\n "); }));
3296
- }
3297
- return [2 /*return*/, answer];
3298
- }
3299
- });
3300
- });
3301
- };
3302
- return CallbackInterfaceTools;
3303
- }());
3304
-
3305
- /**
3306
- * Wrapper around `window.prompt` synchronous function that interacts with the user via browser prompt
3307
- *
3308
- * Warning: It is used for testing and mocking
3309
- * **NOT intended to use in the production** due to its synchronous nature.
3310
- */
3311
- var SimplePromptInterfaceTools = /** @class */ (function () {
3312
- function SimplePromptInterfaceTools(options) {
3313
- this.options = options;
3314
- }
3315
- /**
3316
- * Trigger window.PROMPT DIALOG
3317
- */
3318
- SimplePromptInterfaceTools.prototype.promptDialog = function (options) {
3319
- return __awaiter(this, void 0, void 0, function () {
3320
- var answer;
3321
- return __generator(this, function (_a) {
3322
- answer = window.prompt(spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(options.promptTitle), "\n\n ").concat(block(options.promptMessage), "\n "); }));
3323
- if (this.options.isVerbose) {
3324
- console.info(spaceTrim.spaceTrim(function (block) { return "\n \uD83D\uDCD6 ".concat(block(options.promptTitle), "\n \uD83D\uDC64 ").concat(block(answer || '🚫 User cancelled prompt'), "\n "); }));
3325
- }
3326
- if (answer === null) {
3327
- throw new PromptbookExecutionError('User cancelled prompt');
3328
- }
3329
- return [2 /*return*/, answer];
3330
- });
3331
- });
3332
- };
3333
- return SimplePromptInterfaceTools;
3334
- }());
3335
-
3336
- /**
3337
- * Function usageToWorktime will take usage and estimate saved worktime in hours of reading / writing
3338
- *
3339
- * Note: This is an estimate based of theese sources:
3340
- * - https://jecas.cz/doba-cteni
3341
- * - https://www.originalnitonery.cz/blog/psani-vsemi-deseti-se-muzete-naucit-i-sami-doma
3342
- */
3343
- function usageToWorktime(usage) {
3344
- var value = usage.input.wordsCount.value / (200 /* words per minute */ * 60) +
3345
- usage.output.wordsCount.value / (40 /* words per minute */ * 60);
3346
- var isUncertain = usage.input.wordsCount.isUncertain || usage.output.wordsCount.isUncertain;
3347
- var uncertainNumber = { value: value };
3348
- if (isUncertain === true) {
3349
- uncertainNumber.isUncertain = true;
3350
- }
3351
- return uncertainNumber;
3352
- }
3353
-
3354
3388
  /**
3355
3389
  * Library of promptbooks that groups together promptbooks for an application.
3356
3390
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
@@ -3440,36 +3474,61 @@
3440
3474
  * @returns PromptbookLibrary
3441
3475
  */
3442
3476
  function createPromptbookLibraryFromSources() {
3443
- var e_1, _a;
3444
3477
  var promptbookSources = [];
3445
3478
  for (var _i = 0; _i < arguments.length; _i++) {
3446
3479
  promptbookSources[_i] = arguments[_i];
3447
3480
  }
3448
- var promptbooks = new Array();
3449
- try {
3450
- for (var promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next(); !promptbookSources_1_1.done; promptbookSources_1_1 = promptbookSources_1.next()) {
3451
- var source = promptbookSources_1_1.value;
3452
- var promptbook = void 0;
3453
- if (typeof source === 'string') {
3454
- // Note: When directly creating from string, no need to validate the source
3455
- // The validation is performed always before execution
3456
- promptbook = promptbookStringToJson(source);
3457
- }
3458
- else {
3459
- promptbook = source;
3481
+ return __awaiter(this, void 0, void 0, function () {
3482
+ var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
3483
+ var e_1, _a;
3484
+ return __generator(this, function (_b) {
3485
+ switch (_b.label) {
3486
+ case 0:
3487
+ promptbooks = new Array();
3488
+ _b.label = 1;
3489
+ case 1:
3490
+ _b.trys.push([1, 8, 9, 10]);
3491
+ promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
3492
+ _b.label = 2;
3493
+ case 2:
3494
+ if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
3495
+ source = promptbookSources_1_1.value;
3496
+ promptbook = void 0;
3497
+ if (!(typeof source === 'string')) return [3 /*break*/, 4];
3498
+ return [4 /*yield*/, promptbookStringToJson(source)];
3499
+ case 3:
3500
+ // Note: When directly creating from string, no need to validate the source
3501
+ // The validation is performed always before execution
3502
+ promptbook = _b.sent();
3503
+ return [3 /*break*/, 5];
3504
+ case 4:
3505
+ promptbook = source;
3506
+ _b.label = 5;
3507
+ case 5:
3508
+ promptbooks.push(promptbook);
3509
+ _b.label = 6;
3510
+ case 6:
3511
+ promptbookSources_1_1 = promptbookSources_1.next();
3512
+ return [3 /*break*/, 2];
3513
+ case 7: return [3 /*break*/, 10];
3514
+ case 8:
3515
+ e_1_1 = _b.sent();
3516
+ e_1 = { error: e_1_1 };
3517
+ return [3 /*break*/, 10];
3518
+ case 9:
3519
+ try {
3520
+ if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
3521
+ }
3522
+ finally { if (e_1) throw e_1.error; }
3523
+ return [7 /*endfinally*/];
3524
+ case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
3460
3525
  }
3461
- promptbooks.push(promptbook);
3462
- }
3463
- }
3464
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3465
- finally {
3466
- try {
3467
- if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
3468
- }
3469
- finally { if (e_1) throw e_1.error; }
3470
- }
3471
- return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
3526
+ });
3527
+ });
3472
3528
  }
3529
+ /**
3530
+ * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3531
+ */
3473
3532
 
3474
3533
  /**
3475
3534
  * Constructs Promptbook from async sources
@@ -3505,7 +3564,9 @@
3505
3564
  return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3506
3565
  case 1:
3507
3566
  promptbookSources = _a.sent();
3508
- library = createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3567
+ return [4 /*yield*/, createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
3568
+ case 2:
3569
+ library = _a.sent();
3509
3570
  return [2 /*return*/];
3510
3571
  }
3511
3572
  });
@@ -3553,6 +3614,9 @@
3553
3614
  isResponsibleForPrompt: isResponsibleForPrompt,
3554
3615
  };
3555
3616
  }
3617
+ /**
3618
+ * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3619
+ */
3556
3620
 
3557
3621
  /**
3558
3622
  * Constructs Promptbook from remote Promptbase URL
@@ -3585,6 +3649,9 @@
3585
3649
  });
3586
3650
  });
3587
3651
  }
3652
+ /**
3653
+ * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3654
+ */
3588
3655
 
3589
3656
  /**
3590
3657
  * Creates PromptbookLibrary as a subset of another PromptbookLibrary
@@ -3685,23 +3752,6 @@
3685
3752
  return value.toString();
3686
3753
  }
3687
3754
 
3688
- /**
3689
- * Returns the same value that is passed as argument.
3690
- * No side effects.
3691
- *
3692
- * Note: It can be usefull for leveling indentation
3693
- *
3694
- * @param value any values
3695
- * @returns the same values
3696
- */
3697
- function just(value) {
3698
- if (value === undefined) {
3699
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3700
- return undefined;
3701
- }
3702
- return value;
3703
- }
3704
-
3705
3755
  /**
3706
3756
  * Create a markdown table from a 2D array of strings
3707
3757
  *