@promptbook/cli 0.59.0-8 → 0.59.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 (593) hide show
  1. package/README.md +55 -0
  2. package/bin/promptbook-cli.js +2 -4
  3. package/esm/index.es.js +1132 -611
  4. package/esm/index.es.js.map +1 -1
  5. package/esm/typings/promptbook-library/index.d.ts +25 -0
  6. package/esm/typings/src/_packages/cli.index.d.ts +10 -0
  7. package/{umd/typings → esm/typings/src}/_packages/core.index.d.ts +11 -9
  8. package/esm/typings/src/_packages/node.index.d.ts +4 -0
  9. package/{umd/typings → esm/typings/src}/_packages/types.index.d.ts +4 -3
  10. package/esm/typings/src/cli/actions/hello.d.ts +7 -0
  11. package/esm/typings/src/cli/actions/make.d.ts +7 -0
  12. package/esm/typings/src/cli/actions/prettify.d.ts +7 -0
  13. package/esm/typings/{conversion/prettify/prettifyPromptbookStringCli.d.ts → src/cli/promptbookCli.d.ts} +2 -2
  14. package/esm/typings/{config.d.ts → src/config.d.ts} +4 -0
  15. package/esm/typings/{conversion → src/conversion}/promptbookStringToJson.d.ts +5 -3
  16. package/esm/typings/src/conversion/promptbookStringToJsonSync.d.ts +23 -0
  17. package/{umd/typings/conversion/validation/validatePromptbookJson.d.ts → esm/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
  18. package/esm/typings/src/execution/EmbeddingVector.d.ts +8 -0
  19. package/esm/typings/{execution → src/execution}/LlmExecutionTools.d.ts +1 -0
  20. package/esm/typings/{execution → src/execution}/PromptResult.d.ts +11 -0
  21. package/esm/typings/src/execution/embeddingVectorToString.d.ts +5 -0
  22. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +21 -0
  23. package/esm/typings/{promptbook-library → src/library}/SimplePromptbookLibrary.d.ts +3 -1
  24. package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.d.ts → src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  25. package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  26. package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.d.ts → src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  27. package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromUrl.d.ts → src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  28. package/esm/typings/{promptbook-library/constructors/createPromptbookSublibrary.d.ts → src/library/constructors/createSublibrary.d.ts} +1 -1
  29. package/esm/typings/src/library/libraryToJson.d.ts +8 -0
  30. package/{umd/typings → esm/typings/src}/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -0
  31. package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  32. package/{umd/typings → esm/typings/src}/llm-providers/openai/OpenAiExecutionTools.d.ts +13 -0
  33. package/esm/typings/{llm-providers → src/llm-providers}/openai/computeOpenaiUsage.d.ts +4 -2
  34. package/{umd/typings → esm/typings/src}/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +1 -1
  35. package/esm/typings/{llm-providers → src/llm-providers}/remote/startRemoteServer.d.ts +1 -1
  36. package/{umd/typings → esm/typings/src}/types/ModelRequirements.d.ts +1 -1
  37. package/esm/typings/{types → src/types}/PromptbookJson/KnowledgeJson.d.ts +1 -1
  38. package/esm/typings/{types → src/types}/PromptbookJson/MaterialKnowledgePieceJson.d.ts +4 -3
  39. package/package.json +3 -3
  40. package/umd/index.umd.js +1101 -581
  41. package/umd/index.umd.js.map +1 -1
  42. package/umd/typings/promptbook-library/index.d.ts +25 -0
  43. package/umd/typings/src/_packages/cli.index.d.ts +10 -0
  44. package/{esm/typings → umd/typings/src}/_packages/core.index.d.ts +11 -9
  45. package/umd/typings/src/_packages/node.index.d.ts +4 -0
  46. package/{esm/typings → umd/typings/src}/_packages/types.index.d.ts +4 -3
  47. package/umd/typings/src/cli/actions/hello.d.ts +7 -0
  48. package/umd/typings/src/cli/actions/make.d.ts +7 -0
  49. package/umd/typings/src/cli/actions/prettify.d.ts +7 -0
  50. package/umd/typings/{conversion/prettify/prettifyPromptbookStringCli.d.ts → src/cli/promptbookCli.d.ts} +2 -2
  51. package/umd/typings/{config.d.ts → src/config.d.ts} +4 -0
  52. package/umd/typings/{conversion → src/conversion}/promptbookStringToJson.d.ts +5 -3
  53. package/umd/typings/src/conversion/promptbookStringToJsonSync.d.ts +23 -0
  54. package/{esm/typings/conversion/validation/validatePromptbookJson.d.ts → umd/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
  55. package/umd/typings/src/execution/EmbeddingVector.d.ts +8 -0
  56. package/umd/typings/{execution → src/execution}/LlmExecutionTools.d.ts +1 -0
  57. package/umd/typings/{execution → src/execution}/PromptResult.d.ts +11 -0
  58. package/umd/typings/src/execution/embeddingVectorToString.d.ts +5 -0
  59. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +21 -0
  60. package/umd/typings/{promptbook-library → src/library}/SimplePromptbookLibrary.d.ts +3 -1
  61. package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.d.ts → src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  62. package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  63. package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.d.ts → src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  64. package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromUrl.d.ts → src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  65. package/umd/typings/{promptbook-library/constructors/createPromptbookSublibrary.d.ts → src/library/constructors/createSublibrary.d.ts} +1 -1
  66. package/umd/typings/src/library/libraryToJson.d.ts +8 -0
  67. package/{esm/typings → umd/typings/src}/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -0
  68. package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  69. package/{esm/typings → umd/typings/src}/llm-providers/openai/OpenAiExecutionTools.d.ts +13 -0
  70. package/umd/typings/{llm-providers → src/llm-providers}/openai/computeOpenaiUsage.d.ts +4 -2
  71. package/{esm/typings → umd/typings/src}/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +1 -1
  72. package/umd/typings/{llm-providers → src/llm-providers}/remote/startRemoteServer.d.ts +1 -1
  73. package/{esm/typings → umd/typings/src}/types/ModelRequirements.d.ts +1 -1
  74. package/umd/typings/{types → src/types}/PromptbookJson/KnowledgeJson.d.ts +1 -1
  75. package/umd/typings/{types → src/types}/PromptbookJson/MaterialKnowledgePieceJson.d.ts +4 -3
  76. package/umd/typings/src/utils/trimCodeBlock.test.d.ts +1 -0
  77. package/umd/typings/src/utils/trimEndOfCodeBlock.test.d.ts +1 -0
  78. package/umd/typings/src/utils/unwrapResult.test.d.ts +1 -0
  79. package/umd/typings/src/utils/validators/url/isValidUrl.test.d.ts +1 -0
  80. package/esm/typings/_packages/cli.index.d.ts +0 -10
  81. package/esm/typings/_packages/node.index.d.ts +0 -4
  82. package/esm/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +0 -4
  83. package/esm/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -7
  84. package/esm/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  85. package/umd/typings/_packages/cli.index.d.ts +0 -10
  86. package/umd/typings/_packages/node.index.d.ts +0 -4
  87. package/umd/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +0 -4
  88. package/umd/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -7
  89. package/umd/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  90. /package/esm/typings/{_packages → src/_packages}/anthropic-claude.index.d.ts +0 -0
  91. /package/esm/typings/{_packages → src/_packages}/azure-openai.index.d.ts +0 -0
  92. /package/esm/typings/{_packages → src/_packages}/execute-javascript.index.d.ts +0 -0
  93. /package/esm/typings/{_packages → src/_packages}/fake-llm.index.d.ts +0 -0
  94. /package/esm/typings/{_packages → src/_packages}/langtail.index.d.ts +0 -0
  95. /package/esm/typings/{_packages → src/_packages}/openai.index.d.ts +0 -0
  96. /package/esm/typings/{_packages → src/_packages}/remote-client.index.d.ts +0 -0
  97. /package/esm/typings/{_packages → src/_packages}/remote-server.index.d.ts +0 -0
  98. /package/esm/typings/{_packages → src/_packages}/utils.index.d.ts +0 -0
  99. /package/esm/typings/{conversion → src/conversion}/prettify/PrettifyOptions.d.ts +0 -0
  100. /package/esm/typings/{conversion → src/conversion}/prettify/prettifyPromptbookString.d.ts +0 -0
  101. /package/esm/typings/{conversion → src/conversion}/prettify/renderPromptbookMermaid.d.ts +0 -0
  102. /package/esm/typings/{conversion → src/conversion}/promptbookJsonToString.d.ts +0 -0
  103. /package/esm/typings/{conversion → src/conversion}/promptbookStringToJson.test.d.ts +0 -0
  104. /package/esm/typings/{conversion/utils/extractParametersFromPromptTemplate.test.d.ts → src/conversion/promptbookStringToJsonSync.test.d.ts} +0 -0
  105. /package/esm/typings/{conversion → src/conversion}/utils/extractParametersFromPromptTemplate.d.ts +0 -0
  106. /package/{umd/typings → esm/typings/src}/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +0 -0
  107. /package/esm/typings/{conversion → src/conversion}/utils/extractVariables.d.ts +0 -0
  108. /package/esm/typings/{conversion → src/conversion}/utils/extractVariables.test.d.ts +0 -0
  109. /package/esm/typings/{conversion → src/conversion}/utils/parseCommand.d.ts +0 -0
  110. /package/esm/typings/{conversion → src/conversion}/utils/parseCommand.test.d.ts +0 -0
  111. /package/esm/typings/{conversion → src/conversion}/utils/parseNumber.d.ts +0 -0
  112. /package/esm/typings/{conversion → src/conversion}/utils/parseNumber.test.d.ts +0 -0
  113. /package/esm/typings/{conversion → src/conversion}/utils/renameParameter.d.ts +0 -0
  114. /package/esm/typings/{conversion → src/conversion}/utils/renameParameter.test.d.ts +0 -0
  115. /package/esm/typings/{conversion → src/conversion}/utils/titleToName.d.ts +0 -0
  116. /package/esm/typings/{conversion → src/conversion}/utils/titleToName.test.d.ts +0 -0
  117. /package/esm/typings/{conversion → src/conversion}/validation/_importPromptbook.d.ts +0 -0
  118. /package/esm/typings/{conversion → src/conversion}/validation/promptbookStringToJson-syntaxErrors.test.d.ts +0 -0
  119. /package/esm/typings/{conversion/validation/validatePromptbookJson-logicErrors.test.d.ts → src/conversion/validation/validatePromptbook-logicErrors.test.d.ts} +0 -0
  120. /package/esm/typings/{conversion/validation/validatePromptbookJson.test.d.ts → src/conversion/validation/validatePromptbook.test.d.ts} +0 -0
  121. /package/esm/typings/{errors → src/errors}/PromptbookExecutionError.d.ts +0 -0
  122. /package/esm/typings/{errors → src/errors}/PromptbookLibraryError.d.ts +0 -0
  123. /package/esm/typings/{errors → src/errors}/PromptbookLogicError.d.ts +0 -0
  124. /package/esm/typings/{errors → src/errors}/PromptbookNotFoundError.d.ts +0 -0
  125. /package/esm/typings/{errors → src/errors}/PromptbookReferenceError.d.ts +0 -0
  126. /package/esm/typings/{errors → src/errors}/PromptbookSyntaxError.d.ts +0 -0
  127. /package/esm/typings/{errors → src/errors}/TemplateError.d.ts +0 -0
  128. /package/esm/typings/{errors → src/errors}/UnexpectedError.d.ts +0 -0
  129. /package/esm/typings/{errors → src/errors}/_ExpectError.d.ts +0 -0
  130. /package/esm/typings/{execution → src/execution}/CommonExecutionToolsOptions.d.ts +0 -0
  131. /package/esm/typings/{execution → src/execution}/ExecutionTools.d.ts +0 -0
  132. /package/esm/typings/{execution → src/execution}/PromptbookExecutor.d.ts +0 -0
  133. /package/esm/typings/{execution → src/execution}/ScriptExecutionTools.d.ts +0 -0
  134. /package/esm/typings/{execution → src/execution}/UserInterfaceTools.d.ts +0 -0
  135. /package/esm/typings/{execution → src/execution}/addPromptResultUsage.test.d.ts +0 -0
  136. /package/esm/typings/{execution → src/execution}/assertsExecutionSuccessful.d.ts +0 -0
  137. /package/esm/typings/{execution → src/execution}/createPromptbookExecutor.d.ts +0 -0
  138. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +0 -0
  139. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +0 -0
  140. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +0 -0
  141. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +0 -0
  142. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +0 -0
  143. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +0 -0
  144. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +0 -0
  145. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/translateMessages.d.ts +0 -0
  146. /package/esm/typings/{execution → src/execution}/utils/addUsage.d.ts +0 -0
  147. /package/esm/typings/{execution → src/execution}/utils/addUsage.test.d.ts +0 -0
  148. /package/esm/typings/{execution → src/execution}/utils/checkExpectations.d.ts +0 -0
  149. /package/esm/typings/{execution → src/execution}/utils/checkExpectations.test.d.ts +0 -0
  150. /package/esm/typings/{execution → src/execution}/utils/computeUsageCounts.d.ts +0 -0
  151. /package/esm/typings/{execution → src/execution}/utils/forEachAsync.d.ts +0 -0
  152. /package/esm/typings/{execution → src/execution}/utils/replaceParameters.d.ts +0 -0
  153. /package/esm/typings/{execution → src/execution}/utils/replaceParameters.test.d.ts +0 -0
  154. /package/esm/typings/{execution → src/execution}/utils/uncertainNumber.d.ts +0 -0
  155. /package/esm/typings/{execution → src/execution}/utils/usageToWorktime.d.ts +0 -0
  156. /package/esm/typings/{execution → src/execution}/utils/usageToWorktime.test.d.ts +0 -0
  157. /package/esm/typings/{expectations → src/expectations}/drafts/isDomainNameFree.d.ts +0 -0
  158. /package/esm/typings/{expectations → src/expectations}/drafts/isGithubNameFree.d.ts +0 -0
  159. /package/esm/typings/{formats → src/formats}/_common/FormatDefinition.d.ts +0 -0
  160. /package/esm/typings/{formats → src/formats}/csv/ListFormatDefinition.d.ts +0 -0
  161. /package/esm/typings/{formats → src/formats}/index.d.ts +0 -0
  162. /package/esm/typings/{formats → src/formats}/json/JsonFormatDefinition.d.ts +0 -0
  163. /package/esm/typings/{formats → src/formats}/json/utils/isValidJsonString.d.ts +0 -0
  164. /package/esm/typings/{formats → src/formats}/json/utils/isValidJsonString.test.d.ts +0 -0
  165. /package/esm/typings/{formats → src/formats}/list/ListFormatDefinition.d.ts +0 -0
  166. /package/esm/typings/{formats → src/formats}/xml/XmlFormatDefinition.d.ts +0 -0
  167. /package/esm/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceTools.d.ts +0 -0
  168. /package/esm/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +0 -0
  169. /package/esm/typings/{knowledge → src/knowledge}/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +0 -0
  170. /package/esm/typings/{knowledge → src/knowledge}/dialogs/user-interface-execution-tools.test.d.ts +0 -0
  171. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -0
  172. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +0 -0
  173. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -0
  174. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +0 -0
  175. /package/esm/typings/{promptbook-library → src/library}/PromptbookLibrary.d.ts +0 -0
  176. /package/esm/typings/{llm-providers/mocked/fakeTextToExpectations.test.d.ts → src/library/constructors/createLibraryFromDirectory.test.d.ts} +0 -0
  177. /package/esm/typings/{llm-providers/mocked/faked-completion.test.d.ts → src/library/constructors/createLibraryFromJson.test.d.ts} +0 -0
  178. /package/esm/typings/{llm-providers/openai/computeUsage.test.d.ts → src/library/constructors/createLibraryFromPromise.test.d.ts} +0 -0
  179. /package/esm/typings/{promptbook-library → src/library}/constructors/justTestFsImport.d.ts +0 -0
  180. /package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → src/library/libraryToJson.test.d.ts} +0 -0
  181. /package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +0 -0
  182. /package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  183. /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -0
  184. /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +0 -0
  185. /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  186. /package/esm/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionTools.d.ts +0 -0
  187. /package/esm/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  188. /package/esm/typings/{llm-providers → src/llm-providers}/langtail/playground/playground.d.ts +0 -0
  189. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +0 -0
  190. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +0 -0
  191. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/fakeTextToExpectations.d.ts +0 -0
  192. /package/{umd/typings → esm/typings/src}/llm-providers/mocked/fakeTextToExpectations.test.d.ts +0 -0
  193. /package/{umd/typings → esm/typings/src}/llm-providers/mocked/faked-completion.test.d.ts +0 -0
  194. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/joker.test.d.ts +0 -0
  195. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  196. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  197. /package/esm/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +0 -0
  198. /package/esm/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -0
  199. /package/esm/typings/{llm-providers → src/llm-providers}/multiple/playground/playground.d.ts +0 -0
  200. /package/esm/typings/{llm-providers → src/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
  201. /package/esm/typings/{llm-providers → src/llm-providers}/openai/computeUsage.d.ts +0 -0
  202. /package/{umd/typings → esm/typings/src}/llm-providers/openai/computeUsage.test.d.ts +0 -0
  203. /package/esm/typings/{llm-providers → src/llm-providers}/openai/openai-models.d.ts +0 -0
  204. /package/esm/typings/{llm-providers → src/llm-providers}/openai/playground/playground.d.ts +0 -0
  205. /package/esm/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionTools.d.ts +0 -0
  206. /package/esm/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +0 -0
  207. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  208. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
  209. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
  210. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
  211. /package/esm/typings/{scripting → src/scripting}/_test/custom-function-async.test.ts.test.d.ts +0 -0
  212. /package/esm/typings/{scripting → src/scripting}/_test/custom-function-missing.test.d.ts +0 -0
  213. /package/esm/typings/{scripting → src/scripting}/_test/custom-function-with-dependencies.test.d.ts +0 -0
  214. /package/esm/typings/{scripting → src/scripting}/_test/custom-function.test.d.ts +0 -0
  215. /package/esm/typings/{scripting → src/scripting}/_test/postprocessing.test.d.ts +0 -0
  216. /package/esm/typings/{scripting → src/scripting}/_test/script-execution-errors.test.d.ts +0 -0
  217. /package/esm/typings/{scripting → src/scripting}/_test/script-execution-tools.test.d.ts +0 -0
  218. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.d.ts +0 -0
  219. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  220. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  221. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +0 -0
  222. /package/esm/typings/{scripting → src/scripting}/javascript/utils/preserve.d.ts +0 -0
  223. /package/esm/typings/{scripting → src/scripting}/javascript/utils/unknownToString.d.ts +0 -0
  224. /package/esm/typings/{scripting → src/scripting}/python/PythonExecutionTools.d.ts +0 -0
  225. /package/esm/typings/{scripting → src/scripting}/typescript/TypescriptExecutionTools.d.ts +0 -0
  226. /package/esm/typings/{types → src/types}/Command.d.ts +0 -0
  227. /package/esm/typings/{types → src/types}/ExecutionTypes.d.ts +0 -0
  228. /package/esm/typings/{types → src/types}/Parameters.d.ts +0 -0
  229. /package/esm/typings/{types → src/types}/Prompt.d.ts +0 -0
  230. /package/esm/typings/{types → src/types}/PromptbookJson/PromptTemplateJson.d.ts +0 -0
  231. /package/esm/typings/{types → src/types}/PromptbookJson/PromptTemplateParameterJson.d.ts +0 -0
  232. /package/esm/typings/{types → src/types}/PromptbookJson/PromptbookJson.d.ts +0 -0
  233. /package/esm/typings/{types → src/types}/PromptbookString.d.ts +0 -0
  234. /package/esm/typings/{types → src/types}/ScriptLanguage.d.ts +0 -0
  235. /package/esm/typings/{types → src/types}/TaskProgress.d.ts +0 -0
  236. /package/esm/typings/{types → src/types}/execution-report/ExecutionReportJson.d.ts +0 -0
  237. /package/esm/typings/{types → src/types}/execution-report/ExecutionReportString.d.ts +0 -0
  238. /package/esm/typings/{types → src/types}/execution-report/ExecutionReportStringOptions.d.ts +0 -0
  239. /package/esm/typings/{types → src/types}/execution-report/config.d.ts +0 -0
  240. /package/esm/typings/{types → src/types}/execution-report/countWorkingDuration.d.ts +0 -0
  241. /package/esm/typings/{types → src/types}/execution-report/countWorkingDuration.test.d.ts +0 -0
  242. /package/esm/typings/{types → src/types}/execution-report/executionReportJsonToString.d.ts +0 -0
  243. /package/esm/typings/{types → src/types}/typeAliasEmoji.d.ts +0 -0
  244. /package/esm/typings/{types → src/types}/typeAliases.d.ts +0 -0
  245. /package/esm/typings/{utils → src/utils}/FromtoItems.d.ts +0 -0
  246. /package/esm/typings/{utils → src/utils}/emojis.d.ts +0 -0
  247. /package/esm/typings/{utils → src/utils}/expectation-counters/countCharacters.d.ts +0 -0
  248. /package/esm/typings/{utils → src/utils}/expectation-counters/countCharacters.test.d.ts +0 -0
  249. /package/esm/typings/{utils → src/utils}/expectation-counters/countLines.d.ts +0 -0
  250. /package/esm/typings/{utils → src/utils}/expectation-counters/countLines.test.d.ts +0 -0
  251. /package/esm/typings/{utils → src/utils}/expectation-counters/countPages.d.ts +0 -0
  252. /package/esm/typings/{utils → src/utils}/expectation-counters/countPages.test.d.ts +0 -0
  253. /package/esm/typings/{utils → src/utils}/expectation-counters/countParagraphs.d.ts +0 -0
  254. /package/esm/typings/{utils → src/utils}/expectation-counters/countParagraphs.test.d.ts +0 -0
  255. /package/esm/typings/{utils → src/utils}/expectation-counters/countSentences.d.ts +0 -0
  256. /package/esm/typings/{utils → src/utils}/expectation-counters/countSentences.test.d.ts +0 -0
  257. /package/esm/typings/{utils → src/utils}/expectation-counters/countWords.d.ts +0 -0
  258. /package/esm/typings/{utils → src/utils}/expectation-counters/countWords.test.d.ts +0 -0
  259. /package/esm/typings/{utils → src/utils}/expectation-counters/index.d.ts +0 -0
  260. /package/esm/typings/{utils → src/utils}/extractParameters.d.ts +0 -0
  261. /package/esm/typings/{utils → src/utils}/extractParameters.test.d.ts +0 -0
  262. /package/esm/typings/{utils → src/utils}/formatNumber.d.ts +0 -0
  263. /package/esm/typings/{utils → src/utils}/formatNumber.test.d.ts +0 -0
  264. /package/esm/typings/{utils → src/utils}/getCurrentIsoDate.d.ts +0 -0
  265. /package/esm/typings/{utils → src/utils}/isRunningInWhatever.d.ts +0 -0
  266. /package/esm/typings/{utils → src/utils}/just.d.ts +0 -0
  267. /package/esm/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.d.ts +0 -0
  268. /package/esm/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.test.d.ts +0 -0
  269. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownChart.d.ts +0 -0
  270. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownChart.test.d.ts +0 -0
  271. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownTable.d.ts +0 -0
  272. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownTable.test.d.ts +0 -0
  273. /package/esm/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.d.ts +0 -0
  274. /package/esm/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.test.d.ts +0 -0
  275. /package/esm/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.d.ts +0 -0
  276. /package/esm/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.test.d.ts +0 -0
  277. /package/esm/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.d.ts +0 -0
  278. /package/esm/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.test.d.ts +0 -0
  279. /package/esm/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.d.ts +0 -0
  280. /package/esm/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.test.d.ts +0 -0
  281. /package/esm/typings/{utils → src/utils}/markdown/prettifyMarkdown.d.ts +0 -0
  282. /package/esm/typings/{utils → src/utils}/markdown/prettifyMarkdown.test.d.ts +0 -0
  283. /package/esm/typings/{utils → src/utils}/markdown/removeContentComments.d.ts +0 -0
  284. /package/esm/typings/{utils → src/utils}/markdown/removeContentComments.test.d.ts +0 -0
  285. /package/esm/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.d.ts +0 -0
  286. /package/esm/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.test.d.ts +0 -0
  287. /package/esm/typings/{utils → src/utils}/markdown-json/MarkdownStructure.d.ts +0 -0
  288. /package/esm/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.d.ts +0 -0
  289. /package/esm/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.test.d.ts +0 -0
  290. /package/esm/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.d.ts +0 -0
  291. /package/esm/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.test.d.ts +0 -0
  292. /package/esm/typings/{utils → src/utils}/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +0 -0
  293. /package/esm/typings/{utils → src/utils}/normalization/IKeywords.d.ts +0 -0
  294. /package/esm/typings/{utils → src/utils}/normalization/capitalize.d.ts +0 -0
  295. /package/esm/typings/{utils → src/utils}/normalization/capitalize.test.d.ts +0 -0
  296. /package/esm/typings/{utils → src/utils}/normalization/decapitalize.d.ts +0 -0
  297. /package/esm/typings/{utils → src/utils}/normalization/decapitalize.test.d.ts +0 -0
  298. /package/esm/typings/{utils → src/utils}/normalization/isValidKeyword.d.ts +0 -0
  299. /package/esm/typings/{utils → src/utils}/normalization/isValidKeyword.test.d.ts +0 -0
  300. /package/esm/typings/{utils → src/utils}/normalization/nameToUriPart.d.ts +0 -0
  301. /package/esm/typings/{utils → src/utils}/normalization/nameToUriPart.test.d.ts +0 -0
  302. /package/esm/typings/{utils → src/utils}/normalization/nameToUriParts.d.ts +0 -0
  303. /package/esm/typings/{utils → src/utils}/normalization/nameToUriParts.test.d.ts +0 -0
  304. /package/esm/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.d.ts +0 -0
  305. /package/esm/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.test.d.ts +0 -0
  306. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.d.ts +0 -0
  307. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.test.d.ts +0 -0
  308. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.d.ts +0 -0
  309. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +0 -0
  310. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.d.ts +0 -0
  311. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.test.d.ts +0 -0
  312. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.d.ts +0 -0
  313. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.test.d.ts +0 -0
  314. /package/esm/typings/{utils → src/utils}/normalization/normalizeWhitespaces.d.ts +0 -0
  315. /package/esm/typings/{utils → src/utils}/normalization/normalizeWhitespaces.test.d.ts +0 -0
  316. /package/esm/typings/{utils → src/utils}/normalization/parseKeywords.d.ts +0 -0
  317. /package/esm/typings/{utils → src/utils}/normalization/parseKeywords.test.d.ts +0 -0
  318. /package/esm/typings/{utils → src/utils}/normalization/parseKeywordsFromString.d.ts +0 -0
  319. /package/esm/typings/{utils → src/utils}/normalization/parseKeywordsFromString.test.d.ts +0 -0
  320. /package/esm/typings/{utils → src/utils}/normalization/removeDiacritics.d.ts +0 -0
  321. /package/esm/typings/{utils → src/utils}/normalization/removeDiacritics.test.d.ts +0 -0
  322. /package/esm/typings/{utils → src/utils}/normalization/searchKeywords.d.ts +0 -0
  323. /package/esm/typings/{utils → src/utils}/normalization/searchKeywords.test.d.ts +0 -0
  324. /package/esm/typings/{utils → src/utils}/postprocessing/extractBlock.d.ts +0 -0
  325. /package/esm/typings/{utils → src/utils}/removeEmojis.d.ts +0 -0
  326. /package/esm/typings/{utils → src/utils}/removeEmojis.test.d.ts +0 -0
  327. /package/esm/typings/{utils → src/utils}/removeQuotes.d.ts +0 -0
  328. /package/esm/typings/{utils → src/utils}/removeQuotes.test.d.ts +0 -0
  329. /package/esm/typings/{utils → src/utils}/sets/difference.d.ts +0 -0
  330. /package/esm/typings/{utils → src/utils}/sets/difference.test.d.ts +0 -0
  331. /package/esm/typings/{utils → src/utils}/sets/intersection.d.ts +0 -0
  332. /package/esm/typings/{utils → src/utils}/sets/intersection.test.d.ts +0 -0
  333. /package/esm/typings/{utils → src/utils}/sets/union.d.ts +0 -0
  334. /package/esm/typings/{utils → src/utils}/sets/union.test.d.ts +0 -0
  335. /package/esm/typings/{utils → src/utils}/trimCodeBlock.d.ts +0 -0
  336. /package/esm/typings/{utils → src/utils}/trimCodeBlock.test.d.ts +0 -0
  337. /package/esm/typings/{utils → src/utils}/trimEndOfCodeBlock.d.ts +0 -0
  338. /package/esm/typings/{utils → src/utils}/trimEndOfCodeBlock.test.d.ts +0 -0
  339. /package/esm/typings/{utils → src/utils}/unwrapResult.d.ts +0 -0
  340. /package/esm/typings/{utils → src/utils}/unwrapResult.test.d.ts +0 -0
  341. /package/esm/typings/{utils → src/utils}/validators/url/isValidUrl.d.ts +0 -0
  342. /package/esm/typings/{utils → src/utils}/validators/url/isValidUrl.test.d.ts +0 -0
  343. /package/esm/typings/{version.d.ts → src/version.d.ts} +0 -0
  344. /package/umd/typings/{_packages → src/_packages}/anthropic-claude.index.d.ts +0 -0
  345. /package/umd/typings/{_packages → src/_packages}/azure-openai.index.d.ts +0 -0
  346. /package/umd/typings/{_packages → src/_packages}/execute-javascript.index.d.ts +0 -0
  347. /package/umd/typings/{_packages → src/_packages}/fake-llm.index.d.ts +0 -0
  348. /package/umd/typings/{_packages → src/_packages}/langtail.index.d.ts +0 -0
  349. /package/umd/typings/{_packages → src/_packages}/openai.index.d.ts +0 -0
  350. /package/umd/typings/{_packages → src/_packages}/remote-client.index.d.ts +0 -0
  351. /package/umd/typings/{_packages → src/_packages}/remote-server.index.d.ts +0 -0
  352. /package/umd/typings/{_packages → src/_packages}/utils.index.d.ts +0 -0
  353. /package/umd/typings/{conversion → src/conversion}/prettify/PrettifyOptions.d.ts +0 -0
  354. /package/umd/typings/{conversion → src/conversion}/prettify/prettifyPromptbookString.d.ts +0 -0
  355. /package/umd/typings/{conversion → src/conversion}/prettify/renderPromptbookMermaid.d.ts +0 -0
  356. /package/umd/typings/{conversion → src/conversion}/promptbookJsonToString.d.ts +0 -0
  357. /package/umd/typings/{conversion → src/conversion}/promptbookStringToJson.test.d.ts +0 -0
  358. /package/{esm/typings/promptbook-library/constructors/createPromptbookLibraryFromPromise.test.d.ts → umd/typings/src/conversion/promptbookStringToJsonSync.test.d.ts} +0 -0
  359. /package/umd/typings/{conversion → src/conversion}/utils/extractParametersFromPromptTemplate.d.ts +0 -0
  360. /package/{esm/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.test.d.ts → umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts} +0 -0
  361. /package/umd/typings/{conversion → src/conversion}/utils/extractVariables.d.ts +0 -0
  362. /package/umd/typings/{conversion → src/conversion}/utils/extractVariables.test.d.ts +0 -0
  363. /package/umd/typings/{conversion → src/conversion}/utils/parseCommand.d.ts +0 -0
  364. /package/umd/typings/{conversion → src/conversion}/utils/parseCommand.test.d.ts +0 -0
  365. /package/umd/typings/{conversion → src/conversion}/utils/parseNumber.d.ts +0 -0
  366. /package/umd/typings/{conversion → src/conversion}/utils/parseNumber.test.d.ts +0 -0
  367. /package/umd/typings/{conversion → src/conversion}/utils/renameParameter.d.ts +0 -0
  368. /package/umd/typings/{conversion → src/conversion}/utils/renameParameter.test.d.ts +0 -0
  369. /package/umd/typings/{conversion → src/conversion}/utils/titleToName.d.ts +0 -0
  370. /package/umd/typings/{conversion → src/conversion}/utils/titleToName.test.d.ts +0 -0
  371. /package/umd/typings/{conversion → src/conversion}/validation/_importPromptbook.d.ts +0 -0
  372. /package/umd/typings/{conversion → src/conversion}/validation/promptbookStringToJson-syntaxErrors.test.d.ts +0 -0
  373. /package/umd/typings/{conversion/validation/validatePromptbookJson-logicErrors.test.d.ts → src/conversion/validation/validatePromptbook-logicErrors.test.d.ts} +0 -0
  374. /package/umd/typings/{conversion/validation/validatePromptbookJson.test.d.ts → src/conversion/validation/validatePromptbook.test.d.ts} +0 -0
  375. /package/umd/typings/{errors → src/errors}/PromptbookExecutionError.d.ts +0 -0
  376. /package/umd/typings/{errors → src/errors}/PromptbookLibraryError.d.ts +0 -0
  377. /package/umd/typings/{errors → src/errors}/PromptbookLogicError.d.ts +0 -0
  378. /package/umd/typings/{errors → src/errors}/PromptbookNotFoundError.d.ts +0 -0
  379. /package/umd/typings/{errors → src/errors}/PromptbookReferenceError.d.ts +0 -0
  380. /package/umd/typings/{errors → src/errors}/PromptbookSyntaxError.d.ts +0 -0
  381. /package/umd/typings/{errors → src/errors}/TemplateError.d.ts +0 -0
  382. /package/umd/typings/{errors → src/errors}/UnexpectedError.d.ts +0 -0
  383. /package/umd/typings/{errors → src/errors}/_ExpectError.d.ts +0 -0
  384. /package/umd/typings/{execution → src/execution}/CommonExecutionToolsOptions.d.ts +0 -0
  385. /package/umd/typings/{execution → src/execution}/ExecutionTools.d.ts +0 -0
  386. /package/umd/typings/{execution → src/execution}/PromptbookExecutor.d.ts +0 -0
  387. /package/umd/typings/{execution → src/execution}/ScriptExecutionTools.d.ts +0 -0
  388. /package/umd/typings/{execution → src/execution}/UserInterfaceTools.d.ts +0 -0
  389. /package/umd/typings/{execution → src/execution}/addPromptResultUsage.test.d.ts +0 -0
  390. /package/umd/typings/{execution → src/execution}/assertsExecutionSuccessful.d.ts +0 -0
  391. /package/umd/typings/{execution → src/execution}/createPromptbookExecutor.d.ts +0 -0
  392. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +0 -0
  393. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +0 -0
  394. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +0 -0
  395. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +0 -0
  396. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +0 -0
  397. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +0 -0
  398. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +0 -0
  399. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/translateMessages.d.ts +0 -0
  400. /package/umd/typings/{execution → src/execution}/utils/addUsage.d.ts +0 -0
  401. /package/umd/typings/{execution → src/execution}/utils/addUsage.test.d.ts +0 -0
  402. /package/umd/typings/{execution → src/execution}/utils/checkExpectations.d.ts +0 -0
  403. /package/umd/typings/{execution → src/execution}/utils/checkExpectations.test.d.ts +0 -0
  404. /package/umd/typings/{execution → src/execution}/utils/computeUsageCounts.d.ts +0 -0
  405. /package/umd/typings/{execution → src/execution}/utils/forEachAsync.d.ts +0 -0
  406. /package/umd/typings/{execution → src/execution}/utils/replaceParameters.d.ts +0 -0
  407. /package/umd/typings/{execution → src/execution}/utils/replaceParameters.test.d.ts +0 -0
  408. /package/umd/typings/{execution → src/execution}/utils/uncertainNumber.d.ts +0 -0
  409. /package/umd/typings/{execution → src/execution}/utils/usageToWorktime.d.ts +0 -0
  410. /package/umd/typings/{execution → src/execution}/utils/usageToWorktime.test.d.ts +0 -0
  411. /package/umd/typings/{expectations → src/expectations}/drafts/isDomainNameFree.d.ts +0 -0
  412. /package/umd/typings/{expectations → src/expectations}/drafts/isGithubNameFree.d.ts +0 -0
  413. /package/umd/typings/{formats → src/formats}/_common/FormatDefinition.d.ts +0 -0
  414. /package/umd/typings/{formats → src/formats}/csv/ListFormatDefinition.d.ts +0 -0
  415. /package/umd/typings/{formats → src/formats}/index.d.ts +0 -0
  416. /package/umd/typings/{formats → src/formats}/json/JsonFormatDefinition.d.ts +0 -0
  417. /package/umd/typings/{formats → src/formats}/json/utils/isValidJsonString.d.ts +0 -0
  418. /package/umd/typings/{formats → src/formats}/json/utils/isValidJsonString.test.d.ts +0 -0
  419. /package/umd/typings/{formats → src/formats}/list/ListFormatDefinition.d.ts +0 -0
  420. /package/umd/typings/{formats → src/formats}/xml/XmlFormatDefinition.d.ts +0 -0
  421. /package/umd/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceTools.d.ts +0 -0
  422. /package/umd/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +0 -0
  423. /package/umd/typings/{knowledge → src/knowledge}/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +0 -0
  424. /package/umd/typings/{knowledge → src/knowledge}/dialogs/user-interface-execution-tools.test.d.ts +0 -0
  425. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -0
  426. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +0 -0
  427. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -0
  428. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +0 -0
  429. /package/umd/typings/{promptbook-library → src/library}/PromptbookLibrary.d.ts +0 -0
  430. /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → src/library/constructors/createLibraryFromDirectory.test.d.ts} +0 -0
  431. /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.test.d.ts → src/library/constructors/createLibraryFromJson.test.d.ts} +0 -0
  432. /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromSources.test.d.ts → src/library/constructors/createLibraryFromPromise.test.d.ts} +0 -0
  433. /package/umd/typings/{promptbook-library → src/library}/constructors/justTestFsImport.d.ts +0 -0
  434. /package/umd/typings/{scripting/_test/custom-function-async.test.ts.test.d.ts → src/library/libraryToJson.test.d.ts} +0 -0
  435. /package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +0 -0
  436. /package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  437. /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -0
  438. /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +0 -0
  439. /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  440. /package/umd/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionTools.d.ts +0 -0
  441. /package/umd/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  442. /package/umd/typings/{llm-providers → src/llm-providers}/langtail/playground/playground.d.ts +0 -0
  443. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +0 -0
  444. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +0 -0
  445. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/fakeTextToExpectations.d.ts +0 -0
  446. /package/umd/typings/{scripting/_test/custom-function-missing.test.d.ts → src/llm-providers/mocked/fakeTextToExpectations.test.d.ts} +0 -0
  447. /package/umd/typings/{scripting/_test/custom-function-with-dependencies.test.d.ts → src/llm-providers/mocked/faked-completion.test.d.ts} +0 -0
  448. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/joker.test.d.ts +0 -0
  449. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  450. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  451. /package/umd/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +0 -0
  452. /package/umd/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -0
  453. /package/umd/typings/{llm-providers → src/llm-providers}/multiple/playground/playground.d.ts +0 -0
  454. /package/umd/typings/{llm-providers → src/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
  455. /package/umd/typings/{llm-providers → src/llm-providers}/openai/computeUsage.d.ts +0 -0
  456. /package/umd/typings/{scripting/_test/custom-function.test.d.ts → src/llm-providers/openai/computeUsage.test.d.ts} +0 -0
  457. /package/umd/typings/{llm-providers → src/llm-providers}/openai/openai-models.d.ts +0 -0
  458. /package/umd/typings/{llm-providers → src/llm-providers}/openai/playground/playground.d.ts +0 -0
  459. /package/umd/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionTools.d.ts +0 -0
  460. /package/umd/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +0 -0
  461. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  462. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
  463. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
  464. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
  465. /package/umd/typings/{scripting/_test/postprocessing.test.d.ts → src/scripting/_test/custom-function-async.test.ts.test.d.ts} +0 -0
  466. /package/umd/typings/{scripting/_test/script-execution-errors.test.d.ts → src/scripting/_test/custom-function-missing.test.d.ts} +0 -0
  467. /package/umd/typings/{scripting/_test/script-execution-tools.test.d.ts → src/scripting/_test/custom-function-with-dependencies.test.d.ts} +0 -0
  468. /package/umd/typings/{types/execution-report/countWorkingDuration.test.d.ts → src/scripting/_test/custom-function.test.d.ts} +0 -0
  469. /package/umd/typings/{utils/expectation-counters/countCharacters.test.d.ts → src/scripting/_test/postprocessing.test.d.ts} +0 -0
  470. /package/umd/typings/{utils/expectation-counters/countLines.test.d.ts → src/scripting/_test/script-execution-errors.test.d.ts} +0 -0
  471. /package/umd/typings/{utils/expectation-counters/countPages.test.d.ts → src/scripting/_test/script-execution-tools.test.d.ts} +0 -0
  472. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.d.ts +0 -0
  473. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  474. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  475. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +0 -0
  476. /package/umd/typings/{scripting → src/scripting}/javascript/utils/preserve.d.ts +0 -0
  477. /package/umd/typings/{scripting → src/scripting}/javascript/utils/unknownToString.d.ts +0 -0
  478. /package/umd/typings/{scripting → src/scripting}/python/PythonExecutionTools.d.ts +0 -0
  479. /package/umd/typings/{scripting → src/scripting}/typescript/TypescriptExecutionTools.d.ts +0 -0
  480. /package/umd/typings/{types → src/types}/Command.d.ts +0 -0
  481. /package/umd/typings/{types → src/types}/ExecutionTypes.d.ts +0 -0
  482. /package/umd/typings/{types → src/types}/Parameters.d.ts +0 -0
  483. /package/umd/typings/{types → src/types}/Prompt.d.ts +0 -0
  484. /package/umd/typings/{types → src/types}/PromptbookJson/PromptTemplateJson.d.ts +0 -0
  485. /package/umd/typings/{types → src/types}/PromptbookJson/PromptTemplateParameterJson.d.ts +0 -0
  486. /package/umd/typings/{types → src/types}/PromptbookJson/PromptbookJson.d.ts +0 -0
  487. /package/umd/typings/{types → src/types}/PromptbookString.d.ts +0 -0
  488. /package/umd/typings/{types → src/types}/ScriptLanguage.d.ts +0 -0
  489. /package/umd/typings/{types → src/types}/TaskProgress.d.ts +0 -0
  490. /package/umd/typings/{types → src/types}/execution-report/ExecutionReportJson.d.ts +0 -0
  491. /package/umd/typings/{types → src/types}/execution-report/ExecutionReportString.d.ts +0 -0
  492. /package/umd/typings/{types → src/types}/execution-report/ExecutionReportStringOptions.d.ts +0 -0
  493. /package/umd/typings/{types → src/types}/execution-report/config.d.ts +0 -0
  494. /package/umd/typings/{types → src/types}/execution-report/countWorkingDuration.d.ts +0 -0
  495. /package/umd/typings/{utils/expectation-counters/countParagraphs.test.d.ts → src/types/execution-report/countWorkingDuration.test.d.ts} +0 -0
  496. /package/umd/typings/{types → src/types}/execution-report/executionReportJsonToString.d.ts +0 -0
  497. /package/umd/typings/{types → src/types}/typeAliasEmoji.d.ts +0 -0
  498. /package/umd/typings/{types → src/types}/typeAliases.d.ts +0 -0
  499. /package/umd/typings/{utils → src/utils}/FromtoItems.d.ts +0 -0
  500. /package/umd/typings/{utils → src/utils}/emojis.d.ts +0 -0
  501. /package/umd/typings/{utils → src/utils}/expectation-counters/countCharacters.d.ts +0 -0
  502. /package/umd/typings/{utils/expectation-counters/countSentences.test.d.ts → src/utils/expectation-counters/countCharacters.test.d.ts} +0 -0
  503. /package/umd/typings/{utils → src/utils}/expectation-counters/countLines.d.ts +0 -0
  504. /package/umd/typings/{utils/expectation-counters/countWords.test.d.ts → src/utils/expectation-counters/countLines.test.d.ts} +0 -0
  505. /package/umd/typings/{utils → src/utils}/expectation-counters/countPages.d.ts +0 -0
  506. /package/umd/typings/{utils/extractParameters.test.d.ts → src/utils/expectation-counters/countPages.test.d.ts} +0 -0
  507. /package/umd/typings/{utils → src/utils}/expectation-counters/countParagraphs.d.ts +0 -0
  508. /package/umd/typings/{utils/formatNumber.test.d.ts → src/utils/expectation-counters/countParagraphs.test.d.ts} +0 -0
  509. /package/umd/typings/{utils → src/utils}/expectation-counters/countSentences.d.ts +0 -0
  510. /package/umd/typings/{utils/markdown-json/countMarkdownStructureDeepness.test.d.ts → src/utils/expectation-counters/countSentences.test.d.ts} +0 -0
  511. /package/umd/typings/{utils → src/utils}/expectation-counters/countWords.d.ts +0 -0
  512. /package/umd/typings/{utils/markdown-json/markdownToMarkdownStructure.test.d.ts → src/utils/expectation-counters/countWords.test.d.ts} +0 -0
  513. /package/umd/typings/{utils → src/utils}/expectation-counters/index.d.ts +0 -0
  514. /package/umd/typings/{utils → src/utils}/extractParameters.d.ts +0 -0
  515. /package/umd/typings/{utils/markdown/addAutoGeneratedSection.test.d.ts → src/utils/extractParameters.test.d.ts} +0 -0
  516. /package/umd/typings/{utils → src/utils}/formatNumber.d.ts +0 -0
  517. /package/umd/typings/{utils/markdown/createMarkdownChart.test.d.ts → src/utils/formatNumber.test.d.ts} +0 -0
  518. /package/umd/typings/{utils → src/utils}/getCurrentIsoDate.d.ts +0 -0
  519. /package/umd/typings/{utils → src/utils}/isRunningInWhatever.d.ts +0 -0
  520. /package/umd/typings/{utils → src/utils}/just.d.ts +0 -0
  521. /package/umd/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.d.ts +0 -0
  522. /package/umd/typings/{utils/markdown/extractAllBlocksFromMarkdown.test.d.ts → src/utils/markdown/addAutoGeneratedSection.test.d.ts} +0 -0
  523. /package/umd/typings/{utils → src/utils}/markdown/createMarkdownChart.d.ts +0 -0
  524. /package/umd/typings/{utils/markdown/extractAllListItemsFromMarkdown.test.d.ts → src/utils/markdown/createMarkdownChart.test.d.ts} +0 -0
  525. /package/umd/typings/{utils → src/utils}/markdown/createMarkdownTable.d.ts +0 -0
  526. /package/umd/typings/{utils/markdown/extractOneBlockFromMarkdown.test.d.ts → src/utils/markdown/createMarkdownTable.test.d.ts} +0 -0
  527. /package/umd/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.d.ts +0 -0
  528. /package/umd/typings/{utils/markdown/prettifyMarkdown.test.d.ts → src/utils/markdown/escapeMarkdownBlock.test.d.ts} +0 -0
  529. /package/umd/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.d.ts +0 -0
  530. /package/umd/typings/{utils/markdown/removeContentComments.test.d.ts → src/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts} +0 -0
  531. /package/umd/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.d.ts +0 -0
  532. /package/umd/typings/{utils/markdown/removeMarkdownFormatting.test.d.ts → src/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts} +0 -0
  533. /package/umd/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.d.ts +0 -0
  534. /package/umd/typings/{utils/normalization/capitalize.test.d.ts → src/utils/markdown/extractOneBlockFromMarkdown.test.d.ts} +0 -0
  535. /package/umd/typings/{utils → src/utils}/markdown/prettifyMarkdown.d.ts +0 -0
  536. /package/umd/typings/{utils/normalization/decapitalize.test.d.ts → src/utils/markdown/prettifyMarkdown.test.d.ts} +0 -0
  537. /package/umd/typings/{utils → src/utils}/markdown/removeContentComments.d.ts +0 -0
  538. /package/umd/typings/{utils/normalization/isValidKeyword.test.d.ts → src/utils/markdown/removeContentComments.test.d.ts} +0 -0
  539. /package/umd/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.d.ts +0 -0
  540. /package/umd/typings/{utils/normalization/nameToUriPart.test.d.ts → src/utils/markdown/removeMarkdownFormatting.test.d.ts} +0 -0
  541. /package/umd/typings/{utils → src/utils}/markdown-json/MarkdownStructure.d.ts +0 -0
  542. /package/umd/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.d.ts +0 -0
  543. /package/umd/typings/{utils/markdown/createMarkdownTable.test.d.ts → src/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts} +0 -0
  544. /package/umd/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.d.ts +0 -0
  545. /package/umd/typings/{utils/markdown/escapeMarkdownBlock.test.d.ts → src/utils/markdown-json/markdownToMarkdownStructure.test.d.ts} +0 -0
  546. /package/umd/typings/{utils → src/utils}/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +0 -0
  547. /package/umd/typings/{utils → src/utils}/normalization/IKeywords.d.ts +0 -0
  548. /package/umd/typings/{utils → src/utils}/normalization/capitalize.d.ts +0 -0
  549. /package/umd/typings/{utils/normalization/nameToUriParts.test.d.ts → src/utils/normalization/capitalize.test.d.ts} +0 -0
  550. /package/umd/typings/{utils → src/utils}/normalization/decapitalize.d.ts +0 -0
  551. /package/umd/typings/{utils/normalization/normalize-to-kebab-case.test.d.ts → src/utils/normalization/decapitalize.test.d.ts} +0 -0
  552. /package/umd/typings/{utils → src/utils}/normalization/isValidKeyword.d.ts +0 -0
  553. /package/umd/typings/{utils/normalization/normalizeTo_PascalCase.test.d.ts → src/utils/normalization/isValidKeyword.test.d.ts} +0 -0
  554. /package/umd/typings/{utils → src/utils}/normalization/nameToUriPart.d.ts +0 -0
  555. /package/umd/typings/{utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts → src/utils/normalization/nameToUriPart.test.d.ts} +0 -0
  556. /package/umd/typings/{utils → src/utils}/normalization/nameToUriParts.d.ts +0 -0
  557. /package/umd/typings/{utils/normalization/normalizeTo_camelCase.test.d.ts → src/utils/normalization/nameToUriParts.test.d.ts} +0 -0
  558. /package/umd/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.d.ts +0 -0
  559. /package/umd/typings/{utils/normalization/normalizeTo_snake_case.test.d.ts → src/utils/normalization/normalize-to-kebab-case.test.d.ts} +0 -0
  560. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.d.ts +0 -0
  561. /package/umd/typings/{utils/normalization/normalizeWhitespaces.test.d.ts → src/utils/normalization/normalizeTo_PascalCase.test.d.ts} +0 -0
  562. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.d.ts +0 -0
  563. /package/umd/typings/{utils/normalization/parseKeywords.test.d.ts → src/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts} +0 -0
  564. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.d.ts +0 -0
  565. /package/umd/typings/{utils/normalization/parseKeywordsFromString.test.d.ts → src/utils/normalization/normalizeTo_camelCase.test.d.ts} +0 -0
  566. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.d.ts +0 -0
  567. /package/umd/typings/{utils/normalization/removeDiacritics.test.d.ts → src/utils/normalization/normalizeTo_snake_case.test.d.ts} +0 -0
  568. /package/umd/typings/{utils → src/utils}/normalization/normalizeWhitespaces.d.ts +0 -0
  569. /package/umd/typings/{utils/normalization/searchKeywords.test.d.ts → src/utils/normalization/normalizeWhitespaces.test.d.ts} +0 -0
  570. /package/umd/typings/{utils → src/utils}/normalization/parseKeywords.d.ts +0 -0
  571. /package/umd/typings/{utils/removeEmojis.test.d.ts → src/utils/normalization/parseKeywords.test.d.ts} +0 -0
  572. /package/umd/typings/{utils → src/utils}/normalization/parseKeywordsFromString.d.ts +0 -0
  573. /package/umd/typings/{utils/removeQuotes.test.d.ts → src/utils/normalization/parseKeywordsFromString.test.d.ts} +0 -0
  574. /package/umd/typings/{utils → src/utils}/normalization/removeDiacritics.d.ts +0 -0
  575. /package/umd/typings/{utils/sets/difference.test.d.ts → src/utils/normalization/removeDiacritics.test.d.ts} +0 -0
  576. /package/umd/typings/{utils → src/utils}/normalization/searchKeywords.d.ts +0 -0
  577. /package/umd/typings/{utils/sets/intersection.test.d.ts → src/utils/normalization/searchKeywords.test.d.ts} +0 -0
  578. /package/umd/typings/{utils → src/utils}/postprocessing/extractBlock.d.ts +0 -0
  579. /package/umd/typings/{utils → src/utils}/removeEmojis.d.ts +0 -0
  580. /package/umd/typings/{utils/sets/union.test.d.ts → src/utils/removeEmojis.test.d.ts} +0 -0
  581. /package/umd/typings/{utils → src/utils}/removeQuotes.d.ts +0 -0
  582. /package/umd/typings/{utils/trimCodeBlock.test.d.ts → src/utils/removeQuotes.test.d.ts} +0 -0
  583. /package/umd/typings/{utils → src/utils}/sets/difference.d.ts +0 -0
  584. /package/umd/typings/{utils/trimEndOfCodeBlock.test.d.ts → src/utils/sets/difference.test.d.ts} +0 -0
  585. /package/umd/typings/{utils → src/utils}/sets/intersection.d.ts +0 -0
  586. /package/umd/typings/{utils/unwrapResult.test.d.ts → src/utils/sets/intersection.test.d.ts} +0 -0
  587. /package/umd/typings/{utils → src/utils}/sets/union.d.ts +0 -0
  588. /package/umd/typings/{utils/validators/url/isValidUrl.test.d.ts → src/utils/sets/union.test.d.ts} +0 -0
  589. /package/umd/typings/{utils → src/utils}/trimCodeBlock.d.ts +0 -0
  590. /package/umd/typings/{utils → src/utils}/trimEndOfCodeBlock.d.ts +0 -0
  591. /package/umd/typings/{utils → src/utils}/unwrapResult.d.ts +0 -0
  592. /package/umd/typings/{utils → src/utils}/validators/url/isValidUrl.d.ts +0 -0
  593. /package/umd/typings/{version.d.ts → src/version.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -1,16 +1,16 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('fs/promises'), require('glob-promise'), require('spacetrim'), require('waitasecond'), require('prettier'), require('prettier/parser-html')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'fs/promises', 'glob-promise', 'spacetrim', 'waitasecond', 'prettier', 'prettier/parser-html'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.promises, global.glob, global.spaceTrim, global.waitasecond, global.prettier, global.parserHtml));
