@promptbook/node 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 (591) hide show
  1. package/esm/index.es.js +426 -410
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/promptbook-library/index.d.ts +25 -0
  4. package/esm/typings/src/_packages/cli.index.d.ts +10 -0
  5. package/{umd/typings → esm/typings/src}/_packages/core.index.d.ts +11 -9
  6. package/esm/typings/src/_packages/node.index.d.ts +4 -0
  7. package/{umd/typings → esm/typings/src}/_packages/types.index.d.ts +4 -3
  8. package/esm/typings/src/cli/actions/hello.d.ts +7 -0
  9. package/esm/typings/src/cli/actions/make.d.ts +7 -0
  10. package/esm/typings/src/cli/actions/prettify.d.ts +7 -0
  11. package/esm/typings/{conversion/prettify/prettifyPromptbookStringCli.d.ts → src/cli/promptbookCli.d.ts} +2 -2
  12. package/esm/typings/{config.d.ts → src/config.d.ts} +4 -0
  13. package/esm/typings/{conversion → src/conversion}/promptbookStringToJson.d.ts +5 -3
  14. package/esm/typings/src/conversion/promptbookStringToJsonSync.d.ts +23 -0
  15. package/{umd/typings/conversion/validation/validatePromptbookJson.d.ts → esm/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
  16. package/esm/typings/src/execution/EmbeddingVector.d.ts +8 -0
  17. package/esm/typings/{execution → src/execution}/LlmExecutionTools.d.ts +1 -0
  18. package/esm/typings/{execution → src/execution}/PromptResult.d.ts +11 -0
  19. package/esm/typings/src/execution/embeddingVectorToString.d.ts +5 -0
  20. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +21 -0
  21. package/esm/typings/{promptbook-library → src/library}/SimplePromptbookLibrary.d.ts +3 -1
  22. package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.d.ts → src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  23. package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  24. package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.d.ts → src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  25. package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromUrl.d.ts → src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  26. package/esm/typings/{promptbook-library/constructors/createPromptbookSublibrary.d.ts → src/library/constructors/createSublibrary.d.ts} +1 -1
  27. package/esm/typings/src/library/libraryToJson.d.ts +8 -0
  28. package/{umd/typings → esm/typings/src}/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -0
  29. package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  30. package/{umd/typings → esm/typings/src}/llm-providers/openai/OpenAiExecutionTools.d.ts +13 -0
  31. package/esm/typings/{llm-providers → src/llm-providers}/openai/computeOpenaiUsage.d.ts +4 -2
  32. package/{umd/typings → esm/typings/src}/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +1 -1
  33. package/esm/typings/{llm-providers → src/llm-providers}/remote/startRemoteServer.d.ts +1 -1
  34. package/{umd/typings → esm/typings/src}/types/ModelRequirements.d.ts +1 -1
  35. package/esm/typings/{types → src/types}/PromptbookJson/KnowledgeJson.d.ts +1 -1
  36. package/esm/typings/{types → src/types}/PromptbookJson/MaterialKnowledgePieceJson.d.ts +4 -3
  37. package/package.json +4 -3
  38. package/umd/index.umd.js +430 -414
  39. package/umd/index.umd.js.map +1 -1
  40. package/umd/typings/promptbook-library/index.d.ts +25 -0
  41. package/umd/typings/src/_packages/cli.index.d.ts +10 -0
  42. package/{esm/typings → umd/typings/src}/_packages/core.index.d.ts +11 -9
  43. package/umd/typings/src/_packages/node.index.d.ts +4 -0
  44. package/{esm/typings → umd/typings/src}/_packages/types.index.d.ts +4 -3
  45. package/umd/typings/src/cli/actions/hello.d.ts +7 -0
  46. package/umd/typings/src/cli/actions/make.d.ts +7 -0
  47. package/umd/typings/src/cli/actions/prettify.d.ts +7 -0
  48. package/umd/typings/{conversion/prettify/prettifyPromptbookStringCli.d.ts → src/cli/promptbookCli.d.ts} +2 -2
  49. package/umd/typings/{config.d.ts → src/config.d.ts} +4 -0
  50. package/umd/typings/{conversion → src/conversion}/promptbookStringToJson.d.ts +5 -3
  51. package/umd/typings/src/conversion/promptbookStringToJsonSync.d.ts +23 -0
  52. package/{esm/typings/conversion/validation/validatePromptbookJson.d.ts → umd/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
  53. package/umd/typings/src/execution/EmbeddingVector.d.ts +8 -0
  54. package/umd/typings/{execution → src/execution}/LlmExecutionTools.d.ts +1 -0
  55. package/umd/typings/{execution → src/execution}/PromptResult.d.ts +11 -0
  56. package/umd/typings/src/execution/embeddingVectorToString.d.ts +5 -0
  57. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +21 -0
  58. package/umd/typings/{promptbook-library → src/library}/SimplePromptbookLibrary.d.ts +3 -1
  59. package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.d.ts → src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  60. package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  61. package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.d.ts → src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  62. package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromUrl.d.ts → src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  63. package/umd/typings/{promptbook-library/constructors/createPromptbookSublibrary.d.ts → src/library/constructors/createSublibrary.d.ts} +1 -1
  64. package/umd/typings/src/library/libraryToJson.d.ts +8 -0
  65. package/{esm/typings → umd/typings/src}/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -0
  66. package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +1 -0
  67. package/{esm/typings → umd/typings/src}/llm-providers/openai/OpenAiExecutionTools.d.ts +13 -0
  68. package/umd/typings/{llm-providers → src/llm-providers}/openai/computeOpenaiUsage.d.ts +4 -2
  69. package/{esm/typings → umd/typings/src}/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +1 -1
  70. package/umd/typings/{llm-providers → src/llm-providers}/remote/startRemoteServer.d.ts +1 -1
  71. package/{esm/typings → umd/typings/src}/types/ModelRequirements.d.ts +1 -1
  72. package/umd/typings/{types → src/types}/PromptbookJson/KnowledgeJson.d.ts +1 -1
  73. package/umd/typings/{types → src/types}/PromptbookJson/MaterialKnowledgePieceJson.d.ts +4 -3
  74. package/umd/typings/src/utils/trimCodeBlock.test.d.ts +1 -0
  75. package/umd/typings/src/utils/trimEndOfCodeBlock.test.d.ts +1 -0
  76. package/umd/typings/src/utils/unwrapResult.test.d.ts +1 -0
  77. package/umd/typings/src/utils/validators/url/isValidUrl.test.d.ts +1 -0
  78. package/esm/typings/_packages/cli.index.d.ts +0 -10
  79. package/esm/typings/_packages/node.index.d.ts +0 -4
  80. package/esm/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +0 -4
  81. package/esm/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -7
  82. package/esm/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  83. package/umd/typings/_packages/cli.index.d.ts +0 -10
  84. package/umd/typings/_packages/node.index.d.ts +0 -4
  85. package/umd/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +0 -4
  86. package/umd/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -7
  87. package/umd/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  88. /package/esm/typings/{_packages → src/_packages}/anthropic-claude.index.d.ts +0 -0
  89. /package/esm/typings/{_packages → src/_packages}/azure-openai.index.d.ts +0 -0
  90. /package/esm/typings/{_packages → src/_packages}/execute-javascript.index.d.ts +0 -0
  91. /package/esm/typings/{_packages → src/_packages}/fake-llm.index.d.ts +0 -0
  92. /package/esm/typings/{_packages → src/_packages}/langtail.index.d.ts +0 -0
  93. /package/esm/typings/{_packages → src/_packages}/openai.index.d.ts +0 -0
  94. /package/esm/typings/{_packages → src/_packages}/remote-client.index.d.ts +0 -0
  95. /package/esm/typings/{_packages → src/_packages}/remote-server.index.d.ts +0 -0
  96. /package/esm/typings/{_packages → src/_packages}/utils.index.d.ts +0 -0
  97. /package/esm/typings/{conversion → src/conversion}/prettify/PrettifyOptions.d.ts +0 -0
  98. /package/esm/typings/{conversion → src/conversion}/prettify/prettifyPromptbookString.d.ts +0 -0
  99. /package/esm/typings/{conversion → src/conversion}/prettify/renderPromptbookMermaid.d.ts +0 -0
  100. /package/esm/typings/{conversion → src/conversion}/promptbookJsonToString.d.ts +0 -0
  101. /package/esm/typings/{conversion → src/conversion}/promptbookStringToJson.test.d.ts +0 -0
  102. /package/esm/typings/{conversion/utils/extractParametersFromPromptTemplate.test.d.ts → src/conversion/promptbookStringToJsonSync.test.d.ts} +0 -0
  103. /package/esm/typings/{conversion → src/conversion}/utils/extractParametersFromPromptTemplate.d.ts +0 -0
  104. /package/{umd/typings → esm/typings/src}/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +0 -0
  105. /package/esm/typings/{conversion → src/conversion}/utils/extractVariables.d.ts +0 -0
  106. /package/esm/typings/{conversion → src/conversion}/utils/extractVariables.test.d.ts +0 -0
  107. /package/esm/typings/{conversion → src/conversion}/utils/parseCommand.d.ts +0 -0
  108. /package/esm/typings/{conversion → src/conversion}/utils/parseCommand.test.d.ts +0 -0
  109. /package/esm/typings/{conversion → src/conversion}/utils/parseNumber.d.ts +0 -0
  110. /package/esm/typings/{conversion → src/conversion}/utils/parseNumber.test.d.ts +0 -0
  111. /package/esm/typings/{conversion → src/conversion}/utils/renameParameter.d.ts +0 -0
  112. /package/esm/typings/{conversion → src/conversion}/utils/renameParameter.test.d.ts +0 -0
  113. /package/esm/typings/{conversion → src/conversion}/utils/titleToName.d.ts +0 -0
  114. /package/esm/typings/{conversion → src/conversion}/utils/titleToName.test.d.ts +0 -0
  115. /package/esm/typings/{conversion → src/conversion}/validation/_importPromptbook.d.ts +0 -0
  116. /package/esm/typings/{conversion → src/conversion}/validation/promptbookStringToJson-syntaxErrors.test.d.ts +0 -0
  117. /package/esm/typings/{conversion/validation/validatePromptbookJson-logicErrors.test.d.ts → src/conversion/validation/validatePromptbook-logicErrors.test.d.ts} +0 -0
  118. /package/esm/typings/{conversion/validation/validatePromptbookJson.test.d.ts → src/conversion/validation/validatePromptbook.test.d.ts} +0 -0
  119. /package/esm/typings/{errors → src/errors}/PromptbookExecutionError.d.ts +0 -0
  120. /package/esm/typings/{errors → src/errors}/PromptbookLibraryError.d.ts +0 -0
  121. /package/esm/typings/{errors → src/errors}/PromptbookLogicError.d.ts +0 -0
  122. /package/esm/typings/{errors → src/errors}/PromptbookNotFoundError.d.ts +0 -0
  123. /package/esm/typings/{errors → src/errors}/PromptbookReferenceError.d.ts +0 -0
  124. /package/esm/typings/{errors → src/errors}/PromptbookSyntaxError.d.ts +0 -0
  125. /package/esm/typings/{errors → src/errors}/TemplateError.d.ts +0 -0
  126. /package/esm/typings/{errors → src/errors}/UnexpectedError.d.ts +0 -0
  127. /package/esm/typings/{errors → src/errors}/_ExpectError.d.ts +0 -0
  128. /package/esm/typings/{execution → src/execution}/CommonExecutionToolsOptions.d.ts +0 -0
  129. /package/esm/typings/{execution → src/execution}/ExecutionTools.d.ts +0 -0
  130. /package/esm/typings/{execution → src/execution}/PromptbookExecutor.d.ts +0 -0
  131. /package/esm/typings/{execution → src/execution}/ScriptExecutionTools.d.ts +0 -0
  132. /package/esm/typings/{execution → src/execution}/UserInterfaceTools.d.ts +0 -0
  133. /package/esm/typings/{execution → src/execution}/addPromptResultUsage.test.d.ts +0 -0
  134. /package/esm/typings/{execution → src/execution}/assertsExecutionSuccessful.d.ts +0 -0
  135. /package/esm/typings/{execution → src/execution}/createPromptbookExecutor.d.ts +0 -0
  136. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +0 -0
  137. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +0 -0
  138. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +0 -0
  139. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +0 -0
  140. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +0 -0
  141. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +0 -0
  142. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +0 -0
  143. /package/esm/typings/{execution → src/execution}/translation/automatic-translate/translateMessages.d.ts +0 -0
  144. /package/esm/typings/{execution → src/execution}/utils/addUsage.d.ts +0 -0
  145. /package/esm/typings/{execution → src/execution}/utils/addUsage.test.d.ts +0 -0
  146. /package/esm/typings/{execution → src/execution}/utils/checkExpectations.d.ts +0 -0
  147. /package/esm/typings/{execution → src/execution}/utils/checkExpectations.test.d.ts +0 -0
  148. /package/esm/typings/{execution → src/execution}/utils/computeUsageCounts.d.ts +0 -0
  149. /package/esm/typings/{execution → src/execution}/utils/forEachAsync.d.ts +0 -0
  150. /package/esm/typings/{execution → src/execution}/utils/replaceParameters.d.ts +0 -0
  151. /package/esm/typings/{execution → src/execution}/utils/replaceParameters.test.d.ts +0 -0
  152. /package/esm/typings/{execution → src/execution}/utils/uncertainNumber.d.ts +0 -0
  153. /package/esm/typings/{execution → src/execution}/utils/usageToWorktime.d.ts +0 -0
  154. /package/esm/typings/{execution → src/execution}/utils/usageToWorktime.test.d.ts +0 -0
  155. /package/esm/typings/{expectations → src/expectations}/drafts/isDomainNameFree.d.ts +0 -0
  156. /package/esm/typings/{expectations → src/expectations}/drafts/isGithubNameFree.d.ts +0 -0
  157. /package/esm/typings/{formats → src/formats}/_common/FormatDefinition.d.ts +0 -0
  158. /package/esm/typings/{formats → src/formats}/csv/ListFormatDefinition.d.ts +0 -0
  159. /package/esm/typings/{formats → src/formats}/index.d.ts +0 -0
  160. /package/esm/typings/{formats → src/formats}/json/JsonFormatDefinition.d.ts +0 -0
  161. /package/esm/typings/{formats → src/formats}/json/utils/isValidJsonString.d.ts +0 -0
  162. /package/esm/typings/{formats → src/formats}/json/utils/isValidJsonString.test.d.ts +0 -0
  163. /package/esm/typings/{formats → src/formats}/list/ListFormatDefinition.d.ts +0 -0
  164. /package/esm/typings/{formats → src/formats}/xml/XmlFormatDefinition.d.ts +0 -0
  165. /package/esm/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceTools.d.ts +0 -0
  166. /package/esm/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +0 -0
  167. /package/esm/typings/{knowledge → src/knowledge}/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +0 -0
  168. /package/esm/typings/{knowledge → src/knowledge}/dialogs/user-interface-execution-tools.test.d.ts +0 -0
  169. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -0
  170. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +0 -0
  171. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -0
  172. /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +0 -0
  173. /package/esm/typings/{promptbook-library → src/library}/PromptbookLibrary.d.ts +0 -0
  174. /package/esm/typings/{llm-providers/mocked/fakeTextToExpectations.test.d.ts → src/library/constructors/createLibraryFromDirectory.test.d.ts} +0 -0
  175. /package/esm/typings/{llm-providers/mocked/faked-completion.test.d.ts → src/library/constructors/createLibraryFromJson.test.d.ts} +0 -0
  176. /package/esm/typings/{llm-providers/openai/computeUsage.test.d.ts → src/library/constructors/createLibraryFromPromise.test.d.ts} +0 -0
  177. /package/esm/typings/{promptbook-library → src/library}/constructors/justTestFsImport.d.ts +0 -0
  178. /package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → src/library/libraryToJson.test.d.ts} +0 -0
  179. /package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +0 -0
  180. /package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  181. /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -0
  182. /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +0 -0
  183. /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  184. /package/esm/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionTools.d.ts +0 -0
  185. /package/esm/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  186. /package/esm/typings/{llm-providers → src/llm-providers}/langtail/playground/playground.d.ts +0 -0
  187. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +0 -0
  188. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +0 -0
  189. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/fakeTextToExpectations.d.ts +0 -0
  190. /package/{umd/typings → esm/typings/src}/llm-providers/mocked/fakeTextToExpectations.test.d.ts +0 -0
  191. /package/{umd/typings → esm/typings/src}/llm-providers/mocked/faked-completion.test.d.ts +0 -0
  192. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/joker.test.d.ts +0 -0
  193. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  194. /package/esm/typings/{llm-providers → src/llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  195. /package/esm/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +0 -0
  196. /package/esm/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -0
  197. /package/esm/typings/{llm-providers → src/llm-providers}/multiple/playground/playground.d.ts +0 -0
  198. /package/esm/typings/{llm-providers → src/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
  199. /package/esm/typings/{llm-providers → src/llm-providers}/openai/computeUsage.d.ts +0 -0
  200. /package/{umd/typings → esm/typings/src}/llm-providers/openai/computeUsage.test.d.ts +0 -0
  201. /package/esm/typings/{llm-providers → src/llm-providers}/openai/openai-models.d.ts +0 -0
  202. /package/esm/typings/{llm-providers → src/llm-providers}/openai/playground/playground.d.ts +0 -0
  203. /package/esm/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionTools.d.ts +0 -0
  204. /package/esm/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +0 -0
  205. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  206. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
  207. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
  208. /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
  209. /package/esm/typings/{scripting → src/scripting}/_test/custom-function-async.test.ts.test.d.ts +0 -0
  210. /package/esm/typings/{scripting → src/scripting}/_test/custom-function-missing.test.d.ts +0 -0
  211. /package/esm/typings/{scripting → src/scripting}/_test/custom-function-with-dependencies.test.d.ts +0 -0
  212. /package/esm/typings/{scripting → src/scripting}/_test/custom-function.test.d.ts +0 -0
  213. /package/esm/typings/{scripting → src/scripting}/_test/postprocessing.test.d.ts +0 -0
  214. /package/esm/typings/{scripting → src/scripting}/_test/script-execution-errors.test.d.ts +0 -0
  215. /package/esm/typings/{scripting → src/scripting}/_test/script-execution-tools.test.d.ts +0 -0
  216. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.d.ts +0 -0
  217. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  218. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  219. /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +0 -0
  220. /package/esm/typings/{scripting → src/scripting}/javascript/utils/preserve.d.ts +0 -0
  221. /package/esm/typings/{scripting → src/scripting}/javascript/utils/unknownToString.d.ts +0 -0
  222. /package/esm/typings/{scripting → src/scripting}/python/PythonExecutionTools.d.ts +0 -0
  223. /package/esm/typings/{scripting → src/scripting}/typescript/TypescriptExecutionTools.d.ts +0 -0
  224. /package/esm/typings/{types → src/types}/Command.d.ts +0 -0
  225. /package/esm/typings/{types → src/types}/ExecutionTypes.d.ts +0 -0
  226. /package/esm/typings/{types → src/types}/Parameters.d.ts +0 -0
  227. /package/esm/typings/{types → src/types}/Prompt.d.ts +0 -0
  228. /package/esm/typings/{types → src/types}/PromptbookJson/PromptTemplateJson.d.ts +0 -0
  229. /package/esm/typings/{types → src/types}/PromptbookJson/PromptTemplateParameterJson.d.ts +0 -0
  230. /package/esm/typings/{types → src/types}/PromptbookJson/PromptbookJson.d.ts +0 -0
  231. /package/esm/typings/{types → src/types}/PromptbookString.d.ts +0 -0
  232. /package/esm/typings/{types → src/types}/ScriptLanguage.d.ts +0 -0
  233. /package/esm/typings/{types → src/types}/TaskProgress.d.ts +0 -0
  234. /package/esm/typings/{types → src/types}/execution-report/ExecutionReportJson.d.ts +0 -0
  235. /package/esm/typings/{types → src/types}/execution-report/ExecutionReportString.d.ts +0 -0
  236. /package/esm/typings/{types → src/types}/execution-report/ExecutionReportStringOptions.d.ts +0 -0
  237. /package/esm/typings/{types → src/types}/execution-report/config.d.ts +0 -0
  238. /package/esm/typings/{types → src/types}/execution-report/countWorkingDuration.d.ts +0 -0
  239. /package/esm/typings/{types → src/types}/execution-report/countWorkingDuration.test.d.ts +0 -0
  240. /package/esm/typings/{types → src/types}/execution-report/executionReportJsonToString.d.ts +0 -0
  241. /package/esm/typings/{types → src/types}/typeAliasEmoji.d.ts +0 -0
  242. /package/esm/typings/{types → src/types}/typeAliases.d.ts +0 -0
  243. /package/esm/typings/{utils → src/utils}/FromtoItems.d.ts +0 -0
  244. /package/esm/typings/{utils → src/utils}/emojis.d.ts +0 -0
  245. /package/esm/typings/{utils → src/utils}/expectation-counters/countCharacters.d.ts +0 -0
  246. /package/esm/typings/{utils → src/utils}/expectation-counters/countCharacters.test.d.ts +0 -0
  247. /package/esm/typings/{utils → src/utils}/expectation-counters/countLines.d.ts +0 -0
  248. /package/esm/typings/{utils → src/utils}/expectation-counters/countLines.test.d.ts +0 -0
  249. /package/esm/typings/{utils → src/utils}/expectation-counters/countPages.d.ts +0 -0
  250. /package/esm/typings/{utils → src/utils}/expectation-counters/countPages.test.d.ts +0 -0
  251. /package/esm/typings/{utils → src/utils}/expectation-counters/countParagraphs.d.ts +0 -0
  252. /package/esm/typings/{utils → src/utils}/expectation-counters/countParagraphs.test.d.ts +0 -0
  253. /package/esm/typings/{utils → src/utils}/expectation-counters/countSentences.d.ts +0 -0
  254. /package/esm/typings/{utils → src/utils}/expectation-counters/countSentences.test.d.ts +0 -0
  255. /package/esm/typings/{utils → src/utils}/expectation-counters/countWords.d.ts +0 -0
  256. /package/esm/typings/{utils → src/utils}/expectation-counters/countWords.test.d.ts +0 -0
  257. /package/esm/typings/{utils → src/utils}/expectation-counters/index.d.ts +0 -0
  258. /package/esm/typings/{utils → src/utils}/extractParameters.d.ts +0 -0
  259. /package/esm/typings/{utils → src/utils}/extractParameters.test.d.ts +0 -0
  260. /package/esm/typings/{utils → src/utils}/formatNumber.d.ts +0 -0
  261. /package/esm/typings/{utils → src/utils}/formatNumber.test.d.ts +0 -0
  262. /package/esm/typings/{utils → src/utils}/getCurrentIsoDate.d.ts +0 -0
  263. /package/esm/typings/{utils → src/utils}/isRunningInWhatever.d.ts +0 -0
  264. /package/esm/typings/{utils → src/utils}/just.d.ts +0 -0
  265. /package/esm/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.d.ts +0 -0
  266. /package/esm/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.test.d.ts +0 -0
  267. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownChart.d.ts +0 -0
  268. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownChart.test.d.ts +0 -0
  269. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownTable.d.ts +0 -0
  270. /package/esm/typings/{utils → src/utils}/markdown/createMarkdownTable.test.d.ts +0 -0
  271. /package/esm/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.d.ts +0 -0
  272. /package/esm/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.test.d.ts +0 -0
  273. /package/esm/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.d.ts +0 -0
  274. /package/esm/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.test.d.ts +0 -0
  275. /package/esm/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.d.ts +0 -0
  276. /package/esm/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.test.d.ts +0 -0
  277. /package/esm/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.d.ts +0 -0
  278. /package/esm/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.test.d.ts +0 -0
  279. /package/esm/typings/{utils → src/utils}/markdown/prettifyMarkdown.d.ts +0 -0
  280. /package/esm/typings/{utils → src/utils}/markdown/prettifyMarkdown.test.d.ts +0 -0
  281. /package/esm/typings/{utils → src/utils}/markdown/removeContentComments.d.ts +0 -0
  282. /package/esm/typings/{utils → src/utils}/markdown/removeContentComments.test.d.ts +0 -0
  283. /package/esm/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.d.ts +0 -0
  284. /package/esm/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.test.d.ts +0 -0
  285. /package/esm/typings/{utils → src/utils}/markdown-json/MarkdownStructure.d.ts +0 -0
  286. /package/esm/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.d.ts +0 -0
  287. /package/esm/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.test.d.ts +0 -0
  288. /package/esm/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.d.ts +0 -0
  289. /package/esm/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.test.d.ts +0 -0
  290. /package/esm/typings/{utils → src/utils}/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +0 -0
  291. /package/esm/typings/{utils → src/utils}/normalization/IKeywords.d.ts +0 -0
  292. /package/esm/typings/{utils → src/utils}/normalization/capitalize.d.ts +0 -0
  293. /package/esm/typings/{utils → src/utils}/normalization/capitalize.test.d.ts +0 -0
  294. /package/esm/typings/{utils → src/utils}/normalization/decapitalize.d.ts +0 -0
  295. /package/esm/typings/{utils → src/utils}/normalization/decapitalize.test.d.ts +0 -0
  296. /package/esm/typings/{utils → src/utils}/normalization/isValidKeyword.d.ts +0 -0
  297. /package/esm/typings/{utils → src/utils}/normalization/isValidKeyword.test.d.ts +0 -0
  298. /package/esm/typings/{utils → src/utils}/normalization/nameToUriPart.d.ts +0 -0
  299. /package/esm/typings/{utils → src/utils}/normalization/nameToUriPart.test.d.ts +0 -0
  300. /package/esm/typings/{utils → src/utils}/normalization/nameToUriParts.d.ts +0 -0
  301. /package/esm/typings/{utils → src/utils}/normalization/nameToUriParts.test.d.ts +0 -0
  302. /package/esm/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.d.ts +0 -0
  303. /package/esm/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.test.d.ts +0 -0
  304. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.d.ts +0 -0
  305. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.test.d.ts +0 -0
  306. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.d.ts +0 -0
  307. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +0 -0
  308. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.d.ts +0 -0
  309. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.test.d.ts +0 -0
  310. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.d.ts +0 -0
  311. /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.test.d.ts +0 -0
  312. /package/esm/typings/{utils → src/utils}/normalization/normalizeWhitespaces.d.ts +0 -0
  313. /package/esm/typings/{utils → src/utils}/normalization/normalizeWhitespaces.test.d.ts +0 -0
  314. /package/esm/typings/{utils → src/utils}/normalization/parseKeywords.d.ts +0 -0
  315. /package/esm/typings/{utils → src/utils}/normalization/parseKeywords.test.d.ts +0 -0
  316. /package/esm/typings/{utils → src/utils}/normalization/parseKeywordsFromString.d.ts +0 -0
  317. /package/esm/typings/{utils → src/utils}/normalization/parseKeywordsFromString.test.d.ts +0 -0
  318. /package/esm/typings/{utils → src/utils}/normalization/removeDiacritics.d.ts +0 -0
  319. /package/esm/typings/{utils → src/utils}/normalization/removeDiacritics.test.d.ts +0 -0
  320. /package/esm/typings/{utils → src/utils}/normalization/searchKeywords.d.ts +0 -0
  321. /package/esm/typings/{utils → src/utils}/normalization/searchKeywords.test.d.ts +0 -0
  322. /package/esm/typings/{utils → src/utils}/postprocessing/extractBlock.d.ts +0 -0
  323. /package/esm/typings/{utils → src/utils}/removeEmojis.d.ts +0 -0
  324. /package/esm/typings/{utils → src/utils}/removeEmojis.test.d.ts +0 -0
  325. /package/esm/typings/{utils → src/utils}/removeQuotes.d.ts +0 -0
  326. /package/esm/typings/{utils → src/utils}/removeQuotes.test.d.ts +0 -0
  327. /package/esm/typings/{utils → src/utils}/sets/difference.d.ts +0 -0
  328. /package/esm/typings/{utils → src/utils}/sets/difference.test.d.ts +0 -0
  329. /package/esm/typings/{utils → src/utils}/sets/intersection.d.ts +0 -0
  330. /package/esm/typings/{utils → src/utils}/sets/intersection.test.d.ts +0 -0
  331. /package/esm/typings/{utils → src/utils}/sets/union.d.ts +0 -0
  332. /package/esm/typings/{utils → src/utils}/sets/union.test.d.ts +0 -0
  333. /package/esm/typings/{utils → src/utils}/trimCodeBlock.d.ts +0 -0
  334. /package/esm/typings/{utils → src/utils}/trimCodeBlock.test.d.ts +0 -0
  335. /package/esm/typings/{utils → src/utils}/trimEndOfCodeBlock.d.ts +0 -0
  336. /package/esm/typings/{utils → src/utils}/trimEndOfCodeBlock.test.d.ts +0 -0
  337. /package/esm/typings/{utils → src/utils}/unwrapResult.d.ts +0 -0
  338. /package/esm/typings/{utils → src/utils}/unwrapResult.test.d.ts +0 -0
  339. /package/esm/typings/{utils → src/utils}/validators/url/isValidUrl.d.ts +0 -0
  340. /package/esm/typings/{utils → src/utils}/validators/url/isValidUrl.test.d.ts +0 -0
  341. /package/esm/typings/{version.d.ts → src/version.d.ts} +0 -0
  342. /package/umd/typings/{_packages → src/_packages}/anthropic-claude.index.d.ts +0 -0
  343. /package/umd/typings/{_packages → src/_packages}/azure-openai.index.d.ts +0 -0
  344. /package/umd/typings/{_packages → src/_packages}/execute-javascript.index.d.ts +0 -0
  345. /package/umd/typings/{_packages → src/_packages}/fake-llm.index.d.ts +0 -0
  346. /package/umd/typings/{_packages → src/_packages}/langtail.index.d.ts +0 -0
  347. /package/umd/typings/{_packages → src/_packages}/openai.index.d.ts +0 -0
  348. /package/umd/typings/{_packages → src/_packages}/remote-client.index.d.ts +0 -0
  349. /package/umd/typings/{_packages → src/_packages}/remote-server.index.d.ts +0 -0
  350. /package/umd/typings/{_packages → src/_packages}/utils.index.d.ts +0 -0
  351. /package/umd/typings/{conversion → src/conversion}/prettify/PrettifyOptions.d.ts +0 -0
  352. /package/umd/typings/{conversion → src/conversion}/prettify/prettifyPromptbookString.d.ts +0 -0
  353. /package/umd/typings/{conversion → src/conversion}/prettify/renderPromptbookMermaid.d.ts +0 -0
  354. /package/umd/typings/{conversion → src/conversion}/promptbookJsonToString.d.ts +0 -0
  355. /package/umd/typings/{conversion → src/conversion}/promptbookStringToJson.test.d.ts +0 -0
  356. /package/{esm/typings/promptbook-library/constructors/createPromptbookLibraryFromPromise.test.d.ts → umd/typings/src/conversion/promptbookStringToJsonSync.test.d.ts} +0 -0
  357. /package/umd/typings/{conversion → src/conversion}/utils/extractParametersFromPromptTemplate.d.ts +0 -0
  358. /package/{esm/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.test.d.ts → umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts} +0 -0
  359. /package/umd/typings/{conversion → src/conversion}/utils/extractVariables.d.ts +0 -0
  360. /package/umd/typings/{conversion → src/conversion}/utils/extractVariables.test.d.ts +0 -0
  361. /package/umd/typings/{conversion → src/conversion}/utils/parseCommand.d.ts +0 -0
  362. /package/umd/typings/{conversion → src/conversion}/utils/parseCommand.test.d.ts +0 -0
  363. /package/umd/typings/{conversion → src/conversion}/utils/parseNumber.d.ts +0 -0
  364. /package/umd/typings/{conversion → src/conversion}/utils/parseNumber.test.d.ts +0 -0
  365. /package/umd/typings/{conversion → src/conversion}/utils/renameParameter.d.ts +0 -0
  366. /package/umd/typings/{conversion → src/conversion}/utils/renameParameter.test.d.ts +0 -0
  367. /package/umd/typings/{conversion → src/conversion}/utils/titleToName.d.ts +0 -0
  368. /package/umd/typings/{conversion → src/conversion}/utils/titleToName.test.d.ts +0 -0
  369. /package/umd/typings/{conversion → src/conversion}/validation/_importPromptbook.d.ts +0 -0
  370. /package/umd/typings/{conversion → src/conversion}/validation/promptbookStringToJson-syntaxErrors.test.d.ts +0 -0
  371. /package/umd/typings/{conversion/validation/validatePromptbookJson-logicErrors.test.d.ts → src/conversion/validation/validatePromptbook-logicErrors.test.d.ts} +0 -0
  372. /package/umd/typings/{conversion/validation/validatePromptbookJson.test.d.ts → src/conversion/validation/validatePromptbook.test.d.ts} +0 -0
  373. /package/umd/typings/{errors → src/errors}/PromptbookExecutionError.d.ts +0 -0
  374. /package/umd/typings/{errors → src/errors}/PromptbookLibraryError.d.ts +0 -0
  375. /package/umd/typings/{errors → src/errors}/PromptbookLogicError.d.ts +0 -0
  376. /package/umd/typings/{errors → src/errors}/PromptbookNotFoundError.d.ts +0 -0
  377. /package/umd/typings/{errors → src/errors}/PromptbookReferenceError.d.ts +0 -0
  378. /package/umd/typings/{errors → src/errors}/PromptbookSyntaxError.d.ts +0 -0
  379. /package/umd/typings/{errors → src/errors}/TemplateError.d.ts +0 -0
  380. /package/umd/typings/{errors → src/errors}/UnexpectedError.d.ts +0 -0
  381. /package/umd/typings/{errors → src/errors}/_ExpectError.d.ts +0 -0
  382. /package/umd/typings/{execution → src/execution}/CommonExecutionToolsOptions.d.ts +0 -0
  383. /package/umd/typings/{execution → src/execution}/ExecutionTools.d.ts +0 -0
  384. /package/umd/typings/{execution → src/execution}/PromptbookExecutor.d.ts +0 -0
  385. /package/umd/typings/{execution → src/execution}/ScriptExecutionTools.d.ts +0 -0
  386. /package/umd/typings/{execution → src/execution}/UserInterfaceTools.d.ts +0 -0
  387. /package/umd/typings/{execution → src/execution}/addPromptResultUsage.test.d.ts +0 -0
  388. /package/umd/typings/{execution → src/execution}/assertsExecutionSuccessful.d.ts +0 -0
  389. /package/umd/typings/{execution → src/execution}/createPromptbookExecutor.d.ts +0 -0
  390. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +0 -0
  391. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +0 -0
  392. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +0 -0
  393. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +0 -0
  394. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +0 -0
  395. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +0 -0
  396. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +0 -0
  397. /package/umd/typings/{execution → src/execution}/translation/automatic-translate/translateMessages.d.ts +0 -0
  398. /package/umd/typings/{execution → src/execution}/utils/addUsage.d.ts +0 -0
  399. /package/umd/typings/{execution → src/execution}/utils/addUsage.test.d.ts +0 -0
  400. /package/umd/typings/{execution → src/execution}/utils/checkExpectations.d.ts +0 -0
  401. /package/umd/typings/{execution → src/execution}/utils/checkExpectations.test.d.ts +0 -0
  402. /package/umd/typings/{execution → src/execution}/utils/computeUsageCounts.d.ts +0 -0
  403. /package/umd/typings/{execution → src/execution}/utils/forEachAsync.d.ts +0 -0
  404. /package/umd/typings/{execution → src/execution}/utils/replaceParameters.d.ts +0 -0
  405. /package/umd/typings/{execution → src/execution}/utils/replaceParameters.test.d.ts +0 -0
  406. /package/umd/typings/{execution → src/execution}/utils/uncertainNumber.d.ts +0 -0
  407. /package/umd/typings/{execution → src/execution}/utils/usageToWorktime.d.ts +0 -0
  408. /package/umd/typings/{execution → src/execution}/utils/usageToWorktime.test.d.ts +0 -0
  409. /package/umd/typings/{expectations → src/expectations}/drafts/isDomainNameFree.d.ts +0 -0
  410. /package/umd/typings/{expectations → src/expectations}/drafts/isGithubNameFree.d.ts +0 -0
  411. /package/umd/typings/{formats → src/formats}/_common/FormatDefinition.d.ts +0 -0
  412. /package/umd/typings/{formats → src/formats}/csv/ListFormatDefinition.d.ts +0 -0
  413. /package/umd/typings/{formats → src/formats}/index.d.ts +0 -0
  414. /package/umd/typings/{formats → src/formats}/json/JsonFormatDefinition.d.ts +0 -0
  415. /package/umd/typings/{formats → src/formats}/json/utils/isValidJsonString.d.ts +0 -0
  416. /package/umd/typings/{formats → src/formats}/json/utils/isValidJsonString.test.d.ts +0 -0
  417. /package/umd/typings/{formats → src/formats}/list/ListFormatDefinition.d.ts +0 -0
  418. /package/umd/typings/{formats → src/formats}/xml/XmlFormatDefinition.d.ts +0 -0
  419. /package/umd/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceTools.d.ts +0 -0
  420. /package/umd/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +0 -0
  421. /package/umd/typings/{knowledge → src/knowledge}/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +0 -0
  422. /package/umd/typings/{knowledge → src/knowledge}/dialogs/user-interface-execution-tools.test.d.ts +0 -0
  423. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -0
  424. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +0 -0
  425. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -0
  426. /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +0 -0
  427. /package/umd/typings/{promptbook-library → src/library}/PromptbookLibrary.d.ts +0 -0
  428. /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → src/library/constructors/createLibraryFromDirectory.test.d.ts} +0 -0
  429. /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.test.d.ts → src/library/constructors/createLibraryFromJson.test.d.ts} +0 -0
  430. /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromSources.test.d.ts → src/library/constructors/createLibraryFromPromise.test.d.ts} +0 -0
  431. /package/umd/typings/{promptbook-library → src/library}/constructors/justTestFsImport.d.ts +0 -0
  432. /package/umd/typings/{scripting/_test/custom-function-async.test.ts.test.d.ts → src/library/libraryToJson.test.d.ts} +0 -0
  433. /package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +0 -0
  434. /package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
  435. /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -0
  436. /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +0 -0
  437. /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/playground/playground.d.ts +0 -0
  438. /package/umd/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionTools.d.ts +0 -0
  439. /package/umd/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
  440. /package/umd/typings/{llm-providers → src/llm-providers}/langtail/playground/playground.d.ts +0 -0
  441. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +0 -0
  442. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +0 -0
  443. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/fakeTextToExpectations.d.ts +0 -0
  444. /package/umd/typings/{scripting/_test/custom-function-missing.test.d.ts → src/llm-providers/mocked/fakeTextToExpectations.test.d.ts} +0 -0
  445. /package/umd/typings/{scripting/_test/custom-function-with-dependencies.test.d.ts → src/llm-providers/mocked/faked-completion.test.d.ts} +0 -0
  446. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/joker.test.d.ts +0 -0
  447. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
  448. /package/umd/typings/{llm-providers → src/llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
  449. /package/umd/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +0 -0
  450. /package/umd/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -0
  451. /package/umd/typings/{llm-providers → src/llm-providers}/multiple/playground/playground.d.ts +0 -0
  452. /package/umd/typings/{llm-providers → src/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
  453. /package/umd/typings/{llm-providers → src/llm-providers}/openai/computeUsage.d.ts +0 -0
  454. /package/umd/typings/{scripting/_test/custom-function.test.d.ts → src/llm-providers/openai/computeUsage.test.d.ts} +0 -0
  455. /package/umd/typings/{llm-providers → src/llm-providers}/openai/openai-models.d.ts +0 -0
  456. /package/umd/typings/{llm-providers → src/llm-providers}/openai/playground/playground.d.ts +0 -0
  457. /package/umd/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionTools.d.ts +0 -0
  458. /package/umd/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +0 -0
  459. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
  460. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
  461. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
  462. /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
  463. /package/umd/typings/{scripting/_test/postprocessing.test.d.ts → src/scripting/_test/custom-function-async.test.ts.test.d.ts} +0 -0
  464. /package/umd/typings/{scripting/_test/script-execution-errors.test.d.ts → src/scripting/_test/custom-function-missing.test.d.ts} +0 -0
  465. /package/umd/typings/{scripting/_test/script-execution-tools.test.d.ts → src/scripting/_test/custom-function-with-dependencies.test.d.ts} +0 -0
  466. /package/umd/typings/{types/execution-report/countWorkingDuration.test.d.ts → src/scripting/_test/custom-function.test.d.ts} +0 -0
  467. /package/umd/typings/{utils/expectation-counters/countCharacters.test.d.ts → src/scripting/_test/postprocessing.test.d.ts} +0 -0
  468. /package/umd/typings/{utils/expectation-counters/countLines.test.d.ts → src/scripting/_test/script-execution-errors.test.d.ts} +0 -0
  469. /package/umd/typings/{utils/expectation-counters/countPages.test.d.ts → src/scripting/_test/script-execution-tools.test.d.ts} +0 -0
  470. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.d.ts +0 -0
  471. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
  472. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
  473. /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +0 -0
  474. /package/umd/typings/{scripting → src/scripting}/javascript/utils/preserve.d.ts +0 -0
  475. /package/umd/typings/{scripting → src/scripting}/javascript/utils/unknownToString.d.ts +0 -0
  476. /package/umd/typings/{scripting → src/scripting}/python/PythonExecutionTools.d.ts +0 -0
  477. /package/umd/typings/{scripting → src/scripting}/typescript/TypescriptExecutionTools.d.ts +0 -0
  478. /package/umd/typings/{types → src/types}/Command.d.ts +0 -0
  479. /package/umd/typings/{types → src/types}/ExecutionTypes.d.ts +0 -0
  480. /package/umd/typings/{types → src/types}/Parameters.d.ts +0 -0
  481. /package/umd/typings/{types → src/types}/Prompt.d.ts +0 -0
  482. /package/umd/typings/{types → src/types}/PromptbookJson/PromptTemplateJson.d.ts +0 -0
  483. /package/umd/typings/{types → src/types}/PromptbookJson/PromptTemplateParameterJson.d.ts +0 -0
  484. /package/umd/typings/{types → src/types}/PromptbookJson/PromptbookJson.d.ts +0 -0
  485. /package/umd/typings/{types → src/types}/PromptbookString.d.ts +0 -0
  486. /package/umd/typings/{types → src/types}/ScriptLanguage.d.ts +0 -0
  487. /package/umd/typings/{types → src/types}/TaskProgress.d.ts +0 -0
  488. /package/umd/typings/{types → src/types}/execution-report/ExecutionReportJson.d.ts +0 -0
  489. /package/umd/typings/{types → src/types}/execution-report/ExecutionReportString.d.ts +0 -0
  490. /package/umd/typings/{types → src/types}/execution-report/ExecutionReportStringOptions.d.ts +0 -0
  491. /package/umd/typings/{types → src/types}/execution-report/config.d.ts +0 -0
  492. /package/umd/typings/{types → src/types}/execution-report/countWorkingDuration.d.ts +0 -0
  493. /package/umd/typings/{utils/expectation-counters/countParagraphs.test.d.ts → src/types/execution-report/countWorkingDuration.test.d.ts} +0 -0
  494. /package/umd/typings/{types → src/types}/execution-report/executionReportJsonToString.d.ts +0 -0
  495. /package/umd/typings/{types → src/types}/typeAliasEmoji.d.ts +0 -0
  496. /package/umd/typings/{types → src/types}/typeAliases.d.ts +0 -0
  497. /package/umd/typings/{utils → src/utils}/FromtoItems.d.ts +0 -0
  498. /package/umd/typings/{utils → src/utils}/emojis.d.ts +0 -0
  499. /package/umd/typings/{utils → src/utils}/expectation-counters/countCharacters.d.ts +0 -0
  500. /package/umd/typings/{utils/expectation-counters/countSentences.test.d.ts → src/utils/expectation-counters/countCharacters.test.d.ts} +0 -0
  501. /package/umd/typings/{utils → src/utils}/expectation-counters/countLines.d.ts +0 -0
  502. /package/umd/typings/{utils/expectation-counters/countWords.test.d.ts → src/utils/expectation-counters/countLines.test.d.ts} +0 -0
  503. /package/umd/typings/{utils → src/utils}/expectation-counters/countPages.d.ts +0 -0
  504. /package/umd/typings/{utils/extractParameters.test.d.ts → src/utils/expectation-counters/countPages.test.d.ts} +0 -0
  505. /package/umd/typings/{utils → src/utils}/expectation-counters/countParagraphs.d.ts +0 -0
  506. /package/umd/typings/{utils/formatNumber.test.d.ts → src/utils/expectation-counters/countParagraphs.test.d.ts} +0 -0
  507. /package/umd/typings/{utils → src/utils}/expectation-counters/countSentences.d.ts +0 -0
  508. /package/umd/typings/{utils/markdown-json/countMarkdownStructureDeepness.test.d.ts → src/utils/expectation-counters/countSentences.test.d.ts} +0 -0
  509. /package/umd/typings/{utils → src/utils}/expectation-counters/countWords.d.ts +0 -0
  510. /package/umd/typings/{utils/markdown-json/markdownToMarkdownStructure.test.d.ts → src/utils/expectation-counters/countWords.test.d.ts} +0 -0
  511. /package/umd/typings/{utils → src/utils}/expectation-counters/index.d.ts +0 -0
  512. /package/umd/typings/{utils → src/utils}/extractParameters.d.ts +0 -0
  513. /package/umd/typings/{utils/markdown/addAutoGeneratedSection.test.d.ts → src/utils/extractParameters.test.d.ts} +0 -0
  514. /package/umd/typings/{utils → src/utils}/formatNumber.d.ts +0 -0
  515. /package/umd/typings/{utils/markdown/createMarkdownChart.test.d.ts → src/utils/formatNumber.test.d.ts} +0 -0
  516. /package/umd/typings/{utils → src/utils}/getCurrentIsoDate.d.ts +0 -0
  517. /package/umd/typings/{utils → src/utils}/isRunningInWhatever.d.ts +0 -0
  518. /package/umd/typings/{utils → src/utils}/just.d.ts +0 -0
  519. /package/umd/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.d.ts +0 -0
  520. /package/umd/typings/{utils/markdown/extractAllBlocksFromMarkdown.test.d.ts → src/utils/markdown/addAutoGeneratedSection.test.d.ts} +0 -0
  521. /package/umd/typings/{utils → src/utils}/markdown/createMarkdownChart.d.ts +0 -0
  522. /package/umd/typings/{utils/markdown/extractAllListItemsFromMarkdown.test.d.ts → src/utils/markdown/createMarkdownChart.test.d.ts} +0 -0
  523. /package/umd/typings/{utils → src/utils}/markdown/createMarkdownTable.d.ts +0 -0
  524. /package/umd/typings/{utils/markdown/extractOneBlockFromMarkdown.test.d.ts → src/utils/markdown/createMarkdownTable.test.d.ts} +0 -0
  525. /package/umd/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.d.ts +0 -0
  526. /package/umd/typings/{utils/markdown/prettifyMarkdown.test.d.ts → src/utils/markdown/escapeMarkdownBlock.test.d.ts} +0 -0
  527. /package/umd/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.d.ts +0 -0
  528. /package/umd/typings/{utils/markdown/removeContentComments.test.d.ts → src/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts} +0 -0
  529. /package/umd/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.d.ts +0 -0
  530. /package/umd/typings/{utils/markdown/removeMarkdownFormatting.test.d.ts → src/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts} +0 -0
  531. /package/umd/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.d.ts +0 -0
  532. /package/umd/typings/{utils/normalization/capitalize.test.d.ts → src/utils/markdown/extractOneBlockFromMarkdown.test.d.ts} +0 -0
  533. /package/umd/typings/{utils → src/utils}/markdown/prettifyMarkdown.d.ts +0 -0
  534. /package/umd/typings/{utils/normalization/decapitalize.test.d.ts → src/utils/markdown/prettifyMarkdown.test.d.ts} +0 -0
  535. /package/umd/typings/{utils → src/utils}/markdown/removeContentComments.d.ts +0 -0
  536. /package/umd/typings/{utils/normalization/isValidKeyword.test.d.ts → src/utils/markdown/removeContentComments.test.d.ts} +0 -0
  537. /package/umd/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.d.ts +0 -0
  538. /package/umd/typings/{utils/normalization/nameToUriPart.test.d.ts → src/utils/markdown/removeMarkdownFormatting.test.d.ts} +0 -0
  539. /package/umd/typings/{utils → src/utils}/markdown-json/MarkdownStructure.d.ts +0 -0
  540. /package/umd/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.d.ts +0 -0
  541. /package/umd/typings/{utils/markdown/createMarkdownTable.test.d.ts → src/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts} +0 -0
  542. /package/umd/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.d.ts +0 -0
  543. /package/umd/typings/{utils/markdown/escapeMarkdownBlock.test.d.ts → src/utils/markdown-json/markdownToMarkdownStructure.test.d.ts} +0 -0
  544. /package/umd/typings/{utils → src/utils}/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +0 -0
  545. /package/umd/typings/{utils → src/utils}/normalization/IKeywords.d.ts +0 -0
  546. /package/umd/typings/{utils → src/utils}/normalization/capitalize.d.ts +0 -0
  547. /package/umd/typings/{utils/normalization/nameToUriParts.test.d.ts → src/utils/normalization/capitalize.test.d.ts} +0 -0
  548. /package/umd/typings/{utils → src/utils}/normalization/decapitalize.d.ts +0 -0
  549. /package/umd/typings/{utils/normalization/normalize-to-kebab-case.test.d.ts → src/utils/normalization/decapitalize.test.d.ts} +0 -0
  550. /package/umd/typings/{utils → src/utils}/normalization/isValidKeyword.d.ts +0 -0
  551. /package/umd/typings/{utils/normalization/normalizeTo_PascalCase.test.d.ts → src/utils/normalization/isValidKeyword.test.d.ts} +0 -0
  552. /package/umd/typings/{utils → src/utils}/normalization/nameToUriPart.d.ts +0 -0
  553. /package/umd/typings/{utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts → src/utils/normalization/nameToUriPart.test.d.ts} +0 -0
  554. /package/umd/typings/{utils → src/utils}/normalization/nameToUriParts.d.ts +0 -0
  555. /package/umd/typings/{utils/normalization/normalizeTo_camelCase.test.d.ts → src/utils/normalization/nameToUriParts.test.d.ts} +0 -0
  556. /package/umd/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.d.ts +0 -0
  557. /package/umd/typings/{utils/normalization/normalizeTo_snake_case.test.d.ts → src/utils/normalization/normalize-to-kebab-case.test.d.ts} +0 -0
  558. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.d.ts +0 -0
  559. /package/umd/typings/{utils/normalization/normalizeWhitespaces.test.d.ts → src/utils/normalization/normalizeTo_PascalCase.test.d.ts} +0 -0
  560. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.d.ts +0 -0
  561. /package/umd/typings/{utils/normalization/parseKeywords.test.d.ts → src/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts} +0 -0
  562. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.d.ts +0 -0
  563. /package/umd/typings/{utils/normalization/parseKeywordsFromString.test.d.ts → src/utils/normalization/normalizeTo_camelCase.test.d.ts} +0 -0
  564. /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.d.ts +0 -0
  565. /package/umd/typings/{utils/normalization/removeDiacritics.test.d.ts → src/utils/normalization/normalizeTo_snake_case.test.d.ts} +0 -0
  566. /package/umd/typings/{utils → src/utils}/normalization/normalizeWhitespaces.d.ts +0 -0
  567. /package/umd/typings/{utils/normalization/searchKeywords.test.d.ts → src/utils/normalization/normalizeWhitespaces.test.d.ts} +0 -0
  568. /package/umd/typings/{utils → src/utils}/normalization/parseKeywords.d.ts +0 -0
  569. /package/umd/typings/{utils/removeEmojis.test.d.ts → src/utils/normalization/parseKeywords.test.d.ts} +0 -0
  570. /package/umd/typings/{utils → src/utils}/normalization/parseKeywordsFromString.d.ts +0 -0
  571. /package/umd/typings/{utils/removeQuotes.test.d.ts → src/utils/normalization/parseKeywordsFromString.test.d.ts} +0 -0
  572. /package/umd/typings/{utils → src/utils}/normalization/removeDiacritics.d.ts +0 -0
  573. /package/umd/typings/{utils/sets/difference.test.d.ts → src/utils/normalization/removeDiacritics.test.d.ts} +0 -0
  574. /package/umd/typings/{utils → src/utils}/normalization/searchKeywords.d.ts +0 -0
  575. /package/umd/typings/{utils/sets/intersection.test.d.ts → src/utils/normalization/searchKeywords.test.d.ts} +0 -0
  576. /package/umd/typings/{utils → src/utils}/postprocessing/extractBlock.d.ts +0 -0
  577. /package/umd/typings/{utils → src/utils}/removeEmojis.d.ts +0 -0
  578. /package/umd/typings/{utils/sets/union.test.d.ts → src/utils/removeEmojis.test.d.ts} +0 -0
  579. /package/umd/typings/{utils → src/utils}/removeQuotes.d.ts +0 -0
  580. /package/umd/typings/{utils/trimCodeBlock.test.d.ts → src/utils/removeQuotes.test.d.ts} +0 -0
  581. /package/umd/typings/{utils → src/utils}/sets/difference.d.ts +0 -0
  582. /package/umd/typings/{utils/trimEndOfCodeBlock.test.d.ts → src/utils/sets/difference.test.d.ts} +0 -0
  583. /package/umd/typings/{utils → src/utils}/sets/intersection.d.ts +0 -0
  584. /package/umd/typings/{utils/unwrapResult.test.d.ts → src/utils/sets/intersection.test.d.ts} +0 -0
  585. /package/umd/typings/{utils → src/utils}/sets/union.d.ts +0 -0
  586. /package/umd/typings/{utils/validators/url/isValidUrl.test.d.ts → src/utils/sets/union.test.d.ts} +0 -0
  587. /package/umd/typings/{utils → src/utils}/trimCodeBlock.d.ts +0 -0
  588. /package/umd/typings/{utils → src/utils}/trimEndOfCodeBlock.d.ts +0 -0
  589. /package/umd/typings/{utils → src/utils}/unwrapResult.d.ts +0 -0
  590. /package/umd/typings/{utils → src/utils}/validators/url/isValidUrl.d.ts +0 -0
  591. /package/umd/typings/{version.d.ts → src/version.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -1,4 +1,5 @@
1
- import { readFile, readdir } from 'fs/promises';
1
+ import colors from 'colors';
2
+ import { access, constants, readFile, readdir } from 'fs/promises';
2
3
  import { join } from 'path';
3
4
  import spaceTrim$1, { spaceTrim } from 'spacetrim';
4
5
  import { format } from 'prettier';
@@ -124,18 +125,15 @@ function __spreadArray(to, from, pack) {
124
125
  }
125
126
 
126
127
  /**
127
- * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
128
+ * The maximum number of iterations for a loops
128
129
  */
129
- var PromptbookSyntaxError = /** @class */ (function (_super) {
130
- __extends(PromptbookSyntaxError, _super);
131
- function PromptbookSyntaxError(message) {
132
- var _this = _super.call(this, message) || this;
133
- _this.name = 'PromptbookSyntaxError';
134
- Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
135
- return _this;
136
- }
137
- return PromptbookSyntaxError;
138
- }(Error));
130
+ var LOOP_LIMIT = 1000;
131
+ /**
132
+ * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createLibraryFromDirectory`
133
+ */
134
+ var PROMPTBOOK_MAKED_BASE_FILENAME = "index";
135
+
136
+ 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:[]}];
139
137
 
140
138
  /**
141
139
  * This error indicates errors during the execution of the promptbook
@@ -176,11 +174,6 @@ function assertsExecutionSuccessful(executionResult) {
176
174
  * TODO: [🧠] Can this return type be better typed than void
177
175
  */
178
176
 
179
- /**
180
- * The maximum number of iterations for a loops
181
- */
182
- var LOOP_LIMIT = 1000;
183
-
184
177
  /**
185
178
  * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
186
179
  */
@@ -195,6 +188,20 @@ var PromptbookLogicError = /** @class */ (function (_super) {
195
188
  return PromptbookLogicError;
196
189
  }(Error));
197
190
 
191
+ /**
192
+ * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
193
+ */
194
+ var PromptbookSyntaxError = /** @class */ (function (_super) {
195
+ __extends(PromptbookSyntaxError, _super);
196
+ function PromptbookSyntaxError(message) {
197
+ var _this = _super.call(this, message) || this;
198
+ _this.name = 'PromptbookSyntaxError';
199
+ Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
200
+ return _this;
201
+ }
202
+ return PromptbookSyntaxError;
203
+ }(Error));
204
+
198
205
  /**
199
206
  * This error type indicates that the error should not happen and its last check before crashing with some other error
200
207
  */
@@ -248,7 +255,7 @@ function isValidUrl(url) {
248
255
  * @returns the same promptbook if it is logically valid
249
256
  * @throws {PromptbookLogicError} on logical error in the promptbook
250
257
  */
251
- function validatePromptbookJson(promptbook) {
258
+ function validatePromptbook(promptbook) {
252
259
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
253
260
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
254
261
  if (promptbook.promptbookUrl !== undefined) {
@@ -312,8 +319,7 @@ function validatePromptbookJson(promptbook) {
312
319
  throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
313
320
  }
314
321
  definedParameters.add(template.resultingParameterName);
315
- if (template.executionType === 'PROMPT_TEMPLATE' &&
316
- (template.modelRequirements.modelVariant === undefined)) {
322
+ if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
317
323
  throw new PromptbookLogicError(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 ")));
318
324
  }
319
325
  if (template.jokers && template.jokers.length > 0) {
@@ -383,7 +389,7 @@ function validatePromptbookJson(promptbook) {
383
389
  var loopLimit = LOOP_LIMIT;
384
390
  var _loop_2 = function () {
385
391
  if (loopLimit-- < 0) {
386
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbookJson`');
392
+ throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
387
393
  }
388
394
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
389
395
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
@@ -418,7 +424,7 @@ function validatePromptbookJson(promptbook) {
418
424
  * > * It checks:
419
425
  * > * - it has a valid structure
420
426
  * > * - ...
421
- * > ex port function validatePromptbookJson(promptbook: unknown): asserts promptbook is PromptbookJson {
427
+ * > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
422
428
  */
423
429
 
424
430
  /**
@@ -460,7 +466,7 @@ function isValidJsonString(value /* <-[👨‍⚖️] */) {
460
466
  /**
461
467
  * The version of the Promptbook library
462
468
  */
463
- var PROMPTBOOK_VERSION = '0.59.0-7';
469
+ var PROMPTBOOK_VERSION = '0.59.0-36';
464
470
 
465
471
  /**
466
472
  * Function `addUsage` will add multiple usages into one
@@ -1001,7 +1007,7 @@ function createPromptbookExecutor(options) {
1001
1007
  var _this = this;
1002
1008
  var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1003
1009
  var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
1004
- validatePromptbookJson(promptbook);
1010
+ validatePromptbook(promptbook);
1005
1011
  var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1006
1012
  function executeSingleTemplate(currentTemplate) {
1007
1013
  return __awaiter(this, void 0, void 0, function () {
@@ -1432,7 +1438,7 @@ function createPromptbookExecutor(options) {
1432
1438
  return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
1433
1439
  });
1434
1440
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
1435
- throw new UnexpectedError(spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbookJson\n "));
1441
+ throw new UnexpectedError(spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
1436
1442
  case 1:
1437
1443
  if (!!currentTemplate) return [3 /*break*/, 3];
1438
1444
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -1793,6 +1799,7 @@ var PromptbookReferenceError = /** @class */ (function (_super) {
1793
1799
  * Library of promptbooks that groups together promptbooks for an application.
1794
1800
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1795
1801
  *
1802
+ * @private use `createLibraryFromJson` instead
1796
1803
  * @see https://github.com/webgptorg/promptbook#promptbook-library
1797
1804
  */
1798
1805
  var SimplePromptbookLibrary = /** @class */ (function () {
@@ -1801,8 +1808,9 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1801
1808
  *
1802
1809
  * @param promptbooks !!!
1803
1810
  *
1811
+ * @private Use instead `createLibraryFromJson`
1804
1812
  * Note: During the construction logic of all promptbooks are validated
1805
- * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
1813
+ * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
1806
1814
  */
1807
1815
  function SimplePromptbookLibrary() {
1808
1816
  var e_1, _a;
@@ -1817,7 +1825,7 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1817
1825
  if (promptbook.promptbookUrl === undefined) {
1818
1826
  throw new PromptbookReferenceError(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 ")));
1819
1827
  }
1820
- validatePromptbookJson(promptbook);
1828
+ validatePromptbook(promptbook);
1821
1829
  // Note: [🦄]
1822
1830
  if (this.library.has(promptbook.promptbookUrl) &&
1823
1831
  promptbookJsonToString(promptbook) !==
@@ -1871,68 +1879,19 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1871
1879
  /**
1872
1880
  * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
1873
1881
  *
1874
- * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
1882
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
1875
1883
  * Note: During the construction syntax and logic of all sources are validated
1876
1884
  *
1877
1885
  * @param promptbookSources
1878
1886
  * @returns PromptbookLibrary
1879
1887
  */
1880
- function createPromptbookLibraryFromSources() {
1881
- var promptbookSources = [];
1888
+ function createLibraryFromJson() {
1889
+ var promptbooks = [];
1882
1890
  for (var _i = 0; _i < arguments.length; _i++) {
1883
- promptbookSources[_i] = arguments[_i];
1891
+ promptbooks[_i] = arguments[_i];
1884
1892
  }
1885
- return __awaiter(this, void 0, void 0, function () {
1886
- var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
1887
- var e_1, _a;
1888
- return __generator(this, function (_b) {
1889
- switch (_b.label) {
1890
- case 0:
1891
- promptbooks = new Array();
1892
- _b.label = 1;
1893
- case 1:
1894
- _b.trys.push([1, 8, 9, 10]);
1895
- promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
1896
- _b.label = 2;
1897
- case 2:
1898
- if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
1899
- source = promptbookSources_1_1.value;
1900
- promptbook = void 0;
1901
- if (!(typeof source === 'string')) return [3 /*break*/, 4];
1902
- return [4 /*yield*/, promptbookStringToJson(source)];
1903
- case 3:
1904
- // Note: When directly creating from string, no need to validate the source
1905
- // The validation is performed always before execution
1906
- promptbook = _b.sent();
1907
- return [3 /*break*/, 5];
1908
- case 4:
1909
- promptbook = source;
1910
- _b.label = 5;
1911
- case 5:
1912
- promptbooks.push(promptbook);
1913
- _b.label = 6;
1914
- case 6:
1915
- promptbookSources_1_1 = promptbookSources_1.next();
1916
- return [3 /*break*/, 2];
1917
- case 7: return [3 /*break*/, 10];
1918
- case 8:
1919
- e_1_1 = _b.sent();
1920
- e_1 = { error: e_1_1 };
1921
- return [3 /*break*/, 10];
1922
- case 9:
1923
- try {
1924
- if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
1925
- }
1926
- finally { if (e_1) throw e_1.error; }
1927
- return [7 /*endfinally*/];
1928
- case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
1929
- }
1930
- });
1931
- });
1893
+ return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
1932
1894
  }
1933
- /**
1934
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
1935
- */
1936
1895
 
1937
1896
  /* tslint:disable */
1938
1897
  function normalizeToKebabCase(sentence) {
@@ -1991,85 +1950,100 @@ function normalizeToKebabCase(sentence) {
1991
1950
 
1992
1951
  function prepareKnowledgeFromMarkdown(options) {
1993
1952
  return __awaiter(this, void 0, void 0, function () {
1994
- var content, llmTools, library, promptbook, executor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
1953
+ var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
1995
1954
  var _this = this;
1996
- return __generator(this, function (_a) {
1997
- switch (_a.label) {
1955
+ return __generator(this, function (_b) {
1956
+ switch (_b.label) {
1998
1957
  case 0:
1999
- content = options.content, llmTools = options.llmTools;
2000
- return [4 /*yield*/, createPromptbookLibraryFromSources(
2001
- /* !!!! ...(promptbookLibrary as Array<PromptbookJson>)*/ {
2002
- title: 'Prepare Knowledge from Markdown',
2003
- promptbookUrl: 'https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md',
2004
- promptbookVersion: '0.59.0-5',
2005
- parameters: [
2006
- { name: 'content', description: 'Markdown document content', isInput: true, isOutput: false },
2007
- { name: 'knowledge', description: 'The knowledge JSON object', isInput: false, isOutput: true },
2008
- ],
2009
- promptTemplates: [
2010
- {
2011
- name: 'knowledge',
2012
- title: 'Knowledge',
2013
- dependentParameterNames: ['content'],
2014
- executionType: 'PROMPT_TEMPLATE',
2015
- modelRequirements: { modelVariant: 'CHAT', modelName: 'claude-3-opus-20240229' },
2016
- 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}',
2017
- resultingParameterName: 'knowledge',
2018
- },
2019
- ],
2020
- knowledge: [],
2021
- })];
1958
+ content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
1959
+ library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
1960
+ return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
2022
1961
  case 1:
2023
- library = _a.sent();
2024
- promptbook = library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md');
2025
- executor = createPromptbookExecutor({
2026
- promptbook: promptbook,
1962
+ prepareKnowledgeFromMarkdownPromptbook = _b.sent();
1963
+ prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
1964
+ promptbook: prepareKnowledgeFromMarkdownPromptbook,
2027
1965
  tools: {
2028
1966
  llm: llmTools,
2029
1967
  script: [
2030
- /* <- TODO: Allow to just not define script tools */
1968
+ /* <- TODO: Allow to just keep script undefined */
2031
1969
  ],
2032
1970
  },
2033
1971
  });
2034
- return [4 /*yield*/, executor({ content: content })];
1972
+ return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
2035
1973
  case 2:
2036
- result = _a.sent();
1974
+ prepareKeywordsPromptbook = _b.sent();
1975
+ prepareKeywordsExecutor = createPromptbookExecutor({
1976
+ promptbook: prepareKeywordsPromptbook,
1977
+ tools: {
1978
+ llm: llmTools,
1979
+ script: [
1980
+ /* <- TODO: Allow to just keep script undefined */
1981
+ ],
1982
+ },
1983
+ });
1984
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
1985
+ case 3:
1986
+ result = _b.sent();
2037
1987
  assertsExecutionSuccessful(result);
2038
1988
  outputParameters = result.outputParameters;
2039
1989
  knowledgeRaw = outputParameters.knowledge;
2040
1990
  knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
1991
+ if (isVerbose) {
1992
+ console.info('knowledgeTextPieces:', knowledgeTextPieces);
1993
+ }
2041
1994
  return [4 /*yield*/, Promise.all(knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
2042
- var name, title, content, keywords, index, sources;
2043
- return __generator(this, function (_a) {
2044
- name = "piece-".concat(i);
2045
- title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
2046
- content = spaceTrim$1(knowledgeTextPiece);
2047
- keywords = [];
2048
- index = [];
2049
- sources = [];
2050
- try {
2051
- // TODO: !!!! Summarize name and title from the content
2052
- title = spaceTrim$1(knowledgeTextPiece.substring(0, 30));
2053
- name = normalizeToKebabCase(title);
2054
- // TODO: !!!! Extract keywords via prompt
2055
- // TODO: !!!! Index through LLM model
2056
- // TODO: [🖖] !!!! Make system for sources and identification of sources
2057
- }
2058
- catch (error) {
2059
- console.error(error);
1995
+ var name, title, content, keywords, index, sources, result_1, _a, outputParameters_1, keywordsRaw, error_1;
1996
+ return __generator(this, function (_b) {
1997
+ switch (_b.label) {
1998
+ case 0:
1999
+ name = "piece-".concat(i);
2000
+ title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
2001
+ content = spaceTrim$1(knowledgeTextPiece);
2002
+ keywords = [];
2003
+ index = [];
2004
+ sources = [];
2005
+ _b.label = 1;
2006
+ case 1:
2007
+ _b.trys.push([1, 3, , 4]);
2008
+ // TODO: !!!! Summarize name and title from the content
2009
+ title = spaceTrim$1(knowledgeTextPiece.substring(0, 30));
2010
+ name = normalizeToKebabCase(title);
2011
+ return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
2012
+ case 2:
2013
+ result_1 = _b.sent();
2014
+ _a = result_1.outputParameters, outputParameters_1 = _a === void 0 ? {} : _a;
2015
+ keywordsRaw = outputParameters_1.keywords;
2016
+ keywords = (keywordsRaw || '')
2017
+ .split(',')
2018
+ .map(function (keyword) { return keyword.trim(); })
2019
+ .filter(function (keyword) { return keyword !== ''; });
2020
+ if (isVerbose) {
2021
+ console.info("Keywords for \"".concat(title, "\":"), keywords);
2022
+ }
2023
+ // ---
2024
+ // TODO: !!!! Index through LLM model
2025
+ index.push({
2026
+ modelName: 'fake-model',
2027
+ position: new Array(25).fill(0).map(function () { return Math.random() * 2 - 1; }),
2028
+ });
2029
+ return [3 /*break*/, 4];
2030
+ case 3:
2031
+ error_1 = _b.sent();
2032
+ console.error(error_1);
2033
+ return [3 /*break*/, 4];
2034
+ case 4: return [2 /*return*/, {
2035
+ name: name,
2036
+ title: title,
2037
+ content: content,
2038
+ keywords: keywords,
2039
+ index: index,
2040
+ sources: sources,
2041
+ }];
2060
2042
  }
2061
- return [2 /*return*/, {
2062
- name: name,
2063
- title: title,
2064
- content: content,
2065
- keywords: keywords,
2066
- index: index,
2067
- sources: sources,
2068
- }];
2069
2043
  });
2070
2044
  }); }))];
2071
- case 3:
2072
- knowledge = _a.sent();
2045
+ case 4:
2046
+ knowledge = _b.sent();
2073
2047
  return [2 /*return*/, knowledge];
2074
2048
  }
2075
2049
  });
@@ -2918,9 +2892,279 @@ function titleToName(value) {
2918
2892
  return value;
2919
2893
  }
2920
2894
 
2895
+ /**
2896
+ * Compile promptbook from string (markdown) format to JSON format synchronously
2897
+ *
2898
+ * Note: There are two similar functions:
2899
+ * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
2900
+ * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
2901
+ *
2902
+ * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
2903
+ * @param options - Options and tools for the compilation
2904
+ * @returns {Promptbook} compiled in JSON format (.ptbk.json)
2905
+ * @throws {PromptbookSyntaxError} if the promptbook string is not valid
2906
+ *
2907
+ * Note: This function does not validate logic of the pipeline only the syntax
2908
+ * Note: This function acts as compilation process
2909
+ */
2910
+ function promptbookStringToJsonSync(promptbookString) {
2911
+ var e_1, _a, e_2, _b;
2912
+ var promptbookJson = {
2913
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2914
+ title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2915
+ promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
2916
+ promptbookVersion: PROMPTBOOK_VERSION,
2917
+ description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
2918
+ parameters: [],
2919
+ promptTemplates: [],
2920
+ knowledge: [],
2921
+ };
2922
+ // =============================================================
2923
+ // Note: 1️⃣ Normalization of the PROMPTBOOK string
2924
+ promptbookString = removeContentComments(promptbookString);
2925
+ promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2926
+ promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2927
+ // =============================================================
2928
+ ///Note: 2️⃣ Function for adding parameters
2929
+ var addParam = function (parameterCommand) {
2930
+ var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
2931
+ var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2932
+ if (existingParameter &&
2933
+ existingParameter.description &&
2934
+ existingParameter.description !== parameterDescription &&
2935
+ parameterDescription) {
2936
+ throw new PromptbookSyntaxError(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 "); }));
2937
+ }
2938
+ if (existingParameter) {
2939
+ if (parameterDescription) {
2940
+ existingParameter.description = parameterDescription;
2941
+ }
2942
+ }
2943
+ else {
2944
+ promptbookJson.parameters.push({
2945
+ name: parameterName,
2946
+ description: parameterDescription || undefined,
2947
+ isInput: isInput,
2948
+ isOutput: isOutput,
2949
+ });
2950
+ }
2951
+ };
2952
+ // =============================================================
2953
+ // Note: 3️⃣ Parse the dynamic part - the template pipeline
2954
+ var markdownStructure = markdownToMarkdownStructure(promptbookString);
2955
+ var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
2956
+ if (markdownStructureDeepness !== 2) {
2957
+ throw new PromptbookSyntaxError(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 ")));
2958
+ }
2959
+ promptbookJson.title = markdownStructure.title;
2960
+ // TODO: [1] DRY description
2961
+ var description = markdownStructure.content;
2962
+ // Note: Remove codeblocks
2963
+ description = description.split(/^```.*^```/gms).join('');
2964
+ //Note: Remove lists and return statement
2965
+ description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
2966
+ description = spaceTrim(description);
2967
+ if (description === '') {
2968
+ description = undefined;
2969
+ }
2970
+ promptbookJson.description = description;
2971
+ var defaultModelRequirements = {};
2972
+ var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
2973
+ try {
2974
+ for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
2975
+ var listItem = listItems_1_1.value;
2976
+ var command = parseCommand(listItem);
2977
+ switch (command.type) {
2978
+ case 'PROMPTBOOK_URL':
2979
+ promptbookJson.promptbookUrl = command.promptbookUrl.href;
2980
+ break;
2981
+ case 'PROMPTBOOK_VERSION':
2982
+ promptbookJson.promptbookVersion = command.promptbookVersion;
2983
+ break;
2984
+ case 'MODEL':
2985
+ defaultModelRequirements[command.key] = command.value;
2986
+ break;
2987
+ case 'PARAMETER':
2988
+ addParam(command);
2989
+ break;
2990
+ default:
2991
+ throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
2992
+ }
2993
+ }
2994
+ }
2995
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2996
+ finally {
2997
+ try {
2998
+ if (listItems_1_1 && !listItems_1_1.done && (_a = listItems_1.return)) _a.call(listItems_1);
2999
+ }
3000
+ finally { if (e_1) throw e_1.error; }
3001
+ }
3002
+ var _loop_1 = function (section) {
3003
+ var e_3, _e;
3004
+ // TODO: Parse prompt template description (the content out of the codeblock and lists)
3005
+ var templateModelRequirements = __assign({}, defaultModelRequirements);
3006
+ var listItems_3 = extractAllListItemsFromMarkdown(section.content);
3007
+ var dependentParameterNames = new Set();
3008
+ var executionType = 'PROMPT_TEMPLATE';
3009
+ var jokers = [];
3010
+ var postprocessing = [];
3011
+ var expectAmount = {};
3012
+ var expectFormat = undefined;
3013
+ var isExecutionTypeChanged = false;
3014
+ try {
3015
+ 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()) {
3016
+ var listItem = listItems_2_1.value;
3017
+ var command = parseCommand(listItem);
3018
+ switch (command.type) {
3019
+ case 'JOKER':
3020
+ jokers.push(command.parameterName);
3021
+ dependentParameterNames.add(command.parameterName);
3022
+ break;
3023
+ case 'EXECUTE':
3024
+ if (isExecutionTypeChanged) {
3025
+ throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3026
+ }
3027
+ executionType = command.executionType;
3028
+ isExecutionTypeChanged = true;
3029
+ break;
3030
+ case 'MODEL':
3031
+ templateModelRequirements[command.key] = command.value;
3032
+ break;
3033
+ case 'PARAMETER':
3034
+ // Note: This is just for detecting resulitng parameter name
3035
+ addParam(command);
3036
+ break;
3037
+ case 'POSTPROCESS':
3038
+ postprocessing.push(command.functionName);
3039
+ break;
3040
+ case 'EXPECT_AMOUNT':
3041
+ // eslint-disable-next-line no-case-declarations
3042
+ var unit = command.unit.toLowerCase();
3043
+ expectAmount[unit] = expectAmount[unit] || {};
3044
+ if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
3045
+ if (expectAmount[unit].min !== undefined) {
3046
+ throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3047
+ }
3048
+ expectAmount[unit].min = command.amount;
3049
+ } /* not else */
3050
+ if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
3051
+ if (expectAmount[unit].max !== undefined) {
3052
+ throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3053
+ }
3054
+ expectAmount[unit].max = command.amount;
3055
+ }
3056
+ break;
3057
+ case 'EXPECT_FORMAT':
3058
+ if (expectFormat !== undefined && command.format !== expectFormat) {
3059
+ throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3060
+ }
3061
+ expectFormat = command.format;
3062
+ break;
3063
+ default:
3064
+ throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3065
+ }
3066
+ }
3067
+ }
3068
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
3069
+ finally {
3070
+ try {
3071
+ if (listItems_2_1 && !listItems_2_1.done && (_e = listItems_2.return)) _e.call(listItems_2);
3072
+ }
3073
+ finally { if (e_3) throw e_3.error; }
3074
+ }
3075
+ var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
3076
+ if (executionType === 'SCRIPT') {
3077
+ if (!language) {
3078
+ throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
3079
+ }
3080
+ else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
3081
+ throw new PromptbookSyntaxError(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 "); }));
3082
+ }
3083
+ }
3084
+ var lastLine = section.content.split('\n').pop();
3085
+ var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
3086
+ if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
3087
+ throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3088
+ // TODO: Show code of invalid sections each time + DRY
3089
+ section.content
3090
+ .split('\n')
3091
+ .map(function (line) { return "> ".concat(line); })
3092
+ .join('\n')), "\n "); }));
3093
+ }
3094
+ var resultingParameterName = match.groups.resultingParamName;
3095
+ // TODO: [1] DRY description
3096
+ var description_1 = section.content;
3097
+ // Note: Remove codeblocks
3098
+ description_1 = description_1.split(/^```.*^```/gms).join('');
3099
+ //Note: Remove lists and return statement
3100
+ description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3101
+ description_1 = spaceTrim(description_1);
3102
+ if (description_1 === '') {
3103
+ description_1 = undefined;
3104
+ }
3105
+ if (Object.keys(jokers).length === 0) {
3106
+ jokers = undefined;
3107
+ }
3108
+ if (Object.keys(expectAmount).length === 0) {
3109
+ expectAmount = undefined;
3110
+ }
3111
+ if (Object.keys(postprocessing).length === 0) {
3112
+ postprocessing = undefined;
3113
+ }
3114
+ dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
3115
+ if (templateModelRequirements.modelVariant === undefined) {
3116
+ templateModelRequirements.modelVariant = 'CHAT';
3117
+ }
3118
+ var template = {
3119
+ name: titleToName(section.title),
3120
+ title: section.title,
3121
+ description: description_1,
3122
+ dependentParameterNames: Array.from(dependentParameterNames),
3123
+ executionType: executionType,
3124
+ jokers: jokers,
3125
+ postprocessing: postprocessing,
3126
+ expectations: expectAmount,
3127
+ expectFormat: expectFormat,
3128
+ modelRequirements: templateModelRequirements,
3129
+ contentLanguage: executionType === 'SCRIPT' ? language : undefined,
3130
+ content: content,
3131
+ resultingParameterName: resultingParameterName,
3132
+ };
3133
+ if (executionType !== 'PROMPT_TEMPLATE') {
3134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3135
+ delete template.modelRequirements;
3136
+ }
3137
+ promptbookJson.promptTemplates.push(template);
3138
+ };
3139
+ try {
3140
+ for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
3141
+ var section = _d.value;
3142
+ _loop_1(section);
3143
+ }
3144
+ }
3145
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3146
+ finally {
3147
+ try {
3148
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
3149
+ }
3150
+ finally { if (e_2) throw e_2.error; }
3151
+ }
3152
+ // =============================================================
3153
+ return promptbookJson;
3154
+ }
3155
+ /**
3156
+ * TODO: Report here line/column of error
3157
+ * TODO: Use spaceTrim more effectively
3158
+ * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
3159
+ */
3160
+
2921
3161
  /**
2922
3162
  * Compile promptbook from string (markdown) format to JSON format
2923
3163
  *
3164
+ * Note: There are two similar functions:
3165
+ * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
3166
+ * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
3167
+ *
2924
3168
  * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
2925
3169
  * @param options - Options and tools for the compilation
2926
3170
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
@@ -2932,262 +3176,29 @@ function titleToName(value) {
2932
3176
  function promptbookStringToJson(promptbookString, options) {
2933
3177
  if (options === void 0) { options = {}; }
2934
3178
  return __awaiter(this, void 0, void 0, function () {
2935
- var llmTools, promptbookJson, knowledge, addParam, markdownStructure, markdownStructureDeepness, description, defaultModelRequirements, listItems, listItems_1, listItems_1_1, listItem, command, _loop_1, _a, _b, section;
2936
- var e_1, _c, e_2, _d;
2937
- return __generator(this, function (_e) {
2938
- switch (_e.label) {
3179
+ var llmTools, knowledge, promptbookJson;
3180
+ return __generator(this, function (_a) {
3181
+ switch (_a.label) {
2939
3182
  case 0:
2940
3183
  llmTools = options.llmTools;
2941
- promptbookJson = {
2942
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2943
- title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2944
- promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
2945
- promptbookVersion: PROMPTBOOK_VERSION,
2946
- description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
2947
- parameters: [],
2948
- promptTemplates: [],
2949
- knowledge: [],
2950
- };
2951
3184
  if (!llmTools) return [3 /*break*/, 2];
2952
3185
  return [4 /*yield*/, prepareKnowledgeFromMarkdown({
2953
3186
  content: 'Roses are red, violets are blue, programmers use Promptbook, users too',
2954
3187
  llmTools: llmTools,
2955
3188
  })];
2956
3189
  case 1:
2957
- knowledge = _e.sent();
3190
+ knowledge = _a.sent();
2958
3191
  console.info('!!!! knowledge', knowledge);
2959
- _e.label = 2;
3192
+ _a.label = 2;
2960
3193
  case 2:
2961
- // =============================================================
2962
- // Note: 1️⃣ Normalization of the PROMPTBOOK string
2963
- promptbookString = removeContentComments(promptbookString);
2964
- promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2965
- promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2966
- addParam = function (parameterCommand) {
2967
- var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
2968
- var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2969
- if (existingParameter &&
2970
- existingParameter.description &&
2971
- existingParameter.description !== parameterDescription &&
2972
- parameterDescription) {
2973
- throw new PromptbookSyntaxError(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 "); }));
2974
- }
2975
- if (existingParameter) {
2976
- if (parameterDescription) {
2977
- existingParameter.description = parameterDescription;
2978
- }
2979
- }
2980
- else {
2981
- promptbookJson.parameters.push({
2982
- name: parameterName,
2983
- description: parameterDescription || undefined,
2984
- isInput: isInput,
2985
- isOutput: isOutput,
2986
- });
2987
- }
2988
- };
2989
- markdownStructure = markdownToMarkdownStructure(promptbookString);
2990
- markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
2991
- if (markdownStructureDeepness !== 2) {
2992
- throw new PromptbookSyntaxError(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 ")));
2993
- }
2994
- promptbookJson.title = markdownStructure.title;
2995
- description = markdownStructure.content;
2996
- // Note: Remove codeblocks
2997
- description = description.split(/^```.*^```/gms).join('');
2998
- //Note: Remove lists and return statement
2999
- description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3000
- description = spaceTrim(description);
3001
- if (description === '') {
3002
- description = undefined;
3003
- }
3004
- promptbookJson.description = description;
3005
- defaultModelRequirements = {};
3006
- listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
3007
- try {
3008
- for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
3009
- listItem = listItems_1_1.value;
3010
- command = parseCommand(listItem);
3011
- switch (command.type) {
3012
- case 'PROMPTBOOK_URL':
3013
- promptbookJson.promptbookUrl = command.promptbookUrl.href;
3014
- break;
3015
- case 'PROMPTBOOK_VERSION':
3016
- promptbookJson.promptbookVersion = command.promptbookVersion;
3017
- break;
3018
- case 'MODEL':
3019
- defaultModelRequirements[command.key] = command.value;
3020
- break;
3021
- case 'PARAMETER':
3022
- addParam(command);
3023
- break;
3024
- default:
3025
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
3026
- }
3027
- }
3028
- }
3029
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3030
- finally {
3031
- try {
3032
- if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
3033
- }
3034
- finally { if (e_1) throw e_1.error; }
3035
- }
3036
- _loop_1 = function (section) {
3037
- var e_3, _f;
3038
- // TODO: Parse prompt template description (the content out of the codeblock and lists)
3039
- var templateModelRequirements = __assign({}, defaultModelRequirements);
3040
- var listItems_3 = extractAllListItemsFromMarkdown(section.content);
3041
- var dependentParameterNames = new Set();
3042
- var executionType = 'PROMPT_TEMPLATE';
3043
- var jokers = [];
3044
- var postprocessing = [];
3045
- var expectAmount = {};
3046
- var expectFormat = undefined;
3047
- var isExecutionTypeChanged = false;
3048
- try {
3049
- 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()) {
3050
- var listItem = listItems_2_1.value;
3051
- var command = parseCommand(listItem);
3052
- switch (command.type) {
3053
- case 'JOKER':
3054
- jokers.push(command.parameterName);
3055
- dependentParameterNames.add(command.parameterName);
3056
- break;
3057
- case 'EXECUTE':
3058
- if (isExecutionTypeChanged) {
3059
- throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3060
- }
3061
- executionType = command.executionType;
3062
- isExecutionTypeChanged = true;
3063
- break;
3064
- case 'MODEL':
3065
- templateModelRequirements[command.key] = command.value;
3066
- break;
3067
- case 'PARAMETER':
3068
- // Note: This is just for detecting resulitng parameter name
3069
- addParam(command);
3070
- break;
3071
- case 'POSTPROCESS':
3072
- postprocessing.push(command.functionName);
3073
- break;
3074
- case 'EXPECT_AMOUNT':
3075
- // eslint-disable-next-line no-case-declarations
3076
- var unit = command.unit.toLowerCase();
3077
- expectAmount[unit] = expectAmount[unit] || {};
3078
- if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
3079
- if (expectAmount[unit].min !== undefined) {
3080
- throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3081
- }
3082
- expectAmount[unit].min = command.amount;
3083
- } /* not else */
3084
- if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
3085
- if (expectAmount[unit].max !== undefined) {
3086
- throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3087
- }
3088
- expectAmount[unit].max = command.amount;
3089
- }
3090
- break;
3091
- case 'EXPECT_FORMAT':
3092
- if (expectFormat !== undefined && command.format !== expectFormat) {
3093
- throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3094
- }
3095
- expectFormat = command.format;
3096
- break;
3097
- default:
3098
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3099
- }
3100
- }
3101
- }
3102
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3103
- finally {
3104
- try {
3105
- if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
3106
- }
3107
- finally { if (e_3) throw e_3.error; }
3108
- }
3109
- var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
3110
- if (executionType === 'SCRIPT') {
3111
- if (!language) {
3112
- throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
3113
- }
3114
- else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
3115
- throw new PromptbookSyntaxError(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 "); }));
3116
- }
3117
- }
3118
- var lastLine = section.content.split('\n').pop();
3119
- var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
3120
- if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
3121
- throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3122
- // TODO: Show code of invalid sections each time + DRY
3123
- section.content
3124
- .split('\n')
3125
- .map(function (line) { return "> ".concat(line); })
3126
- .join('\n')), "\n "); }));
3127
- }
3128
- var resultingParameterName = match.groups.resultingParamName;
3129
- // TODO: [1] DRY description
3130
- var description_1 = section.content;
3131
- // Note: Remove codeblocks
3132
- description_1 = description_1.split(/^```.*^```/gms).join('');
3133
- //Note: Remove lists and return statement
3134
- description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
3135
- description_1 = spaceTrim(description_1);
3136
- if (description_1 === '') {
3137
- description_1 = undefined;
3138
- }
3139
- if (Object.keys(jokers).length === 0) {
3140
- jokers = undefined;
3141
- }
3142
- if (Object.keys(expectAmount).length === 0) {
3143
- expectAmount = undefined;
3144
- }
3145
- if (Object.keys(postprocessing).length === 0) {
3146
- postprocessing = undefined;
3147
- }
3148
- dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
3149
- if (templateModelRequirements.modelVariant === undefined) {
3150
- templateModelRequirements.modelVariant = 'CHAT';
3151
- }
3152
- promptbookJson.promptTemplates.push({
3153
- name: titleToName(section.title),
3154
- title: section.title,
3155
- description: description_1,
3156
- dependentParameterNames: Array.from(dependentParameterNames),
3157
- executionType: executionType,
3158
- jokers: jokers,
3159
- postprocessing: postprocessing,
3160
- expectations: expectAmount,
3161
- expectFormat: expectFormat,
3162
- modelRequirements: templateModelRequirements,
3163
- contentLanguage: executionType === 'SCRIPT' ? language : undefined,
3164
- content: content,
3165
- resultingParameterName: resultingParameterName,
3166
- });
3167
- };
3168
- try {
3169
- for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
3170
- section = _b.value;
3171
- _loop_1(section);
3172
- }
3173
- }
3174
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3175
- finally {
3176
- try {
3177
- if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
3178
- }
3179
- finally { if (e_2) throw e_2.error; }
3180
- }
3181
- // =============================================================
3194
+ promptbookJson = promptbookStringToJsonSync(promptbookString);
3182
3195
  return [2 /*return*/, promptbookJson];
3183
3196
  }
3184
3197
  });
3185
3198
  });
3186
3199
  }
3187
3200
  /**
3188
- * TODO: Report here line/column of error
3189
- * TODO: Use spaceTrim more effectively
3190
- * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
3201
+ * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3191
3202
  */
3192
3203
 
3193
3204
  /**
@@ -3224,19 +3235,19 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
3224
3235
  * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
3225
3236
  *
3226
3237
  * Note: This is useful as internal tool for other constructor functions like
3227
- * `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
3238
+ * `createLibraryFromUrl` or `createLibraryFromDirectory`
3228
3239
  * Consider using those functions instead of this one
3229
3240
  *
3230
3241
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3231
3242
  * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
3232
3243
  *
3233
- * Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
3244
+ * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
3234
3245
  *
3235
3246
  * @param promptbookSourcesPromiseOrFactory
3236
3247
  * @returns PromptbookLibrary
3237
3248
  * @deprecated Do not use, it will became internal tool for other constructor functions
3238
3249
  */
3239
- function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3250
+ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3240
3251
  var library;
3241
3252
  function forSources() {
3242
3253
  return __awaiter(this, void 0, void 0, function () {
@@ -3251,9 +3262,7 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3251
3262
  return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3252
3263
  case 1:
3253
3264
  promptbookSources = _a.sent();
3254
- return [4 /*yield*/, createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
3255
- case 2:
3256
- library = _a.sent();
3265
+ library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3257
3266
  return [2 /*return*/];
3258
3267
  }
3259
3268
  });
@@ -3301,9 +3310,6 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3301
3310
  isResponsibleForPrompt: isResponsibleForPrompt,
3302
3311
  };
3303
3312
  }
3304
- /**
3305
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3306
- */
3307
3313
 
3308
3314
  /**
3309
3315
  * Constructs Promptbook from given directory
@@ -3314,32 +3320,42 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3314
3320
  * @param options - Misc options for the library
3315
3321
  * @returns PromptbookLibrary
3316
3322
  */
3317
- function createPromptbookLibraryFromDirectory(path, options) {
3323
+ function createLibraryFromDirectory(path, options) {
3318
3324
  return __awaiter(this, void 0, void 0, function () {
3319
- var _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3325
+ var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3320
3326
  var _this = this;
3321
3327
  return __generator(this, function (_f) {
3322
3328
  switch (_f.label) {
3323
3329
  case 0:
3324
3330
  if (!isRunningInNode()) {
3325
- throw new Error('Function `createPromptbookLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3331
+ throw new Error('Function `createLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3332
+ }
3333
+ makedLibraryFilePath = join(path, "".concat(PROMPTBOOK_MAKED_BASE_FILENAME, ".json"));
3334
+ return [4 /*yield*/, access(makedLibraryFilePath, constants.R_OK)
3335
+ .then(function () { return true; })
3336
+ .catch(function () { return false; })];
3337
+ case 1:
3338
+ makedLibraryFileExists = _f.sent();
3339
+ if (!makedLibraryFileExists) {
3340
+ console.info(colors.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.")));
3341
+ }
3342
+ else {
3343
+ colors.green("(In future, not implemented yet) Using your prebuild promptbook library ".concat(makedLibraryFilePath));
3344
+ // TODO: !! Implement;
3326
3345
  }
3327
3346
  _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;
3328
- library = createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3347
+ library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3329
3348
  var fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
3330
3349
  var e_1, _a;
3331
3350
  return __generator(this, function (_b) {
3332
3351
  switch (_b.label) {
3333
3352
  case 0:
3334
3353
  if (isVerbose) {
3335
- console.info("Creating promptbook library from path ".concat(path));
3354
+ console.info("Creating promptbook library from path ".concat(path.split('\\').join('/')));
3336
3355
  }
3337
3356
  return [4 /*yield*/, listAllFiles(path, isRecursive)];
3338
3357
  case 1:
3339
3358
  fileNames = _b.sent();
3340
- if (isVerbose) {
3341
- console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive, fileNames: fileNames });
3342
- }
3343
3359
  promptbooks = [];
3344
3360
  _loop_1 = function (fileName) {
3345
3361
  var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
@@ -3359,7 +3375,7 @@ function createPromptbookLibraryFromDirectory(path, options) {
3359
3375
  case 3:
3360
3376
  if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 5];
3361
3377
  if (isVerbose) {
3362
- console.info("Loading ".concat(fileName));
3378
+ console.info("Loading ".concat(fileName.split('\\').join('/')));
3363
3379
  }
3364
3380
  _d = (_c = JSON).parse;
3365
3381
  return [4 /*yield*/, readFile(fileName, 'utf8')];
@@ -3369,7 +3385,7 @@ function createPromptbookLibraryFromDirectory(path, options) {
3369
3385
  return [3 /*break*/, 6];
3370
3386
  case 5:
3371
3387
  if (isVerbose) {
3372
- console.info("Skipping file ".concat(fileName));
3388
+ console.info("Skipping file ".concat(fileName.split('\\').join('/')));
3373
3389
  }
3374
3390
  _e.label = 6;
3375
3391
  case 6:
@@ -3377,17 +3393,17 @@ function createPromptbookLibraryFromDirectory(path, options) {
3377
3393
  if (promptbook !== null) {
3378
3394
  if (!promptbook.promptbookUrl) {
3379
3395
  if (isVerbose) {
3380
- console.info("Not loading ".concat(fileName, " - missing URL"));
3396
+ console.info("Not loading ".concat(fileName.split('\\').join('/'), " - missing URL"));
3381
3397
  }
3382
3398
  }
3383
3399
  else {
3384
3400
  if (isVerbose) {
3385
- console.info("Loading ".concat(fileName));
3401
+ console.info("Loading ".concat(fileName.split('\\').join('/')));
3386
3402
  }
3387
3403
  if (!isCrashOnError) {
3388
3404
  // Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
3389
3405
  // But be handled in current try-catch block
3390
- validatePromptbookJson(promptbook);
3406
+ validatePromptbook(promptbook);
3391
3407
  }
3392
3408
  // Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
3393
3409
  promptbooks.push(promptbook);
@@ -3439,12 +3455,12 @@ function createPromptbookLibraryFromDirectory(path, options) {
3439
3455
  }
3440
3456
  });
3441
3457
  }); });
3442
- if (!(isLazyLoaded === false)) return [3 /*break*/, 2];
3458
+ if (!(isLazyLoaded === false)) return [3 /*break*/, 3];
3443
3459
  return [4 /*yield*/, library.listPromptbooks()];
3444
- case 1:
3460
+ case 2:
3445
3461
  _f.sent();
3446
- _f.label = 2;
3447
- case 2: return [2 /*return*/, library];
3462
+ _f.label = 3;
3463
+ case 3: return [2 /*return*/, library];
3448
3464
  }
3449
3465
  });
3450
3466
  });
@@ -3455,7 +3471,7 @@ function createPromptbookLibraryFromDirectory(path, options) {
3455
3471
  * @param path
3456
3472
  * @param isRecursive
3457
3473
  * @returns List of all files in the directory
3458
- * @private internal function for `createPromptbookLibraryFromDirectory`
3474
+ * @private internal function for `createLibraryFromDirectory`
3459
3475
  */
3460
3476
  function listAllFiles(path, isRecursive) {
3461
3477
  return __awaiter(this, void 0, void 0, function () {
@@ -3512,5 +3528,5 @@ function listAllFiles(path, isRecursive) {
3512
3528
  * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3513
3529
  */
3514
3530
 
3515
- export { PROMPTBOOK_VERSION, createPromptbookLibraryFromDirectory };
3531
+ export { PROMPTBOOK_VERSION, createLibraryFromDirectory };
3516
3532
  //# sourceMappingURL=index.es.js.map