5
- })(this, (function (exports, colors, commander, promises, glob, spaceTrim, waitasecond, prettier, parserHtml) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('commander'), require('spacetrim'), require('colors'), require('waitasecond'), require('fs/promises'), require('path'), require('prettier'), require('prettier/parser-html'), require('glob-promise')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'commander', 'spacetrim', 'colors', 'waitasecond', 'fs/promises', 'path', 'prettier', 'prettier/parser-html', 'glob-promise'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.commander, global.spaceTrim, global.colors, global.waitasecond, global.promises, global.path, global.prettier, global.parserHtml, global.glob));
5
+ })(this, (function (exports, commander, spaceTrim, colors, waitasecond, promises, path, prettier, parserHtml, glob) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
10
9
  var commander__default = /*#__PURE__*/_interopDefaultLegacy(commander);
11
- var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
12
10
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
11
+ var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
13
12
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
13
+ var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
14
14
 
15
15
  /*! *****************************************************************************
16
16
  Copyright (c) Microsoft Corporation.
@@ -147,70 +147,60 @@
147
147
  /**
148
148
  * The version of the Promptbook library
149
149
  */
150
- var PROMPTBOOK_VERSION = '0.59.0-7';
150
+ var PROMPTBOOK_VERSION = '0.59.0-36';
151
151
 
152
152
  /**
153
- * Removes HTML or Markdown comments from a string.
153
+ * Initializes testing `hello` command for Promptbook CLI utilities
154
154
  *
155
- * @param {string} content - The string to remove comments from.
156
- * @returns {string} The input string with all comments removed.
155
+ * @private part of `promptbookCli`
157
156
  */
158
- function removeContentComments(content) {
159
- return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
157
+ function initializeHello(program) {
158
+ var _this = this;
159
+ var helloCommand = program.command('hello');
160
+ helloCommand.description(spaceTrim__default["default"]("\n Just command for testing\n "));
161
+ helloCommand.argument('<name>', 'Your name');
162
+ helloCommand.option('-g, --greeting <greeting>', "Greeting", 'Hello');
163
+ helloCommand.action(function (name, _a) {
164
+ var greeting = _a.greeting;
165
+ return __awaiter(_this, void 0, void 0, function () {
166
+ return __generator(this, function (_b) {
167
+ switch (_b.label) {
168
+ case 0:
169
+ console.info(colors__default["default"].cyan("".concat(greeting, " ").concat(name)));
170
+ return [4 /*yield*/, waitasecond.forTime(1000)];
171
+ case 1:
172
+ _b.sent();
173
+ console.info(colors__default["default"].rainbow("Nice to meet you!"));
174
+ process.exit(0);
175
+ return [2 /*return*/];
176
+ }
177
+ });
178
+ });
179
+ });
160
180
  }
161
181
 
162
182
  /**
163
- * Add or modify an auto-generated section in a markdown file
164
- *
165
- * @private within the library
183
+ * The maximum number of iterations for a loops
166
184
  */
167
- function addAutoGeneratedSection(content, options) {
168
- var sectionName = options.sectionName, sectionContent = options.sectionContent;
169
- var warningLine = "<!-- \u26A0\uFE0F WARNING: This section was auto-generated -->";
170
- var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
171
- var sectionMatch = content.match(sectionRegex);
172
- if (sectionMatch) {
173
- return content.replace(sectionRegex, spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
174
- }
175
- var placeForSection = removeContentComments(content).match(/^##.*$/im);
176
- if (!placeForSection) {
177
- throw new Error("No place where to put the section <!--".concat(sectionName, "-->"));
178
- }
179
- var _a = __read(placeForSection, 1), heading = _a[0];
180
- return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
181
- }
185
+ var LOOP_LIMIT = 1000;
186
+ /**
187
+ * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createLibraryFromDirectory`
188
+ */
189
+ var PROMPTBOOK_MAKED_BASE_FILENAME = "index";
182
190
 
183
191
  /**
184
- * Prettify the html code
185
- *
186
- * @param content raw html code
187
- * @returns formatted html code
192
+ * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
188
193
  */
189
- function prettifyMarkdown(content) {
190
- try {
191
- return prettier.format(content, {
192
- parser: 'markdown',
193
- plugins: [parserHtml__default["default"]],
194
- // TODO: DRY - make some import or auto-copy of .prettierrc
195
- endOfLine: 'lf',
196
- tabWidth: 4,
197
- singleQuote: true,
198
- trailingComma: 'all',
199
- arrowParens: 'always',
200
- printWidth: 120,
201
- htmlWhitespaceSensitivity: 'ignore',
202
- jsxBracketSameLine: false,
203
- bracketSpacing: true,
204
- });
205
- }
206
- catch (error) {
207
- console.error('There was an error with prettifying the markdown, using the original as the fallback', {
208
- error: error,
209
- html: content,
210
- });
211
- return content;
194
+ var PromptbookLogicError = /** @class */ (function (_super) {
195
+ __extends(PromptbookLogicError, _super);
196
+ function PromptbookLogicError(message) {
197
+ var _this = _super.call(this, message) || this;
198
+ _this.name = 'PromptbookLogicError';
199
+ Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
200
+ return _this;
212
201
  }
213
- }
202
+ return PromptbookLogicError;
203
+ }(Error));
214
204
 
215
205
  /**
216
206
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -226,64 +216,6 @@
226
216
  return PromptbookSyntaxError;
227
217
  }(Error));
228
218
 
229
- /**
230
- * This error indicates errors during the execution of the promptbook
231
- */
232
- var PromptbookExecutionError = /** @class */ (function (_super) {
233
- __extends(PromptbookExecutionError, _super);
234
- function PromptbookExecutionError(message) {
235
- var _this = _super.call(this, message) || this;
236
- _this.name = 'PromptbookExecutionError';
237
- Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
238
- return _this;
239
- }
240
- return PromptbookExecutionError;
241
- }(Error));
242
-
243
- /**
244
- * Asserts that the execution of a promptnook is successful
245
- *
246
- * @param executionResult - The partial result of the promptnook execution
247
- * @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
248
- */
249
- function assertsExecutionSuccessful(executionResult) {
250
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
251
- if (isSuccessful === true) {
252
- return;
253
- }
254
- if (errors.length === 0) {
255
- throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
256
- }
257
- else if (errors.length === 1) {
258
- throw errors[0];
259
- }
260
- else {
261
- throw new PromptbookExecutionError(spaceTrim.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 "); }));
262
- }
263
- }
264
- /**
265
- * TODO: [🧠] Can this return type be better typed than void
266
- */
267
-
268
- /**
269
- * The maximum number of iterations for a loops
270
- */
271
- var LOOP_LIMIT = 1000;
272
-
273
- /**
274
- * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
275
- */
276
- var PromptbookLogicError = /** @class */ (function (_super) {
277
- __extends(PromptbookLogicError, _super);
278
- function PromptbookLogicError(message) {
279
- var _this = _super.call(this, message) || this;
280
- _this.name = 'PromptbookLogicError';
281
- Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
282
- return _this;
283
- }
284
- return PromptbookLogicError;
285
- }(Error));
286
-
287
219
  /**
288
220
  * This error type indicates that the error should not happen and its last check before crashing with some other error
289
221
  */
@@ -337,7 +269,7 @@
337
269
  * @returns the same promptbook if it is logically valid
338
270
  * @throws {PromptbookLogicError} on logical error in the promptbook
339
271
  */
340
- function validatePromptbookJson(promptbook) {
272
+ function validatePromptbook(promptbook) {
341
273
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
342
274
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
343
275
  if (promptbook.promptbookUrl !== undefined) {
@@ -401,8 +333,7 @@
401
333
  throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
402
334
  }
403
335
  definedParameters.add(template.resultingParameterName);
404
- if (template.executionType === 'PROMPT_TEMPLATE' &&
405
- (template.modelRequirements.modelVariant === undefined)) {
336
+ if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
406
337
  throw new PromptbookLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
407
338
  }
408
339
  if (template.jokers && template.jokers.length > 0) {
@@ -472,7 +403,7 @@
472
403
  var loopLimit = LOOP_LIMIT;
473
404
  var _loop_2 = function () {
474
405
  if (loopLimit-- < 0) {
475
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbookJson`');
406
+ throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
476
407
  }
477
408
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
478
409
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
@@ -507,7 +438,48 @@
507
438
  * > * It checks:
508
439
  * > * - it has a valid structure
509
440
  * > * - ...
510
- * > ex port function validatePromptbookJson(promptbook: unknown): asserts promptbook is PromptbookJson {
441
+ * > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
442
+ */
443
+
444
+ var promptbookLibrary = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.59.0-36",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-36",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
445
+
446
+ /**
447
+ * This error indicates errors during the execution of the promptbook
448
+ */
449
+ var PromptbookExecutionError = /** @class */ (function (_super) {
450
+ __extends(PromptbookExecutionError, _super);
451
+ function PromptbookExecutionError(message) {
452
+ var _this = _super.call(this, message) || this;
453
+ _this.name = 'PromptbookExecutionError';
454
+ Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
455
+ return _this;
456
+ }
457
+ return PromptbookExecutionError;
458
+ }(Error));
459
+
460
+ /**
461
+ * Asserts that the execution of a promptnook is successful
462
+ *
463
+ * @param executionResult - The partial result of the promptnook execution
464
+ * @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
465
+ */
466
+ function assertsExecutionSuccessful(executionResult) {
467
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
468
+ if (isSuccessful === true) {
469
+ return;
470
+ }
471
+ if (errors.length === 0) {
472
+ throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
473
+ }
474
+ else if (errors.length === 1) {
475
+ throw errors[0];
476
+ }
477
+ else {
478
+ throw new PromptbookExecutionError(spaceTrim.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 "); }));
479
+ }
480
+ }
481
+ /**
482
+ * TODO: [🧠] Can this return type be better typed than void
511
483
  */
512
484
 
513
485
  /**
@@ -1085,7 +1057,7 @@
1085
1057
  var _this = this;
1086
1058
  var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1087
1059
  var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
1088
- validatePromptbookJson(promptbook);
1060
+ validatePromptbook(promptbook);
1089
1061
  var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1090
1062
  function executeSingleTemplate(currentTemplate) {
1091
1063
  return __awaiter(this, void 0, void 0, function () {
@@ -1516,7 +1488,7 @@
1516
1488
  return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
1517
1489
  });
1518
1490
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
1519
- throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbookJson\n "));
1491
+ throw new UnexpectedError(spaceTrim.spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
1520
1492
  case 1:
1521
1493
  if (!!currentTemplate) return [3 /*break*/, 3];
1522
1494
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -1606,6 +1578,38 @@
1606
1578
  * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
1607
1579
  */
1608
1580
 
1581
+ /**
1582
+ * Prettify the html code
1583
+ *
1584
+ * @param content raw html code
1585
+ * @returns formatted html code
1586
+ */
1587
+ function prettifyMarkdown(content) {
1588
+ try {
1589
+ return prettier.format(content, {
1590
+ parser: 'markdown',
1591
+ plugins: [parserHtml__default["default"]],
1592
+ // TODO: DRY - make some import or auto-copy of .prettierrc
1593
+ endOfLine: 'lf',
1594
+ tabWidth: 4,
1595
+ singleQuote: true,
1596
+ trailingComma: 'all',
1597
+ arrowParens: 'always',
1598
+ printWidth: 120,
1599
+ htmlWhitespaceSensitivity: 'ignore',
1600
+ jsxBracketSameLine: false,
1601
+ bracketSpacing: true,
1602
+ });
1603
+ }
1604
+ catch (error) {
1605
+ console.error('There was an error with prettifying the markdown, using the original as the fallback', {
1606
+ error: error,
1607
+ html: content,
1608
+ });
1609
+ return content;
1610
+ }
1611
+ }
1612
+
1609
1613
  /**
1610
1614
  * Makes first letter of a string uppercase
1611
1615
  *
@@ -1845,6 +1849,7 @@
1845
1849
  * Library of promptbooks that groups together promptbooks for an application.
1846
1850
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1847
1851
  *
1852
+ * @private use `createLibraryFromJson` instead
1848
1853
  * @see https://github.com/webgptorg/promptbook#promptbook-library
1849
1854
  */
1850
1855
  var SimplePromptbookLibrary = /** @class */ (function () {
@@ -1853,8 +1858,9 @@
1853
1858
  *
1854
1859
  * @param promptbooks !!!
1855
1860
  *
1861
+ * @private Use instead `createLibraryFromJson`
1856
1862
  * Note: During the construction logic of all promptbooks are validated
1857
- * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
1863
+ * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
1858
1864
  */
1859
1865
  function SimplePromptbookLibrary() {
1860
1866
  var e_1, _a;
@@ -1869,7 +1875,7 @@
1869
1875
  if (promptbook.promptbookUrl === undefined) {
1870
1876
  throw new PromptbookReferenceError(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
1871
1877
  }
1872
- validatePromptbookJson(promptbook);
1878
+ validatePromptbook(promptbook);
1873
1879
  // Note: [🦄]
1874
1880
  if (this.library.has(promptbook.promptbookUrl) &&
1875
1881
  promptbookJsonToString(promptbook) !==
@@ -1923,68 +1929,19 @@
1923
1929
  /**
1924
1930
  * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
1925
1931
  *
1926
- * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
1932
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
1927
1933
  * Note: During the construction syntax and logic of all sources are validated
1928
1934
  *
1929
1935
  * @param promptbookSources
1930
1936
  * @returns PromptbookLibrary
1931
1937
  */
1932
- function createPromptbookLibraryFromSources() {
1933
- var promptbookSources = [];
1938
+ function createLibraryFromJson() {
1939
+ var promptbooks = [];
1934
1940
  for (var _i = 0; _i < arguments.length; _i++) {
1935
- promptbookSources[_i] = arguments[_i];
1941
+ promptbooks[_i] = arguments[_i];
1936
1942
  }
1937
- return __awaiter(this, void 0, void 0, function () {
1938
- var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
1939
- var e_1, _a;
1940
- return __generator(this, function (_b) {
1941
- switch (_b.label) {
1942
- case 0:
1943
- promptbooks = new Array();
1944
- _b.label = 1;
1945
- case 1:
1946
- _b.trys.push([1, 8, 9, 10]);
1947
- promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
1948
- _b.label = 2;
1949
- case 2:
1950
- if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
1951
- source = promptbookSources_1_1.value;
1952
- promptbook = void 0;
1953
- if (!(typeof source === 'string')) return [3 /*break*/, 4];
1954
- return [4 /*yield*/, promptbookStringToJson(source)];
1955
- case 3:
1956
- // Note: When directly creating from string, no need to validate the source
1957
- // The validation is performed always before execution
1958
- promptbook = _b.sent();
1959
- return [3 /*break*/, 5];
1960
- case 4:
1961
- promptbook = source;
1962
- _b.label = 5;
1963
- case 5:
1964
- promptbooks.push(promptbook);
1965
- _b.label = 6;
1966
- case 6:
1967
- promptbookSources_1_1 = promptbookSources_1.next();
1968
- return [3 /*break*/, 2];
1969
- case 7: return [3 /*break*/, 10];
1970
- case 8:
1971
- e_1_1 = _b.sent();
1972
- e_1 = { error: e_1_1 };
1973
- return [3 /*break*/, 10];
1974
- case 9:
1975
- try {
1976
- if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
1977
- }
1978
- finally { if (e_1) throw e_1.error; }
1979
- return [7 /*endfinally*/];
1980
- case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
1981
- }
1982
- });
1983
- });
1943
+ return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
1984
1944
  }
1985
- /**
1986
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
1987
- */
1988
1945
 
1989
1946
  /* tslint:disable */
1990
1947
  function normalizeToKebabCase(sentence) {
@@ -2043,85 +2000,100 @@
2043
2000
 
2044
2001
  function prepareKnowledgeFromMarkdown(options) {
2045
2002
  return __awaiter(this, void 0, void 0, function () {
2046
- var content, llmTools, library, promptbook, executor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
2003
+ var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
2047
2004
  var _this = this;
2048
- return __generator(this, function (_a) {
2049
- switch (_a.label) {
2005
+ return __generator(this, function (_b) {
2006
+ switch (_b.label) {
2050
2007
  case 0:
2051
- content = options.content, llmTools = options.llmTools;
2052
- return [4 /*yield*/, createPromptbookLibraryFromSources(
2053
- /* !!!! ...(promptbookLibrary as Array<PromptbookJson>)*/ {
2054
- title: 'Prepare Knowledge from Markdown',
2055
- promptbookUrl: 'https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md',
2056
- promptbookVersion: '0.59.0-5',
2057
- parameters: [
2058
- { name: 'content', description: 'Markdown document content', isInput: true, isOutput: false },
2059
- { name: 'knowledge', description: 'The knowledge JSON object', isInput: false, isOutput: true },
2060
- ],
2061
- promptTemplates: [
2062
- {
2063
- name: 'knowledge',
2064
- title: 'Knowledge',
2065
- dependentParameterNames: ['content'],
2066
- executionType: 'PROMPT_TEMPLATE',
2067
- modelRequirements: { modelVariant: 'CHAT', modelName: 'claude-3-opus-20240229' },
2068
- content: 'You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}',
2069
- resultingParameterName: 'knowledge',
2070
- },
2071
- ],
2072
- knowledge: [],
2073
- })];
2008
+ content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
2009
+ library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
2010
+ return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
2074
2011
  case 1:
2075
- library = _a.sent();
2076
- promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
2077
- executor = createPromptbookExecutor({
2078
- promptbook: promptbook,
2012
+ prepareKnowledgeFromMarkdownPromptbook = _b.sent();
2013
+ prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
2014
+ promptbook: prepareKnowledgeFromMarkdownPromptbook,
2079
2015
  tools: {
2080
2016
  llm: llmTools,
2081
2017
  script: [
2082
- /* <- TODO: Allow to just not define script tools */
2018
+ /* <- TODO: Allow to just keep script undefined */
2083
2019
  ],
2084
2020
  },
2085
2021
  });
2086
- return [4 /*yield*/, executor({ content: content })];
2022
+ return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
2087
2023
  case 2:
2088
- result = _a.sent();
2024
+ prepareKeywordsPromptbook = _b.sent();
2025
+ prepareKeywordsExecutor = createPromptbookExecutor({
2026
+ promptbook: prepareKeywordsPromptbook,
2027
+ tools: {
2028
+ llm: llmTools,
2029
+ script: [
2030
+ /* <- TODO: Allow to just keep script undefined */
2031
+ ],
2032
+ },
2033
+ });
2034
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
2035
+ case 3:
2036
+ result = _b.sent();
2089
2037
  assertsExecutionSuccessful(result);
2090
2038
  outputParameters = result.outputParameters;
2091
2039
  knowledgeRaw = outputParameters.knowledge;
2092
2040
  knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
2041
+ if (isVerbose) {
2042
+ console.info('knowledgeTextPieces:', knowledgeTextPieces);
2043
+ }
2093
2044
  return [4 /*yield*/, Promise.all(knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
2094
- var name, title, content, keywords, index, sources;
2095
- return __generator(this, function (_a) {
2096
- name = "piece-".concat(i);
2097
- title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 100));
2098
- content = spaceTrim__default["default"](knowledgeTextPiece);
2099
- keywords = [];
2100
- index = [];
2101
- sources = [];
2102
- try {
2103
- // TODO: !!!! Summarize name and title from the content
2104
- title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 30));
2105
- name = normalizeToKebabCase(title);
2106
- // TODO: !!!! Extract keywords via prompt
2107
- // TODO: !!!! Index through LLM model
2108
- // TODO: [🖖] !!!! Make system for sources and identification of sources
2109
- }
2110
- catch (error) {
2111
- console.error(error);
2045
+ var name, title, content, keywords, index, sources, result_1, _a, outputParameters_1, keywordsRaw, error_1;
2046
+ return __generator(this, function (_b) {
2047
+ switch (_b.label) {
2048
+ case 0:
2049
+ name = "piece-".concat(i);
2050
+ title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 100));
2051
+ content = spaceTrim__default["default"](knowledgeTextPiece);
2052
+ keywords = [];
2053
+ index = [];
2054
+ sources = [];
2055
+ _b.label = 1;
2056
+ case 1:
2057
+ _b.trys.push([1, 3, , 4]);
2058
+ // TODO: !!!! Summarize name and title from the content
2059
+ title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 30));
2060
+ name = normalizeToKebabCase(title);
2061
+ return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
2062
+ case 2:
2063
+ result_1 = _b.sent();
2064
+ _a = result_1.outputParameters, outputParameters_1 = _a === void 0 ? {} : _a;
2065
+ keywordsRaw = outputParameters_1.keywords;
2066
+ keywords = (keywordsRaw || '')
2067
+ .split(',')
2068
+ .map(function (keyword) { return keyword.trim(); })
2069
+ .filter(function (keyword) { return keyword !== ''; });
2070
+ if (isVerbose) {
2071
+ console.info("Keywords for \"".concat(title, "\":"), keywords);
2072
+ }
2073
+ // ---
2074
+ // TODO: !!!! Index through LLM model
2075
+ index.push({
2076
+ modelName: 'fake-model',
2077
+ position: new Array(25).fill(0).map(function () { return Math.random() * 2 - 1; }),
2078
+ });
2079
+ return [3 /*break*/, 4];
2080
+ case 3:
2081
+ error_1 = _b.sent();
2082
+ console.error(error_1);
2083
+ return [3 /*break*/, 4];
2084
+ case 4: return [2 /*return*/, {
2085
+ name: name,
2086
+ title: title,
2087
+ content: content,
2088
+ keywords: keywords,
2089
+ index: index,
2090
+ sources: sources,
2091
+ }];
2112
2092
  }
2113
- return [2 /*return*/, {
2114
- name: name,
2115
- title: title,
2116
- content: content,
2117
- keywords: keywords,
2118
- index: index,
2119
- sources: sources,
2120
- }];
2121
2093
  });
2122
2094
  }); }))];
2123
- case 3:
2124
- knowledge = _a.sent();
2095
+ case 4:
2096
+ knowledge = _b.sent();
2125
2097
  return [2 /*return*/, knowledge];
2126
2098
  }
2127
2099
  });
@@ -2362,12 +2334,22 @@
2362
2334
  */
2363
2335
 
2364
2336
  /**
2365
- * Creates a new set with all elements that are present in either set
2337
+ * Removes HTML or Markdown comments from a string.
2338
+ *
2339
+ * @param {string} content - The string to remove comments from.
2340
+ * @returns {string} The input string with all comments removed.
2366
2341
  */
2367
- function union() {
2368
- var e_1, _a, e_2, _b;
2369
- var sets = [];
2370
- for (var _i = 0; _i < arguments.length; _i++) {
2342
+ function removeContentComments(content) {
2343
+ return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
2344
+ }
2345
+
2346
+ /**
2347
+ * Creates a new set with all elements that are present in either set
2348
+ */
2349
+ function union() {
2350
+ var e_1, _a, e_2, _b;
2351
+ var sets = [];
2352
+ for (var _i = 0; _i < arguments.length; _i++) {
2371
2353
  sets[_i] = arguments[_i];
2372
2354
  }
2373
2355
  var union = new Set();
@@ -2960,9 +2942,279 @@
2960
2942
  return value;
2961
2943
  }
2962
2944
 
2945
+ /**
2946
+ * Compile promptbook from string (markdown) format to JSON format synchronously
2947
+ *
2948
+ * Note: There are two similar functions:
2949
+ * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
2950
+ * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
2951
+ *
2952
+ * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
2953
+ * @param options - Options and tools for the compilation
2954
+ * @returns {Promptbook} compiled in JSON format (.ptbk.json)
2955
+ * @throws {PromptbookSyntaxError} if the promptbook string is not valid
2956
+ *
2957
+ * Note: This function does not validate logic of the pipeline only the syntax
2958
+ * Note: This function acts as compilation process
2959
+ */
2960
+ function promptbookStringToJsonSync(promptbookString) {
2961
+ var e_1, _a, e_2, _b;
2962
+ var promptbookJson = {
2963
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2964
+ title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2965
+ promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
2966
+ promptbookVersion: PROMPTBOOK_VERSION,
2967
+ description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
2968
+ parameters: [],
2969
+ promptTemplates: [],
2970
+ knowledge: [],
2971
+ };
2972
+ // =============================================================
2973
+ // Note: 1️⃣ Normalization of the PROMPTBOOK string
2974
+ promptbookString = removeContentComments(promptbookString);
2975
+ promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2976
+ promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2977
+ // =============================================================
2978
+ ///Note: 2️⃣ Function for adding parameters
2979
+ var addParam = function (parameterCommand) {
2980
+ var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
2981
+ var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2982
+ if (existingParameter &&
2983
+ existingParameter.description &&
2984
+ existingParameter.description !== parameterDescription &&
2985
+ parameterDescription) {
2986
+ 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 "); }));
2987
+ }
2988
+ if (existingParameter) {
2989
+ if (parameterDescription) {
2990
+ existingParameter.description = parameterDescription;
2991
+ }
2992
+ }
2993
+ else {
2994
+ promptbookJson.parameters.push({
2995
+ name: parameterName,
2996
+ description: parameterDescription || undefined,
2997
+ isInput: isInput,
2998
+ isOutput: isOutput,
2999
+ });
3000
+ }
3001
+ };
3002
+ // =============================================================
3003
+ // Note: 3️⃣ Parse the dynamic part - the template pipeline
3004
+ var markdownStructure = markdownToMarkdownStructure(promptbookString);
3005
+ var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
3006
+ if (markdownStructureDeepness !== 2) {
3007
+ 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 ")));
3008
+ }
3009
+ promptbookJson.title = markdownStructure.title;
3010
+ // TODO: [1] DRY description
3011
+ var description = markdownStructure.content;
3012
+ // Note: Remove codeblocks
3013
+ description = description.split(/^```.*^```/gms).join('');
3014
+ //Note: Remove lists and return statement
3015
+ description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3016
+ description = spaceTrim.spaceTrim(description);
3017
+ if (description === '') {
3018
+ description = undefined;
3019
+ }
3020
+ promptbookJson.description = description;
3021
+ var defaultModelRequirements = {};
3022
+ var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
3023
+ try {
3024
+ for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
3025
+ var listItem = listItems_1_1.value;
3026
+ var command = parseCommand(listItem);
3027
+ switch (command.type) {
3028
+ case 'PROMPTBOOK_URL':
3029
+ promptbookJson.promptbookUrl = command.promptbookUrl.href;
3030
+ break;
3031
+ case 'PROMPTBOOK_VERSION':
3032
+ promptbookJson.promptbookVersion = command.promptbookVersion;
3033
+ break;
3034
+ case 'MODEL':
3035
+ defaultModelRequirements[command.key] = command.value;
3036
+ break;
3037
+ case 'PARAMETER':
3038
+ addParam(command);
3039
+ break;
3040
+ default:
3041
+ throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
3042
+ }
3043
+ }
3044
+ }
3045
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3046
+ finally {
3047
+ try {
3048
+ if (listItems_1_1 && !listItems_1_1.done && (_a = listItems_1.return)) _a.call(listItems_1);
3049
+ }
3050
+ finally { if (e_1) throw e_1.error; }
3051
+ }
3052
+ var _loop_1 = function (section) {
3053
+ var e_3, _e;
3054
+ // TODO: Parse prompt template description (the content out of the codeblock and lists)
3055
+ var templateModelRequirements = __assign({}, defaultModelRequirements);
3056
+ var listItems_3 = extractAllListItemsFromMarkdown(section.content);
3057
+ var dependentParameterNames = new Set();
3058
+ var executionType = 'PROMPT_TEMPLATE';
3059
+ var jokers = [];
3060
+ var postprocessing = [];
3061
+ var expectAmount = {};
3062
+ var expectFormat = undefined;
3063
+ var isExecutionTypeChanged = false;
3064
+ try {
3065
+ 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()) {
3066
+ var listItem = listItems_2_1.value;
3067
+ var command = parseCommand(listItem);
3068
+ switch (command.type) {
3069
+ case 'JOKER':
3070
+ jokers.push(command.parameterName);
3071
+ dependentParameterNames.add(command.parameterName);
3072
+ break;
3073
+ case 'EXECUTE':
3074
+ if (isExecutionTypeChanged) {
3075
+ throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3076
+ }
3077
+ executionType = command.executionType;
3078
+ isExecutionTypeChanged = true;
3079
+ break;
3080
+ case 'MODEL':
3081
+ templateModelRequirements[command.key] = command.value;
3082
+ break;
3083
+ case 'PARAMETER':
3084
+ // Note: This is just for detecting resulitng parameter name
3085
+ addParam(command);
3086
+ break;
3087
+ case 'POSTPROCESS':
3088
+ postprocessing.push(command.functionName);
3089
+ break;
3090
+ case 'EXPECT_AMOUNT':
3091
+ // eslint-disable-next-line no-case-declarations
3092
+ var unit = command.unit.toLowerCase();
3093
+ expectAmount[unit] = expectAmount[unit] || {};
3094
+ if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
3095
+ if (expectAmount[unit].min !== undefined) {
3096
+ throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3097
+ }
3098
+ expectAmount[unit].min = command.amount;
3099
+ } /* not else */
3100
+ if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
3101
+ if (expectAmount[unit].max !== undefined) {
3102
+ throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3103
+ }
3104
+ expectAmount[unit].max = command.amount;
3105
+ }
3106
+ break;
3107
+ case 'EXPECT_FORMAT':
3108
+ if (expectFormat !== undefined && command.format !== expectFormat) {
3109
+ throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3110
+ }
3111
+ expectFormat = command.format;
3112
+ break;
3113
+ default:
3114
+ throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3115
+ }
3116
+ }
3117
+ }
3118
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
3119
+ finally {
3120
+ try {
3121
+ if (listItems_2_1 && !listItems_2_1.done && (_e = listItems_2.return)) _e.call(listItems_2);
3122
+ }
3123
+ finally { if (e_3) throw e_3.error; }
3124
+ }
3125
+ var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
3126
+ if (executionType === 'SCRIPT') {
3127
+ if (!language) {
3128
+ throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
3129
+ }
3130
+ else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
3131
+ 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 "); }));
3132
+ }
3133
+ }
3134
+ var lastLine = section.content.split('\n').pop();
3135
+ var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
3136
+ if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
3137
+ throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3138
+ // TODO: Show code of invalid sections each time + DRY
3139
+ section.content
3140
+ .split('\n')
3141
+ .map(function (line) { return "> ".concat(line); })
3142
+ .join('\n')), "\n "); }));
3143
+ }
3144
+ var resultingParameterName = match.groups.resultingParamName;
3145
+ // TODO: [1] DRY description
3146
+ var description_1 = section.content;
3147
+ // Note: Remove codeblocks
3148
+ description_1 = description_1.split(/^```.*^```/gms).join('');
3149
+ //Note: Remove lists and return statement
3150
+ description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3151
+ description_1 = spaceTrim.spaceTrim(description_1);
3152
+ if (description_1 === '') {
3153
+ description_1 = undefined;
3154
+ }
3155
+ if (Object.keys(jokers).length === 0) {
3156
+ jokers = undefined;
3157
+ }
3158
+ if (Object.keys(expectAmount).length === 0) {
3159
+ expectAmount = undefined;
3160
+ }
3161
+ if (Object.keys(postprocessing).length === 0) {
3162
+ postprocessing = undefined;
3163
+ }
3164
+ dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
3165
+ if (templateModelRequirements.modelVariant === undefined) {
3166
+ templateModelRequirements.modelVariant = 'CHAT';
3167
+ }
3168
+ var template = {
3169
+ name: titleToName(section.title),
3170
+ title: section.title,
3171
+ description: description_1,
3172
+ dependentParameterNames: Array.from(dependentParameterNames),
3173
+ executionType: executionType,
3174
+ jokers: jokers,
3175
+ postprocessing: postprocessing,
3176
+ expectations: expectAmount,
3177
+ expectFormat: expectFormat,
3178
+ modelRequirements: templateModelRequirements,
3179
+ contentLanguage: executionType === 'SCRIPT' ? language : undefined,
3180
+ content: content,
3181
+ resultingParameterName: resultingParameterName,
3182
+ };
3183
+ if (executionType !== 'PROMPT_TEMPLATE') {
3184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3185
+ delete template.modelRequirements;
3186
+ }
3187
+ promptbookJson.promptTemplates.push(template);
3188
+ };
3189
+ try {
3190
+ for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
3191
+ var section = _d.value;
3192
+ _loop_1(section);
3193
+ }
3194
+ }
3195
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3196
+ finally {
3197
+ try {
3198
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
3199
+ }
3200
+ finally { if (e_2) throw e_2.error; }
3201
+ }
3202
+ // =============================================================
3203
+ return promptbookJson;
3204
+ }
3205
+ /**
3206
+ * TODO: Report here line/column of error
3207
+ * TODO: Use spaceTrim more effectively
3208
+ * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
3209
+ */
3210
+
2963
3211
  /**
2964
3212
  * Compile promptbook from string (markdown) format to JSON format
2965
3213
  *
3214
+ * Note: There are two similar functions:
3215
+ * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
3216
+ * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
3217
+ *
2966
3218
  * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
2967
3219
  * @param options - Options and tools for the compilation
2968
3220
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
@@ -2974,263 +3226,542 @@
2974
3226
  function promptbookStringToJson(promptbookString, options) {
2975
3227
  if (options === void 0) { options = {}; }
2976
3228
  return __awaiter(this, void 0, void 0, function () {
2977
- var llmTools, promptbookJson, knowledge, addParam, markdownStructure, markdownStructureDeepness, description, defaultModelRequirements, listItems, listItems_1, listItems_1_1, listItem, command, _loop_1, _a, _b, section;
2978
- var e_1, _c, e_2, _d;
2979
- return __generator(this, function (_e) {
2980
- switch (_e.label) {
3229
+ var llmTools, knowledge, promptbookJson;
3230
+ return __generator(this, function (_a) {
3231
+ switch (_a.label) {
2981
3232
  case 0:
2982
3233
  llmTools = options.llmTools;
2983
- promptbookJson = {
2984
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2985
- title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2986
- promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
2987
- promptbookVersion: PROMPTBOOK_VERSION,
2988
- description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
2989
- parameters: [],
2990
- promptTemplates: [],
2991
- knowledge: [],
2992
- };
2993
3234
  if (!llmTools) return [3 /*break*/, 2];
2994
3235
  return [4 /*yield*/, prepareKnowledgeFromMarkdown({
2995
3236
  content: 'Roses are red, violets are blue, programmers use Promptbook, users too',
2996
3237
  llmTools: llmTools,
2997
3238
  })];
2998
3239
  case 1:
2999
- knowledge = _e.sent();
3240
+ knowledge = _a.sent();
3000
3241
  console.info('!!!! knowledge', knowledge);
3001
- _e.label = 2;
3242
+ _a.label = 2;
3002
3243
  case 2:
3003
- // =============================================================
3004
- // Note: 1️⃣ Normalization of the PROMPTBOOK string
3005
- promptbookString = removeContentComments(promptbookString);
3006
- promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
3007
- promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
3008
- addParam = function (parameterCommand) {
3009
- var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
3010
- var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
3011
- if (existingParameter &&
3012
- existingParameter.description &&
3013
- existingParameter.description !== parameterDescription &&
3014
- parameterDescription) {
3015
- 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 "); }));
3016
- }
3017
- if (existingParameter) {
3018
- if (parameterDescription) {
3019
- existingParameter.description = parameterDescription;
3020
- }
3021
- }
3022
- else {
3023
- promptbookJson.parameters.push({
3024
- name: parameterName,
3025
- description: parameterDescription || undefined,
3026
- isInput: isInput,
3027
- isOutput: isOutput,
3028
- });
3244
+ promptbookJson = promptbookStringToJsonSync(promptbookString);
3245
+ return [2 /*return*/, promptbookJson];
3246
+ }
3247
+ });
3248
+ });
3249
+ }
3250
+ /**
3251
+ * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3252
+ */
3253
+
3254
+ /**
3255
+ * This error indicates that the promptbook library cannot be propperly loaded
3256
+ */
3257
+ var PromptbookLibraryError = /** @class */ (function (_super) {
3258
+ __extends(PromptbookLibraryError, _super);
3259
+ function PromptbookLibraryError(message) {
3260
+ var _this = _super.call(this, message) || this;
3261
+ _this.name = 'PromptbookLibraryError';
3262
+ Object.setPrototypeOf(_this, PromptbookLibraryError.prototype);
3263
+ return _this;
3264
+ }
3265
+ return PromptbookLibraryError;
3266
+ }(Error));
3267
+
3268
+ /**
3269
+ * Constructs Promptbook from async sources
3270
+ * It can be one of the following:
3271
+ * - Promise of array of PromptbookJson or PromptbookString
3272
+ * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
3273
+ *
3274
+ * Note: This is useful as internal tool for other constructor functions like
3275
+ * `createLibraryFromUrl` or `createLibraryFromDirectory`
3276
+ * Consider using those functions instead of this one
3277
+ *
3278
+ * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3279
+ * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
3280
+ *
3281
+ * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
3282
+ *
3283
+ * @param promptbookSourcesPromiseOrFactory
3284
+ * @returns PromptbookLibrary
3285
+ * @deprecated Do not use, it will became internal tool for other constructor functions
3286
+ */
3287
+ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3288
+ var library;
3289
+ function forSources() {
3290
+ return __awaiter(this, void 0, void 0, function () {
3291
+ var promptbookSources;
3292
+ return __generator(this, function (_a) {
3293
+ switch (_a.label) {
3294
+ case 0:
3295
+ if (typeof promptbookSourcesPromiseOrFactory === 'function') {
3296
+ // Note: Calling factory function only once despite multiple calls to resolveSources
3297
+ promptbookSourcesPromiseOrFactory = promptbookSourcesPromiseOrFactory();
3029
3298
  }
3030
- };
3031
- markdownStructure = markdownToMarkdownStructure(promptbookString);
3032
- markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
3033
- if (markdownStructureDeepness !== 2) {
3034
- 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 ")));
3035
- }
3036
- promptbookJson.title = markdownStructure.title;
3037
- description = markdownStructure.content;
3038
- // Note: Remove codeblocks
3039
- description = description.split(/^```.*^```/gms).join('');
3040
- //Note: Remove lists and return statement
3041
- description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3042
- description = spaceTrim.spaceTrim(description);
3043
- if (description === '') {
3044
- description = undefined;
3299
+ return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3300
+ case 1:
3301
+ promptbookSources = _a.sent();
3302
+ library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3303
+ return [2 /*return*/];
3304
+ }
3305
+ });
3306
+ });
3307
+ }
3308
+ function listPromptbooks() {
3309
+ return __awaiter(this, void 0, void 0, function () {
3310
+ return __generator(this, function (_a) {
3311
+ switch (_a.label) {
3312
+ case 0: return [4 /*yield*/, forSources()];
3313
+ case 1:
3314
+ _a.sent();
3315
+ return [2 /*return*/, /* not await */ library.listPromptbooks()];
3316
+ }
3317
+ });
3318
+ });
3319
+ }
3320
+ function getPromptbookByUrl(url) {
3321
+ return __awaiter(this, void 0, void 0, function () {
3322
+ return __generator(this, function (_a) {
3323
+ switch (_a.label) {
3324
+ case 0: return [4 /*yield*/, forSources()];
3325
+ case 1:
3326
+ _a.sent();
3327
+ return [2 /*return*/, /* not await */ library.getPromptbookByUrl(url)];
3328
+ }
3329
+ });
3330
+ });
3331
+ }
3332
+ function isResponsibleForPrompt(prompt) {
3333
+ return __awaiter(this, void 0, void 0, function () {
3334
+ return __generator(this, function (_a) {
3335
+ switch (_a.label) {
3336
+ case 0: return [4 /*yield*/, forSources()];
3337
+ case 1:
3338
+ _a.sent();
3339
+ return [2 /*return*/, /* not await */ library.isResponsibleForPrompt(prompt)];
3340
+ }
3341
+ });
3342
+ });
3343
+ }
3344
+ return {
3345
+ listPromptbooks: listPromptbooks,
3346
+ getPromptbookByUrl: getPromptbookByUrl,
3347
+ isResponsibleForPrompt: isResponsibleForPrompt,
3348
+ };
3349
+ }
3350
+
3351
+ /**
3352
+ * Constructs Promptbook from given directory
3353
+ *
3354
+ * Note: Works only in Node.js environment because it reads the file system
3355
+ *
3356
+ * @param path - path to the directory with promptbooks
3357
+ * @param options - Misc options for the library
3358
+ * @returns PromptbookLibrary
3359
+ */
3360
+ function createLibraryFromDirectory(path$1, options) {
3361
+ return __awaiter(this, void 0, void 0, function () {
3362
+ var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3363
+ var _this = this;
3364
+ return __generator(this, function (_f) {
3365
+ switch (_f.label) {
3366
+ case 0:
3367
+ if (!isRunningInNode()) {
3368
+ throw new Error('Function `createLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3045
3369
  }
3046
- promptbookJson.description = description;
3047
- defaultModelRequirements = {};
3048
- listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
3049
- try {
3050
- for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
3051
- listItem = listItems_1_1.value;
3052
- command = parseCommand(listItem);
3053
- switch (command.type) {
3054
- case 'PROMPTBOOK_URL':
3055
- promptbookJson.promptbookUrl = command.promptbookUrl.href;
3056
- break;
3057
- case 'PROMPTBOOK_VERSION':
3058
- promptbookJson.promptbookVersion = command.promptbookVersion;
3059
- break;
3060
- case 'MODEL':
3061
- defaultModelRequirements[command.key] = command.value;
3062
- break;
3063
- case 'PARAMETER':
3064
- addParam(command);
3065
- break;
3066
- default:
3067
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
3068
- }
3069
- }
3370
+ makedLibraryFilePath = path.join(path$1, "".concat(PROMPTBOOK_MAKED_BASE_FILENAME, ".json"));
3371
+ return [4 /*yield*/, promises.access(makedLibraryFilePath, promises.constants.R_OK)
3372
+ .then(function () { return true; })
3373
+ .catch(function () { return false; })];
3374
+ case 1:
3375
+ makedLibraryFileExists = _f.sent();
3376
+ if (!makedLibraryFileExists) {
3377
+ console.info(colors__default["default"].yellow("Tip: Prebuild your promptbook library (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"promptbook make\" to speed up the library creation.")));
3070
3378
  }
3071
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3072
- finally {
3073
- try {
3074
- if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
3075
- }
3076
- finally { if (e_1) throw e_1.error; }
3379
+ else {
3380
+ colors__default["default"].green("(In future, not implemented yet) Using your prebuild promptbook library ".concat(makedLibraryFilePath));
3381
+ // TODO: !! Implement;
3077
3382
  }
3078
- _loop_1 = function (section) {
3079
- var e_3, _f;
3080
- // TODO: Parse prompt template description (the content out of the codeblock and lists)
3081
- var templateModelRequirements = __assign({}, defaultModelRequirements);
3082
- var listItems_3 = extractAllListItemsFromMarkdown(section.content);
3083
- var dependentParameterNames = new Set();
3084
- var executionType = 'PROMPT_TEMPLATE';
3085
- var jokers = [];
3086
- var postprocessing = [];
3087
- var expectAmount = {};
3088
- var expectFormat = undefined;
3089
- var isExecutionTypeChanged = false;
3090
- try {
3091
- 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()) {
3092
- var listItem = listItems_2_1.value;
3093
- var command = parseCommand(listItem);
3094
- switch (command.type) {
3095
- case 'JOKER':
3096
- jokers.push(command.parameterName);
3097
- dependentParameterNames.add(command.parameterName);
3098
- break;
3099
- case 'EXECUTE':
3100
- if (isExecutionTypeChanged) {
3101
- throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3102
- }
3103
- executionType = command.executionType;
3104
- isExecutionTypeChanged = true;
3105
- break;
3106
- case 'MODEL':
3107
- templateModelRequirements[command.key] = command.value;
3108
- break;
3109
- case 'PARAMETER':
3110
- // Note: This is just for detecting resulitng parameter name
3111
- addParam(command);
3112
- break;
3113
- case 'POSTPROCESS':
3114
- postprocessing.push(command.functionName);
3115
- break;
3116
- case 'EXPECT_AMOUNT':
3117
- // eslint-disable-next-line no-case-declarations
3118
- var unit = command.unit.toLowerCase();
3119
- expectAmount[unit] = expectAmount[unit] || {};
3120
- if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
3121
- if (expectAmount[unit].min !== undefined) {
3122
- throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3123
- }
3124
- expectAmount[unit].min = command.amount;
3125
- } /* not else */
3126
- if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
3127
- if (expectAmount[unit].max !== undefined) {
3128
- throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3383
+ _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashOnError, isCrashOnError = _e === void 0 ? true : _e;
3384
+ library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3385
+ var fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
3386
+ var e_1, _a;
3387
+ return __generator(this, function (_b) {
3388
+ switch (_b.label) {
3389
+ case 0:
3390
+ if (isVerbose) {
3391
+ console.info("Creating promptbook library from path ".concat(path$1.split('\\').join('/')));
3392
+ }
3393
+ return [4 /*yield*/, listAllFiles(path$1, isRecursive)];
3394
+ case 1:
3395
+ fileNames = _b.sent();
3396
+ promptbooks = [];
3397
+ _loop_1 = function (fileName) {
3398
+ var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
3399
+ return __generator(this, function (_e) {
3400
+ switch (_e.label) {
3401
+ case 0:
3402
+ _e.trys.push([0, 7, , 8]);
3403
+ promptbook = null;
3404
+ if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 3];
3405
+ return [4 /*yield*/, promises.readFile(fileName, 'utf8')];
3406
+ case 1:
3407
+ promptbookString = (_e.sent());
3408
+ return [4 /*yield*/, promptbookStringToJson(promptbookString)];
3409
+ case 2:
3410
+ promptbook = _e.sent();
3411
+ return [3 /*break*/, 6];
3412
+ case 3:
3413
+ if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 5];
3414
+ if (isVerbose) {
3415
+ console.info("Loading ".concat(fileName.split('\\').join('/')));
3416
+ }
3417
+ _d = (_c = JSON).parse;
3418
+ return [4 /*yield*/, promises.readFile(fileName, 'utf8')];
3419
+ case 4:
3420
+ // TODO: Handle non-valid JSON files
3421
+ promptbook = _d.apply(_c, [_e.sent()]);
3422
+ return [3 /*break*/, 6];
3423
+ case 5:
3424
+ if (isVerbose) {
3425
+ console.info("Skipping file ".concat(fileName.split('\\').join('/')));
3426
+ }
3427
+ _e.label = 6;
3428
+ case 6:
3429
+ // ---
3430
+ if (promptbook !== null) {
3431
+ if (!promptbook.promptbookUrl) {
3432
+ if (isVerbose) {
3433
+ console.info("Not loading ".concat(fileName.split('\\').join('/'), " - missing URL"));
3434
+ }
3435
+ }
3436
+ else {
3437
+ if (isVerbose) {
3438
+ console.info("Loading ".concat(fileName.split('\\').join('/')));
3439
+ }
3440
+ if (!isCrashOnError) {
3441
+ // Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
3442
+ // But be handled in current try-catch block
3443
+ validatePromptbook(promptbook);
3444
+ }
3445
+ // Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
3446
+ promptbooks.push(promptbook);
3447
+ }
3448
+ }
3449
+ return [3 /*break*/, 8];
3450
+ case 7:
3451
+ error_1 = _e.sent();
3452
+ if (!(error_1 instanceof Error)) {
3453
+ throw error_1;
3454
+ }
3455
+ wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n Error during loading promptbook from file ".concat(fileName.split('\\').join('/'), ":\n\n ").concat(block(error_1.message), "\n\n "); });
3456
+ if (isCrashOnError) {
3457
+ throw new PromptbookLibraryError(wrappedErrorMessage);
3458
+ }
3459
+ console.error(wrappedErrorMessage);
3460
+ return [3 /*break*/, 8];
3461
+ case 8: return [2 /*return*/];
3129
3462
  }
3130
- expectAmount[unit].max = command.amount;
3131
- }
3132
- break;
3133
- case 'EXPECT_FORMAT':
3134
- if (expectFormat !== undefined && command.format !== expectFormat) {
3135
- throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3136
- }
3137
- expectFormat = command.format;
3138
- break;
3139
- default:
3140
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3141
- }
3142
- }
3143
- }
3144
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3145
- finally {
3146
- try {
3147
- if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
3463
+ });
3464
+ };
3465
+ _b.label = 2;
3466
+ case 2:
3467
+ _b.trys.push([2, 7, 8, 9]);
3468
+ fileNames_1 = __values(fileNames), fileNames_1_1 = fileNames_1.next();
3469
+ _b.label = 3;
3470
+ case 3:
3471
+ if (!!fileNames_1_1.done) return [3 /*break*/, 6];
3472
+ fileName = fileNames_1_1.value;
3473
+ return [5 /*yield**/, _loop_1(fileName)];
3474
+ case 4:
3475
+ _b.sent();
3476
+ _b.label = 5;
3477
+ case 5:
3478
+ fileNames_1_1 = fileNames_1.next();
3479
+ return [3 /*break*/, 3];
3480
+ case 6: return [3 /*break*/, 9];
3481
+ case 7:
3482
+ e_1_1 = _b.sent();
3483
+ e_1 = { error: e_1_1 };
3484
+ return [3 /*break*/, 9];
3485
+ case 8:
3486
+ try {
3487
+ if (fileNames_1_1 && !fileNames_1_1.done && (_a = fileNames_1.return)) _a.call(fileNames_1);
3488
+ }
3489
+ finally { if (e_1) throw e_1.error; }
3490
+ return [7 /*endfinally*/];
3491
+ case 9: return [2 /*return*/, promptbooks];
3148
3492
  }
3149
- finally { if (e_3) throw e_3.error; }
3493
+ });
3494
+ }); });
3495
+ if (!(isLazyLoaded === false)) return [3 /*break*/, 3];
3496
+ return [4 /*yield*/, library.listPromptbooks()];
3497
+ case 2:
3498
+ _f.sent();
3499
+ _f.label = 3;
3500
+ case 3: return [2 /*return*/, library];
3501
+ }
3502
+ });
3503
+ });
3504
+ }
3505
+ /**
3506
+ * Reads all files in the directory
3507
+ *
3508
+ * @param path
3509
+ * @param isRecursive
3510
+ * @returns List of all files in the directory
3511
+ * @private internal function for `createLibraryFromDirectory`
3512
+ */
3513
+ function listAllFiles(path$1, isRecursive) {
3514
+ return __awaiter(this, void 0, void 0, function () {
3515
+ var dirents, fileNames, _a, _b, dirent, subPath, _c, _d, _e, _f, e_2_1;
3516
+ var e_2, _g;
3517
+ return __generator(this, function (_h) {
3518
+ switch (_h.label) {
3519
+ case 0: return [4 /*yield*/, promises.readdir(path$1, {
3520
+ withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
3521
+ })];
3522
+ case 1:
3523
+ dirents = _h.sent();
3524
+ fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
3525
+ var name = _a.name;
3526
+ return path.join(path$1, name);
3527
+ });
3528
+ if (!isRecursive) return [3 /*break*/, 9];
3529
+ _h.label = 2;
3530
+ case 2:
3531
+ _h.trys.push([2, 7, 8, 9]);
3532
+ _a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
3533
+ _h.label = 3;
3534
+ case 3:
3535
+ if (!!_b.done) return [3 /*break*/, 6];
3536
+ dirent = _b.value;
3537
+ subPath = path.join(path$1, dirent.name);
3538
+ _d = (_c = fileNames.push).apply;
3539
+ _e = [fileNames];
3540
+ _f = [[]];
3541
+ return [4 /*yield*/, listAllFiles(subPath, isRecursive)];
3542
+ case 4:
3543
+ _d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
3544
+ _h.label = 5;
3545
+ case 5:
3546
+ _b = _a.next();
3547
+ return [3 /*break*/, 3];
3548
+ case 6: return [3 /*break*/, 9];
3549
+ case 7:
3550
+ e_2_1 = _h.sent();
3551
+ e_2 = { error: e_2_1 };
3552
+ return [3 /*break*/, 9];
3553
+ case 8:
3554
+ try {
3555
+ if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
3556
+ }
3557
+ finally { if (e_2) throw e_2.error; }
3558
+ return [7 /*endfinally*/];
3559
+ case 9: return [2 /*return*/, fileNames];
3560
+ }
3561
+ });
3562
+ });
3563
+ }
3564
+ /**
3565
+ * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3566
+ */
3567
+
3568
+ /**
3569
+ * Converts PromptbookLibrary to serialized JSON
3570
+ *
3571
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
3572
+ */
3573
+ function libraryToJson(library) {
3574
+ return __awaiter(this, void 0, void 0, function () {
3575
+ var promptbookUrls, promptbooks;
3576
+ return __generator(this, function (_a) {
3577
+ switch (_a.label) {
3578
+ case 0: return [4 /*yield*/, library.listPromptbooks()];
3579
+ case 1:
3580
+ promptbookUrls = _a.sent();
3581
+ return [4 /*yield*/, Promise.all(promptbookUrls.map(function (url) { return library.getPromptbookByUrl(url); }))];
3582
+ case 2:
3583
+ promptbooks = _a.sent();
3584
+ return [2 /*return*/, promptbooks];
3585
+ }
3586
+ });
3587
+ });
3588
+ }
3589
+
3590
+ /**
3591
+ * Initializes `make` command for Promptbook CLI utilities
3592
+ *
3593
+ * @private part of `promptbookCli`
3594
+ */
3595
+ function initializeMake(program) {
3596
+ var _this = this;
3597
+ var helloCommand = program.command('make');
3598
+ helloCommand.description(spaceTrim__default["default"]("\n Makes a new promptbook library in given folder\n "));
3599
+ helloCommand.argument('<path>', 'Path to promptbook directory');
3600
+ helloCommand.option('--project-name', "Name of the project for whom library is", 'Project');
3601
+ helloCommand.option('-f, --format <format>', spaceTrim__default["default"]("\n Output format of builded library \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'javascript' /* <- Note: [🏳‍🌈] */);
3602
+ helloCommand.option('--no-validation', "Do not validate logic of promptbooks in library", true);
3603
+ helloCommand.option('--validation', "Types of validations separated by comma (options \"logic\",\"imports\")", 'logic,imports');
3604
+ helloCommand.option('--verbose', "Is verbose", false);
3605
+ helloCommand.option('-o, --out-file <path>', spaceTrim__default["default"]("\n Where to save the builded library\n\n Note: If you keep it \"".concat(PROMPTBOOK_MAKED_BASE_FILENAME, "\" it will be saved in the root of the promptbook directory\n If you set it to a path, it will be saved in that path\n BUT you can use only one format and set correct extension\n ")), PROMPTBOOK_MAKED_BASE_FILENAME);
3606
+ // TODO: !!! Auto-detect AI api keys + explicit api keys as argv
3607
+ helloCommand.action(function (path$1, _a) {
3608
+ var projectName = _a.projectName, format = _a.format, validation = _a.validation, verbose = _a.verbose, outFile = _a.outFile;
3609
+ return __awaiter(_this, void 0, void 0, function () {
3610
+ var formats, validations, library, validations_1, validations_1_1, validation_1, _b, _c, promptbookUrl, promptbook, e_1_1, e_2_1, libraryJson, libraryJsonString, saveFile;
3611
+ var e_2, _d, e_1, _e;
3612
+ var _this = this;
3613
+ return __generator(this, function (_f) {
3614
+ switch (_f.label) {
3615
+ case 0:
3616
+ console.info('!!!', { projectName: projectName, path: path$1, format: format, validation: validation, verbose: verbose, outFile: outFile });
3617
+ formats = (format || '')
3618
+ .split(',')
3619
+ .map(function (_) { return _.trim(); })
3620
+ .filter(function (_) { return _ !== ''; });
3621
+ validations = (validation || '')
3622
+ .split(',')
3623
+ .map(function (_) { return _.trim(); })
3624
+ .filter(function (_) { return _ !== ''; });
3625
+ if (outFile !== PROMPTBOOK_MAKED_BASE_FILENAME && formats.length !== 1) {
3626
+ console.error(colors__default["default"].red("You can use only one format when saving to a file"));
3627
+ process.exit(1);
3150
3628
  }
3151
- var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
3152
- if (executionType === 'SCRIPT') {
3153
- if (!language) {
3154
- throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
3629
+ return [4 /*yield*/, createLibraryFromDirectory(path$1, {
3630
+ isVerbose: verbose,
3631
+ isRecursive: true,
3632
+ })];
3633
+ case 1:
3634
+ library = _f.sent();
3635
+ _f.label = 2;
3636
+ case 2:
3637
+ _f.trys.push([2, 14, 15, 16]);
3638
+ validations_1 = __values(validations), validations_1_1 = validations_1.next();
3639
+ _f.label = 3;
3640
+ case 3:
3641
+ if (!!validations_1_1.done) return [3 /*break*/, 13];
3642
+ validation_1 = validations_1_1.value;
3643
+ _f.label = 4;
3644
+ case 4:
3645
+ _f.trys.push([4, 10, 11, 12]);
3646
+ e_1 = void 0;
3647
+ return [4 /*yield*/, library.listPromptbooks()];
3648
+ case 5:
3649
+ _b = (__values.apply(void 0, [_f.sent()])), _c = _b.next();
3650
+ _f.label = 6;
3651
+ case 6:
3652
+ if (!!_c.done) return [3 /*break*/, 9];
3653
+ promptbookUrl = _c.value;
3654
+ return [4 /*yield*/, library.getPromptbookByUrl(promptbookUrl)];
3655
+ case 7:
3656
+ promptbook = _f.sent();
3657
+ if (validation_1 === 'logic') {
3658
+ validatePromptbook(promptbook);
3659
+ if (verbose) {
3660
+ console.info(colors__default["default"].cyan("Validated logic of ".concat(promptbook.promptbookUrl)));
3155
3661
  }
3156
- else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
3157
- 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 "); }));
3158
- }
3159
- }
3160
- var lastLine = section.content.split('\n').pop();
3161
- var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
3162
- if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
3163
- throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3164
- // TODO: Show code of invalid sections each time + DRY
3165
- section.content
3166
- .split('\n')
3167
- .map(function (line) { return "> ".concat(line); })
3168
- .join('\n')), "\n "); }));
3169
3662
  }
3170
- var resultingParameterName = match.groups.resultingParamName;
3171
- // TODO: [1] DRY description
3172
- var description_1 = section.content;
3173
- // Note: Remove codeblocks
3174
- description_1 = description_1.split(/^```.*^```/gms).join('');
3175
- //Note: Remove lists and return statement
3176
- description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3177
- description_1 = spaceTrim.spaceTrim(description_1);
3178
- if (description_1 === '') {
3179
- description_1 = undefined;
3180
- }
3181
- if (Object.keys(jokers).length === 0) {
3182
- jokers = undefined;
3183
- }
3184
- if (Object.keys(expectAmount).length === 0) {
3185
- expectAmount = undefined;
3186
- }
3187
- if (Object.keys(postprocessing).length === 0) {
3188
- postprocessing = undefined;
3189
- }
3190
- dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
3191
- if (templateModelRequirements.modelVariant === undefined) {
3192
- templateModelRequirements.modelVariant = 'CHAT';
3193
- }
3194
- promptbookJson.promptTemplates.push({
3195
- name: titleToName(section.title),
3196
- title: section.title,
3197
- description: description_1,
3198
- dependentParameterNames: Array.from(dependentParameterNames),
3199
- executionType: executionType,
3200
- jokers: jokers,
3201
- postprocessing: postprocessing,
3202
- expectations: expectAmount,
3203
- expectFormat: expectFormat,
3204
- modelRequirements: templateModelRequirements,
3205
- contentLanguage: executionType === 'SCRIPT' ? language : undefined,
3206
- content: content,
3207
- resultingParameterName: resultingParameterName,
3208
- });
3209
- };
3210
- try {
3211
- for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
3212
- section = _b.value;
3213
- _loop_1(section);
3663
+ _f.label = 8;
3664
+ case 8:
3665
+ _c = _b.next();
3666
+ return [3 /*break*/, 6];
3667
+ case 9: return [3 /*break*/, 12];
3668
+ case 10:
3669
+ e_1_1 = _f.sent();
3670
+ e_1 = { error: e_1_1 };
3671
+ return [3 /*break*/, 12];
3672
+ case 11:
3673
+ try {
3674
+ if (_c && !_c.done && (_e = _b.return)) _e.call(_b);
3214
3675
  }
3215
- }
3216
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3217
- finally {
3676
+ finally { if (e_1) throw e_1.error; }
3677
+ return [7 /*endfinally*/];
3678
+ case 12:
3679
+ validations_1_1 = validations_1.next();
3680
+ return [3 /*break*/, 3];
3681
+ case 13: return [3 /*break*/, 16];
3682
+ case 14:
3683
+ e_2_1 = _f.sent();
3684
+ e_2 = { error: e_2_1 };
3685
+ return [3 /*break*/, 16];
3686
+ case 15:
3218
3687
  try {
3219
- if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
3688
+ if (validations_1_1 && !validations_1_1.done && (_d = validations_1.return)) _d.call(validations_1);
3220
3689
  }
3221
3690
  finally { if (e_2) throw e_2.error; }
3222
- }
3223
- // =============================================================
3224
- return [2 /*return*/, promptbookJson];
3225
- }
3691
+ return [7 /*endfinally*/];
3692
+ case 16: return [4 /*yield*/, libraryToJson(library)];
3693
+ case 17:
3694
+ libraryJson = _f.sent();
3695
+ libraryJsonString = JSON.stringify(libraryJson);
3696
+ saveFile = function (extension, content) { return __awaiter(_this, void 0, void 0, function () {
3697
+ var filePath;
3698
+ return __generator(this, function (_a) {
3699
+ switch (_a.label) {
3700
+ case 0:
3701
+ filePath = outFile !== PROMPTBOOK_MAKED_BASE_FILENAME
3702
+ ? outFile
3703
+ : path.join(path$1, "".concat(PROMPTBOOK_MAKED_BASE_FILENAME, ".").concat(extension));
3704
+ if (!outFile.endsWith(".".concat(extension))) {
3705
+ console.warn(colors__default["default"].yellow("Warning: Extension of output file should be \"".concat(extension, "\"")));
3706
+ }
3707
+ return [4 /*yield*/, promises.mkdir(path.dirname(filePath), { recursive: true })];
3708
+ case 1:
3709
+ _a.sent();
3710
+ return [4 /*yield*/, promises.writeFile(filePath, content, 'utf-8')];
3711
+ case 2:
3712
+ _a.sent();
3713
+ // Note: Log despite of verbose mode
3714
+ console.info(colors__default["default"].green("Maked ".concat(filePath.split('\\').join('/'))));
3715
+ return [2 /*return*/];
3716
+ }
3717
+ });
3718
+ }); };
3719
+ if (!formats.includes('json')) return [3 /*break*/, 19];
3720
+ return [4 /*yield*/, saveFile('json', libraryJsonString + '\n')];
3721
+ case 18:
3722
+ _f.sent();
3723
+ _f.label = 19;
3724
+ case 19:
3725
+ if (!formats.includes('javascript')) return [3 /*break*/, 21];
3726
+ return [4 /*yield*/, saveFile('js', spaceTrim__default["default"]("\n import { createLibraryFromJson } from '@promptbook/core';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PromptbookLibrary} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPromptbookLibrary(){\n if(promptbookLibrary===null){\n promptbookLibrary = createLibraryFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return promptbookLibrary;\n }\n ") + '\n'))];
3727
+ case 20:
3728
+ _f.sent();
3729
+ _f.label = 21;
3730
+ case 21:
3731
+ if (!formats.includes('typescript')) return [3 /*break*/, 23];
3732
+ return [4 /*yield*/, saveFile('ts', spaceTrim__default["default"]("\n import { createLibraryFromJson } from '@promptbook/core';\n import type { PromptbookLibrary } from '@promptbook/types';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary: null | PromptbookLibrary = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PromptbookLibrary} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPromptbookLibrary(): PromptbookLibrary{\n if(promptbookLibrary===null){\n promptbookLibrary = createLibraryFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return promptbookLibrary;\n }\n ") + '\n'))];
3733
+ case 22:
3734
+ _f.sent();
3735
+ _f.label = 23;
3736
+ case 23:
3737
+ process.exit(0);
3738
+ return [2 /*return*/];
3739
+ }
3740
+ });
3226
3741
  });
3227
3742
  });
3228
3743
  }
3744
+
3229
3745
  /**
3230
- * TODO: Report here line/column of error
3231
- * TODO: Use spaceTrim more effectively
3232
- * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
3746
+ * Add or modify an auto-generated section in a markdown file
3747
+ *
3748
+ * @private within the library
3233
3749
  */
3750
+ function addAutoGeneratedSection(content, options) {
3751
+ var sectionName = options.sectionName, sectionContent = options.sectionContent;
3752
+ var warningLine = "<!-- \u26A0\uFE0F WARNING: This section was auto-generated -->";
3753
+ var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
3754
+ var sectionMatch = content.match(sectionRegex);
3755
+ if (sectionMatch) {
3756
+ return content.replace(sectionRegex, spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
3757
+ }
3758
+ var placeForSection = removeContentComments(content).match(/^##.*$/im);
3759
+ if (!placeForSection) {
3760
+ throw new Error("No place where to put the section <!--".concat(sectionName, "-->"));
3761
+ }
3762
+ var _a = __read(placeForSection, 1), heading = _a[0];
3763
+ return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
3764
+ }
3234
3765
 
3235
3766
  /* tslint:disable */
3236
3767
  function normalizeTo_camelCase(sentence, __firstLetterCapital) {
@@ -3356,7 +3887,7 @@
3356
3887
  case 0:
3357
3888
  isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
3358
3889
  if (!isGraphAdded) return [3 /*break*/, 2];
3359
- return [4 /*yield*/, promptbookStringToJson(promptbookString /* , {!!!!} */)];
3890
+ return [4 /*yield*/, promptbookStringToJson(promptbookString)];
3360
3891
  case 1:
3361
3892
  promptbookJson = _a.sent();
3362
3893
  promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson, {
@@ -3385,117 +3916,106 @@
3385
3916
  */
3386
3917
 
3387
3918
  /**
3388
- * Runs CLI script for prettifying promptbooks
3919
+ * Initializes `prettify` command for Promptbook CLI utilities
3920
+ *
3921
+ * @private part of `promptbookCli`
3389
3922
  */
3390
- function prettifyPromptbookStringCli() {
3923
+ function initializePrettify(program) {
3924
+ var _this = this;
3925
+ var prettifyCommand = program.command('prettify');
3926
+ prettifyCommand.description(spaceTrim__default["default"]("\n Iterates over promptbooks and does multiple enhancing operations on them:\n\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
3927
+ prettifyCommand.argument('<filesGlob>', 'Promptbooks to prettify as glob pattern');
3928
+ prettifyCommand.option('-i, --ignore <glob>', "Ignore as glob pattern");
3929
+ prettifyCommand.action(function (filesGlob, _a) {
3930
+ var ignore = _a.ignore;
3931
+ return __awaiter(_this, void 0, void 0, function () {
3932
+ var filePaths, filePaths_1, filePaths_1_1, filePath, promptbookMarkdown, error_1, e_1_1;
3933
+ var e_1, _b;
3934
+ return __generator(this, function (_c) {
3935
+ switch (_c.label) {
3936
+ case 0: return [4 /*yield*/, glob__default["default"](filesGlob, { ignore: ignore })];
3937
+ case 1:
3938
+ filePaths = _c.sent();
3939
+ _c.label = 2;
3940
+ case 2:
3941
+ _c.trys.push([2, 11, 12, 13]);
3942
+ filePaths_1 = __values(filePaths), filePaths_1_1 = filePaths_1.next();
3943
+ _c.label = 3;
3944
+ case 3:
3945
+ if (!!filePaths_1_1.done) return [3 /*break*/, 10];
3946
+ filePath = filePaths_1_1.value;
3947
+ if (!filePath.endsWith('.ptbk.md')) {
3948
+ console.warn(colors__default["default"].yellow("Skipping prettify of non-promptbook ".concat(filePath)));
3949
+ return [3 /*break*/, 9];
3950
+ }
3951
+ return [4 /*yield*/, promises.readFile(filePath, 'utf-8')];
3952
+ case 4:
3953
+ promptbookMarkdown = (_c.sent());
3954
+ _c.label = 5;
3955
+ case 5:
3956
+ _c.trys.push([5, 8, , 9]);
3957
+ return [4 /*yield*/, prettifyPromptbookString(promptbookMarkdown, {
3958
+ isGraphAdded: true,
3959
+ isPrettifyed: true,
3960
+ // <- [🕌]
3961
+ })];
3962
+ case 6:
3963
+ promptbookMarkdown = _c.sent();
3964
+ return [4 /*yield*/, promises.writeFile(filePath, promptbookMarkdown)];
3965
+ case 7:
3966
+ _c.sent();
3967
+ console.info(colors__default["default"].green("Prettify ".concat(filePath)));
3968
+ return [3 /*break*/, 9];
3969
+ case 8:
3970
+ error_1 = _c.sent();
3971
+ if (!(error_1 instanceof Error)) {
3972
+ throw error_1;
3973
+ }
3974
+ console.info(colors__default["default"].red("Prettify ".concat(error_1.name, " ").concat(filePath)));
3975
+ console.error(colors__default["default"].bgRed(error_1.name));
3976
+ console.error(error_1);
3977
+ process.exit(1);
3978
+ return [3 /*break*/, 9];
3979
+ case 9:
3980
+ filePaths_1_1 = filePaths_1.next();
3981
+ return [3 /*break*/, 3];
3982
+ case 10: return [3 /*break*/, 13];
3983
+ case 11:
3984
+ e_1_1 = _c.sent();
3985
+ e_1 = { error: e_1_1 };
3986
+ return [3 /*break*/, 13];
3987
+ case 12:
3988
+ try {
3989
+ if (filePaths_1_1 && !filePaths_1_1.done && (_b = filePaths_1.return)) _b.call(filePaths_1);
3990
+ }
3991
+ finally { if (e_1) throw e_1.error; }
3992
+ return [7 /*endfinally*/];
3993
+ case 13:
3994
+ process.exit(0);
3995
+ return [2 /*return*/];
3996
+ }
3997
+ });
3998
+ });
3999
+ });
4000
+ }
4001
+
4002
+ /**
4003
+ * Runs CLI utilities of Promptbook package
4004
+ */
4005
+ function promptbookCli() {
3391
4006
  return __awaiter(this, void 0, void 0, function () {
3392
- var program, prettifyCommand, helloCommand;
3393
- var _this = this;
4007
+ var program;
3394
4008
  return __generator(this, function (_a) {
3395
4009
  if (!isRunningInNode()) {
3396
- throw new Error(spaceTrim.spaceTrim("\n Function prettifyPromptbookStringCli is initiator of CLI script and should be run in Node.js environment.\n\n - In browser use prettifyPromptbookString.\n\n "));
4010
+ throw new Error(spaceTrim.spaceTrim("\n Function promptbookCli is initiator of CLI script and should be run in Node.js environment.\n\n - In browser use function exported from `@promptbook/utils` or `@promptbook/core` directly, for example `prettifyPromptbookString`.\n\n "));
3397
4011
  }
3398
4012
  program = new commander__default["default"].Command();
3399
4013
  program.name('promptbook');
3400
4014
  program.version(PROMPTBOOK_VERSION);
3401
- program.description(spaceTrim.spaceTrim("\n Promptbook utilities\n "));
3402
- prettifyCommand = program.command('prettify');
3403
- prettifyCommand.description(spaceTrim.spaceTrim("\n Iterates over promptbooks and does multiple enhancing operations on them:\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
3404
- prettifyCommand.argument('<filesGlob>', 'Promptbooks to prettify as glob pattern');
3405
- prettifyCommand.option('-i, --ignore <glob>', "Ignore as glob pattern");
3406
- prettifyCommand.action(function (filesGlob, _a) {
3407
- var ignore = _a.ignore;
3408
- return __awaiter(_this, void 0, void 0, function () {
3409
- var filePaths, filePaths_1, filePaths_1_1, filePath, promptbookMarkdown, error_1, e_1_1;
3410
- var e_1, _b;
3411
- return __generator(this, function (_c) {
3412
- switch (_c.label) {
3413
- case 0: return [4 /*yield*/, glob__default["default"](filesGlob, { ignore: ignore })];
3414
- case 1:
3415
- filePaths = _c.sent();
3416
- _c.label = 2;
3417
- case 2:
3418
- _c.trys.push([2, 11, 12, 13]);
3419
- filePaths_1 = __values(filePaths), filePaths_1_1 = filePaths_1.next();
3420
- _c.label = 3;
3421
- case 3:
3422
- if (!!filePaths_1_1.done) return [3 /*break*/, 10];
3423
- filePath = filePaths_1_1.value;
3424
- if (!filePath.endsWith('.ptbk.md')) {
3425
- console.warn(colors__default["default"].yellow("Skipping prettify of non-promptbook ".concat(filePath)));
3426
- return [3 /*break*/, 9];
3427
- }
3428
- return [4 /*yield*/, promises.readFile(filePath, 'utf-8')];
3429
- case 4:
3430
- promptbookMarkdown = (_c.sent());
3431
- _c.label = 5;
3432
- case 5:
3433
- _c.trys.push([5, 8, , 9]);
3434
- return [4 /*yield*/, prettifyPromptbookString(promptbookMarkdown, {
3435
- isGraphAdded: true,
3436
- isPrettifyed: true,
3437
- // <- [🕌]
3438
- })];
3439
- case 6:
3440
- promptbookMarkdown = _c.sent();
3441
- return [4 /*yield*/, promises.writeFile(filePath, promptbookMarkdown)];
3442
- case 7:
3443
- _c.sent();
3444
- console.info(colors__default["default"].green("Prettify ".concat(filePath)));
3445
- return [3 /*break*/, 9];
3446
- case 8:
3447
- error_1 = _c.sent();
3448
- if (!(error_1 instanceof Error)) {
3449
- throw error_1;
3450
- }
3451
- console.info(colors__default["default"].red("Prettify ".concat(error_1.name, " ").concat(filePath)));
3452
- console.error(colors__default["default"].bgRed(error_1.name));
3453
- console.error(error_1);
3454
- process.exit(1);
3455
- return [3 /*break*/, 9];
3456
- case 9:
3457
- filePaths_1_1 = filePaths_1.next();
3458
- return [3 /*break*/, 3];
3459
- case 10: return [3 /*break*/, 13];
3460
- case 11:
3461
- e_1_1 = _c.sent();
3462
- e_1 = { error: e_1_1 };
3463
- return [3 /*break*/, 13];
3464
- case 12:
3465
- try {
3466
- if (filePaths_1_1 && !filePaths_1_1.done && (_b = filePaths_1.return)) _b.call(filePaths_1);
3467
- }
3468
- finally { if (e_1) throw e_1.error; }
3469
- return [7 /*endfinally*/];
3470
- case 13:
3471
- process.exit(0);
3472
- return [2 /*return*/];
3473
- }
3474
- });
3475
- });
3476
- });
3477
- helloCommand = program.command('hello');
3478
- helloCommand.description(spaceTrim.spaceTrim("\n Just command for testing\n "));
3479
- helloCommand.argument('<name>', 'Your name');
3480
- helloCommand.option('-g, --greeting <greeting>', "Greeting", 'Hello');
3481
- helloCommand.action(function (name, _a) {
3482
- var greeting = _a.greeting;
3483
- return __awaiter(_this, void 0, void 0, function () {
3484
- return __generator(this, function (_b) {
3485
- switch (_b.label) {
3486
- case 0:
3487
- console.info(colors__default["default"].cyan("".concat(greeting, " ").concat(name)));
3488
- return [4 /*yield*/, waitasecond.forTime(1000)];
3489
- case 1:
3490
- _b.sent();
3491
- console.info(colors__default["default"].rainbow("Nice to meet you!"));
3492
- process.exit(0);
3493
- return [2 /*return*/];
3494
- }
3495
- });
3496
- });
3497
- });
3498
- //------
4015
+ program.description(spaceTrim.spaceTrim("\n Promptbook utilities for enhancing workflow with promptbooks\n "));
4016
+ initializeHello(program);
4017
+ initializeMake(program);
4018
+ initializePrettify(program);
3499
4019
  program.parse(process.argv);
3500
4020
  return [2 /*return*/];
3501
4021
  });
@@ -3511,13 +4031,13 @@
3511
4031
  /**
3512
4032
  * Hidden utilities which should not be used by external consumers.
3513
4033
  */
3514
- var __ = {
4034
+ var __CLI = {
3515
4035
  // Note: [🥠]
3516
- prettifyPromptbookStringCli: prettifyPromptbookStringCli,
4036
+ __initialize: promptbookCli,
3517
4037
  };
3518
4038
 
3519
4039
  exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
3520
- exports.__ = __;
4040
+ exports.__CLI = __CLI;
3521
4041
 
3522
4042
  Object.defineProperty(exports, '__esModule', { value: true });
3523
4043